From 5a079a2d114f96d4847d1ee305d5b7c16eeec50e Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 27 Dec 2025 12:03:39 -0800 Subject: Initial commit --- contrib/SDL-3.2.8/src/video/SDL_RLEaccel.c | 1576 + contrib/SDL-3.2.8/src/video/SDL_RLEaccel_c.h | 32 + contrib/SDL-3.2.8/src/video/SDL_blit.c | 290 + contrib/SDL-3.2.8/src/video/SDL_blit.h | 751 + contrib/SDL-3.2.8/src/video/SDL_blit_0.c | 972 + contrib/SDL-3.2.8/src/video/SDL_blit_1.c | 563 + contrib/SDL-3.2.8/src/video/SDL_blit_A.c | 1461 + contrib/SDL-3.2.8/src/video/SDL_blit_N.c | 2954 ++ contrib/SDL-3.2.8/src/video/SDL_blit_auto.c | 11542 ++++++ contrib/SDL-3.2.8/src/video/SDL_blit_auto.h | 34 + contrib/SDL-3.2.8/src/video/SDL_blit_copy.c | 110 + contrib/SDL-3.2.8/src/video/SDL_blit_copy.h | 27 + contrib/SDL-3.2.8/src/video/SDL_blit_slow.c | 996 + contrib/SDL-3.2.8/src/video/SDL_blit_slow.h | 30 + contrib/SDL-3.2.8/src/video/SDL_bmp.c | 879 + contrib/SDL-3.2.8/src/video/SDL_clipboard.c | 474 + contrib/SDL-3.2.8/src/video/SDL_clipboard_c.h | 46 + contrib/SDL-3.2.8/src/video/SDL_egl.c | 1339 + contrib/SDL-3.2.8/src/video/SDL_egl_c.h | 171 + contrib/SDL-3.2.8/src/video/SDL_fillrect.c | 369 + contrib/SDL-3.2.8/src/video/SDL_pixels.c | 1530 + contrib/SDL-3.2.8/src/video/SDL_pixels_c.h | 57 + contrib/SDL-3.2.8/src/video/SDL_rect.c | 116 + contrib/SDL-3.2.8/src/video/SDL_rect_c.h | 29 + contrib/SDL-3.2.8/src/video/SDL_rect_impl.h | 465 + contrib/SDL-3.2.8/src/video/SDL_stb.c | 121 + contrib/SDL-3.2.8/src/video/SDL_stb_c.h | 31 + contrib/SDL-3.2.8/src/video/SDL_stretch.c | 978 + contrib/SDL-3.2.8/src/video/SDL_surface.c | 2995 ++ contrib/SDL-3.2.8/src/video/SDL_surface_c.h | 92 + contrib/SDL-3.2.8/src/video/SDL_sysvideo.h | 602 + contrib/SDL-3.2.8/src/video/SDL_video.c | 6130 ++++ contrib/SDL-3.2.8/src/video/SDL_video_c.h | 69 + .../SDL-3.2.8/src/video/SDL_video_unsupported.c | 115 + contrib/SDL-3.2.8/src/video/SDL_vulkan_internal.h | 91 + contrib/SDL-3.2.8/src/video/SDL_vulkan_utils.c | 487 + contrib/SDL-3.2.8/src/video/SDL_yuv.c | 2592 ++ contrib/SDL-3.2.8/src/video/SDL_yuv_c.h | 36 + .../src/video/android/SDL_androidclipboard.c | 44 + .../src/video/android/SDL_androidclipboard.h | 30 + .../src/video/android/SDL_androidevents.c | 269 + .../src/video/android/SDL_androidevents.h | 26 + .../SDL-3.2.8/src/video/android/SDL_androidgl.c | 88 + .../SDL-3.2.8/src/video/android/SDL_androidgl.h | 31 + .../src/video/android/SDL_androidkeyboard.c | 468 + .../src/video/android/SDL_androidkeyboard.h | 32 + .../src/video/android/SDL_androidmessagebox.c | 33 + .../src/video/android/SDL_androidmessagebox.h | 27 + .../SDL-3.2.8/src/video/android/SDL_androidmouse.c | 250 + .../SDL-3.2.8/src/video/android/SDL_androidmouse.h | 31 + .../SDL-3.2.8/src/video/android/SDL_androidpen.c | 98 + .../SDL-3.2.8/src/video/android/SDL_androidpen.h | 25 + .../SDL-3.2.8/src/video/android/SDL_androidtouch.c | 96 + .../SDL-3.2.8/src/video/android/SDL_androidtouch.h | 27 + .../SDL-3.2.8/src/video/android/SDL_androidvideo.c | 331 + .../SDL-3.2.8/src/video/android/SDL_androidvideo.h | 52 + .../src/video/android/SDL_androidvulkan.c | 171 + .../src/video/android/SDL_androidvulkan.h | 52 + .../src/video/android/SDL_androidwindow.c | 204 + .../src/video/android/SDL_androidwindow.h | 51 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.h | 34 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.m | 262 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.h | 33 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.m | 680 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.h | 36 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.m | 604 + .../src/video/cocoa/SDL_cocoamessagebox.h | 27 + .../src/video/cocoa/SDL_cocoamessagebox.m | 145 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.h | 66 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.m | 182 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.h | 45 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.m | 716 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.h | 51 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.m | 591 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.h | 88 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.m | 559 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.h | 48 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.m | 156 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.h | 32 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.m | 178 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.h | 28 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.m | 54 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.h | 71 + contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.m | 337 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.h | 52 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.m | 304 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h | 199 + .../SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.m | 3277 ++ contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h | 103 + .../src/video/directx/SDL_d3d12_xbox_cmacros.h | 4761 +++ contrib/SDL-3.2.8/src/video/directx/d3d12.h | 34949 +++++++++++++++++++ .../SDL-3.2.8/src/video/directx/d3d12sdklayers.h | 4267 +++ .../src/video/directx/gen_xbox_cmacros.cs | 91 + contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c | 38 + .../SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h | 31 + .../src/video/dummy/SDL_nullframebuffer.c | 78 + .../src/video/dummy/SDL_nullframebuffer_c.h | 31 + contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c | 182 + contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h | 28 + .../src/video/emscripten/SDL_emscriptenevents.c | 1117 + .../src/video/emscripten/SDL_emscriptenevents.h | 31 + .../video/emscripten/SDL_emscriptenframebuffer.c | 161 + .../video/emscripten/SDL_emscriptenframebuffer.h | 30 + .../src/video/emscripten/SDL_emscriptenmouse.c | 216 + .../src/video/emscripten/SDL_emscriptenmouse.h | 34 + .../src/video/emscripten/SDL_emscriptenopengles.c | 162 + .../src/video/emscripten/SDL_emscriptenopengles.h | 43 + .../src/video/emscripten/SDL_emscriptenvideo.c | 459 + .../src/video/emscripten/SDL_emscriptenvideo.h | 54 + .../SDL-3.2.8/src/video/gdk/SDL_gdktextinput.cpp | 321 + contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.h | 50 + contrib/SDL-3.2.8/src/video/haiku/SDL_BWin.h | 755 + .../SDL-3.2.8/src/video/haiku/SDL_bclipboard.cc | 93 + contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.h | 31 + contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.cc | 39 + contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.h | 37 + .../SDL-3.2.8/src/video/haiku/SDL_bframebuffer.cc | 128 + .../SDL-3.2.8/src/video/haiku/SDL_bframebuffer.h | 45 + contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.cc | 168 + contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.h | 38 + .../SDL-3.2.8/src/video/haiku/SDL_bmessagebox.cc | 383 + .../SDL-3.2.8/src/video/haiku/SDL_bmessagebox.h | 42 + contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.cc | 307 + contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.h | 43 + contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.cc | 205 + contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.h | 52 + contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.cc | 326 + contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.h | 40 + contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.cc | 224 + contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.h | 46 + contrib/SDL-3.2.8/src/video/khronos/EGL/egl.h | 342 + contrib/SDL-3.2.8/src/video/khronos/EGL/eglext.h | 1507 + .../SDL-3.2.8/src/video/khronos/EGL/eglplatform.h | 175 + contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2.h | 656 + contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2ext.h | 4101 +++ .../src/video/khronos/GLES2/gl2platform.h | 27 + contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3.h | 1192 + contrib/SDL-3.2.8/src/video/khronos/GLES3/gl31.h | 1507 + contrib/SDL-3.2.8/src/video/khronos/GLES3/gl32.h | 1808 + .../src/video/khronos/GLES3/gl3platform.h | 27 + .../SDL-3.2.8/src/video/khronos/KHR/khrplatform.h | 311 + .../khronos/vk_video/vulkan_video_codec_av1std.h | 392 + .../vk_video/vulkan_video_codec_av1std_decode.h | 109 + .../khronos/vk_video/vulkan_video_codec_h264std.h | 312 + .../vk_video/vulkan_video_codec_h264std_decode.h | 77 + .../vk_video/vulkan_video_codec_h264std_encode.h | 147 + .../khronos/vk_video/vulkan_video_codec_h265std.h | 446 + .../vk_video/vulkan_video_codec_h265std_decode.h | 67 + .../vk_video/vulkan_video_codec_h265std_encode.h | 157 + .../khronos/vk_video/vulkan_video_codecs_common.h | 36 + .../SDL-3.2.8/src/video/khronos/vulkan/vk_icd.h | 244 + .../SDL-3.2.8/src/video/khronos/vulkan/vk_layer.h | 189 + .../src/video/khronos/vulkan/vk_platform.h | 84 + .../SDL-3.2.8/src/video/khronos/vulkan/vulkan.h | 99 + .../src/video/khronos/vulkan/vulkan_android.h | 153 + .../src/video/khronos/vulkan/vulkan_beta.h | 216 + .../src/video/khronos/vulkan/vulkan_core.h | 19661 +++++++++++ .../src/video/khronos/vulkan/vulkan_directfb.h | 55 + .../src/video/khronos/vulkan/vulkan_fuchsia.h | 262 + .../src/video/khronos/vulkan/vulkan_ggp.h | 60 + .../src/video/khronos/vulkan/vulkan_ios.h | 48 + .../src/video/khronos/vulkan/vulkan_macos.h | 48 + .../src/video/khronos/vulkan/vulkan_metal.h | 206 + .../src/video/khronos/vulkan/vulkan_screen.h | 108 + .../SDL-3.2.8/src/video/khronos/vulkan/vulkan_vi.h | 48 + .../src/video/khronos/vulkan/vulkan_wayland.h | 55 + .../src/video/khronos/vulkan/vulkan_win32.h | 342 + .../src/video/khronos/vulkan/vulkan_xcb.h | 56 + .../src/video/khronos/vulkan/vulkan_xlib.h | 56 + .../src/video/khronos/vulkan/vulkan_xlib_xrandr.h | 46 + contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.c | 161 + contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.h | 54 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.c | 44 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.h | 29 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.c | 410 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.h | 53 + .../src/video/kmsdrm/SDL_kmsdrmopengles.c | 203 + .../src/video/kmsdrm/SDL_kmsdrmopengles.h | 42 + contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmsym.h | 145 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.c | 1820 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.h | 176 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.c | 520 + .../SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.h | 51 + contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents.c | 45 + .../SDL-3.2.8/src/video/n3ds/SDL_n3dsevents_c.h | 29 + .../SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer.c | 161 + .../src/video/n3ds/SDL_n3dsframebuffer_c.h | 31 + contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.c | 69 + contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.h | 36 + contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.c | 86 + contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.h | 29 + contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.c | 259 + contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.h | 41 + .../src/video/offscreen/SDL_offscreenevents.c | 38 + .../src/video/offscreen/SDL_offscreenevents_c.h | 23 + .../src/video/offscreen/SDL_offscreenframebuffer.c | 79 + .../video/offscreen/SDL_offscreenframebuffer_c.h | 25 + .../src/video/offscreen/SDL_offscreenopengles.c | 82 + .../src/video/offscreen/SDL_offscreenopengles.h | 44 + .../src/video/offscreen/SDL_offscreenvideo.c | 151 + .../src/video/offscreen/SDL_offscreenvideo.h | 28 + .../src/video/offscreen/SDL_offscreenvulkan.c | 261 + .../src/video/offscreen/SDL_offscreenvulkan.h | 38 + .../src/video/offscreen/SDL_offscreenwindow.c | 90 + .../src/video/offscreen/SDL_offscreenwindow.h | 40 + .../SDL-3.2.8/src/video/openvr/SDL_openvrvideo.c | 1664 + .../SDL-3.2.8/src/video/openvr/SDL_openvrvideo.h | 106 + contrib/SDL-3.2.8/src/video/openvr/openvr_capi.h | 3200 ++ contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.c | 121 + contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.h | 46 + contrib/SDL-3.2.8/src/video/psp/SDL_pspevents.c | 274 + contrib/SDL-3.2.8/src/video/psp/SDL_pspevents_c.h | 29 + contrib/SDL-3.2.8/src/video/psp/SDL_pspgl.c | 190 + contrib/SDL-3.2.8/src/video/psp/SDL_pspgl_c.h | 50 + contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse.c | 37 + contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse_c.h | 24 + contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.c | 499 + contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.h | 81 + contrib/SDL-3.2.8/src/video/qnx/SDL_qnx.h | 48 + contrib/SDL-3.2.8/src/video/qnx/SDL_qnxgl.c | 277 + contrib/SDL-3.2.8/src/video/qnx/SDL_qnxkeyboard.c | 132 + contrib/SDL-3.2.8/src/video/qnx/SDL_qnxvideo.c | 351 + .../SDL-3.2.8/src/video/raspberry/SDL_rpievents.c | 43 + .../src/video/raspberry/SDL_rpievents_c.h | 29 + .../SDL-3.2.8/src/video/raspberry/SDL_rpimouse.c | 314 + .../SDL-3.2.8/src/video/raspberry/SDL_rpimouse.h | 40 + .../src/video/raspberry/SDL_rpiopengles.c | 65 + .../src/video/raspberry/SDL_rpiopengles.h | 47 + .../SDL-3.2.8/src/video/raspberry/SDL_rpivideo.c | 376 + .../SDL-3.2.8/src/video/raspberry/SDL_rpivideo.h | 89 + .../SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h | 51 + .../SDL-3.2.8/src/video/riscos/SDL_riscosevents.c | 177 + .../src/video/riscos/SDL_riscosevents_c.h | 33 + .../src/video/riscos/SDL_riscosframebuffer.c | 127 + .../src/video/riscos/SDL_riscosframebuffer_c.h | 31 + .../src/video/riscos/SDL_riscosmessagebox.c | 67 + .../src/video/riscos/SDL_riscosmessagebox.h | 27 + .../SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c | 310 + .../SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h | 30 + .../SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c | 79 + .../SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h | 28 + .../SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c | 130 + .../SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h | 36 + .../SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c | 56 + .../SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h | 38 + .../SDL-3.2.8/src/video/riscos/scancodes_riscos.h | 157 + contrib/SDL-3.2.8/src/video/sdlgenblit.pl | 736 + contrib/SDL-3.2.8/src/video/stb_image.h | 8252 +++++ .../src/video/uikit/SDL_uikitappdelegate.h | 45 + .../src/video/uikit/SDL_uikitappdelegate.m | 519 + .../SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.h | 33 + .../SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.m | 105 + .../SDL-3.2.8/src/video/uikit/SDL_uikitevents.h | 40 + .../SDL-3.2.8/src/video/uikit/SDL_uikitevents.m | 461 + .../src/video/uikit/SDL_uikitmessagebox.h | 28 + .../src/video/uikit/SDL_uikitmessagebox.m | 154 + .../SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.h | 54 + .../SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.m | 140 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.h | 67 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.m | 543 + .../SDL-3.2.8/src/video/uikit/SDL_uikitopengles.h | 40 + .../SDL-3.2.8/src/video/uikit/SDL_uikitopengles.m | 221 + .../src/video/uikit/SDL_uikitopenglview.h | 62 + .../src/video/uikit/SDL_uikitopenglview.m | 377 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.h | 39 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.m | 214 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.h | 52 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.m | 312 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.h | 52 + contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.m | 587 + .../src/video/uikit/SDL_uikitviewcontroller.h | 96 + .../src/video/uikit/SDL_uikitviewcontroller.m | 736 + .../SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.h | 52 + .../SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.m | 265 + .../SDL-3.2.8/src/video/uikit/SDL_uikitwindow.h | 56 + .../SDL-3.2.8/src/video/uikit/SDL_uikitwindow.m | 471 + .../SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.c | 116 + .../SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.h | 25 + contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr.c | 122 + .../SDL-3.2.8/src/video/vita/SDL_vitagl_pvr_c.h | 31 + contrib/SDL-3.2.8/src/video/vita/SDL_vitagles.c | 217 + contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_c.h | 53 + .../SDL-3.2.8/src/video/vita/SDL_vitagles_pvr.c | 92 + .../SDL-3.2.8/src/video/vita/SDL_vitagles_pvr_c.h | 32 + .../SDL-3.2.8/src/video/vita/SDL_vitakeyboard.c | 190 + .../SDL-3.2.8/src/video/vita/SDL_vitakeyboard.h | 31 + .../SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c | 125 + .../SDL-3.2.8/src/video/vita/SDL_vitamessagebox.h | 31 + contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse.c | 105 + contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse_c.h | 31 + contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.c | 186 + contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.h | 33 + contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.c | 592 + contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.h | 106 + .../src/video/vivante/SDL_vivanteopengles.c | 41 + .../src/video/vivante/SDL_vivanteopengles.h | 46 + .../src/video/vivante/SDL_vivanteplatform.c | 49 + .../src/video/vivante/SDL_vivanteplatform.h | 45 + .../SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c | 363 + .../SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h | 86 + .../src/video/vivante/SDL_vivantevulkan.c | 154 + .../src/video/vivante/SDL_vivantevulkan.h | 51 + .../src/video/wayland/SDL_waylandclipboard.c | 174 + .../src/video/wayland/SDL_waylandclipboard.h | 34 + .../SDL-3.2.8/src/video/wayland/SDL_waylandcolor.c | 303 + .../SDL-3.2.8/src/video/wayland/SDL_waylandcolor.h | 35 + .../src/video/wayland/SDL_waylanddatamanager.c | 619 + .../src/video/wayland/SDL_waylanddatamanager.h | 162 + .../SDL-3.2.8/src/video/wayland/SDL_waylanddyn.c | 176 + .../SDL-3.2.8/src/video/wayland/SDL_waylanddyn.h | 195 + .../src/video/wayland/SDL_waylandevents.c | 3408 ++ .../src/video/wayland/SDL_waylandevents_c.h | 195 + .../src/video/wayland/SDL_waylandkeyboard.c | 209 + .../src/video/wayland/SDL_waylandkeyboard.h | 40 + .../src/video/wayland/SDL_waylandmessagebox.c | 196 + .../src/video/wayland/SDL_waylandmessagebox.h | 31 + .../SDL-3.2.8/src/video/wayland/SDL_waylandmouse.c | 1057 + .../SDL-3.2.8/src/video/wayland/SDL_waylandmouse.h | 34 + .../src/video/wayland/SDL_waylandopengles.c | 220 + .../src/video/wayland/SDL_waylandopengles.h | 48 + .../src/video/wayland/SDL_waylandshmbuffer.c | 170 + .../src/video/wayland/SDL_waylandshmbuffer.h | 38 + .../SDL-3.2.8/src/video/wayland/SDL_waylandsym.h | 242 + .../SDL-3.2.8/src/video/wayland/SDL_waylandvideo.c | 1692 + .../SDL-3.2.8/src/video/wayland/SDL_waylandvideo.h | 140 + .../src/video/wayland/SDL_waylandvulkan.c | 203 + .../src/video/wayland/SDL_waylandvulkan.h | 55 + .../src/video/wayland/SDL_waylandwindow.c | 3125 ++ .../src/video/wayland/SDL_waylandwindow.h | 248 + contrib/SDL-3.2.8/src/video/windows/SDL_msctf.h | 246 + .../src/video/windows/SDL_surface_utils.c | 97 + .../src/video/windows/SDL_surface_utils.h | 38 + .../src/video/windows/SDL_windowsclipboard.c | 442 + .../src/video/windows/SDL_windowsclipboard.h | 34 + .../src/video/windows/SDL_windowsevents.c | 2734 ++ .../src/video/windows/SDL_windowsevents.h | 39 + .../src/video/windows/SDL_windowsframebuffer.c | 132 + .../src/video/windows/SDL_windowsframebuffer.h | 25 + .../src/video/windows/SDL_windowsgameinput.c | 612 + .../src/video/windows/SDL_windowsgameinput.h | 29 + .../src/video/windows/SDL_windowskeyboard.c | 1145 + .../src/video/windows/SDL_windowskeyboard.h | 40 + .../src/video/windows/SDL_windowsmessagebox.c | 1086 + .../src/video/windows/SDL_windowsmessagebox.h | 27 + .../SDL-3.2.8/src/video/windows/SDL_windowsmodes.c | 927 + .../SDL-3.2.8/src/video/windows/SDL_windowsmodes.h | 55 + .../SDL-3.2.8/src/video/windows/SDL_windowsmouse.c | 745 + .../SDL-3.2.8/src/video/windows/SDL_windowsmouse.h | 34 + .../src/video/windows/SDL_windowsopengl.c | 906 + .../src/video/windows/SDL_windowsopengl.h | 178 + .../src/video/windows/SDL_windowsopengles.c | 142 + .../src/video/windows/SDL_windowsopengles.h | 48 + .../src/video/windows/SDL_windowsrawinput.c | 262 + .../src/video/windows/SDL_windowsrawinput.h | 30 + .../SDL-3.2.8/src/video/windows/SDL_windowsshape.c | 125 + .../SDL-3.2.8/src/video/windows/SDL_windowsshape.h | 28 + .../SDL-3.2.8/src/video/windows/SDL_windowsvideo.c | 773 + .../SDL-3.2.8/src/video/windows/SDL_windowsvideo.h | 507 + .../src/video/windows/SDL_windowsvulkan.c | 195 + .../src/video/windows/SDL_windowsvulkan.h | 55 + .../src/video/windows/SDL_windowswindow.c | 2435 ++ .../src/video/windows/SDL_windowswindow.h | 152 + contrib/SDL-3.2.8/src/video/windows/wmmsg.h | 1050 + contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.c | 329 + contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.h | 46 + contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.c | 211 + contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.h | 113 + contrib/SDL-3.2.8/src/video/x11/SDL_x11events.c | 2205 ++ contrib/SDL-3.2.8/src/video/x11/SDL_x11events.h | 40 + .../SDL-3.2.8/src/video/x11/SDL_x11framebuffer.c | 261 + .../SDL-3.2.8/src/video/x11/SDL_x11framebuffer.h | 34 + contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.c | 789 + contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.h | 40 + .../SDL-3.2.8/src/video/x11/SDL_x11messagebox.c | 887 + .../SDL-3.2.8/src/video/x11/SDL_x11messagebox.h | 31 + contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.c | 1051 + contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.h | 69 + contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.c | 552 + contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.h | 40 + contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.c | 1116 + contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.h | 96 + contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.c | 152 + contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.h | 55 + contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.c | 437 + contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.h | 72 + contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.c | 129 + contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.h | 39 + contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.c | 111 + contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.h | 28 + contrib/SDL-3.2.8/src/video/x11/SDL_x11sym.h | 354 + contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.c | 46 + contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.h | 30 + contrib/SDL-3.2.8/src/video/x11/SDL_x11video.c | 505 + contrib/SDL-3.2.8/src/video/x11/SDL_x11video.h | 177 + contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.c | 290 + contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.h | 52 + contrib/SDL-3.2.8/src/video/x11/SDL_x11window.c | 2243 ++ contrib/SDL-3.2.8/src/video/x11/SDL_x11window.h | 169 + contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.c | 214 + contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.h | 39 + contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.c | 829 + contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.h | 44 + contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.c | 148 + contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.h | 39 + contrib/SDL-3.2.8/src/video/x11/edid-parse.c | 753 + contrib/SDL-3.2.8/src/video/x11/edid.h | 191 + contrib/SDL-3.2.8/src/video/x11/xsettings-client.c | 859 + contrib/SDL-3.2.8/src/video/x11/xsettings-client.h | 153 + contrib/SDL-3.2.8/src/video/yuv2rgb/LICENSE | 27 + contrib/SDL-3.2.8/src/video/yuv2rgb/README.md | 63 + contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb.h | 33 + .../SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_common.h | 15 + .../SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_internal.h | 85 + contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.c | 43 + contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.h | 36 + .../SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx_func.h | 372 + contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse.c | 460 + contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse.h | 241 + .../SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse_func.h | 529 + contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std.c | 200 + contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std.h | 143 + .../SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std_func.h | 271 + 422 files changed, 217786 insertions(+) create mode 100644 contrib/SDL-3.2.8/src/video/SDL_RLEaccel.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_RLEaccel_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_0.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_1.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_A.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_N.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_auto.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_auto.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_copy.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_copy.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_slow.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_blit_slow.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_bmp.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_clipboard.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_clipboard_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_egl.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_egl_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_fillrect.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_pixels.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_pixels_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_rect.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_rect_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_rect_impl.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_stb.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_stb_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_stretch.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_surface.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_surface_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_sysvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_video.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_video_c.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_video_unsupported.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_vulkan_internal.h create mode 100644 contrib/SDL-3.2.8/src/video/SDL_vulkan_utils.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_yuv.c create mode 100644 contrib/SDL-3.2.8/src/video/SDL_yuv_c.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidevents.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidevents.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidgl.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidgl.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidpen.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidpen.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.c create mode 100644 contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.m create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h create mode 100644 contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.m create mode 100644 contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h create mode 100644 contrib/SDL-3.2.8/src/video/directx/SDL_d3d12_xbox_cmacros.h create mode 100644 contrib/SDL-3.2.8/src/video/directx/d3d12.h create mode 100644 contrib/SDL-3.2.8/src/video/directx/d3d12sdklayers.h create mode 100644 contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs create mode 100644 contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c create mode 100644 contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h create mode 100644 contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.c create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.h create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.h create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.h create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.c create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.cpp create mode 100644 contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_BWin.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.cc create mode 100644 contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/EGL/egl.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/EGL/eglext.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/EGL/eglplatform.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2ext.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2platform.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/GLES3/gl31.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/GLES3/gl32.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3platform.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/KHR/khrplatform.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std_decode.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codecs_common.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_icd.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_layer.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_platform.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_android.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_beta.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_core.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_directfb.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_fuchsia.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ggp.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ios.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_macos.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_metal.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_screen.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_vi.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_wayland.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_win32.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xcb.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib.h create mode 100644 contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib_xrandr.h create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.c create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.h create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.c create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.h create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.h create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.c create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmsym.h create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.c create mode 100644 contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents.c create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer_c.h create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.c create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.h create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.c create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.h create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents.c create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer_c.h create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.c create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.c create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.c create mode 100644 contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.h create mode 100644 contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/openvr/openvr_capi.h create mode 100644 contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.c create mode 100644 contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.h create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspevents.c create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspevents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspgl.c create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspgl_c.h create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse_c.h create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/qnx/SDL_qnx.h create mode 100644 contrib/SDL-3.2.8/src/video/qnx/SDL_qnxgl.c create mode 100644 contrib/SDL-3.2.8/src/video/qnx/SDL_qnxkeyboard.c create mode 100644 contrib/SDL-3.2.8/src/video/qnx/SDL_qnxvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents.c create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.c create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.h create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.c create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.c create mode 100644 contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c create mode 100644 contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h create mode 100644 contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h create mode 100755 contrib/SDL-3.2.8/src/video/sdlgenblit.pl create mode 100644 contrib/SDL-3.2.8/src/video/stb_image.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.m create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.h create mode 100644 contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.m create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr_c.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitagles.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_c.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr_c.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse_c.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.h create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.c create mode 100644 contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.h create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c create mode 100644 contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandsym.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.c create mode 100644 contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_msctf.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.c create mode 100644 contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.h create mode 100644 contrib/SDL-3.2.8/src/video/windows/wmmsg.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11events.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11events.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11sym.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11video.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11video.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11window.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11window.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/edid-parse.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/edid.h create mode 100644 contrib/SDL-3.2.8/src/video/x11/xsettings-client.c create mode 100644 contrib/SDL-3.2.8/src/video/x11/xsettings-client.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/LICENSE create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/README.md create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_common.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_internal.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.c create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx_func.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse.c create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse_func.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std.c create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std.h create mode 100644 contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std_func.h (limited to 'contrib/SDL-3.2.8/src/video') diff --git a/contrib/SDL-3.2.8/src/video/SDL_RLEaccel.c b/contrib/SDL-3.2.8/src/video/SDL_RLEaccel.c new file mode 100644 index 0000000..890b825 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_RLEaccel.c @@ -0,0 +1,1576 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_HAVE_RLE + +/* + * RLE encoding for software colorkey and alpha-channel acceleration + * + * Original version by Sam Lantinga + * + * Mattias EngdegÄrd (Yorick): Rewrite. New encoding format, encoder and + * decoder. Added per-surface alpha blitter. Added per-pixel alpha + * format, encoder and blitter. + * + * Many thanks to Xark and johns for hints, benchmarks and useful comments + * leading to this code. + * + * Welcome to Macro Mayhem. + */ + +/* + * The encoding translates the image data to a stream of segments of the form + * + * + * + * where is the number of transparent pixels to skip, + * is the number of opaque pixels to blit, + * and are the pixels themselves. + * + * This basic structure is used both for colorkeyed surfaces, used for simple + * binary transparency and for per-surface alpha blending, and for surfaces + * with per-pixel alpha. The details differ, however: + * + * Encoding of colorkeyed surfaces: + * + * Encoded pixels always have the same format as the target surface. + * and are unsigned 8 bit integers, except for 32 bit depth + * where they are 16 bit. This makes the pixel data aligned at all times. + * Segments never wrap around from one scan line to the next. + * + * The end of the sequence is marked by a zero , pair at the * + * beginning of a line. + * + * Encoding of surfaces with per-pixel alpha: + * + * The sequence begins with an SDL_PixelFormat value describing the target + * pixel format, to provide reliable un-encoding. + * + * Each scan line is encoded twice: First all completely opaque pixels, + * encoded in the target format as described above, and then all + * partially transparent (translucent) pixels (where 1 <= alpha <= 254), + * in the following 32-bit format: + * + * For 32-bit targets, each pixel has the target RGB format but with + * the alpha value occupying the highest 8 bits. The and + * counts are 16 bit. + * + * For 16-bit targets, each pixel has the target RGB format, but with + * the middle component (usually green) shifted 16 steps to the left, + * and the hole filled with the 5 most significant bits of the alpha value. + * i.e. if the target has the format rrrrrggggggbbbbb, + * the encoded pixel will be 00000gggggg00000rrrrr0aaaaabbbbb. + * The and counts are 8 bit for the opaque lines, 16 bit + * for the translucent lines. Two padding bytes may be inserted + * before each translucent line to keep them 32-bit aligned. + * + * The end of the sequence is marked by a zero , pair at the + * beginning of an opaque line. + */ + +#include "SDL_sysvideo.h" +#include "SDL_surface_c.h" +#include "SDL_RLEaccel_c.h" + +#define PIXEL_COPY(to, from, len, bpp) \ + SDL_memcpy(to, from, (size_t)(len) * (bpp)) + +/* + * Various colorkey blit methods, for opaque and per-surface alpha + */ + +#define OPAQUE_BLIT(to, from, length, bpp, alpha) \ + PIXEL_COPY(to, from, length, bpp) + +/* + * For 32bpp pixels on the form 0x00rrggbb: + * If we treat the middle component separately, we can process the two + * remaining in parallel. This is safe to do because of the gap to the left + * of each component, so the bits from the multiplication don't collide. + * This can be used for any RGB permutation of course. + */ +#define ALPHA_BLIT32_888(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint32 *src = (Uint32 *)(from); \ + Uint32 *dst = (Uint32 *)(to); \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + Uint32 s1 = s & 0xff00ff; \ + Uint32 d1 = d & 0xff00ff; \ + d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ + s &= 0xff00; \ + d &= 0xff00; \ + d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ + *dst++ = d1 | d; \ + } \ + } while (0) + +/* + * For 16bpp pixels we can go a step further: put the middle component + * in the high 16 bits of a 32 bit word, and process all three RGB + * components at the same time. Since the smallest gap is here just + * 5 bits, we have to scale alpha down to 5 bits as well. + */ +#define ALPHA_BLIT16_565(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + Uint32 ALPHA = alpha >> 3; \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + s = (s | s << 16) & 0x07e0f81f; \ + d = (d | d << 16) & 0x07e0f81f; \ + d += (s - d) * ALPHA >> 5; \ + d &= 0x07e0f81f; \ + *dst++ = (Uint16)(d | d >> 16); \ + } \ + } while (0) + +#define ALPHA_BLIT16_555(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + Uint32 ALPHA = alpha >> 3; \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + s = (s | s << 16) & 0x03e07c1f; \ + d = (d | d << 16) & 0x03e07c1f; \ + d += (s - d) * ALPHA >> 5; \ + d &= 0x03e07c1f; \ + *dst++ = (Uint16)(d | d >> 16); \ + } \ + } while (0) + +/* + * The general slow catch-all function, for remaining depths and formats + */ +#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint8 *src = from; \ + Uint8 *dst = to; \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = 0, d = 0; \ + unsigned rs, gs, bs, rd, gd, bd; \ + switch (bpp) { \ + case 2: \ + s = *(Uint16 *)src; \ + d = *(Uint16 *)dst; \ + break; \ + case 3: \ + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ + s = (src[0] << 16) | (src[1] << 8) | src[2]; \ + d = (dst[0] << 16) | (dst[1] << 8) | dst[2]; \ + } else { \ + s = (src[2] << 16) | (src[1] << 8) | src[0]; \ + d = (dst[2] << 16) | (dst[1] << 8) | dst[0]; \ + } \ + break; \ + case 4: \ + s = *(Uint32 *)src; \ + d = *(Uint32 *)dst; \ + break; \ + } \ + RGB_FROM_PIXEL(s, fmt, rs, gs, bs); \ + RGB_FROM_PIXEL(d, fmt, rd, gd, bd); \ + rd += (rs - rd) * alpha >> 8; \ + gd += (gs - gd) * alpha >> 8; \ + bd += (bs - bd) * alpha >> 8; \ + PIXEL_FROM_RGB(d, fmt, rd, gd, bd); \ + switch (bpp) { \ + case 2: \ + *(Uint16 *)dst = (Uint16)d; \ + break; \ + case 3: \ + if (SDL_BYTEORDER == SDL_BIG_ENDIAN) { \ + dst[0] = (Uint8)(d >> 16); \ + dst[1] = (Uint8)(d >> 8); \ + dst[2] = (Uint8)(d); \ + } else { \ + dst[0] = (Uint8)d; \ + dst[1] = (Uint8)(d >> 8); \ + dst[2] = (Uint8)(d >> 16); \ + } \ + break; \ + case 4: \ + *(Uint32 *)dst = d; \ + break; \ + } \ + src += bpp; \ + dst += bpp; \ + } \ + } while (0) + +/* + * Special case: 50% alpha (alpha=128) + * This is treated specially because it can be optimized very well, and + * since it is good for many cases of semi-translucency. + * The theory is to do all three components at the same time: + * First zero the lowest bit of each component, which gives us room to + * add them. Then shift right and add the sum of the lowest bits. + */ +#define ALPHA_BLIT32_888_50(to, from, length, bpp, alpha) \ + do { \ + int i; \ + Uint32 *src = (Uint32 *)(from); \ + Uint32 *dst = (Uint32 *)(to); \ + for (i = 0; i < (int)(length); i++) { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + *dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) + (s & d & 0x00010101); \ + } \ + } while (0) + +/* + * For 16bpp, we can actually blend two pixels in parallel, if we take + * care to shift before we add, not after. + */ + +// helper: blend a single 16 bit pixel at 50% +#define BLEND16_50(dst, src, mask) \ + do { \ + Uint32 s = *src++; \ + Uint32 d = *dst; \ + *dst++ = (Uint16)((((s & mask) + (d & mask)) >> 1) + \ + (s & d & (~mask & 0xffff))); \ + } while (0) + +// basic 16bpp blender. mask is the pixels to keep when adding. +#define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask) \ + do { \ + unsigned n = (length); \ + Uint16 *src = (Uint16 *)(from); \ + Uint16 *dst = (Uint16 *)(to); \ + if (((uintptr_t)src ^ (uintptr_t)dst) & 3) { \ + /* source and destination not in phase, blit one by one */ \ + while (n--) \ + BLEND16_50(dst, src, mask); \ + } else { \ + if ((uintptr_t)src & 3) { \ + /* first odd pixel */ \ + BLEND16_50(dst, src, mask); \ + n--; \ + } \ + for (; n > 1; n -= 2) { \ + Uint32 s = *(Uint32 *)src; \ + Uint32 d = *(Uint32 *)dst; \ + *(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) + (s & d & (~(mask | mask << 16))); \ + src += 2; \ + dst += 2; \ + } \ + if (n) \ + BLEND16_50(dst, src, mask); /* last odd pixel */ \ + } \ + } while (0) + +#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha) \ + ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xf7deU) + +#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha) \ + ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbdeU) + +#define CHOOSE_BLIT(blitter, alpha, fmt) \ + do { \ + if (alpha == 255) { \ + switch (fmt->bytes_per_pixel) { \ + case 1: \ + blitter(1, Uint8, OPAQUE_BLIT); \ + break; \ + case 2: \ + blitter(2, Uint8, OPAQUE_BLIT); \ + break; \ + case 3: \ + blitter(3, Uint8, OPAQUE_BLIT); \ + break; \ + case 4: \ + blitter(4, Uint16, OPAQUE_BLIT); \ + break; \ + } \ + } else { \ + switch (fmt->bytes_per_pixel) { \ + case 1: \ + /* No 8bpp alpha blitting */ \ + break; \ + \ + case 2: \ + switch (fmt->Rmask | fmt->Gmask | fmt->Bmask) { \ + case 0xffff: \ + if (fmt->Gmask == 0x07e0 || fmt->Rmask == 0x07e0 || fmt->Bmask == 0x07e0) { \ + if (alpha == 128) { \ + blitter(2, Uint8, ALPHA_BLIT16_565_50); \ + } else { \ + blitter(2, Uint8, ALPHA_BLIT16_565); \ + } \ + } else { \ + goto general16; \ + } \ + break; \ + \ + case 0x7fff: \ + if (fmt->Gmask == 0x03e0 || fmt->Rmask == 0x03e0 || fmt->Bmask == 0x03e0) { \ + if (alpha == 128) { \ + blitter(2, Uint8, ALPHA_BLIT16_555_50); \ + } else { \ + blitter(2, Uint8, ALPHA_BLIT16_555); \ + } \ + break; \ + } else { \ + goto general16; \ + } \ + break; \ + \ + default: \ + general16: \ + blitter(2, Uint8, ALPHA_BLIT_ANY); \ + } \ + break; \ + \ + case 3: \ + blitter(3, Uint8, ALPHA_BLIT_ANY); \ + break; \ + \ + case 4: \ + if ((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff && (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00 || fmt->Bmask == 0xff00)) { \ + if (alpha == 128) { \ + blitter(4, Uint16, ALPHA_BLIT32_888_50); \ + } else { \ + blitter(4, Uint16, ALPHA_BLIT32_888); \ + } \ + } else { \ + blitter(4, Uint16, ALPHA_BLIT_ANY); \ + } \ + break; \ + } \ + } \ + } while (0) + +/* + * Set a pixel value using the given format, except that the alpha value is + * placed in the top byte. This is the format used for RLE with alpha. + */ +#define RLEPIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ + { \ + Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \ + ((g >> (8 - fmt->Gbits)) << fmt->Gshift) | \ + ((b >> (8 - fmt->Bbits)) << fmt->Bshift) | \ + (a << 24); \ + } + +/* + * This takes care of the case when the surface is clipped on the left and/or + * right. Top clipping has already been taken care of. + */ +#define RLECLIPBLIT(bpp, Type, do_blit) \ + do { \ + int linecount = srcrect->h; \ + int ofs = 0; \ + int left = srcrect->x; \ + int right = left + srcrect->w; \ + dstbuf -= left * bpp; \ + for (;;) { \ + int run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Type); \ + if (run) { \ + /* clip to left and right borders */ \ + if (ofs < right) { \ + int start = 0; \ + int len = run; \ + int startcol; \ + if (left - ofs > 0) { \ + start = left - ofs; \ + len -= start; \ + if (len <= 0) \ + goto nocopy##bpp##do_blit; \ + } \ + startcol = ofs + start; \ + if (len > right - startcol) \ + len = right - startcol; \ + do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \ + len, bpp, alpha); \ + } \ + nocopy##bpp##do_blit : srcbuf += run * bpp; \ + ofs += run; \ + } else if (!ofs) { \ + break; \ + } \ + \ + if (ofs == w) { \ + ofs = 0; \ + dstbuf += surf_dst->pitch; \ + if (!--linecount) { \ + break; \ + } \ + } \ + } \ + } while (0) + +static void RLEClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst, + Uint8 *dstbuf, const SDL_Rect *srcrect, unsigned alpha) +{ + const SDL_PixelFormatDetails *fmt = surf_dst->fmt; + + CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt); +} + +#undef RLECLIPBLIT + +// blit a colorkeyed RLE surface +static bool SDLCALL SDL_RLEBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect, + SDL_Surface *surf_dst, const SDL_Rect *dstrect) +{ + Uint8 *dstbuf; + Uint8 *srcbuf; + int x, y; + int w = surf_src->w; + unsigned alpha; + + // Lock the destination if necessary + if (SDL_MUSTLOCK(surf_dst)) { + if (!SDL_LockSurface(surf_dst)) { + return false; + } + } + + // Set up the source and destination pointers + x = dstrect->x; + y = dstrect->y; + dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * surf_src->fmt->bytes_per_pixel; + srcbuf = (Uint8 *)surf_src->map.data + sizeof(SDL_PixelFormat); + + { + // skip lines at the top if necessary + int vskip = srcrect->y; + int ofs = 0; + if (vskip) { + +#define RLESKIP(bpp, Type) \ + for (;;) { \ + int run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += sizeof(Type) * 2; \ + if (run) { \ + srcbuf += run * bpp; \ + ofs += run; \ + } else if (!ofs) \ + goto done; \ + if (ofs == w) { \ + ofs = 0; \ + if (!--vskip) \ + break; \ + } \ + } + + switch (surf_src->fmt->bytes_per_pixel) { + case 1: + RLESKIP(1, Uint8); + break; + case 2: + RLESKIP(2, Uint8); + break; + case 3: + RLESKIP(3, Uint8); + break; + case 4: + RLESKIP(4, Uint16); + break; + } + +#undef RLESKIP + } + } + + alpha = surf_src->map.info.a; + // if left or right edge clipping needed, call clip blit + if (srcrect->x || srcrect->w != surf_src->w) { + RLEClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect, alpha); + } else { + const SDL_PixelFormatDetails *fmt = surf_src->fmt; + +#define RLEBLIT(bpp, Type, do_blit) \ + do { \ + int linecount = srcrect->h; \ + int ofs = 0; \ + for (;;) { \ + unsigned run; \ + ofs += *(Type *)srcbuf; \ + run = ((Type *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Type); \ + if (run) { \ + do_blit(dstbuf + ofs * bpp, srcbuf, run, bpp, alpha); \ + srcbuf += run * bpp; \ + ofs += run; \ + } else if (!ofs) \ + break; \ + if (ofs == w) { \ + ofs = 0; \ + dstbuf += surf_dst->pitch; \ + if (!--linecount) \ + break; \ + } \ + } \ + } while (0) + + CHOOSE_BLIT(RLEBLIT, alpha, fmt); + +#undef RLEBLIT + } + +done: + // Unlock the destination if necessary + if (SDL_MUSTLOCK(surf_dst)) { + SDL_UnlockSurface(surf_dst); + } + return true; +} + +#undef OPAQUE_BLIT + +/* + * Per-pixel blitting macros for translucent pixels: + * These use the same techniques as the per-surface blitting macros + */ + +/* + * For 32bpp pixels, we have made sure the alpha is stored in the top + * 8 bits, so proceed as usual + */ +#define BLIT_TRANSL_888(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = s >> 24; \ + Uint32 s1 = s & 0xff00ff; \ + Uint32 d1 = d & 0xff00ff; \ + d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff; \ + s &= 0xff00; \ + d &= 0xff00; \ + d = (d + ((s - d) * alpha >> 8)) & 0xff00; \ + dst = d1 | d | 0xff000000; \ + } while (0) + +/* + * For 16bpp pixels, we have stored the 5 most significant alpha bits in + * bits 5-10. As before, we can process all 3 RGB components at the same time. + */ +#define BLIT_TRANSL_565(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = (s & 0x3e0) >> 5; \ + s &= 0x07e0f81f; \ + d = (d | d << 16) & 0x07e0f81f; \ + d += (s - d) * alpha >> 5; \ + d &= 0x07e0f81f; \ + dst = (Uint16)(d | d >> 16); \ + } while (0) + +#define BLIT_TRANSL_555(src, dst) \ + do { \ + Uint32 s = src; \ + Uint32 d = dst; \ + unsigned alpha = (s & 0x3e0) >> 5; \ + s &= 0x03e07c1f; \ + d = (d | d << 16) & 0x03e07c1f; \ + d += (s - d) * alpha >> 5; \ + d &= 0x03e07c1f; \ + dst = (Uint16)(d | d >> 16); \ + } while (0) + +// blit a pixel-alpha RLE surface clipped at the right and/or left edges +static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *surf_dst, + Uint8 *dstbuf, const SDL_Rect *srcrect) +{ + const SDL_PixelFormatDetails *df = surf_dst->fmt; + /* + * clipped blitter: Ptype is the destination pixel type, + * Ctype the translucent count type, and do_blend the macro + * to blend one pixel. + */ +#define RLEALPHACLIPBLIT(Ptype, Ctype, do_blend) \ + do { \ + int linecount = srcrect->h; \ + int left = srcrect->x; \ + int right = left + srcrect->w; \ + dstbuf -= left * sizeof(Ptype); \ + do { \ + int ofs = 0; \ + /* blit opaque pixels on one line */ \ + do { \ + unsigned run; \ + ofs += ((Ctype *)srcbuf)[0]; \ + run = ((Ctype *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Ctype); \ + if (run) { \ + /* clip to left and right borders */ \ + int cofs = ofs; \ + int crun = run; \ + if (left - cofs > 0) { \ + crun -= left - cofs; \ + cofs = left; \ + } \ + if (crun > right - cofs) \ + crun = right - cofs; \ + if (crun > 0) \ + PIXEL_COPY(dstbuf + cofs * sizeof(Ptype), \ + srcbuf + (cofs - ofs) * sizeof(Ptype), \ + (unsigned)crun, sizeof(Ptype)); \ + srcbuf += run * sizeof(Ptype); \ + ofs += run; \ + } else if (!ofs) \ + return; \ + } while (ofs < w); \ + /* skip padding if necessary */ \ + if (sizeof(Ptype) == 2) \ + srcbuf += (uintptr_t)srcbuf & 2; \ + /* blit translucent pixels on the same line */ \ + ofs = 0; \ + do { \ + unsigned run; \ + ofs += ((Uint16 *)srcbuf)[0]; \ + run = ((Uint16 *)srcbuf)[1]; \ + srcbuf += 4; \ + if (run) { \ + /* clip to left and right borders */ \ + int cofs = ofs; \ + int crun = run; \ + if (left - cofs > 0) { \ + crun -= left - cofs; \ + cofs = left; \ + } \ + if (crun > right - cofs) \ + crun = right - cofs; \ + if (crun > 0) { \ + Ptype *dst = (Ptype *)dstbuf + cofs; \ + Uint32 *src = (Uint32 *)srcbuf + (cofs - ofs); \ + int i; \ + for (i = 0; i < crun; i++) \ + do_blend(src[i], dst[i]); \ + } \ + srcbuf += run * 4; \ + ofs += run; \ + } \ + } while (ofs < w); \ + dstbuf += surf_dst->pitch; \ + } while (--linecount); \ + } while (0) + + switch (df->bytes_per_pixel) { + case 2: + if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) { + RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_565); + } else { + RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_555); + } + break; + case 4: + RLEALPHACLIPBLIT(Uint32, Uint16, BLIT_TRANSL_888); + break; + } +} + +// blit a pixel-alpha RLE surface +static bool SDLCALL SDL_RLEAlphaBlit(SDL_Surface *surf_src, const SDL_Rect *srcrect, + SDL_Surface *surf_dst, const SDL_Rect *dstrect) +{ + int x, y; + int w = surf_src->w; + Uint8 *srcbuf, *dstbuf; + const SDL_PixelFormatDetails *df = surf_dst->fmt; + + // Lock the destination if necessary + if (SDL_MUSTLOCK(surf_dst)) { + if (!SDL_LockSurface(surf_dst)) { + return false; + } + } + + x = dstrect->x; + y = dstrect->y; + dstbuf = (Uint8 *)surf_dst->pixels + y * surf_dst->pitch + x * df->bytes_per_pixel; + srcbuf = (Uint8 *)surf_src->map.data + sizeof(SDL_PixelFormat); + + { + // skip lines at the top if necessary + int vskip = srcrect->y; + if (vskip) { + int ofs; + if (df->bytes_per_pixel == 2) { + // the 16/32 interleaved format + do { + // skip opaque line + ofs = 0; + do { + int run; + ofs += srcbuf[0]; + run = srcbuf[1]; + srcbuf += 2; + if (run) { + srcbuf += 2 * run; + ofs += run; + } else if (ofs == 0) { + goto done; + } + } while (ofs < w); + + // skip padding + srcbuf += (uintptr_t)srcbuf & 2; + + // skip translucent line + ofs = 0; + do { + int run; + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; + srcbuf += 4 * (run + 1); + ofs += run; + } while (ofs < w); + } while (--vskip); + } else { + // the 32/32 interleaved format + vskip <<= 1; // opaque and translucent have same format + do { + ofs = 0; + do { + int run; + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; + srcbuf += 4; + if (run) { + srcbuf += 4 * run; + ofs += run; + } else if (ofs == 0) { + goto done; + } + } while (ofs < w); + } while (--vskip); + } + } + } + + // if left or right edge clipping needed, call clip blit + if (srcrect->x || srcrect->w != surf_src->w) { + RLEAlphaClipBlit(w, srcbuf, surf_dst, dstbuf, srcrect); + } else { + + /* + * non-clipped blitter. Ptype is the destination pixel type, + * Ctype the translucent count type, and do_blend the + * macro to blend one pixel. + */ +#define RLEALPHABLIT(Ptype, Ctype, do_blend) \ + do { \ + int linecount = srcrect->h; \ + do { \ + int ofs = 0; \ + /* blit opaque pixels on one line */ \ + do { \ + unsigned run; \ + ofs += ((Ctype *)srcbuf)[0]; \ + run = ((Ctype *)srcbuf)[1]; \ + srcbuf += 2 * sizeof(Ctype); \ + if (run) { \ + PIXEL_COPY(dstbuf + ofs * sizeof(Ptype), srcbuf, \ + run, sizeof(Ptype)); \ + srcbuf += run * sizeof(Ptype); \ + ofs += run; \ + } else if (!ofs) \ + goto done; \ + } while (ofs < w); \ + /* skip padding if necessary */ \ + if (sizeof(Ptype) == 2) \ + srcbuf += (uintptr_t)srcbuf & 2; \ + /* blit translucent pixels on the same line */ \ + ofs = 0; \ + do { \ + unsigned run; \ + ofs += ((Uint16 *)srcbuf)[0]; \ + run = ((Uint16 *)srcbuf)[1]; \ + srcbuf += 4; \ + if (run) { \ + Ptype *dst = (Ptype *)dstbuf + ofs; \ + unsigned i; \ + for (i = 0; i < run; i++) { \ + Uint32 src = *(Uint32 *)srcbuf; \ + do_blend(src, *dst); \ + srcbuf += 4; \ + dst++; \ + } \ + ofs += run; \ + } \ + } while (ofs < w); \ + dstbuf += surf_dst->pitch; \ + } while (--linecount); \ + } while (0) + + switch (df->bytes_per_pixel) { + case 2: + if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) { + RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565); + } else { + RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555); + } + break; + case 4: + RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888); + break; + } + } + +done: + // Unlock the destination if necessary + if (SDL_MUSTLOCK(surf_dst)) { + SDL_UnlockSurface(surf_dst); + } + return true; +} + +/* + * Auxiliary functions: + * The encoding functions take 32bpp rgb + a, and + * return the number of bytes copied to the destination. + * The decoding functions copy to 32bpp rgb + a, and + * return the number of bytes copied from the source. + * These are only used in the encoder and un-RLE code and are therefore not + * highly optimised. + */ + +// encode 32bpp rgb + a into 16bpp rgb, losing alpha +static int copy_opaque_16(void *dst, const Uint32 *src, int n, + const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) +{ + int i; + Uint16 *d = (Uint16 *)dst; + for (i = 0; i < n; i++) { + unsigned r, g, b; + RGB_FROM_PIXEL(*src, sfmt, r, g, b); + PIXEL_FROM_RGB(*d, dfmt, r, g, b); + src++; + d++; + } + return n * 2; +} + +// decode opaque pixels from 16bpp to 32bpp rgb + a +static int uncopy_opaque_16(Uint32 *dst, const void *src, int n, + const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) +{ + int i; + const Uint16 *s = (const Uint16 *)src; + unsigned alpha = dfmt->Amask ? 255 : 0; + for (i = 0; i < n; i++) { + unsigned r, g, b; + RGB_FROM_PIXEL(*s, sfmt, r, g, b); + PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, alpha); + s++; + dst++; + } + return n * 2; +} + +// encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 +static int copy_transl_565(void *dst, const Uint32 *src, int n, + const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) +{ + int i; + Uint32 *d = (Uint32 *)dst; + for (i = 0; i < n; i++) { + unsigned r, g, b, a; + Uint16 pix; + RGBA_FROM_8888(*src, sfmt, r, g, b, a); + PIXEL_FROM_RGB(pix, dfmt, r, g, b); + *d = ((pix & 0x7e0) << 16) | (pix & 0xf81f) | ((a << 2) & 0x7e0); + src++; + d++; + } + return n * 4; +} + +// encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 +static int copy_transl_555(void *dst, const Uint32 *src, int n, + const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) +{ + int i; + Uint32 *d = (Uint32 *)dst; + for (i = 0; i < n; i++) { + unsigned r, g, b, a; + Uint16 pix; + RGBA_FROM_8888(*src, sfmt, r, g, b, a); + PIXEL_FROM_RGB(pix, dfmt, r, g, b); + *d = ((pix & 0x3e0) << 16) | (pix & 0xfc1f) | ((a << 2) & 0x3e0); + src++; + d++; + } + return n * 4; +} + +// decode translucent pixels from 32bpp GORAB to 32bpp rgb + a +static int uncopy_transl_16(Uint32 *dst, const void *src, int n, + const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) +{ + int i; + const Uint32 *s = (const Uint32 *)src; + for (i = 0; i < n; i++) { + unsigned r, g, b, a; + Uint32 pix = *s++; + a = (pix & 0x3e0) >> 2; + pix = (pix & ~0x3e0) | pix >> 16; + RGB_FROM_PIXEL(pix, sfmt, r, g, b); + PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a); + dst++; + } + return n * 4; +} + +// encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) +static int copy_32(void *dst, const Uint32 *src, int n, + const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) +{ + int i; + Uint32 *d = (Uint32 *)dst; + for (i = 0; i < n; i++) { + unsigned r, g, b, a; + RGBA_FROM_8888(*src, sfmt, r, g, b, a); + RLEPIXEL_FROM_RGBA(*d, dfmt, r, g, b, a); + d++; + src++; + } + return n * 4; +} + +// decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) +static int uncopy_32(Uint32 *dst, const void *src, int n, + const SDL_PixelFormatDetails *sfmt, const SDL_PixelFormatDetails *dfmt) +{ + int i; + const Uint32 *s = (const Uint32 *)src; + for (i = 0; i < n; i++) { + unsigned r, g, b, a; + Uint32 pixel = *s++; + RGB_FROM_PIXEL(pixel, sfmt, r, g, b); + a = pixel >> 24; + PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a); + dst++; + } + return n * 4; +} + +#define ISOPAQUE(pixel, fmt) ((((pixel)&fmt->Amask) >> fmt->Ashift) == 255) + +#define ISTRANSL(pixel, fmt) \ + ((unsigned)((((pixel)&fmt->Amask) >> fmt->Ashift) - 1U) < 254U) + +// convert surface to be quickly alpha-blittable onto dest, if possible +static bool RLEAlphaSurface(SDL_Surface *surface) +{ + SDL_Surface *dest; + const SDL_PixelFormatDetails *df; + int maxsize = 0; + int max_opaque_run; + int max_transl_run = 65535; + unsigned masksum; + Uint8 *rlebuf, *dst; + int (*copy_opaque)(void *, const Uint32 *, int, + const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *); + int (*copy_transl)(void *, const Uint32 *, int, + const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *); + + dest = surface->map.info.dst_surface; + if (!dest) { + return false; + } + df = dest->fmt; + if (surface->fmt->bits_per_pixel != 32) { + return false; // only 32bpp source supported + } + + /* find out whether the destination is one we support, + and determine the max size of the encoded result */ + masksum = df->Rmask | df->Gmask | df->Bmask; + switch (df->bytes_per_pixel) { + case 2: + // 16bpp: only support 565 and 555 formats + switch (masksum) { + case 0xffff: + if (df->Gmask == 0x07e0 || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) { + copy_opaque = copy_opaque_16; + copy_transl = copy_transl_565; + } else { + return false; + } + break; + case 0x7fff: + if (df->Gmask == 0x03e0 || df->Rmask == 0x03e0 || df->Bmask == 0x03e0) { + copy_opaque = copy_opaque_16; + copy_transl = copy_transl_555; + } else { + return false; + } + break; + default: + return false; + } + max_opaque_run = 255; // runs stored as bytes + + /* worst case is alternating opaque and translucent pixels, + with room for alignment padding between lines */ + maxsize = surface->h * (2 + (4 + 2) * (surface->w + 1)) + 2; + break; + case 4: + if (masksum != 0x00ffffff) { + return false; // requires unused high byte + } + copy_opaque = copy_32; + copy_transl = copy_32; + max_opaque_run = 255; // runs stored as short ints + + // worst case is alternating opaque and translucent pixels + maxsize = surface->h * 2 * 4 * (surface->w + 1) + 4; + break; + default: + return false; // anything else unsupported right now + } + + maxsize += sizeof(SDL_PixelFormat); + rlebuf = (Uint8 *)SDL_malloc(maxsize); + if (!rlebuf) { + return false; + } + // save the destination format so we can undo the encoding later + *(SDL_PixelFormat *)rlebuf = dest->format; + dst = rlebuf + sizeof(SDL_PixelFormat); + + // Do the actual encoding + { + int x, y; + int h = surface->h, w = surface->w; + const SDL_PixelFormatDetails *sf = surface->fmt; + Uint32 *src = (Uint32 *)surface->pixels; + Uint8 *lastline = dst; // end of last non-blank line + + // opaque counts are 8 or 16 bits, depending on target depth +#define ADD_OPAQUE_COUNTS(n, m) \ + if (df->bytes_per_pixel == 4) { \ + ((Uint16 *)dst)[0] = (Uint16)n; \ + ((Uint16 *)dst)[1] = (Uint16)m; \ + dst += 4; \ + } else { \ + dst[0] = (Uint8)n; \ + dst[1] = (Uint8)m; \ + dst += 2; \ + } + + // translucent counts are always 16 bit +#define ADD_TRANSL_COUNTS(n, m) \ + (((Uint16 *)dst)[0] = (Uint16)n, ((Uint16 *)dst)[1] = (Uint16)m, dst += 4) + + for (y = 0; y < h; y++) { + int runstart, skipstart; + int blankline = 0; + // First encode all opaque pixels of a scan line + x = 0; + do { + int run, skip, len; + skipstart = x; + while (x < w && !ISOPAQUE(src[x], sf)) { + x++; + } + runstart = x; + while (x < w && ISOPAQUE(src[x], sf)) { + x++; + } + skip = runstart - skipstart; + if (skip == w) { + blankline = 1; + } + run = x - runstart; + while (skip > max_opaque_run) { + ADD_OPAQUE_COUNTS(max_opaque_run, 0); + skip -= max_opaque_run; + } + len = SDL_min(run, max_opaque_run); + ADD_OPAQUE_COUNTS(skip, len); + dst += copy_opaque(dst, src + runstart, len, sf, df); + runstart += len; + run -= len; + while (run) { + len = SDL_min(run, max_opaque_run); + ADD_OPAQUE_COUNTS(0, len); + dst += copy_opaque(dst, src + runstart, len, sf, df); + runstart += len; + run -= len; + } + } while (x < w); + + // Make sure the next output address is 32-bit aligned + dst += (uintptr_t)dst & 2; + + // Next, encode all translucent pixels of the same scan line + x = 0; + do { + int run, skip, len; + skipstart = x; + while (x < w && !ISTRANSL(src[x], sf)) { + x++; + } + runstart = x; + while (x < w && ISTRANSL(src[x], sf)) { + x++; + } + skip = runstart - skipstart; + blankline &= (skip == w); + run = x - runstart; + while (skip > max_transl_run) { + ADD_TRANSL_COUNTS(max_transl_run, 0); + skip -= max_transl_run; + } + len = SDL_min(run, max_transl_run); + ADD_TRANSL_COUNTS(skip, len); + dst += copy_transl(dst, src + runstart, len, sf, df); + runstart += len; + run -= len; + while (run) { + len = SDL_min(run, max_transl_run); + ADD_TRANSL_COUNTS(0, len); + dst += copy_transl(dst, src + runstart, len, sf, df); + runstart += len; + run -= len; + } + if (!blankline) { + lastline = dst; + } + } while (x < w); + + src += surface->pitch >> 2; + } + dst = lastline; // back up past trailing blank lines + ADD_OPAQUE_COUNTS(0, 0); + } + +#undef ADD_OPAQUE_COUNTS +#undef ADD_TRANSL_COUNTS + + // Now that we have it encoded, release the original pixels + if (!(surface->flags & SDL_SURFACE_PREALLOCATED)) { + if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) { + SDL_aligned_free(surface->pixels); + surface->flags &= ~SDL_SURFACE_SIMD_ALIGNED; + } else { + SDL_free(surface->pixels); + } + surface->pixels = NULL; + } + + // reallocate the buffer to release unused memory + { + Uint8 *p = (Uint8 *)SDL_realloc(rlebuf, dst - rlebuf); + if (!p) { + p = rlebuf; + } + surface->map.data = p; + } + + return true; +} + +static Uint32 getpix_8(const Uint8 *srcbuf) +{ + return *srcbuf; +} + +static Uint32 getpix_16(const Uint8 *srcbuf) +{ + return *(const Uint16 *)srcbuf; +} + +static Uint32 getpix_24(const Uint8 *srcbuf) +{ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + return srcbuf[0] + (srcbuf[1] << 8) + (srcbuf[2] << 16); +#else + return (srcbuf[0] << 16) + (srcbuf[1] << 8) + srcbuf[2]; +#endif +} + +static Uint32 getpix_32(const Uint8 *srcbuf) +{ + return *(const Uint32 *)srcbuf; +} + +typedef Uint32 (*getpix_func)(const Uint8 *); + +static const getpix_func getpixes[4] = { + getpix_8, getpix_16, getpix_24, getpix_32 +}; + +static bool RLEColorkeySurface(SDL_Surface *surface) +{ + SDL_Surface *dest; + Uint8 *rlebuf, *dst; + int maxn; + int y; + Uint8 *srcbuf, *lastline; + int maxsize = 0; + const int bpp = surface->fmt->bytes_per_pixel; + getpix_func getpix; + Uint32 ckey, rgbmask; + int w, h; + + dest = surface->map.info.dst_surface; + if (!dest) { + return false; + } + + // calculate the worst case size for the compressed surface + switch (bpp) { + case 1: + /* worst case is alternating opaque and transparent pixels, + starting with an opaque pixel */ + maxsize = surface->h * 3 * (surface->w / 2 + 1) + 2; + break; + case 2: + case 3: + // worst case is solid runs, at most 255 pixels wide + maxsize = surface->h * (2 * (surface->w / 255 + 1) + surface->w * bpp) + 2; + break; + case 4: + // worst case is solid runs, at most 65535 pixels wide + maxsize = surface->h * (4 * (surface->w / 65535 + 1) + surface->w * 4) + 4; + break; + + default: + return false; + } + + maxsize += sizeof(SDL_PixelFormat); + rlebuf = (Uint8 *)SDL_malloc(maxsize); + if (!rlebuf) { + return false; + } + // save the destination format so we can undo the encoding later + *(SDL_PixelFormat *)rlebuf = dest->format; + + // Set up the conversion + srcbuf = (Uint8 *)surface->pixels; + maxn = bpp == 4 ? 65535 : 255; + dst = rlebuf + sizeof(SDL_PixelFormat); + rgbmask = ~surface->fmt->Amask; + ckey = surface->map.info.colorkey & rgbmask; + lastline = dst; + getpix = getpixes[bpp - 1]; + w = surface->w; + h = surface->h; + +#define ADD_COUNTS(n, m) \ + if (bpp == 4) { \ + ((Uint16 *)dst)[0] = (Uint16)n; \ + ((Uint16 *)dst)[1] = (Uint16)m; \ + dst += 4; \ + } else { \ + dst[0] = (Uint8)n; \ + dst[1] = (Uint8)m; \ + dst += 2; \ + } + + for (y = 0; y < h; y++) { + int x = 0; + int blankline = 0; + do { + int run, skip; + int len; + int runstart; + int skipstart = x; + + // find run of transparent, then opaque pixels + while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) == ckey) { + x++; + } + runstart = x; + while (x < w && (getpix(srcbuf + x * bpp) & rgbmask) != ckey) { + x++; + } + skip = runstart - skipstart; + if (skip == w) { + blankline = 1; + } + run = x - runstart; + + // encode segment + while (skip > maxn) { + ADD_COUNTS(maxn, 0); + skip -= maxn; + } + len = SDL_min(run, maxn); + ADD_COUNTS(skip, len); + SDL_memcpy(dst, srcbuf + runstart * bpp, (size_t)len * bpp); + dst += len * bpp; + run -= len; + runstart += len; + while (run) { + len = SDL_min(run, maxn); + ADD_COUNTS(0, len); + SDL_memcpy(dst, srcbuf + runstart * bpp, (size_t)len * bpp); + dst += len * bpp; + runstart += len; + run -= len; + } + if (!blankline) { + lastline = dst; + } + } while (x < w); + + srcbuf += surface->pitch; + } + dst = lastline; // back up bast trailing blank lines + ADD_COUNTS(0, 0); + +#undef ADD_COUNTS + + // Now that we have it encoded, release the original pixels + if (!(surface->flags & SDL_SURFACE_PREALLOCATED)) { + if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) { + SDL_aligned_free(surface->pixels); + surface->flags &= ~SDL_SURFACE_SIMD_ALIGNED; + } else { + SDL_free(surface->pixels); + } + surface->pixels = NULL; + } + + // reallocate the buffer to release unused memory + { + // If SDL_realloc returns NULL, the original block is left intact + Uint8 *p = (Uint8 *)SDL_realloc(rlebuf, dst - rlebuf); + if (!p) { + p = rlebuf; + } + surface->map.data = p; + } + + return true; +} + +bool SDL_RLESurface(SDL_Surface *surface) +{ + int flags; + + // Clear any previous RLE conversion + if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) { + SDL_UnRLESurface(surface, true); + } + + // We don't support RLE encoding of bitmaps + if (SDL_BITSPERPIXEL(surface->format) < 8) { + return false; + } + + // Make sure the pixels are available + if (!surface->pixels) { + return false; + } + + flags = surface->map.info.flags; + if (flags & SDL_COPY_COLORKEY) { + // ok + } else if ((flags & SDL_COPY_BLEND) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) { + // ok + } else { + // If we don't have colorkey or blending, nothing to do... + return false; + } + + // Pass on combinations not supported + if ((flags & SDL_COPY_MODULATE_COLOR) || + ((flags & SDL_COPY_MODULATE_ALPHA) && SDL_ISPIXELFORMAT_ALPHA(surface->format)) || + (flags & (SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL)) || + (flags & SDL_COPY_NEAREST)) { + return false; + } + + // Encode and set up the blit + if (!SDL_ISPIXELFORMAT_ALPHA(surface->format) || !(flags & SDL_COPY_BLEND)) { + if (!surface->map.identity) { + return false; + } + if (!RLEColorkeySurface(surface)) { + return false; + } + surface->map.blit = SDL_RLEBlit; + surface->map.info.flags |= SDL_COPY_RLE_COLORKEY; + } else { + if (!RLEAlphaSurface(surface)) { + return false; + } + surface->map.blit = SDL_RLEAlphaBlit; + surface->map.info.flags |= SDL_COPY_RLE_ALPHAKEY; + } + + // The surface is now accelerated + surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL; + + return true; +} + +/* + * Un-RLE a surface with pixel alpha + * This may not give back exactly the image before RLE-encoding; all + * completely transparent pixels will be lost, and color and alpha depth + * may have been reduced (when encoding for 16bpp targets). + */ +static bool UnRLEAlpha(SDL_Surface *surface) +{ + Uint8 *srcbuf; + Uint32 *dst; + const SDL_PixelFormatDetails *sf = surface->fmt; + const SDL_PixelFormatDetails *df = SDL_GetPixelFormatDetails(*(SDL_PixelFormat *)surface->map.data); + int (*uncopy_opaque)(Uint32 *, const void *, int, + const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *); + int (*uncopy_transl)(Uint32 *, const void *, int, + const SDL_PixelFormatDetails *, const SDL_PixelFormatDetails *); + int w = surface->w; + int bpp = df->bytes_per_pixel; + size_t size; + + if (bpp == 2) { + uncopy_opaque = uncopy_opaque_16; + uncopy_transl = uncopy_transl_16; + } else { + uncopy_opaque = uncopy_transl = uncopy_32; + } + + if (!SDL_size_mul_check_overflow(surface->h, surface->pitch, &size)) { + return false; + } + + surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); + if (!surface->pixels) { + return false; + } + surface->flags |= SDL_SURFACE_SIMD_ALIGNED; + // fill background with transparent pixels + SDL_memset(surface->pixels, 0, (size_t)surface->h * surface->pitch); + + dst = (Uint32 *)surface->pixels; + srcbuf = (Uint8 *)surface->map.data + sizeof(SDL_PixelFormat); + for (;;) { + // copy opaque pixels + int ofs = 0; + do { + unsigned run; + if (bpp == 2) { + ofs += srcbuf[0]; + run = srcbuf[1]; + srcbuf += 2; + } else { + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; + srcbuf += 4; + } + if (run) { + srcbuf += uncopy_opaque(dst + ofs, srcbuf, run, df, sf); + ofs += run; + } else if (!ofs) { + goto end_function; + } + } while (ofs < w); + + // skip padding if needed + if (bpp == 2) { + srcbuf += (uintptr_t)srcbuf & 2; + } + + // copy translucent pixels + ofs = 0; + do { + unsigned run; + ofs += ((Uint16 *)srcbuf)[0]; + run = ((Uint16 *)srcbuf)[1]; + srcbuf += 4; + if (run) { + srcbuf += uncopy_transl(dst + ofs, srcbuf, run, df, sf); + ofs += run; + } + } while (ofs < w); + dst += surface->pitch >> 2; + } + +end_function: + return true; +} + +void SDL_UnRLESurface(SDL_Surface *surface, bool recode) +{ + if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) { + surface->internal_flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL; + + if (recode && !(surface->flags & SDL_SURFACE_PREALLOCATED)) { + if (surface->map.info.flags & SDL_COPY_RLE_COLORKEY) { + SDL_Rect full; + size_t size; + + // re-create the original surface + if (!SDL_size_mul_check_overflow(surface->h, surface->pitch, &size)) { + // Memory corruption? + surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL; + return; + } + surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); + if (!surface->pixels) { + // Oh crap... + surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL; + return; + } + surface->flags |= SDL_SURFACE_SIMD_ALIGNED; + + // fill it with the background color + SDL_FillSurfaceRect(surface, NULL, surface->map.info.colorkey); + + // now render the encoded surface + full.x = full.y = 0; + full.w = surface->w; + full.h = surface->h; + SDL_RLEBlit(surface, &full, surface, &full); + } else { + if (!UnRLEAlpha(surface)) { + // Oh crap... + surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL; + return; + } + } + } + surface->map.info.flags &= + ~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY); + + SDL_free(surface->map.data); + surface->map.data = NULL; + } +} + +#endif // SDL_HAVE_RLE diff --git a/contrib/SDL-3.2.8/src/video/SDL_RLEaccel_c.h b/contrib/SDL-3.2.8/src/video/SDL_RLEaccel_c.h new file mode 100644 index 0000000..5a89a09 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_RLEaccel_c.h @@ -0,0 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_RLEaccel_c_h_ +#define SDL_RLEaccel_c_h_ + +#include "SDL_internal.h" + +// Useful functions and variables from SDL_RLEaccel.c + +extern bool SDL_RLESurface(SDL_Surface *surface); +extern void SDL_UnRLESurface(SDL_Surface *surface, bool recode); + +#endif // SDL_RLEaccel_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit.c b/contrib/SDL-3.2.8/src/video/SDL_blit.c new file mode 100644 index 0000000..5ffd181 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit.c @@ -0,0 +1,290 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_sysvideo.h" +#include "SDL_surface_c.h" +#include "SDL_blit_auto.h" +#include "SDL_blit_copy.h" +#include "SDL_blit_slow.h" +#include "SDL_RLEaccel_c.h" +#include "SDL_pixels_c.h" + +// The general purpose software blit routine +static bool SDLCALL SDL_SoftBlit(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, const SDL_Rect *dstrect) +{ + bool okay; + int src_locked; + int dst_locked; + + // Everything is okay at the beginning... + okay = true; + + // Lock the destination if it's in hardware + dst_locked = 0; + if (SDL_MUSTLOCK(dst)) { + if (!SDL_LockSurface(dst)) { + okay = false; + } else { + dst_locked = 1; + } + } + // Lock the source if it's in hardware + src_locked = 0; + if (SDL_MUSTLOCK(src)) { + if (!SDL_LockSurface(src)) { + okay = false; + } else { + src_locked = 1; + } + } + + // Set up source and destination buffer pointers, and BLIT! + if (okay) { + SDL_BlitFunc RunBlit; + SDL_BlitInfo *info = &src->map.info; + + // Set up the blit information + info->src = (Uint8 *)src->pixels + + (Uint16)srcrect->y * src->pitch + + (Uint16)srcrect->x * info->src_fmt->bytes_per_pixel; + info->src_w = srcrect->w; + info->src_h = srcrect->h; + info->src_pitch = src->pitch; + info->src_skip = + info->src_pitch - info->src_w * info->src_fmt->bytes_per_pixel; + info->dst = + (Uint8 *)dst->pixels + (Uint16)dstrect->y * dst->pitch + + (Uint16)dstrect->x * info->dst_fmt->bytes_per_pixel; + info->dst_w = dstrect->w; + info->dst_h = dstrect->h; + info->dst_pitch = dst->pitch; + info->dst_skip = + info->dst_pitch - info->dst_w * info->dst_fmt->bytes_per_pixel; + RunBlit = (SDL_BlitFunc)src->map.data; + + // Run the actual software blit + RunBlit(info); + } + + // We need to unlock the surfaces if they're locked + if (dst_locked) { + SDL_UnlockSurface(dst); + } + if (src_locked) { + SDL_UnlockSurface(src); + } + // Blit is done! + return okay; +} + +#ifdef SDL_HAVE_BLIT_AUTO + +#ifdef SDL_PLATFORM_MACOS +#include + +static bool SDL_UseAltivecPrefetch(void) +{ + const char key[] = "hw.l3cachesize"; + u_int64_t result = 0; + size_t typeSize = sizeof(result); + + if (sysctlbyname(key, &result, &typeSize, NULL, 0) == 0 && result > 0) { + return true; + } else { + return false; + } +} +#else +static bool SDL_UseAltivecPrefetch(void) +{ + // Just guess G4 + return true; +} +#endif // SDL_PLATFORM_MACOS + +static SDL_BlitFunc SDL_ChooseBlitFunc(SDL_PixelFormat src_format, SDL_PixelFormat dst_format, int flags, + SDL_BlitFuncEntry *entries) +{ + int i, flagcheck = (flags & (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_COLORKEY | SDL_COPY_NEAREST)); + static unsigned int features = 0x7fffffff; + + // Get the available CPU features + if (features == 0x7fffffff) { + features = SDL_CPU_ANY; + if (SDL_HasMMX()) { + features |= SDL_CPU_MMX; + } + if (SDL_HasSSE()) { + features |= SDL_CPU_SSE; + } + if (SDL_HasSSE2()) { + features |= SDL_CPU_SSE2; + } + if (SDL_HasAltiVec()) { + if (SDL_UseAltivecPrefetch()) { + features |= SDL_CPU_ALTIVEC_PREFETCH; + } else { + features |= SDL_CPU_ALTIVEC_NOPREFETCH; + } + } + } + + for (i = 0; entries[i].func; ++i) { + // Check for matching pixel formats + if (src_format != entries[i].src_format) { + continue; + } + if (dst_format != entries[i].dst_format) { + continue; + } + + // Check flags + if ((flagcheck & entries[i].flags) != flagcheck) { + continue; + } + + // Check CPU features + if ((entries[i].cpu & features) != entries[i].cpu) { + continue; + } + + // We found the best one! + return entries[i].func; + } + return NULL; +} +#endif // SDL_HAVE_BLIT_AUTO + +// Figure out which of many blit routines to set up on a surface +bool SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst) +{ + SDL_BlitFunc blit = NULL; + SDL_BlitMap *map = &surface->map; + SDL_Colorspace src_colorspace = surface->colorspace; + SDL_Colorspace dst_colorspace = dst->colorspace; + + // We don't currently support blitting to < 8 bpp surfaces + if (SDL_BITSPERPIXEL(dst->format) < 8) { + SDL_InvalidateMap(map); + return SDL_SetError("Blit combination not supported"); + } + +#ifdef SDL_HAVE_RLE + // Clean everything out to start + if (surface->flags & SDL_INTERNAL_SURFACE_RLEACCEL) { + SDL_UnRLESurface(surface, true); + } +#endif + + map->blit = SDL_SoftBlit; + map->info.src_surface = surface; + map->info.src_fmt = surface->fmt; + map->info.src_pal = surface->palette; + map->info.dst_surface = dst; + map->info.dst_fmt = dst->fmt; + map->info.dst_pal = dst->palette; + +#ifdef SDL_HAVE_RLE + // See if we can do RLE acceleration + if (map->info.flags & SDL_COPY_RLE_DESIRED) { + if (SDL_RLESurface(surface)) { + return true; + } + } +#endif + + // Choose a standard blit function + if (!blit) { + if (src_colorspace != dst_colorspace || + SDL_BYTESPERPIXEL(surface->format) > 4 || + SDL_BYTESPERPIXEL(dst->format) > 4) { + blit = SDL_Blit_Slow_Float; + } + } + if (!blit) { + if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) { + blit = SDL_BlitCopy; + } else if (SDL_ISPIXELFORMAT_10BIT(surface->format) || + SDL_ISPIXELFORMAT_10BIT(dst->format)) { + blit = SDL_Blit_Slow; + } +#ifdef SDL_HAVE_BLIT_0 + else if (SDL_BITSPERPIXEL(surface->format) < 8 && + SDL_ISPIXELFORMAT_INDEXED(surface->format)) { + blit = SDL_CalculateBlit0(surface); + } +#endif +#ifdef SDL_HAVE_BLIT_1 + else if (SDL_BYTESPERPIXEL(surface->format) == 1 && + SDL_ISPIXELFORMAT_INDEXED(surface->format)) { + blit = SDL_CalculateBlit1(surface); + } +#endif +#ifdef SDL_HAVE_BLIT_A + else if (map->info.flags & SDL_COPY_BLEND) { + blit = SDL_CalculateBlitA(surface); + } +#endif +#ifdef SDL_HAVE_BLIT_N + else { + blit = SDL_CalculateBlitN(surface); + } +#endif + } +#ifdef SDL_HAVE_BLIT_AUTO + if (!blit) { + SDL_PixelFormat src_format = surface->format; + SDL_PixelFormat dst_format = dst->format; + + blit = + SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, + SDL_GeneratedBlitFuncTable); + } +#endif + +#ifndef TEST_SLOW_BLIT + if (!blit) +#endif + { + SDL_PixelFormat src_format = surface->format; + SDL_PixelFormat dst_format = dst->format; + + if ((!SDL_ISPIXELFORMAT_INDEXED(src_format) || + (src_format == SDL_PIXELFORMAT_INDEX8 && surface->palette)) && + !SDL_ISPIXELFORMAT_FOURCC(src_format) && + (!SDL_ISPIXELFORMAT_INDEXED(dst_format) || + (dst_format == SDL_PIXELFORMAT_INDEX8 && dst->palette)) && + !SDL_ISPIXELFORMAT_FOURCC(dst_format)) { + blit = SDL_Blit_Slow; + } + } + map->data = (void *)blit; + + // Make sure we have a blit function + if (!blit) { + SDL_InvalidateMap(map); + return SDL_SetError("Blit combination not supported"); + } + + return true; +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit.h b/contrib/SDL-3.2.8/src/video/SDL_blit.h new file mode 100644 index 0000000..714feeb --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit.h @@ -0,0 +1,751 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_blit_h_ +#define SDL_blit_h_ + +// Table to do pixel byte expansion +extern const Uint8 *SDL_expand_byte[9]; +extern const Uint16 SDL_expand_byte_10[]; + +// SDL blit copy flags +#define SDL_COPY_MODULATE_COLOR 0x00000001 +#define SDL_COPY_MODULATE_ALPHA 0x00000002 +#define SDL_COPY_MODULATE_MASK (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA) +#define SDL_COPY_BLEND 0x00000010 +#define SDL_COPY_BLEND_PREMULTIPLIED 0x00000020 +#define SDL_COPY_ADD 0x00000040 +#define SDL_COPY_ADD_PREMULTIPLIED 0x00000080 +#define SDL_COPY_MOD 0x00000100 +#define SDL_COPY_MUL 0x00000200 +#define SDL_COPY_BLEND_MASK (SDL_COPY_BLEND | SDL_COPY_BLEND_PREMULTIPLIED | SDL_COPY_ADD | SDL_COPY_ADD_PREMULTIPLIED | SDL_COPY_MOD | SDL_COPY_MUL) +#define SDL_COPY_COLORKEY 0x00000400 +#define SDL_COPY_NEAREST 0x00000800 +#define SDL_COPY_RLE_DESIRED 0x00001000 +#define SDL_COPY_RLE_COLORKEY 0x00002000 +#define SDL_COPY_RLE_ALPHAKEY 0x00004000 +#define SDL_COPY_RLE_MASK (SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY) + +// SDL blit CPU flags +#define SDL_CPU_ANY 0x00000000 +#define SDL_CPU_MMX 0x00000001 +#define SDL_CPU_SSE 0x00000002 +#define SDL_CPU_SSE2 0x00000004 +#define SDL_CPU_ALTIVEC_PREFETCH 0x00000008 +#define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000010 + +typedef struct +{ + SDL_Surface *src_surface; + Uint8 *src; + int src_w, src_h; + int src_pitch; + int src_skip; + SDL_Surface *dst_surface; + Uint8 *dst; + int dst_w, dst_h; + int dst_pitch; + int dst_skip; + const SDL_PixelFormatDetails *src_fmt; + const SDL_Palette *src_pal; + const SDL_PixelFormatDetails *dst_fmt; + const SDL_Palette *dst_pal; + Uint8 *table; + SDL_HashTable *palette_map; + int flags; + Uint32 colorkey; + Uint8 r, g, b, a; +} SDL_BlitInfo; + +typedef void (*SDL_BlitFunc)(SDL_BlitInfo *info); + +typedef struct +{ + SDL_PixelFormat src_format; + SDL_PixelFormat dst_format; + int flags; + unsigned int cpu; + SDL_BlitFunc func; +} SDL_BlitFuncEntry; + +typedef bool (SDLCALL *SDL_Blit) (struct SDL_Surface *src, const SDL_Rect *srcrect, struct SDL_Surface *dst, const SDL_Rect *dstrect); + +// Blit mapping definition +typedef struct SDL_BlitMap +{ + int identity; + SDL_Blit blit; + void *data; + SDL_BlitInfo info; + + /* the version count matches the destination; mismatch indicates + an invalid mapping */ + Uint32 dst_palette_version; + Uint32 src_palette_version; +} SDL_BlitMap; + +// Functions found in SDL_blit.c +extern bool SDL_CalculateBlit(SDL_Surface *surface, SDL_Surface *dst); + +/* Functions found in SDL_blit_*.c */ +extern SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface); +extern SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface); +extern SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface); +extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface); + +/* + * Useful macros for blitting routines + */ + +#ifdef __GNUC__ +#define DECLARE_ALIGNED(t, v, a) t __attribute__((aligned(a))) v +#elif defined(_MSC_VER) +#define DECLARE_ALIGNED(t, v, a) __declspec(align(a)) t v +#else +#define DECLARE_ALIGNED(t, v, a) t v +#endif + +// Load pixel of the specified format from a buffer and get its R-G-B values +#define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \ + { \ + r = SDL_expand_byte[fmt->Rbits][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gbits][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bbits][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \ + } +#define RGB_FROM_RGB565(Pixel, r, g, b) \ + { \ + r = SDL_expand_byte[5][((Pixel & 0xF800) >> 11)]; \ + g = SDL_expand_byte[6][((Pixel & 0x07E0) >> 5)]; \ + b = SDL_expand_byte[5][(Pixel & 0x001F)]; \ + } +#define RGB_FROM_RGB555(Pixel, r, g, b) \ + { \ + r = SDL_expand_byte[5][((Pixel & 0x7C00) >> 10)]; \ + g = SDL_expand_byte[5][((Pixel & 0x03E0) >> 5)]; \ + b = SDL_expand_byte[5][(Pixel & 0x001F)]; \ + } +#define RGB_FROM_XRGB8888(Pixel, r, g, b) \ + { \ + r = ((Pixel & 0xFF0000) >> 16); \ + g = ((Pixel & 0xFF00) >> 8); \ + b = (Pixel & 0xFF); \ + } +#define RETRIEVE_RGB_PIXEL(buf, bpp, Pixel) \ + do { \ + switch (bpp) { \ + case 1: \ + Pixel = *((Uint8 *)(buf)); \ + break; \ + \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + break; \ + \ + case 3: \ + { \ + Uint8 *B = (Uint8 *)(buf); \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + Pixel = B[0] + (B[1] << 8) + (B[2] << 16); \ + } else { \ + Pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \ + } \ + } break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + break; \ + \ + default: \ + Pixel = 0; /* stop gcc complaints */ \ + break; \ + } \ + } while (0) + +#define DISEMBLE_RGB(buf, bpp, fmt, Pixel, r, g, b) \ + do { \ + switch (bpp) { \ + case 1: \ + Pixel = *((Uint8 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + case 3: \ + { \ + Pixel = 0; \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + r = *((buf) + fmt->Rshift / 8); \ + g = *((buf) + fmt->Gshift / 8); \ + b = *((buf) + fmt->Bshift / 8); \ + } else { \ + r = *((buf) + 2 - fmt->Rshift / 8); \ + g = *((buf) + 2 - fmt->Gshift / 8); \ + b = *((buf) + 2 - fmt->Bshift / 8); \ + } \ + } break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + RGB_FROM_PIXEL(Pixel, fmt, r, g, b); \ + break; \ + \ + default: \ + /* stop gcc complaints */ \ + Pixel = 0; \ + r = g = b = 0; \ + break; \ + } \ + } while (0) + +// Assemble R-G-B values into a specified pixel format and store them +#define PIXEL_FROM_RGB(Pixel, fmt, r, g, b) \ + { \ + Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \ + ((g >> (8 - fmt->Gbits)) << fmt->Gshift) | \ + ((b >> (8 - fmt->Bbits)) << fmt->Bshift) | \ + fmt->Amask; \ + } +#define RGB332_FROM_RGB(Pixel, r, g, b) \ + { \ + Pixel = (Uint8)(((r >> 5) << 5) | ((g >> 5) << 2) | (b >> 6)); \ + } +#define RGB565_FROM_RGB(Pixel, r, g, b) \ + { \ + Pixel = (Uint16)(((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); \ + } +#define RGB555_FROM_RGB(Pixel, r, g, b) \ + { \ + Pixel = (Uint16)(((r >> 3) << 10) | ((g >> 3) << 5) | (b >> 3)); \ + } +#define XRGB8888_FROM_RGB(Pixel, r, g, b) \ + { \ + Pixel = (r << 16) | (g << 8) | b; \ + } +#define ARGB8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (a << 24) | (r << 16) | (g << 8) | b; \ + } +#define RGBA8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (r << 24) | (g << 16) | (b << 8) | a; \ + } +#define ABGR8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (a << 24) | (b << 16) | (g << 8) | r; \ + } +#define BGRA8888_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + Pixel = (b << 24) | (g << 16) | (r << 8) | a; \ + } +#define ARGB2101010_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + r = r ? ((r << 2) | 0x3) : 0; \ + g = g ? ((g << 2) | 0x3) : 0; \ + b = b ? ((b << 2) | 0x3) : 0; \ + a = (a * 3) / 255; \ + Pixel = (a << 30) | (r << 20) | (g << 10) | b; \ + } +#define ARGB2101010_FROM_RGBAFLOAT(Pixel, r, g, b, a) \ + { \ + r = SDL_clamp(r, 0.0f, 1.0f) * 1023.0f; \ + g = SDL_clamp(g, 0.0f, 1.0f) * 1023.0f; \ + b = SDL_clamp(b, 0.0f, 1.0f) * 1023.0f; \ + a = SDL_clamp(a, 0.0f, 1.0f) * 3.0f; \ + Pixel = (((Uint32)SDL_roundf(a)) << 30) | \ + (((Uint32)SDL_roundf(r)) << 20) | \ + (((Uint32)SDL_roundf(g)) << 10) | \ + (Uint32)SDL_roundf(b); \ + } +#define ABGR2101010_FROM_RGBA(Pixel, r, g, b, a) \ + { \ + r = r ? ((r << 2) | 0x3) : 0; \ + g = g ? ((g << 2) | 0x3) : 0; \ + b = b ? ((b << 2) | 0x3) : 0; \ + a = (a * 3) / 255; \ + Pixel = (a << 30) | (b << 20) | (g << 10) | r; \ + } +#define ABGR2101010_FROM_RGBAFLOAT(Pixel, r, g, b, a) \ + { \ + r = SDL_clamp(r, 0.0f, 1.0f) * 1023.0f; \ + g = SDL_clamp(g, 0.0f, 1.0f) * 1023.0f; \ + b = SDL_clamp(b, 0.0f, 1.0f) * 1023.0f; \ + a = SDL_clamp(a, 0.0f, 1.0f) * 3.0f; \ + Pixel = (((Uint32)SDL_roundf(a)) << 30) | \ + (((Uint32)SDL_roundf(b)) << 20) | \ + (((Uint32)SDL_roundf(g)) << 10) | \ + (Uint32)SDL_roundf(r); \ + } +#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) \ + { \ + switch (bpp) { \ + case 1: \ + { \ + Uint8 _pixel; \ + \ + PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ + *((Uint8 *)(buf)) = _pixel; \ + } break; \ + \ + case 2: \ + { \ + Uint16 _pixel; \ + \ + PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ + *((Uint16 *)(buf)) = _pixel; \ + } break; \ + \ + case 3: \ + { \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + *((buf) + fmt->Rshift / 8) = r; \ + *((buf) + fmt->Gshift / 8) = g; \ + *((buf) + fmt->Bshift / 8) = b; \ + } else { \ + *((buf) + 2 - fmt->Rshift / 8) = r; \ + *((buf) + 2 - fmt->Gshift / 8) = g; \ + *((buf) + 2 - fmt->Bshift / 8) = b; \ + } \ + } break; \ + \ + case 4: \ + { \ + Uint32 _pixel; \ + \ + PIXEL_FROM_RGB(_pixel, fmt, r, g, b); \ + *((Uint32 *)(buf)) = _pixel; \ + } break; \ + } \ + } + +// FIXME: Should we rescale alpha into 0..255 here? +#define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ + { \ + r = SDL_expand_byte[fmt->Rbits][((Pixel & fmt->Rmask) >> fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gbits][((Pixel & fmt->Gmask) >> fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bbits][((Pixel & fmt->Bmask) >> fmt->Bshift)]; \ + a = SDL_expand_byte[fmt->Abits][((Pixel & fmt->Amask) >> fmt->Ashift)]; \ + } +#define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \ + { \ + r = (Pixel & fmt->Rmask) >> fmt->Rshift; \ + g = (Pixel & fmt->Gmask) >> fmt->Gshift; \ + b = (Pixel & fmt->Bmask) >> fmt->Bshift; \ + a = (Pixel & fmt->Amask) >> fmt->Ashift; \ + } +#define RGBA_FROM_RGBA8888(Pixel, r, g, b, a) \ + { \ + r = (Pixel >> 24); \ + g = ((Pixel >> 16) & 0xFF); \ + b = ((Pixel >> 8) & 0xFF); \ + a = (Pixel & 0xFF); \ + } +#define RGBA_FROM_ARGB8888(Pixel, r, g, b, a) \ + { \ + r = ((Pixel >> 16) & 0xFF); \ + g = ((Pixel >> 8) & 0xFF); \ + b = (Pixel & 0xFF); \ + a = (Pixel >> 24); \ + } +#define RGBA_FROM_ABGR8888(Pixel, r, g, b, a) \ + { \ + r = (Pixel & 0xFF); \ + g = ((Pixel >> 8) & 0xFF); \ + b = ((Pixel >> 16) & 0xFF); \ + a = (Pixel >> 24); \ + } +#define RGBA_FROM_BGRA8888(Pixel, r, g, b, a) \ + { \ + r = ((Pixel >> 8) & 0xFF); \ + g = ((Pixel >> 16) & 0xFF); \ + b = (Pixel >> 24); \ + a = (Pixel & 0xFF); \ + } +#define RGBA_FROM_ARGB2101010(Pixel, r, g, b, a) \ + { \ + r = ((Pixel >> 22) & 0xFF); \ + g = ((Pixel >> 12) & 0xFF); \ + b = ((Pixel >> 2) & 0xFF); \ + a = SDL_expand_byte[2][(Pixel >> 30)]; \ + } +#define RGBAFLOAT_FROM_ARGB2101010(Pixel, r, g, b, a) \ + { \ + r = (float)((Pixel >> 20) & 0x3FF) / 1023.0f; \ + g = (float)((Pixel >> 10) & 0x3FF) / 1023.0f; \ + b = (float)((Pixel >> 0) & 0x3FF) / 1023.0f; \ + a = (float)(Pixel >> 30) / 3.0f; \ + } +#define RGBA_FROM_ABGR2101010(Pixel, r, g, b, a) \ + { \ + r = ((Pixel >> 2) & 0xFF); \ + g = ((Pixel >> 12) & 0xFF); \ + b = ((Pixel >> 22) & 0xFF); \ + a = SDL_expand_byte[2][(Pixel >> 30)]; \ + } +#define RGBAFLOAT_FROM_ABGR2101010(Pixel, r, g, b, a) \ + { \ + r = (float)((Pixel >> 0) & 0x3FF) / 1023.0f; \ + g = (float)((Pixel >> 10) & 0x3FF) / 1023.0f; \ + b = (float)((Pixel >> 20) & 0x3FF) / 1023.0f; \ + a = (float)(Pixel >> 30) / 3.0f; \ + } +#define DISEMBLE_RGBA(buf, bpp, fmt, Pixel, r, g, b, a) \ + do { \ + switch (bpp) { \ + case 1: \ + Pixel = *((Uint8 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + case 2: \ + Pixel = *((Uint16 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + case 3: \ + { \ + Pixel = 0; \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + r = *((buf) + fmt->Rshift / 8); \ + g = *((buf) + fmt->Gshift / 8); \ + b = *((buf) + fmt->Bshift / 8); \ + } else { \ + r = *((buf) + 2 - fmt->Rshift / 8); \ + g = *((buf) + 2 - fmt->Gshift / 8); \ + b = *((buf) + 2 - fmt->Bshift / 8); \ + } \ + a = 0xFF; \ + } break; \ + \ + case 4: \ + Pixel = *((Uint32 *)(buf)); \ + RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a); \ + break; \ + \ + default: \ + /* stop gcc complaints */ \ + Pixel = 0; \ + r = g = b = a = 0; \ + break; \ + } \ + } while (0) + +// FIXME: this isn't correct, especially for Alpha (maximum != 255) +#define PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a) \ + { \ + Pixel = ((r >> (8 - fmt->Rbits)) << fmt->Rshift) | \ + ((g >> (8 - fmt->Gbits)) << fmt->Gshift) | \ + ((b >> (8 - fmt->Bbits)) << fmt->Bshift) | \ + ((a >> (8 - fmt->Abits)) << fmt->Ashift); \ + } +#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \ + { \ + switch (bpp) { \ + case 1: \ + { \ + Uint8 _pixel; \ + \ + PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ + *((Uint8 *)(buf)) = _pixel; \ + } break; \ + \ + case 2: \ + { \ + Uint16 _pixel; \ + \ + PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ + *((Uint16 *)(buf)) = _pixel; \ + } break; \ + \ + case 3: \ + { \ + if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ + *((buf) + fmt->Rshift / 8) = r; \ + *((buf) + fmt->Gshift / 8) = g; \ + *((buf) + fmt->Bshift / 8) = b; \ + } else { \ + *((buf) + 2 - fmt->Rshift / 8) = r; \ + *((buf) + 2 - fmt->Gshift / 8) = g; \ + *((buf) + 2 - fmt->Bshift / 8) = b; \ + } \ + } break; \ + \ + case 4: \ + { \ + Uint32 _pixel; \ + \ + PIXEL_FROM_RGBA(_pixel, fmt, r, g, b, a); \ + *((Uint32 *)(buf)) = _pixel; \ + } break; \ + } \ + } + +// Convert any 32-bit 4-bpp pixel to ARGB format +#define PIXEL_TO_ARGB_PIXEL(src, srcfmt, dst) \ + do { \ + Uint8 a, r, g, b; \ + RGBA_FROM_PIXEL(src, srcfmt, r, g, b, a); \ + dst = a << 24 | r << 16 | g << 8 | b; \ + } while (0) +// Blend a single color channel or alpha value +/* dC = ((sC * sA) + (dC * (255 - sA))) / 255 */ +#define ALPHA_BLEND_CHANNEL(sC, dC, sA) \ + do { \ + Uint16 x; \ + x = ((sC - dC) * sA) + ((dC << 8) - dC); \ + x += 0x1U; \ + x += x >> 8; \ + dC = x >> 8; \ + } while (0) +// Perform a division by 255 after a multiplication of two 8-bit color channels +/* out = (sC * dC) / 255 */ +#define MULT_DIV_255(sC, dC, out) \ + do { \ + Uint16 x = sC * dC; \ + x += 0x1U; \ + x += x >> 8; \ + out = x >> 8; \ + } while (0) +// Blend the RGB values of two pixels with an alpha value +#define ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB) \ + do { \ + ALPHA_BLEND_CHANNEL(sR, dR, A); \ + ALPHA_BLEND_CHANNEL(sG, dG, A); \ + ALPHA_BLEND_CHANNEL(sB, dB, A); \ + } while (0) + +// Blend two 8888 pixels with the same format +/* Calculates dst = ((src * factor) + (dst * (255 - factor))) / 255 */ +// FIXME: SDL_SIZE_MAX might not be an integer literal +#if defined(SIZE_MAX) && (SIZE_MAX == 0xffffffffffffffff) +#define FACTOR_BLEND_8888(src, dst, factor) \ + do { \ + Uint64 src64 = src; \ + src64 = (src64 | (src64 << 24)) & 0x00FF00FF00FF00FF; \ + \ + Uint64 dst64 = dst; \ + dst64 = (dst64 | (dst64 << 24)) & 0x00FF00FF00FF00FF; \ + \ + dst64 = ((src64 - dst64) * factor) + (dst64 << 8) - dst64; \ + dst64 += 0x0001000100010001; \ + dst64 += (dst64 >> 8) & 0x00FF00FF00FF00FF; \ + dst64 &= 0xFF00FF00FF00FF00; \ + \ + dst = (Uint32)((dst64 >> 8) | (dst64 >> 32)); \ + } while (0) +#else +#define FACTOR_BLEND_8888(src, dst, factor) \ + do { \ + Uint32 src02 = src & 0x00FF00FF; \ + Uint32 dst02 = dst & 0x00FF00FF; \ + \ + Uint32 src13 = (src >> 8) & 0x00FF00FF; \ + Uint32 dst13 = (dst >> 8) & 0x00FF00FF; \ + \ + Uint32 res02 = ((src02 - dst02) * factor) + (dst02 << 8) - dst02; \ + res02 += 0x00010001; \ + res02 += (res02 >> 8) & 0x00FF00FF; \ + res02 = (res02 >> 8) & 0x00FF00FF; \ + \ + Uint32 res13 = ((src13 - dst13) * factor) + (dst13 << 8) - dst13; \ + res13 += 0x00010001; \ + res13 += (res13 >> 8) & 0x00FF00FF; \ + res13 &= 0xFF00FF00; \ + dst = res02 | res13; \ + } while (0) +#endif + +// Alpha blend two 8888 pixels with the same formats. +#define ALPHA_BLEND_8888(src, dst, fmt) \ + do { \ + Uint32 srcA = (src >> fmt->Ashift) & 0xFF; \ + Uint32 tmp = src | fmt->Amask; \ + FACTOR_BLEND_8888(tmp, dst, srcA); \ + } while (0) + +// Alpha blend two 8888 pixels with differing formats. +#define ALPHA_BLEND_SWIZZLE_8888(src, dst, srcfmt, dstfmt) \ + do { \ + Uint32 srcA = (src >> srcfmt->Ashift) & 0xFF; \ + Uint32 tmp = (((src >> srcfmt->Rshift) & 0xFF) << dstfmt->Rshift) | \ + (((src >> srcfmt->Gshift) & 0xFF) << dstfmt->Gshift) | \ + (((src >> srcfmt->Bshift) & 0xFF) << dstfmt->Bshift) | \ + dstfmt->Amask; \ + FACTOR_BLEND_8888(tmp, dst, srcA); \ + } while (0) +// Blend the RGBA values of two pixels +#define ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA) \ + do { \ + ALPHA_BLEND_CHANNEL(sR, dR, sA); \ + ALPHA_BLEND_CHANNEL(sG, dG, sA); \ + ALPHA_BLEND_CHANNEL(sB, dB, sA); \ + ALPHA_BLEND_CHANNEL(255, dA, sA); \ + } while (0) + +// This is a very useful loop for optimizing blitters +#if defined(_MSC_VER) && (_MSC_VER == 1300) +// There's a bug in the Visual C++ 7 optimizer when compiling this code +#else +#define USE_DUFFS_LOOP +#endif + +#define DUFFS_LOOP1(pixel_copy_increment, width) \ + { \ + int n; \ + for (n = width; n > 0; --n) { \ + pixel_copy_increment; \ + } \ + } + +#ifdef USE_DUFFS_LOOP + +// 8-times unrolled loop +#define DUFFS_LOOP8(pixel_copy_increment, width) \ + { \ + int n = (width + 7) / 8; \ + switch (width & 7) { \ + case 0: \ + do { \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 7: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 6: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 5: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 4: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 3: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 2: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 1: \ + pixel_copy_increment; \ + } while (--n > 0); \ + } \ + } + +// 4-times unrolled loop +#define DUFFS_LOOP4(pixel_copy_increment, width) \ + { \ + int n = (width + 3) / 4; \ + switch (width & 3) { \ + case 0: \ + do { \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 3: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 2: \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 1: \ + pixel_copy_increment; \ + } while (--n > 0); \ + } \ + } + +// 2-times unrolled loop +#define DUFFS_LOOP2(pixel_copy_increment, width) \ + { \ + int n = (width + 1) / 2; \ + switch (width & 1) { \ + case 0: \ + do { \ + pixel_copy_increment; \ + SDL_FALLTHROUGH; \ + case 1: \ + pixel_copy_increment; \ + } while (--n > 0); \ + } \ + } + +// Use the 4-times version of the loop by default +#define DUFFS_LOOP(pixel_copy_increment, width) \ + DUFFS_LOOP4(pixel_copy_increment, width) +// Use the 8-times version of the loop for simple routines +#define DUFFS_LOOP_TRIVIAL(pixel_copy_increment, width) \ + DUFFS_LOOP8(pixel_copy_increment, width) + +// Special version of Duff's device for even more optimization +#define DUFFS_LOOP_124(pixel_copy_increment1, \ + pixel_copy_increment2, \ + pixel_copy_increment4, width) \ + { \ + int n = width; \ + if (n & 1) { \ + pixel_copy_increment1; \ + n -= 1; \ + } \ + if (n & 2) { \ + pixel_copy_increment2; \ + n -= 2; \ + } \ + if (n & 4) { \ + pixel_copy_increment4; \ + n -= 4; \ + } \ + if (n) { \ + n /= 8; \ + do { \ + pixel_copy_increment4; \ + pixel_copy_increment4; \ + } while (--n > 0); \ + } \ + } + +#else + +// Don't use Duff's device to unroll loops +#define DUFFS_LOOP(pixel_copy_increment, width) \ + DUFFS_LOOP1(pixel_copy_increment, width) +#define DUFFS_LOOP_TRIVIAL(pixel_copy_increment, width) \ + DUFFS_LOOP1(pixel_copy_increment, width) +#define DUFFS_LOOP8(pixel_copy_increment, width) \ + DUFFS_LOOP1(pixel_copy_increment, width) +#define DUFFS_LOOP4(pixel_copy_increment, width) \ + DUFFS_LOOP1(pixel_copy_increment, width) +#define DUFFS_LOOP2(pixel_copy_increment, width) \ + DUFFS_LOOP1(pixel_copy_increment, width) +#define DUFFS_LOOP_124(pixel_copy_increment1, \ + pixel_copy_increment2, \ + pixel_copy_increment4, width) \ + DUFFS_LOOP1(pixel_copy_increment1, width) + +#endif // USE_DUFFS_LOOP + +#if defined(_MSC_VER) && (_MSC_VER >= 600) +#pragma warning(disable : 4244) // '=': conversion from 'X' to 'Y', possible loss of data +#endif + +#endif // SDL_blit_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_0.c b/contrib/SDL-3.2.8/src/video/SDL_blit_0.c new file mode 100644 index 0000000..0d05bdd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_0.c @@ -0,0 +1,972 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_HAVE_BLIT_0 + +#include "SDL_surface_c.h" + +// Functions to blit from bitmaps to other surfaces + +SDL_FORCE_INLINE void BlitBto1(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int c; + int width, height; + Uint8 *src, *map, *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = info->dst; + dstskip = info->dst_skip; + map = info->table; + + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (map) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (1) { + *dst = map[bit]; + } + dst++; + byte >>= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (1) { + *dst = map[bit]; + } + dst++; + byte <<= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } + } else { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (1) { + *dst = bit; + } + dst++; + byte >>= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (1) { + *dst = bit; + } + dst++; + byte <<= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } + } +} + +SDL_FORCE_INLINE void BlitBto2(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int c; + int width, height; + Uint8 *src; + Uint16 *map, *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = (Uint16 *)info->dst; + dstskip = info->dst_skip / 2; + map = (Uint16 *)info->table; + + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (1) { + *dst = map[bit]; + } + byte >>= srcbpp; + dst++; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (1) { + *dst = map[bit]; + } + byte <<= srcbpp; + dst++; + } + src += srcskip; + dst += dstskip; + } + } +} + +SDL_FORCE_INLINE void BlitBto3(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int c, o; + int width, height; + Uint8 *src, *map, *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = info->dst; + dstskip = info->dst_skip; + map = info->table; + + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (1) { + o = bit * 4; + dst[0] = map[o++]; + dst[1] = map[o++]; + dst[2] = map[o++]; + } + byte >>= srcbpp; + dst += 3; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (1) { + o = bit * 4; + dst[0] = map[o++]; + dst[1] = map[o++]; + dst[2] = map[o++]; + } + byte <<= srcbpp; + dst += 3; + } + src += srcskip; + dst += dstskip; + } + } +} + +SDL_FORCE_INLINE void BlitBto4(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int width, height; + Uint8 *src; + Uint32 *map, *dst; + int srcskip, dstskip; + int c; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = (Uint32 *)info->dst; + dstskip = info->dst_skip / 4; + map = (Uint32 *)info->table; + + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (1) { + *dst = map[bit]; + } + byte >>= srcbpp; + dst++; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (1) { + *dst = map[bit]; + } + byte <<= srcbpp; + dst++; + } + src += srcskip; + dst += dstskip; + } + } +} + +SDL_FORCE_INLINE void BlitBto1Key(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + Uint8 *dst = info->dst; + int srcskip = info->src_skip; + int dstskip = info->dst_skip; + Uint32 ckey = info->colorkey; + Uint8 *palmap = info->table; + int c; + + // Set up some basic variables + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (palmap) { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (bit != ckey) { + *dst = palmap[bit]; + } + dst++; + byte >>= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (bit != ckey) { + *dst = palmap[bit]; + } + dst++; + byte <<= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } + } else { + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (bit != ckey) { + *dst = bit; + } + dst++; + byte >>= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (bit != ckey) { + *dst = bit; + } + dst++; + byte <<= srcbpp; + } + src += srcskip; + dst += dstskip; + } + } + } +} + +SDL_FORCE_INLINE void BlitBto2Key(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + Uint16 *dstp = (Uint16 *)info->dst; + int srcskip = info->src_skip; + int dstskip = info->dst_skip; + Uint32 ckey = info->colorkey; + Uint8 *palmap = info->table; + int c; + + // Set up some basic variables + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + dstskip /= 2; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (bit != ckey) { + *dstp = ((Uint16 *)palmap)[bit]; + } + byte >>= srcbpp; + dstp++; + } + src += srcskip; + dstp += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (bit != ckey) { + *dstp = ((Uint16 *)palmap)[bit]; + } + byte <<= srcbpp; + dstp++; + } + src += srcskip; + dstp += dstskip; + } + } +} + +SDL_FORCE_INLINE void BlitBto3Key(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + Uint8 *dst = info->dst; + int srcskip = info->src_skip; + int dstskip = info->dst_skip; + Uint32 ckey = info->colorkey; + Uint8 *palmap = info->table; + int c; + + // Set up some basic variables + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (bit != ckey) { + SDL_memcpy(dst, &palmap[bit * 4], 3); + } + byte >>= srcbpp; + dst += 3; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (bit != ckey) { + SDL_memcpy(dst, &palmap[bit * 4], 3); + } + byte <<= srcbpp; + dst += 3; + } + src += srcskip; + dst += dstskip; + } + } +} + +SDL_FORCE_INLINE void BlitBto4Key(SDL_BlitInfo *info, const Uint32 srcbpp) +{ + const Uint32 mask = (1 << srcbpp) - 1; + const Uint32 align = (8 / srcbpp) - 1; + + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + Uint32 *dstp = (Uint32 *)info->dst; + int srcskip = info->src_skip; + int dstskip = info->dst_skip; + Uint32 ckey = info->colorkey; + Uint8 *palmap = info->table; + int c; + + // Set up some basic variables + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + dstskip /= 4; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (bit != ckey) { + *dstp = ((Uint32 *)palmap)[bit]; + } + byte >>= srcbpp; + dstp++; + } + src += srcskip; + dstp += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (bit != ckey) { + *dstp = ((Uint32 *)palmap)[bit]; + } + byte <<= srcbpp; + dstp++; + } + src += srcskip; + dstp += dstskip; + } + } +} + +static void BlitBtoNAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + Uint8 *dst = info->dst; + int srcskip = info->src_skip; + int dstskip = info->dst_skip; + const SDL_Color *srcpal = info->src_pal->colors; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int srcbpp, dstbpp; + int c; + Uint32 pixel, mask, align; + unsigned sR, sG, sB; + unsigned dR, dG, dB, dA; + const unsigned A = info->a; + + // Set up some basic variables + srcbpp = srcfmt->bytes_per_pixel; + dstbpp = dstfmt->bytes_per_pixel; + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + mask = (1 << srcbpp) - 1; + align = (8 / srcbpp) - 1; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (1) { + sR = srcpal[bit].r; + sG = srcpal[bit].g; + sB = srcpal[bit].b; + DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + byte >>= srcbpp; + dst += dstbpp; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (1) { + sR = srcpal[bit].r; + sG = srcpal[bit].g; + sB = srcpal[bit].b; + DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + byte <<= srcbpp; + dst += dstbpp; + } + src += srcskip; + dst += dstskip; + } + } +} + +static void BlitBtoNAlphaKey(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + Uint8 *dst = info->dst; + int srcskip = info->src_skip; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + const SDL_Color *srcpal = info->src_pal->colors; + int srcbpp, dstbpp; + int c; + Uint32 pixel, mask, align; + unsigned sR, sG, sB; + unsigned dR, dG, dB, dA; + const unsigned A = info->a; + Uint32 ckey = info->colorkey; + + // Set up some basic variables + srcbpp = srcfmt->bytes_per_pixel; + dstbpp = dstfmt->bytes_per_pixel; + if (srcbpp == 4) + srcskip += width - (width + 1) / 2; + else if (srcbpp == 2) + srcskip += width - (width + 3) / 4; + else if (srcbpp == 1) + srcskip += width - (width + 7) / 8; + mask = (1 << srcbpp) - 1; + align = (8 / srcbpp) - 1; + + if (SDL_PIXELORDER(info->src_fmt->format) == SDL_BITMAPORDER_4321) { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte & mask); + if (bit != ckey) { + sR = srcpal[bit].r; + sG = srcpal[bit].g; + sB = srcpal[bit].b; + DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + byte >>= srcbpp; + dst += dstbpp; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + Uint8 byte = 0, bit; + for (c = 0; c < width; ++c) { + if (!(c & align)) { + byte = *src++; + } + bit = (byte >> (8 - srcbpp)) & mask; + if (bit != ckey) { + sR = srcpal[bit].r; + sG = srcpal[bit].g; + sB = srcpal[bit].b; + DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + byte <<= srcbpp; + dst += dstbpp; + } + src += srcskip; + dst += dstskip; + } + } +} + + + +static void Blit1bto1(SDL_BlitInfo *info) { + BlitBto1(info, 1); +} + +static void Blit1bto2(SDL_BlitInfo *info) { + BlitBto2(info, 1); +} + +static void Blit1bto3(SDL_BlitInfo *info) { + BlitBto3(info, 1); +} + +static void Blit1bto4(SDL_BlitInfo *info) { + BlitBto4(info, 1); +} + +static const SDL_BlitFunc bitmap_blit_1b[] = { + (SDL_BlitFunc)NULL, Blit1bto1, Blit1bto2, Blit1bto3, Blit1bto4 +}; + +static void Blit1bto1Key(SDL_BlitInfo *info) { + BlitBto1Key(info, 1); +} + +static void Blit1bto2Key(SDL_BlitInfo *info) { + BlitBto2Key(info, 1); +} + +static void Blit1bto3Key(SDL_BlitInfo *info) { + BlitBto3Key(info, 1); +} + +static void Blit1bto4Key(SDL_BlitInfo *info) { + BlitBto4Key(info, 1); +} + +static const SDL_BlitFunc colorkey_blit_1b[] = { + (SDL_BlitFunc)NULL, Blit1bto1Key, Blit1bto2Key, Blit1bto3Key, Blit1bto4Key +}; + + + +static void Blit2bto1(SDL_BlitInfo *info) { + BlitBto1(info, 2); +} + +static void Blit2bto2(SDL_BlitInfo *info) { + BlitBto2(info, 2); +} + +static void Blit2bto3(SDL_BlitInfo *info) { + BlitBto3(info, 2); +} + +static void Blit2bto4(SDL_BlitInfo *info) { + BlitBto4(info, 2); +} + +static const SDL_BlitFunc bitmap_blit_2b[] = { + (SDL_BlitFunc)NULL, Blit2bto1, Blit2bto2, Blit2bto3, Blit2bto4 +}; + +static void Blit2bto1Key(SDL_BlitInfo *info) { + BlitBto1Key(info, 2); +} + +static void Blit2bto2Key(SDL_BlitInfo *info) { + BlitBto2Key(info, 2); +} + +static void Blit2bto3Key(SDL_BlitInfo *info) { + BlitBto3Key(info, 2); +} + +static void Blit2bto4Key(SDL_BlitInfo *info) { + BlitBto4Key(info, 2); +} + +static const SDL_BlitFunc colorkey_blit_2b[] = { + (SDL_BlitFunc)NULL, Blit2bto1Key, Blit2bto2Key, Blit2bto3Key, Blit2bto4Key +}; + + + +static void Blit4bto1(SDL_BlitInfo *info) { + BlitBto1(info, 4); +} + +static void Blit4bto2(SDL_BlitInfo *info) { + BlitBto2(info, 4); +} + +static void Blit4bto3(SDL_BlitInfo *info) { + BlitBto3(info, 4); +} + +static void Blit4bto4(SDL_BlitInfo *info) { + BlitBto4(info, 4); +} + +static const SDL_BlitFunc bitmap_blit_4b[] = { + (SDL_BlitFunc)NULL, Blit4bto1, Blit4bto2, Blit4bto3, Blit4bto4 +}; + +static void Blit4bto1Key(SDL_BlitInfo *info) { + BlitBto1Key(info, 4); +} + +static void Blit4bto2Key(SDL_BlitInfo *info) { + BlitBto2Key(info, 4); +} + +static void Blit4bto3Key(SDL_BlitInfo *info) { + BlitBto3Key(info, 4); +} + +static void Blit4bto4Key(SDL_BlitInfo *info) { + BlitBto4Key(info, 4); +} + +static const SDL_BlitFunc colorkey_blit_4b[] = { + (SDL_BlitFunc)NULL, Blit4bto1Key, Blit4bto2Key, Blit4bto3Key, Blit4bto4Key +}; + + + +SDL_BlitFunc SDL_CalculateBlit0(SDL_Surface *surface) +{ + int which; + + if (SDL_BITSPERPIXEL(surface->map.info.dst_fmt->format) < 8) { + which = 0; + } else { + which = SDL_BYTESPERPIXEL(surface->map.info.dst_fmt->format); + } + + if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX1) { + switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + if (which < SDL_arraysize(bitmap_blit_1b)) { + return bitmap_blit_1b[which]; + } + break; + + case SDL_COPY_COLORKEY: + if (which < SDL_arraysize(colorkey_blit_1b)) { + return colorkey_blit_1b[which]; + } + break; + + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc)NULL; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc)NULL; + } + return NULL; + } + + if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX2) { + switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + if (which < SDL_arraysize(bitmap_blit_2b)) { + return bitmap_blit_2b[which]; + } + break; + + case SDL_COPY_COLORKEY: + if (which < SDL_arraysize(colorkey_blit_2b)) { + return colorkey_blit_2b[which]; + } + break; + + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc)NULL; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc)NULL; + } + return NULL; + } + + if (SDL_PIXELTYPE(surface->format) == SDL_PIXELTYPE_INDEX4) { + switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + if (which < SDL_arraysize(bitmap_blit_4b)) { + return bitmap_blit_4b[which]; + } + break; + + case SDL_COPY_COLORKEY: + if (which < SDL_arraysize(colorkey_blit_4b)) { + return colorkey_blit_4b[which]; + } + break; + + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? BlitBtoNAlpha : (SDL_BlitFunc)NULL; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? BlitBtoNAlphaKey : (SDL_BlitFunc)NULL; + } + return NULL; + } + + return NULL; +} + +#endif // SDL_HAVE_BLIT_0 diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_1.c b/contrib/SDL-3.2.8/src/video/SDL_blit_1.c new file mode 100644 index 0000000..e085610 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_1.c @@ -0,0 +1,563 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_HAVE_BLIT_1 + +#include "SDL_surface_c.h" +#include "SDL_sysvideo.h" + +// Functions to blit from 8-bit surfaces to other surfaces + +static void Blit1to1(SDL_BlitInfo *info) +{ +#ifndef USE_DUFFS_LOOP + int c; +#endif + int width, height; + Uint8 *src, *map, *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = info->dst; + dstskip = info->dst_skip; + map = info->table; + + while (height--) { +#ifdef USE_DUFFS_LOOP + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + *dst = map[*src]; + } + dst++; + src++; + , width); + /* *INDENT-ON* */ // clang-format on +#else + for (c = width; c; --c) { + *dst = map[*src]; + dst++; + src++; + } +#endif + src += srcskip; + dst += dstskip; + } +} + +// This is now endian dependent +#ifndef USE_DUFFS_LOOP +#if (SDL_BYTEORDER == SDL_LIL_ENDIAN) +#define HI 1 +#define LO 0 +#else // ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) +#define HI 0 +#define LO 1 +#endif +#endif +static void Blit1to2(SDL_BlitInfo *info) +{ +#ifndef USE_DUFFS_LOOP + int c; +#endif + int width, height; + Uint8 *src, *dst; + Uint16 *map; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = info->dst; + dstskip = info->dst_skip; + map = (Uint16 *)info->table; + +#ifdef USE_DUFFS_LOOP + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + *(Uint16 *)dst = map[*src++]; + dst += 2; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +#else + // Memory align at 4-byte boundary, if necessary + if ((long)dst & 0x03) { + // Don't do anything if width is 0 + if (width == 0) { + return; + } + --width; + + while (height--) { + // Perform copy alignment + *(Uint16 *)dst = map[*src++]; + dst += 2; + + // Copy in 4 pixel chunks + for (c = width / 4; c; --c) { + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); + src += 2; + dst += 4; + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); + src += 2; + dst += 4; + } + // Get any leftovers + switch (width & 3) { + case 3: + *(Uint16 *)dst = map[*src++]; + dst += 2; + SDL_FALLTHROUGH; + case 2: + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); + src += 2; + dst += 4; + break; + case 1: + *(Uint16 *)dst = map[*src++]; + dst += 2; + break; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + // Copy in 4 pixel chunks + for (c = width / 4; c; --c) { + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); + src += 2; + dst += 4; + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); + src += 2; + dst += 4; + } + // Get any leftovers + switch (width & 3) { + case 3: + *(Uint16 *)dst = map[*src++]; + dst += 2; + SDL_FALLTHROUGH; + case 2: + *(Uint32 *)dst = (map[src[HI]] << 16) | (map[src[LO]]); + src += 2; + dst += 4; + break; + case 1: + *(Uint16 *)dst = map[*src++]; + dst += 2; + break; + } + src += srcskip; + dst += dstskip; + } + } +#endif // USE_DUFFS_LOOP +} + +static void Blit1to3(SDL_BlitInfo *info) +{ +#ifndef USE_DUFFS_LOOP + int c; +#endif + int o; + int width, height; + Uint8 *src, *map, *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = info->dst; + dstskip = info->dst_skip; + map = info->table; + + while (height--) { +#ifdef USE_DUFFS_LOOP + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + o = *src * 4; + dst[0] = map[o++]; + dst[1] = map[o++]; + dst[2] = map[o++]; + } + src++; + dst += 3; + , width); + /* *INDENT-ON* */ // clang-format on +#else + for (c = width; c; --c) { + o = *src * 4; + dst[0] = map[o++]; + dst[1] = map[o++]; + dst[2] = map[o++]; + src++; + dst += 3; + } +#endif // USE_DUFFS_LOOP + src += srcskip; + dst += dstskip; + } +} + +static void Blit1to4(SDL_BlitInfo *info) +{ +#ifndef USE_DUFFS_LOOP + int c; +#endif + int width, height; + Uint8 *src; + Uint32 *map, *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = (Uint32 *)info->dst; + dstskip = info->dst_skip / 4; + map = (Uint32 *)info->table; + + while (height--) { +#ifdef USE_DUFFS_LOOP + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + *dst++ = map[*src++]; + , width); + /* *INDENT-ON* */ // clang-format on +#else + for (c = width / 4; c; --c) { + *dst++ = map[*src++]; + *dst++ = map[*src++]; + *dst++ = map[*src++]; + *dst++ = map[*src++]; + } + switch (width & 3) { + case 3: + *dst++ = map[*src++]; + SDL_FALLTHROUGH; + case 2: + *dst++ = map[*src++]; + SDL_FALLTHROUGH; + case 1: + *dst++ = map[*src++]; + } +#endif // USE_DUFFS_LOOP + src += srcskip; + dst += dstskip; + } +} + +static void Blit1to1Key(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint8 *palmap = info->table; + Uint32 ckey = info->colorkey; + + if (palmap) { + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ( *src != ckey ) { + *dst = palmap[*src]; + } + dst++; + src++; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ( *src != ckey ) { + *dst = *src; + } + dst++; + src++; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } +} + +static void Blit1to2Key(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip; + Uint16 *palmap = (Uint16 *)info->table; + Uint32 ckey = info->colorkey; + + // Set up some basic variables + dstskip /= 2; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ( *src != ckey ) { + *dstp=palmap[*src]; + } + src++; + dstp++; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dstp += dstskip; + } +} + +static void Blit1to3Key(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint8 *palmap = info->table; + Uint32 ckey = info->colorkey; + int o; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + if ( *src != ckey ) { + o = *src * 4; + dst[0] = palmap[o++]; + dst[1] = palmap[o++]; + dst[2] = palmap[o++]; + } + src++; + dst += 3; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +static void Blit1to4Key(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint32 *dstp = (Uint32 *)info->dst; + int dstskip = info->dst_skip; + Uint32 *palmap = (Uint32 *)info->table; + Uint32 ckey = info->colorkey; + + // Set up some basic variables + dstskip /= 4; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ( *src != ckey ) { + *dstp = palmap[*src]; + } + src++; + dstp++; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dstp += dstskip; + } +} + +static void Blit1toNAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + const SDL_Color *srcpal = info->src_pal->colors; + int dstbpp; + Uint32 pixel; + unsigned sR, sG, sB, sA; + unsigned dR, dG, dB, dA; + const unsigned A = info->a; + + // Set up some basic variables + dstbpp = dstfmt->bytes_per_pixel; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + sR = srcpal[*src].r; + sG = srcpal[*src].g; + sB = srcpal[*src].b; + sA = (srcpal[*src].a * A) / 255; + DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + src++; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +static void Blit1toNAlphaKey(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + const SDL_Color *srcpal = info->src_pal->colors; + Uint32 ckey = info->colorkey; + int dstbpp; + Uint32 pixel; + unsigned sR, sG, sB, sA; + unsigned dR, dG, dB, dA; + const unsigned A = info->a; + + // Set up some basic variables + dstbpp = dstfmt->bytes_per_pixel; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + if ( *src != ckey ) { + sR = srcpal[*src].r; + sG = srcpal[*src].g; + sB = srcpal[*src].b; + sA = (srcpal[*src].a * A) / 255; + DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + src++; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +static const SDL_BlitFunc one_blit[] = { + (SDL_BlitFunc)NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4 +}; + +static const SDL_BlitFunc one_blitkey[] = { + (SDL_BlitFunc)NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key +}; + +SDL_BlitFunc SDL_CalculateBlit1(SDL_Surface *surface) +{ + int which; + + if (SDL_BITSPERPIXEL(surface->map.info.dst_fmt->format) < 8) { + which = 0; + } else { + which = SDL_BYTESPERPIXEL(surface->map.info.dst_fmt->format); + } + + switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + if (which < SDL_arraysize(one_blit)) { + return one_blit[which]; + } + break; + + case SDL_COPY_COLORKEY: + if (which < SDL_arraysize(one_blitkey)) { + return one_blitkey[which]; + } + break; + + case SDL_COPY_COLORKEY | SDL_COPY_BLEND: // this is not super-robust but handles a specific case we found sdl12-compat. + if (surface->map.info.a == 255) { + if (which < SDL_arraysize(one_blitkey)) { + return one_blitkey[which]; + } + } else { + return which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc)NULL; + } + break; + + case SDL_COPY_BLEND: + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + /* Supporting 8bpp->8bpp alpha is doable but requires lots of + tables which consume space and takes time to precompute, + so is better left to the user */ + return which >= 2 ? Blit1toNAlpha : (SDL_BlitFunc)NULL; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + return which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc)NULL; + } + return (SDL_BlitFunc)NULL; +} + +#endif // SDL_HAVE_BLIT_1 diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_A.c b/contrib/SDL-3.2.8/src/video/SDL_blit_A.c new file mode 100644 index 0000000..5d6d92d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_A.c @@ -0,0 +1,1461 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_HAVE_BLIT_A + +#include "SDL_surface_c.h" + +// Functions to perform alpha blended blitting + +// N->1 blending with per-surface alpha +static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint8 *palmap = info->table; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_Color *dstpal = info->dst_pal->colors; + int srcbpp = srcfmt->bytes_per_pixel; + Uint32 Pixel; + unsigned sR, sG, sB; + unsigned dR, dG, dB; + const unsigned A = info->a; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); + dR = dstpal[*dst].r; + dG = dstpal[*dst].g; + dB = dstpal[*dst].b; + ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB); + dR &= 0xff; + dG &= 0xff; + dB &= 0xff; + // Pack RGB into 8bit pixel + if ( palmap == NULL ) { + *dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))); + } else { + *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; + } + dst++; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +// N->1 blending with pixel alpha +static void BlitNto1PixelAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint8 *palmap = info->table; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_Color *dstpal = info->dst_pal->colors; + int srcbpp = srcfmt->bytes_per_pixel; + Uint32 Pixel; + unsigned sR, sG, sB, sA; + unsigned dR, dG, dB; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + DISEMBLE_RGBA(src,srcbpp,srcfmt,Pixel,sR,sG,sB,sA); + dR = dstpal[*dst].r; + dG = dstpal[*dst].g; + dB = dstpal[*dst].b; + ALPHA_BLEND_RGB(sR, sG, sB, sA, dR, dG, dB); + dR &= 0xff; + dG &= 0xff; + dB &= 0xff; + // Pack RGB into 8bit pixel + if ( palmap == NULL ) { + *dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))); + } else { + *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; + } + dst++; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +// colorkeyed N->1 blending with per-surface alpha +static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint8 *palmap = info->table; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_Color *dstpal = info->dst_pal->colors; + int srcbpp = srcfmt->bytes_per_pixel; + Uint32 ckey = info->colorkey; + Uint32 Pixel; + unsigned sR, sG, sB; + unsigned dR, dG, dB; + const unsigned A = info->a; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); + if ( Pixel != ckey ) { + dR = dstpal[*dst].r; + dG = dstpal[*dst].g; + dB = dstpal[*dst].b; + ALPHA_BLEND_RGB(sR, sG, sB, A, dR, dG, dB); + dR &= 0xff; + dG &= 0xff; + dB &= 0xff; + // Pack RGB into 8bit pixel + if ( palmap == NULL ) { + *dst = (Uint8)(((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))); + } else { + *dst = palmap[((dR>>5)<<(3+2))|((dG>>5)<<(2))|((dB>>6)<<(0))]; + } + } + dst++; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +#ifdef SDL_SSE2_INTRINSICS + +static void SDL_TARGETING("sse2") Blit888to888SurfaceAlphaSSE2(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint8 alpha = info->a; + + const __m128i alpha_fill_mask = _mm_set1_epi32((int)0xff000000); + const __m128i srcA = _mm_set1_epi16(alpha); + + while (height--) { + int i = 0; + + for (; i + 4 <= width; i += 4) { + // Load 4 src pixels + __m128i src128 = _mm_loadu_si128((__m128i *)src); + + // Load 4 dst pixels + __m128i dst128 = _mm_loadu_si128((__m128i *)dst); + + __m128i src_lo = _mm_unpacklo_epi8(src128, _mm_setzero_si128()); + __m128i src_hi = _mm_unpackhi_epi8(src128, _mm_setzero_si128()); + + __m128i dst_lo = _mm_unpacklo_epi8(dst128, _mm_setzero_si128()); + __m128i dst_hi = _mm_unpackhi_epi8(dst128, _mm_setzero_si128()); + + // dst = ((src - dst) * srcA) + ((dst << 8) - dst) + dst_lo = _mm_add_epi16(_mm_mullo_epi16(_mm_sub_epi16(src_lo, dst_lo), srcA), + _mm_sub_epi16(_mm_slli_epi16(dst_lo, 8), dst_lo)); + dst_hi = _mm_add_epi16(_mm_mullo_epi16(_mm_sub_epi16(src_hi, dst_hi), srcA), + _mm_sub_epi16(_mm_slli_epi16(dst_hi, 8), dst_hi)); + + // dst += 0x1U (use 0x80 to round instead of floor) + dst_lo = _mm_add_epi16(dst_lo, _mm_set1_epi16(1)); + dst_hi = _mm_add_epi16(dst_hi, _mm_set1_epi16(1)); + + // dst = (dst + (dst >> 8)) >> 8 + dst_lo = _mm_srli_epi16(_mm_add_epi16(dst_lo, _mm_srli_epi16(dst_lo, 8)), 8); + dst_hi = _mm_srli_epi16(_mm_add_epi16(dst_hi, _mm_srli_epi16(dst_hi, 8)), 8); + + dst128 = _mm_packus_epi16(dst_lo, dst_hi); + + // Set the alpha channels of dst to 255 + dst128 = _mm_or_si128(dst128, alpha_fill_mask); + + _mm_storeu_si128((__m128i *)dst, dst128); + + src += 16; + dst += 16; + } + + for (; i < width; ++i) { + Uint32 src32 = *(Uint32 *)src; + Uint32 dst32 = *(Uint32 *)dst; + + FACTOR_BLEND_8888(src32, dst32, alpha); + + *dst = dst32 | 0xff000000; + + src += 4; + dst += 4; + } + + src += srcskip; + dst += dstskip; + } +} + +#endif + +// fast RGB888->(A)RGB888 blending with surface alpha=128 special case +static void BlitRGBtoRGBSurfaceAlpha128(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint32 *srcp = (Uint32 *)info->src; + int srcskip = info->src_skip >> 2; + Uint32 *dstp = (Uint32 *)info->dst; + int dstskip = info->dst_skip >> 2; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + *dstp++ = ((((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1) + + (s & d & 0x00010101)) | 0xff000000; + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } +} + +// fast RGB888->(A)RGB888 blending with surface alpha +static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info) +{ + unsigned alpha = info->a; + if (alpha == 128) { + BlitRGBtoRGBSurfaceAlpha128(info); + } else { + int width = info->dst_w; + int height = info->dst_h; + Uint32 *srcp = (Uint32 *)info->src; + int srcskip = info->src_skip >> 2; + Uint32 *dstp = (Uint32 *)info->dst; + int dstskip = info->dst_skip >> 2; + Uint32 s; + Uint32 d; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP({ + s = *srcp; + d = *dstp; + + FACTOR_BLEND_8888(s, d, alpha); + + *dstp = d | 0xff000000; + ++srcp; + ++dstp; + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } + } +} + +// 16bpp special case for per-surface alpha=50%: blend 2 pixels in parallel + +// blend a single 16 bit pixel at 50% +#define BLEND16_50(d, s, mask) \ + ((((s & mask) + (d & mask)) >> 1) + (s & d & (~mask & 0xffff))) + +// blend two 16 bit pixels at 50% +#define BLEND2x16_50(d, s, mask) \ + (((s & (mask | mask << 16)) >> 1) + ((d & (mask | mask << 16)) >> 1) + (s & d & (~(mask | mask << 16)))) + +static void Blit16to16SurfaceAlpha128(SDL_BlitInfo *info, Uint16 mask) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint16 *srcp = (Uint16 *)info->src; + int srcskip = info->src_skip >> 1; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip >> 1; + + while (height--) { + if (((uintptr_t)srcp ^ (uintptr_t)dstp) & 2) { + /* + * Source and destination not aligned, pipeline it. + * This is mostly a win for big blits but no loss for + * small ones + */ + Uint32 prev_sw; + int w = width; + + // handle odd destination + if ((uintptr_t)dstp & 2) { + Uint16 d = *dstp, s = *srcp; + *dstp = BLEND16_50(d, s, mask); + dstp++; + srcp++; + w--; + } + srcp++; // srcp is now 32-bit aligned + + // bootstrap pipeline with first halfword + prev_sw = ((Uint32 *)srcp)[-1]; + + while (w > 1) { + Uint32 sw, dw, s; + sw = *(Uint32 *)srcp; + dw = *(Uint32 *)dstp; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + s = (prev_sw << 16) + (sw >> 16); +#else + s = (prev_sw >> 16) + (sw << 16); +#endif + prev_sw = sw; + *(Uint32 *)dstp = BLEND2x16_50(dw, s, mask); + dstp += 2; + srcp += 2; + w -= 2; + } + + // final pixel if any + if (w) { + Uint16 d = *dstp, s; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + s = (Uint16)prev_sw; +#else + s = (Uint16)(prev_sw >> 16); +#endif + *dstp = BLEND16_50(d, s, mask); + srcp++; + dstp++; + } + srcp += srcskip - 1; + dstp += dstskip; + } else { + // source and destination are aligned + int w = width; + + // first odd pixel? + if ((uintptr_t)srcp & 2) { + Uint16 d = *dstp, s = *srcp; + *dstp = BLEND16_50(d, s, mask); + srcp++; + dstp++; + w--; + } + // srcp and dstp are now 32-bit aligned + + while (w > 1) { + Uint32 sw = *(Uint32 *)srcp; + Uint32 dw = *(Uint32 *)dstp; + *(Uint32 *)dstp = BLEND2x16_50(dw, sw, mask); + srcp += 2; + dstp += 2; + w -= 2; + } + + // last odd pixel? + if (w) { + Uint16 d = *dstp, s = *srcp; + *dstp = BLEND16_50(d, s, mask); + srcp++; + dstp++; + } + srcp += srcskip; + dstp += dstskip; + } + } +} + +#ifdef SDL_MMX_INTRINSICS + +// fast RGB565->RGB565 blending with surface alpha +static void SDL_TARGETING("mmx") Blit565to565SurfaceAlphaMMX(SDL_BlitInfo *info) +{ + unsigned alpha = info->a; + if (alpha == 128) { + Blit16to16SurfaceAlpha128(info, 0xf7de); + } else { + int width = info->dst_w; + int height = info->dst_h; + Uint16 *srcp = (Uint16 *)info->src; + int srcskip = info->src_skip >> 1; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip >> 1; + Uint32 s, d; + +#ifdef USE_DUFFS_LOOP + __m64 src1, dst1, src2, dst2, gmask, bmask, mm_res, mm_alpha; + + alpha &= ~(1 + 2 + 4); // cut alpha to get the exact same behaviour + mm_alpha = _mm_set_pi32(0, alpha); // 0000000A -> mm_alpha + alpha >>= 3; // downscale alpha to 5 bits + + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); // 00000A0A -> mm_alpha + mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); // 0A0A0A0A -> mm_alpha + /* position alpha to allow for mullo and mulhi on diff channels + to reduce the number of operations */ + mm_alpha = _mm_slli_si64(mm_alpha, 3); + + // Setup the 565 color channel masks + gmask = _mm_set_pi32(0x07E007E0, 0x07E007E0); // MASKGREEN -> gmask + bmask = _mm_set_pi32(0x001F001F, 0x001F001F); // MASKBLUE -> bmask +#endif + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_124( + { + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + src1 = *(__m64*)srcp; // 4 src pixels -> src1 + dst1 = *(__m64*)dstp; // 4 dst pixels -> dst1 + + // red + src2 = src1; + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 [000r 000r 000r 000r] + + dst2 = dst1; + dst2 = _mm_srli_pi16(dst2, 11); // dst2 >> 11 -> dst2 [000r 000r 000r 000r] + + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 + src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_slli_pi16(dst2, 11); // dst2 << 11 -> dst2 + + mm_res = dst2; // RED -> mm_res + + // green -- process the bits in place + src2 = src1; + src2 = _mm_and_si64(src2, gmask); // src & MASKGREEN -> src2 + + dst2 = dst1; + dst2 = _mm_and_si64(dst2, gmask); // dst & MASKGREEN -> dst2 + + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 + src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_slli_pi16(src2, 5); // src2 << 5 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN -> mm_res + + // blue + src2 = src1; + src2 = _mm_and_si64(src2, bmask); // src & MASKBLUE -> src2[000b 000b 000b 000b] + + dst2 = dst1; + dst2 = _mm_and_si64(dst2, bmask); // dst & MASKBLUE -> dst2[000b 000b 000b 000b] + + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 + src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_and_si64(dst2, bmask); // dst2 & MASKBLUE -> dst2 + + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res + + *(__m64*)dstp = mm_res; // mm_res -> 4 dst pixels + + srcp += 4; + dstp += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } + _mm_empty(); + } +} + +// fast RGB555->RGB555 blending with surface alpha +static void SDL_TARGETING("mmx") Blit555to555SurfaceAlphaMMX(SDL_BlitInfo *info) +{ + unsigned alpha = info->a; + if (alpha == 128) { + Blit16to16SurfaceAlpha128(info, 0xfbde); + } else { + int width = info->dst_w; + int height = info->dst_h; + Uint16 *srcp = (Uint16 *)info->src; + int srcskip = info->src_skip >> 1; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip >> 1; + Uint32 s, d; + +#ifdef USE_DUFFS_LOOP + __m64 src1, dst1, src2, dst2, rmask, gmask, bmask, mm_res, mm_alpha; + + alpha &= ~(1 + 2 + 4); // cut alpha to get the exact same behaviour + mm_alpha = _mm_set_pi32(0, alpha); // 0000000A -> mm_alpha + alpha >>= 3; // downscale alpha to 5 bits + + mm_alpha = _mm_unpacklo_pi16(mm_alpha, mm_alpha); // 00000A0A -> mm_alpha + mm_alpha = _mm_unpacklo_pi32(mm_alpha, mm_alpha); // 0A0A0A0A -> mm_alpha + /* position alpha to allow for mullo and mulhi on diff channels + to reduce the number of operations */ + mm_alpha = _mm_slli_si64(mm_alpha, 3); + + // Setup the 555 color channel masks + rmask = _mm_set_pi32(0x7C007C00, 0x7C007C00); // MASKRED -> rmask + gmask = _mm_set_pi32(0x03E003E0, 0x03E003E0); // MASKGREEN -> gmask + bmask = _mm_set_pi32(0x001F001F, 0x001F001F); // MASKBLUE -> bmask +#endif + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_124( + { + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + s = *srcp++; + d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + },{ + src1 = *(__m64*)srcp; // 4 src pixels -> src1 + dst1 = *(__m64*)dstp; // 4 dst pixels -> dst1 + + // red -- process the bits in place + src2 = src1; + src2 = _mm_and_si64(src2, rmask); // src & MASKRED -> src2 + + dst2 = dst1; + dst2 = _mm_and_si64(dst2, rmask); // dst & MASKRED -> dst2 + + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 + src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_slli_pi16(src2, 5); // src2 << 5 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_and_si64(dst2, rmask); // dst2 & MASKRED -> dst2 + + mm_res = dst2; // RED -> mm_res + + // green -- process the bits in place + src2 = src1; + src2 = _mm_and_si64(src2, gmask); // src & MASKGREEN -> src2 + + dst2 = dst1; + dst2 = _mm_and_si64(dst2, gmask); // dst & MASKGREEN -> dst2 + + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 + src2 = _mm_mulhi_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_slli_pi16(src2, 5); // src2 << 5 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN -> mm_res + + // blue + src2 = src1; // src -> src2 + src2 = _mm_and_si64(src2, bmask); // src & MASKBLUE -> src2[000b 000b 000b 000b] + + dst2 = dst1; // dst -> dst2 + dst2 = _mm_and_si64(dst2, bmask); // dst & MASKBLUE -> dst2[000b 000b 000b 000b] + + // blend + src2 = _mm_sub_pi16(src2, dst2);// src - dst -> src2 + src2 = _mm_mullo_pi16(src2, mm_alpha); /* src2 * alpha -> src2 */ + src2 = _mm_srli_pi16(src2, 11); // src2 >> 11 -> src2 + dst2 = _mm_add_pi16(src2, dst2); // src2 + dst2 -> dst2 + dst2 = _mm_and_si64(dst2, bmask); // dst2 & MASKBLUE -> dst2 + + mm_res = _mm_or_si64(mm_res, dst2); // RED | GREEN | BLUE -> mm_res + + *(__m64*)dstp = mm_res; // mm_res -> 4 dst pixels + + srcp += 4; + dstp += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } + _mm_empty(); + } +} + +#endif // SDL_MMX_INTRINSICS + +// fast RGB565->RGB565 blending with surface alpha +static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info) +{ + unsigned alpha = info->a; + if (alpha == 128) { + Blit16to16SurfaceAlpha128(info, 0xf7de); + } else { + int width = info->dst_w; + int height = info->dst_h; + Uint16 *srcp = (Uint16 *)info->src; + int srcskip = info->src_skip >> 1; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip >> 1; + alpha >>= 3; // downscale alpha to 5 bits + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x07e0f81f; + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp++ = (Uint16)(d | d >> 16); + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } + } +} + +// fast RGB555->RGB555 blending with surface alpha +static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info) +{ + unsigned alpha = info->a; // downscale alpha to 5 bits + if (alpha == 128) { + Blit16to16SurfaceAlpha128(info, 0xfbde); + } else { + int width = info->dst_w; + int height = info->dst_h; + Uint16 *srcp = (Uint16 *)info->src; + int srcskip = info->src_skip >> 1; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip >> 1; + alpha >>= 3; // downscale alpha to 5 bits + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP({ + Uint32 s = *srcp++; + Uint32 d = *dstp; + /* + * shift out the middle component (green) to + * the high 16 bits, and process all three RGB + * components at the same time. + */ + s = (s | s << 16) & 0x03e07c1f; + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp++ = (Uint16)(d | d >> 16); + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } + } +} + +// fast ARGB8888->RGB565 blending with pixel alpha +static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint32 *srcp = (Uint32 *)info->src; + int srcskip = info->src_skip >> 2; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip >> 1; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP({ + Uint32 s = *srcp; + unsigned alpha = s >> 27; // downscale alpha to 5 bits + /* Here we special-case opaque alpha since the + compositioning used (>>8 instead of /255) doesn't handle + it correctly. */ + if (alpha) { + if (alpha == (SDL_ALPHA_OPAQUE >> 3)) { + *dstp = (Uint16)((s >> 8 & 0xf800) + (s >> 5 & 0x7e0) + (s >> 3 & 0x1f)); + } else { + Uint32 d = *dstp; + /* + * convert source and destination to G0RAB65565 + * and blend all components at the same time + */ + s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800) + (s >> 3 & 0x1f); + d = (d | d << 16) & 0x07e0f81f; + d += (s - d) * alpha >> 5; + d &= 0x07e0f81f; + *dstp = (Uint16)(d | d >> 16); + } + } + srcp++; + dstp++; + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } +} + +// fast ARGB8888->RGB555 blending with pixel alpha +static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint32 *srcp = (Uint32 *)info->src; + int srcskip = info->src_skip >> 2; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip >> 1; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP({ + unsigned alpha; + Uint32 s = *srcp; + alpha = s >> 27; // downscale alpha to 5 bits + /* Here we special-case opaque alpha since the + compositioning used (>>8 instead of /255) doesn't handle + it correctly. */ + if (alpha) { + if (alpha == (SDL_ALPHA_OPAQUE >> 3)) { + *dstp = (Uint16)((s >> 9 & 0x7c00) + (s >> 6 & 0x3e0) + (s >> 3 & 0x1f)); + } else { + Uint32 d = *dstp; + /* + * convert source and destination to G0RAB55555 + * and blend all components at the same time + */ + s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00) + (s >> 3 & 0x1f); + d = (d | d << 16) & 0x03e07c1f; + d += (s - d) * alpha >> 5; + d &= 0x03e07c1f; + *dstp = (Uint16)(d | d >> 16); + } + } + srcp++; + dstp++; + }, width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } +} + +// General (slow) N->N blending with per-surface alpha +static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int srcbpp = srcfmt->bytes_per_pixel; + int dstbpp = dstfmt->bytes_per_pixel; + Uint32 Pixel; + unsigned sR, sG, sB; + unsigned dR, dG, dB, dA; + const unsigned sA = info->a; + + if (sA) { + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); + DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + src += srcbpp; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } +} + +// General (slow) colorkeyed N->N blending with per-surface alpha +static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + Uint32 ckey = info->colorkey; + int srcbpp = srcfmt->bytes_per_pixel; + int dstbpp = dstfmt->bytes_per_pixel; + Uint32 Pixel; + unsigned sR, sG, sB; + unsigned dR, dG, dB, dA; + const unsigned sA = info->a; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel); + if (sA && Pixel != ckey) { + RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); + DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + src += srcbpp; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +// Fast 32-bit RGBA->RGBA blending with pixel alpha +static void Blit8888to8888PixelAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + + while (height--) { + int i = 0; + + for (; i < width; ++i) { + Uint32 src32 = *(Uint32 *)src; + Uint32 dst32 = *(Uint32 *)dst; + ALPHA_BLEND_8888(src32, dst32, srcfmt); + *(Uint32 *)dst = dst32; + src += 4; + dst += 4; + } + + src += srcskip; + dst += dstskip; + } +} + +// Fast 32-bit RGBA->RGB(A) blending with pixel alpha and src swizzling +static void Blit8888to8888PixelAlphaSwizzle(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + + while (height--) { + int i = 0; + + for (; i < width; ++i) { + Uint32 src32 = *(Uint32 *)src; + Uint32 dst32 = *(Uint32 *)dst; + ALPHA_BLEND_SWIZZLE_8888(src32, dst32, srcfmt, dstfmt); + *(Uint32 *)dst = dst32; + src += 4; + dst += 4; + } + + src += srcskip; + dst += dstskip; + } +} + +#ifdef SDL_SSE4_1_INTRINSICS + +static void SDL_TARGETING("sse4.1") Blit8888to8888PixelAlphaSwizzleSSE41(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + + // The byte offsets for the start of each pixel + const __m128i mask_offsets = _mm_set_epi8( + 12, 12, 12, 12, 8, 8, 8, 8, 4, 4, 4, 4, 0, 0, 0, 0); + + const __m128i convert_mask = _mm_add_epi32( + _mm_set1_epi32( + ((srcfmt->Rshift >> 3) << dstfmt->Rshift) | + ((srcfmt->Gshift >> 3) << dstfmt->Gshift) | + ((srcfmt->Bshift >> 3) << dstfmt->Bshift)), + mask_offsets); + + const __m128i alpha_splat_mask = _mm_add_epi8(_mm_set1_epi8(srcfmt->Ashift >> 3), mask_offsets); + const __m128i alpha_fill_mask = _mm_set1_epi32((int)dstfmt->Amask); + + while (height--) { + int i = 0; + + for (; i + 4 <= width; i += 4) { + // Load 4 src pixels + __m128i src128 = _mm_loadu_si128((__m128i *)src); + + // Load 4 dst pixels + __m128i dst128 = _mm_loadu_si128((__m128i *)dst); + + // Extract the alpha from each pixel and splat it into all the channels + __m128i srcA = _mm_shuffle_epi8(src128, alpha_splat_mask); + + // Convert to dst format + src128 = _mm_shuffle_epi8(src128, convert_mask); + + // Set the alpha channels of src to 255 + src128 = _mm_or_si128(src128, alpha_fill_mask); + + // Duplicate each 8-bit alpha value into both bytes of 16-bit lanes + __m128i srca_lo = _mm_unpacklo_epi8(srcA, srcA); + __m128i srca_hi = _mm_unpackhi_epi8(srcA, srcA); + + // Calculate 255-srcA in every second 8-bit lane (255-srcA = srcA^0xff) + srca_lo = _mm_xor_si128(srca_lo, _mm_set1_epi16(0xff00)); + srca_hi = _mm_xor_si128(srca_hi, _mm_set1_epi16(0xff00)); + + // maddubs expects second argument to be signed, so subtract 128 + src128 = _mm_sub_epi8(src128, _mm_set1_epi8((Uint8)128)); + dst128 = _mm_sub_epi8(dst128, _mm_set1_epi8((Uint8)128)); + + // dst = srcA*(src-128) + (255-srcA)*(dst-128) = srcA*src + (255-srcA)*dst - 128*255 + __m128i dst_lo = _mm_maddubs_epi16(srca_lo, _mm_unpacklo_epi8(src128, dst128)); + __m128i dst_hi = _mm_maddubs_epi16(srca_hi, _mm_unpackhi_epi8(src128, dst128)); + + // dst += 0x1U (use 0x80 to round instead of floor) + 128*255 (to fix maddubs result) + dst_lo = _mm_add_epi16(dst_lo, _mm_set1_epi16(1 + 128*255)); + dst_hi = _mm_add_epi16(dst_hi, _mm_set1_epi16(1 + 128*255)); + + // dst = (dst + (dst >> 8)) >> 8 = (dst * 257) >> 16 + dst_lo = _mm_mulhi_epu16(dst_lo, _mm_set1_epi16(257)); + dst_hi = _mm_mulhi_epu16(dst_hi, _mm_set1_epi16(257)); + + // Blend the pixels together and save the result + _mm_storeu_si128((__m128i *)dst, _mm_packus_epi16(dst_lo, dst_hi)); + + src += 16; + dst += 16; + } + + for (; i < width; ++i) { + Uint32 src32 = *(Uint32 *)src; + Uint32 dst32 = *(Uint32 *)dst; + ALPHA_BLEND_SWIZZLE_8888(src32, dst32, srcfmt, dstfmt); + *(Uint32 *)dst = dst32; + src += 4; + dst += 4; + } + + src += srcskip; + dst += dstskip; + } +} + +#endif + +#ifdef SDL_AVX2_INTRINSICS + +static void SDL_TARGETING("avx2") Blit8888to8888PixelAlphaSwizzleAVX2(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + + // The byte offsets for the start of each pixel + const __m256i mask_offsets = _mm256_set_epi8( + 28, 28, 28, 28, 24, 24, 24, 24, 20, 20, 20, 20, 16, 16, 16, 16, 12, 12, 12, 12, 8, 8, 8, 8, 4, 4, 4, 4, 0, 0, 0, 0); + + const __m256i convert_mask = _mm256_add_epi32( + _mm256_set1_epi32( + ((srcfmt->Rshift >> 3) << dstfmt->Rshift) | + ((srcfmt->Gshift >> 3) << dstfmt->Gshift) | + ((srcfmt->Bshift >> 3) << dstfmt->Bshift)), + mask_offsets); + + const __m256i alpha_splat_mask = _mm256_add_epi8(_mm256_set1_epi8(srcfmt->Ashift >> 3), mask_offsets); + const __m256i alpha_fill_mask = _mm256_set1_epi32((int)dstfmt->Amask); + + while (height--) { + int i = 0; + + for (; i + 8 <= width; i += 8) { + // Load 8 src pixels + __m256i src256 = _mm256_loadu_si256((__m256i *)src); + + // Load 8 dst pixels + __m256i dst256 = _mm256_loadu_si256((__m256i *)dst); + + // Extract the alpha from each pixel and splat it into all the channels + __m256i srcA = _mm256_shuffle_epi8(src256, alpha_splat_mask); + + // Convert to dst format + src256 = _mm256_shuffle_epi8(src256, convert_mask); + + // Set the alpha channels of src to 255 + src256 = _mm256_or_si256(src256, alpha_fill_mask); + + // Duplicate each 8-bit alpha value into both bytes of 16-bit lanes + __m256i alpha_lo = _mm256_unpacklo_epi8(srcA, srcA); + __m256i alpha_hi = _mm256_unpackhi_epi8(srcA, srcA); + + // Calculate 255-srcA in every second 8-bit lane (255-srcA = srcA^0xff) + alpha_lo = _mm256_xor_si256(alpha_lo, _mm256_set1_epi16(0xff00)); + alpha_hi = _mm256_xor_si256(alpha_hi, _mm256_set1_epi16(0xff00)); + + // maddubs expects second argument to be signed, so subtract 128 + src256 = _mm256_sub_epi8(src256, _mm256_set1_epi8((Uint8)128)); + dst256 = _mm256_sub_epi8(dst256, _mm256_set1_epi8((Uint8)128)); + + // dst = srcA*(src-128) + (255-srcA)*(dst-128) = srcA*src + (255-srcA)*dst - 128*255 + __m256i dst_lo = _mm256_maddubs_epi16(alpha_lo, _mm256_unpacklo_epi8(src256, dst256)); + __m256i dst_hi = _mm256_maddubs_epi16(alpha_hi, _mm256_unpackhi_epi8(src256, dst256)); + + // dst += 0x1U (use 0x80 to round instead of floor) + 128*255 (to fix maddubs result) + dst_lo = _mm256_add_epi16(dst_lo, _mm256_set1_epi16(1 + 128*255)); + dst_hi = _mm256_add_epi16(dst_hi, _mm256_set1_epi16(1 + 128*255)); + + // dst = (dst + (dst >> 8)) >> 8 = (dst * 257) >> 16 + dst_lo = _mm256_mulhi_epu16(dst_lo, _mm256_set1_epi16(257)); + dst_hi = _mm256_mulhi_epu16(dst_hi, _mm256_set1_epi16(257)); + + // Blend the pixels together and save the result + _mm256_storeu_si256((__m256i *)dst, _mm256_packus_epi16(dst_lo, dst_hi)); + + src += 32; + dst += 32; + } + + for (; i < width; ++i) { + Uint32 src32 = *(Uint32 *)src; + Uint32 dst32 = *(Uint32 *)dst; + ALPHA_BLEND_SWIZZLE_8888(src32, dst32, srcfmt, dstfmt); + *(Uint32 *)dst = dst32; + src += 4; + dst += 4; + } + + src += srcskip; + dst += dstskip; + } +} + +#endif + +#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8) + +static void Blit8888to8888PixelAlphaSwizzleNEON(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + + // The byte offsets for the start of each pixel + const uint8x16_t mask_offsets = vreinterpretq_u8_u64(vcombine_u64( + vcreate_u64(0x0404040400000000), vcreate_u64(0x0c0c0c0c08080808))); + + const uint8x16_t convert_mask = vreinterpretq_u8_u32(vaddq_u32( + vreinterpretq_u32_u8(mask_offsets), + vdupq_n_u32( + ((srcfmt->Rshift >> 3) << dstfmt->Rshift) | + ((srcfmt->Gshift >> 3) << dstfmt->Gshift) | + ((srcfmt->Bshift >> 3) << dstfmt->Bshift)))); + + const uint8x16_t alpha_splat_mask = vaddq_u8(vdupq_n_u8(srcfmt->Ashift >> 3), mask_offsets); + const uint8x16_t alpha_fill_mask = vreinterpretq_u8_u32(vdupq_n_u32(dstfmt->Amask)); + + while (height--) { + int i = 0; + + for (; i + 4 <= width; i += 4) { + // Load 4 src pixels + uint8x16_t src128 = vld1q_u8(src); + + // Load 4 dst pixels + uint8x16_t dst128 = vld1q_u8(dst); + + // Extract the alpha from each pixel and splat it into all the channels + uint8x16_t srcA = vqtbl1q_u8(src128, alpha_splat_mask); + + // Convert to dst format + src128 = vqtbl1q_u8(src128, convert_mask); + + // Set the alpha channels of src to 255 + src128 = vorrq_u8(src128, alpha_fill_mask); + + // 255 - srcA = ~srcA + uint8x16_t srcInvA = vmvnq_u8(srcA); + + // Result initialized with 1, this is for truncated divide later + uint16x8_t res_lo = vdupq_n_u16(1); + uint16x8_t res_hi = vdupq_n_u16(1); + + // res = alpha * src + (255 - alpha) * dst + res_lo = vmlal_u8(res_lo, vget_low_u8(srcA), vget_low_u8(src128)); + res_lo = vmlal_u8(res_lo, vget_low_u8(srcInvA), vget_low_u8(dst128)); + res_hi = vmlal_high_u8(res_hi, srcA, src128); + res_hi = vmlal_high_u8(res_hi, srcInvA, dst128); + + // Now result has +1 already added for truncated division + // dst = (res + (res >> 8)) >> 8 + uint8x8_t temp; + temp = vaddhn_u16(res_lo, vshrq_n_u16(res_lo, 8)); + dst128 = vaddhn_high_u16(temp, res_hi, vshrq_n_u16(res_hi, 8)); + + // For rounded division remove the constant 1 and change first two vmlal_u8 to vmull_u8 + // Then replace two previous lines with following code: + // temp = vraddhn_u16(res_lo, vrshrq_n_u16(res_lo, 8)); + // dst128 = vraddhn_high_u16(temp, res_hi, vrshrq_n_u16(res_hi, 8)); + + // Save the result + vst1q_u8(dst, dst128); + + src += 16; + dst += 16; + } + + // Process 1 pixel per iteration, max 3 iterations, same calculations as above + for (; i < width; ++i) { + // Top 32-bits will be not used in src32 & dst32 + uint8x8_t src32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32*)src)); + uint8x8_t dst32 = vreinterpret_u8_u32(vld1_dup_u32((Uint32*)dst)); + + uint8x8_t srcA = vtbl1_u8(src32, vget_low_u8(alpha_splat_mask)); + src32 = vtbl1_u8(src32, vget_low_u8(convert_mask)); + src32 = vorr_u8(src32, vget_low_u8(alpha_fill_mask)); + uint8x8_t srcInvA = vmvn_u8(srcA); + + uint16x8_t res = vdupq_n_u16(1); + res = vmlal_u8(res, srcA, src32); + res = vmlal_u8(res, srcInvA, dst32); + + dst32 = vaddhn_u16(res, vshrq_n_u16(res, 8)); + + // Save the result, only low 32-bits + vst1_lane_u32((Uint32*)dst, vreinterpret_u32_u8(dst32), 0); + + src += 4; + dst += 4; + } + + src += srcskip; + dst += dstskip; + } +} + +#endif + +// General (slow) N->N blending with pixel alpha +static void BlitNtoNPixelAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int srcbpp; + int dstbpp; + Uint32 Pixel; + unsigned sR, sG, sB, sA; + unsigned dR, dG, dB, dA; + + // Set up some basic variables + srcbpp = srcfmt->bytes_per_pixel; + dstbpp = dstfmt->bytes_per_pixel; + + while (height--) { + DUFFS_LOOP( + { + DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); + if (sA) { + DISEMBLE_RGBA(dst, dstbpp, dstfmt, Pixel, dR, dG, dB, dA); + ALPHA_BLEND_RGBA(sR, sG, sB, sA, dR, dG, dB, dA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA); + } + src += srcbpp; + dst += dstbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) +{ + const SDL_PixelFormatDetails *sf = surface->fmt; + const SDL_PixelFormatDetails *df = surface->map.info.dst_fmt; + + switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) { + case SDL_COPY_BLEND: + // Per-pixel alpha blits + switch (df->bytes_per_pixel) { + case 1: + if (surface->map.info.dst_pal) { + return BlitNto1PixelAlpha; + } else { + // RGB332 has no palette ! + return BlitNtoNPixelAlpha; + } + + case 2: + if (sf->bytes_per_pixel == 4 && sf->Amask == 0xff000000 && sf->Gmask == 0xff00 && ((sf->Rmask == 0xff && df->Rmask == 0x1f) || (sf->Bmask == 0xff && df->Bmask == 0x1f))) { + if (df->Gmask == 0x7e0) { + return BlitARGBto565PixelAlpha; + } else if (df->Gmask == 0x3e0 && !df->Amask) { + return BlitARGBto555PixelAlpha; + } + } + return BlitNtoNPixelAlpha; + + case 4: + if (SDL_PIXELLAYOUT(sf->format) == SDL_PACKEDLAYOUT_8888 && sf->Amask && + SDL_PIXELLAYOUT(df->format) == SDL_PACKEDLAYOUT_8888) { +#ifdef SDL_AVX2_INTRINSICS + if (SDL_HasAVX2()) { + return Blit8888to8888PixelAlphaSwizzleAVX2; + } +#endif +#ifdef SDL_SSE4_1_INTRINSICS + if (SDL_HasSSE41()) { + return Blit8888to8888PixelAlphaSwizzleSSE41; + } +#endif +#if defined(SDL_NEON_INTRINSICS) && (__ARM_ARCH >= 8) + // To prevent "unused function" compiler warnings/errors + (void)Blit8888to8888PixelAlpha; + (void)Blit8888to8888PixelAlphaSwizzle; + return Blit8888to8888PixelAlphaSwizzleNEON; +#else + if (sf->format == df->format) { + return Blit8888to8888PixelAlpha; + } else { + return Blit8888to8888PixelAlphaSwizzle; + } +#endif + } + return BlitNtoNPixelAlpha; + + case 3: + default: + break; + } + return BlitNtoNPixelAlpha; + + case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + if (sf->Amask == 0) { + // Per-surface alpha blits + switch (df->bytes_per_pixel) { + case 1: + if (surface->map.info.dst_pal) { + return BlitNto1SurfaceAlpha; + } else { + // RGB332 has no palette ! + return BlitNtoNSurfaceAlpha; + } + + case 2: + if (surface->map.identity) { + if (df->Gmask == 0x7e0) { +#ifdef SDL_MMX_INTRINSICS + if (SDL_HasMMX()) { + return Blit565to565SurfaceAlphaMMX; + } else +#endif + { + return Blit565to565SurfaceAlpha; + } + } else if (df->Gmask == 0x3e0) { +#ifdef SDL_MMX_INTRINSICS + if (SDL_HasMMX()) { + return Blit555to555SurfaceAlphaMMX; + } else +#endif + { + return Blit555to555SurfaceAlpha; + } + } + } + return BlitNtoNSurfaceAlpha; + + case 4: + if (sf->Rmask == df->Rmask && sf->Gmask == df->Gmask && sf->Bmask == df->Bmask && sf->bytes_per_pixel == 4) { +#ifdef SDL_SSE2_INTRINSICS + if (sf->Rshift % 8 == 0 && sf->Gshift % 8 == 0 && sf->Bshift % 8 == 0 && SDL_HasSSE2()) { + return Blit888to888SurfaceAlphaSSE2; + } +#endif + if ((sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff) { + return BlitRGBtoRGBSurfaceAlpha; + } + } + return BlitNtoNSurfaceAlpha; + + case 3: + default: + return BlitNtoNSurfaceAlpha; + } + } + break; + + case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND: + if (sf->Amask == 0) { + if (df->bytes_per_pixel == 1) { + + if (surface->map.info.dst_pal) { + return BlitNto1SurfaceAlphaKey; + } else { + // RGB332 has no palette ! + return BlitNtoNSurfaceAlphaKey; + } + } else { + return BlitNtoNSurfaceAlphaKey; + } + } + break; + } + + return NULL; +} + +#endif // SDL_HAVE_BLIT_A + diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_N.c b/contrib/SDL-3.2.8/src/video/SDL_blit_N.c new file mode 100644 index 0000000..c710e46 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_N.c @@ -0,0 +1,2954 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_HAVE_BLIT_N + +#include "SDL_surface_c.h" +#include "SDL_blit_copy.h" + +// General optimized routines that write char by char +#define HAVE_FAST_WRITE_INT8 1 + +// On some CPU, it's slower than combining and write a word +#ifdef __MIPS__ +#undef HAVE_FAST_WRITE_INT8 +#define HAVE_FAST_WRITE_INT8 0 +#endif + +// Functions to blit from N-bit surfaces to other surfaces + +#define BLIT_FEATURE_NONE 0x00 +#define BLIT_FEATURE_HAS_MMX 0x01 +#define BLIT_FEATURE_HAS_ALTIVEC 0x02 +#define BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH 0x04 + +#ifdef SDL_ALTIVEC_BLITTERS +#ifdef SDL_PLATFORM_MACOS +#include +static size_t GetL3CacheSize(void) +{ + const char key[] = "hw.l3cachesize"; + u_int64_t result = 0; + size_t typeSize = sizeof(result); + + int err = sysctlbyname(key, &result, &typeSize, NULL, 0); + if (0 != err) { + return 0; + } + + return result; +} +#else +static size_t GetL3CacheSize(void) +{ + // XXX: Just guess G4 + return 2097152; +} +#endif // SDL_PLATFORM_MACOS + +#if (defined(SDL_PLATFORM_MACOS) && (__GNUC__ < 4)) +#define VECUINT8_LITERAL(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ + (vector unsigned char)(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) +#define VECUINT16_LITERAL(a, b, c, d, e, f, g, h) \ + (vector unsigned short)(a, b, c, d, e, f, g, h) +#else +#define VECUINT8_LITERAL(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \ + (vector unsigned char) \ + { \ + a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p \ + } +#define VECUINT16_LITERAL(a, b, c, d, e, f, g, h) \ + (vector unsigned short) \ + { \ + a, b, c, d, e, f, g, h \ + } +#endif + +#define UNALIGNED_PTR(x) (((size_t)x) & 0x0000000F) +#define VSWIZZLE32(a, b, c, d) (vector unsigned char)(0x00 + a, 0x00 + b, 0x00 + c, 0x00 + d, \ + 0x04 + a, 0x04 + b, 0x04 + c, 0x04 + d, \ + 0x08 + a, 0x08 + b, 0x08 + c, 0x08 + d, \ + 0x0C + a, 0x0C + b, 0x0C + c, 0x0C + d) + +#define MAKE8888(dstfmt, r, g, b, a) \ + (((r << dstfmt->Rshift) & dstfmt->Rmask) | \ + ((g << dstfmt->Gshift) & dstfmt->Gmask) | \ + ((b << dstfmt->Bshift) & dstfmt->Bmask) | \ + ((a << dstfmt->Ashift) & dstfmt->Amask)) + +/* + * Data Stream Touch...Altivec cache prefetching. + * + * Don't use this on a G5...however, the speed boost is very significant + * on a G4. + */ +#define DST_CHAN_SRC 1 +#define DST_CHAN_DEST 2 + +// macro to set DST control word value... +#define DST_CTRL(size, count, stride) \ + (((size) << 24) | ((count) << 16) | (stride)) + +#define VEC_ALIGNER(src) ((UNALIGNED_PTR(src)) \ + ? vec_lvsl(0, src) \ + : vec_add(vec_lvsl(8, src), vec_splat_u8(8))) + +// Calculate the permute vector used for 32->32 swizzling +static vector unsigned char calc_swizzle32(const SDL_PixelFormatDetails *srcfmt, const SDL_PixelFormatDetails *dstfmt) +{ + /* + * We have to assume that the bits that aren't used by other + * colors is alpha, and it's one complete byte, since some formats + * leave alpha with a zero mask, but we should still swizzle the bits. + */ + // ARGB + static const SDL_PixelFormatDetails default_pixel_format = { + SDL_PIXELFORMAT_ARGB8888, 0, 0, { 0, 0 }, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, 8, 8, 8, 8, 16, 8, 0, 24 + }; + const vector unsigned char plus = VECUINT8_LITERAL(0x00, 0x00, 0x00, 0x00, + 0x04, 0x04, 0x04, 0x04, + 0x08, 0x08, 0x08, 0x08, + 0x0C, 0x0C, 0x0C, + 0x0C); + vector unsigned char vswiz; + vector unsigned int srcvec; + Uint32 rmask, gmask, bmask, amask; + + if (!srcfmt) { + srcfmt = &default_pixel_format; + } + if (!dstfmt) { + dstfmt = &default_pixel_format; + } + +#define RESHIFT(X) (3 - ((X) >> 3)) + rmask = RESHIFT(srcfmt->Rshift) << (dstfmt->Rshift); + gmask = RESHIFT(srcfmt->Gshift) << (dstfmt->Gshift); + bmask = RESHIFT(srcfmt->Bshift) << (dstfmt->Bshift); + + // Use zero for alpha if either surface doesn't have alpha + if (dstfmt->Amask) { + amask = + ((srcfmt->Amask) ? RESHIFT(srcfmt->Ashift) : 0x10) << (dstfmt->Ashift); + } else { + amask = + 0x10101010 & ((dstfmt->Rmask | dstfmt->Gmask | dstfmt->Bmask) ^ + 0xFFFFFFFF); + } +#undef RESHIFT + + ((unsigned int *)(char *)&srcvec)[0] = (rmask | gmask | bmask | amask); + vswiz = vec_add(plus, (vector unsigned char)vec_splat(srcvec, 0)); + return (vswiz); +} + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +// reorder bytes for PowerPC little endian +static vector unsigned char reorder_ppc64le_vec(vector unsigned char vpermute) +{ + /* The result vector of calc_swizzle32 reorder bytes using vec_perm. + The LE transformation for vec_perm has an implicit assumption + that the permutation is being used to reorder vector elements, + not to reorder bytes within those elements. + Unfortunately the result order is not the expected one for powerpc + little endian when the two first vector parameters of vec_perm are + not of type 'vector char'. This is because the numbering from the + left for BE, and numbering from the right for LE, produces a + different interpretation of what the odd and even lanes are. + Refer to fedora bug 1392465 + */ + + const vector unsigned char ppc64le_reorder = VECUINT8_LITERAL( + 0x01, 0x00, 0x03, 0x02, + 0x05, 0x04, 0x07, 0x06, + 0x09, 0x08, 0x0B, 0x0A, + 0x0D, 0x0C, 0x0F, 0x0E); + + vector unsigned char vswiz_ppc64le; + vswiz_ppc64le = vec_perm(vpermute, vpermute, ppc64le_reorder); + return (vswiz_ppc64le); +} +#endif + +static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info); +static void Blit_XRGB8888_RGB565Altivec(SDL_BlitInfo *info) +{ + int height = info->dst_h; + Uint8 *src = (Uint8 *)info->src; + int srcskip = info->src_skip; + Uint8 *dst = (Uint8 *)info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + vector unsigned char valpha = vec_splat_u8(0); + vector unsigned char vpermute = calc_swizzle32(srcfmt, NULL); + vector unsigned char vgmerge = VECUINT8_LITERAL(0x00, 0x02, 0x00, 0x06, + 0x00, 0x0a, 0x00, 0x0e, + 0x00, 0x12, 0x00, 0x16, + 0x00, 0x1a, 0x00, 0x1e); + vector unsigned short v1 = vec_splat_u16(1); + vector unsigned short v3 = vec_splat_u16(3); + vector unsigned short v3f = + VECUINT16_LITERAL(0x003f, 0x003f, 0x003f, 0x003f, + 0x003f, 0x003f, 0x003f, 0x003f); + vector unsigned short vfc = + VECUINT16_LITERAL(0x00fc, 0x00fc, 0x00fc, 0x00fc, + 0x00fc, 0x00fc, 0x00fc, 0x00fc); + vector unsigned short vf800 = (vector unsigned short)vec_splat_u8(-7); + vf800 = vec_sl(vf800, vec_splat_u16(8)); + + while (height--) { + vector unsigned char valigner; + vector unsigned char voverflow; + vector unsigned char vsrc; + + int width = info->dst_w; + int extrawidth; + + // do scalar until we can align... +#define ONE_PIXEL_BLEND(condition, widthvar) \ + while (condition) { \ + Uint32 Pixel; \ + unsigned sR, sG, sB, sA; \ + DISEMBLE_RGBA((Uint8 *)src, 4, srcfmt, Pixel, \ + sR, sG, sB, sA); \ + *(Uint16 *)(dst) = (((sR << 8) & 0x0000F800) | \ + ((sG << 3) & 0x000007E0) | \ + ((sB >> 3) & 0x0000001F)); \ + dst += 2; \ + src += 4; \ + widthvar--; \ + } + + ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); + + // After all that work, here's the vector part! + extrawidth = (width % 8); // trailing unaligned stores + width -= extrawidth; + vsrc = vec_ld(0, src); + valigner = VEC_ALIGNER(src); + + while (width) { + vector unsigned short vpixel, vrpixel, vgpixel, vbpixel; + vector unsigned int vsrc1, vsrc2; + vector unsigned char vdst; + + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); + vsrc1 = (vector unsigned int)vec_perm(vsrc, valpha, vpermute); + src += 16; + vsrc = voverflow; + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); + vsrc2 = (vector unsigned int)vec_perm(vsrc, valpha, vpermute); + // 1555 + vpixel = (vector unsigned short)vec_packpx(vsrc1, vsrc2); + vgpixel = (vector unsigned short)vec_perm(vsrc1, vsrc2, vgmerge); + vgpixel = vec_and(vgpixel, vfc); + vgpixel = vec_sl(vgpixel, v3); + vrpixel = vec_sl(vpixel, v1); + vrpixel = vec_and(vrpixel, vf800); + vbpixel = vec_and(vpixel, v3f); + vdst = + vec_or((vector unsigned char)vrpixel, + (vector unsigned char)vgpixel); + // 565 + vdst = vec_or(vdst, (vector unsigned char)vbpixel); + vec_st(vdst, 0, dst); + + width -= 8; + src += 16; + dst += 16; + vsrc = voverflow; + } + + SDL_assert(width == 0); + + // do scalar until we can align... + ONE_PIXEL_BLEND((extrawidth), extrawidth); +#undef ONE_PIXEL_BLEND + + src += srcskip; // move to next row, accounting for pitch. + dst += dstskip; + } +} + +static void Blit_RGB565_32Altivec(SDL_BlitInfo *info) +{ + int height = info->dst_h; + Uint8 *src = (Uint8 *)info->src; + int srcskip = info->src_skip; + Uint8 *dst = (Uint8 *)info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + unsigned alpha; + vector unsigned char valpha; + vector unsigned char vpermute; + vector unsigned short vf800; + vector unsigned int v8 = vec_splat_u32(8); + vector unsigned int v16 = vec_add(v8, v8); + vector unsigned short v2 = vec_splat_u16(2); + vector unsigned short v3 = vec_splat_u16(3); + /* + 0x10 - 0x1f is the alpha + 0x00 - 0x0e evens are the red + 0x01 - 0x0f odds are zero + */ + vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01, + 0x10, 0x02, 0x01, 0x01, + 0x10, 0x04, 0x01, 0x01, + 0x10, 0x06, 0x01, + 0x01); + vector unsigned char vredalpha2 = + (vector unsigned char)(vec_add((vector unsigned int)vredalpha1, vec_sl(v8, v16))); + /* + 0x00 - 0x0f is ARxx ARxx ARxx ARxx + 0x11 - 0x0f odds are blue + */ + vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11, + 0x04, 0x05, 0x06, 0x13, + 0x08, 0x09, 0x0a, 0x15, + 0x0c, 0x0d, 0x0e, 0x17); + vector unsigned char vblue2 = + (vector unsigned char)(vec_add((vector unsigned int)vblue1, v8)); + /* + 0x00 - 0x0f is ARxB ARxB ARxB ARxB + 0x10 - 0x0e evens are green + */ + vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03, + 0x04, 0x05, 0x12, 0x07, + 0x08, 0x09, 0x14, 0x0b, + 0x0c, 0x0d, 0x16, 0x0f); + vector unsigned char vgreen2 = + (vector unsigned char)(vec_add((vector unsigned int)vgreen1, vec_sl(v8, v8))); + + SDL_assert(srcfmt->bytes_per_pixel == 2); + SDL_assert(dstfmt->bytes_per_pixel == 4); + + vf800 = (vector unsigned short)vec_splat_u8(-7); + vf800 = vec_sl(vf800, vec_splat_u16(8)); + + if (dstfmt->Amask && info->a) { + ((unsigned char *)&valpha)[0] = alpha = info->a; + valpha = vec_splat(valpha, 0); + } else { + alpha = 0; + valpha = vec_splat_u8(0); + } + + vpermute = calc_swizzle32(NULL, dstfmt); + while (height--) { + vector unsigned char valigner; + vector unsigned char voverflow; + vector unsigned char vsrc; + + int width = info->dst_w; + int extrawidth; + + // do scalar until we can align... +#define ONE_PIXEL_BLEND(condition, widthvar) \ + while (condition) { \ + unsigned sR, sG, sB; \ + unsigned short Pixel = *((unsigned short *)src); \ + sR = (Pixel >> 8) & 0xf8; \ + sG = (Pixel >> 3) & 0xfc; \ + sB = (Pixel << 3) & 0xf8; \ + ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ + src += 2; \ + dst += 4; \ + widthvar--; \ + } + ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); + + // After all that work, here's the vector part! + extrawidth = (width % 8); // trailing unaligned stores + width -= extrawidth; + vsrc = vec_ld(0, src); + valigner = VEC_ALIGNER(src); + + while (width) { + vector unsigned short vR, vG, vB; + vector unsigned char vdst1, vdst2; + + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); + + vR = vec_and((vector unsigned short)vsrc, vf800); + vB = vec_sl((vector unsigned short)vsrc, v3); + vG = vec_sl(vB, v2); + + vdst1 = + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vB, vblue1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vG, vgreen1); + vdst1 = vec_perm(vdst1, valpha, vpermute); + vec_st(vdst1, 0, dst); + + vdst2 = + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vB, vblue2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vG, vgreen2); + vdst2 = vec_perm(vdst2, valpha, vpermute); + vec_st(vdst2, 16, dst); + + width -= 8; + dst += 32; + src += 16; + vsrc = voverflow; + } + + SDL_assert(width == 0); + + // do scalar until we can align... + ONE_PIXEL_BLEND((extrawidth), extrawidth); +#undef ONE_PIXEL_BLEND + + src += srcskip; // move to next row, accounting for pitch. + dst += dstskip; + } +} + +static void Blit_RGB555_32Altivec(SDL_BlitInfo *info) +{ + int height = info->dst_h; + Uint8 *src = (Uint8 *)info->src; + int srcskip = info->src_skip; + Uint8 *dst = (Uint8 *)info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + unsigned alpha; + vector unsigned char valpha; + vector unsigned char vpermute; + vector unsigned short vf800; + vector unsigned int v8 = vec_splat_u32(8); + vector unsigned int v16 = vec_add(v8, v8); + vector unsigned short v1 = vec_splat_u16(1); + vector unsigned short v3 = vec_splat_u16(3); + /* + 0x10 - 0x1f is the alpha + 0x00 - 0x0e evens are the red + 0x01 - 0x0f odds are zero + */ + vector unsigned char vredalpha1 = VECUINT8_LITERAL(0x10, 0x00, 0x01, 0x01, + 0x10, 0x02, 0x01, 0x01, + 0x10, 0x04, 0x01, 0x01, + 0x10, 0x06, 0x01, + 0x01); + vector unsigned char vredalpha2 = + (vector unsigned char)(vec_add((vector unsigned int)vredalpha1, vec_sl(v8, v16))); + /* + 0x00 - 0x0f is ARxx ARxx ARxx ARxx + 0x11 - 0x0f odds are blue + */ + vector unsigned char vblue1 = VECUINT8_LITERAL(0x00, 0x01, 0x02, 0x11, + 0x04, 0x05, 0x06, 0x13, + 0x08, 0x09, 0x0a, 0x15, + 0x0c, 0x0d, 0x0e, 0x17); + vector unsigned char vblue2 = + (vector unsigned char)(vec_add((vector unsigned int)vblue1, v8)); + /* + 0x00 - 0x0f is ARxB ARxB ARxB ARxB + 0x10 - 0x0e evens are green + */ + vector unsigned char vgreen1 = VECUINT8_LITERAL(0x00, 0x01, 0x10, 0x03, + 0x04, 0x05, 0x12, 0x07, + 0x08, 0x09, 0x14, 0x0b, + 0x0c, 0x0d, 0x16, 0x0f); + vector unsigned char vgreen2 = + (vector unsigned char)(vec_add((vector unsigned int)vgreen1, vec_sl(v8, v8))); + + SDL_assert(srcfmt->bytes_per_pixel == 2); + SDL_assert(dstfmt->bytes_per_pixel == 4); + + vf800 = (vector unsigned short)vec_splat_u8(-7); + vf800 = vec_sl(vf800, vec_splat_u16(8)); + + if (dstfmt->Amask && info->a) { + ((unsigned char *)&valpha)[0] = alpha = info->a; + valpha = vec_splat(valpha, 0); + } else { + alpha = 0; + valpha = vec_splat_u8(0); + } + + vpermute = calc_swizzle32(NULL, dstfmt); + while (height--) { + vector unsigned char valigner; + vector unsigned char voverflow; + vector unsigned char vsrc; + + int width = info->dst_w; + int extrawidth; + + // do scalar until we can align... +#define ONE_PIXEL_BLEND(condition, widthvar) \ + while (condition) { \ + unsigned sR, sG, sB; \ + unsigned short Pixel = *((unsigned short *)src); \ + sR = (Pixel >> 7) & 0xf8; \ + sG = (Pixel >> 2) & 0xf8; \ + sB = (Pixel << 3) & 0xf8; \ + ASSEMBLE_RGBA(dst, 4, dstfmt, sR, sG, sB, alpha); \ + src += 2; \ + dst += 4; \ + widthvar--; \ + } + ONE_PIXEL_BLEND(((UNALIGNED_PTR(dst)) && (width)), width); + + // After all that work, here's the vector part! + extrawidth = (width % 8); // trailing unaligned stores + width -= extrawidth; + vsrc = vec_ld(0, src); + valigner = VEC_ALIGNER(src); + + while (width) { + vector unsigned short vR, vG, vB; + vector unsigned char vdst1, vdst2; + + voverflow = vec_ld(15, src); + vsrc = vec_perm(vsrc, voverflow, valigner); + + vR = vec_and(vec_sl((vector unsigned short)vsrc, v1), vf800); + vB = vec_sl((vector unsigned short)vsrc, v3); + vG = vec_sl(vB, v3); + + vdst1 = + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vB, vblue1); + vdst1 = vec_perm(vdst1, (vector unsigned char)vG, vgreen1); + vdst1 = vec_perm(vdst1, valpha, vpermute); + vec_st(vdst1, 0, dst); + + vdst2 = + (vector unsigned char)vec_perm((vector unsigned char)vR, + valpha, vredalpha2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vB, vblue2); + vdst2 = vec_perm(vdst2, (vector unsigned char)vG, vgreen2); + vdst2 = vec_perm(vdst2, valpha, vpermute); + vec_st(vdst2, 16, dst); + + width -= 8; + dst += 32; + src += 16; + vsrc = voverflow; + } + + SDL_assert(width == 0); + + // do scalar until we can align... + ONE_PIXEL_BLEND((extrawidth), extrawidth); +#undef ONE_PIXEL_BLEND + + src += srcskip; // move to next row, accounting for pitch. + dst += dstskip; + } +} + +static void BlitNtoNKey(SDL_BlitInfo *info); +static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info); +static void Blit32to32KeyAltivec(SDL_BlitInfo *info) +{ + int height = info->dst_h; + Uint32 *srcp = (Uint32 *)info->src; + int srcskip = info->src_skip / 4; + Uint32 *dstp = (Uint32 *)info->dst; + int dstskip = info->dst_skip / 4; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + int srcbpp = srcfmt->bytes_per_pixel; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int dstbpp = dstfmt->bytes_per_pixel; + int copy_alpha = (srcfmt->Amask && dstfmt->Amask); + unsigned alpha = dstfmt->Amask ? info->a : 0; + Uint32 rgbmask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; + Uint32 ckey = info->colorkey; + vector unsigned int valpha; + vector unsigned char vpermute; + vector unsigned char vzero; + vector unsigned int vckey; + vector unsigned int vrgbmask; + vpermute = calc_swizzle32(srcfmt, dstfmt); + if (info->dst_w < 16) { + if (copy_alpha) { + BlitNtoNKeyCopyAlpha(info); + } else { + BlitNtoNKey(info); + } + return; + } + vzero = vec_splat_u8(0); + if (alpha) { + ((unsigned char *)&valpha)[0] = (unsigned char)alpha; + valpha = + (vector unsigned int)vec_splat((vector unsigned char)valpha, 0); + } else { + valpha = (vector unsigned int)vzero; + } + ckey &= rgbmask; + ((unsigned int *)(char *)&vckey)[0] = ckey; + vckey = vec_splat(vckey, 0); + ((unsigned int *)(char *)&vrgbmask)[0] = rgbmask; + vrgbmask = vec_splat(vrgbmask, 0); + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + // reorder bytes for PowerPC little endian + vpermute = reorder_ppc64le_vec(vpermute); +#endif + + while (height--) { +#define ONE_PIXEL_BLEND(condition, widthvar) \ + if (copy_alpha) { \ + while (condition) { \ + Uint32 Pixel; \ + unsigned sR, sG, sB, sA; \ + DISEMBLE_RGBA((Uint8 *)srcp, srcbpp, srcfmt, Pixel, \ + sR, sG, sB, sA); \ + if ((Pixel & rgbmask) != ckey) { \ + ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ + sR, sG, sB, sA); \ + } \ + dstp = (Uint32 *)(((Uint8 *)dstp) + dstbpp); \ + srcp = (Uint32 *)(((Uint8 *)srcp) + srcbpp); \ + widthvar--; \ + } \ + } else { \ + while (condition) { \ + Uint32 Pixel; \ + unsigned sR, sG, sB; \ + RETRIEVE_RGB_PIXEL((Uint8 *)srcp, srcbpp, Pixel); \ + if (Pixel != ckey) { \ + RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); \ + ASSEMBLE_RGBA((Uint8 *)dstp, dstbpp, dstfmt, \ + sR, sG, sB, alpha); \ + } \ + dstp = (Uint32 *)(((Uint8 *)dstp) + dstbpp); \ + srcp = (Uint32 *)(((Uint8 *)srcp) + srcbpp); \ + widthvar--; \ + } \ + } + int width = info->dst_w; + ONE_PIXEL_BLEND((UNALIGNED_PTR(dstp)) && (width), width); + SDL_assert(width > 0); + if (width > 0) { + int extrawidth = (width % 4); + vector unsigned char valigner = VEC_ALIGNER(srcp); + vector unsigned int vs = vec_ld(0, srcp); + width -= extrawidth; + SDL_assert(width >= 4); + while (width) { + vector unsigned char vsel; + vector unsigned int vd; + vector unsigned int voverflow = vec_ld(15, srcp); + // load the source vec + vs = vec_perm(vs, voverflow, valigner); + // vsel is set for items that match the key + vsel = (vector unsigned char)vec_and(vs, vrgbmask); + vsel = (vector unsigned char)vec_cmpeq(vs, vckey); + // permute the src vec to the dest format + vs = vec_perm(vs, valpha, vpermute); + // load the destination vec + vd = vec_ld(0, dstp); + // select the source and dest into vs + vd = (vector unsigned int)vec_sel((vector unsigned char)vs, + (vector unsigned char)vd, + vsel); + + vec_st(vd, 0, dstp); + srcp += 4; + width -= 4; + dstp += 4; + vs = voverflow; + } + ONE_PIXEL_BLEND((extrawidth), extrawidth); +#undef ONE_PIXEL_BLEND + srcp += srcskip; + dstp += dstskip; + } + } +} + +// Altivec code to swizzle one 32-bit surface to a different 32-bit format. +// Use this on a G5 +static void ConvertAltivec32to32_noprefetch(SDL_BlitInfo *info) +{ + int height = info->dst_h; + Uint32 *src = (Uint32 *)info->src; + int srcskip = info->src_skip / 4; + Uint32 *dst = (Uint32 *)info->dst; + int dstskip = info->dst_skip / 4; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + vector unsigned int vzero = vec_splat_u32(0); + vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); + if (dstfmt->Amask && !srcfmt->Amask) { + if (info->a) { + vector unsigned char valpha; + ((unsigned char *)&valpha)[0] = info->a; + vzero = (vector unsigned int)vec_splat(valpha, 0); + } + } + + SDL_assert(srcfmt->bytes_per_pixel == 4); + SDL_assert(dstfmt->bytes_per_pixel == 4); + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + // reorder bytes for PowerPC little endian + vpermute = reorder_ppc64le_vec(vpermute); +#endif + + while (height--) { + vector unsigned char valigner; + vector unsigned int vbits; + vector unsigned int voverflow; + Uint32 bits; + Uint8 r, g, b, a; + + int width = info->dst_w; + int extrawidth; + + // do scalar until we can align... + while ((UNALIGNED_PTR(dst)) && (width)) { + bits = *(src++); + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + if (!srcfmt->Amask) + a = info->a; + *(dst++) = MAKE8888(dstfmt, r, g, b, a); + width--; + } + + // After all that work, here's the vector part! + extrawidth = (width % 4); + width -= extrawidth; + valigner = VEC_ALIGNER(src); + vbits = vec_ld(0, src); + + while (width) { + voverflow = vec_ld(15, src); + src += 4; + width -= 4; + vbits = vec_perm(vbits, voverflow, valigner); // src is ready. + vbits = vec_perm(vbits, vzero, vpermute); // swizzle it. + vec_st(vbits, 0, dst); // store it back out. + dst += 4; + vbits = voverflow; + } + + SDL_assert(width == 0); + + // cover pixels at the end of the row that didn't fit in 16 bytes. + while (extrawidth) { + bits = *(src++); // max 7 pixels, don't bother with prefetch. + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + if (!srcfmt->Amask) + a = info->a; + *(dst++) = MAKE8888(dstfmt, r, g, b, a); + extrawidth--; + } + + src += srcskip; + dst += dstskip; + } +} + +// Altivec code to swizzle one 32-bit surface to a different 32-bit format. +// Use this on a G4 +static void ConvertAltivec32to32_prefetch(SDL_BlitInfo *info) +{ + const int scalar_dst_lead = sizeof(Uint32) * 4; + const int vector_dst_lead = sizeof(Uint32) * 16; + + int height = info->dst_h; + Uint32 *src = (Uint32 *)info->src; + int srcskip = info->src_skip / 4; + Uint32 *dst = (Uint32 *)info->dst; + int dstskip = info->dst_skip / 4; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + vector unsigned int vzero = vec_splat_u32(0); + vector unsigned char vpermute = calc_swizzle32(srcfmt, dstfmt); + if (dstfmt->Amask && !srcfmt->Amask) { + if (info->a) { + vector unsigned char valpha; + ((unsigned char *)&valpha)[0] = info->a; + vzero = (vector unsigned int)vec_splat(valpha, 0); + } + } + + SDL_assert(srcfmt->bytes_per_pixel == 4); + SDL_assert(dstfmt->bytes_per_pixel == 4); + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + // reorder bytes for PowerPC little endian + vpermute = reorder_ppc64le_vec(vpermute); +#endif + + while (height--) { + vector unsigned char valigner; + vector unsigned int vbits; + vector unsigned int voverflow; + Uint32 bits; + Uint8 r, g, b, a; + + int width = info->dst_w; + int extrawidth; + + // do scalar until we can align... + while ((UNALIGNED_PTR(dst)) && (width)) { + vec_dstt(src + scalar_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_SRC); + vec_dstst(dst + scalar_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_DEST); + bits = *(src++); + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + if (!srcfmt->Amask) + a = info->a; + *(dst++) = MAKE8888(dstfmt, r, g, b, a); + width--; + } + + // After all that work, here's the vector part! + extrawidth = (width % 4); + width -= extrawidth; + valigner = VEC_ALIGNER(src); + vbits = vec_ld(0, src); + + while (width) { + vec_dstt(src + vector_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_SRC); + vec_dstst(dst + vector_dst_lead, DST_CTRL(2, 32, 1024), + DST_CHAN_DEST); + voverflow = vec_ld(15, src); + src += 4; + width -= 4; + vbits = vec_perm(vbits, voverflow, valigner); // src is ready. + vbits = vec_perm(vbits, vzero, vpermute); // swizzle it. + vec_st(vbits, 0, dst); // store it back out. + dst += 4; + vbits = voverflow; + } + + SDL_assert(width == 0); + + // cover pixels at the end of the row that didn't fit in 16 bytes. + while (extrawidth) { + bits = *(src++); // max 7 pixels, don't bother with prefetch. + RGBA_FROM_8888(bits, srcfmt, r, g, b, a); + if (!srcfmt->Amask) + a = info->a; + *(dst++) = MAKE8888(dstfmt, r, g, b, a); + extrawidth--; + } + + src += srcskip; + dst += dstskip; + } + + vec_dss(DST_CHAN_SRC); + vec_dss(DST_CHAN_DEST); +} + +static Uint32 GetBlitFeatures(void) +{ + static Uint32 features = ~0u; + if (features == ~0u) { + features = (0 + // Feature 1 is has-MMX + | ((SDL_HasMMX()) ? BLIT_FEATURE_HAS_MMX : 0) + // Feature 2 is has-AltiVec + | ((SDL_HasAltiVec()) ? BLIT_FEATURE_HAS_ALTIVEC : 0) + // Feature 4 is dont-use-prefetch + // !!!! FIXME: Check for G5 or later, not the cache size! Always prefetch on a G4. + | ((GetL3CacheSize() == 0) ? BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH : 0)); + } + return features; +} + +#ifdef __MWERKS__ +#pragma altivec_model off +#endif +#else +// Feature 1 is has-MMX +#define GetBlitFeatures() ((SDL_HasMMX() ? BLIT_FEATURE_HAS_MMX : 0)) +#endif + +// This is now endian dependent +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#define HI 1 +#define LO 0 +#else // SDL_BYTEORDER == SDL_BIG_ENDIAN +#define HI 0 +#define LO 1 +#endif + +// Special optimized blit for RGB 8-8-8 --> RGB 5-5-5 +#define RGB888_RGB555(dst, src) \ + { \ + *(Uint16 *)(dst) = (Uint16)((((*src) & 0x00F80000) >> 9) | \ + (((*src) & 0x0000F800) >> 6) | \ + (((*src) & 0x000000F8) >> 3)); \ + } +#ifndef USE_DUFFS_LOOP +#define RGB888_RGB555_TWO(dst, src) \ + { \ + *(Uint32 *)(dst) = (((((src[HI]) & 0x00F80000) >> 9) | \ + (((src[HI]) & 0x0000F800) >> 6) | \ + (((src[HI]) & 0x000000F8) >> 3)) \ + << 16) | \ + (((src[LO]) & 0x00F80000) >> 9) | \ + (((src[LO]) & 0x0000F800) >> 6) | \ + (((src[LO]) & 0x000000F8) >> 3); \ + } +#endif +static void Blit_XRGB8888_RGB555(SDL_BlitInfo *info) +{ +#ifndef USE_DUFFS_LOOP + int c; +#endif + int width, height; + Uint32 *src; + Uint16 *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = (Uint32 *)info->src; + srcskip = info->src_skip / 4; + dst = (Uint16 *)info->dst; + dstskip = info->dst_skip / 2; + +#ifdef USE_DUFFS_LOOP + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + RGB888_RGB555(dst, src); + ++src; + ++dst; + , width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +#else + // Memory align at 4-byte boundary, if necessary + if ((long)dst & 0x03) { + // Don't do anything if width is 0 + if (width == 0) { + return; + } + --width; + + while (height--) { + // Perform copy alignment + RGB888_RGB555(dst, src); + ++src; + ++dst; + + // Copy in 4 pixel chunks + for (c = width / 4; c; --c) { + RGB888_RGB555_TWO(dst, src); + src += 2; + dst += 2; + RGB888_RGB555_TWO(dst, src); + src += 2; + dst += 2; + } + // Get any leftovers + switch (width & 3) { + case 3: + RGB888_RGB555(dst, src); + ++src; + ++dst; + SDL_FALLTHROUGH; + case 2: + RGB888_RGB555_TWO(dst, src); + src += 2; + dst += 2; + break; + case 1: + RGB888_RGB555(dst, src); + ++src; + ++dst; + break; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + // Copy in 4 pixel chunks + for (c = width / 4; c; --c) { + RGB888_RGB555_TWO(dst, src); + src += 2; + dst += 2; + RGB888_RGB555_TWO(dst, src); + src += 2; + dst += 2; + } + // Get any leftovers + switch (width & 3) { + case 3: + RGB888_RGB555(dst, src); + ++src; + ++dst; + SDL_FALLTHROUGH; + case 2: + RGB888_RGB555_TWO(dst, src); + src += 2; + dst += 2; + break; + case 1: + RGB888_RGB555(dst, src); + ++src; + ++dst; + break; + } + src += srcskip; + dst += dstskip; + } + } +#endif // USE_DUFFS_LOOP +} + +// Special optimized blit for RGB 8-8-8 --> RGB 5-6-5 +#define RGB888_RGB565(dst, src) \ + { \ + *(Uint16 *)(dst) = (Uint16)((((*src) & 0x00F80000) >> 8) | \ + (((*src) & 0x0000FC00) >> 5) | \ + (((*src) & 0x000000F8) >> 3)); \ + } +#ifndef USE_DUFFS_LOOP +#define RGB888_RGB565_TWO(dst, src) \ + { \ + *(Uint32 *)(dst) = (((((src[HI]) & 0x00F80000) >> 8) | \ + (((src[HI]) & 0x0000FC00) >> 5) | \ + (((src[HI]) & 0x000000F8) >> 3)) \ + << 16) | \ + (((src[LO]) & 0x00F80000) >> 8) | \ + (((src[LO]) & 0x0000FC00) >> 5) | \ + (((src[LO]) & 0x000000F8) >> 3); \ + } +#endif +static void Blit_XRGB8888_RGB565(SDL_BlitInfo *info) +{ +#ifndef USE_DUFFS_LOOP + int c; +#endif + int width, height; + Uint32 *src; + Uint16 *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = (Uint32 *)info->src; + srcskip = info->src_skip / 4; + dst = (Uint16 *)info->dst; + dstskip = info->dst_skip / 2; + +#ifdef USE_DUFFS_LOOP + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + RGB888_RGB565(dst, src); + ++src; + ++dst; + , width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +#else + // Memory align at 4-byte boundary, if necessary + if ((long)dst & 0x03) { + // Don't do anything if width is 0 + if (width == 0) { + return; + } + --width; + + while (height--) { + // Perform copy alignment + RGB888_RGB565(dst, src); + ++src; + ++dst; + + // Copy in 4 pixel chunks + for (c = width / 4; c; --c) { + RGB888_RGB565_TWO(dst, src); + src += 2; + dst += 2; + RGB888_RGB565_TWO(dst, src); + src += 2; + dst += 2; + } + // Get any leftovers + switch (width & 3) { + case 3: + RGB888_RGB565(dst, src); + ++src; + ++dst; + SDL_FALLTHROUGH; + case 2: + RGB888_RGB565_TWO(dst, src); + src += 2; + dst += 2; + break; + case 1: + RGB888_RGB565(dst, src); + ++src; + ++dst; + break; + } + src += srcskip; + dst += dstskip; + } + } else { + while (height--) { + // Copy in 4 pixel chunks + for (c = width / 4; c; --c) { + RGB888_RGB565_TWO(dst, src); + src += 2; + dst += 2; + RGB888_RGB565_TWO(dst, src); + src += 2; + dst += 2; + } + // Get any leftovers + switch (width & 3) { + case 3: + RGB888_RGB565(dst, src); + ++src; + ++dst; + SDL_FALLTHROUGH; + case 2: + RGB888_RGB565_TWO(dst, src); + src += 2; + dst += 2; + break; + case 1: + RGB888_RGB565(dst, src); + ++src; + ++dst; + break; + } + src += srcskip; + dst += dstskip; + } + } +#endif // USE_DUFFS_LOOP +} + +#ifdef SDL_HAVE_BLIT_N_RGB565 + +// Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces +#define RGB565_32(dst, src, map) (map[src[LO] * 2] + map[src[HI] * 2 + 1]) +static void Blit_RGB565_32(SDL_BlitInfo *info, const Uint32 *map) +{ +#ifndef USE_DUFFS_LOOP + int c; +#endif + int width, height; + Uint8 *src; + Uint32 *dst; + int srcskip, dstskip; + + // Set up some basic variables + width = info->dst_w; + height = info->dst_h; + src = info->src; + srcskip = info->src_skip; + dst = (Uint32 *)info->dst; + dstskip = info->dst_skip / 4; + +#ifdef USE_DUFFS_LOOP + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + *dst++ = RGB565_32(dst, src, map); + src += 2; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +#else + while (height--) { + // Copy in 4 pixel chunks + for (c = width / 4; c; --c) { + *dst++ = RGB565_32(dst, src, map); + src += 2; + *dst++ = RGB565_32(dst, src, map); + src += 2; + *dst++ = RGB565_32(dst, src, map); + src += 2; + *dst++ = RGB565_32(dst, src, map); + src += 2; + } + // Get any leftovers + switch (width & 3) { + case 3: + *dst++ = RGB565_32(dst, src, map); + src += 2; + SDL_FALLTHROUGH; + case 2: + *dst++ = RGB565_32(dst, src, map); + src += 2; + SDL_FALLTHROUGH; + case 1: + *dst++ = RGB565_32(dst, src, map); + src += 2; + break; + } + src += srcskip; + dst += dstskip; + } +#endif // USE_DUFFS_LOOP +} + +/* *INDENT-OFF* */ // clang-format off + +// Special optimized blit for RGB 5-6-5 --> ARGB 8-8-8-8 +static const Uint32 RGB565_ARGB8888_LUT[512] = { + 0x00000000, 0xff000000, 0x00000008, 0xff002000, + 0x00000010, 0xff004000, 0x00000018, 0xff006100, + 0x00000020, 0xff008100, 0x00000029, 0xff00a100, + 0x00000031, 0xff00c200, 0x00000039, 0xff00e200, + 0x00000041, 0xff080000, 0x0000004a, 0xff082000, + 0x00000052, 0xff084000, 0x0000005a, 0xff086100, + 0x00000062, 0xff088100, 0x0000006a, 0xff08a100, + 0x00000073, 0xff08c200, 0x0000007b, 0xff08e200, + 0x00000083, 0xff100000, 0x0000008b, 0xff102000, + 0x00000094, 0xff104000, 0x0000009c, 0xff106100, + 0x000000a4, 0xff108100, 0x000000ac, 0xff10a100, + 0x000000b4, 0xff10c200, 0x000000bd, 0xff10e200, + 0x000000c5, 0xff180000, 0x000000cd, 0xff182000, + 0x000000d5, 0xff184000, 0x000000de, 0xff186100, + 0x000000e6, 0xff188100, 0x000000ee, 0xff18a100, + 0x000000f6, 0xff18c200, 0x000000ff, 0xff18e200, + 0x00000400, 0xff200000, 0x00000408, 0xff202000, + 0x00000410, 0xff204000, 0x00000418, 0xff206100, + 0x00000420, 0xff208100, 0x00000429, 0xff20a100, + 0x00000431, 0xff20c200, 0x00000439, 0xff20e200, + 0x00000441, 0xff290000, 0x0000044a, 0xff292000, + 0x00000452, 0xff294000, 0x0000045a, 0xff296100, + 0x00000462, 0xff298100, 0x0000046a, 0xff29a100, + 0x00000473, 0xff29c200, 0x0000047b, 0xff29e200, + 0x00000483, 0xff310000, 0x0000048b, 0xff312000, + 0x00000494, 0xff314000, 0x0000049c, 0xff316100, + 0x000004a4, 0xff318100, 0x000004ac, 0xff31a100, + 0x000004b4, 0xff31c200, 0x000004bd, 0xff31e200, + 0x000004c5, 0xff390000, 0x000004cd, 0xff392000, + 0x000004d5, 0xff394000, 0x000004de, 0xff396100, + 0x000004e6, 0xff398100, 0x000004ee, 0xff39a100, + 0x000004f6, 0xff39c200, 0x000004ff, 0xff39e200, + 0x00000800, 0xff410000, 0x00000808, 0xff412000, + 0x00000810, 0xff414000, 0x00000818, 0xff416100, + 0x00000820, 0xff418100, 0x00000829, 0xff41a100, + 0x00000831, 0xff41c200, 0x00000839, 0xff41e200, + 0x00000841, 0xff4a0000, 0x0000084a, 0xff4a2000, + 0x00000852, 0xff4a4000, 0x0000085a, 0xff4a6100, + 0x00000862, 0xff4a8100, 0x0000086a, 0xff4aa100, + 0x00000873, 0xff4ac200, 0x0000087b, 0xff4ae200, + 0x00000883, 0xff520000, 0x0000088b, 0xff522000, + 0x00000894, 0xff524000, 0x0000089c, 0xff526100, + 0x000008a4, 0xff528100, 0x000008ac, 0xff52a100, + 0x000008b4, 0xff52c200, 0x000008bd, 0xff52e200, + 0x000008c5, 0xff5a0000, 0x000008cd, 0xff5a2000, + 0x000008d5, 0xff5a4000, 0x000008de, 0xff5a6100, + 0x000008e6, 0xff5a8100, 0x000008ee, 0xff5aa100, + 0x000008f6, 0xff5ac200, 0x000008ff, 0xff5ae200, + 0x00000c00, 0xff620000, 0x00000c08, 0xff622000, + 0x00000c10, 0xff624000, 0x00000c18, 0xff626100, + 0x00000c20, 0xff628100, 0x00000c29, 0xff62a100, + 0x00000c31, 0xff62c200, 0x00000c39, 0xff62e200, + 0x00000c41, 0xff6a0000, 0x00000c4a, 0xff6a2000, + 0x00000c52, 0xff6a4000, 0x00000c5a, 0xff6a6100, + 0x00000c62, 0xff6a8100, 0x00000c6a, 0xff6aa100, + 0x00000c73, 0xff6ac200, 0x00000c7b, 0xff6ae200, + 0x00000c83, 0xff730000, 0x00000c8b, 0xff732000, + 0x00000c94, 0xff734000, 0x00000c9c, 0xff736100, + 0x00000ca4, 0xff738100, 0x00000cac, 0xff73a100, + 0x00000cb4, 0xff73c200, 0x00000cbd, 0xff73e200, + 0x00000cc5, 0xff7b0000, 0x00000ccd, 0xff7b2000, + 0x00000cd5, 0xff7b4000, 0x00000cde, 0xff7b6100, + 0x00000ce6, 0xff7b8100, 0x00000cee, 0xff7ba100, + 0x00000cf6, 0xff7bc200, 0x00000cff, 0xff7be200, + 0x00001000, 0xff830000, 0x00001008, 0xff832000, + 0x00001010, 0xff834000, 0x00001018, 0xff836100, + 0x00001020, 0xff838100, 0x00001029, 0xff83a100, + 0x00001031, 0xff83c200, 0x00001039, 0xff83e200, + 0x00001041, 0xff8b0000, 0x0000104a, 0xff8b2000, + 0x00001052, 0xff8b4000, 0x0000105a, 0xff8b6100, + 0x00001062, 0xff8b8100, 0x0000106a, 0xff8ba100, + 0x00001073, 0xff8bc200, 0x0000107b, 0xff8be200, + 0x00001083, 0xff940000, 0x0000108b, 0xff942000, + 0x00001094, 0xff944000, 0x0000109c, 0xff946100, + 0x000010a4, 0xff948100, 0x000010ac, 0xff94a100, + 0x000010b4, 0xff94c200, 0x000010bd, 0xff94e200, + 0x000010c5, 0xff9c0000, 0x000010cd, 0xff9c2000, + 0x000010d5, 0xff9c4000, 0x000010de, 0xff9c6100, + 0x000010e6, 0xff9c8100, 0x000010ee, 0xff9ca100, + 0x000010f6, 0xff9cc200, 0x000010ff, 0xff9ce200, + 0x00001400, 0xffa40000, 0x00001408, 0xffa42000, + 0x00001410, 0xffa44000, 0x00001418, 0xffa46100, + 0x00001420, 0xffa48100, 0x00001429, 0xffa4a100, + 0x00001431, 0xffa4c200, 0x00001439, 0xffa4e200, + 0x00001441, 0xffac0000, 0x0000144a, 0xffac2000, + 0x00001452, 0xffac4000, 0x0000145a, 0xffac6100, + 0x00001462, 0xffac8100, 0x0000146a, 0xffaca100, + 0x00001473, 0xffacc200, 0x0000147b, 0xfface200, + 0x00001483, 0xffb40000, 0x0000148b, 0xffb42000, + 0x00001494, 0xffb44000, 0x0000149c, 0xffb46100, + 0x000014a4, 0xffb48100, 0x000014ac, 0xffb4a100, + 0x000014b4, 0xffb4c200, 0x000014bd, 0xffb4e200, + 0x000014c5, 0xffbd0000, 0x000014cd, 0xffbd2000, + 0x000014d5, 0xffbd4000, 0x000014de, 0xffbd6100, + 0x000014e6, 0xffbd8100, 0x000014ee, 0xffbda100, + 0x000014f6, 0xffbdc200, 0x000014ff, 0xffbde200, + 0x00001800, 0xffc50000, 0x00001808, 0xffc52000, + 0x00001810, 0xffc54000, 0x00001818, 0xffc56100, + 0x00001820, 0xffc58100, 0x00001829, 0xffc5a100, + 0x00001831, 0xffc5c200, 0x00001839, 0xffc5e200, + 0x00001841, 0xffcd0000, 0x0000184a, 0xffcd2000, + 0x00001852, 0xffcd4000, 0x0000185a, 0xffcd6100, + 0x00001862, 0xffcd8100, 0x0000186a, 0xffcda100, + 0x00001873, 0xffcdc200, 0x0000187b, 0xffcde200, + 0x00001883, 0xffd50000, 0x0000188b, 0xffd52000, + 0x00001894, 0xffd54000, 0x0000189c, 0xffd56100, + 0x000018a4, 0xffd58100, 0x000018ac, 0xffd5a100, + 0x000018b4, 0xffd5c200, 0x000018bd, 0xffd5e200, + 0x000018c5, 0xffde0000, 0x000018cd, 0xffde2000, + 0x000018d5, 0xffde4000, 0x000018de, 0xffde6100, + 0x000018e6, 0xffde8100, 0x000018ee, 0xffdea100, + 0x000018f6, 0xffdec200, 0x000018ff, 0xffdee200, + 0x00001c00, 0xffe60000, 0x00001c08, 0xffe62000, + 0x00001c10, 0xffe64000, 0x00001c18, 0xffe66100, + 0x00001c20, 0xffe68100, 0x00001c29, 0xffe6a100, + 0x00001c31, 0xffe6c200, 0x00001c39, 0xffe6e200, + 0x00001c41, 0xffee0000, 0x00001c4a, 0xffee2000, + 0x00001c52, 0xffee4000, 0x00001c5a, 0xffee6100, + 0x00001c62, 0xffee8100, 0x00001c6a, 0xffeea100, + 0x00001c73, 0xffeec200, 0x00001c7b, 0xffeee200, + 0x00001c83, 0xfff60000, 0x00001c8b, 0xfff62000, + 0x00001c94, 0xfff64000, 0x00001c9c, 0xfff66100, + 0x00001ca4, 0xfff68100, 0x00001cac, 0xfff6a100, + 0x00001cb4, 0xfff6c200, 0x00001cbd, 0xfff6e200, + 0x00001cc5, 0xffff0000, 0x00001ccd, 0xffff2000, + 0x00001cd5, 0xffff4000, 0x00001cde, 0xffff6100, + 0x00001ce6, 0xffff8100, 0x00001cee, 0xffffa100, + 0x00001cf6, 0xffffc200, 0x00001cff, 0xffffe200 +}; + +static void Blit_RGB565_ARGB8888(SDL_BlitInfo * info) +{ + Blit_RGB565_32(info, RGB565_ARGB8888_LUT); +} + +// Special optimized blit for RGB 5-6-5 --> ABGR 8-8-8-8 +static const Uint32 RGB565_ABGR8888_LUT[512] = { + 0xff000000, 0x00000000, 0xff080000, 0x00002000, + 0xff100000, 0x00004000, 0xff180000, 0x00006100, + 0xff200000, 0x00008100, 0xff290000, 0x0000a100, + 0xff310000, 0x0000c200, 0xff390000, 0x0000e200, + 0xff410000, 0x00000008, 0xff4a0000, 0x00002008, + 0xff520000, 0x00004008, 0xff5a0000, 0x00006108, + 0xff620000, 0x00008108, 0xff6a0000, 0x0000a108, + 0xff730000, 0x0000c208, 0xff7b0000, 0x0000e208, + 0xff830000, 0x00000010, 0xff8b0000, 0x00002010, + 0xff940000, 0x00004010, 0xff9c0000, 0x00006110, + 0xffa40000, 0x00008110, 0xffac0000, 0x0000a110, + 0xffb40000, 0x0000c210, 0xffbd0000, 0x0000e210, + 0xffc50000, 0x00000018, 0xffcd0000, 0x00002018, + 0xffd50000, 0x00004018, 0xffde0000, 0x00006118, + 0xffe60000, 0x00008118, 0xffee0000, 0x0000a118, + 0xfff60000, 0x0000c218, 0xffff0000, 0x0000e218, + 0xff000400, 0x00000020, 0xff080400, 0x00002020, + 0xff100400, 0x00004020, 0xff180400, 0x00006120, + 0xff200400, 0x00008120, 0xff290400, 0x0000a120, + 0xff310400, 0x0000c220, 0xff390400, 0x0000e220, + 0xff410400, 0x00000029, 0xff4a0400, 0x00002029, + 0xff520400, 0x00004029, 0xff5a0400, 0x00006129, + 0xff620400, 0x00008129, 0xff6a0400, 0x0000a129, + 0xff730400, 0x0000c229, 0xff7b0400, 0x0000e229, + 0xff830400, 0x00000031, 0xff8b0400, 0x00002031, + 0xff940400, 0x00004031, 0xff9c0400, 0x00006131, + 0xffa40400, 0x00008131, 0xffac0400, 0x0000a131, + 0xffb40400, 0x0000c231, 0xffbd0400, 0x0000e231, + 0xffc50400, 0x00000039, 0xffcd0400, 0x00002039, + 0xffd50400, 0x00004039, 0xffde0400, 0x00006139, + 0xffe60400, 0x00008139, 0xffee0400, 0x0000a139, + 0xfff60400, 0x0000c239, 0xffff0400, 0x0000e239, + 0xff000800, 0x00000041, 0xff080800, 0x00002041, + 0xff100800, 0x00004041, 0xff180800, 0x00006141, + 0xff200800, 0x00008141, 0xff290800, 0x0000a141, + 0xff310800, 0x0000c241, 0xff390800, 0x0000e241, + 0xff410800, 0x0000004a, 0xff4a0800, 0x0000204a, + 0xff520800, 0x0000404a, 0xff5a0800, 0x0000614a, + 0xff620800, 0x0000814a, 0xff6a0800, 0x0000a14a, + 0xff730800, 0x0000c24a, 0xff7b0800, 0x0000e24a, + 0xff830800, 0x00000052, 0xff8b0800, 0x00002052, + 0xff940800, 0x00004052, 0xff9c0800, 0x00006152, + 0xffa40800, 0x00008152, 0xffac0800, 0x0000a152, + 0xffb40800, 0x0000c252, 0xffbd0800, 0x0000e252, + 0xffc50800, 0x0000005a, 0xffcd0800, 0x0000205a, + 0xffd50800, 0x0000405a, 0xffde0800, 0x0000615a, + 0xffe60800, 0x0000815a, 0xffee0800, 0x0000a15a, + 0xfff60800, 0x0000c25a, 0xffff0800, 0x0000e25a, + 0xff000c00, 0x00000062, 0xff080c00, 0x00002062, + 0xff100c00, 0x00004062, 0xff180c00, 0x00006162, + 0xff200c00, 0x00008162, 0xff290c00, 0x0000a162, + 0xff310c00, 0x0000c262, 0xff390c00, 0x0000e262, + 0xff410c00, 0x0000006a, 0xff4a0c00, 0x0000206a, + 0xff520c00, 0x0000406a, 0xff5a0c00, 0x0000616a, + 0xff620c00, 0x0000816a, 0xff6a0c00, 0x0000a16a, + 0xff730c00, 0x0000c26a, 0xff7b0c00, 0x0000e26a, + 0xff830c00, 0x00000073, 0xff8b0c00, 0x00002073, + 0xff940c00, 0x00004073, 0xff9c0c00, 0x00006173, + 0xffa40c00, 0x00008173, 0xffac0c00, 0x0000a173, + 0xffb40c00, 0x0000c273, 0xffbd0c00, 0x0000e273, + 0xffc50c00, 0x0000007b, 0xffcd0c00, 0x0000207b, + 0xffd50c00, 0x0000407b, 0xffde0c00, 0x0000617b, + 0xffe60c00, 0x0000817b, 0xffee0c00, 0x0000a17b, + 0xfff60c00, 0x0000c27b, 0xffff0c00, 0x0000e27b, + 0xff001000, 0x00000083, 0xff081000, 0x00002083, + 0xff101000, 0x00004083, 0xff181000, 0x00006183, + 0xff201000, 0x00008183, 0xff291000, 0x0000a183, + 0xff311000, 0x0000c283, 0xff391000, 0x0000e283, + 0xff411000, 0x0000008b, 0xff4a1000, 0x0000208b, + 0xff521000, 0x0000408b, 0xff5a1000, 0x0000618b, + 0xff621000, 0x0000818b, 0xff6a1000, 0x0000a18b, + 0xff731000, 0x0000c28b, 0xff7b1000, 0x0000e28b, + 0xff831000, 0x00000094, 0xff8b1000, 0x00002094, + 0xff941000, 0x00004094, 0xff9c1000, 0x00006194, + 0xffa41000, 0x00008194, 0xffac1000, 0x0000a194, + 0xffb41000, 0x0000c294, 0xffbd1000, 0x0000e294, + 0xffc51000, 0x0000009c, 0xffcd1000, 0x0000209c, + 0xffd51000, 0x0000409c, 0xffde1000, 0x0000619c, + 0xffe61000, 0x0000819c, 0xffee1000, 0x0000a19c, + 0xfff61000, 0x0000c29c, 0xffff1000, 0x0000e29c, + 0xff001400, 0x000000a4, 0xff081400, 0x000020a4, + 0xff101400, 0x000040a4, 0xff181400, 0x000061a4, + 0xff201400, 0x000081a4, 0xff291400, 0x0000a1a4, + 0xff311400, 0x0000c2a4, 0xff391400, 0x0000e2a4, + 0xff411400, 0x000000ac, 0xff4a1400, 0x000020ac, + 0xff521400, 0x000040ac, 0xff5a1400, 0x000061ac, + 0xff621400, 0x000081ac, 0xff6a1400, 0x0000a1ac, + 0xff731400, 0x0000c2ac, 0xff7b1400, 0x0000e2ac, + 0xff831400, 0x000000b4, 0xff8b1400, 0x000020b4, + 0xff941400, 0x000040b4, 0xff9c1400, 0x000061b4, + 0xffa41400, 0x000081b4, 0xffac1400, 0x0000a1b4, + 0xffb41400, 0x0000c2b4, 0xffbd1400, 0x0000e2b4, + 0xffc51400, 0x000000bd, 0xffcd1400, 0x000020bd, + 0xffd51400, 0x000040bd, 0xffde1400, 0x000061bd, + 0xffe61400, 0x000081bd, 0xffee1400, 0x0000a1bd, + 0xfff61400, 0x0000c2bd, 0xffff1400, 0x0000e2bd, + 0xff001800, 0x000000c5, 0xff081800, 0x000020c5, + 0xff101800, 0x000040c5, 0xff181800, 0x000061c5, + 0xff201800, 0x000081c5, 0xff291800, 0x0000a1c5, + 0xff311800, 0x0000c2c5, 0xff391800, 0x0000e2c5, + 0xff411800, 0x000000cd, 0xff4a1800, 0x000020cd, + 0xff521800, 0x000040cd, 0xff5a1800, 0x000061cd, + 0xff621800, 0x000081cd, 0xff6a1800, 0x0000a1cd, + 0xff731800, 0x0000c2cd, 0xff7b1800, 0x0000e2cd, + 0xff831800, 0x000000d5, 0xff8b1800, 0x000020d5, + 0xff941800, 0x000040d5, 0xff9c1800, 0x000061d5, + 0xffa41800, 0x000081d5, 0xffac1800, 0x0000a1d5, + 0xffb41800, 0x0000c2d5, 0xffbd1800, 0x0000e2d5, + 0xffc51800, 0x000000de, 0xffcd1800, 0x000020de, + 0xffd51800, 0x000040de, 0xffde1800, 0x000061de, + 0xffe61800, 0x000081de, 0xffee1800, 0x0000a1de, + 0xfff61800, 0x0000c2de, 0xffff1800, 0x0000e2de, + 0xff001c00, 0x000000e6, 0xff081c00, 0x000020e6, + 0xff101c00, 0x000040e6, 0xff181c00, 0x000061e6, + 0xff201c00, 0x000081e6, 0xff291c00, 0x0000a1e6, + 0xff311c00, 0x0000c2e6, 0xff391c00, 0x0000e2e6, + 0xff411c00, 0x000000ee, 0xff4a1c00, 0x000020ee, + 0xff521c00, 0x000040ee, 0xff5a1c00, 0x000061ee, + 0xff621c00, 0x000081ee, 0xff6a1c00, 0x0000a1ee, + 0xff731c00, 0x0000c2ee, 0xff7b1c00, 0x0000e2ee, + 0xff831c00, 0x000000f6, 0xff8b1c00, 0x000020f6, + 0xff941c00, 0x000040f6, 0xff9c1c00, 0x000061f6, + 0xffa41c00, 0x000081f6, 0xffac1c00, 0x0000a1f6, + 0xffb41c00, 0x0000c2f6, 0xffbd1c00, 0x0000e2f6, + 0xffc51c00, 0x000000ff, 0xffcd1c00, 0x000020ff, + 0xffd51c00, 0x000040ff, 0xffde1c00, 0x000061ff, + 0xffe61c00, 0x000081ff, 0xffee1c00, 0x0000a1ff, + 0xfff61c00, 0x0000c2ff, 0xffff1c00, 0x0000e2ff +}; + +static void Blit_RGB565_ABGR8888(SDL_BlitInfo * info) +{ + Blit_RGB565_32(info, RGB565_ABGR8888_LUT); +} + +// Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 +static const Uint32 RGB565_RGBA8888_LUT[512] = { + 0x000000ff, 0x00000000, 0x000008ff, 0x00200000, + 0x000010ff, 0x00400000, 0x000018ff, 0x00610000, + 0x000020ff, 0x00810000, 0x000029ff, 0x00a10000, + 0x000031ff, 0x00c20000, 0x000039ff, 0x00e20000, + 0x000041ff, 0x08000000, 0x00004aff, 0x08200000, + 0x000052ff, 0x08400000, 0x00005aff, 0x08610000, + 0x000062ff, 0x08810000, 0x00006aff, 0x08a10000, + 0x000073ff, 0x08c20000, 0x00007bff, 0x08e20000, + 0x000083ff, 0x10000000, 0x00008bff, 0x10200000, + 0x000094ff, 0x10400000, 0x00009cff, 0x10610000, + 0x0000a4ff, 0x10810000, 0x0000acff, 0x10a10000, + 0x0000b4ff, 0x10c20000, 0x0000bdff, 0x10e20000, + 0x0000c5ff, 0x18000000, 0x0000cdff, 0x18200000, + 0x0000d5ff, 0x18400000, 0x0000deff, 0x18610000, + 0x0000e6ff, 0x18810000, 0x0000eeff, 0x18a10000, + 0x0000f6ff, 0x18c20000, 0x0000ffff, 0x18e20000, + 0x000400ff, 0x20000000, 0x000408ff, 0x20200000, + 0x000410ff, 0x20400000, 0x000418ff, 0x20610000, + 0x000420ff, 0x20810000, 0x000429ff, 0x20a10000, + 0x000431ff, 0x20c20000, 0x000439ff, 0x20e20000, + 0x000441ff, 0x29000000, 0x00044aff, 0x29200000, + 0x000452ff, 0x29400000, 0x00045aff, 0x29610000, + 0x000462ff, 0x29810000, 0x00046aff, 0x29a10000, + 0x000473ff, 0x29c20000, 0x00047bff, 0x29e20000, + 0x000483ff, 0x31000000, 0x00048bff, 0x31200000, + 0x000494ff, 0x31400000, 0x00049cff, 0x31610000, + 0x0004a4ff, 0x31810000, 0x0004acff, 0x31a10000, + 0x0004b4ff, 0x31c20000, 0x0004bdff, 0x31e20000, + 0x0004c5ff, 0x39000000, 0x0004cdff, 0x39200000, + 0x0004d5ff, 0x39400000, 0x0004deff, 0x39610000, + 0x0004e6ff, 0x39810000, 0x0004eeff, 0x39a10000, + 0x0004f6ff, 0x39c20000, 0x0004ffff, 0x39e20000, + 0x000800ff, 0x41000000, 0x000808ff, 0x41200000, + 0x000810ff, 0x41400000, 0x000818ff, 0x41610000, + 0x000820ff, 0x41810000, 0x000829ff, 0x41a10000, + 0x000831ff, 0x41c20000, 0x000839ff, 0x41e20000, + 0x000841ff, 0x4a000000, 0x00084aff, 0x4a200000, + 0x000852ff, 0x4a400000, 0x00085aff, 0x4a610000, + 0x000862ff, 0x4a810000, 0x00086aff, 0x4aa10000, + 0x000873ff, 0x4ac20000, 0x00087bff, 0x4ae20000, + 0x000883ff, 0x52000000, 0x00088bff, 0x52200000, + 0x000894ff, 0x52400000, 0x00089cff, 0x52610000, + 0x0008a4ff, 0x52810000, 0x0008acff, 0x52a10000, + 0x0008b4ff, 0x52c20000, 0x0008bdff, 0x52e20000, + 0x0008c5ff, 0x5a000000, 0x0008cdff, 0x5a200000, + 0x0008d5ff, 0x5a400000, 0x0008deff, 0x5a610000, + 0x0008e6ff, 0x5a810000, 0x0008eeff, 0x5aa10000, + 0x0008f6ff, 0x5ac20000, 0x0008ffff, 0x5ae20000, + 0x000c00ff, 0x62000000, 0x000c08ff, 0x62200000, + 0x000c10ff, 0x62400000, 0x000c18ff, 0x62610000, + 0x000c20ff, 0x62810000, 0x000c29ff, 0x62a10000, + 0x000c31ff, 0x62c20000, 0x000c39ff, 0x62e20000, + 0x000c41ff, 0x6a000000, 0x000c4aff, 0x6a200000, + 0x000c52ff, 0x6a400000, 0x000c5aff, 0x6a610000, + 0x000c62ff, 0x6a810000, 0x000c6aff, 0x6aa10000, + 0x000c73ff, 0x6ac20000, 0x000c7bff, 0x6ae20000, + 0x000c83ff, 0x73000000, 0x000c8bff, 0x73200000, + 0x000c94ff, 0x73400000, 0x000c9cff, 0x73610000, + 0x000ca4ff, 0x73810000, 0x000cacff, 0x73a10000, + 0x000cb4ff, 0x73c20000, 0x000cbdff, 0x73e20000, + 0x000cc5ff, 0x7b000000, 0x000ccdff, 0x7b200000, + 0x000cd5ff, 0x7b400000, 0x000cdeff, 0x7b610000, + 0x000ce6ff, 0x7b810000, 0x000ceeff, 0x7ba10000, + 0x000cf6ff, 0x7bc20000, 0x000cffff, 0x7be20000, + 0x001000ff, 0x83000000, 0x001008ff, 0x83200000, + 0x001010ff, 0x83400000, 0x001018ff, 0x83610000, + 0x001020ff, 0x83810000, 0x001029ff, 0x83a10000, + 0x001031ff, 0x83c20000, 0x001039ff, 0x83e20000, + 0x001041ff, 0x8b000000, 0x00104aff, 0x8b200000, + 0x001052ff, 0x8b400000, 0x00105aff, 0x8b610000, + 0x001062ff, 0x8b810000, 0x00106aff, 0x8ba10000, + 0x001073ff, 0x8bc20000, 0x00107bff, 0x8be20000, + 0x001083ff, 0x94000000, 0x00108bff, 0x94200000, + 0x001094ff, 0x94400000, 0x00109cff, 0x94610000, + 0x0010a4ff, 0x94810000, 0x0010acff, 0x94a10000, + 0x0010b4ff, 0x94c20000, 0x0010bdff, 0x94e20000, + 0x0010c5ff, 0x9c000000, 0x0010cdff, 0x9c200000, + 0x0010d5ff, 0x9c400000, 0x0010deff, 0x9c610000, + 0x0010e6ff, 0x9c810000, 0x0010eeff, 0x9ca10000, + 0x0010f6ff, 0x9cc20000, 0x0010ffff, 0x9ce20000, + 0x001400ff, 0xa4000000, 0x001408ff, 0xa4200000, + 0x001410ff, 0xa4400000, 0x001418ff, 0xa4610000, + 0x001420ff, 0xa4810000, 0x001429ff, 0xa4a10000, + 0x001431ff, 0xa4c20000, 0x001439ff, 0xa4e20000, + 0x001441ff, 0xac000000, 0x00144aff, 0xac200000, + 0x001452ff, 0xac400000, 0x00145aff, 0xac610000, + 0x001462ff, 0xac810000, 0x00146aff, 0xaca10000, + 0x001473ff, 0xacc20000, 0x00147bff, 0xace20000, + 0x001483ff, 0xb4000000, 0x00148bff, 0xb4200000, + 0x001494ff, 0xb4400000, 0x00149cff, 0xb4610000, + 0x0014a4ff, 0xb4810000, 0x0014acff, 0xb4a10000, + 0x0014b4ff, 0xb4c20000, 0x0014bdff, 0xb4e20000, + 0x0014c5ff, 0xbd000000, 0x0014cdff, 0xbd200000, + 0x0014d5ff, 0xbd400000, 0x0014deff, 0xbd610000, + 0x0014e6ff, 0xbd810000, 0x0014eeff, 0xbda10000, + 0x0014f6ff, 0xbdc20000, 0x0014ffff, 0xbde20000, + 0x001800ff, 0xc5000000, 0x001808ff, 0xc5200000, + 0x001810ff, 0xc5400000, 0x001818ff, 0xc5610000, + 0x001820ff, 0xc5810000, 0x001829ff, 0xc5a10000, + 0x001831ff, 0xc5c20000, 0x001839ff, 0xc5e20000, + 0x001841ff, 0xcd000000, 0x00184aff, 0xcd200000, + 0x001852ff, 0xcd400000, 0x00185aff, 0xcd610000, + 0x001862ff, 0xcd810000, 0x00186aff, 0xcda10000, + 0x001873ff, 0xcdc20000, 0x00187bff, 0xcde20000, + 0x001883ff, 0xd5000000, 0x00188bff, 0xd5200000, + 0x001894ff, 0xd5400000, 0x00189cff, 0xd5610000, + 0x0018a4ff, 0xd5810000, 0x0018acff, 0xd5a10000, + 0x0018b4ff, 0xd5c20000, 0x0018bdff, 0xd5e20000, + 0x0018c5ff, 0xde000000, 0x0018cdff, 0xde200000, + 0x0018d5ff, 0xde400000, 0x0018deff, 0xde610000, + 0x0018e6ff, 0xde810000, 0x0018eeff, 0xdea10000, + 0x0018f6ff, 0xdec20000, 0x0018ffff, 0xdee20000, + 0x001c00ff, 0xe6000000, 0x001c08ff, 0xe6200000, + 0x001c10ff, 0xe6400000, 0x001c18ff, 0xe6610000, + 0x001c20ff, 0xe6810000, 0x001c29ff, 0xe6a10000, + 0x001c31ff, 0xe6c20000, 0x001c39ff, 0xe6e20000, + 0x001c41ff, 0xee000000, 0x001c4aff, 0xee200000, + 0x001c52ff, 0xee400000, 0x001c5aff, 0xee610000, + 0x001c62ff, 0xee810000, 0x001c6aff, 0xeea10000, + 0x001c73ff, 0xeec20000, 0x001c7bff, 0xeee20000, + 0x001c83ff, 0xf6000000, 0x001c8bff, 0xf6200000, + 0x001c94ff, 0xf6400000, 0x001c9cff, 0xf6610000, + 0x001ca4ff, 0xf6810000, 0x001cacff, 0xf6a10000, + 0x001cb4ff, 0xf6c20000, 0x001cbdff, 0xf6e20000, + 0x001cc5ff, 0xff000000, 0x001ccdff, 0xff200000, + 0x001cd5ff, 0xff400000, 0x001cdeff, 0xff610000, + 0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000, + 0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000, +}; + +static void Blit_RGB565_RGBA8888(SDL_BlitInfo * info) +{ + Blit_RGB565_32(info, RGB565_RGBA8888_LUT); +} + +// Special optimized blit for RGB 5-6-5 --> BGRA 8-8-8-8 +static const Uint32 RGB565_BGRA8888_LUT[512] = { + 0x00000000, 0x000000ff, 0x08000000, 0x002000ff, + 0x10000000, 0x004000ff, 0x18000000, 0x006100ff, + 0x20000000, 0x008100ff, 0x29000000, 0x00a100ff, + 0x31000000, 0x00c200ff, 0x39000000, 0x00e200ff, + 0x41000000, 0x000008ff, 0x4a000000, 0x002008ff, + 0x52000000, 0x004008ff, 0x5a000000, 0x006108ff, + 0x62000000, 0x008108ff, 0x6a000000, 0x00a108ff, + 0x73000000, 0x00c208ff, 0x7b000000, 0x00e208ff, + 0x83000000, 0x000010ff, 0x8b000000, 0x002010ff, + 0x94000000, 0x004010ff, 0x9c000000, 0x006110ff, + 0xa4000000, 0x008110ff, 0xac000000, 0x00a110ff, + 0xb4000000, 0x00c210ff, 0xbd000000, 0x00e210ff, + 0xc5000000, 0x000018ff, 0xcd000000, 0x002018ff, + 0xd5000000, 0x004018ff, 0xde000000, 0x006118ff, + 0xe6000000, 0x008118ff, 0xee000000, 0x00a118ff, + 0xf6000000, 0x00c218ff, 0xff000000, 0x00e218ff, + 0x00040000, 0x000020ff, 0x08040000, 0x002020ff, + 0x10040000, 0x004020ff, 0x18040000, 0x006120ff, + 0x20040000, 0x008120ff, 0x29040000, 0x00a120ff, + 0x31040000, 0x00c220ff, 0x39040000, 0x00e220ff, + 0x41040000, 0x000029ff, 0x4a040000, 0x002029ff, + 0x52040000, 0x004029ff, 0x5a040000, 0x006129ff, + 0x62040000, 0x008129ff, 0x6a040000, 0x00a129ff, + 0x73040000, 0x00c229ff, 0x7b040000, 0x00e229ff, + 0x83040000, 0x000031ff, 0x8b040000, 0x002031ff, + 0x94040000, 0x004031ff, 0x9c040000, 0x006131ff, + 0xa4040000, 0x008131ff, 0xac040000, 0x00a131ff, + 0xb4040000, 0x00c231ff, 0xbd040000, 0x00e231ff, + 0xc5040000, 0x000039ff, 0xcd040000, 0x002039ff, + 0xd5040000, 0x004039ff, 0xde040000, 0x006139ff, + 0xe6040000, 0x008139ff, 0xee040000, 0x00a139ff, + 0xf6040000, 0x00c239ff, 0xff040000, 0x00e239ff, + 0x00080000, 0x000041ff, 0x08080000, 0x002041ff, + 0x10080000, 0x004041ff, 0x18080000, 0x006141ff, + 0x20080000, 0x008141ff, 0x29080000, 0x00a141ff, + 0x31080000, 0x00c241ff, 0x39080000, 0x00e241ff, + 0x41080000, 0x00004aff, 0x4a080000, 0x00204aff, + 0x52080000, 0x00404aff, 0x5a080000, 0x00614aff, + 0x62080000, 0x00814aff, 0x6a080000, 0x00a14aff, + 0x73080000, 0x00c24aff, 0x7b080000, 0x00e24aff, + 0x83080000, 0x000052ff, 0x8b080000, 0x002052ff, + 0x94080000, 0x004052ff, 0x9c080000, 0x006152ff, + 0xa4080000, 0x008152ff, 0xac080000, 0x00a152ff, + 0xb4080000, 0x00c252ff, 0xbd080000, 0x00e252ff, + 0xc5080000, 0x00005aff, 0xcd080000, 0x00205aff, + 0xd5080000, 0x00405aff, 0xde080000, 0x00615aff, + 0xe6080000, 0x00815aff, 0xee080000, 0x00a15aff, + 0xf6080000, 0x00c25aff, 0xff080000, 0x00e25aff, + 0x000c0000, 0x000062ff, 0x080c0000, 0x002062ff, + 0x100c0000, 0x004062ff, 0x180c0000, 0x006162ff, + 0x200c0000, 0x008162ff, 0x290c0000, 0x00a162ff, + 0x310c0000, 0x00c262ff, 0x390c0000, 0x00e262ff, + 0x410c0000, 0x00006aff, 0x4a0c0000, 0x00206aff, + 0x520c0000, 0x00406aff, 0x5a0c0000, 0x00616aff, + 0x620c0000, 0x00816aff, 0x6a0c0000, 0x00a16aff, + 0x730c0000, 0x00c26aff, 0x7b0c0000, 0x00e26aff, + 0x830c0000, 0x000073ff, 0x8b0c0000, 0x002073ff, + 0x940c0000, 0x004073ff, 0x9c0c0000, 0x006173ff, + 0xa40c0000, 0x008173ff, 0xac0c0000, 0x00a173ff, + 0xb40c0000, 0x00c273ff, 0xbd0c0000, 0x00e273ff, + 0xc50c0000, 0x00007bff, 0xcd0c0000, 0x00207bff, + 0xd50c0000, 0x00407bff, 0xde0c0000, 0x00617bff, + 0xe60c0000, 0x00817bff, 0xee0c0000, 0x00a17bff, + 0xf60c0000, 0x00c27bff, 0xff0c0000, 0x00e27bff, + 0x00100000, 0x000083ff, 0x08100000, 0x002083ff, + 0x10100000, 0x004083ff, 0x18100000, 0x006183ff, + 0x20100000, 0x008183ff, 0x29100000, 0x00a183ff, + 0x31100000, 0x00c283ff, 0x39100000, 0x00e283ff, + 0x41100000, 0x00008bff, 0x4a100000, 0x00208bff, + 0x52100000, 0x00408bff, 0x5a100000, 0x00618bff, + 0x62100000, 0x00818bff, 0x6a100000, 0x00a18bff, + 0x73100000, 0x00c28bff, 0x7b100000, 0x00e28bff, + 0x83100000, 0x000094ff, 0x8b100000, 0x002094ff, + 0x94100000, 0x004094ff, 0x9c100000, 0x006194ff, + 0xa4100000, 0x008194ff, 0xac100000, 0x00a194ff, + 0xb4100000, 0x00c294ff, 0xbd100000, 0x00e294ff, + 0xc5100000, 0x00009cff, 0xcd100000, 0x00209cff, + 0xd5100000, 0x00409cff, 0xde100000, 0x00619cff, + 0xe6100000, 0x00819cff, 0xee100000, 0x00a19cff, + 0xf6100000, 0x00c29cff, 0xff100000, 0x00e29cff, + 0x00140000, 0x0000a4ff, 0x08140000, 0x0020a4ff, + 0x10140000, 0x0040a4ff, 0x18140000, 0x0061a4ff, + 0x20140000, 0x0081a4ff, 0x29140000, 0x00a1a4ff, + 0x31140000, 0x00c2a4ff, 0x39140000, 0x00e2a4ff, + 0x41140000, 0x0000acff, 0x4a140000, 0x0020acff, + 0x52140000, 0x0040acff, 0x5a140000, 0x0061acff, + 0x62140000, 0x0081acff, 0x6a140000, 0x00a1acff, + 0x73140000, 0x00c2acff, 0x7b140000, 0x00e2acff, + 0x83140000, 0x0000b4ff, 0x8b140000, 0x0020b4ff, + 0x94140000, 0x0040b4ff, 0x9c140000, 0x0061b4ff, + 0xa4140000, 0x0081b4ff, 0xac140000, 0x00a1b4ff, + 0xb4140000, 0x00c2b4ff, 0xbd140000, 0x00e2b4ff, + 0xc5140000, 0x0000bdff, 0xcd140000, 0x0020bdff, + 0xd5140000, 0x0040bdff, 0xde140000, 0x0061bdff, + 0xe6140000, 0x0081bdff, 0xee140000, 0x00a1bdff, + 0xf6140000, 0x00c2bdff, 0xff140000, 0x00e2bdff, + 0x00180000, 0x0000c5ff, 0x08180000, 0x0020c5ff, + 0x10180000, 0x0040c5ff, 0x18180000, 0x0061c5ff, + 0x20180000, 0x0081c5ff, 0x29180000, 0x00a1c5ff, + 0x31180000, 0x00c2c5ff, 0x39180000, 0x00e2c5ff, + 0x41180000, 0x0000cdff, 0x4a180000, 0x0020cdff, + 0x52180000, 0x0040cdff, 0x5a180000, 0x0061cdff, + 0x62180000, 0x0081cdff, 0x6a180000, 0x00a1cdff, + 0x73180000, 0x00c2cdff, 0x7b180000, 0x00e2cdff, + 0x83180000, 0x0000d5ff, 0x8b180000, 0x0020d5ff, + 0x94180000, 0x0040d5ff, 0x9c180000, 0x0061d5ff, + 0xa4180000, 0x0081d5ff, 0xac180000, 0x00a1d5ff, + 0xb4180000, 0x00c2d5ff, 0xbd180000, 0x00e2d5ff, + 0xc5180000, 0x0000deff, 0xcd180000, 0x0020deff, + 0xd5180000, 0x0040deff, 0xde180000, 0x0061deff, + 0xe6180000, 0x0081deff, 0xee180000, 0x00a1deff, + 0xf6180000, 0x00c2deff, 0xff180000, 0x00e2deff, + 0x001c0000, 0x0000e6ff, 0x081c0000, 0x0020e6ff, + 0x101c0000, 0x0040e6ff, 0x181c0000, 0x0061e6ff, + 0x201c0000, 0x0081e6ff, 0x291c0000, 0x00a1e6ff, + 0x311c0000, 0x00c2e6ff, 0x391c0000, 0x00e2e6ff, + 0x411c0000, 0x0000eeff, 0x4a1c0000, 0x0020eeff, + 0x521c0000, 0x0040eeff, 0x5a1c0000, 0x0061eeff, + 0x621c0000, 0x0081eeff, 0x6a1c0000, 0x00a1eeff, + 0x731c0000, 0x00c2eeff, 0x7b1c0000, 0x00e2eeff, + 0x831c0000, 0x0000f6ff, 0x8b1c0000, 0x0020f6ff, + 0x941c0000, 0x0040f6ff, 0x9c1c0000, 0x0061f6ff, + 0xa41c0000, 0x0081f6ff, 0xac1c0000, 0x00a1f6ff, + 0xb41c0000, 0x00c2f6ff, 0xbd1c0000, 0x00e2f6ff, + 0xc51c0000, 0x0000ffff, 0xcd1c0000, 0x0020ffff, + 0xd51c0000, 0x0040ffff, 0xde1c0000, 0x0061ffff, + 0xe61c0000, 0x0081ffff, 0xee1c0000, 0x00a1ffff, + 0xf61c0000, 0x00c2ffff, 0xff1c0000, 0x00e2ffff +}; + +static void Blit_RGB565_BGRA8888(SDL_BlitInfo * info) +{ + Blit_RGB565_32(info, RGB565_BGRA8888_LUT); +} + +/* *INDENT-ON* */ // clang-format on + +#endif // SDL_HAVE_BLIT_N_RGB565 + +// blits 16 bit RGB<->RGBA with both surfaces having the same R,G,B fields +static void Blit2to2MaskAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint16 *src = (Uint16 *)info->src; + int srcskip = info->src_skip; + Uint16 *dst = (Uint16 *)info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + + if (dstfmt->Amask) { + // RGB->RGBA, SET_ALPHA + Uint16 mask = ((Uint32)info->a >> (8 - dstfmt->Abits)) << dstfmt->Ashift; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + *dst = *src | mask; + ++dst; + ++src; + }, + width); + /* *INDENT-ON* */ // clang-format on + src = (Uint16 *)((Uint8 *)src + srcskip); + dst = (Uint16 *)((Uint8 *)dst + dstskip); + } + } else { + // RGBA->RGB, NO_ALPHA + Uint16 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + *dst = *src & mask; + ++dst; + ++src; + }, + width); + /* *INDENT-ON* */ // clang-format on + src = (Uint16 *)((Uint8 *)src + srcskip); + dst = (Uint16 *)((Uint8 *)dst + dstskip); + } + } +} + +// blits 32 bit RGB<->RGBA with both surfaces having the same R,G,B fields +static void Blit4to4MaskAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint32 *src = (Uint32 *)info->src; + int srcskip = info->src_skip; + Uint32 *dst = (Uint32 *)info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + + if (dstfmt->Amask) { + // RGB->RGBA, SET_ALPHA + Uint32 mask = ((Uint32)info->a >> (8 - dstfmt->Abits)) << dstfmt->Ashift; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + *dst = *src | mask; + ++dst; + ++src; + }, + width); + /* *INDENT-ON* */ // clang-format on + src = (Uint32 *)((Uint8 *)src + srcskip); + dst = (Uint32 *)((Uint8 *)dst + dstskip); + } + } else { + // RGBA->RGB, NO_ALPHA + Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + *dst = *src & mask; + ++dst; + ++src; + }, + width); + /* *INDENT-ON* */ // clang-format on + src = (Uint32 *)((Uint8 *)src + srcskip); + dst = (Uint32 *)((Uint8 *)dst + dstskip); + } + } +} + +// permutation for mapping srcfmt to dstfmt, overloading or not the alpha channel +static void get_permutation(const SDL_PixelFormatDetails *srcfmt, const SDL_PixelFormatDetails *dstfmt, + int *_p0, int *_p1, int *_p2, int *_p3, int *_alpha_channel) +{ + int alpha_channel = 0, p0, p1, p2, p3; +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + int Pixel = 0x04030201; // identity permutation +#else + int Pixel = 0x01020304; // identity permutation + int srcbpp = srcfmt->bytes_per_pixel; + int dstbpp = dstfmt->bytes_per_pixel; +#endif + + if (srcfmt->Amask) { + RGBA_FROM_PIXEL(Pixel, srcfmt, p0, p1, p2, p3); + } else { + RGB_FROM_PIXEL(Pixel, srcfmt, p0, p1, p2); + p3 = 0; + } + + if (dstfmt->Amask) { + if (srcfmt->Amask) { + PIXEL_FROM_RGBA(Pixel, dstfmt, p0, p1, p2, p3); + } else { + PIXEL_FROM_RGBA(Pixel, dstfmt, p0, p1, p2, 0); + } + } else { + PIXEL_FROM_RGB(Pixel, dstfmt, p0, p1, p2); + } + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + p0 = Pixel & 0xFF; + p1 = (Pixel >> 8) & 0xFF; + p2 = (Pixel >> 16) & 0xFF; + p3 = (Pixel >> 24) & 0xFF; +#else + p3 = Pixel & 0xFF; + p2 = (Pixel >> 8) & 0xFF; + p1 = (Pixel >> 16) & 0xFF; + p0 = (Pixel >> 24) & 0xFF; +#endif + + if (p0 == 0) { + p0 = 1; + alpha_channel = 0; + } else if (p1 == 0) { + p1 = 1; + alpha_channel = 1; + } else if (p2 == 0) { + p2 = 1; + alpha_channel = 2; + } else if (p3 == 0) { + p3 = 1; + alpha_channel = 3; + } + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN +#else + if (srcbpp == 3 && dstbpp == 4) { + if (p0 != 1) { + p0--; + } + if (p1 != 1) { + p1--; + } + if (p2 != 1) { + p2--; + } + if (p3 != 1) { + p3--; + } + } else if (srcbpp == 4 && dstbpp == 3) { + p0 = p1; + p1 = p2; + p2 = p3; + } +#endif + *_p0 = p0 - 1; + *_p1 = p1 - 1; + *_p2 = p2 - 1; + *_p3 = p3 - 1; + + if (_alpha_channel) { + *_alpha_channel = alpha_channel; + } +} + +static void BlitNtoN(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + int srcbpp = srcfmt->bytes_per_pixel; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int dstbpp = dstfmt->bytes_per_pixel; + unsigned alpha = dstfmt->Amask ? info->a : 0; + +#if HAVE_FAST_WRITE_INT8 + // Blit with permutation: 4->4 + if (srcbpp == 4 && dstbpp == 4 && + !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && + !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { + + // Find the appropriate permutation + int alpha_channel, p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + dst[3] = src[p3]; + dst[alpha_channel] = (Uint8)alpha; + src += 4; + dst += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } +#endif + + // Blit with permutation: 4->3 + if (srcbpp == 4 && dstbpp == 3 && + !SDL_ISPIXELFORMAT_10BIT(srcfmt->format)) { + + // Find the appropriate permutation + int p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + src += 4; + dst += 3; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } + +#if HAVE_FAST_WRITE_INT8 + // Blit with permutation: 3->4 + if (srcbpp == 3 && dstbpp == 4 && + !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { + + // Find the appropriate permutation + int alpha_channel, p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + dst[3] = src[p3]; + dst[alpha_channel] = (Uint8)alpha; + src += 3; + dst += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } +#endif + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 Pixel; + unsigned sR; + unsigned sG; + unsigned sB; + DISEMBLE_RGB(src, srcbpp, srcfmt, Pixel, sR, sG, sB); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha); + dst += dstbpp; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +static void BlitNtoNCopyAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + int srcbpp = srcfmt->bytes_per_pixel; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int dstbpp = dstfmt->bytes_per_pixel; + int c; + +#if HAVE_FAST_WRITE_INT8 + // Blit with permutation: 4->4 + if (srcbpp == 4 && dstbpp == 4 && + !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && + !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { + + // Find the appropriate permutation + int p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + dst[3] = src[p3]; + src += 4; + dst += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } +#endif + + while (height--) { + for (c = width; c; --c) { + Uint32 Pixel; + unsigned sR, sG, sB, sA; + DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA); + dst += dstbpp; + src += srcbpp; + } + src += srcskip; + dst += dstskip; + } +} + +static void Blit2to2Key(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint16 *srcp = (Uint16 *)info->src; + int srcskip = info->src_skip; + Uint16 *dstp = (Uint16 *)info->dst; + int dstskip = info->dst_skip; + Uint32 ckey = info->colorkey; + Uint32 rgbmask = ~info->src_fmt->Amask; + + // Set up some basic variables + srcskip /= 2; + dstskip /= 2; + ckey &= rgbmask; + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ( (*srcp & rgbmask) != ckey ) { + *dstp = *srcp; + } + dstp++; + srcp++; + }, + width); + /* *INDENT-ON* */ // clang-format on + srcp += srcskip; + dstp += dstskip; + } +} + +static void BlitNtoNKey(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint32 ckey = info->colorkey; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int srcbpp = srcfmt->bytes_per_pixel; + int dstbpp = dstfmt->bytes_per_pixel; + unsigned alpha = dstfmt->Amask ? info->a : 0; + Uint32 rgbmask = ~srcfmt->Amask; + int sfmt = srcfmt->format; + int dfmt = dstfmt->format; + + // Set up some basic variables + ckey &= rgbmask; + + // BPP 4, same rgb + if (srcbpp == 4 && dstbpp == 4 && srcfmt->Rmask == dstfmt->Rmask && srcfmt->Gmask == dstfmt->Gmask && srcfmt->Bmask == dstfmt->Bmask) { + Uint32 *src32 = (Uint32 *)src; + Uint32 *dst32 = (Uint32 *)dst; + + if (dstfmt->Amask) { + // RGB->RGBA, SET_ALPHA + Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift; + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ((*src32 & rgbmask) != ckey) { + *dst32 = *src32 | mask; + } + ++dst32; + ++src32; + }, width); + /* *INDENT-ON* */ // clang-format on + src32 = (Uint32 *)((Uint8 *)src32 + srcskip); + dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); + } + return; + } else { + // RGBA->RGB, NO_ALPHA + Uint32 mask = srcfmt->Rmask | srcfmt->Gmask | srcfmt->Bmask; + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ((*src32 & rgbmask) != ckey) { + *dst32 = *src32 & mask; + } + ++dst32; + ++src32; + }, width); + /* *INDENT-ON* */ // clang-format on + src32 = (Uint32 *)((Uint8 *)src32 + srcskip); + dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); + } + return; + } + } + +#if HAVE_FAST_WRITE_INT8 + // Blit with permutation: 4->4 + if (srcbpp == 4 && dstbpp == 4 && + !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && + !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { + + // Find the appropriate permutation + int alpha_channel, p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 *src32 = (Uint32*)src; + + if ((*src32 & rgbmask) != ckey) { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + dst[3] = src[p3]; + dst[alpha_channel] = (Uint8)alpha; + } + src += 4; + dst += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } +#endif + + // BPP 3, same rgb triplet + if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_RGB24) || + (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_BGR24)) { + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + Uint8 k0 = ckey & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k2 = (ckey >> 16) & 0xFF; +#else + Uint8 k0 = (ckey >> 16) & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k2 = ckey & 0xFF; +#endif + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint8 s0 = src[0]; + Uint8 s1 = src[1]; + Uint8 s2 = src[2]; + + if (k0 != s0 || k1 != s1 || k2 != s2) { + dst[0] = s0; + dst[1] = s1; + dst[2] = s2; + } + src += 3; + dst += 3; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } + + // BPP 3, inversed rgb triplet + if ((sfmt == SDL_PIXELFORMAT_RGB24 && dfmt == SDL_PIXELFORMAT_BGR24) || + (sfmt == SDL_PIXELFORMAT_BGR24 && dfmt == SDL_PIXELFORMAT_RGB24)) { + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + Uint8 k0 = ckey & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k2 = (ckey >> 16) & 0xFF; +#else + Uint8 k0 = (ckey >> 16) & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k2 = ckey & 0xFF; +#endif + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint8 s0 = src[0]; + Uint8 s1 = src[1]; + Uint8 s2 = src[2]; + if (k0 != s0 || k1 != s1 || k2 != s2) { + // Inversed RGB + dst[0] = s2; + dst[1] = s1; + dst[2] = s0; + } + src += 3; + dst += 3; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } + + // Blit with permutation: 4->3 + if (srcbpp == 4 && dstbpp == 3 && + !SDL_ISPIXELFORMAT_10BIT(srcfmt->format)) { + + // Find the appropriate permutation + int p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 *src32 = (Uint32*)src; + if ((*src32 & rgbmask) != ckey) { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + } + src += 4; + dst += 3; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } + +#if HAVE_FAST_WRITE_INT8 + // Blit with permutation: 3->4 + if (srcbpp == 3 && dstbpp == 4 && + !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { + +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + Uint8 k0 = ckey & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k2 = (ckey >> 16) & 0xFF; +#else + Uint8 k0 = (ckey >> 16) & 0xFF; + Uint8 k1 = (ckey >> 8) & 0xFF; + Uint8 k2 = ckey & 0xFF; +#endif + + // Find the appropriate permutation + int alpha_channel, p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, &alpha_channel); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint8 s0 = src[0]; + Uint8 s1 = src[1]; + Uint8 s2 = src[2]; + + if (k0 != s0 || k1 != s1 || k2 != s2) { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + dst[3] = src[p3]; + dst[alpha_channel] = (Uint8)alpha; + } + src += 3; + dst += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } +#endif + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 Pixel; + unsigned sR; + unsigned sG; + unsigned sB; + RETRIEVE_RGB_PIXEL(src, srcbpp, Pixel); + if ( (Pixel & rgbmask) != ckey ) { + RGB_FROM_PIXEL(Pixel, srcfmt, sR, sG, sB); + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha); + } + dst += dstbpp; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + Uint32 ckey = info->colorkey; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + Uint32 rgbmask = ~srcfmt->Amask; + + Uint8 srcbpp; + Uint8 dstbpp; + Uint32 Pixel; + unsigned sR, sG, sB, sA; + + // Set up some basic variables + srcbpp = srcfmt->bytes_per_pixel; + dstbpp = dstfmt->bytes_per_pixel; + ckey &= rgbmask; + + // Fastpath: same source/destination format, with Amask, bpp 32, loop is vectorized. ~10x faster + if (srcfmt->format == dstfmt->format) { + + if (srcfmt->format == SDL_PIXELFORMAT_ARGB8888 || + srcfmt->format == SDL_PIXELFORMAT_ABGR8888 || + srcfmt->format == SDL_PIXELFORMAT_BGRA8888 || + srcfmt->format == SDL_PIXELFORMAT_RGBA8888) { + + Uint32 *src32 = (Uint32 *)src; + Uint32 *dst32 = (Uint32 *)dst; + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP_TRIVIAL( + { + if ((*src32 & rgbmask) != ckey) { + *dst32 = *src32; + } + ++src32; + ++dst32; + }, + width); + /* *INDENT-ON* */ // clang-format on + src32 = (Uint32 *)((Uint8 *)src32 + srcskip); + dst32 = (Uint32 *)((Uint8 *)dst32 + dstskip); + } + } + return; + } + +#if HAVE_FAST_WRITE_INT8 + // Blit with permutation: 4->4 + if (srcbpp == 4 && dstbpp == 4 && + !SDL_ISPIXELFORMAT_10BIT(srcfmt->format) && + !SDL_ISPIXELFORMAT_10BIT(dstfmt->format)) { + + // Find the appropriate permutation + int p0, p1, p2, p3; + get_permutation(srcfmt, dstfmt, &p0, &p1, &p2, &p3, NULL); + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 *src32 = (Uint32*)src; + if ((*src32 & rgbmask) != ckey) { + dst[0] = src[p0]; + dst[1] = src[p1]; + dst[2] = src[p2]; + dst[3] = src[p3]; + } + src += 4; + dst += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + return; + } +#endif + + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + DISEMBLE_RGBA(src, srcbpp, srcfmt, Pixel, sR, sG, sB, sA); + if ( (Pixel & rgbmask) != ckey ) { + ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, sA); + } + dst += dstbpp; + src += srcbpp; + }, + width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } +} + +// Blit_3or4_to_3or4__same_rgb: 3 or 4 bpp, same RGB triplet +static void Blit_3or4_to_3or4__same_rgb(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + int srcbpp = srcfmt->bytes_per_pixel; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int dstbpp = dstfmt->bytes_per_pixel; + + if (dstfmt->Amask) { + // SET_ALPHA + Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift; +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + int i0 = 0, i1 = 1, i2 = 2; +#else + int i0 = srcbpp - 1 - 0; + int i1 = srcbpp - 1 - 1; + int i2 = srcbpp - 1 - 2; +#endif + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 *dst32 = (Uint32*)dst; + Uint8 s0 = src[i0]; + Uint8 s1 = src[i1]; + Uint8 s2 = src[i2]; + *dst32 = (s0) | (s1 << 8) | (s2 << 16) | mask; + dst += 4; + src += srcbpp; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } else { + // NO_ALPHA +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + int i0 = 0, i1 = 1, i2 = 2; + int j0 = 0, j1 = 1, j2 = 2; +#else + int i0 = srcbpp - 1 - 0; + int i1 = srcbpp - 1 - 1; + int i2 = srcbpp - 1 - 2; + int j0 = dstbpp - 1 - 0; + int j1 = dstbpp - 1 - 1; + int j2 = dstbpp - 1 - 2; +#endif + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint8 s0 = src[i0]; + Uint8 s1 = src[i1]; + Uint8 s2 = src[i2]; + dst[j0] = s0; + dst[j1] = s1; + dst[j2] = s2; + dst += dstbpp; + src += srcbpp; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } +} + +// Blit_3or4_to_3or4__inversed_rgb: 3 or 4 bpp, inversed RGB triplet +static void Blit_3or4_to_3or4__inversed_rgb(SDL_BlitInfo *info) +{ + int width = info->dst_w; + int height = info->dst_h; + Uint8 *src = info->src; + int srcskip = info->src_skip; + Uint8 *dst = info->dst; + int dstskip = info->dst_skip; + const SDL_PixelFormatDetails *srcfmt = info->src_fmt; + int srcbpp = srcfmt->bytes_per_pixel; + const SDL_PixelFormatDetails *dstfmt = info->dst_fmt; + int dstbpp = dstfmt->bytes_per_pixel; + + if (dstfmt->Amask) { + if (srcfmt->Amask) { + // COPY_ALPHA + // Only to switch ABGR8888 <-> ARGB8888 + while (height--) { +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + int i0 = 0, i1 = 1, i2 = 2, i3 = 3; +#else + int i0 = 3, i1 = 2, i2 = 1, i3 = 0; +#endif + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 *dst32 = (Uint32*)dst; + Uint8 s0 = src[i0]; + Uint8 s1 = src[i1]; + Uint8 s2 = src[i2]; + Uint32 alphashift = ((Uint32)src[i3]) << dstfmt->Ashift; + // inversed, compared to Blit_3or4_to_3or4__same_rgb + *dst32 = (s0 << 16) | (s1 << 8) | (s2) | alphashift; + dst += 4; + src += 4; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } else { + // SET_ALPHA + Uint32 mask = ((Uint32)info->a) << dstfmt->Ashift; +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + int i0 = 0, i1 = 1, i2 = 2; +#else + int i0 = srcbpp - 1 - 0; + int i1 = srcbpp - 1 - 1; + int i2 = srcbpp - 1 - 2; +#endif + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint32 *dst32 = (Uint32*)dst; + Uint8 s0 = src[i0]; + Uint8 s1 = src[i1]; + Uint8 s2 = src[i2]; + // inversed, compared to Blit_3or4_to_3or4__same_rgb + *dst32 = (s0 << 16) | (s1 << 8) | (s2) | mask; + dst += 4; + src += srcbpp; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } + } else { + // NO_ALPHA +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + int i0 = 0, i1 = 1, i2 = 2; + int j0 = 2, j1 = 1, j2 = 0; +#else + int i0 = srcbpp - 1 - 0; + int i1 = srcbpp - 1 - 1; + int i2 = srcbpp - 1 - 2; + int j0 = dstbpp - 1 - 2; + int j1 = dstbpp - 1 - 1; + int j2 = dstbpp - 1 - 0; +#endif + while (height--) { + /* *INDENT-OFF* */ // clang-format off + DUFFS_LOOP( + { + Uint8 s0 = src[i0]; + Uint8 s1 = src[i1]; + Uint8 s2 = src[i2]; + // inversed, compared to Blit_3or4_to_3or4__same_rgb + dst[j0] = s0; + dst[j1] = s1; + dst[j2] = s2; + dst += dstbpp; + src += srcbpp; + }, width); + /* *INDENT-ON* */ // clang-format on + src += srcskip; + dst += dstskip; + } + } +} + +// Normal N to N optimized blitters +#define NO_ALPHA 1 +#define SET_ALPHA 2 +#define COPY_ALPHA 4 +struct blit_table +{ + Uint32 srcR, srcG, srcB; + int dstbpp; + Uint32 dstR, dstG, dstB; + Uint32 blit_features; + SDL_BlitFunc blitfunc; + Uint32 alpha; // bitwise NO_ALPHA, SET_ALPHA, COPY_ALPHA +}; +static const struct blit_table normal_blit_1[] = { + // Default for 8-bit RGB source, never optimized + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } +}; + +static const struct blit_table normal_blit_2[] = { +#ifdef SDL_ALTIVEC_BLITTERS + // has-altivec + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB565_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x00007C00, 0x000003E0, 0x0000001F, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC, Blit_RGB555_32Altivec, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, +#endif +#ifdef SDL_HAVE_BLIT_N_RGB565 + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_RGB565_ARGB8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_RGB565_ABGR8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0xFF000000, 0x00FF0000, 0x0000FF00, + 0, Blit_RGB565_RGBA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + { 0x0000F800, 0x000007E0, 0x0000001F, 4, 0x0000FF00, 0x00FF0000, 0xFF000000, + 0, Blit_RGB565_BGRA8888, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, +#endif + // Default for 16-bit RGB source, used if no other blitter matches + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } +}; + +static const struct blit_table normal_blit_3[] = { + // 3->4 with same rgb triplet + { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__same_rgb, +#if HAVE_FAST_WRITE_INT8 + NO_ALPHA | +#endif + SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__same_rgb, +#if HAVE_FAST_WRITE_INT8 + NO_ALPHA | +#endif + SET_ALPHA }, + // 3->4 with inversed rgb triplet + { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, +#if HAVE_FAST_WRITE_INT8 + NO_ALPHA | +#endif + SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, +#if HAVE_FAST_WRITE_INT8 + NO_ALPHA | +#endif + SET_ALPHA }, + // 3->3 to switch RGB 24 <-> BGR 24 + { 0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA }, + // Default for 24-bit RGB source, never optimized + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } +}; + +static const struct blit_table normal_blit_4[] = { +#ifdef SDL_ALTIVEC_BLITTERS + // has-altivec | dont-use-prefetch + { 0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC | BLIT_FEATURE_ALTIVEC_DONT_USE_PREFETCH, ConvertAltivec32to32_noprefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + // has-altivec + { 0x00000000, 0x00000000, 0x00000000, 4, 0x00000000, 0x00000000, 0x00000000, + BLIT_FEATURE_HAS_ALTIVEC, ConvertAltivec32to32_prefetch, NO_ALPHA | COPY_ALPHA | SET_ALPHA }, + // has-altivec + { 0x00000000, 0x00000000, 0x00000000, 2, 0x0000F800, 0x000007E0, 0x0000001F, + BLIT_FEATURE_HAS_ALTIVEC, Blit_XRGB8888_RGB565Altivec, NO_ALPHA }, +#endif + // 4->3 with same rgb triplet + { 0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__same_rgb, NO_ALPHA | SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__same_rgb, NO_ALPHA | SET_ALPHA }, + // 4->3 with inversed rgb triplet + { 0x000000FF, 0x0000FF00, 0x00FF0000, 3, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA | SET_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 3, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, NO_ALPHA | SET_ALPHA }, + // 4->4 with inversed rgb triplet, and COPY_ALPHA to switch ABGR8888 <-> ARGB8888 + { 0x000000FF, 0x0000FF00, 0x00FF0000, 4, 0x00FF0000, 0x0000FF00, 0x000000FF, + 0, Blit_3or4_to_3or4__inversed_rgb, +#if HAVE_FAST_WRITE_INT8 + NO_ALPHA | +#endif + SET_ALPHA | COPY_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 4, 0x000000FF, 0x0000FF00, 0x00FF0000, + 0, Blit_3or4_to_3or4__inversed_rgb, +#if HAVE_FAST_WRITE_INT8 + NO_ALPHA | +#endif + SET_ALPHA | COPY_ALPHA }, + // RGB 888 and RGB 565 + { 0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x0000F800, 0x000007E0, 0x0000001F, + 0, Blit_XRGB8888_RGB565, NO_ALPHA }, + { 0x00FF0000, 0x0000FF00, 0x000000FF, 2, 0x00007C00, 0x000003E0, 0x0000001F, + 0, Blit_XRGB8888_RGB555, NO_ALPHA }, + // Default for 32-bit RGB source, used if no other blitter matches + { 0, 0, 0, 0, 0, 0, 0, 0, BlitNtoN, 0 } +}; + +static const struct blit_table *const normal_blit[] = { + normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4 +}; + +// Mask matches table, or table entry is zero +#define MASKOK(x, y) (((x) == (y)) || ((y) == 0x00000000)) + +SDL_BlitFunc SDL_CalculateBlitN(SDL_Surface *surface) +{ + const SDL_PixelFormatDetails *srcfmt; + const SDL_PixelFormatDetails *dstfmt; + const struct blit_table *table; + int which; + SDL_BlitFunc blitfun; + + // Set up data for choosing the blit + srcfmt = surface->fmt; + dstfmt = surface->map.info.dst_fmt; + + // We don't support destinations less than 8-bits + if (dstfmt->bits_per_pixel < 8) { + return NULL; + } + + switch (surface->map.info.flags & ~SDL_COPY_RLE_MASK) { + case 0: + blitfun = NULL; + if (dstfmt->bits_per_pixel > 8) { + Uint32 a_need = NO_ALPHA; + if (dstfmt->Amask) { + a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA; + } + if (srcfmt->bytes_per_pixel > 0 && + srcfmt->bytes_per_pixel <= SDL_arraysize(normal_blit)) { + table = normal_blit[srcfmt->bytes_per_pixel - 1]; + for (which = 0; table[which].dstbpp; ++which) { + if (MASKOK(srcfmt->Rmask, table[which].srcR) && + MASKOK(srcfmt->Gmask, table[which].srcG) && + MASKOK(srcfmt->Bmask, table[which].srcB) && + MASKOK(dstfmt->Rmask, table[which].dstR) && + MASKOK(dstfmt->Gmask, table[which].dstG) && + MASKOK(dstfmt->Bmask, table[which].dstB) && + dstfmt->bytes_per_pixel == table[which].dstbpp && + (a_need & table[which].alpha) == a_need && + ((table[which].blit_features & GetBlitFeatures()) == + table[which].blit_features)) { + break; + } + } + blitfun = table[which].blitfunc; + } + + if (blitfun == BlitNtoN) { // default C fallback catch-all. Slow! + if (srcfmt->bytes_per_pixel == dstfmt->bytes_per_pixel && + srcfmt->Rmask == dstfmt->Rmask && + srcfmt->Gmask == dstfmt->Gmask && + srcfmt->Bmask == dstfmt->Bmask) { + if (a_need == COPY_ALPHA) { + if (srcfmt->Amask == dstfmt->Amask) { + // Fastpath C fallback: RGBA<->RGBA blit with matching RGBA + blitfun = SDL_BlitCopy; + } else { + blitfun = BlitNtoNCopyAlpha; + } + } else { + if (srcfmt->bytes_per_pixel == 4) { + // Fastpath C fallback: 32bit RGB<->RGBA blit with matching RGB + blitfun = Blit4to4MaskAlpha; + } else if (srcfmt->bytes_per_pixel == 2) { + // Fastpath C fallback: 16bit RGB<->RGBA blit with matching RGB + blitfun = Blit2to2MaskAlpha; + } + } + } else if (a_need == COPY_ALPHA) { + blitfun = BlitNtoNCopyAlpha; + } + } + } + return blitfun; + + case SDL_COPY_COLORKEY: + /* colorkey blit: Here we don't have too many options, mostly + because RLE is the preferred fast way to deal with this. + If a particular case turns out to be useful we'll add it. */ + + if (srcfmt->bytes_per_pixel == 2 && surface->map.identity != 0) { + return Blit2to2Key; + } else { +#ifdef SDL_ALTIVEC_BLITTERS + if ((srcfmt->bytes_per_pixel == 4) && (dstfmt->bytes_per_pixel == 4) && SDL_HasAltiVec()) { + return Blit32to32KeyAltivec; + } else +#endif + if (srcfmt->Amask && dstfmt->Amask) { + return BlitNtoNKeyCopyAlpha; + } else { + return BlitNtoNKey; + } + } + } + + return NULL; +} + +#endif // SDL_HAVE_BLIT_N diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_auto.c b/contrib/SDL-3.2.8/src/video/SDL_blit_auto.c new file mode 100644 index 0000000..d9bf673 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_auto.c @@ -0,0 +1,11542 @@ +// DO NOT EDIT! This file is generated by sdlgenblit.pl +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_HAVE_BLIT_AUTO + +/* *INDENT-OFF* */ // clang-format off + +#include "SDL_blit.h" +#include "SDL_blit_auto.h" + +static void SDL_Blit_XRGB8888_XRGB8888_Scale(SDL_BlitInfo *info) +{ + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + *dst = *src; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XRGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XRGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XBGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XBGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XBGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ARGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + const Uint32 A = 0xFF; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel |= (A << 24); + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ARGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ARGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ABGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + const Uint32 A = 0xFF; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ABGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ABGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info) +{ + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + *dst = *src; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + const Uint32 A = 0xFF; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ABGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + const Uint32 A = 0xFF; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel |= (A << 24); + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ABGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = 0xFF; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ABGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; + Uint32 srcR, srcG, srcB; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel &= 0xFFFFFF; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info) +{ + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + *dst = *src; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ABGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ABGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ABGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel >>= 8; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel = (pixel >> 8) | (pixel << 24); + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ABGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ABGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ABGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel &= 0xFFFFFF; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ABGR8888_Scale(SDL_BlitInfo *info) +{ + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + *dst = *src; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ABGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ABGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel >>= 8; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + Uint32 pixel; + Uint32 R, G, B; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + pixel = (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (R << 16) | (G << 8) | B; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ABGR8888_Scale(SDL_BlitInfo *info) +{ + Uint32 pixel; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + pixel = (pixel >> 8) | (pixel << 24); + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ABGR8888_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ABGR8888_Modulate(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 pixel; + Uint32 R, G, B, A; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + pixel = *src; + B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(R, modulateR, R); + MULT_DIV_255(G, modulateG, G); + MULT_DIV_255(B, modulateB, B); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(A, modulateA, A); + } + pixel = (A << 24) | (B << 16) | (G << 8) | R; + *dst = pixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (info->dst_h--) { + Uint32 *src = (Uint32 *)info->src; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + while (n--) { + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +} + +static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + Uint32 *src = 0; + Uint32 *dst = (Uint32 *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); + srcpixel = *src; + srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; + dstpixel = *dst; + dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(srcR, modulateR, srcR); + MULT_DIV_255(srcG, modulateG, srcG); + MULT_DIV_255(srcB, modulateB, srcB); + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(srcA, modulateA, srcA); + } + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (srcA < 255) { + MULT_DIV_255(srcR, srcA, srcR); + MULT_DIV_255(srcG, srcA, srcG); + MULT_DIV_255(srcB, srcA, srcB); + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + MULT_DIV_255((255 - srcA), dstR, dstR); + dstR += srcR; + if (dstR > 255) dstR = 255; + MULT_DIV_255((255 - srcA), dstG, dstG); + dstG += srcG; + if (dstG > 255) dstG = 255; + MULT_DIV_255((255 - srcA), dstB, dstB); + dstB += srcB; + if (dstB > 255) dstB = 255; + MULT_DIV_255((255 - srcA), dstA, dstA); + dstA += srcA; + if (dstA > 255) dstA = 255; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; if (dstR > 255) dstR = 255; + dstG = srcG + dstG; if (dstG > 255) dstG = 255; + dstB = srcB + dstB; if (dstB > 255) dstB = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(srcR, dstR, dstR); + MULT_DIV_255(srcG, dstG, dstG); + MULT_DIV_255(srcB, dstB, dstB); + break; + case SDL_COPY_MUL: + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(srcR, dstR, tmp1); + MULT_DIV_255(dstR, (255 - srcA), tmp2); + dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; + MULT_DIV_255(srcG, dstG, tmp1); + MULT_DIV_255(dstG, (255 - srcA), tmp2); + dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; + MULT_DIV_255(srcB, dstB, tmp1); + MULT_DIV_255(dstB, (255 - srcA), tmp2); + dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; + } + break; + } + dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; + *dst = dstpixel; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_UNKNOWN, 0, 0, NULL } +}; + +/* *INDENT-ON* */ // clang-format on + +#endif // SDL_HAVE_BLIT_AUTO + diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_auto.h b/contrib/SDL-3.2.8/src/video/SDL_blit_auto.h new file mode 100644 index 0000000..cd3f0d8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_auto.h @@ -0,0 +1,34 @@ +// DO NOT EDIT! This file is generated by sdlgenblit.pl +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" +#include "SDL_blit.h" + +#ifdef SDL_HAVE_BLIT_AUTO + +/* *INDENT-OFF* */ // clang-format off + +extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[]; + +/* *INDENT-ON* */ // clang-format on + +#endif // SDL_HAVE_BLIT_AUTO + diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_copy.c b/contrib/SDL-3.2.8/src/video/SDL_blit_copy.c new file mode 100644 index 0000000..05ce0a4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_copy.c @@ -0,0 +1,110 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_surface_c.h" +#include "SDL_blit_copy.h" + +#ifdef SDL_SSE_INTRINSICS +// This assumes 16-byte aligned src and dst +static SDL_INLINE void SDL_TARGETING("sse") SDL_memcpySSE(Uint8 *dst, const Uint8 *src, int len) +{ + int i; + + __m128 values[4]; + for (i = len / 64; i--;) { + _mm_prefetch((const char *)src, _MM_HINT_NTA); + values[0] = *(__m128 *)(src + 0); + values[1] = *(__m128 *)(src + 16); + values[2] = *(__m128 *)(src + 32); + values[3] = *(__m128 *)(src + 48); + _mm_stream_ps((float *)(dst + 0), values[0]); + _mm_stream_ps((float *)(dst + 16), values[1]); + _mm_stream_ps((float *)(dst + 32), values[2]); + _mm_stream_ps((float *)(dst + 48), values[3]); + src += 64; + dst += 64; + } + + if (len & 63) { + SDL_memcpy(dst, src, len & 63); + } +} +#endif // SDL_SSE_INTRINSICS + +void SDL_BlitCopy(SDL_BlitInfo *info) +{ + bool overlap; + Uint8 *src, *dst; + int w, h; + int srcskip, dstskip; + + w = info->dst_w * info->dst_fmt->bytes_per_pixel; + h = info->dst_h; + src = info->src; + dst = info->dst; + srcskip = info->src_pitch; + dstskip = info->dst_pitch; + + // Properly handle overlapping blits + if (src < dst) { + overlap = (dst < (src + h * srcskip)); + } else { + overlap = (src < (dst + h * dstskip)); + } + if (overlap) { + if (dst < src) { + while (h--) { + SDL_memmove(dst, src, w); + src += srcskip; + dst += dstskip; + } + } else { + src += ((h - 1) * srcskip); + dst += ((h - 1) * dstskip); + while (h--) { + SDL_memmove(dst, src, w); + src -= srcskip; + dst -= dstskip; + } + } + return; + } + +#ifdef SDL_SSE_INTRINSICS + if (SDL_HasSSE() && + !((uintptr_t)src & 15) && !(srcskip & 15) && + !((uintptr_t)dst & 15) && !(dstskip & 15)) { + while (h--) { + SDL_memcpySSE(dst, src, w); + src += srcskip; + dst += dstskip; + } + return; + } +#endif + + while (h--) { + SDL_memcpy(dst, src, w); + src += srcskip; + dst += dstskip; + } +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_copy.h b/contrib/SDL-3.2.8/src/video/SDL_blit_copy.h new file mode 100644 index 0000000..485e3d1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_copy.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_blit_copy_h_ +#define SDL_blit_copy_h_ + +void SDL_BlitCopy(SDL_BlitInfo *info); + +#endif // SDL_blit_copy_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_slow.c b/contrib/SDL-3.2.8/src/video/SDL_blit_slow.c new file mode 100644 index 0000000..d0dd4cf --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_slow.c @@ -0,0 +1,996 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_surface_c.h" +#include "SDL_blit_slow.h" +#include "SDL_pixels_c.h" + +typedef enum +{ + SlowBlitPixelAccess_Index8, + SlowBlitPixelAccess_RGB, + SlowBlitPixelAccess_RGBA, + SlowBlitPixelAccess_10Bit, + SlowBlitPixelAccess_Large, +} SlowBlitPixelAccess; + +static SlowBlitPixelAccess GetPixelAccessMethod(SDL_PixelFormat format) +{ + if (SDL_BYTESPERPIXEL(format) > 4) { + return SlowBlitPixelAccess_Large; + } else if (SDL_ISPIXELFORMAT_10BIT(format)) { + return SlowBlitPixelAccess_10Bit; + } else if (format == SDL_PIXELFORMAT_INDEX8) { + return SlowBlitPixelAccess_Index8; + } else if (SDL_ISPIXELFORMAT_ALPHA(format)) { + return SlowBlitPixelAccess_RGBA; + } else { + return SlowBlitPixelAccess_RGB; + } +} + +/* The ONE TRUE BLITTER + * This puppy has to handle all the unoptimized cases - yes, it's slow. + */ +void SDL_Blit_Slow(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + Uint32 srcpixel = 0; + Uint32 srcR = 0, srcG = 0, srcB = 0, srcA = 0; + Uint32 dstpixel = 0; + Uint32 dstR = 0, dstG = 0, dstB = 0, dstA = 0; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + const SDL_PixelFormatDetails *src_fmt = info->src_fmt; + const SDL_Palette *src_pal = info->src_pal; + const SDL_PixelFormatDetails *dst_fmt = info->dst_fmt; + const SDL_Palette *dst_pal = info->dst_pal; + SDL_HashTable *palette_map = info->palette_map; + int srcbpp = src_fmt->bytes_per_pixel; + int dstbpp = dst_fmt->bytes_per_pixel; + SlowBlitPixelAccess src_access; + SlowBlitPixelAccess dst_access; + Uint32 rgbmask = ~src_fmt->Amask; + Uint32 ckey = info->colorkey & rgbmask; + Uint32 last_pixel = 0; + Uint8 last_index = 0; + + src_access = GetPixelAccessMethod(src_fmt->format); + dst_access = GetPixelAccessMethod(dst_fmt->format); + if (dst_access == SlowBlitPixelAccess_Index8) { + last_index = SDL_LookupRGBAColor(palette_map, last_pixel, dst_pal); + } + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; // start at the middle of pixel + + while (info->dst_h--) { + Uint8 *src = 0; + Uint8 *dst = info->dst; + int n = info->dst_w; + posx = incx / 2; // start at the middle of pixel + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp)); + + switch (src_access) { + case SlowBlitPixelAccess_Index8: + srcpixel = *src; + srcR = src_pal->colors[srcpixel].r; + srcG = src_pal->colors[srcpixel].g; + srcB = src_pal->colors[srcpixel].b; + srcA = src_pal->colors[srcpixel].a; + break; + case SlowBlitPixelAccess_RGB: + DISEMBLE_RGB(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB); + srcA = 0xFF; + break; + case SlowBlitPixelAccess_RGBA: + DISEMBLE_RGBA(src, srcbpp, src_fmt, srcpixel, srcR, srcG, srcB, srcA); + break; + case SlowBlitPixelAccess_10Bit: + srcpixel = *((Uint32 *)(src)); + switch (src_fmt->format) { + case SDL_PIXELFORMAT_XRGB2101010: + RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA); + srcA = 0xFF; + break; + case SDL_PIXELFORMAT_XBGR2101010: + RGBA_FROM_ABGR2101010(srcpixel, srcR, srcG, srcB, srcA); + srcA = 0xFF; + break; + case SDL_PIXELFORMAT_ARGB2101010: + RGBA_FROM_ARGB2101010(srcpixel, srcR, srcG, srcB, srcA); + break; + case SDL_PIXELFORMAT_ABGR2101010: + RGBA_FROM_ABGR2101010(srcpixel, srcR, srcG, srcB, srcA); + break; + default: + break; + } + break; + case SlowBlitPixelAccess_Large: + // Handled in SDL_Blit_Slow_Float() + break; + } + + if (flags & SDL_COPY_COLORKEY) { + // srcpixel isn't set for 24 bpp + if (srcbpp == 3) { + srcpixel = (srcR << src_fmt->Rshift) | + (srcG << src_fmt->Gshift) | (srcB << src_fmt->Bshift); + } + if ((srcpixel & rgbmask) == ckey) { + posx += incx; + dst += dstbpp; + continue; + } + } + if (flags & SDL_COPY_BLEND_MASK) { + switch (dst_access) { + case SlowBlitPixelAccess_Index8: + dstpixel = *dst; + dstR = dst_pal->colors[dstpixel].r; + dstG = dst_pal->colors[dstpixel].g; + dstB = dst_pal->colors[dstpixel].b; + dstA = dst_pal->colors[dstpixel].a; + break; + case SlowBlitPixelAccess_RGB: + DISEMBLE_RGB(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB); + dstA = 0xFF; + break; + case SlowBlitPixelAccess_RGBA: + DISEMBLE_RGBA(dst, dstbpp, dst_fmt, dstpixel, dstR, dstG, dstB, dstA); + break; + case SlowBlitPixelAccess_10Bit: + dstpixel = *((Uint32 *)(dst)); + switch (dst_fmt->format) { + case SDL_PIXELFORMAT_XRGB2101010: + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + dstA = 0xFF; + break; + case SDL_PIXELFORMAT_XBGR2101010: + RGBA_FROM_ABGR2101010(dstpixel, dstR, dstG, dstB, dstA); + dstA = 0xFF; + break; + case SDL_PIXELFORMAT_ARGB2101010: + RGBA_FROM_ARGB2101010(dstpixel, dstR, dstG, dstB, dstA); + break; + case SDL_PIXELFORMAT_ABGR2101010: + RGBA_FROM_ABGR2101010(dstpixel, dstR, dstG, dstB, dstA); + break; + default: + break; + } + break; + case SlowBlitPixelAccess_Large: + // Handled in SDL_Blit_Slow_Float() + break; + } + } else { + // don't care + } + + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) { + if (srcA < 255) { + srcR = (srcR * srcA) / 255; + srcG = (srcG * srcA) / 255; + srcB = (srcB * srcA) / 255; + } + } + switch (flags & SDL_COPY_BLEND_MASK) { + case 0: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = srcA; + break; + case SDL_COPY_BLEND: + dstR = srcR + ((255 - srcA) * dstR) / 255; + dstG = srcG + ((255 - srcA) * dstG) / 255; + dstB = srcB + ((255 - srcA) * dstB) / 255; + dstA = srcA + ((255 - srcA) * dstA) / 255; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + dstR = srcR + ((255 - srcA) * dstR) / 255; + if (dstR > 255) { + dstR = 255; + } + dstG = srcG + ((255 - srcA) * dstG) / 255; + if (dstG > 255) { + dstG = 255; + } + dstB = srcB + ((255 - srcA) * dstB) / 255; + if (dstB > 255) { + dstB = 255; + } + dstA = srcA + ((255 - srcA) * dstA) / 255; + if (dstA > 255) { + dstA = 255; + } + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + dstR = srcR + dstR; + if (dstR > 255) { + dstR = 255; + } + dstG = srcG + dstG; + if (dstG > 255) { + dstG = 255; + } + dstB = srcB + dstB; + if (dstB > 255) { + dstB = 255; + } + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR) / 255; + dstG = (srcG * dstG) / 255; + dstB = (srcB * dstB) / 255; + break; + case SDL_COPY_MUL: + dstR = ((srcR * dstR) + (dstR * (255 - srcA))) / 255; + if (dstR > 255) { + dstR = 255; + } + dstG = ((srcG * dstG) + (dstG * (255 - srcA))) / 255; + if (dstG > 255) { + dstG = 255; + } + dstB = ((srcB * dstB) + (dstB * (255 - srcA))) / 255; + if (dstB > 255) { + dstB = 255; + } + break; + } + + switch (dst_access) { + case SlowBlitPixelAccess_Index8: + dstpixel = ((dstR << 24) | (dstG << 16) | (dstB << 8) | dstA); + if (dstpixel != last_pixel) { + last_pixel = dstpixel; + last_index = SDL_LookupRGBAColor(palette_map, dstpixel, dst_pal); + } + *dst = last_index; + break; + case SlowBlitPixelAccess_RGB: + ASSEMBLE_RGB(dst, dstbpp, dst_fmt, dstR, dstG, dstB); + break; + case SlowBlitPixelAccess_RGBA: + ASSEMBLE_RGBA(dst, dstbpp, dst_fmt, dstR, dstG, dstB, dstA); + break; + case SlowBlitPixelAccess_10Bit: + { + Uint32 pixel; + switch (dst_fmt->format) { + case SDL_PIXELFORMAT_XRGB2101010: + dstA = 0xFF; + SDL_FALLTHROUGH; + case SDL_PIXELFORMAT_ARGB2101010: + ARGB2101010_FROM_RGBA(pixel, dstR, dstG, dstB, dstA); + break; + case SDL_PIXELFORMAT_XBGR2101010: + dstA = 0xFF; + SDL_FALLTHROUGH; + case SDL_PIXELFORMAT_ABGR2101010: + ABGR2101010_FROM_RGBA(pixel, dstR, dstG, dstB, dstA); + break; + default: + pixel = 0; + break; + } + *(Uint32 *)dst = pixel; + break; + } + case SlowBlitPixelAccess_Large: + // Handled in SDL_Blit_Slow_Float() + break; + } + + posx += incx; + dst += dstbpp; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + +/* Convert from F16 to float + * Public domain implementation from https://gist.github.com/rygorous/2144712 + */ +typedef union +{ + Uint32 u; + float f; + struct + { + Uint32 Mantissa : 23; + Uint32 Exponent : 8; + Uint32 Sign : 1; + } x; +} FP32; + +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable:4214) +#endif + +typedef union +{ + Uint16 u; + struct + { + Uint16 Mantissa : 10; + Uint16 Exponent : 5; + Uint16 Sign : 1; + } x; +} FP16; + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +static float half_to_float(Uint16 unValue) +{ + static const FP32 magic = { (254 - 15) << 23 }; + static const FP32 was_infnan = { (127 + 16) << 23 }; + FP16 h; + FP32 o; + + h.u = unValue; + o.u = (h.u & 0x7fff) << 13; // exponent/mantissa bits + o.f *= magic.f; // exponent adjust + if (o.f >= was_infnan.f) // make sure Inf/NaN survive + o.u |= 255 << 23; + o.u |= (h.u & 0x8000) << 16; // sign bit + return o.f; +} + +/* Convert from float to F16 + * Public domain implementation from https://stackoverflow.com/questions/76799117/how-to-convert-a-float-to-a-half-type-and-the-other-way-around-in-c + */ +static Uint16 float_to_half(float a) +{ + Uint32 ia; + Uint16 ir; + + SDL_memcpy(&ia, &a, sizeof(ia)); + + ir = (ia >> 16) & 0x8000; + if ((ia & 0x7f800000) == 0x7f800000) { + if ((ia & 0x7fffffff) == 0x7f800000) { + ir |= 0x7c00; // infinity + } else { + ir |= 0x7e00 | ((ia >> (24 - 11)) & 0x1ff); // NaN, quietened + } + } else if ((ia & 0x7f800000) >= 0x33000000) { + int shift = (int)((ia >> 23) & 0xff) - 127; + if (shift > 15) { + ir |= 0x7c00; // infinity + } else { + ia = (ia & 0x007fffff) | 0x00800000; // extract mantissa + if (shift < -14) { // denormal + ir |= ia >> (-1 - shift); + ia = ia << (32 - (-1 - shift)); + } else { // normal + ir |= ia >> (24 - 11); + ia = ia << (32 - (24 - 11)); + ir = ir + ((14 + shift) << 10); + } + // IEEE-754 round to nearest of even + if ((ia > 0x80000000) || ((ia == 0x80000000) && (ir & 1))) { + ir++; + } + } + } + return ir; +} + +static void ReadFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL_PixelFormatDetails *fmt, const SDL_Palette *pal, SDL_Colorspace colorspace, float SDR_white_point, + float *outR, float *outG, float *outB, float *outA) +{ + Uint32 pixel; + Uint32 R, G, B, A; + float fR = 0.0f, fG = 0.0f, fB = 0.0f, fA = 0.0f; + float v[4]; + + switch (access) { + case SlowBlitPixelAccess_Index8: + pixel = *pixels; + fR = (float)pal->colors[pixel].r / 255.0f; + fG = (float)pal->colors[pixel].g / 255.0f; + fB = (float)pal->colors[pixel].b / 255.0f; + fA = (float)pal->colors[pixel].a / 255.0f; + break; + case SlowBlitPixelAccess_RGB: + DISEMBLE_RGB(pixels, fmt->bytes_per_pixel, fmt, pixel, R, G, B); + fR = (float)R / 255.0f; + fG = (float)G / 255.0f; + fB = (float)B / 255.0f; + fA = 1.0f; + break; + case SlowBlitPixelAccess_RGBA: + DISEMBLE_RGBA(pixels, fmt->bytes_per_pixel, fmt, pixel, R, G, B, A); + fR = (float)R / 255.0f; + fG = (float)G / 255.0f; + fB = (float)B / 255.0f; + fA = (float)A / 255.0f; + break; + case SlowBlitPixelAccess_10Bit: + pixel = *((Uint32 *)pixels); + switch (fmt->format) { + case SDL_PIXELFORMAT_XRGB2101010: + RGBAFLOAT_FROM_ARGB2101010(pixel, fR, fG, fB, fA); + fA = 1.0f; + break; + case SDL_PIXELFORMAT_XBGR2101010: + RGBAFLOAT_FROM_ABGR2101010(pixel, fR, fG, fB, fA); + fA = 1.0f; + break; + case SDL_PIXELFORMAT_ARGB2101010: + RGBAFLOAT_FROM_ARGB2101010(pixel, fR, fG, fB, fA); + break; + case SDL_PIXELFORMAT_ABGR2101010: + RGBAFLOAT_FROM_ABGR2101010(pixel, fR, fG, fB, fA); + break; + default: + fR = fG = fB = fA = 0.0f; + break; + } + break; + case SlowBlitPixelAccess_Large: + switch (SDL_PIXELTYPE(fmt->format)) { + case SDL_PIXELTYPE_ARRAYU16: + v[0] = (float)(((Uint16 *)pixels)[0]) / SDL_MAX_UINT16; + v[1] = (float)(((Uint16 *)pixels)[1]) / SDL_MAX_UINT16; + v[2] = (float)(((Uint16 *)pixels)[2]) / SDL_MAX_UINT16; + if (fmt->bytes_per_pixel == 8) { + v[3] = (float)(((Uint16 *)pixels)[3]) / SDL_MAX_UINT16; + } else { + v[3] = 1.0f; + } + break; + case SDL_PIXELTYPE_ARRAYF16: + v[0] = half_to_float(((Uint16 *)pixels)[0]); + v[1] = half_to_float(((Uint16 *)pixels)[1]); + v[2] = half_to_float(((Uint16 *)pixels)[2]); + if (fmt->bytes_per_pixel == 8) { + v[3] = half_to_float(((Uint16 *)pixels)[3]); + } else { + v[3] = 1.0f; + } + break; + case SDL_PIXELTYPE_ARRAYF32: + v[0] = ((float *)pixels)[0]; + v[1] = ((float *)pixels)[1]; + v[2] = ((float *)pixels)[2]; + if (fmt->bytes_per_pixel == 16) { + v[3] = ((float *)pixels)[3]; + } else { + v[3] = 1.0f; + } + break; + default: + // Unknown array type + v[0] = v[1] = v[2] = v[3] = 0.0f; + break; + } + switch (SDL_PIXELORDER(fmt->format)) { + case SDL_ARRAYORDER_RGB: + fR = v[0]; + fG = v[1]; + fB = v[2]; + fA = 1.0f; + break; + case SDL_ARRAYORDER_RGBA: + fR = v[0]; + fG = v[1]; + fB = v[2]; + fA = v[3]; + break; + case SDL_ARRAYORDER_ARGB: + fA = v[0]; + fR = v[1]; + fG = v[2]; + fB = v[3]; + break; + case SDL_ARRAYORDER_BGR: + fB = v[0]; + fG = v[1]; + fR = v[2]; + fA = 1.0f; + break; + case SDL_ARRAYORDER_BGRA: + fB = v[0]; + fG = v[1]; + fR = v[2]; + fA = v[3]; + break; + case SDL_ARRAYORDER_ABGR: + fA = v[0]; + fB = v[1]; + fG = v[2]; + fR = v[3]; + break; + default: + // Unknown array order + fA = fR = fG = fB = 0.0f; + break; + } + break; + } + + // Convert to nits so src and dst are guaranteed to be linear and in the same units + switch (SDL_COLORSPACETRANSFER(colorspace)) { + case SDL_TRANSFER_CHARACTERISTICS_SRGB: + fR = SDL_sRGBtoLinear(fR); + fG = SDL_sRGBtoLinear(fG); + fB = SDL_sRGBtoLinear(fB); + break; + case SDL_TRANSFER_CHARACTERISTICS_PQ: + fR = SDL_PQtoNits(fR) / SDR_white_point; + fG = SDL_PQtoNits(fG) / SDR_white_point; + fB = SDL_PQtoNits(fB) / SDR_white_point; + break; + case SDL_TRANSFER_CHARACTERISTICS_LINEAR: + fR /= SDR_white_point; + fG /= SDR_white_point; + fB /= SDR_white_point; + break; + default: + // Unknown, leave it alone + break; + } + + *outR = fR; + *outG = fG; + *outB = fB; + *outA = fA; +} + +static void WriteFloatPixel(Uint8 *pixels, SlowBlitPixelAccess access, const SDL_PixelFormatDetails *fmt, SDL_Colorspace colorspace, float SDR_white_point, + float fR, float fG, float fB, float fA) +{ + Uint32 R, G, B, A; + Uint32 pixel; + float v[4]; + + // We converted to nits so src and dst are guaranteed to be linear and in the same units + switch (SDL_COLORSPACETRANSFER(colorspace)) { + case SDL_TRANSFER_CHARACTERISTICS_SRGB: + fR = SDL_sRGBfromLinear(fR); + fG = SDL_sRGBfromLinear(fG); + fB = SDL_sRGBfromLinear(fB); + break; + case SDL_TRANSFER_CHARACTERISTICS_PQ: + fR = SDL_PQfromNits(fR * SDR_white_point); + fG = SDL_PQfromNits(fG * SDR_white_point); + fB = SDL_PQfromNits(fB * SDR_white_point); + break; + case SDL_TRANSFER_CHARACTERISTICS_LINEAR: + fR *= SDR_white_point; + fG *= SDR_white_point; + fB *= SDR_white_point; + break; + default: + // Unknown, leave it alone + break; + } + + switch (access) { + case SlowBlitPixelAccess_Index8: + // This should never happen, checked before this call + SDL_assert(0); + break; + case SlowBlitPixelAccess_RGB: + R = (Uint8)SDL_roundf(SDL_clamp(fR, 0.0f, 1.0f) * 255.0f); + G = (Uint8)SDL_roundf(SDL_clamp(fG, 0.0f, 1.0f) * 255.0f); + B = (Uint8)SDL_roundf(SDL_clamp(fB, 0.0f, 1.0f) * 255.0f); + ASSEMBLE_RGB(pixels, fmt->bytes_per_pixel, fmt, R, G, B); + break; + case SlowBlitPixelAccess_RGBA: + R = (Uint8)SDL_roundf(SDL_clamp(fR, 0.0f, 1.0f) * 255.0f); + G = (Uint8)SDL_roundf(SDL_clamp(fG, 0.0f, 1.0f) * 255.0f); + B = (Uint8)SDL_roundf(SDL_clamp(fB, 0.0f, 1.0f) * 255.0f); + A = (Uint8)SDL_roundf(SDL_clamp(fA, 0.0f, 1.0f) * 255.0f); + ASSEMBLE_RGBA(pixels, fmt->bytes_per_pixel, fmt, R, G, B, A); + break; + case SlowBlitPixelAccess_10Bit: + { + switch (fmt->format) { + case SDL_PIXELFORMAT_XRGB2101010: + fA = 1.0f; + SDL_FALLTHROUGH; + case SDL_PIXELFORMAT_ARGB2101010: + ARGB2101010_FROM_RGBAFLOAT(pixel, fR, fG, fB, fA); + break; + case SDL_PIXELFORMAT_XBGR2101010: + fA = 1.0f; + SDL_FALLTHROUGH; + case SDL_PIXELFORMAT_ABGR2101010: + ABGR2101010_FROM_RGBAFLOAT(pixel, fR, fG, fB, fA); + break; + default: + pixel = 0; + break; + } + *(Uint32 *)pixels = pixel; + break; + } + case SlowBlitPixelAccess_Large: + switch (SDL_PIXELORDER(fmt->format)) { + case SDL_ARRAYORDER_RGB: + v[0] = fR; + v[1] = fG; + v[2] = fB; + v[3] = 1.0f; + break; + case SDL_ARRAYORDER_RGBA: + v[0] = fR; + v[1] = fG; + v[2] = fB; + v[3] = fA; + break; + case SDL_ARRAYORDER_ARGB: + v[0] = fA; + v[1] = fR; + v[2] = fG; + v[3] = fB; + break; + case SDL_ARRAYORDER_BGR: + v[0] = fB; + v[1] = fG; + v[2] = fR; + v[3] = 1.0f; + break; + case SDL_ARRAYORDER_BGRA: + v[0] = fB; + v[1] = fG; + v[2] = fR; + v[3] = fA; + break; + case SDL_ARRAYORDER_ABGR: + v[0] = fA; + v[1] = fB; + v[2] = fG; + v[3] = fR; + break; + default: + // Unknown array order + v[0] = v[1] = v[2] = v[3] = 0.0f; + break; + } + switch (SDL_PIXELTYPE(fmt->format)) { + case SDL_PIXELTYPE_ARRAYU16: + ((Uint16 *)pixels)[0] = (Uint16)SDL_roundf(SDL_clamp(v[0], 0.0f, 1.0f) * SDL_MAX_UINT16); + ((Uint16 *)pixels)[1] = (Uint16)SDL_roundf(SDL_clamp(v[1], 0.0f, 1.0f) * SDL_MAX_UINT16); + ((Uint16 *)pixels)[2] = (Uint16)SDL_roundf(SDL_clamp(v[2], 0.0f, 1.0f) * SDL_MAX_UINT16); + if (fmt->bytes_per_pixel == 8) { + ((Uint16 *)pixels)[3] = (Uint16)SDL_roundf(SDL_clamp(v[3], 0.0f, 1.0f) * SDL_MAX_UINT16); + } + break; + case SDL_PIXELTYPE_ARRAYF16: + ((Uint16 *)pixels)[0] = float_to_half(v[0]); + ((Uint16 *)pixels)[1] = float_to_half(v[1]); + ((Uint16 *)pixels)[2] = float_to_half(v[2]); + if (fmt->bytes_per_pixel == 8) { + ((Uint16 *)pixels)[3] = float_to_half(v[3]); + } + break; + case SDL_PIXELTYPE_ARRAYF32: + ((float *)pixels)[0] = v[0]; + ((float *)pixels)[1] = v[1]; + ((float *)pixels)[2] = v[2]; + if (fmt->bytes_per_pixel == 16) { + ((float *)pixels)[3] = v[3]; + } + break; + default: + // Unknown array type + break; + } + break; + } +} + +typedef enum +{ + SDL_TONEMAP_NONE, + SDL_TONEMAP_LINEAR, + SDL_TONEMAP_CHROME +} SDL_TonemapOperator; + +typedef struct +{ + SDL_TonemapOperator op; + + union { + struct { + float scale; + } linear; + + struct { + float a; + float b; + const float *color_primaries_matrix; + } chrome; + + } data; + +} SDL_TonemapContext; + +static void TonemapLinear(float *r, float *g, float *b, float scale) +{ + *r *= scale; + *g *= scale; + *b *= scale; +} + +/* This uses the same tonemapping algorithm developed by Google for Chrome: + * https://colab.research.google.com/drive/1hI10nq6L6ru_UFvz7-f7xQaQp0qarz_K + * + * Essentially, you use the source headroom and the destination headroom + * to calculate scaling factors: + * tonemap_a = (dst_headroom / (src_headroom * src_headroom)); + * tonemap_b = (1.0f / dst_headroom); + * + * Then you normalize your source color by the HDR whitepoint, + * and calculate a final scaling factor in BT.2020 colorspace. + */ +static void TonemapChrome(float *r, float *g, float *b, float tonemap_a, float tonemap_b) +{ + float v1 = *r; + float v2 = *g; + float v3 = *b; + float vmax = SDL_max(v1, SDL_max(v2, v3)); + + if (vmax > 0.0f) { + float scale = (1.0f + tonemap_a * vmax) / (1.0f + tonemap_b * vmax); + TonemapLinear(r, g, b, scale); + } +} + +static void ApplyTonemap(SDL_TonemapContext *ctx, float *r, float *g, float *b) +{ + switch (ctx->op) { + case SDL_TONEMAP_LINEAR: + TonemapLinear(r, g, b, ctx->data.linear.scale); + break; + case SDL_TONEMAP_CHROME: + if (ctx->data.chrome.color_primaries_matrix) { + SDL_ConvertColorPrimaries(r, g, b, ctx->data.chrome.color_primaries_matrix); + } + TonemapChrome(r, g, b, ctx->data.chrome.a, ctx->data.chrome.b); + break; + default: + break; + } +} + +/* The SECOND TRUE BLITTER + * This one is even slower than the first, but also handles large pixel formats and colorspace conversion + */ +void SDL_Blit_Slow_Float(SDL_BlitInfo *info) +{ + const int flags = info->flags; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; + const Uint32 modulateA = info->a; + float srcR, srcG, srcB, srcA; + float dstR, dstG, dstB, dstA; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; + const SDL_PixelFormatDetails *src_fmt = info->src_fmt; + const SDL_Palette *src_pal = info->src_pal; + const SDL_PixelFormatDetails *dst_fmt = info->dst_fmt; + const SDL_Palette *dst_pal = info->dst_pal; + SDL_HashTable *palette_map = info->palette_map; + int srcbpp = src_fmt->bytes_per_pixel; + int dstbpp = dst_fmt->bytes_per_pixel; + SlowBlitPixelAccess src_access; + SlowBlitPixelAccess dst_access; + SDL_Colorspace src_colorspace; + SDL_Colorspace dst_colorspace; + SDL_ColorPrimaries src_primaries; + SDL_ColorPrimaries dst_primaries; + const float *color_primaries_matrix = NULL; + float src_white_point; + float dst_white_point; + float dst_headroom; + float src_headroom; + SDL_TonemapContext tonemap; + Uint32 last_pixel = 0; + Uint8 last_index = 0; + + src_colorspace = info->src_surface->colorspace; + dst_colorspace = info->dst_surface->colorspace; + src_primaries = SDL_COLORSPACEPRIMARIES(src_colorspace); + dst_primaries = SDL_COLORSPACEPRIMARIES(dst_colorspace); + + src_white_point = SDL_GetSurfaceSDRWhitePoint(info->src_surface, src_colorspace); + dst_white_point = SDL_GetSurfaceSDRWhitePoint(info->dst_surface, dst_colorspace); + src_headroom = SDL_GetSurfaceHDRHeadroom(info->src_surface, src_colorspace); + dst_headroom = SDL_GetSurfaceHDRHeadroom(info->dst_surface, dst_colorspace); + if (dst_headroom == 0.0f) { + // The destination will have the same headroom as the source + dst_headroom = src_headroom; + SDL_SetFloatProperty(SDL_GetSurfaceProperties(info->dst_surface), SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT, dst_headroom); + } + + SDL_zero(tonemap); + + if (src_headroom > dst_headroom) { + const char *tonemap_operator = SDL_GetStringProperty(SDL_GetSurfaceProperties(info->src_surface), SDL_PROP_SURFACE_TONEMAP_OPERATOR_STRING, NULL); + if (tonemap_operator) { + if (SDL_strncmp(tonemap_operator, "*=", 2) == 0) { + tonemap.op = SDL_TONEMAP_LINEAR; + tonemap.data.linear.scale = (float)SDL_atof(tonemap_operator + 2); + } else if (SDL_strcasecmp(tonemap_operator, "chrome") == 0) { + tonemap.op = SDL_TONEMAP_CHROME; + } else if (SDL_strcasecmp(tonemap_operator, "none") == 0) { + tonemap.op = SDL_TONEMAP_NONE; + } + } else { + tonemap.op = SDL_TONEMAP_CHROME; + } + if (tonemap.op == SDL_TONEMAP_CHROME) { + tonemap.data.chrome.a = (dst_headroom / (src_headroom * src_headroom)); + tonemap.data.chrome.b = (1.0f / dst_headroom); + + // We'll convert to BT.2020 primaries for the tonemap operation + tonemap.data.chrome.color_primaries_matrix = SDL_GetColorPrimariesConversionMatrix(src_primaries, SDL_COLOR_PRIMARIES_BT2020); + if (tonemap.data.chrome.color_primaries_matrix) { + src_primaries = SDL_COLOR_PRIMARIES_BT2020; + } + } + } + + if (src_primaries != dst_primaries) { + color_primaries_matrix = SDL_GetColorPrimariesConversionMatrix(src_primaries, dst_primaries); + } + + src_access = GetPixelAccessMethod(src_fmt->format); + dst_access = GetPixelAccessMethod(dst_fmt->format); + if (dst_access == SlowBlitPixelAccess_Index8) { + last_index = SDL_LookupRGBAColor(palette_map, last_pixel, dst_pal); + } + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; // start at the middle of pixel + + while (info->dst_h--) { + Uint8 *src = 0; + Uint8 *dst = info->dst; + int n = info->dst_w; + posx = incx / 2; // start at the middle of pixel + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = (info->src + (srcy * info->src_pitch) + (srcx * srcbpp)); + + ReadFloatPixel(src, src_access, src_fmt, src_pal, src_colorspace, src_white_point, &srcR, &srcG, &srcB, &srcA); + + if (tonemap.op) { + ApplyTonemap(&tonemap, &srcR, &srcG, &srcB); + } + + if (color_primaries_matrix) { + SDL_ConvertColorPrimaries(&srcR, &srcG, &srcB, color_primaries_matrix); + } + + if (flags & SDL_COPY_COLORKEY) { + // colorkey isn't supported + } + if ((flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL))) { + ReadFloatPixel(dst, dst_access, dst_fmt, dst_pal, dst_colorspace, dst_white_point, &dstR, &dstG, &dstB, &dstA); + } else { + // don't care + dstR = dstG = dstB = dstA = 0.0f; + } + + if (flags & SDL_COPY_MODULATE_COLOR) { + srcR = (srcR * modulateR) / 255; + srcG = (srcG * modulateG) / 255; + srcB = (srcB * modulateB) / 255; + } + if (flags & SDL_COPY_MODULATE_ALPHA) { + srcA = (srcA * modulateA) / 255; + } + if (flags & (SDL_COPY_BLEND | SDL_COPY_ADD)) { + if (srcA < 1.0f) { + srcR = (srcR * srcA); + srcG = (srcG * srcA); + srcB = (srcB * srcA); + } + } + switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL)) { + case 0: + dstR = srcR; + dstG = srcG; + dstB = srcB; + dstA = srcA; + break; + case SDL_COPY_BLEND: + dstR = srcR + ((1.0f - srcA) * dstR); + dstG = srcG + ((1.0f - srcA) * dstG); + dstB = srcB + ((1.0f - srcA) * dstB); + dstA = srcA + ((1.0f - srcA) * dstA); + break; + case SDL_COPY_ADD: + dstR = srcR + dstR; + dstG = srcG + dstG; + dstB = srcB + dstB; + break; + case SDL_COPY_MOD: + dstR = (srcR * dstR); + dstG = (srcG * dstG); + dstB = (srcB * dstB); + break; + case SDL_COPY_MUL: + dstR = ((srcR * dstR) + (dstR * (1.0f - srcA))); + dstG = ((srcG * dstG) + (dstG * (1.0f - srcA))); + dstB = ((srcB * dstB) + (dstB * (1.0f - srcA))); + break; + } + + if (dst_access == SlowBlitPixelAccess_Index8) { + Uint32 R = (Uint8)SDL_roundf(SDL_clamp(SDL_sRGBfromLinear(dstR), 0.0f, 1.0f) * 255.0f); + Uint32 G = (Uint8)SDL_roundf(SDL_clamp(SDL_sRGBfromLinear(dstG), 0.0f, 1.0f) * 255.0f); + Uint32 B = (Uint8)SDL_roundf(SDL_clamp(SDL_sRGBfromLinear(dstB), 0.0f, 1.0f) * 255.0f); + Uint32 A = (Uint8)SDL_roundf(SDL_clamp(dstA, 0.0f, 1.0f) * 255.0f); + Uint32 dstpixel = ((R << 24) | (G << 16) | (B << 8) | A); + if (dstpixel != last_pixel) { + last_pixel = dstpixel; + last_index = SDL_LookupRGBAColor(palette_map, dstpixel, dst_pal); + } + *dst = last_index; + } else { + WriteFloatPixel(dst, dst_access, dst_fmt, dst_colorspace, dst_white_point, dstR, dstG, dstB, dstA); + } + + posx += incx; + dst += dstbpp; + } + posy += incy; + info->dst += info->dst_pitch; + } +} + diff --git a/contrib/SDL-3.2.8/src/video/SDL_blit_slow.h b/contrib/SDL-3.2.8/src/video/SDL_blit_slow.h new file mode 100644 index 0000000..d886713 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_blit_slow.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_blit_slow_h_ +#define SDL_blit_slow_h_ + +#include "SDL_internal.h" + +extern void SDL_Blit_Slow(SDL_BlitInfo *info); +extern void SDL_Blit_Slow_Float(SDL_BlitInfo *info); + +#endif // SDL_blit_slow_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_bmp.c b/contrib/SDL-3.2.8/src/video/SDL_bmp.c new file mode 100644 index 0000000..688086f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_bmp.c @@ -0,0 +1,879 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +/* + Code to load and save surfaces in Windows BMP format. + + Why support BMP format? Well, it's a native format for Windows, and + most image processing programs can read and write it. It would be nice + to be able to have at least one image format that we can natively load + and save, and since PNG is so complex that it would bloat the library, + BMP is a good alternative. + + This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp. +*/ + +#include "SDL_pixels_c.h" +#include "SDL_surface_c.h" + +#define SAVE_32BIT_BMP + +// Compression encodings for BMP files +#ifndef BI_RGB +#define BI_RGB 0 +#define BI_RLE8 1 +#define BI_RLE4 2 +#define BI_BITFIELDS 3 +#endif + +// Logical color space values for BMP files +// https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wmf/eb4bbd50-b3ce-4917-895c-be31f214797f +#ifndef LCS_WINDOWS_COLOR_SPACE +// 0x57696E20 == "Win " +#define LCS_WINDOWS_COLOR_SPACE 0x57696E20 +#endif + +#ifndef LCS_sRGB +// 0x73524742 == "sRGB" +#define LCS_sRGB 0x73524742 +#endif + +// Logical/physical color relationship +// https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wmf/9fec0834-607d-427d-abd5-ab240fb0db38 +#ifndef LCS_GM_GRAPHICS +#define LCS_GM_GRAPHICS 0x00000002 +#endif + +static bool readRlePixels(SDL_Surface *surface, SDL_IOStream *src, int isRle8) +{ + /* + | Sets the surface pixels from src. A bmp image is upside down. + */ + int pitch = surface->pitch; + int height = surface->h; + Uint8 *start = (Uint8 *)surface->pixels; + Uint8 *end = start + (height * pitch); + Uint8 *bits = end - pitch, *spot; + int ofs = 0; + Uint8 ch; + Uint8 needsPad; + const int pixels_per_byte = (isRle8 ? 1 : 2); + +#define COPY_PIXEL(x) \ + spot = &bits[ofs++]; \ + if (spot >= start && spot < end) \ + *spot = (x) + + for (;;) { + if (!SDL_ReadU8(src, &ch)) { + return false; + } + /* + | encoded mode starts with a run length, and then a byte + | with two colour indexes to alternate between for the run + */ + if (ch) { + Uint8 pixel; + if (!SDL_ReadU8(src, &pixel)) { + return false; + } + ch /= pixels_per_byte; + do { + COPY_PIXEL(pixel); + } while (--ch); + } else { + /* + | A leading zero is an escape; it may signal the end of the bitmap, + | a cursor move, or some absolute data. + | zero tag may be absolute mode or an escape + */ + if (!SDL_ReadU8(src, &ch)) { + return false; + } + switch (ch) { + case 0: // end of line + ofs = 0; + bits -= pitch; // go to previous + break; + case 1: // end of bitmap + return true; // success! + case 2: // delta + if (!SDL_ReadU8(src, &ch)) { + return false; + } + ofs += ch / pixels_per_byte; + + if (!SDL_ReadU8(src, &ch)) { + return false; + } + bits -= ((ch / pixels_per_byte) * pitch); + break; + default: // no compression + ch /= pixels_per_byte; + needsPad = (ch & 1); + do { + Uint8 pixel; + if (!SDL_ReadU8(src, &pixel)) { + return false; + } + COPY_PIXEL(pixel); + } while (--ch); + + // pad at even boundary + if (needsPad && !SDL_ReadU8(src, &ch)) { + return false; + } + break; + } + } + } +} + +static void CorrectAlphaChannel(SDL_Surface *surface) +{ + // Check to see if there is any alpha channel data + bool hasAlpha = false; +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + int alphaChannelOffset = 0; +#else + int alphaChannelOffset = 3; +#endif + Uint8 *alpha = ((Uint8 *)surface->pixels) + alphaChannelOffset; + Uint8 *end = alpha + surface->h * surface->pitch; + + while (alpha < end) { + if (*alpha != 0) { + hasAlpha = true; + break; + } + alpha += 4; + } + + if (!hasAlpha) { + alpha = ((Uint8 *)surface->pixels) + alphaChannelOffset; + while (alpha < end) { + *alpha = SDL_ALPHA_OPAQUE; + alpha += 4; + } + } +} + +SDL_Surface *SDL_LoadBMP_IO(SDL_IOStream *src, bool closeio) +{ + bool was_error = true; + Sint64 fp_offset = 0; + int i, pad; + SDL_Surface *surface; + Uint32 Rmask = 0; + Uint32 Gmask = 0; + Uint32 Bmask = 0; + Uint32 Amask = 0; + Uint8 *bits; + Uint8 *top, *end; + bool topDown; + bool haveRGBMasks = false; + bool haveAlphaMask = false; + bool correctAlpha = false; + + // The Win32 BMP file header (14 bytes) + char magic[2]; + // Uint32 bfSize; + // Uint16 bfReserved1; + // Uint16 bfReserved2; + Uint32 bfOffBits; + + // The Win32 BITMAPINFOHEADER struct (40 bytes) + Uint32 biSize; + Sint32 biWidth = 0; + Sint32 biHeight = 0; + // Uint16 biPlanes; + Uint16 biBitCount = 0; + Uint32 biCompression = 0; + // Uint32 biSizeImage; + // Sint32 biXPelsPerMeter; + // Sint32 biYPelsPerMeter; + Uint32 biClrUsed = 0; + // Uint32 biClrImportant; + + // Make sure we are passed a valid data source + surface = NULL; + if (!src) { + SDL_InvalidParamError("src"); + goto done; + } + + // Read in the BMP file header + fp_offset = SDL_TellIO(src); + if (fp_offset < 0) { + goto done; + } + SDL_ClearError(); + if (SDL_ReadIO(src, magic, 2) != 2) { + goto done; + } + if (SDL_strncmp(magic, "BM", 2) != 0) { + SDL_SetError("File is not a Windows BMP file"); + goto done; + } + if (!SDL_ReadU32LE(src, NULL /* bfSize */) || + !SDL_ReadU16LE(src, NULL /* bfReserved1 */) || + !SDL_ReadU16LE(src, NULL /* bfReserved2 */) || + !SDL_ReadU32LE(src, &bfOffBits)) { + goto done; + } + + // Read the Win32 BITMAPINFOHEADER + if (!SDL_ReadU32LE(src, &biSize)) { + goto done; + } + if (biSize == 12) { // really old BITMAPCOREHEADER + Uint16 biWidth16, biHeight16; + if (!SDL_ReadU16LE(src, &biWidth16) || + !SDL_ReadU16LE(src, &biHeight16) || + !SDL_ReadU16LE(src, NULL /* biPlanes */) || + !SDL_ReadU16LE(src, &biBitCount)) { + goto done; + } + biWidth = biWidth16; + biHeight = biHeight16; + biCompression = BI_RGB; + // biSizeImage = 0; + // biXPelsPerMeter = 0; + // biYPelsPerMeter = 0; + biClrUsed = 0; + // biClrImportant = 0; + } else if (biSize >= 40) { // some version of BITMAPINFOHEADER + Uint32 headerSize; + if (!SDL_ReadS32LE(src, &biWidth) || + !SDL_ReadS32LE(src, &biHeight) || + !SDL_ReadU16LE(src, NULL /* biPlanes */) || + !SDL_ReadU16LE(src, &biBitCount) || + !SDL_ReadU32LE(src, &biCompression) || + !SDL_ReadU32LE(src, NULL /* biSizeImage */) || + !SDL_ReadU32LE(src, NULL /* biXPelsPerMeter */) || + !SDL_ReadU32LE(src, NULL /* biYPelsPerMeter */) || + !SDL_ReadU32LE(src, &biClrUsed) || + !SDL_ReadU32LE(src, NULL /* biClrImportant */)) { + goto done; + } + + // 64 == BITMAPCOREHEADER2, an incompatible OS/2 2.x extension. Skip this stuff for now. + if (biSize != 64) { + /* This is complicated. If compression is BI_BITFIELDS, then + we have 3 DWORDS that specify the RGB masks. This is either + stored here in an BITMAPV2INFOHEADER (which only differs in + that it adds these RGB masks) and biSize >= 52, or we've got + these masks stored in the exact same place, but strictly + speaking, this is the bmiColors field in BITMAPINFO immediately + following the legacy v1 info header, just past biSize. */ + if (biCompression == BI_BITFIELDS) { + haveRGBMasks = true; + if (!SDL_ReadU32LE(src, &Rmask) || + !SDL_ReadU32LE(src, &Gmask) || + !SDL_ReadU32LE(src, &Bmask)) { + goto done; + } + + // ...v3 adds an alpha mask. + if (biSize >= 56) { // BITMAPV3INFOHEADER; adds alpha mask + haveAlphaMask = true; + if (!SDL_ReadU32LE(src, &Amask)) { + goto done; + } + } + } else { + // the mask fields are ignored for v2+ headers if not BI_BITFIELD. + if (biSize >= 52) { // BITMAPV2INFOHEADER; adds RGB masks + if (!SDL_ReadU32LE(src, NULL /* Rmask */) || + !SDL_ReadU32LE(src, NULL /* Gmask */) || + !SDL_ReadU32LE(src, NULL /* Bmask */)) { + goto done; + } + } + if (biSize >= 56) { // BITMAPV3INFOHEADER; adds alpha mask + if (!SDL_ReadU32LE(src, NULL /* Amask */)) { + goto done; + } + } + } + + /* Insert other fields here; Wikipedia and MSDN say we're up to + v5 of this header, but we ignore those for now (they add gamma, + color spaces, etc). Ignoring the weird OS/2 2.x format, we + currently parse up to v3 correctly (hopefully!). */ + } + + // skip any header bytes we didn't handle... + headerSize = (Uint32)(SDL_TellIO(src) - (fp_offset + 14)); + if (biSize > headerSize) { + if (SDL_SeekIO(src, (biSize - headerSize), SDL_IO_SEEK_CUR) < 0) { + goto done; + } + } + } + if (biWidth <= 0 || biHeight == 0) { + SDL_SetError("BMP file with bad dimensions (%" SDL_PRIs32 "x%" SDL_PRIs32 ")", biWidth, biHeight); + goto done; + } + if (biHeight < 0) { + topDown = true; + biHeight = -biHeight; + } else { + topDown = false; + } + + // Check for read error + if (SDL_strcmp(SDL_GetError(), "") != 0) { + goto done; + } + + // Reject invalid bit depths + switch (biBitCount) { + case 0: + case 3: + case 5: + case 6: + case 7: + SDL_SetError("%u bpp BMP images are not supported", biBitCount); + goto done; + default: + break; + } + + // RLE4 and RLE8 BMP compression is supported + switch (biCompression) { + case BI_RGB: + // If there are no masks, use the defaults + SDL_assert(!haveRGBMasks); + SDL_assert(!haveAlphaMask); + // Default values for the BMP format + switch (biBitCount) { + case 15: + case 16: + // SDL_PIXELFORMAT_XRGB1555 or SDL_PIXELFORMAT_ARGB1555 if Amask + Rmask = 0x7C00; + Gmask = 0x03E0; + Bmask = 0x001F; + break; + case 24: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + // SDL_PIXELFORMAT_RGB24 + Rmask = 0x000000FF; + Gmask = 0x0000FF00; + Bmask = 0x00FF0000; +#else + // SDL_PIXELFORMAT_BGR24 + Rmask = 0x00FF0000; + Gmask = 0x0000FF00; + Bmask = 0x000000FF; +#endif + break; + case 32: + // We don't know if this has alpha channel or not + correctAlpha = true; + // SDL_PIXELFORMAT_RGBA8888 + Amask = 0xFF000000; + Rmask = 0x00FF0000; + Gmask = 0x0000FF00; + Bmask = 0x000000FF; + break; + default: + break; + } + break; + + case BI_BITFIELDS: + break; // we handled this in the info header. + + default: + break; + } + + // Create a compatible surface, note that the colors are RGB ordered + { + SDL_PixelFormat format; + + // Get the pixel format + format = SDL_GetPixelFormatForMasks(biBitCount, Rmask, Gmask, Bmask, Amask); + surface = SDL_CreateSurface(biWidth, biHeight, format); + + if (!surface) { + goto done; + } + } + + // Load the palette, if any + if (SDL_ISPIXELFORMAT_INDEXED(surface->format)) { + SDL_Palette *palette = SDL_CreateSurfacePalette(surface); + if (!palette) { + goto done; + } + + if (SDL_SeekIO(src, fp_offset + 14 + biSize, SDL_IO_SEEK_SET) < 0) { + SDL_SetError("Error seeking in datastream"); + goto done; + } + + if (biBitCount >= 32) { // we shift biClrUsed by this value later. + SDL_SetError("Unsupported or incorrect biBitCount field"); + goto done; + } + + if (biClrUsed == 0) { + biClrUsed = 1 << biBitCount; + } + + if (biClrUsed > (Uint32)palette->ncolors) { + biClrUsed = 1 << biBitCount; // try forcing it? + if (biClrUsed > (Uint32)palette->ncolors) { + SDL_SetError("Unsupported or incorrect biClrUsed field"); + goto done; + } + } + palette->ncolors = biClrUsed; + + if (biSize == 12) { + for (i = 0; i < palette->ncolors; ++i) { + if (!SDL_ReadU8(src, &palette->colors[i].b) || + !SDL_ReadU8(src, &palette->colors[i].g) || + !SDL_ReadU8(src, &palette->colors[i].r)) { + goto done; + } + palette->colors[i].a = SDL_ALPHA_OPAQUE; + } + } else { + for (i = 0; i < palette->ncolors; ++i) { + if (!SDL_ReadU8(src, &palette->colors[i].b) || + !SDL_ReadU8(src, &palette->colors[i].g) || + !SDL_ReadU8(src, &palette->colors[i].r) || + !SDL_ReadU8(src, &palette->colors[i].a)) { + goto done; + } + + /* According to Microsoft documentation, the fourth element + is reserved and must be zero, so we shouldn't treat it as + alpha. + */ + palette->colors[i].a = SDL_ALPHA_OPAQUE; + } + } + } + + // Read the surface pixels. Note that the bmp image is upside down + if (SDL_SeekIO(src, fp_offset + bfOffBits, SDL_IO_SEEK_SET) < 0) { + SDL_SetError("Error seeking in datastream"); + goto done; + } + if ((biCompression == BI_RLE4) || (biCompression == BI_RLE8)) { + if (!readRlePixels(surface, src, biCompression == BI_RLE8)) { + SDL_SetError("Error reading from datastream"); + goto done; + } + + // Success! + was_error = false; + goto done; + } + top = (Uint8 *)surface->pixels; + end = (Uint8 *)surface->pixels + (surface->h * surface->pitch); + pad = ((surface->pitch % 4) ? (4 - (surface->pitch % 4)) : 0); + if (topDown) { + bits = top; + } else { + bits = end - surface->pitch; + } + while (bits >= top && bits < end) { + if (SDL_ReadIO(src, bits, surface->pitch) != (size_t)surface->pitch) { + goto done; + } + if (biBitCount == 8 && surface->palette && biClrUsed < (1u << biBitCount)) { + for (i = 0; i < surface->w; ++i) { + if (bits[i] >= biClrUsed) { + SDL_SetError("A BMP image contains a pixel with a color out of the palette"); + goto done; + } + } + } +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + /* Byte-swap the pixels if needed. Note that the 24bpp + case has already been taken care of above. */ + switch (biBitCount) { + case 15: + case 16: + { + Uint16 *pix = (Uint16 *)bits; + for (i = 0; i < surface->w; i++) { + pix[i] = SDL_Swap16(pix[i]); + } + break; + } + + case 32: + { + Uint32 *pix = (Uint32 *)bits; + for (i = 0; i < surface->w; i++) { + pix[i] = SDL_Swap32(pix[i]); + } + break; + } + } +#endif + + // Skip padding bytes, ugh + if (pad) { + Uint8 padbyte; + for (i = 0; i < pad; ++i) { + if (!SDL_ReadU8(src, &padbyte)) { + goto done; + } + } + } + if (topDown) { + bits += surface->pitch; + } else { + bits -= surface->pitch; + } + } + if (correctAlpha) { + CorrectAlphaChannel(surface); + } + + was_error = false; + +done: + if (was_error) { + if (src) { + SDL_SeekIO(src, fp_offset, SDL_IO_SEEK_SET); + } + SDL_DestroySurface(surface); + surface = NULL; + } + if (closeio && src) { + SDL_CloseIO(src); + } + return surface; +} + +SDL_Surface *SDL_LoadBMP(const char *file) +{ + SDL_IOStream *stream = SDL_IOFromFile(file, "rb"); + if (!stream) { + return NULL; + } + return SDL_LoadBMP_IO(stream, true); +} + +bool SDL_SaveBMP_IO(SDL_Surface *surface, SDL_IOStream *dst, bool closeio) +{ + bool was_error = true; + Sint64 fp_offset, new_offset; + int i, pad; + SDL_Surface *intermediate_surface = NULL; + Uint8 *bits; + bool save32bit = false; + bool saveLegacyBMP = false; + + // The Win32 BMP file header (14 bytes) + char magic[2] = { 'B', 'M' }; + Uint32 bfSize; + Uint16 bfReserved1; + Uint16 bfReserved2; + Uint32 bfOffBits; + + // The Win32 BITMAPINFOHEADER struct (40 bytes) + Uint32 biSize; + Sint32 biWidth; + Sint32 biHeight; + Uint16 biPlanes; + Uint16 biBitCount; + Uint32 biCompression; + Uint32 biSizeImage; + Sint32 biXPelsPerMeter; + Sint32 biYPelsPerMeter; + Uint32 biClrUsed; + Uint32 biClrImportant; + + // The additional header members from the Win32 BITMAPV4HEADER struct (108 bytes in total) + Uint32 bV4RedMask = 0; + Uint32 bV4GreenMask = 0; + Uint32 bV4BlueMask = 0; + Uint32 bV4AlphaMask = 0; + Uint32 bV4CSType = 0; + Sint32 bV4Endpoints[3 * 3] = { 0 }; + Uint32 bV4GammaRed = 0; + Uint32 bV4GammaGreen = 0; + Uint32 bV4GammaBlue = 0; + + // The additional header members from the Win32 BITMAPV5HEADER struct (124 bytes in total) + Uint32 bV5Intent = 0; + Uint32 bV5ProfileData = 0; + Uint32 bV5ProfileSize = 0; + Uint32 bV5Reserved = 0; + + // Make sure we have somewhere to save + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + goto done; + } + if (!dst) { + SDL_InvalidParamError("dst"); + goto done; + } + +#ifdef SAVE_32BIT_BMP + // We can save alpha information in a 32-bit BMP + if (SDL_BITSPERPIXEL(surface->format) >= 8 && + (SDL_ISPIXELFORMAT_ALPHA(surface->format) || + surface->map.info.flags & SDL_COPY_COLORKEY)) { + save32bit = true; + } +#endif // SAVE_32BIT_BMP + + if (surface->palette && !save32bit) { + if (SDL_BITSPERPIXEL(surface->format) == 8) { + intermediate_surface = surface; + } else { + SDL_SetError("%u bpp BMP files not supported", + SDL_BITSPERPIXEL(surface->format)); + goto done; + } + } else if ((surface->format == SDL_PIXELFORMAT_BGR24 && !save32bit) || + (surface->format == SDL_PIXELFORMAT_BGRA32 && save32bit)) { + intermediate_surface = surface; + } else { + SDL_PixelFormat pixel_format; + + /* If the surface has a colorkey or alpha channel we'll save a + 32-bit BMP with alpha channel, otherwise save a 24-bit BMP. */ + if (save32bit) { + pixel_format = SDL_PIXELFORMAT_BGRA32; + } else { + pixel_format = SDL_PIXELFORMAT_BGR24; + } + intermediate_surface = SDL_ConvertSurface(surface, pixel_format); + if (!intermediate_surface) { + SDL_SetError("Couldn't convert image to %d bpp", + (int)SDL_BITSPERPIXEL(pixel_format)); + goto done; + } + } + + if (save32bit) { + saveLegacyBMP = SDL_GetHintBoolean(SDL_HINT_BMP_SAVE_LEGACY_FORMAT, false); + } + + if (SDL_LockSurface(intermediate_surface)) { + const size_t bw = intermediate_surface->w * intermediate_surface->fmt->bytes_per_pixel; + + // Set the BMP file header values + bfSize = 0; // We'll write this when we're done + bfReserved1 = 0; + bfReserved2 = 0; + bfOffBits = 0; // We'll write this when we're done + + // Write the BMP file header values + fp_offset = SDL_TellIO(dst); + if (fp_offset < 0) { + goto done; + } + if (SDL_WriteIO(dst, magic, 2) != 2 || + !SDL_WriteU32LE(dst, bfSize) || + !SDL_WriteU16LE(dst, bfReserved1) || + !SDL_WriteU16LE(dst, bfReserved2) || + !SDL_WriteU32LE(dst, bfOffBits)) { + goto done; + } + + // Set the BMP info values + biSize = 40; + biWidth = intermediate_surface->w; + biHeight = intermediate_surface->h; + biPlanes = 1; + biBitCount = intermediate_surface->fmt->bits_per_pixel; + biCompression = BI_RGB; + biSizeImage = intermediate_surface->h * intermediate_surface->pitch; + biXPelsPerMeter = 0; + biYPelsPerMeter = 0; + if (intermediate_surface->palette) { + biClrUsed = intermediate_surface->palette->ncolors; + } else { + biClrUsed = 0; + } + biClrImportant = 0; + + // Set the BMP info values + if (save32bit && !saveLegacyBMP) { + biSize = 124; + // Version 4 values + biCompression = BI_BITFIELDS; + // The BMP format is always little endian, these masks stay the same + bV4RedMask = 0x00ff0000; + bV4GreenMask = 0x0000ff00; + bV4BlueMask = 0x000000ff; + bV4AlphaMask = 0xff000000; + bV4CSType = LCS_sRGB; + bV4GammaRed = 0; + bV4GammaGreen = 0; + bV4GammaBlue = 0; + // Version 5 values + bV5Intent = LCS_GM_GRAPHICS; + bV5ProfileData = 0; + bV5ProfileSize = 0; + bV5Reserved = 0; + } + + // Write the BMP info values + if (!SDL_WriteU32LE(dst, biSize) || + !SDL_WriteS32LE(dst, biWidth) || + !SDL_WriteS32LE(dst, biHeight) || + !SDL_WriteU16LE(dst, biPlanes) || + !SDL_WriteU16LE(dst, biBitCount) || + !SDL_WriteU32LE(dst, biCompression) || + !SDL_WriteU32LE(dst, biSizeImage) || + !SDL_WriteU32LE(dst, biXPelsPerMeter) || + !SDL_WriteU32LE(dst, biYPelsPerMeter) || + !SDL_WriteU32LE(dst, biClrUsed) || + !SDL_WriteU32LE(dst, biClrImportant)) { + goto done; + } + + // Write the BMP info values + if (save32bit && !saveLegacyBMP) { + // Version 4 values + if (!SDL_WriteU32LE(dst, bV4RedMask) || + !SDL_WriteU32LE(dst, bV4GreenMask) || + !SDL_WriteU32LE(dst, bV4BlueMask) || + !SDL_WriteU32LE(dst, bV4AlphaMask) || + !SDL_WriteU32LE(dst, bV4CSType)) { + goto done; + } + for (i = 0; i < 3 * 3; i++) { + if (!SDL_WriteU32LE(dst, bV4Endpoints[i])) { + goto done; + } + } + if (!SDL_WriteU32LE(dst, bV4GammaRed) || + !SDL_WriteU32LE(dst, bV4GammaGreen) || + !SDL_WriteU32LE(dst, bV4GammaBlue)) { + goto done; + } + // Version 5 values + if (!SDL_WriteU32LE(dst, bV5Intent) || + !SDL_WriteU32LE(dst, bV5ProfileData) || + !SDL_WriteU32LE(dst, bV5ProfileSize) || + !SDL_WriteU32LE(dst, bV5Reserved)) { + goto done; + } + } + + // Write the palette (in BGR color order) + if (intermediate_surface->palette) { + SDL_Color *colors; + int ncolors; + + colors = intermediate_surface->palette->colors; + ncolors = intermediate_surface->palette->ncolors; + for (i = 0; i < ncolors; ++i) { + if (!SDL_WriteU8(dst, colors[i].b) || + !SDL_WriteU8(dst, colors[i].g) || + !SDL_WriteU8(dst, colors[i].r) || + !SDL_WriteU8(dst, colors[i].a)) { + goto done; + } + } + } + + // Write the bitmap offset + bfOffBits = (Uint32)(SDL_TellIO(dst) - fp_offset); + if (SDL_SeekIO(dst, fp_offset + 10, SDL_IO_SEEK_SET) < 0) { + goto done; + } + if (!SDL_WriteU32LE(dst, bfOffBits)) { + goto done; + } + if (SDL_SeekIO(dst, fp_offset + bfOffBits, SDL_IO_SEEK_SET) < 0) { + goto done; + } + + // Write the bitmap image upside down + bits = (Uint8 *)intermediate_surface->pixels + (intermediate_surface->h * intermediate_surface->pitch); + pad = ((bw % 4) ? (4 - (bw % 4)) : 0); + while (bits > (Uint8 *)intermediate_surface->pixels) { + bits -= intermediate_surface->pitch; + if (SDL_WriteIO(dst, bits, bw) != bw) { + goto done; + } + if (pad) { + const Uint8 padbyte = 0; + for (i = 0; i < pad; ++i) { + if (!SDL_WriteU8(dst, padbyte)) { + goto done; + } + } + } + } + + // Write the BMP file size + new_offset = SDL_TellIO(dst); + if (new_offset < 0) { + goto done; + } + bfSize = (Uint32)(new_offset - fp_offset); + if (SDL_SeekIO(dst, fp_offset + 2, SDL_IO_SEEK_SET) < 0) { + goto done; + } + if (!SDL_WriteU32LE(dst, bfSize)) { + goto done; + } + if (SDL_SeekIO(dst, fp_offset + bfSize, SDL_IO_SEEK_SET) < 0) { + goto done; + } + + // Close it up.. + SDL_UnlockSurface(intermediate_surface); + + was_error = false; + } + +done: + if (intermediate_surface && intermediate_surface != surface) { + SDL_DestroySurface(intermediate_surface); + } + if (closeio && dst) { + if (!SDL_CloseIO(dst)) { + was_error = true; + } + } + if (was_error) { + return false; + } + return true; +} + +bool SDL_SaveBMP(SDL_Surface *surface, const char *file) +{ + SDL_IOStream *stream = SDL_IOFromFile(file, "wb"); + if (!stream) { + return false; + } + return SDL_SaveBMP_IO(surface, stream, true); +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_clipboard.c b/contrib/SDL-3.2.8/src/video/SDL_clipboard.c new file mode 100644 index 0000000..105c288 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_clipboard.c @@ -0,0 +1,474 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_clipboard_c.h" +#include "SDL_sysvideo.h" +#include "../events/SDL_events_c.h" +#include "../events/SDL_clipboardevents_c.h" + +void SDL_FreeClipboardMimeTypes(SDL_VideoDevice *_this) +{ + if (_this->clipboard_mime_types) { + for (size_t i = 0; i < _this->num_clipboard_mime_types; ++i) { + SDL_free(_this->clipboard_mime_types[i]); + } + SDL_free(_this->clipboard_mime_types); + _this->clipboard_mime_types = NULL; + _this->num_clipboard_mime_types = 0; + } +} + + +void SDL_CancelClipboardData(Uint32 sequence) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (sequence && sequence != _this->clipboard_sequence) { + // This clipboard data was already canceled + return; + } + + if (_this->clipboard_cleanup) { + _this->clipboard_cleanup(_this->clipboard_userdata); + } + + SDL_FreeClipboardMimeTypes(_this); + + _this->clipboard_callback = NULL; + _this->clipboard_cleanup = NULL; + _this->clipboard_userdata = NULL; +} + +bool SDL_SaveClipboardMimeTypes(const char **mime_types, size_t num_mime_types) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + SDL_FreeClipboardMimeTypes(_this); + + if (mime_types && num_mime_types > 0) { + size_t num_allocated = 0; + + _this->clipboard_mime_types = (char **)SDL_malloc(num_mime_types * sizeof(char *)); + if (_this->clipboard_mime_types) { + for (size_t i = 0; i < num_mime_types; ++i) { + _this->clipboard_mime_types[i] = SDL_strdup(mime_types[i]); + if (_this->clipboard_mime_types[i]) { + ++num_allocated; + } + } + } + if (num_allocated < num_mime_types) { + SDL_FreeClipboardMimeTypes(_this); + return false; + } + _this->num_clipboard_mime_types = num_mime_types; + } + return true; +} + +bool SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanupCallback cleanup, void *userdata, const char **mime_types, size_t num_mime_types) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (!_this) { + return SDL_UninitializedVideo(); + } + + // Parameter validation + if (!((callback && mime_types && num_mime_types > 0) || + (!callback && !mime_types && num_mime_types == 0))) { + return SDL_SetError("Invalid parameters"); + } + + SDL_CancelClipboardData(0); + + ++_this->clipboard_sequence; + if (!_this->clipboard_sequence) { + _this->clipboard_sequence = 1; + } + _this->clipboard_callback = callback; + _this->clipboard_cleanup = cleanup; + _this->clipboard_userdata = userdata; + + if (!SDL_SaveClipboardMimeTypes(mime_types, num_mime_types)) { + SDL_ClearClipboardData(); + return false; + } + + if (_this->SetClipboardData) { + if (!_this->SetClipboardData(_this)) { + return false; + } + } else if (_this->SetClipboardText) { + char *text = NULL; + size_t size; + + for (size_t i = 0; i < num_mime_types; ++i) { + const char *mime_type = _this->clipboard_mime_types[i]; + if (SDL_IsTextMimeType(mime_type)) { + const void *data = _this->clipboard_callback(_this->clipboard_userdata, mime_type, &size); + if (data) { + text = (char *)SDL_malloc(size + 1); + SDL_memcpy(text, data, size); + text[size] = '\0'; + if (!_this->SetClipboardText(_this, text)) { + SDL_free(text); + return false; + } + break; + } + } + } + if (text) { + SDL_free(text); + } else { + if (!_this->SetClipboardText(_this, "")) { + return false; + } + } + } + + char **mime_types_copy = SDL_CopyClipboardMimeTypes(mime_types, num_mime_types, true); + if (!mime_types_copy) + return SDL_SetError("unable to copy current mime types"); + + SDL_SendClipboardUpdate(true, mime_types_copy, num_mime_types); + return true; +} + +bool SDL_ClearClipboardData(void) +{ + return SDL_SetClipboardData(NULL, NULL, NULL, NULL, 0); +} + +void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size) +{ + void *data = NULL; + + if (_this->clipboard_callback) { + const void *provided_data = _this->clipboard_callback(_this->clipboard_userdata, mime_type, size); + if (provided_data) { + // Make a copy of it for the caller and guarantee null termination + data = SDL_malloc(*size + sizeof(Uint32)); + if (data) { + SDL_memcpy(data, provided_data, *size); + SDL_memset((Uint8 *)data + *size, 0, sizeof(Uint32)); + } + } + } + return data; +} + +void *SDL_GetClipboardData(const char *mime_type, size_t *size) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + size_t unused; + + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + + if (!mime_type) { + SDL_InvalidParamError("mime_type"); + return NULL; + } + if (!size) { + size = &unused; + } + + // Initialize size to empty, so implementations don't have to worry about it + *size = 0; + + if (_this->GetClipboardData) { + return _this->GetClipboardData(_this, mime_type, size); + } else if (_this->GetClipboardText && SDL_IsTextMimeType(mime_type)) { + char *text = _this->GetClipboardText(_this); + if (text) { + if (*text == '\0') { + SDL_free(text); + text = NULL; + } else { + *size = SDL_strlen(text); + } + } + return text; + } else { + return SDL_GetInternalClipboardData(_this, mime_type, size); + } +} + +bool SDL_HasInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type) +{ + size_t i; + + for (i = 0; i < _this->num_clipboard_mime_types; ++i) { + if (SDL_strcmp(mime_type, _this->clipboard_mime_types[i]) == 0) { + return true; + } + } + return false; +} + +bool SDL_HasClipboardData(const char *mime_type) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (!_this) { + SDL_UninitializedVideo(); + return false; + } + + if (!mime_type) { + SDL_InvalidParamError("mime_type"); + return false; + } + + if (_this->HasClipboardData) { + return _this->HasClipboardData(_this, mime_type); + } else if (_this->HasClipboardText && SDL_IsTextMimeType(mime_type)) { + return _this->HasClipboardText(_this); + } else { + return SDL_HasInternalClipboardData(_this, mime_type); + } +} + +char **SDL_CopyClipboardMimeTypes(const char **clipboard_mime_types, size_t num_mime_types, bool temporary) +{ + size_t allocSize = sizeof(char *); + for (size_t i = 0; i < num_mime_types; i++) { + allocSize += sizeof(char *) + SDL_strlen(clipboard_mime_types[i]) + 1; + } + + char *ret; + if (temporary) + ret = (char *)SDL_AllocateTemporaryMemory(allocSize); + else + ret = (char *)SDL_malloc(allocSize); + if (!ret) { + return NULL; + } + + char **result = (char **)ret; + ret += sizeof(char *) * (num_mime_types + 1); + + for (size_t i = 0; i < num_mime_types; i++) { + result[i] = ret; + + const char *mime_type = clipboard_mime_types[i]; + // Copy the whole string including the terminating null char + char c; + do { + c = *ret++ = *mime_type++; + } while (c != '\0'); + } + result[num_mime_types] = NULL; + + return result; + +} + +char **SDL_GetClipboardMimeTypes(size_t *num_mime_types) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (num_mime_types) { + *num_mime_types = 0; + } + + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + + if (num_mime_types) { + *num_mime_types = _this->num_clipboard_mime_types; + } + return SDL_CopyClipboardMimeTypes((const char **)_this->clipboard_mime_types, _this->num_clipboard_mime_types, false); +} + +// Clipboard text + +bool SDL_IsTextMimeType(const char *mime_type) +{ + return (SDL_strncmp(mime_type, "text", 4) == 0); +} + +static const char **SDL_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types) +{ + if (_this->GetTextMimeTypes) { + return _this->GetTextMimeTypes(_this, num_mime_types); + } else { + static const char *text_mime_types[] = { + "text/plain;charset=utf-8" + }; + + *num_mime_types = SDL_arraysize(text_mime_types); + return text_mime_types; + } +} + +const void * SDLCALL SDL_ClipboardTextCallback(void *userdata, const char *mime_type, size_t *size) +{ + char *text = (char *)userdata; + if (text) { + *size = SDL_strlen(text); + } else { + *size = 0; + } + return text; +} + +bool SDL_SetClipboardText(const char *text) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + size_t num_mime_types; + const char **text_mime_types; + + if (!_this) { + return SDL_UninitializedVideo(); + } + + if (text && *text) { + text_mime_types = SDL_GetTextMimeTypes(_this, &num_mime_types); + + return SDL_SetClipboardData(SDL_ClipboardTextCallback, SDL_free, SDL_strdup(text), text_mime_types, num_mime_types); + } + return SDL_ClearClipboardData(); +} + +char *SDL_GetClipboardText(void) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + size_t i, num_mime_types; + const char **text_mime_types; + size_t length; + char *text = NULL; + + if (!_this) { + SDL_UninitializedVideo(); + return SDL_strdup(""); + } + + text_mime_types = SDL_GetTextMimeTypes(_this, &num_mime_types); + for (i = 0; i < num_mime_types; ++i) { + void *clipdata = SDL_GetClipboardData(text_mime_types[i], &length); + if (clipdata) { + text = (char *)clipdata; + break; + } + } + + if (!text) { + text = SDL_strdup(""); + } + return text; +} + +bool SDL_HasClipboardText(void) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + size_t i, num_mime_types; + const char **text_mime_types; + + if (!_this) { + return SDL_UninitializedVideo(); + } + + text_mime_types = SDL_GetTextMimeTypes(_this, &num_mime_types); + for (i = 0; i < num_mime_types; ++i) { + if (SDL_HasClipboardData(text_mime_types[i])) { + return true; + } + } + return false; +} + +// Primary selection text + +bool SDL_SetPrimarySelectionText(const char *text) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (!_this) { + return SDL_UninitializedVideo(); + } + + if (!text) { + text = ""; + } + if (_this->SetPrimarySelectionText) { + if (!_this->SetPrimarySelectionText(_this, text)) { + return false; + } + } else { + SDL_free(_this->primary_selection_text); + _this->primary_selection_text = SDL_strdup(text); + } + + char **mime_types = SDL_CopyClipboardMimeTypes((const char **)_this->clipboard_mime_types, _this->num_clipboard_mime_types, true); + if (!mime_types) + return SDL_SetError("unable to copy current mime types"); + + SDL_SendClipboardUpdate(true, mime_types, _this->num_clipboard_mime_types); + return true; +} + +char *SDL_GetPrimarySelectionText(void) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (!_this) { + SDL_UninitializedVideo(); + return SDL_strdup(""); + } + + if (_this->GetPrimarySelectionText) { + return _this->GetPrimarySelectionText(_this); + } else { + const char *text = _this->primary_selection_text; + if (!text) { + text = ""; + } + return SDL_strdup(text); + } +} + +bool SDL_HasPrimarySelectionText(void) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + if (!_this) { + return SDL_UninitializedVideo(); + } + + if (_this->HasPrimarySelectionText) { + return _this->HasPrimarySelectionText(_this); + } else { + if (_this->primary_selection_text && _this->primary_selection_text[0] != '\0') { + return true; + } else { + return false; + } + } +} + diff --git a/contrib/SDL-3.2.8/src/video/SDL_clipboard_c.h b/contrib/SDL-3.2.8/src/video/SDL_clipboard_c.h new file mode 100644 index 0000000..11e5a0c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_clipboard_c.h @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_clipboard_c_h_ +#define SDL_clipboard_c_h_ + +#include "SDL_sysvideo.h" + + +// Return true if the mime type is valid clipboard text +extern bool SDL_IsTextMimeType(const char *mime_type); + +// Cancel the clipboard data callback, called internally for cleanup +extern void SDL_CancelClipboardData(Uint32 sequence); + +// Call the clipboard callback for application data +extern void *SDL_GetInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); +extern bool SDL_HasInternalClipboardData(SDL_VideoDevice *_this, const char *mime_type); + +// General purpose clipboard text callback +const void * SDLCALL SDL_ClipboardTextCallback(void *userdata, const char *mime_type, size_t *size); + +bool SDL_SaveClipboardMimeTypes(const char **mime_types, size_t num_mime_types); +void SDL_FreeClipboardMimeTypes(SDL_VideoDevice *_this); +char **SDL_CopyClipboardMimeTypes(const char **clipboard_mime_types, size_t num_mime_types, bool temporary); + +#endif // SDL_clipboard_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_egl.c b/contrib/SDL-3.2.8/src/video/SDL_egl.c new file mode 100644 index 0000000..8650254 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_egl.c @@ -0,0 +1,1339 @@ +/* + * Simple DirectMedia Layer + * Copyright (C) 1997-2025 Sam Lantinga + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + */ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_OPENGL_EGL + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) +#include "../core/windows/SDL_windows.h" +#endif +#ifdef SDL_VIDEO_DRIVER_ANDROID +#include +#include "../video/android/SDL_androidvideo.h" +#endif +#ifdef SDL_VIDEO_DRIVER_RPI +#include +#endif +#ifdef SDL_VIDEO_VITA_PVR_OGL +#include +#endif + +#include "SDL_sysvideo.h" +#include "SDL_egl_c.h" + +#ifdef EGL_KHR_create_context +// EGL_OPENGL_ES3_BIT_KHR was added in version 13 of the extension. +#ifndef EGL_OPENGL_ES3_BIT_KHR +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif +#endif // EGL_KHR_create_context + +#ifndef EGL_EXT_pixel_format_float +#define EGL_EXT_pixel_format_float +#define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 +#define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A +#define EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B +#endif + +#ifndef EGL_EXT_present_opaque +#define EGL_EXT_present_opaque 1 +#define EGL_PRESENT_OPAQUE_EXT 0x31DF +#endif // EGL_EXT_present_opaque + +#ifdef SDL_VIDEO_DRIVER_RPI +// Raspbian places the OpenGL ES/EGL binaries in a non standard path +#define DEFAULT_EGL (vc4 ? "libEGL.so.1" : "libbrcmEGL.so") +#define DEFAULT_OGL_ES2 (vc4 ? "libGLESv2.so.2" : "libbrcmGLESv2.so") +#define ALT_EGL "libEGL.so" +#define ALT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL_ES_PVR (vc4 ? "libGLES_CM.so.1" : "libbrcmGLESv2.so") +#define DEFAULT_OGL_ES (vc4 ? "libGLESv1_CM.so.1" : "libbrcmGLESv2.so") + +#elif defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_VIVANTE) +// Android +#define DEFAULT_EGL "libEGL.so" +#define DEFAULT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" +#define DEFAULT_OGL_ES "libGLESv1_CM.so" + +#elif defined(SDL_VIDEO_DRIVER_WINDOWS) +// EGL AND OpenGL ES support via ANGLE +#define DEFAULT_EGL "libEGL.dll" +#define DEFAULT_OGL "opengl32.dll" +#define DEFAULT_OGL_ES2 "libGLESv2.dll" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.dll" +#define DEFAULT_OGL_ES "libGLESv1_CM.dll" + +#elif defined(SDL_VIDEO_DRIVER_COCOA) +// EGL AND OpenGL ES support via ANGLE +#define DEFAULT_EGL "libEGL.dylib" +#define DEFAULT_OGL_ES2 "libGLESv2.dylib" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.dylib" //??? +#define DEFAULT_OGL_ES "libGLESv1_CM.dylib" //??? + +#elif defined(SDL_PLATFORM_OPENBSD) +// OpenBSD +#define DEFAULT_OGL "libGL.so" +#define DEFAULT_EGL "libEGL.so" +#define DEFAULT_OGL_ES2 "libGLESv2.so" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so" +#define DEFAULT_OGL_ES "libGLESv1_CM.so" + +#else +// Desktop Linux/Unix-like +#define DEFAULT_OGL "libGL.so.1" +#define DEFAULT_EGL "libEGL.so.1" +#define ALT_OGL "libOpenGL.so.0" +#define DEFAULT_OGL_ES2 "libGLESv2.so.2" +#define DEFAULT_OGL_ES_PVR "libGLES_CM.so.1" +#define DEFAULT_OGL_ES "libGLESv1_CM.so.1" +#endif // SDL_VIDEO_DRIVER_RPI + +#if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_VITA_PVR_OGL) +#include +#endif + +/** If we happen to not have this defined because of an older EGL version, just define it 0x0 + as eglGetPlatformDisplayEXT will most likely be NULL if this is missing +*/ +#ifndef EGL_PLATFORM_DEVICE_EXT +#define EGL_PLATFORM_DEVICE_EXT 0x0 +#endif + +#ifdef SDL_VIDEO_OPENGL +typedef void (APIENTRY* PFNGLGETINTEGERVPROC) (GLenum pname, GLint * params); +#endif + +#if defined(SDL_VIDEO_STATIC_ANGLE) || defined(SDL_VIDEO_DRIVER_VITA) +#define LOAD_FUNC(TYPE, NAME) \ + _this->egl_data->NAME = NAME; +#else +#define LOAD_FUNC(TYPE, NAME) \ + _this->egl_data->NAME = (TYPE)SDL_LoadFunction(_this->egl_data->egl_dll_handle, #NAME); \ + if (!_this->egl_data->NAME) { \ + return SDL_SetError("Could not retrieve EGL function " #NAME); \ + } +#endif + +// it is allowed to not have some of the EGL extensions on start - attempts to use them will fail later. +#define LOAD_FUNC_EGLEXT(TYPE, NAME) \ + _this->egl_data->NAME = (TYPE)_this->egl_data->eglGetProcAddress(#NAME); + +static const char *SDL_EGL_GetErrorName(EGLint eglErrorCode) +{ +#define SDL_EGL_ERROR_TRANSLATE(e) \ + case e: \ + return #e; + switch (eglErrorCode) { + SDL_EGL_ERROR_TRANSLATE(EGL_SUCCESS); + SDL_EGL_ERROR_TRANSLATE(EGL_NOT_INITIALIZED); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_ACCESS); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_ALLOC); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_ATTRIBUTE); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_CONTEXT); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_CONFIG); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_CURRENT_SURFACE); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_DISPLAY); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_SURFACE); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_MATCH); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_PARAMETER); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_NATIVE_PIXMAP); + SDL_EGL_ERROR_TRANSLATE(EGL_BAD_NATIVE_WINDOW); + SDL_EGL_ERROR_TRANSLATE(EGL_CONTEXT_LOST); + } + return ""; +} + +bool SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, EGLint eglErrorCode) +{ + const char *errorText = SDL_EGL_GetErrorName(eglErrorCode); + char altErrorText[32]; + if (errorText[0] == '\0') { + // An unknown-to-SDL error code was reported. Report its hexadecimal value, instead of its name. + (void)SDL_snprintf(altErrorText, SDL_arraysize(altErrorText), "0x%x", (unsigned int)eglErrorCode); + errorText = altErrorText; + } + return SDL_SetError("%s (call to %s failed, reporting an error of %s)", message, eglFunctionName, errorText); +} + +// EGL implementation of SDL OpenGL ES support + +bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext) +{ + size_t ext_len; + const char *ext_override; + const char *egl_extstr; + const char *ext_start; + + // Invalid extensions can be rejected early + if (!ext || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { + // SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); + return false; + } + + /* Extensions can be masked with a hint or environment variable. + * Unlike the OpenGL override, this will use the set bits of an integer + * to disable the extension. + * Bit Action + * 0 If set, the display extension is masked and not present to SDL. + * 1 If set, the client extension is masked and not present to SDL. + */ + ext_override = SDL_GetHint(ext); + if (ext_override) { + int disable_ext = SDL_atoi(ext_override); + if (disable_ext & 0x01 && type == SDL_EGL_DISPLAY_EXTENSION) { + return false; + } else if (disable_ext & 0x02 && type == SDL_EGL_CLIENT_EXTENSION) { + return false; + } + } + + ext_len = SDL_strlen(ext); + switch (type) { + case SDL_EGL_DISPLAY_EXTENSION: + egl_extstr = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_EXTENSIONS); + break; + case SDL_EGL_CLIENT_EXTENSION: + /* EGL_EXT_client_extensions modifies eglQueryString to return client extensions + * if EGL_NO_DISPLAY is passed. Implementations without it are required to return NULL. + * This behavior is included in EGL 1.5. + */ + egl_extstr = _this->egl_data->eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); + break; + default: + // SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid extension type"); + return false; + } + + if (egl_extstr) { + ext_start = egl_extstr; + + while (*ext_start) { + ext_start = SDL_strstr(ext_start, ext); + if (!ext_start) { + return false; + } + // Check if the match is not just a substring of one of the extensions + if (ext_start == egl_extstr || *(ext_start - 1) == ' ') { + if (ext_start[ext_len] == ' ' || ext_start[ext_len] == 0) { + return true; + } + } + // If the search stopped in the middle of an extension, skip to the end of it + ext_start += ext_len; + while (*ext_start != ' ' && *ext_start != 0) { + ext_start++; + } + } + } + + return false; +} + +SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const char *proc) +{ + SDL_FunctionPointer result = NULL; + if (_this->egl_data) { + const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor); + const bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5); + + // EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. + if (!result && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + result = _this->egl_data->eglGetProcAddress(proc); + } + +#if !defined(SDL_PLATFORM_EMSCRIPTEN) && !defined(SDL_VIDEO_DRIVER_VITA) // LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. + // Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. + if (!result) { + result = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc); + } +#endif + + // Try eglGetProcAddress if we're on <= 1.4 and still searching... + if (!result && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + result = _this->egl_data->eglGetProcAddress(proc); + } + } + return result; +} + +void SDL_EGL_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->egl_data) { + if (_this->egl_data->egl_display) { + _this->egl_data->eglTerminate(_this->egl_data->egl_display); + _this->egl_data->egl_display = NULL; + } + + if (_this->egl_data->egl_dll_handle) { + SDL_UnloadObject(_this->egl_data->egl_dll_handle); + _this->egl_data->egl_dll_handle = NULL; + } + if (_this->egl_data->opengl_dll_handle) { + SDL_UnloadObject(_this->egl_data->opengl_dll_handle); + _this->egl_data->opengl_dll_handle = NULL; + } + + SDL_free(_this->egl_data); + _this->egl_data = NULL; + } +} + +static bool SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_path) +{ + SDL_SharedObject *egl_dll_handle = NULL; +#if !defined(SDL_VIDEO_STATIC_ANGLE) && !defined(SDL_VIDEO_DRIVER_VITA) + SDL_SharedObject *opengl_dll_handle = NULL; +#endif + const char *path = NULL; +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + const char *d3dcompiler; +#endif +#ifdef SDL_VIDEO_DRIVER_RPI + bool vc4 = (0 == access("/sys/module/vc4/", F_OK)); +#endif + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + d3dcompiler = SDL_GetHint(SDL_HINT_VIDEO_WIN_D3DCOMPILER); + if (d3dcompiler) { + if (SDL_strcasecmp(d3dcompiler, "none") != 0) { + if (SDL_LoadObject(d3dcompiler) == NULL) { + SDL_ClearError(); + } + } + } else { + if (WIN_IsWindowsVistaOrGreater()) { + // Try the newer d3d compilers first + const char *d3dcompiler_list[] = { + "d3dcompiler_47.dll", + "d3dcompiler_46.dll", + }; + int i; + + for (i = 0; i < SDL_arraysize(d3dcompiler_list); ++i) { + if (SDL_LoadObject(d3dcompiler_list[i]) != NULL) { + break; + } + SDL_ClearError(); + } + } else { + if (SDL_LoadObject("d3dcompiler_43.dll") == NULL) { + SDL_ClearError(); + } + } + } +#endif + +#if !defined(SDL_VIDEO_STATIC_ANGLE) && !defined(SDL_VIDEO_DRIVER_VITA) + /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ + path = SDL_GetHint(SDL_HINT_OPENGL_LIBRARY); + if (path) { + opengl_dll_handle = SDL_LoadObject(path); + } + + if (!opengl_dll_handle) { + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { + if (_this->gl_config.major_version > 1) { + path = DEFAULT_OGL_ES2; + opengl_dll_handle = SDL_LoadObject(path); +#ifdef ALT_OGL_ES2 + if (!opengl_dll_handle && !vc4) { + path = ALT_OGL_ES2; + opengl_dll_handle = SDL_LoadObject(path); + } +#endif + + } else { + path = DEFAULT_OGL_ES; + opengl_dll_handle = SDL_LoadObject(path); + if (!opengl_dll_handle) { + path = DEFAULT_OGL_ES_PVR; + opengl_dll_handle = SDL_LoadObject(path); + } +#ifdef ALT_OGL_ES2 + if (!opengl_dll_handle && !vc4) { + path = ALT_OGL_ES2; + opengl_dll_handle = SDL_LoadObject(path); + } +#endif + } + } +#ifdef DEFAULT_OGL + else { + path = DEFAULT_OGL; + opengl_dll_handle = SDL_LoadObject(path); +#ifdef ALT_OGL + if (!opengl_dll_handle) { + path = ALT_OGL; + opengl_dll_handle = SDL_LoadObject(path); + } +#endif + } +#endif + } + _this->egl_data->opengl_dll_handle = opengl_dll_handle; + + if (!opengl_dll_handle) { + return SDL_SetError("Could not initialize OpenGL / GLES library"); + } + + /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */ + if (egl_path) { + egl_dll_handle = SDL_LoadObject(egl_path); + } + // Try loading a EGL symbol, if it does not work try the default library paths + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { + SDL_UnloadObject(egl_dll_handle); + } + path = SDL_GetHint(SDL_HINT_EGL_LIBRARY); + if (!path) { + path = DEFAULT_EGL; + } + egl_dll_handle = SDL_LoadObject(path); + +#ifdef ALT_EGL + if (!egl_dll_handle && !vc4) { + path = ALT_EGL; + egl_dll_handle = SDL_LoadObject(path); + } +#endif + + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { + SDL_UnloadObject(egl_dll_handle); + } + return SDL_SetError("Could not load EGL library"); + } + SDL_ClearError(); + } +#endif + + _this->egl_data->egl_dll_handle = egl_dll_handle; + + // Load new function pointers + LOAD_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); + LOAD_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); + LOAD_FUNC(PFNEGLTERMINATEPROC, eglTerminate); + LOAD_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); + LOAD_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); + LOAD_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); + LOAD_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext); + LOAD_FUNC(PFNEGLCREATEPBUFFERSURFACEPROC, eglCreatePbufferSurface); + LOAD_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface); + LOAD_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); + LOAD_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); + LOAD_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers); + LOAD_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); + LOAD_FUNC(PFNEGLQUERYSTRINGPROC, eglQueryString); + LOAD_FUNC(PFNEGLGETCONFIGATTRIBPROC, eglGetConfigAttrib); + LOAD_FUNC(PFNEGLWAITNATIVEPROC, eglWaitNative); + LOAD_FUNC(PFNEGLWAITGLPROC, eglWaitGL); + LOAD_FUNC(PFNEGLBINDAPIPROC, eglBindAPI); + LOAD_FUNC(PFNEGLGETERRORPROC, eglGetError); + LOAD_FUNC_EGLEXT(PFNEGLQUERYDEVICESEXTPROC, eglQueryDevicesEXT); + LOAD_FUNC_EGLEXT(PFNEGLGETPLATFORMDISPLAYEXTPROC, eglGetPlatformDisplayEXT); + // Atomic functions + LOAD_FUNC_EGLEXT(PFNEGLCREATESYNCKHRPROC, eglCreateSyncKHR); + LOAD_FUNC_EGLEXT(PFNEGLDESTROYSYNCKHRPROC, eglDestroySyncKHR); + LOAD_FUNC_EGLEXT(PFNEGLDUPNATIVEFENCEFDANDROIDPROC, eglDupNativeFenceFDANDROID); + LOAD_FUNC_EGLEXT(PFNEGLWAITSYNCKHRPROC, eglWaitSyncKHR); + LOAD_FUNC_EGLEXT(PFNEGLCLIENTWAITSYNCKHRPROC, eglClientWaitSyncKHR); + // Atomic functions end + + if (path) { + SDL_strlcpy(_this->gl_config.driver_path, path, sizeof(_this->gl_config.driver_path) - 1); + } else { + *_this->gl_config.driver_path = '\0'; + } + + return true; +} + +bool SDL_EGL_LoadLibraryOnly(SDL_VideoDevice *_this, const char *egl_path) +{ + if (_this->egl_data) { + return SDL_SetError("EGL context already created"); + } + + _this->egl_data = (struct SDL_EGL_VideoData *)SDL_calloc(1, sizeof(SDL_EGL_VideoData)); + if (!_this->egl_data) { + return false; + } + + if (!SDL_EGL_LoadLibraryInternal(_this, egl_path)) { + SDL_free(_this->egl_data); + _this->egl_data = NULL; + return false; + } + return true; +} + +static void SDL_EGL_GetVersion(SDL_VideoDevice *_this) +{ + if (_this->egl_data->eglQueryString) { + const char *egl_version = _this->egl_data->eglQueryString(_this->egl_data->egl_display, EGL_VERSION); + if (egl_version) { + int major = 0, minor = 0; + if (SDL_sscanf(egl_version, "%d.%d", &major, &minor) == 2) { + _this->egl_data->egl_version_major = major; + _this->egl_data->egl_version_minor = minor; + } else { + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "Could not parse EGL version string: %s", egl_version); + } + } + } +} + +bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisplayType native_display, EGLenum platform) +{ + if (!SDL_EGL_LoadLibraryOnly(_this, egl_path)) { + return false; + } + + _this->egl_data->egl_display = EGL_NO_DISPLAY; + +#ifndef SDL_VIDEO_DRIVER_VITA + if (platform) { + /* EGL 1.5 allows querying for client version with EGL_NO_DISPLAY + * -- + * Khronos doc: "EGL_BAD_DISPLAY is generated if display is not an EGL display connection, unless display is EGL_NO_DISPLAY and name is EGL_EXTENSIONS." + * Therefore SDL_EGL_GetVersion() shouldn't work with uninitialized display. + * - it actually doesn't work on Android that has 1.5 egl client + * - it works on desktop X11 (using SDL_VIDEO_FORCE_EGL=1) */ + SDL_EGL_GetVersion(_this); + + if (_this->egl_data->egl_version_major == 1 && _this->egl_data->egl_version_minor == 5) { + LOAD_FUNC(PFNEGLGETPLATFORMDISPLAYPROC, eglGetPlatformDisplay); + } + + if (_this->egl_data->eglGetPlatformDisplay) { + EGLAttrib *attribs = NULL; + if (_this->egl_platformattrib_callback) { + attribs = _this->egl_platformattrib_callback(_this->egl_attrib_callback_userdata); + if (!attribs) { + _this->gl_config.driver_loaded = 0; + *_this->gl_config.driver_path = '\0'; + return SDL_SetError("EGL platform attribute callback returned NULL pointer"); + } + } + _this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplay(platform, (void *)(uintptr_t)native_display, attribs); + SDL_free(attribs); + } else { + if (SDL_EGL_HasExtension(_this, SDL_EGL_CLIENT_EXTENSION, "EGL_EXT_platform_base")) { + _this->egl_data->eglGetPlatformDisplayEXT = (PFNEGLGETPLATFORMDISPLAYEXTPROC)SDL_EGL_GetProcAddressInternal(_this, "eglGetPlatformDisplayEXT"); + if (_this->egl_data->eglGetPlatformDisplayEXT) { + _this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplayEXT(platform, (void *)(uintptr_t)native_display, NULL); + } + } + } + } +#endif + // Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails + if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && + (_this->egl_data->eglGetDisplay) && + SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK, true)) { + _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); + } + if (_this->egl_data->egl_display == EGL_NO_DISPLAY) { + _this->gl_config.driver_loaded = 0; + *_this->gl_config.driver_path = '\0'; + return SDL_SetError("Could not get EGL display"); + } + + if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { + _this->gl_config.driver_loaded = 0; + *_this->gl_config.driver_path = '\0'; + return SDL_SetError("Could not initialize EGL"); + } + + // Get the EGL version with a valid egl_display, for EGL <= 1.4 + SDL_EGL_GetVersion(_this); + + _this->egl_data->is_offscreen = false; + + return true; +} + +/** + On multi GPU machines EGL device 0 is not always the first valid GPU. + Container environments can restrict access to some GPUs that are still listed in the EGL + device list. If the requested device is a restricted GPU and cannot be used + (eglInitialize() will fail) then attempt to automatically and silently select the next + valid available GPU for EGL to use. +*/ + +bool SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) +{ + void *egl_devices[SDL_EGL_MAX_DEVICES]; + EGLint num_egl_devices = 0; + const char *egl_device_hint; + + if (_this->gl_config.driver_loaded <= 0) { + return SDL_SetError("SDL_EGL_LoadLibraryOnly() has not been called or has failed."); + } + + // Check for all extensions that are optional until used and fail if any is missing + if (!_this->egl_data->eglQueryDevicesEXT) { + return SDL_SetError("eglQueryDevicesEXT is missing (EXT_device_enumeration not supported by the drivers?)"); + } + + if (!_this->egl_data->eglGetPlatformDisplayEXT) { + return SDL_SetError("eglGetPlatformDisplayEXT is missing (EXT_platform_base not supported by the drivers?)"); + } + + if (_this->egl_data->eglQueryDevicesEXT(SDL_EGL_MAX_DEVICES, egl_devices, &num_egl_devices) != EGL_TRUE) { + return SDL_SetError("eglQueryDevicesEXT() failed"); + } + + egl_device_hint = SDL_GetHint("SDL_HINT_EGL_DEVICE"); + if (egl_device_hint) { + device = SDL_atoi(egl_device_hint); + + if (device >= num_egl_devices) { + return SDL_SetError("Invalid EGL device is requested."); + } + + _this->egl_data->egl_display = _this->egl_data->eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, egl_devices[device], NULL); + + if (_this->egl_data->egl_display == EGL_NO_DISPLAY) { + return SDL_SetError("eglGetPlatformDisplayEXT() failed."); + } + + if (_this->egl_data->eglInitialize(_this->egl_data->egl_display, NULL, NULL) != EGL_TRUE) { + return SDL_SetError("Could not initialize EGL"); + } + } else { + int i; + bool found = false; + EGLDisplay attempted_egl_display; + + // If no hint is provided lets look for the first device/display that will allow us to eglInit + for (i = 0; i < num_egl_devices; i++) { + attempted_egl_display = _this->egl_data->eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, egl_devices[i], NULL); + + if (attempted_egl_display == EGL_NO_DISPLAY) { + continue; + } + + if (_this->egl_data->eglInitialize(attempted_egl_display, NULL, NULL) != EGL_TRUE) { + _this->egl_data->eglTerminate(attempted_egl_display); + continue; + } + + // We did not fail, we'll pick this one! + _this->egl_data->egl_display = attempted_egl_display; + found = true; + + break; + } + + if (!found) { + return SDL_SetError("Could not find a valid EGL device to initialize"); + } + } + + // Get the EGL version with a valid egl_display, for EGL <= 1.4 + SDL_EGL_GetVersion(_this); + + _this->egl_data->is_offscreen = true; + + return true; +} + +void SDL_EGL_SetRequiredVisualId(SDL_VideoDevice *_this, int visual_id) +{ + _this->egl_data->egl_required_visual_id = visual_id; +} + +#ifdef DUMP_EGL_CONFIG + +#define ATTRIBUTE(_attr) \ + { \ + _attr, #_attr \ + } + +typedef struct +{ + EGLint attribute; + char const *name; +} Attribute; + +static Attribute all_attributes[] = { + ATTRIBUTE(EGL_BUFFER_SIZE), + ATTRIBUTE(EGL_ALPHA_SIZE), + ATTRIBUTE(EGL_BLUE_SIZE), + ATTRIBUTE(EGL_GREEN_SIZE), + ATTRIBUTE(EGL_RED_SIZE), + ATTRIBUTE(EGL_DEPTH_SIZE), + ATTRIBUTE(EGL_STENCIL_SIZE), + ATTRIBUTE(EGL_CONFIG_CAVEAT), + ATTRIBUTE(EGL_CONFIG_ID), + ATTRIBUTE(EGL_LEVEL), + ATTRIBUTE(EGL_MAX_PBUFFER_HEIGHT), + ATTRIBUTE(EGL_MAX_PBUFFER_WIDTH), + ATTRIBUTE(EGL_MAX_PBUFFER_PIXELS), + ATTRIBUTE(EGL_NATIVE_RENDERABLE), + ATTRIBUTE(EGL_NATIVE_VISUAL_ID), + ATTRIBUTE(EGL_NATIVE_VISUAL_TYPE), + ATTRIBUTE(EGL_SAMPLES), + ATTRIBUTE(EGL_SAMPLE_BUFFERS), + ATTRIBUTE(EGL_SURFACE_TYPE), + ATTRIBUTE(EGL_TRANSPARENT_TYPE), + ATTRIBUTE(EGL_TRANSPARENT_BLUE_VALUE), + ATTRIBUTE(EGL_TRANSPARENT_GREEN_VALUE), + ATTRIBUTE(EGL_TRANSPARENT_RED_VALUE), + ATTRIBUTE(EGL_BIND_TO_TEXTURE_RGB), + ATTRIBUTE(EGL_BIND_TO_TEXTURE_RGBA), + ATTRIBUTE(EGL_MIN_SWAP_INTERVAL), + ATTRIBUTE(EGL_MAX_SWAP_INTERVAL), + ATTRIBUTE(EGL_LUMINANCE_SIZE), + ATTRIBUTE(EGL_ALPHA_MASK_SIZE), + ATTRIBUTE(EGL_COLOR_BUFFER_TYPE), + ATTRIBUTE(EGL_RENDERABLE_TYPE), + ATTRIBUTE(EGL_MATCH_NATIVE_PIXMAP), + ATTRIBUTE(EGL_CONFORMANT), +}; + +static void dumpconfig(SDL_VideoDevice *_this, EGLConfig config) +{ + int attr; + for (attr = 0; attr < sizeof(all_attributes) / sizeof(Attribute); attr++) { + EGLint value; + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, config, all_attributes[attr].attribute, &value); + SDL_Log("\t%-32s: %10d (0x%08x)", all_attributes[attr].name, value, value); + } +} + +#endif // DUMP_EGL_CONFIG + +static bool SDL_EGL_PrivateChooseConfig(SDL_VideoDevice *_this, bool set_config_caveat_none) +{ + // 64 seems nice. + EGLint attribs[64]; + EGLint found_configs = 0, value; + // 128 seems even nicer here + EGLConfig configs[128]; + bool has_matching_format = false; + int i, j, best_bitdiff = -1, best_truecolor_bitdiff = -1; + int truecolor_config_idx = -1; + + // Get a valid EGL configuration + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + + if (set_config_caveat_none) { + attribs[i++] = EGL_CONFIG_CAVEAT; + attribs[i++] = EGL_NONE; + } + + if (_this->gl_config.alpha_size) { + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + + if (_this->gl_config.buffer_size) { + attribs[i++] = EGL_BUFFER_SIZE; + attribs[i++] = _this->gl_config.buffer_size; + } + + if (_this->gl_config.depth_size) { + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + } + + if (_this->gl_config.stencil_size) { + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } + + if (_this->gl_config.multisamplebuffers) { + attribs[i++] = EGL_SAMPLE_BUFFERS; + attribs[i++] = _this->gl_config.multisamplebuffers; + } + + if (_this->gl_config.multisamplesamples) { + attribs[i++] = EGL_SAMPLES; + attribs[i++] = _this->gl_config.multisamplesamples; + } + + if (_this->gl_config.floatbuffers) { + attribs[i++] = EGL_COLOR_COMPONENT_TYPE_EXT; + attribs[i++] = EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT; + } + + if (_this->egl_data->is_offscreen) { + attribs[i++] = EGL_SURFACE_TYPE; + attribs[i++] = EGL_PBUFFER_BIT; + } + + attribs[i++] = EGL_RENDERABLE_TYPE; + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { +#ifdef EGL_KHR_create_context + if (_this->gl_config.major_version >= 3 && + SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context")) { + attribs[i++] = EGL_OPENGL_ES3_BIT_KHR; + } else +#endif + if (_this->gl_config.major_version >= 2) { + attribs[i++] = EGL_OPENGL_ES2_BIT; + } else { + attribs[i++] = EGL_OPENGL_ES_BIT; + } + _this->egl_data->eglBindAPI(EGL_OPENGL_ES_API); + } else { + attribs[i++] = EGL_OPENGL_BIT; + _this->egl_data->eglBindAPI(EGL_OPENGL_API); + } + + if (_this->egl_data->egl_surfacetype) { + attribs[i++] = EGL_SURFACE_TYPE; + attribs[i++] = _this->egl_data->egl_surfacetype; + } + + attribs[i++] = EGL_NONE; + + SDL_assert(i < SDL_arraysize(attribs)); + + if (_this->egl_data->eglChooseConfig(_this->egl_data->egl_display, + attribs, + configs, SDL_arraysize(configs), + &found_configs) == EGL_FALSE || + found_configs == 0) { + return false; + } + + // first ensure that a found config has a matching format, or the function will fall through. + if (_this->egl_data->egl_required_visual_id) { + for (i = 0; i < found_configs; i++) { + EGLint format; + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + configs[i], + EGL_NATIVE_VISUAL_ID, &format); + if (_this->egl_data->egl_required_visual_id == format) { + has_matching_format = true; + break; + } + } + } + + // eglChooseConfig returns a number of configurations that match or exceed the requested attribs. + // From those, we select the one that matches our requirements more closely via a makeshift algorithm + + for (i = 0; i < found_configs; i++) { + bool is_truecolor = false; + int bitdiff = 0; + + if (has_matching_format && _this->egl_data->egl_required_visual_id) { + EGLint format; + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + configs[i], + EGL_NATIVE_VISUAL_ID, &format); + if (_this->egl_data->egl_required_visual_id != format) { + continue; + } + } + + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_RED_SIZE, &value); + if (value == 8) { + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_GREEN_SIZE, &value); + if (value == 8) { + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], EGL_BLUE_SIZE, &value); + if (value == 8) { + is_truecolor = true; + } + } + } + + for (j = 0; j < SDL_arraysize(attribs) - 1; j += 2) { + if (attribs[j] == EGL_NONE) { + break; + } + + if (attribs[j + 1] != EGL_DONT_CARE && (attribs[j] == EGL_RED_SIZE || + attribs[j] == EGL_GREEN_SIZE || + attribs[j] == EGL_BLUE_SIZE || + attribs[j] == EGL_ALPHA_SIZE || + attribs[j] == EGL_DEPTH_SIZE || + attribs[j] == EGL_STENCIL_SIZE)) { + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, configs[i], attribs[j], &value); + bitdiff += value - attribs[j + 1]; // value is always >= attrib + } + } + + if ((bitdiff < best_bitdiff) || (best_bitdiff == -1)) { + _this->egl_data->egl_config = configs[i]; + best_bitdiff = bitdiff; + } + + if (is_truecolor && ((bitdiff < best_truecolor_bitdiff) || (best_truecolor_bitdiff == -1))) { + truecolor_config_idx = i; + best_truecolor_bitdiff = bitdiff; + } + } + +#define FAVOR_TRUECOLOR 1 +#if FAVOR_TRUECOLOR + /* Some apps request a low color depth, either because they _assume_ + they'll get a larger one but don't want to fail if only smaller ones + are available, or they just never called SDL_GL_SetAttribute at all and + got a tiny default. For these cases, a game that would otherwise run + at 24-bit color might get dithered down to something smaller, which is + worth avoiding. If the app requested <= 16 bit color and an exact 24-bit + match is available, favor that. Otherwise, we look for the closest + match. Note that while the API promises what you request _or better_, + it's feasible this can be disastrous for performance for custom software + on small hardware that all expected to actually get 16-bit color. In this + case, turn off FAVOR_TRUECOLOR (and maybe send a patch to make this more + flexible). */ + if (((_this->gl_config.red_size + _this->gl_config.blue_size + _this->gl_config.green_size) <= 16)) { + if (truecolor_config_idx != -1) { + _this->egl_data->egl_config = configs[truecolor_config_idx]; + } + } +#endif + +#ifdef DUMP_EGL_CONFIG + dumpconfig(_this, _this->egl_data->egl_config); +#endif + + return true; +} + +bool SDL_EGL_ChooseConfig(SDL_VideoDevice *_this) +{ + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + // Try with EGL_CONFIG_CAVEAT set to EGL_NONE, to avoid any EGL_SLOW_CONFIG or EGL_NON_CONFORMANT_CONFIG + if (SDL_EGL_PrivateChooseConfig(_this, true)) { + return true; + } + + // Fallback with all configs + if (SDL_EGL_PrivateChooseConfig(_this, false)) { + SDL_Log("SDL_EGL_ChooseConfig: found a slow EGL config"); + return true; + } + + return SDL_EGL_SetError("Couldn't find matching EGL config", "eglChooseConfig"); +} + +SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surface) +{ + // max 16 key+value pairs plus terminator. + EGLint attribs[33]; + int attr = 0; + + EGLContext egl_context, share_context = EGL_NO_CONTEXT; + EGLint profile_mask = _this->gl_config.profile_mask; + EGLint major_version = _this->gl_config.major_version; + EGLint minor_version = _this->gl_config.minor_version; + bool profile_es = (profile_mask == SDL_GL_CONTEXT_PROFILE_ES); + + if (!_this->egl_data) { + SDL_SetError("EGL not initialized"); + return NULL; + } + + if (_this->gl_config.share_with_current_context) { + share_context = (EGLContext)SDL_GL_GetCurrentContext(); + } + +#ifdef SDL_VIDEO_DRIVER_ANDROID + if (_this->gl_config.flags & SDL_GL_CONTEXT_DEBUG_FLAG) { + /* If SDL_GL_CONTEXT_DEBUG_FLAG is set but EGL_KHR_debug unsupported, unset. + * This is required because some Android devices like to complain about it + * by "silently" failing, logging a hint which could be easily overlooked: + * E/libEGL (26984): validate_display:255 error 3008 (EGL_BAD_DISPLAY) + * The following explicitly checks for EGL_KHR_debug before EGL 1.5 + */ + int egl_version_major = _this->egl_data->egl_version_major; + int egl_version_minor = _this->egl_data->egl_version_minor; + if (((egl_version_major < 1) || (egl_version_major == 1 && egl_version_minor < 5)) && + !SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_debug")) { + // SDL profile bits match EGL profile bits. + _this->gl_config.flags &= ~SDL_GL_CONTEXT_DEBUG_FLAG; + } + } +#endif + + // Set the context version and other attributes. + if ((major_version < 3 || (minor_version == 0 && profile_es)) && + _this->gl_config.flags == 0 && + (profile_mask == 0 || profile_es)) { + /* Create a context without using EGL_KHR_create_context attribs. + * When creating a GLES context without EGL_KHR_create_context we can + * only specify the major version. When creating a desktop GL context + * we can't specify any version, so we only try in that case when the + * version is less than 3.0 (matches SDL's GLX/WGL behavior.) + */ + if (profile_es) { + attribs[attr++] = EGL_CONTEXT_CLIENT_VERSION; + attribs[attr++] = SDL_max(major_version, 1); + } + } else { +#ifdef EGL_KHR_create_context + /* The Major/minor version, context profiles, and context flags can + * only be specified when this extension is available. + */ + if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context")) { + attribs[attr++] = EGL_CONTEXT_MAJOR_VERSION_KHR; + attribs[attr++] = major_version; + attribs[attr++] = EGL_CONTEXT_MINOR_VERSION_KHR; + attribs[attr++] = minor_version; + + // SDL profile bits match EGL profile bits. + if (profile_mask != 0 && profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { + attribs[attr++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR; + attribs[attr++] = profile_mask; + } + + // SDL flags match EGL flags. + if (_this->gl_config.flags != 0) { + attribs[attr++] = EGL_CONTEXT_FLAGS_KHR; + attribs[attr++] = _this->gl_config.flags; + } + } else +#endif // EGL_KHR_create_context + { + SDL_SetError("Could not create EGL context (context attributes are not supported)"); + return NULL; + } + } + +#ifdef EGL_KHR_create_context_no_error + if (_this->gl_config.no_error) { + if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_create_context_no_error")) { + attribs[attr++] = EGL_CONTEXT_OPENGL_NO_ERROR_KHR; + attribs[attr++] = _this->gl_config.no_error; + } + } +#endif + + if (_this->egl_contextattrib_callback) { + const int maxAttribs = sizeof(attribs) / sizeof(attribs[0]); + EGLint *userAttribs, *userAttribP; + userAttribs = _this->egl_contextattrib_callback(_this->egl_attrib_callback_userdata, _this->egl_data->egl_display, _this->egl_data->egl_config); + if (!userAttribs) { + _this->gl_config.driver_loaded = 0; + *_this->gl_config.driver_path = '\0'; + SDL_SetError("EGL context attribute callback returned NULL pointer"); + return NULL; + } + + for (userAttribP = userAttribs; *userAttribP != EGL_NONE;) { + if (attr + 3 >= maxAttribs) { + _this->gl_config.driver_loaded = 0; + *_this->gl_config.driver_path = '\0'; + SDL_SetError("EGL context attribute callback returned too many attributes"); + return NULL; + } + attribs[attr++] = *userAttribP++; + attribs[attr++] = *userAttribP++; + } + SDL_free(userAttribs); + } + + attribs[attr++] = EGL_NONE; + + // Bind the API + if (profile_es) { + _this->egl_data->apitype = EGL_OPENGL_ES_API; + } else { + _this->egl_data->apitype = EGL_OPENGL_API; + } + _this->egl_data->eglBindAPI(_this->egl_data->apitype); + + egl_context = _this->egl_data->eglCreateContext(_this->egl_data->egl_display, + _this->egl_data->egl_config, + share_context, attribs); + + if (egl_context == EGL_NO_CONTEXT) { + SDL_EGL_SetError("Could not create EGL context", "eglCreateContext"); + return NULL; + } + + _this->egl_data->egl_swapinterval = 0; + + if (!SDL_EGL_MakeCurrent(_this, egl_surface, (SDL_GLContext)egl_context)) { + // Delete the context + SDL_EGL_DestroyContext(_this, (SDL_GLContext)egl_context); + return NULL; + } + + /* Check whether making contexts current without a surface is supported. + * First condition: EGL must support it. That's the case for EGL 1.5 + * or later, or if the EGL_KHR_surfaceless_context extension is present. */ + if ((_this->egl_data->egl_version_major > 1) || + ((_this->egl_data->egl_version_major == 1) && (_this->egl_data->egl_version_minor >= 5)) || + SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_surfaceless_context")) { + // Secondary condition: The client API must support it. + if (profile_es) { + /* On OpenGL ES, the GL_OES_surfaceless_context extension must be + * present. */ + if (SDL_GL_ExtensionSupported("GL_OES_surfaceless_context")) { + _this->gl_allow_no_surface = true; + } +#if defined(SDL_VIDEO_OPENGL) && !defined(SDL_VIDEO_DRIVER_VITA) + } else { + // Desktop OpenGL supports it by default from version 3.0 on. + PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv"); + if (glGetIntegervFunc) { + GLint v = 0; + glGetIntegervFunc(GL_MAJOR_VERSION, &v); + if (v >= 3) { + _this->gl_allow_no_surface = true; + } + } +#endif + } + } + + return (SDL_GLContext)egl_context; +} + +bool SDL_EGL_MakeCurrent(SDL_VideoDevice *_this, EGLSurface egl_surface, SDL_GLContext context) +{ + EGLContext egl_context = (EGLContext)context; + + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + if (!_this->egl_data->eglMakeCurrent) { + if (!egl_surface && !context) { + // Can't do the nothing there is to do? Probably trying to cleanup a failed startup, just return. + return true; + } else { + return SDL_SetError("EGL not initialized"); // something clearly went wrong somewhere. + } + } + + // Make sure current thread has a valid API bound to it. + if (_this->egl_data->eglBindAPI) { + _this->egl_data->eglBindAPI(_this->egl_data->apitype); + } + + /* The android emulator crashes badly if you try to eglMakeCurrent + * with a valid context and invalid surface, so we have to check for both here. + */ + if (!egl_context || (!egl_surface && !_this->gl_allow_no_surface)) { + _this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + } else { + if (!_this->egl_data->eglMakeCurrent(_this->egl_data->egl_display, + egl_surface, egl_surface, egl_context)) { + return SDL_EGL_SetError("Unable to make EGL context current", "eglMakeCurrent"); + } + } + + return true; +} + +bool SDL_EGL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + EGLBoolean status; + + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + /* FIXME: Revisit this check when EGL_EXT_swap_control_tear is published: + * https://github.com/KhronosGroup/EGL-Registry/pull/113 + */ + if (interval < 0) { + return SDL_SetError("Late swap tearing currently unsupported"); + } + + status = _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, interval); + if (status == EGL_TRUE) { + _this->egl_data->egl_swapinterval = interval; + return true; + } + + return SDL_EGL_SetError("Unable to set the EGL swap interval", "eglSwapInterval"); +} + +bool SDL_EGL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + *interval = _this->egl_data->egl_swapinterval; + return true; +} + +bool SDL_EGL_SwapBuffers(SDL_VideoDevice *_this, EGLSurface egl_surface) +{ + if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, egl_surface)) { + return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); + } + return true; +} + +bool SDL_EGL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + EGLContext egl_context = (EGLContext)context; + + // Clean up GLES and EGL + if (!_this->egl_data) { + return true; + } + + if (egl_context != NULL && egl_context != EGL_NO_CONTEXT) { + _this->egl_data->eglDestroyContext(_this->egl_data->egl_display, egl_context); + } + return true; +} + +EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, NativeWindowType nw) +{ +#ifdef SDL_VIDEO_DRIVER_ANDROID + EGLint format_wanted; + EGLint format_got; +#endif + // max 16 key+value pairs, plus terminator. + EGLint attribs[33]; + int attr = 0; + + EGLSurface surface; + + if (!SDL_EGL_ChooseConfig(_this)) { + return EGL_NO_SURFACE; + } + +#ifdef SDL_VIDEO_DRIVER_ANDROID + /* On Android, EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is + * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). */ + _this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + _this->egl_data->egl_config, + EGL_NATIVE_VISUAL_ID, &format_wanted); + + // Format based on selected egl config. + ANativeWindow_setBuffersGeometry(nw, 0, 0, format_wanted); +#endif + + if (_this->gl_config.framebuffer_srgb_capable) { +#ifdef EGL_KHR_gl_colorspace + if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_KHR_gl_colorspace")) { + attribs[attr++] = EGL_GL_COLORSPACE_KHR; + attribs[attr++] = EGL_GL_COLORSPACE_SRGB_KHR; + } else +#endif + { + SDL_SetError("EGL implementation does not support sRGB system framebuffers"); + return EGL_NO_SURFACE; + } + } + +#ifdef EGL_EXT_present_opaque + if (SDL_EGL_HasExtension(_this, SDL_EGL_DISPLAY_EXTENSION, "EGL_EXT_present_opaque")) { + bool allow_transparent = false; + if (window && (window->flags & SDL_WINDOW_TRANSPARENT)) { + allow_transparent = true; + } + attribs[attr++] = EGL_PRESENT_OPAQUE_EXT; + attribs[attr++] = allow_transparent ? EGL_FALSE : EGL_TRUE; + } +#endif + + if (_this->egl_surfaceattrib_callback) { + const int maxAttribs = sizeof(attribs) / sizeof(attribs[0]); + EGLint *userAttribs, *userAttribP; + userAttribs = _this->egl_surfaceattrib_callback(_this->egl_attrib_callback_userdata, _this->egl_data->egl_display, _this->egl_data->egl_config); + if (!userAttribs) { + _this->gl_config.driver_loaded = 0; + *_this->gl_config.driver_path = '\0'; + SDL_SetError("EGL surface attribute callback returned NULL pointer"); + return EGL_NO_SURFACE; + } + + for (userAttribP = userAttribs; *userAttribP != EGL_NONE;) { + if (attr + 3 >= maxAttribs) { + _this->gl_config.driver_loaded = 0; + *_this->gl_config.driver_path = '\0'; + SDL_SetError("EGL surface attribute callback returned too many attributes"); + return EGL_NO_SURFACE; + } + attribs[attr++] = *userAttribP++; + attribs[attr++] = *userAttribP++; + } + SDL_free(userAttribs); + } + + attribs[attr++] = EGL_NONE; + + surface = _this->egl_data->eglCreateWindowSurface( + _this->egl_data->egl_display, + _this->egl_data->egl_config, + nw, &attribs[0]); + if (surface == EGL_NO_SURFACE) { + SDL_EGL_SetError("unable to create an EGL window surface", "eglCreateWindowSurface"); + } + +#ifdef SDL_VIDEO_DRIVER_ANDROID + format_got = ANativeWindow_getFormat(nw); + Android_SetFormat(format_wanted, format_got); +#endif + + return surface; +} + +EGLSurface +SDL_EGL_CreateOffscreenSurface(SDL_VideoDevice *_this, int width, int height) +{ + EGLint attributes[] = { + EGL_WIDTH, 0, + EGL_HEIGHT, 0, + EGL_NONE + }; + attributes[1] = width; + attributes[3] = height; + + if (!SDL_EGL_ChooseConfig(_this)) { + return EGL_NO_SURFACE; + } + + return _this->egl_data->eglCreatePbufferSurface( + _this->egl_data->egl_display, + _this->egl_data->egl_config, + attributes); +} + +void SDL_EGL_DestroySurface(SDL_VideoDevice *_this, EGLSurface egl_surface) +{ + if (!_this->egl_data) { + return; + } + + if (egl_surface != EGL_NO_SURFACE) { + _this->egl_data->eglDestroySurface(_this->egl_data->egl_display, egl_surface); + } +} + +#endif // SDL_VIDEO_OPENGL_EGL diff --git a/contrib/SDL-3.2.8/src/video/SDL_egl_c.h b/contrib/SDL-3.2.8/src/video/SDL_egl_c.h new file mode 100644 index 0000000..24dd392 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_egl_c.h @@ -0,0 +1,171 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_egl_h_ +#define SDL_egl_h_ + +#ifdef SDL_VIDEO_OPENGL_EGL + +#include + +#include "SDL_sysvideo.h" + +#define SDL_EGL_MAX_DEVICES 8 + +// For systems that don't define these +typedef intptr_t EGLAttrib; +typedef void *EGLDeviceEXT; +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLINITIALIZEPROC) (EGLDisplay dpy, EGLint *major, EGLint *minor); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLTERMINATEPROC) (EGLDisplay dpy); +typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP PFNEGLGETPROCADDRESSPROC) (const char *procname); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSECONFIGPROC) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLContext (EGLAPIENTRYP PFNEGLCREATECONTEXTPROC) (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERSURFACEPROC) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLMAKECURRENTPROC) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPINTERVALPROC) (EGLDisplay dpy, EGLint interval); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGPROC) (EGLDisplay dpy, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGATTRIBPROC) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITNATIVEPROC) (EGLint engine); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITGLPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDAPIPROC) (EGLenum api); +typedef EGLint (EGLAPIENTRYP PFNEGLGETERRORPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); + +typedef struct SDL_EGL_VideoData +{ + SDL_SharedObject *opengl_dll_handle; + SDL_SharedObject *egl_dll_handle; + EGLDisplay egl_display; + EGLConfig egl_config; + int egl_swapinterval; + int egl_surfacetype; + int egl_version_major, egl_version_minor; + EGLint egl_required_visual_id; + bool is_offscreen; // whether EGL display was offscreen + EGLenum apitype; // EGL_OPENGL_ES_API, EGL_OPENGL_API, etc + + PFNEGLGETDISPLAYPROC eglGetDisplay; + PFNEGLINITIALIZEPROC eglInitialize; + PFNEGLTERMINATEPROC eglTerminate; + PFNEGLGETPROCADDRESSPROC eglGetProcAddress; + PFNEGLCHOOSECONFIGPROC eglChooseConfig; + PFNEGLCREATECONTEXTPROC eglCreateContext; + PFNEGLDESTROYCONTEXTPROC eglDestroyContext; + PFNEGLCREATEPBUFFERSURFACEPROC eglCreatePbufferSurface; + PFNEGLCREATEWINDOWSURFACEPROC eglCreateWindowSurface; + PFNEGLDESTROYSURFACEPROC eglDestroySurface; + PFNEGLMAKECURRENTPROC eglMakeCurrent; + PFNEGLSWAPBUFFERSPROC eglSwapBuffers; + PFNEGLSWAPINTERVALPROC eglSwapInterval; + PFNEGLQUERYSTRINGPROC eglQueryString; + PFNEGLGETCONFIGATTRIBPROC eglGetConfigAttrib; + PFNEGLWAITNATIVEPROC eglWaitNative; + PFNEGLWAITGLPROC eglWaitGL; + PFNEGLBINDAPIPROC eglBindAPI; + PFNEGLGETERRORPROC eglGetError; + PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT; + PFNEGLGETPLATFORMDISPLAYPROC eglGetPlatformDisplay; + PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT; + + // Atomic functions + PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR; + PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR; + PFNEGLDUPNATIVEFENCEFDANDROIDPROC eglDupNativeFenceFDANDROID; + PFNEGLWAITSYNCKHRPROC eglWaitSyncKHR; + PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR; + + // Atomic functions end +} SDL_EGL_VideoData; + +// OpenGLES functions +typedef enum SDL_EGL_ExtensionType +{ + SDL_EGL_DISPLAY_EXTENSION, + SDL_EGL_CLIENT_EXTENSION +} SDL_EGL_ExtensionType; + +extern bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type, const char *ext); + +extern bool SDL_EGL_GetAttribute(SDL_VideoDevice *_this, SDL_GLAttr attrib, int *value); +/* SDL_EGL_LoadLibrary can get a display for a specific platform (EGL_PLATFORM_*) + * or, if 0 is passed, let the implementation decide. + */ +extern bool SDL_EGL_LoadLibraryOnly(SDL_VideoDevice *_this, const char *path); +extern bool SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path, NativeDisplayType native_display, EGLenum platform); +extern SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const char *proc); +extern void SDL_EGL_UnloadLibrary(SDL_VideoDevice *_this); +extern void SDL_EGL_SetRequiredVisualId(SDL_VideoDevice *_this, int visual_id); +extern bool SDL_EGL_ChooseConfig(SDL_VideoDevice *_this); +extern bool SDL_EGL_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool SDL_EGL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern bool SDL_EGL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, NativeWindowType nw); +extern void SDL_EGL_DestroySurface(SDL_VideoDevice *_this, EGLSurface egl_surface); + +extern EGLSurface SDL_EGL_CreateOffscreenSurface(SDL_VideoDevice *_this, int width, int height); +// Assumes that LoadLibraryOnly() has succeeded +extern bool SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device); + +// These need to be wrapped to get the surface for the window by the platform GLES implementation +extern SDL_GLContext SDL_EGL_CreateContext(SDL_VideoDevice *_this, EGLSurface egl_surface); +extern bool SDL_EGL_MakeCurrent(SDL_VideoDevice *_this, EGLSurface egl_surface, SDL_GLContext context); +extern bool SDL_EGL_SwapBuffers(SDL_VideoDevice *_this, EGLSurface egl_surface); + +// SDL Error-reporting +extern bool SDL_EGL_SetErrorEx(const char *message, const char *eglFunctionName, EGLint eglErrorCode); +#define SDL_EGL_SetError(message, eglFunctionName) SDL_EGL_SetErrorEx(message, eglFunctionName, _this->egl_data->eglGetError()) + +// A few of useful macros + +#define SDL_EGL_SwapWindow_impl(BACKEND) \ + bool BACKEND##_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) \ + { \ + return SDL_EGL_SwapBuffers(_this, window->internal->egl_surface); \ + } + +#define SDL_EGL_MakeCurrent_impl(BACKEND) \ + bool BACKEND##_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) \ + { \ + return SDL_EGL_MakeCurrent(_this, window ? window->internal->egl_surface : EGL_NO_SURFACE, context); \ + } + +#define SDL_EGL_CreateContext_impl(BACKEND) \ + SDL_GLContext BACKEND##_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) \ + { \ + return SDL_EGL_CreateContext(_this, window->internal->egl_surface); \ + } + +#endif // SDL_VIDEO_OPENGL_EGL + +#endif // SDL_egl_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_fillrect.c b/contrib/SDL-3.2.8/src/video/SDL_fillrect.c new file mode 100644 index 0000000..3ab24a9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_fillrect.c @@ -0,0 +1,369 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_surface_c.h" + +#ifdef SDL_SSE_INTRINSICS +/* *INDENT-OFF* */ // clang-format off + +#if defined(_MSC_VER) && !defined(__clang__) +#define SSE_BEGIN \ + __m128 c128; \ + c128.m128_u32[0] = color; \ + c128.m128_u32[1] = color; \ + c128.m128_u32[2] = color; \ + c128.m128_u32[3] = color; +#else +#define SSE_BEGIN \ + __m128 c128; \ + DECLARE_ALIGNED(Uint32, cccc[4], 16); \ + cccc[0] = color; \ + cccc[1] = color; \ + cccc[2] = color; \ + cccc[3] = color; \ + c128 = *(__m128 *)cccc; +#endif + +#define SSE_WORK \ + for (i = n / 64; i--;) { \ + _mm_stream_ps((float *)(p+0), c128); \ + _mm_stream_ps((float *)(p+16), c128); \ + _mm_stream_ps((float *)(p+32), c128); \ + _mm_stream_ps((float *)(p+48), c128); \ + p += 64; \ + } + +#define SSE_END + +#define DEFINE_SSE_FILLRECT(bpp, type) \ +static void SDL_TARGETING("sse") SDL_FillSurfaceRect##bpp##SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) \ +{ \ + int i, n; \ + Uint8 *p = NULL; \ + \ + /* If the number of bytes per row is equal to the pitch, treat */ \ + /* all rows as one long continuous row (for better performance) */ \ + if ((w) * (bpp) == pitch) { \ + w = w * h; \ + h = 1; \ + } \ + \ + SSE_BEGIN; \ + \ + while (h--) { \ + n = (w) * (bpp); \ + p = pixels; \ + \ + if (n > 63) { \ + int adjust = 16 - ((uintptr_t)p & 15); \ + if (adjust < 16) { \ + n -= adjust; \ + adjust /= (bpp); \ + while (adjust--) { \ + *((type *)p) = (type)color; \ + p += (bpp); \ + } \ + } \ + SSE_WORK; \ + } \ + if (n & 63) { \ + int remainder = (n & 63); \ + remainder /= (bpp); \ + while (remainder--) { \ + *((type *)p) = (type)color; \ + p += (bpp); \ + } \ + } \ + pixels += pitch; \ + } \ + \ + SSE_END; \ +} + +static void SDL_TARGETING("sse") SDL_FillSurfaceRect1SSE(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + int i, n; + + SSE_BEGIN; + while (h--) { + Uint8 *p = pixels; + n = w; + + if (n > 63) { + int adjust = 16 - ((uintptr_t)p & 15); + if (adjust) { + n -= adjust; + SDL_memset(p, color, adjust); + p += adjust; + } + SSE_WORK; + } + if (n & 63) { + int remainder = (n & 63); + SDL_memset(p, color, remainder); + } + pixels += pitch; + } + + SSE_END; +} +// DEFINE_SSE_FILLRECT(1, Uint8) +DEFINE_SSE_FILLRECT(2, Uint16) +DEFINE_SSE_FILLRECT(4, Uint32) + +/* *INDENT-ON* */ // clang-format on +#endif // __SSE__ + +static void SDL_FillSurfaceRect1(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + int n; + Uint8 *p = NULL; + + while (h--) { + n = w; + p = pixels; + + if (n > 3) { + switch ((uintptr_t)p & 3) { + case 1: + *p++ = (Uint8)color; + --n; + SDL_FALLTHROUGH; + case 2: + *p++ = (Uint8)color; + --n; + SDL_FALLTHROUGH; + case 3: + *p++ = (Uint8)color; + --n; + } + SDL_memset4(p, color, (n >> 2)); + } + if (n & 3) { + p += (n & ~3); + switch (n & 3) { + case 3: + *p++ = (Uint8)color; + SDL_FALLTHROUGH; + case 2: + *p++ = (Uint8)color; + SDL_FALLTHROUGH; + case 1: + *p++ = (Uint8)color; + } + } + pixels += pitch; + } +} + +static void SDL_FillSurfaceRect2(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + int n; + Uint16 *p = NULL; + + while (h--) { + n = w; + p = (Uint16 *)pixels; + + if (n > 1) { + if ((uintptr_t)p & 2) { + *p++ = (Uint16)color; + --n; + } + SDL_memset4(p, color, (n >> 1)); + } + if (n & 1) { + p[n - 1] = (Uint16)color; + } + pixels += pitch; + } +} + +static void SDL_FillSurfaceRect3(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + Uint8 b1 = (Uint8)(color & 0xFF); + Uint8 b2 = (Uint8)((color >> 8) & 0xFF); + Uint8 b3 = (Uint8)((color >> 16) & 0xFF); +#elif SDL_BYTEORDER == SDL_BIG_ENDIAN + Uint8 b1 = (Uint8)((color >> 16) & 0xFF); + Uint8 b2 = (Uint8)((color >> 8) & 0xFF); + Uint8 b3 = (Uint8)(color & 0xFF); +#endif + int n; + Uint8 *p = NULL; + + while (h--) { + n = w; + p = pixels; + + while (n--) { + *p++ = b1; + *p++ = b2; + *p++ = b3; + } + pixels += pitch; + } +} + +static void SDL_FillSurfaceRect4(Uint8 *pixels, int pitch, Uint32 color, int w, int h) +{ + while (h--) { + SDL_memset4(pixels, color, w); + pixels += pitch; + } +} + +/* + * This function performs a fast fill of the given rectangle with 'color' + */ +bool SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) +{ + if (!SDL_SurfaceValid(dst)) { + return SDL_InvalidParamError("SDL_FillSurfaceRect(): dst"); + } + + // If 'rect' == NULL, then fill the whole surface + if (!rect) { + rect = &dst->clip_rect; + // Don't attempt to fill if the surface's clip_rect is empty + if (SDL_RectEmpty(rect)) { + return true; + } + } + + return SDL_FillSurfaceRects(dst, rect, 1, color); +} + +bool SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, Uint32 color) +{ + SDL_Rect clipped; + Uint8 *pixels; + const SDL_Rect *rect; + void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL; + int i; + + if (!SDL_SurfaceValid(dst)) { + return SDL_InvalidParamError("SDL_FillSurfaceRects(): dst"); + } + + // Nothing to do + if (dst->w == 0 || dst->h == 0) { + return true; + } + + // Perform software fill + if (!dst->pixels) { + return SDL_SetError("SDL_FillSurfaceRects(): You must lock the surface"); + } + + if (!rects) { + return SDL_InvalidParamError("SDL_FillSurfaceRects(): rects"); + } + + /* This function doesn't usually work on surfaces < 8 bpp + * Except: support for 4bits, when filling full size. + */ + if (SDL_BITSPERPIXEL(dst->format) < 8) { + if (count == 1) { + const SDL_Rect *r = &rects[0]; + if (r->x == 0 && r->y == 0 && r->w == dst->w && r->h == dst->h) { + if (SDL_BITSPERPIXEL(dst->format) == 4) { + Uint8 b = (((Uint8)color << 4) | (Uint8)color); + SDL_memset(dst->pixels, b, (size_t)dst->h * dst->pitch); + return true; + } + } + } + return SDL_SetError("SDL_FillSurfaceRects(): Unsupported surface format"); + } + + if (fill_function == NULL) { + switch (SDL_BYTESPERPIXEL(dst->format)) { + case 1: + { + color |= (color << 8); + color |= (color << 16); +#ifdef SDL_SSE_INTRINSICS + if (SDL_HasSSE()) { + fill_function = SDL_FillSurfaceRect1SSE; + break; + } +#endif + fill_function = SDL_FillSurfaceRect1; + break; + } + + case 2: + { + color |= (color << 16); +#ifdef SDL_SSE_INTRINSICS + if (SDL_HasSSE()) { + fill_function = SDL_FillSurfaceRect2SSE; + break; + } +#endif + fill_function = SDL_FillSurfaceRect2; + break; + } + + case 3: + // 24-bit RGB is a slow path, at least for now. + { + fill_function = SDL_FillSurfaceRect3; + break; + } + + case 4: + { +#ifdef SDL_SSE_INTRINSICS + if (SDL_HasSSE()) { + fill_function = SDL_FillSurfaceRect4SSE; + break; + } +#endif + fill_function = SDL_FillSurfaceRect4; + break; + } + + default: + return SDL_SetError("Unsupported pixel format"); + } + } + + for (i = 0; i < count; ++i) { + rect = &rects[i]; + // Perform clipping + if (!SDL_GetRectIntersection(rect, &dst->clip_rect, &clipped)) { + continue; + } + rect = &clipped; + + pixels = (Uint8 *)dst->pixels + rect->y * dst->pitch + + rect->x * SDL_BYTESPERPIXEL(dst->format); + + fill_function(pixels, dst->pitch, color, rect->w, rect->h); + } + + // We're done! + return true; +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_pixels.c b/contrib/SDL-3.2.8/src/video/SDL_pixels.c new file mode 100644 index 0000000..5fede22 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_pixels.c @@ -0,0 +1,1530 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +// General (mostly internal) pixel/color manipulation routines for SDL + +#include "SDL_sysvideo.h" +#include "SDL_pixels_c.h" +#include "SDL_RLEaccel_c.h" + +// Lookup tables to expand partial bytes to the full 0..255 range + +static const Uint8 lookup_0[] = { + 255 +}; + +static const Uint8 lookup_1[] = { + 0, 255 +}; + +static const Uint8 lookup_2[] = { + 0, 85, 170, 255 +}; + +static const Uint8 lookup_3[] = { + 0, 36, 72, 109, 145, 182, 218, 255 +}; + +static const Uint8 lookup_4[] = { + 0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255 +}; + +static const Uint8 lookup_5[] = { + 0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255 +}; + +static const Uint8 lookup_6[] = { + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255 +}; + +static const Uint8 lookup_7[] = { + 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255 +}; + +static const Uint8 lookup_8[] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 +}; + +const Uint8 *SDL_expand_byte[9] = { + lookup_0, + lookup_1, + lookup_2, + lookup_3, + lookup_4, + lookup_5, + lookup_6, + lookup_7, + lookup_8 +}; + +// Lookup tables to expand 8 bit to 10 bit range +const Uint16 SDL_expand_byte_10[] = { + 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 84, 88, 92, 96, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 277, 281, 285, 289, 293, 297, 301, 305, 309, 313, 317, 321, 325, 329, 333, 337, 341, 345, 349, 353, 357, 361, 365, 369, 373, 377, 381, 385, 389, 393, 397, 401, 405, 409, 413, 417, 421, 425, 429, 433, 437, 441, 445, 449, 453, 457, 461, 465, 469, 473, 477, 481, 485, 489, 493, 497, 501, 505, 509, 514, 518, 522, 526, 530, 534, 538, 542, 546, 550, 554, 558, 562, 566, 570, 574, 578, 582, 586, 590, 594, 598, 602, 606, 610, 614, 618, 622, 626, 630, 634, 638, 642, 646, 650, 654, 658, 662, 666, 670, 674, 678, 682, 686, 690, 694, 698, 702, 706, 710, 714, 718, 722, 726, 730, 734, 738, 742, 746, 750, 754, 758, 762, 766, 770, 774, 778, 782, 786, 790, 794, 798, 802, 806, 810, 814, 818, 822, 826, 830, 834, 838, 842, 846, 850, 855, 859, 863, 867, 871, 875, 879, 883, 887, 891, 895, 899, 903, 907, 911, 915, 919, 923, 927, 931, 935, 939, 943, 947, 951, 955, 959, 963, 967, 971, 975, 979, 983, 987, 991, 995, 999, 1003, 1007, 1011, 1015, 1019, 1023 +}; +SDL_COMPILE_TIME_ASSERT(SDL_expand_byte_10_size, SDL_arraysize(SDL_expand_byte_10) == (1 << 8)); + + +// Helper functions + +#define CASE(X) \ + case X: \ + return #X; +const char *SDL_GetPixelFormatName(SDL_PixelFormat format) +{ + switch (format) { + + CASE(SDL_PIXELFORMAT_INDEX1LSB) + CASE(SDL_PIXELFORMAT_INDEX1MSB) + CASE(SDL_PIXELFORMAT_INDEX2LSB) + CASE(SDL_PIXELFORMAT_INDEX2MSB) + CASE(SDL_PIXELFORMAT_INDEX4LSB) + CASE(SDL_PIXELFORMAT_INDEX4MSB) + CASE(SDL_PIXELFORMAT_INDEX8) + CASE(SDL_PIXELFORMAT_RGB332) + CASE(SDL_PIXELFORMAT_XRGB4444) + CASE(SDL_PIXELFORMAT_XBGR4444) + CASE(SDL_PIXELFORMAT_XRGB1555) + CASE(SDL_PIXELFORMAT_XBGR1555) + CASE(SDL_PIXELFORMAT_ARGB4444) + CASE(SDL_PIXELFORMAT_RGBA4444) + CASE(SDL_PIXELFORMAT_ABGR4444) + CASE(SDL_PIXELFORMAT_BGRA4444) + CASE(SDL_PIXELFORMAT_ARGB1555) + CASE(SDL_PIXELFORMAT_RGBA5551) + CASE(SDL_PIXELFORMAT_ABGR1555) + CASE(SDL_PIXELFORMAT_BGRA5551) + CASE(SDL_PIXELFORMAT_RGB565) + CASE(SDL_PIXELFORMAT_BGR565) + CASE(SDL_PIXELFORMAT_RGB24) + CASE(SDL_PIXELFORMAT_BGR24) + CASE(SDL_PIXELFORMAT_XRGB8888) + CASE(SDL_PIXELFORMAT_RGBX8888) + CASE(SDL_PIXELFORMAT_XBGR8888) + CASE(SDL_PIXELFORMAT_BGRX8888) + CASE(SDL_PIXELFORMAT_ARGB8888) + CASE(SDL_PIXELFORMAT_RGBA8888) + CASE(SDL_PIXELFORMAT_ABGR8888) + CASE(SDL_PIXELFORMAT_BGRA8888) + CASE(SDL_PIXELFORMAT_XRGB2101010) + CASE(SDL_PIXELFORMAT_XBGR2101010) + CASE(SDL_PIXELFORMAT_ARGB2101010) + CASE(SDL_PIXELFORMAT_ABGR2101010) + CASE(SDL_PIXELFORMAT_RGB48) + CASE(SDL_PIXELFORMAT_BGR48) + CASE(SDL_PIXELFORMAT_RGBA64) + CASE(SDL_PIXELFORMAT_ARGB64) + CASE(SDL_PIXELFORMAT_BGRA64) + CASE(SDL_PIXELFORMAT_ABGR64) + CASE(SDL_PIXELFORMAT_RGB48_FLOAT) + CASE(SDL_PIXELFORMAT_BGR48_FLOAT) + CASE(SDL_PIXELFORMAT_RGBA64_FLOAT) + CASE(SDL_PIXELFORMAT_ARGB64_FLOAT) + CASE(SDL_PIXELFORMAT_BGRA64_FLOAT) + CASE(SDL_PIXELFORMAT_ABGR64_FLOAT) + CASE(SDL_PIXELFORMAT_RGB96_FLOAT) + CASE(SDL_PIXELFORMAT_BGR96_FLOAT) + CASE(SDL_PIXELFORMAT_RGBA128_FLOAT) + CASE(SDL_PIXELFORMAT_ARGB128_FLOAT) + CASE(SDL_PIXELFORMAT_BGRA128_FLOAT) + CASE(SDL_PIXELFORMAT_ABGR128_FLOAT) + CASE(SDL_PIXELFORMAT_YV12) + CASE(SDL_PIXELFORMAT_IYUV) + CASE(SDL_PIXELFORMAT_YUY2) + CASE(SDL_PIXELFORMAT_UYVY) + CASE(SDL_PIXELFORMAT_YVYU) + CASE(SDL_PIXELFORMAT_NV12) + CASE(SDL_PIXELFORMAT_NV21) + CASE(SDL_PIXELFORMAT_P010) + CASE(SDL_PIXELFORMAT_EXTERNAL_OES) + CASE(SDL_PIXELFORMAT_MJPG) + + default: + return "SDL_PIXELFORMAT_UNKNOWN"; + } +} +#undef CASE + +bool SDL_GetMasksForPixelFormat(SDL_PixelFormat format, int *bpp, Uint32 *Rmask, Uint32 *Gmask, Uint32 *Bmask, Uint32 *Amask) +{ + Uint32 masks[4]; + +#ifdef SDL_HAVE_YUV + // Partial support for SDL_Surface with FOURCC + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + // Not a format that uses masks + *Rmask = *Gmask = *Bmask = *Amask = 0; + // however, some of these are packed formats, and can legit declare bits-per-pixel! + switch (format) { + case SDL_PIXELFORMAT_YUY2: + case SDL_PIXELFORMAT_UYVY: + case SDL_PIXELFORMAT_YVYU: + *bpp = 32; + break; + default: + *bpp = 0; // oh well. + } + return true; + } +#else + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + return SDL_SetError("SDL not built with YUV support"); + } +#endif + + // Initialize the values here + if (SDL_BYTESPERPIXEL(format) <= 2) { + *bpp = SDL_BITSPERPIXEL(format); + } else { + *bpp = SDL_BYTESPERPIXEL(format) * 8; + } + *Rmask = *Gmask = *Bmask = *Amask = 0; + + if (format == SDL_PIXELFORMAT_RGB24) { +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + *Rmask = 0x00FF0000; + *Gmask = 0x0000FF00; + *Bmask = 0x000000FF; +#else + *Rmask = 0x000000FF; + *Gmask = 0x0000FF00; + *Bmask = 0x00FF0000; +#endif + return true; + } + + if (format == SDL_PIXELFORMAT_BGR24) { +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + *Rmask = 0x000000FF; + *Gmask = 0x0000FF00; + *Bmask = 0x00FF0000; +#else + *Rmask = 0x00FF0000; + *Gmask = 0x0000FF00; + *Bmask = 0x000000FF; +#endif + return true; + } + + if (SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED8 && + SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED16 && + SDL_PIXELTYPE(format) != SDL_PIXELTYPE_PACKED32) { + // Not a format that uses masks + return true; + } + + switch (SDL_PIXELLAYOUT(format)) { + case SDL_PACKEDLAYOUT_332: + masks[0] = 0x00000000; + masks[1] = 0x000000E0; + masks[2] = 0x0000001C; + masks[3] = 0x00000003; + break; + case SDL_PACKEDLAYOUT_4444: + masks[0] = 0x0000F000; + masks[1] = 0x00000F00; + masks[2] = 0x000000F0; + masks[3] = 0x0000000F; + break; + case SDL_PACKEDLAYOUT_1555: + masks[0] = 0x00008000; + masks[1] = 0x00007C00; + masks[2] = 0x000003E0; + masks[3] = 0x0000001F; + break; + case SDL_PACKEDLAYOUT_5551: + masks[0] = 0x0000F800; + masks[1] = 0x000007C0; + masks[2] = 0x0000003E; + masks[3] = 0x00000001; + break; + case SDL_PACKEDLAYOUT_565: + masks[0] = 0x00000000; + masks[1] = 0x0000F800; + masks[2] = 0x000007E0; + masks[3] = 0x0000001F; + break; + case SDL_PACKEDLAYOUT_8888: + masks[0] = 0xFF000000; + masks[1] = 0x00FF0000; + masks[2] = 0x0000FF00; + masks[3] = 0x000000FF; + break; + case SDL_PACKEDLAYOUT_2101010: + masks[0] = 0xC0000000; + masks[1] = 0x3FF00000; + masks[2] = 0x000FFC00; + masks[3] = 0x000003FF; + break; + case SDL_PACKEDLAYOUT_1010102: + masks[0] = 0xFFC00000; + masks[1] = 0x003FF000; + masks[2] = 0x00000FFC; + masks[3] = 0x00000003; + break; + default: + return SDL_SetError("Unknown pixel format"); + } + + switch (SDL_PIXELORDER(format)) { + case SDL_PACKEDORDER_XRGB: + *Rmask = masks[1]; + *Gmask = masks[2]; + *Bmask = masks[3]; + break; + case SDL_PACKEDORDER_RGBX: + *Rmask = masks[0]; + *Gmask = masks[1]; + *Bmask = masks[2]; + break; + case SDL_PACKEDORDER_ARGB: + *Amask = masks[0]; + *Rmask = masks[1]; + *Gmask = masks[2]; + *Bmask = masks[3]; + break; + case SDL_PACKEDORDER_RGBA: + *Rmask = masks[0]; + *Gmask = masks[1]; + *Bmask = masks[2]; + *Amask = masks[3]; + break; + case SDL_PACKEDORDER_XBGR: + *Bmask = masks[1]; + *Gmask = masks[2]; + *Rmask = masks[3]; + break; + case SDL_PACKEDORDER_BGRX: + *Bmask = masks[0]; + *Gmask = masks[1]; + *Rmask = masks[2]; + break; + case SDL_PACKEDORDER_BGRA: + *Bmask = masks[0]; + *Gmask = masks[1]; + *Rmask = masks[2]; + *Amask = masks[3]; + break; + case SDL_PACKEDORDER_ABGR: + *Amask = masks[0]; + *Bmask = masks[1]; + *Gmask = masks[2]; + *Rmask = masks[3]; + break; + default: + return SDL_SetError("Unknown pixel format"); + } + return true; +} + +SDL_PixelFormat SDL_GetPixelFormatForMasks(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) +{ + switch (bpp) { + case 1: + // SDL defaults to MSB ordering + return SDL_PIXELFORMAT_INDEX1MSB; + case 2: + // SDL defaults to MSB ordering + return SDL_PIXELFORMAT_INDEX2MSB; + case 4: + // SDL defaults to MSB ordering + return SDL_PIXELFORMAT_INDEX4MSB; + case 8: + if (Rmask == 0xE0 && + Gmask == 0x1C && + Bmask == 0x03 && + Amask == 0x00) { + return SDL_PIXELFORMAT_RGB332; + } + return SDL_PIXELFORMAT_INDEX8; + case 12: + if (Rmask == 0) { + return SDL_PIXELFORMAT_XRGB4444; + } + if (Rmask == 0x0F00 && + Gmask == 0x00F0 && + Bmask == 0x000F && + Amask == 0x0000) { + return SDL_PIXELFORMAT_XRGB4444; + } + if (Rmask == 0x000F && + Gmask == 0x00F0 && + Bmask == 0x0F00 && + Amask == 0x0000) { + return SDL_PIXELFORMAT_XBGR4444; + } + break; + case 15: + if (Rmask == 0) { + return SDL_PIXELFORMAT_XRGB1555; + } + SDL_FALLTHROUGH; + case 16: + if (Rmask == 0) { + return SDL_PIXELFORMAT_RGB565; + } + if (Rmask == 0x7C00 && + Gmask == 0x03E0 && + Bmask == 0x001F && + Amask == 0x0000) { + return SDL_PIXELFORMAT_XRGB1555; + } + if (Rmask == 0x001F && + Gmask == 0x03E0 && + Bmask == 0x7C00 && + Amask == 0x0000) { + return SDL_PIXELFORMAT_XBGR1555; + } + if (Rmask == 0x0F00 && + Gmask == 0x00F0 && + Bmask == 0x000F && + Amask == 0xF000) { + return SDL_PIXELFORMAT_ARGB4444; + } + if (Rmask == 0xF000 && + Gmask == 0x0F00 && + Bmask == 0x00F0 && + Amask == 0x000F) { + return SDL_PIXELFORMAT_RGBA4444; + } + if (Rmask == 0x000F && + Gmask == 0x00F0 && + Bmask == 0x0F00 && + Amask == 0xF000) { + return SDL_PIXELFORMAT_ABGR4444; + } + if (Rmask == 0x00F0 && + Gmask == 0x0F00 && + Bmask == 0xF000 && + Amask == 0x000F) { + return SDL_PIXELFORMAT_BGRA4444; + } + if (Rmask == 0x7C00 && + Gmask == 0x03E0 && + Bmask == 0x001F && + Amask == 0x8000) { + return SDL_PIXELFORMAT_ARGB1555; + } + if (Rmask == 0xF800 && + Gmask == 0x07C0 && + Bmask == 0x003E && + Amask == 0x0001) { + return SDL_PIXELFORMAT_RGBA5551; + } + if (Rmask == 0x001F && + Gmask == 0x03E0 && + Bmask == 0x7C00 && + Amask == 0x8000) { + return SDL_PIXELFORMAT_ABGR1555; + } + if (Rmask == 0x003E && + Gmask == 0x07C0 && + Bmask == 0xF800 && + Amask == 0x0001) { + return SDL_PIXELFORMAT_BGRA5551; + } + if (Rmask == 0xF800 && + Gmask == 0x07E0 && + Bmask == 0x001F && + Amask == 0x0000) { + return SDL_PIXELFORMAT_RGB565; + } + if (Rmask == 0x001F && + Gmask == 0x07E0 && + Bmask == 0xF800 && + Amask == 0x0000) { + return SDL_PIXELFORMAT_BGR565; + } + if (Rmask == 0x003F && + Gmask == 0x07C0 && + Bmask == 0xF800 && + Amask == 0x0000) { + // Technically this would be BGR556, but Witek says this works in bug 3158 + return SDL_PIXELFORMAT_RGB565; + } + break; + case 24: + switch (Rmask) { + case 0: + case 0x00FF0000: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + return SDL_PIXELFORMAT_RGB24; +#else + return SDL_PIXELFORMAT_BGR24; +#endif + case 0x000000FF: +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + return SDL_PIXELFORMAT_BGR24; +#else + return SDL_PIXELFORMAT_RGB24; +#endif + } + break; + case 30: + if (Rmask == 0x3FF00000 && + Gmask == 0x000FFC00 && + Bmask == 0x000003FF && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_XRGB2101010; + } + if (Rmask == 0x000003FF && + Gmask == 0x000FFC00 && + Bmask == 0x3FF00000 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_XBGR2101010; + } + break; + case 32: + if (Rmask == 0) { + return SDL_PIXELFORMAT_XRGB8888; + } + if (Rmask == 0x00FF0000 && + Gmask == 0x0000FF00 && + Bmask == 0x000000FF && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_XRGB8888; + } + if (Rmask == 0xFF000000 && + Gmask == 0x00FF0000 && + Bmask == 0x0000FF00 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_RGBX8888; + } + if (Rmask == 0x000000FF && + Gmask == 0x0000FF00 && + Bmask == 0x00FF0000 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_XBGR8888; + } + if (Rmask == 0x0000FF00 && + Gmask == 0x00FF0000 && + Bmask == 0xFF000000 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_BGRX8888; + } + if (Rmask == 0x00FF0000 && + Gmask == 0x0000FF00 && + Bmask == 0x000000FF && + Amask == 0xFF000000) { + return SDL_PIXELFORMAT_ARGB8888; + } + if (Rmask == 0xFF000000 && + Gmask == 0x00FF0000 && + Bmask == 0x0000FF00 && + Amask == 0x000000FF) { + return SDL_PIXELFORMAT_RGBA8888; + } + if (Rmask == 0x000000FF && + Gmask == 0x0000FF00 && + Bmask == 0x00FF0000 && + Amask == 0xFF000000) { + return SDL_PIXELFORMAT_ABGR8888; + } + if (Rmask == 0x0000FF00 && + Gmask == 0x00FF0000 && + Bmask == 0xFF000000 && + Amask == 0x000000FF) { + return SDL_PIXELFORMAT_BGRA8888; + } + if (Rmask == 0x3FF00000 && + Gmask == 0x000FFC00 && + Bmask == 0x000003FF && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_XRGB2101010; + } + if (Rmask == 0x000003FF && + Gmask == 0x000FFC00 && + Bmask == 0x3FF00000 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_XBGR2101010; + } + if (Rmask == 0x3FF00000 && + Gmask == 0x000FFC00 && + Bmask == 0x000003FF && + Amask == 0xC0000000) { + return SDL_PIXELFORMAT_ARGB2101010; + } + if (Rmask == 0x000003FF && + Gmask == 0x000FFC00 && + Bmask == 0x3FF00000 && + Amask == 0xC0000000) { + return SDL_PIXELFORMAT_ABGR2101010; + } + break; + } + return SDL_PIXELFORMAT_UNKNOWN; +} + +static SDL_InitState SDL_format_details_init; +static SDL_HashTable *SDL_format_details; + +static bool SDL_InitPixelFormatDetails(SDL_PixelFormatDetails *details, SDL_PixelFormat format) +{ + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + Uint32 mask; + + if (!SDL_GetMasksForPixelFormat(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + return false; + } + + // Set up the format + SDL_zerop(details); + details->format = format; + details->bits_per_pixel = (Uint8)bpp; + details->bytes_per_pixel = (Uint8)((bpp + 7) / 8); + + details->Rmask = Rmask; + details->Rshift = 0; + details->Rbits = 0; + if (Rmask) { + for (mask = Rmask; !(mask & 0x01); mask >>= 1) { + ++details->Rshift; + } + for (; (mask & 0x01); mask >>= 1) { + ++details->Rbits; + } + } + + details->Gmask = Gmask; + details->Gshift = 0; + details->Gbits = 0; + if (Gmask) { + for (mask = Gmask; !(mask & 0x01); mask >>= 1) { + ++details->Gshift; + } + for (; (mask & 0x01); mask >>= 1) { + ++details->Gbits; + } + } + + details->Bmask = Bmask; + details->Bshift = 0; + details->Bbits = 0; + if (Bmask) { + for (mask = Bmask; !(mask & 0x01); mask >>= 1) { + ++details->Bshift; + } + for (; (mask & 0x01); mask >>= 1) { + ++details->Bbits; + } + } + + details->Amask = Amask; + details->Ashift = 0; + details->Abits = 0; + if (Amask) { + for (mask = Amask; !(mask & 0x01); mask >>= 1) { + ++details->Ashift; + } + for (; (mask & 0x01); mask >>= 1) { + ++details->Abits; + } + } + + return true; +} + +const SDL_PixelFormatDetails *SDL_GetPixelFormatDetails(SDL_PixelFormat format) +{ + SDL_PixelFormatDetails *details; + + if (SDL_ShouldInit(&SDL_format_details_init)) { + SDL_format_details = SDL_CreateHashTable(0, true, SDL_HashID, SDL_KeyMatchID, SDL_DestroyHashValue, NULL); + if (!SDL_format_details) { + SDL_SetInitialized(&SDL_format_details_init, false); + return NULL; + } + SDL_SetInitialized(&SDL_format_details_init, true); + } + + if (SDL_FindInHashTable(SDL_format_details, (const void *)(uintptr_t)format, (const void **)&details)) { + return details; + } + + // Allocate an empty pixel format structure, and initialize it + details = (SDL_PixelFormatDetails *)SDL_malloc(sizeof(*details)); + if (!details) { + return NULL; + } + + if (!SDL_InitPixelFormatDetails(details, format)) { + SDL_free(details); + return NULL; + } + + if (!SDL_InsertIntoHashTable(SDL_format_details, (const void *)(uintptr_t)format, (void *)details, false)) { + SDL_free(details); + // uh...did another thread beat us to inserting this? + if (SDL_FindInHashTable(SDL_format_details, (const void *)(uintptr_t)format, (const void **)&details)) { + return details; + } + return NULL; // oh well. + } + + return details; +} + +void SDL_QuitPixelFormatDetails(void) +{ + if (SDL_ShouldQuit(&SDL_format_details_init)) { + SDL_DestroyHashTable(SDL_format_details); + SDL_format_details = NULL; + SDL_SetInitialized(&SDL_format_details_init, false); + } +} + +SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormat format) +{ + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + if (format == SDL_PIXELFORMAT_MJPG) { + return SDL_COLORSPACE_SRGB; + } else if (format == SDL_PIXELFORMAT_P010) { + return SDL_COLORSPACE_HDR10; + } else { + return SDL_COLORSPACE_YUV_DEFAULT; + } + } else if (SDL_ISPIXELFORMAT_FLOAT(format)) { + return SDL_COLORSPACE_SRGB_LINEAR; + } else if (SDL_ISPIXELFORMAT_10BIT(format)) { + return SDL_COLORSPACE_HDR10; + } else { + return SDL_COLORSPACE_RGB_DEFAULT; + } +} + +float SDL_sRGBtoLinear(float v) +{ + if (v <= 0.04045f) { + v = (v / 12.92f); + } else { + v = SDL_powf((v + 0.055f) / 1.055f, 2.4f); + } + return v; +} + +float SDL_sRGBfromLinear(float v) +{ + if (v <= 0.0031308f) { + v = (v * 12.92f); + } else { + v = (SDL_powf(v, 1.0f / 2.4f) * 1.055f - 0.055f); + } + return v; +} + +float SDL_PQtoNits(float v) +{ + const float c1 = 0.8359375f; + const float c2 = 18.8515625f; + const float c3 = 18.6875f; + const float oo_m1 = 1.0f / 0.1593017578125f; + const float oo_m2 = 1.0f / 78.84375f; + + float num = SDL_max(SDL_powf(v, oo_m2) - c1, 0.0f); + float den = c2 - c3 * SDL_powf(v, oo_m2); + return 10000.0f * SDL_powf(num / den, oo_m1); +} + +float SDL_PQfromNits(float v) +{ + const float c1 = 0.8359375f; + const float c2 = 18.8515625f; + const float c3 = 18.6875f; + const float m1 = 0.1593017578125f; + const float m2 = 78.84375f; + + float y = SDL_clamp(v / 10000.0f, 0.0f, 1.0f); + float num = c1 + c2 * SDL_powf(y, m1); + float den = 1.0f + c3 * SDL_powf(y, m1); + return SDL_powf(num / den, m2); +} + +/* This is a helpful tool for deriving these: + * https://kdashg.github.io/misc/colors/from-coeffs.html + */ +static const float mat_BT601_Limited_8bit[] = { + -0.0627451017f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.1644f, 0.0000f, 1.5960f, 0.0f, // Rcoeff + 1.1644f, -0.3918f, -0.8130f, 0.0f, // Gcoeff + 1.1644f, 2.0172f, 0.0000f, 0.0f, // Bcoeff +}; + +static const float mat_BT601_Full_8bit[] = { + 0.0f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.0000f, 0.0000f, 1.4075f, 0.0f, // Rcoeff + 1.0000f, -0.3455f, -0.7169f, 0.0f, // Gcoeff + 1.0000f, 1.7790f, 0.0000f, 0.0f, // Bcoeff +}; + +static const float mat_BT709_Limited_8bit[] = { + -0.0627451017f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.1644f, 0.0000f, 1.7927f, 0.0f, // Rcoeff + 1.1644f, -0.2132f, -0.5329f, 0.0f, // Gcoeff + 1.1644f, 2.1124f, 0.0000f, 0.0f, // Bcoeff +}; + +static const float mat_BT709_Full_8bit[] = { + 0.0f, -0.501960814f, -0.501960814f, 0.0f, // offset + 1.0000f, 0.0000f, 1.5810f, 0.0f, // Rcoeff + 1.0000f, -0.1881f, -0.4700f, 0.0f, // Gcoeff + 1.0000f, 1.8629f, 0.0000f, 0.0f, // Bcoeff +}; + +static const float mat_BT2020_Limited_10bit[] = { + -0.062561095f, -0.500488759f, -0.500488759f, 0.0f, // offset + 1.1678f, 0.0000f, 1.6836f, 0.0f, // Rcoeff + 1.1678f, -0.1879f, -0.6523f, 0.0f, // Gcoeff + 1.1678f, 2.1481f, 0.0000f, 0.0f, // Bcoeff +}; + +static const float mat_BT2020_Full_10bit[] = { + 0.0f, -0.500488759f, -0.500488759f, 0.0f, // offset + 1.0000f, 0.0000f, 1.4760f, 0.0f, // Rcoeff + 1.0000f, -0.1647f, -0.5719f, 0.0f, // Gcoeff + 1.0000f, 1.8832f, 0.0000f, 0.0f, // Bcoeff +}; + +static const float *SDL_GetBT601ConversionMatrix( SDL_Colorspace colorspace ) +{ + switch (SDL_COLORSPACERANGE(colorspace)) { + case SDL_COLOR_RANGE_LIMITED: + case SDL_COLOR_RANGE_UNKNOWN: + return mat_BT601_Limited_8bit; + case SDL_COLOR_RANGE_FULL: + return mat_BT601_Full_8bit; + default: + break; + } + return NULL; +} + +static const float *SDL_GetBT709ConversionMatrix(SDL_Colorspace colorspace) +{ + switch (SDL_COLORSPACERANGE(colorspace)) { + case SDL_COLOR_RANGE_LIMITED: + case SDL_COLOR_RANGE_UNKNOWN: + return mat_BT709_Limited_8bit; + case SDL_COLOR_RANGE_FULL: + return mat_BT709_Full_8bit; + default: + break; + } + return NULL; +} + +static const float *SDL_GetBT2020ConversionMatrix(SDL_Colorspace colorspace) +{ + switch (SDL_COLORSPACERANGE(colorspace)) { + case SDL_COLOR_RANGE_LIMITED: + case SDL_COLOR_RANGE_UNKNOWN: + return mat_BT2020_Limited_10bit; + case SDL_COLOR_RANGE_FULL: + return mat_BT2020_Full_10bit; + default: + break; + } + return NULL; +} + +const float *SDL_GetYCbCRtoRGBConversionMatrix(SDL_Colorspace colorspace, int w, int h, int bits_per_pixel) +{ + const int YUV_SD_THRESHOLD = 576; + + switch (SDL_COLORSPACEMATRIX(colorspace)) { + case SDL_MATRIX_COEFFICIENTS_BT601: + case SDL_MATRIX_COEFFICIENTS_BT470BG: + return SDL_GetBT601ConversionMatrix(colorspace); + + case SDL_MATRIX_COEFFICIENTS_BT709: + return SDL_GetBT709ConversionMatrix(colorspace); + + case SDL_MATRIX_COEFFICIENTS_BT2020_NCL: + return SDL_GetBT2020ConversionMatrix(colorspace); + + case SDL_MATRIX_COEFFICIENTS_UNSPECIFIED: + switch (bits_per_pixel) { + case 8: + if (h <= YUV_SD_THRESHOLD) { + return SDL_GetBT601ConversionMatrix(colorspace); + } else { + return SDL_GetBT709ConversionMatrix(colorspace); + } + case 10: + case 16: + return SDL_GetBT2020ConversionMatrix(colorspace); + default: + break; + } + break; + default: + break; + } + return NULL; +} + +const float *SDL_GetColorPrimariesConversionMatrix(SDL_ColorPrimaries src, SDL_ColorPrimaries dst) +{ + /* Conversion matrices generated using gamescope color helpers and the primaries definitions at: + * https://www.itu.int/rec/T-REC-H.273-201612-S/en + * + * You can also generate these online using the RGB-XYZ matrix calculator, and then multiplying + * XYZ_to_dst * src_to_XYZ to get the combined conversion matrix: + * https://www.russellcottrell.com/photo/matrixCalculator.htm + */ + static const float mat601to709[] = { + 0.939542f, 0.050181f, 0.010277f, + 0.017772f, 0.965793f, 0.016435f, + -0.001622f, -0.004370f, 1.005991f, + }; + static const float mat601to2020[] = { + 0.595254f, 0.349314f, 0.055432f, + 0.081244f, 0.891503f, 0.027253f, + 0.015512f, 0.081912f, 0.902576f, + }; + static const float mat709to601[] = { + 1.065379f, -0.055401f, -0.009978f, + -0.019633f, 1.036363f, -0.016731f, + 0.001632f, 0.004412f, 0.993956f, + }; + static const float mat709to2020[] = { + 0.627404f, 0.329283f, 0.043313f, + 0.069097f, 0.919541f, 0.011362f, + 0.016391f, 0.088013f, 0.895595f, + }; + static const float mat2020to601[] = { + 1.776133f, -0.687820f, -0.088313f, + -0.161376f, 1.187315f, -0.025940f, + -0.015881f, -0.095931f, 1.111812f, + }; + static const float mat2020to709[] = { + 1.660496f, -0.587656f, -0.072840f, + -0.124547f, 1.132895f, -0.008348f, + -0.018154f, -0.100597f, 1.118751f + }; + static const float matSMPTE431to709[] = { + 1.120713f, -0.234649f, 0.000000f, + -0.038478f, 1.087034f, 0.000000f, + -0.017967f, -0.082030f, 0.954576f, + }; + static const float matSMPTE431to2020[] = { + 0.689691f, 0.207169f, 0.041346f, + 0.041852f, 0.982426f, 0.010846f, + -0.001107f, 0.018362f, 0.854914f, + }; + static const float matSMPTE432to709[] = { + 1.224940f, -0.224940f, -0.000000f, + -0.042057f, 1.042057f, 0.000000f, + -0.019638f, -0.078636f, 1.098273f, + }; + static const float matSMPTE432to2020[] = { + 0.753833f, 0.198597f, 0.047570f, + 0.045744f, 0.941777f, 0.012479f, + -0.001210f, 0.017602f, 0.983609f, + }; + + switch (dst) { + case SDL_COLOR_PRIMARIES_BT601: + case SDL_COLOR_PRIMARIES_SMPTE240: + switch (src) { + case SDL_COLOR_PRIMARIES_BT709: + return mat709to601; + case SDL_COLOR_PRIMARIES_BT2020: + return mat2020to601; + default: + break; + } + break; + case SDL_COLOR_PRIMARIES_BT709: + switch (src) { + case SDL_COLOR_PRIMARIES_BT601: + case SDL_COLOR_PRIMARIES_SMPTE240: + return mat601to709; + case SDL_COLOR_PRIMARIES_BT2020: + return mat2020to709; + case SDL_COLOR_PRIMARIES_SMPTE431: + return matSMPTE431to709; + case SDL_COLOR_PRIMARIES_SMPTE432: + return matSMPTE432to709; + default: + break; + } + break; + case SDL_COLOR_PRIMARIES_BT2020: + switch (src) { + case SDL_COLOR_PRIMARIES_BT601: + case SDL_COLOR_PRIMARIES_SMPTE240: + return mat601to2020; + case SDL_COLOR_PRIMARIES_BT709: + return mat709to2020; + case SDL_COLOR_PRIMARIES_SMPTE431: + return matSMPTE431to2020; + case SDL_COLOR_PRIMARIES_SMPTE432: + return matSMPTE432to2020; + default: + break; + } + break; + default: + break; + } + return NULL; +} + +void SDL_ConvertColorPrimaries(float *fR, float *fG, float *fB, const float *matrix) +{ + float v[3]; + + v[0] = *fR; + v[1] = *fG; + v[2] = *fB; + + *fR = matrix[0 * 3 + 0] * v[0] + matrix[0 * 3 + 1] * v[1] + matrix[0 * 3 + 2] * v[2]; + *fG = matrix[1 * 3 + 0] * v[0] + matrix[1 * 3 + 1] * v[1] + matrix[1 * 3 + 2] * v[2]; + *fB = matrix[2 * 3 + 0] * v[0] + matrix[2 * 3 + 1] * v[1] + matrix[2 * 3 + 2] * v[2]; +} + +SDL_Palette *SDL_CreatePalette(int ncolors) +{ + SDL_Palette *palette; + + // Input validation + if (ncolors < 1) { + SDL_InvalidParamError("ncolors"); + return NULL; + } + + palette = (SDL_Palette *)SDL_malloc(sizeof(*palette)); + if (!palette) { + return NULL; + } + palette->colors = (SDL_Color *)SDL_malloc(ncolors * sizeof(*palette->colors)); + if (!palette->colors) { + SDL_free(palette); + return NULL; + } + palette->ncolors = ncolors; + palette->version = 1; + palette->refcount = 1; + + SDL_memset(palette->colors, 0xFF, ncolors * sizeof(*palette->colors)); + + return palette; +} + +bool SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int firstcolor, int ncolors) +{ + bool result = true; + + // Verify the parameters + if (!palette) { + return false; + } + if (ncolors > (palette->ncolors - firstcolor)) { + ncolors = (palette->ncolors - firstcolor); + result = false; + } + + if (colors != (palette->colors + firstcolor)) { + SDL_memcpy(palette->colors + firstcolor, colors, + ncolors * sizeof(*colors)); + } + ++palette->version; + if (!palette->version) { + palette->version = 1; + } + + return result; +} + +void SDL_DestroyPalette(SDL_Palette *palette) +{ + if (!palette) { + return; + } + if (--palette->refcount > 0) { + return; + } + SDL_free(palette->colors); + SDL_free(palette); +} + +/* + * Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors + */ +void SDL_DitherPalette(SDL_Palette *palette) +{ + int i; + if (palette->ncolors != 256) { + return; // only 8bpp supported right now + } + + for (i = 0; i < palette->ncolors; i++) { + int r, g, b; + /* map each bit field to the full [0, 255] interval, + so 0 is mapped to (0, 0, 0) and 255 to (255, 255, 255) */ + r = i & 0xe0; + r |= r >> 3 | r >> 6; + palette->colors[i].r = (Uint8)r; + g = (i << 3) & 0xe0; + g |= g >> 3 | g >> 6; + palette->colors[i].g = (Uint8)g; + b = i & 0x3; + b |= b << 2; + b |= b << 4; + palette->colors[i].b = (Uint8)b; + palette->colors[i].a = SDL_ALPHA_OPAQUE; + } +} + +/* + * Match an RGB value to a particular palette index + */ +Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + // Do colorspace distance matching + unsigned int smallest; + unsigned int distance; + int rd, gd, bd, ad; + int i; + Uint8 pixel = 0; + + smallest = ~0U; + for (i = 0; i < pal->ncolors; ++i) { + rd = pal->colors[i].r - r; + gd = pal->colors[i].g - g; + bd = pal->colors[i].b - b; + ad = pal->colors[i].a - a; + distance = (rd * rd) + (gd * gd) + (bd * bd) + (ad * ad); + if (distance < smallest) { + pixel = (Uint8)i; + if (distance == 0) { // Perfect match! + break; + } + smallest = distance; + } + } + return pixel; +} + +Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixel, const SDL_Palette *pal) +{ + Uint8 color_index = 0; + const void *value; + if (SDL_FindInHashTable(palette_map, (const void *)(uintptr_t)pixel, &value)) { + color_index = (Uint8)(uintptr_t)value; + } else { + Uint8 r = (Uint8)((pixel >> 24) & 0xFF); + Uint8 g = (Uint8)((pixel >> 16) & 0xFF); + Uint8 b = (Uint8)((pixel >> 8) & 0xFF); + Uint8 a = (Uint8)((pixel >> 0) & 0xFF); + color_index = SDL_FindColor(pal, r, g, b, a); + SDL_InsertIntoHashTable(palette_map, (const void *)(uintptr_t)pixel, (const void *)(uintptr_t)color_index, true); + } + return color_index; +} + +// Tell whether palette is opaque, and if it has an alpha_channel +void SDL_DetectPalette(const SDL_Palette *pal, bool *is_opaque, bool *has_alpha_channel) +{ + int i; + + { + bool all_opaque = true; + for (i = 0; i < pal->ncolors; i++) { + Uint8 alpha_value = pal->colors[i].a; + if (alpha_value != SDL_ALPHA_OPAQUE) { + all_opaque = false; + break; + } + } + + if (all_opaque) { + // Palette is opaque, with an alpha channel + *is_opaque = true; + *has_alpha_channel = true; + return; + } + } + + { + bool all_transparent = true; + for (i = 0; i < pal->ncolors; i++) { + Uint8 alpha_value = pal->colors[i].a; + if (alpha_value != SDL_ALPHA_TRANSPARENT) { + all_transparent = false; + break; + } + } + + if (all_transparent) { + // Palette is opaque, without an alpha channel + *is_opaque = true; + *has_alpha_channel = false; + return; + } + } + + // Palette has alpha values + *is_opaque = false; + *has_alpha_channel = true; +} + +// Find the opaque pixel value corresponding to an RGB triple +Uint32 SDL_MapRGB(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b) +{ + if (!format) { + SDL_InvalidParamError("format"); + return 0; + } + + if (SDL_ISPIXELFORMAT_INDEXED(format->format)) { + if (!palette) { + SDL_InvalidParamError("palette"); + return 0; + } + return SDL_FindColor(palette, r, g, b, SDL_ALPHA_OPAQUE); + } + + if (SDL_ISPIXELFORMAT_10BIT(format->format)) { + return (((Uint32)SDL_expand_byte_10[r]) << format->Rshift) | + (((Uint32)SDL_expand_byte_10[g]) << format->Gshift) | + (((Uint32)SDL_expand_byte_10[b]) << format->Bshift) | + format->Amask; + } else { + return ((Uint32)(r >> (8 - format->Rbits))) << format->Rshift | + ((Uint32)(g >> (8 - format->Gbits))) << format->Gshift | + ((Uint32)(b >> (8 - format->Bbits))) << format->Bshift | + format->Amask; + } +} + +// Find the pixel value corresponding to an RGBA quadruple +Uint32 SDL_MapRGBA(const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + if (!format) { + SDL_InvalidParamError("format"); + return 0; + } + + if (SDL_ISPIXELFORMAT_INDEXED(format->format)) { + if (!palette) { + SDL_InvalidParamError("palette"); + return 0; + } + return SDL_FindColor(palette, r, g, b, a); + } + + if (SDL_ISPIXELFORMAT_10BIT(format->format)) { + return (((Uint32)SDL_expand_byte_10[r]) << format->Rshift) | + (((Uint32)SDL_expand_byte_10[g]) << format->Gshift) | + (((Uint32)SDL_expand_byte_10[b]) << format->Bshift) | + ((((Uint32)(a >> (8 - format->Abits))) << format->Ashift) & format->Amask); + } else { + return ((Uint32)(r >> (8 - format->Rbits))) << format->Rshift | + ((Uint32)(g >> (8 - format->Gbits))) << format->Gshift | + ((Uint32)(b >> (8 - format->Bbits))) << format->Bshift | + ((((Uint32)(a >> (8 - format->Abits))) << format->Ashift) & format->Amask); + } +} + +void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b) +{ + Uint8 unused; + + if (!r) { + r = &unused; + } + if (!g) { + g = &unused; + } + if (!b) { + b = &unused; + } + + if (!format) { + *r = *g = *b = 0; + return; + } + + if (SDL_ISPIXELFORMAT_INDEXED(format->format)) { + if (palette && pixel < (unsigned)palette->ncolors) { + *r = palette->colors[pixel].r; + *g = palette->colors[pixel].g; + *b = palette->colors[pixel].b; + } else { + *r = *g = *b = 0; + } + return; + } + + if (SDL_ISPIXELFORMAT_10BIT(format->format)) { + unsigned v; + v = (pixel & format->Rmask) >> format->Rshift; + *r = (Uint8)(v >> 2); + v = (pixel & format->Gmask) >> format->Gshift; + *g = (Uint8)(v >> 2); + v = (pixel & format->Bmask) >> format->Bshift; + *b = (Uint8)(v >> 2); + } else { + unsigned v; + v = (pixel & format->Rmask) >> format->Rshift; + *r = SDL_expand_byte[format->Rbits][v]; + v = (pixel & format->Gmask) >> format->Gshift; + *g = SDL_expand_byte[format->Gbits][v]; + v = (pixel & format->Bmask) >> format->Bshift; + *b = SDL_expand_byte[format->Bbits][v]; + } +} + +void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormatDetails *format, const SDL_Palette *palette, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) +{ + Uint8 unused; + + if (!r) { + r = &unused; + } + if (!g) { + g = &unused; + } + if (!b) { + b = &unused; + } + if (!a) { + a = &unused; + } + + if (!format) { + *r = *g = *b = *a = 0; + return; + } + + if (SDL_ISPIXELFORMAT_INDEXED(format->format)) { + if (palette && pixel < (unsigned)palette->ncolors) { + *r = palette->colors[pixel].r; + *g = palette->colors[pixel].g; + *b = palette->colors[pixel].b; + *a = palette->colors[pixel].a; + } else { + *r = *g = *b = *a = 0; + } + return; + } + + if (SDL_ISPIXELFORMAT_10BIT(format->format)) { + unsigned v; + v = (pixel & format->Rmask) >> format->Rshift; + *r = (Uint8)(v >> 2); + v = (pixel & format->Gmask) >> format->Gshift; + *g = (Uint8)(v >> 2); + v = (pixel & format->Bmask) >> format->Bshift; + *b = (Uint8)(v >> 2); + v = (pixel & format->Amask) >> format->Ashift; + *a = SDL_expand_byte[format->Abits][v]; + } else { + unsigned v; + v = (pixel & format->Rmask) >> format->Rshift; + *r = SDL_expand_byte[format->Rbits][v]; + v = (pixel & format->Gmask) >> format->Gshift; + *g = SDL_expand_byte[format->Gbits][v]; + v = (pixel & format->Bmask) >> format->Bshift; + *b = SDL_expand_byte[format->Bbits][v]; + v = (pixel & format->Amask) >> format->Ashift; + *a = SDL_expand_byte[format->Abits][v]; + } +} + +// Map from Palette to Palette +static Uint8 *Map1to1(const SDL_Palette *src, const SDL_Palette *dst, int *identical) +{ + Uint8 *map; + int i; + + if (identical) { + if (src->ncolors <= dst->ncolors) { + // If an identical palette, no need to map + if (src == dst || + (SDL_memcmp(src->colors, dst->colors, + src->ncolors * sizeof(SDL_Color)) == 0)) { + *identical = 1; + return NULL; + } + } + *identical = 0; + } + map = (Uint8 *)SDL_calloc(256, sizeof(Uint8)); + if (!map) { + return NULL; + } + for (i = 0; i < src->ncolors; ++i) { + map[i] = SDL_FindColor(dst, + src->colors[i].r, src->colors[i].g, + src->colors[i].b, src->colors[i].a); + } + return map; +} + +// Map from Palette to BitField +static Uint8 *Map1toN(const SDL_Palette *pal, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod, const SDL_PixelFormatDetails *dst) +{ + Uint8 *map; + int i; + int bpp; + + if (!pal) { + SDL_SetError("src does not have a palette set"); + return NULL; + } + + bpp = ((SDL_BYTESPERPIXEL(dst->format) == 3) ? 4 : SDL_BYTESPERPIXEL(dst->format)); + map = (Uint8 *)SDL_calloc(256, bpp); + if (!map) { + return NULL; + } + + // We memory copy to the pixel map so the endianness is preserved + for (i = 0; i < pal->ncolors; ++i) { + Uint8 R = (Uint8)((pal->colors[i].r * Rmod) / 255); + Uint8 G = (Uint8)((pal->colors[i].g * Gmod) / 255); + Uint8 B = (Uint8)((pal->colors[i].b * Bmod) / 255); + Uint8 A = (Uint8)((pal->colors[i].a * Amod) / 255); + ASSEMBLE_RGBA(&map[i * bpp], SDL_BYTESPERPIXEL(dst->format), dst, (Uint32)R, + (Uint32)G, (Uint32)B, (Uint32)A); + } + return map; +} + +bool SDL_ValidateMap(SDL_Surface *src, SDL_Surface *dst) +{ + SDL_BlitMap *map = &src->map; + + if (map->info.dst_fmt != dst->fmt || + map->info.dst_pal != dst->palette || + (dst->palette && + map->dst_palette_version != dst->palette->version) || + (src->palette && + map->src_palette_version != src->palette->version)) { + if (!SDL_MapSurface(src, dst)) { + return false; + } + // just here for debugging + // printf + // ("src = 0x%08X src->flags = %08X map->info.flags = %08x\ndst = 0x%08X dst->flags = %08X dst->map.info.flags = %08X\nmap->blit = 0x%08x\n", + // src, dst->flags, map->info.flags, dst, dst->flags, + // dst->map.info.flags, map->blit); + } else { + map->info.dst_surface = dst; + } + return true; +} + +void SDL_InvalidateMap(SDL_BlitMap *map) +{ + map->info.dst_fmt = NULL; + map->info.dst_pal = NULL; + map->src_palette_version = 0; + map->dst_palette_version = 0; + if (map->info.table) { + SDL_free(map->info.table); + map->info.table = NULL; + } + if (map->info.palette_map) { + SDL_DestroyHashTable(map->info.palette_map); + map->info.palette_map = NULL; + } +} + +bool SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) +{ + const SDL_PixelFormatDetails *srcfmt; + const SDL_Palette *srcpal; + const SDL_PixelFormatDetails *dstfmt; + const SDL_Palette *dstpal; + SDL_BlitMap *map; + + // Clear out any previous mapping + map = &src->map; +#ifdef SDL_HAVE_RLE + if (src->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) { + SDL_UnRLESurface(src, true); + } +#endif + SDL_InvalidateMap(map); + + // Figure out what kind of mapping we're doing + map->identity = 0; + srcfmt = src->fmt; + srcpal = src->palette; + dstfmt = dst->fmt; + dstpal = dst->palette; + if (SDL_ISPIXELFORMAT_INDEXED(srcfmt->format)) { + if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) { + // Palette --> Palette + if (srcpal && dstpal) { + map->info.table = Map1to1(srcpal, dstpal, &map->identity); + } else { + map->identity = 1; + } + if (!map->identity) { + if (!map->info.table) { + return false; + } + } + if (srcfmt->bits_per_pixel != dstfmt->bits_per_pixel) { + map->identity = 0; + } + } else { + // Palette --> BitField + map->info.table = + Map1toN(srcpal, src->map.info.r, src->map.info.g, + src->map.info.b, src->map.info.a, dstfmt); + if (!map->info.table) { + return false; + } + } + } else { + if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) { + // BitField --> Palette + map->info.palette_map = SDL_CreateHashTable(0, false, SDL_HashID, SDL_KeyMatchID, NULL, NULL); + } else { + // BitField --> BitField + if (srcfmt == dstfmt) { + map->identity = 1; + } + } + } + + if (dstpal) { + map->dst_palette_version = dstpal->version; + } else { + map->dst_palette_version = 0; + } + + if (srcpal) { + map->src_palette_version = srcpal->version; + } else { + map->src_palette_version = 0; + } + + // Choose your blitters wisely + return SDL_CalculateBlit(src, dst); +} + diff --git a/contrib/SDL-3.2.8/src/video/SDL_pixels_c.h b/contrib/SDL-3.2.8/src/video/SDL_pixels_c.h new file mode 100644 index 0000000..92c3401 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_pixels_c.h @@ -0,0 +1,57 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_pixels_c_h_ +#define SDL_pixels_c_h_ + +// Useful functions and variables from SDL_pixel.c + +#include "SDL_blit.h" + + +// Pixel format functions +extern bool SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, bool minimalPitch); +extern SDL_Colorspace SDL_GetDefaultColorspaceForFormat(SDL_PixelFormat pixel_format); +extern void SDL_QuitPixelFormatDetails(void); + +// Colorspace conversion functions +extern float SDL_sRGBtoLinear(float v); +extern float SDL_sRGBfromLinear(float v); +extern float SDL_PQtoNits(float v); +extern float SDL_PQfromNits(float v); +extern const float *SDL_GetYCbCRtoRGBConversionMatrix(SDL_Colorspace colorspace, int w, int h, int bits_per_pixel); +extern const float *SDL_GetColorPrimariesConversionMatrix(SDL_ColorPrimaries src, SDL_ColorPrimaries dst); +extern void SDL_ConvertColorPrimaries(float *fR, float *fG, float *fB, const float *matrix); + +// Blit mapping functions +extern bool SDL_ValidateMap(SDL_Surface *src, SDL_Surface *dst); +extern void SDL_InvalidateMap(SDL_BlitMap *map); +extern bool SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst); + +// Miscellaneous functions +extern void SDL_DitherPalette(SDL_Palette *palette); +extern Uint8 SDL_FindColor(const SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern Uint8 SDL_LookupRGBAColor(SDL_HashTable *palette_map, Uint32 pixel, const SDL_Palette *pal); +extern void SDL_DetectPalette(const SDL_Palette *pal, bool *is_opaque, bool *has_alpha_channel); +extern SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, void *pixels, int pitch); + +#endif // SDL_pixels_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_rect.c b/contrib/SDL-3.2.8/src/video/SDL_rect.c new file mode 100644 index 0000000..dadb588 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_rect.c @@ -0,0 +1,116 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_rect_c.h" + +/* There's no float version of this at the moment, because it's not a public API + and internally we only need the int version. */ +bool SDL_GetSpanEnclosingRect(int width, int height, + int numrects, const SDL_Rect *rects, SDL_Rect *span) +{ + int i; + int span_y1, span_y2; + int rect_y1, rect_y2; + + if (width < 1) { + SDL_InvalidParamError("width"); + return false; + } else if (height < 1) { + SDL_InvalidParamError("height"); + return false; + } else if (!rects) { + SDL_InvalidParamError("rects"); + return false; + } else if (!span) { + SDL_InvalidParamError("span"); + return false; + } else if (numrects < 1) { + SDL_InvalidParamError("numrects"); + return false; + } + + // Initialize to empty rect + span_y1 = height; + span_y2 = 0; + + for (i = 0; i < numrects; ++i) { + rect_y1 = rects[i].y; + rect_y2 = rect_y1 + rects[i].h; + + // Clip out of bounds rectangles, and expand span rect + if (rect_y1 < 0) { + span_y1 = 0; + } else if (rect_y1 < span_y1) { + span_y1 = rect_y1; + } + if (rect_y2 > height) { + span_y2 = height; + } else if (rect_y2 > span_y2) { + span_y2 = rect_y2; + } + } + if (span_y2 > span_y1) { + span->x = 0; + span->y = span_y1; + span->w = width; + span->h = (span_y2 - span_y1); + return true; + } + return false; +} + +// For use with the Cohen-Sutherland algorithm for line clipping, in SDL_rect_impl.h +#define CODE_BOTTOM 1 +#define CODE_TOP 2 +#define CODE_LEFT 4 +#define CODE_RIGHT 8 + +// Same code twice, for float and int versions... +#define RECTTYPE SDL_Rect +#define POINTTYPE SDL_Point +#define SCALARTYPE int +#define BIGSCALARTYPE Sint64 +#define COMPUTEOUTCODE ComputeOutCode +#define ENCLOSEPOINTS_EPSILON 1 +#define SDL_RECT_CAN_OVERFLOW SDL_RectCanOverflow +#define SDL_HASINTERSECTION SDL_HasRectIntersection +#define SDL_INTERSECTRECT SDL_GetRectIntersection +#define SDL_RECTEMPTY SDL_RectEmpty +#define SDL_UNIONRECT SDL_GetRectUnion +#define SDL_ENCLOSEPOINTS SDL_GetRectEnclosingPoints +#define SDL_INTERSECTRECTANDLINE SDL_GetRectAndLineIntersection +#include "SDL_rect_impl.h" + +#define RECTTYPE SDL_FRect +#define POINTTYPE SDL_FPoint +#define SCALARTYPE float +#define BIGSCALARTYPE double +#define COMPUTEOUTCODE ComputeOutCodeFloat +#define ENCLOSEPOINTS_EPSILON 0.0f +#define SDL_RECT_CAN_OVERFLOW SDL_RectCanOverflowFloat +#define SDL_HASINTERSECTION SDL_HasRectIntersectionFloat +#define SDL_INTERSECTRECT SDL_GetRectIntersectionFloat +#define SDL_RECTEMPTY SDL_RectEmptyFloat +#define SDL_UNIONRECT SDL_GetRectUnionFloat +#define SDL_ENCLOSEPOINTS SDL_GetRectEnclosingPointsFloat +#define SDL_INTERSECTRECTANDLINE SDL_GetRectAndLineIntersectionFloat +#include "SDL_rect_impl.h" diff --git a/contrib/SDL-3.2.8/src/video/SDL_rect_c.h b/contrib/SDL-3.2.8/src/video/SDL_rect_c.h new file mode 100644 index 0000000..9d98551 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_rect_c.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_rect_c_h_ +#define SDL_rect_c_h_ + +#include "SDL_internal.h" + +extern bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, const SDL_Rect *rects, SDL_Rect *span); + +#endif // SDL_rect_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_rect_impl.h b/contrib/SDL-3.2.8/src/video/SDL_rect_impl.h new file mode 100644 index 0000000..d35f073 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_rect_impl.h @@ -0,0 +1,465 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +// This file is #included twice to support int and float versions with the same code. + +static bool SDL_RECT_CAN_OVERFLOW(const RECTTYPE *rect) +{ + if (rect->x <= (SCALARTYPE)(SDL_MIN_SINT32 / 2) || + rect->x >= (SCALARTYPE)(SDL_MAX_SINT32 / 2) || + rect->y <= (SCALARTYPE)(SDL_MIN_SINT32 / 2) || + rect->y >= (SCALARTYPE)(SDL_MAX_SINT32 / 2) || + rect->w >= (SCALARTYPE)(SDL_MAX_SINT32 / 2) || + rect->h >= (SCALARTYPE)(SDL_MAX_SINT32 / 2)) { + return true; + } + return false; +} + +bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) +{ + SCALARTYPE Amin, Amax, Bmin, Bmax; + + if (!A) { + SDL_InvalidParamError("A"); + return false; + } else if (!B) { + SDL_InvalidParamError("B"); + return false; + } else if (SDL_RECT_CAN_OVERFLOW(A) || + SDL_RECT_CAN_OVERFLOW(B)) { + SDL_SetError("Potential rect math overflow"); + return false; + } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { + return false; // Special cases for empty rects + } + + // Horizontal intersection + Amin = A->x; + Amax = Amin + A->w; + Bmin = B->x; + Bmax = Bmin + B->w; + if (Bmin > Amin) { + Amin = Bmin; + } + if (Bmax < Amax) { + Amax = Bmax; + } + if ((Amax - ENCLOSEPOINTS_EPSILON) < Amin) { + return false; + } + // Vertical intersection + Amin = A->y; + Amax = Amin + A->h; + Bmin = B->y; + Bmax = Bmin + B->h; + if (Bmin > Amin) { + Amin = Bmin; + } + if (Bmax < Amax) { + Amax = Bmax; + } + if ((Amax - ENCLOSEPOINTS_EPSILON) < Amin) { + return false; + } + return true; +} + +bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) +{ + SCALARTYPE Amin, Amax, Bmin, Bmax; + + if (!A) { + SDL_InvalidParamError("A"); + return false; + } else if (!B) { + SDL_InvalidParamError("B"); + return false; + } else if (SDL_RECT_CAN_OVERFLOW(A) || + SDL_RECT_CAN_OVERFLOW(B)) { + SDL_SetError("Potential rect math overflow"); + return false; + } else if (!result) { + SDL_InvalidParamError("result"); + return false; + } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { // Special cases for empty rects + result->w = 0; + result->h = 0; + return false; + } + + // Horizontal intersection + Amin = A->x; + Amax = Amin + A->w; + Bmin = B->x; + Bmax = Bmin + B->w; + if (Bmin > Amin) { + Amin = Bmin; + } + result->x = Amin; + if (Bmax < Amax) { + Amax = Bmax; + } + result->w = Amax - Amin; + + // Vertical intersection + Amin = A->y; + Amax = Amin + A->h; + Bmin = B->y; + Bmax = Bmin + B->h; + if (Bmin > Amin) { + Amin = Bmin; + } + result->y = Amin; + if (Bmax < Amax) { + Amax = Bmax; + } + result->h = Amax - Amin; + + return !SDL_RECTEMPTY(result); +} + +bool SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) +{ + SCALARTYPE Amin, Amax, Bmin, Bmax; + + if (!A) { + return SDL_InvalidParamError("A"); + } else if (!B) { + return SDL_InvalidParamError("B"); + } else if (SDL_RECT_CAN_OVERFLOW(A) || + SDL_RECT_CAN_OVERFLOW(B)) { + return SDL_SetError("Potential rect math overflow"); + } else if (!result) { + return SDL_InvalidParamError("result"); + } else if (SDL_RECTEMPTY(A)) { // Special cases for empty Rects + if (SDL_RECTEMPTY(B)) { // A and B empty + SDL_zerop(result); + } else { // A empty, B not empty + *result = *B; + } + return true; + } else if (SDL_RECTEMPTY(B)) { // A not empty, B empty + *result = *A; + return true; + } + + // Horizontal union + Amin = A->x; + Amax = Amin + A->w; + Bmin = B->x; + Bmax = Bmin + B->w; + if (Bmin < Amin) { + Amin = Bmin; + } + result->x = Amin; + if (Bmax > Amax) { + Amax = Bmax; + } + result->w = Amax - Amin; + + // Vertical union + Amin = A->y; + Amax = Amin + A->h; + Bmin = B->y; + Bmax = Bmin + B->h; + if (Bmin < Amin) { + Amin = Bmin; + } + result->y = Amin; + if (Bmax > Amax) { + Amax = Bmax; + } + result->h = Amax - Amin; + return true; +} + +bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *clip, RECTTYPE *result) +{ + SCALARTYPE minx = 0; + SCALARTYPE miny = 0; + SCALARTYPE maxx = 0; + SCALARTYPE maxy = 0; + SCALARTYPE x, y; + int i; + + if (!points) { + SDL_InvalidParamError("points"); + return false; + } else if (count < 1) { + SDL_InvalidParamError("count"); + return false; + } + + if (clip) { + bool added = false; + const SCALARTYPE clip_minx = clip->x; + const SCALARTYPE clip_miny = clip->y; + const SCALARTYPE clip_maxx = clip->x + clip->w - ENCLOSEPOINTS_EPSILON; + const SCALARTYPE clip_maxy = clip->y + clip->h - ENCLOSEPOINTS_EPSILON; + + // Special case for empty rectangle + if (SDL_RECTEMPTY(clip)) { + return false; + } + + for (i = 0; i < count; ++i) { + x = points[i].x; + y = points[i].y; + + if (x < clip_minx || x > clip_maxx || + y < clip_miny || y > clip_maxy) { + continue; + } + if (!added) { + // Special case: if no result was requested, we are done + if (!result) { + return true; + } + + // First point added + minx = maxx = x; + miny = maxy = y; + added = true; + continue; + } + if (x < minx) { + minx = x; + } else if (x > maxx) { + maxx = x; + } + if (y < miny) { + miny = y; + } else if (y > maxy) { + maxy = y; + } + } + if (!added) { + return false; + } + } else { + // Special case: if no result was requested, we are done + if (!result) { + return true; + } + + // No clipping, always add the first point + minx = maxx = points[0].x; + miny = maxy = points[0].y; + + for (i = 1; i < count; ++i) { + x = points[i].x; + y = points[i].y; + + if (x < minx) { + minx = x; + } else if (x > maxx) { + maxx = x; + } + if (y < miny) { + miny = y; + } else if (y > maxy) { + maxy = y; + } + } + } + + if (result) { + result->x = minx; + result->y = miny; + result->w = (maxx - minx) + ENCLOSEPOINTS_EPSILON; + result->h = (maxy - miny) + ENCLOSEPOINTS_EPSILON; + } + return true; +} + +// Use the Cohen-Sutherland algorithm for line clipping +static int COMPUTEOUTCODE(const RECTTYPE *rect, SCALARTYPE x, SCALARTYPE y) +{ + int code = 0; + if (y < rect->y) { + code |= CODE_TOP; + } else if (y > (rect->y + rect->h - ENCLOSEPOINTS_EPSILON)) { + code |= CODE_BOTTOM; + } + if (x < rect->x) { + code |= CODE_LEFT; + } else if (x > (rect->x + rect->w - ENCLOSEPOINTS_EPSILON)) { + code |= CODE_RIGHT; + } + return code; +} + +bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTYPE *Y1, SCALARTYPE *X2, SCALARTYPE *Y2) +{ + SCALARTYPE x = 0; + SCALARTYPE y = 0; + SCALARTYPE x1, y1; + SCALARTYPE x2, y2; + SCALARTYPE rectx1; + SCALARTYPE recty1; + SCALARTYPE rectx2; + SCALARTYPE recty2; + int outcode1, outcode2; + + if (!rect) { + SDL_InvalidParamError("rect"); + return false; + } else if (SDL_RECT_CAN_OVERFLOW(rect)) { + SDL_SetError("Potential rect math overflow"); + return false; + } else if (!X1) { + SDL_InvalidParamError("X1"); + return false; + } else if (!Y1) { + SDL_InvalidParamError("Y1"); + return false; + } else if (!X2) { + SDL_InvalidParamError("X2"); + return false; + } else if (!Y2) { + SDL_InvalidParamError("Y2"); + return false; + } else if (SDL_RECTEMPTY(rect)) { + return false; // Special case for empty rect + } + + x1 = *X1; + y1 = *Y1; + x2 = *X2; + y2 = *Y2; + rectx1 = rect->x; + recty1 = rect->y; + rectx2 = rect->x + rect->w - ENCLOSEPOINTS_EPSILON; + recty2 = rect->y + rect->h - ENCLOSEPOINTS_EPSILON; + + // Check to see if entire line is inside rect + if (x1 >= rectx1 && x1 <= rectx2 && x2 >= rectx1 && x2 <= rectx2 && + y1 >= recty1 && y1 <= recty2 && y2 >= recty1 && y2 <= recty2) { + return true; + } + + // Check to see if entire line is to one side of rect + if ((x1 < rectx1 && x2 < rectx1) || (x1 > rectx2 && x2 > rectx2) || + (y1 < recty1 && y2 < recty1) || (y1 > recty2 && y2 > recty2)) { + return false; + } + + if (y1 == y2) { // Horizontal line, easy to clip + if (x1 < rectx1) { + *X1 = rectx1; + } else if (x1 > rectx2) { + *X1 = rectx2; + } + if (x2 < rectx1) { + *X2 = rectx1; + } else if (x2 > rectx2) { + *X2 = rectx2; + } + return true; + } + + if (x1 == x2) { // Vertical line, easy to clip + if (y1 < recty1) { + *Y1 = recty1; + } else if (y1 > recty2) { + *Y1 = recty2; + } + if (y2 < recty1) { + *Y2 = recty1; + } else if (y2 > recty2) { + *Y2 = recty2; + } + return true; + } + + // More complicated Cohen-Sutherland algorithm + outcode1 = COMPUTEOUTCODE(rect, x1, y1); + outcode2 = COMPUTEOUTCODE(rect, x2, y2); + while (outcode1 || outcode2) { + if (outcode1 & outcode2) { + return false; + } + + if (outcode1) { + if (outcode1 & CODE_TOP) { + y = recty1; + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); + } else if (outcode1 & CODE_BOTTOM) { + y = recty2; + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); + } else if (outcode1 & CODE_LEFT) { + x = rectx1; + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); + } else if (outcode1 & CODE_RIGHT) { + x = rectx2; + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); + } + x1 = x; + y1 = y; + outcode1 = COMPUTEOUTCODE(rect, x, y); + } else { + if (outcode2 & CODE_TOP) { + SDL_assert(y2 != y1); // if equal: division by zero. + y = recty1; + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); + } else if (outcode2 & CODE_BOTTOM) { + SDL_assert(y2 != y1); // if equal: division by zero. + y = recty2; + x = (SCALARTYPE) (x1 + ((BIGSCALARTYPE)(x2 - x1) * (y - y1)) / (y2 - y1)); + } else if (outcode2 & CODE_LEFT) { + /* If this assertion ever fires, here's the static analysis that warned about it: + http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-b0d01a.html#EndPath */ + SDL_assert(x2 != x1); // if equal: division by zero. + x = rectx1; + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); + } else if (outcode2 & CODE_RIGHT) { + /* If this assertion ever fires, here's the static analysis that warned about it: + http://buildbot.libsdl.org/sdl-static-analysis/sdl-macosx-static-analysis/sdl-macosx-static-analysis-1101/report-39b114.html#EndPath */ + SDL_assert(x2 != x1); // if equal: division by zero. + x = rectx2; + y = (SCALARTYPE) (y1 + ((BIGSCALARTYPE)(y2 - y1) * (x - x1)) / (x2 - x1)); + } + x2 = x; + y2 = y; + outcode2 = COMPUTEOUTCODE(rect, x, y); + } + } + *X1 = x1; + *Y1 = y1; + *X2 = x2; + *Y2 = y2; + return true; +} + +#undef RECTTYPE +#undef POINTTYPE +#undef SCALARTYPE +#undef BIGSCALARTYPE +#undef COMPUTEOUTCODE +#undef ENCLOSEPOINTS_EPSILON +#undef SDL_RECT_CAN_OVERFLOW +#undef SDL_HASINTERSECTION +#undef SDL_INTERSECTRECT +#undef SDL_RECTEMPTY +#undef SDL_UNIONRECT +#undef SDL_ENCLOSEPOINTS +#undef SDL_INTERSECTRECTANDLINE diff --git a/contrib/SDL-3.2.8/src/video/SDL_stb.c b/contrib/SDL-3.2.8/src/video/SDL_stb.c new file mode 100644 index 0000000..934c1ad --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_stb.c @@ -0,0 +1,121 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_stb_c.h" + + +// We currently only support JPEG, but we could add other image formats if we wanted +#ifdef SDL_HAVE_STB +#define malloc SDL_malloc +#define realloc SDL_realloc +#define free SDL_free +#undef memcpy +#define memcpy SDL_memcpy +#undef memset +#define memset SDL_memset +#undef strcmp +#define strcmp SDL_strcmp +#undef strncmp +#define strncmp SDL_strncmp +#define strtol SDL_strtol + +#define abs SDL_abs +#define pow SDL_pow +#define ldexp SDL_scalbn + +#define STB_IMAGE_STATIC +#define STBI_NO_THREAD_LOCALS +#define STBI_FAILURE_USERMSG +#if defined(SDL_NEON_INTRINSICS) +#define STBI_NEON +#endif +#define STBI_ONLY_JPEG +#define STBI_NO_GIF +#define STBI_NO_PNG +#define STBI_NO_HDR +#define STBI_NO_LINEAR +#define STBI_NO_ZLIB +#define STBI_NO_STDIO +#define STBI_ASSERT SDL_assert +#define STB_IMAGE_IMPLEMENTATION +#include "stb_image.h" + +#undef memset +#endif + +#ifdef SDL_HAVE_STB +static bool SDL_ConvertPixels_MJPG_to_NV12(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int w = 0, h = 0, format = 0; + stbi__context s; + stbi__start_mem(&s, src, src_pitch); + + stbi__result_info ri; + SDL_zero(ri); + ri.bits_per_channel = 8; + ri.channel_order = STBI_ORDER_RGB; + ri.num_channels = 0; + + stbi__nv12 nv12; + nv12.w = width; + nv12.h = height; + nv12.pitch = dst_pitch; + nv12.y = (stbi_uc *)dst; + nv12.uv = nv12.y + (nv12.h * nv12.pitch); + + void *pixels = stbi__jpeg_load(&s, &w, &h, &format, 4, &nv12, &ri); + if (!pixels) { + return false; + } + return true; +} +#endif // SDL_HAVE_STB + +bool SDL_ConvertPixels_STB(int width, int height, + SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, + SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch) +{ +#ifdef SDL_HAVE_STB + if (src_format == SDL_PIXELFORMAT_MJPG && dst_format == SDL_PIXELFORMAT_NV12) { + return SDL_ConvertPixels_MJPG_to_NV12(width, height, src, src_pitch, dst, dst_pitch); + } + + bool result; + int w = 0, h = 0, format = 0; + int len = (src_format == SDL_PIXELFORMAT_MJPG) ? src_pitch : (height * src_pitch); + void *pixels = stbi_load_from_memory(src, len, &w, &h, &format, 4); + if (!pixels) { + return false; + } + + if (w == width && h == height) { + result = SDL_ConvertPixelsAndColorspace(w, h, SDL_PIXELFORMAT_RGBA32, SDL_COLORSPACE_SRGB, 0, pixels, width * 4, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); + } else { + result = SDL_SetError("Expected image size %dx%d, actual size %dx%d", width, height, w, h); + } + stbi_image_free(pixels); + + return result; +#else + return SDL_SetError("SDL not built with STB image support"); +#endif +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_stb_c.h b/contrib/SDL-3.2.8/src/video/SDL_stb_c.h new file mode 100644 index 0000000..bf8cc4d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_stb_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_stb_c_h_ +#define SDL_stb_c_h_ + +#include "SDL_internal.h" + +// Image conversion functions + +extern bool SDL_ConvertPixels_STB(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); + +#endif // SDL_stb_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_stretch.c b/contrib/SDL-3.2.8/src/video/SDL_stretch.c new file mode 100644 index 0000000..c893cc3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_stretch.c @@ -0,0 +1,978 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_surface_c.h" + +static bool SDL_StretchSurfaceUncheckedNearest(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); +static bool SDL_StretchSurfaceUncheckedLinear(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect); + +bool SDL_StretchSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode) +{ + bool result; + int src_locked; + int dst_locked; + SDL_Rect full_src; + SDL_Rect full_dst; + + if (!src) { + return SDL_InvalidParamError("src"); + } + if (!dst) { + return SDL_InvalidParamError("dst"); + } + + if (src->format != dst->format) { + // Slow! + SDL_Surface *src_tmp = SDL_ConvertSurfaceAndColorspace(src, dst->format, dst->palette, dst->colorspace, dst->props); + if (!src_tmp) { + return false; + } + result = SDL_StretchSurface(src_tmp, srcrect, dst, dstrect, scaleMode); + SDL_DestroySurface(src_tmp); + return result; + } + + if (SDL_ISPIXELFORMAT_FOURCC(src->format)) { + // Slow! + if (!dstrect) { + full_dst.x = 0; + full_dst.y = 0; + full_dst.w = dst->w; + full_dst.h = dst->h; + dstrect = &full_dst; + } + + SDL_Surface *src_tmp = SDL_ConvertSurface(src, SDL_PIXELFORMAT_XRGB8888); + SDL_Surface *dst_tmp = SDL_CreateSurface(dstrect->w, dstrect->h, SDL_PIXELFORMAT_XRGB8888); + if (src_tmp && dst_tmp) { + result = SDL_StretchSurface(src_tmp, srcrect, dst_tmp, NULL, scaleMode); + if (result) { + result = SDL_ConvertPixelsAndColorspace(dstrect->w, dstrect->h, + dst_tmp->format, SDL_COLORSPACE_SRGB, 0, + dst_tmp->pixels, dst_tmp->pitch, + dst->format, dst->colorspace, SDL_GetSurfaceProperties(dst), + (Uint8 *)dst->pixels + dstrect->y * dst->pitch + dstrect->x * SDL_BYTESPERPIXEL(dst->format), dst->pitch); + } + } else { + result = false; + } + SDL_DestroySurface(src_tmp); + SDL_DestroySurface(dst_tmp); + return result; + } + + if (scaleMode != SDL_SCALEMODE_NEAREST && scaleMode != SDL_SCALEMODE_LINEAR) { + return SDL_InvalidParamError("scaleMode"); + } + + if (scaleMode != SDL_SCALEMODE_NEAREST) { + scaleMode = SDL_SCALEMODE_LINEAR; + } + + if (scaleMode == SDL_SCALEMODE_LINEAR) { + if (SDL_BYTESPERPIXEL(src->format) != 4 || src->format == SDL_PIXELFORMAT_ARGB2101010) { + return SDL_SetError("Wrong format"); + } + } + + // Verify the blit rectangles + if (srcrect) { + if ((srcrect->x < 0) || (srcrect->y < 0) || + ((srcrect->x + srcrect->w) > src->w) || + ((srcrect->y + srcrect->h) > src->h)) { + return SDL_SetError("Invalid source blit rectangle"); + } + } else { + full_src.x = 0; + full_src.y = 0; + full_src.w = src->w; + full_src.h = src->h; + srcrect = &full_src; + } + if (dstrect) { + if ((dstrect->x < 0) || (dstrect->y < 0) || + ((dstrect->x + dstrect->w) > dst->w) || + ((dstrect->y + dstrect->h) > dst->h)) { + return SDL_SetError("Invalid destination blit rectangle"); + } + } else { + full_dst.x = 0; + full_dst.y = 0; + full_dst.w = dst->w; + full_dst.h = dst->h; + dstrect = &full_dst; + } + + if (dstrect->w <= 0 || dstrect->h <= 0) { + return true; + } + + if (srcrect->w > SDL_MAX_UINT16 || srcrect->h > SDL_MAX_UINT16 || + dstrect->w > SDL_MAX_UINT16 || dstrect->h > SDL_MAX_UINT16) { + return SDL_SetError("Size too large for scaling"); + } + + // Lock the destination if it's in hardware + dst_locked = 0; + if (SDL_MUSTLOCK(dst)) { + if (!SDL_LockSurface(dst)) { + return SDL_SetError("Unable to lock destination surface"); + } + dst_locked = 1; + } + // Lock the source if it's in hardware + src_locked = 0; + if (SDL_MUSTLOCK(src)) { + if (!SDL_LockSurface(src)) { + if (dst_locked) { + SDL_UnlockSurface(dst); + } + return SDL_SetError("Unable to lock source surface"); + } + src_locked = 1; + } + + if (scaleMode == SDL_SCALEMODE_NEAREST) { + result = SDL_StretchSurfaceUncheckedNearest(src, srcrect, dst, dstrect); + } else { + result = SDL_StretchSurfaceUncheckedLinear(src, srcrect, dst, dstrect); + } + + // We need to unlock the surfaces if they're locked + if (dst_locked) { + SDL_UnlockSurface(dst); + } + if (src_locked) { + SDL_UnlockSurface(src); + } + + return result; +} + +/* bilinear interpolation precision must be < 8 + Because with SSE: add-multiply: _mm_madd_epi16 works with signed int + so pixels 0xb1...... are negatives and false the result + same in NEON probably */ +#define PRECISION 7 + +#define FIXED_POINT(i) ((Uint32)(i) << 16) +#define SRC_INDEX(fp) ((Uint32)(fp) >> 16) +#define INTEGER(fp) ((Uint32)(fp) >> PRECISION) +#define FRAC(fp) ((Uint32)((fp) >> (16 - PRECISION)) & ((1 << PRECISION) - 1)) +#define FRAC_ZERO 0 +#define FRAC_ONE (1 << PRECISION) +#define FP_ONE FIXED_POINT(1) + +#define BILINEAR___START \ + int i; \ + Sint64 fp_sum_h; \ + int fp_step_h, left_pad_h, right_pad_h; \ + Sint64 fp_sum_w; \ + int fp_step_w, left_pad_w, right_pad_w; \ + Sint64 fp_sum_w_init; \ + int left_pad_w_init, right_pad_w_init, dst_gap, middle_init; \ + get_scaler_datas(src_h, dst_h, &fp_sum_h, &fp_step_h, &left_pad_h, &right_pad_h); \ + get_scaler_datas(src_w, dst_w, &fp_sum_w, &fp_step_w, &left_pad_w, &right_pad_w); \ + fp_sum_w_init = fp_sum_w + left_pad_w * fp_step_w; \ + left_pad_w_init = left_pad_w; \ + right_pad_w_init = right_pad_w; \ + dst_gap = dst_pitch - 4 * dst_w; \ + middle_init = dst_w - left_pad_w - right_pad_w; + +#define BILINEAR___HEIGHT \ + int index_h, frac_h0, frac_h1, middle; \ + const Uint32 *src_h0, *src_h1; \ + int no_padding; \ + Uint64 incr_h0, incr_h1; \ + \ + no_padding = !(i < left_pad_h || i > dst_h - 1 - right_pad_h); \ + index_h = SRC_INDEX(fp_sum_h); \ + frac_h0 = FRAC(fp_sum_h); \ + \ + index_h = no_padding ? index_h : (i < left_pad_h ? 0 : src_h - 1); \ + frac_h0 = no_padding ? frac_h0 : 0; \ + incr_h1 = no_padding ? src_pitch : 0; \ + incr_h0 = (Uint64)index_h * src_pitch; \ + \ + src_h0 = (const Uint32 *)((const Uint8 *)src + incr_h0); \ + src_h1 = (const Uint32 *)((const Uint8 *)src_h0 + incr_h1); \ + \ + fp_sum_h += fp_step_h; \ + \ + frac_h1 = FRAC_ONE - frac_h0; \ + fp_sum_w = fp_sum_w_init; \ + right_pad_w = right_pad_w_init; \ + left_pad_w = left_pad_w_init; \ + middle = middle_init; + +#ifdef __clang__ +// Remove inlining of this function +// Compiler crash with clang 9.0.8 / android-ndk-r21d +// Compiler crash with clang 11.0.3 / Xcode +// OK with clang 11.0.5 / android-ndk-22 +// OK with clang 12.0.0 / Xcode +__attribute__((noinline)) +#endif +static void get_scaler_datas(int src_nb, int dst_nb, Sint64 *fp_start, int *fp_step, int *left_pad, int *right_pad) +{ + + int step = FIXED_POINT(src_nb) / (dst_nb); // source step in fixed point + int x0 = FP_ONE / 2; // dst first pixel center at 0.5 in fixed point + Sint64 fp_sum; + int i; +#if 0 + // scale to source coordinates + x0 *= src_nb; + x0 /= dst_nb; // x0 == step / 2 +#else + // Use this code for perfect match with pixman + Sint64 tmp[2]; + tmp[0] = (Sint64)step * (x0 >> 16); + tmp[1] = (Sint64)step * (x0 & 0xFFFF); + x0 = (int)(tmp[0] + ((tmp[1] + 0x8000) >> 16)); // x0 == (step + 1) / 2 +#endif + // -= 0.5, get back the pixel origin, in source coordinates + x0 -= FP_ONE / 2; + + *fp_start = x0; + *fp_step = step; + *left_pad = 0; + *right_pad = 0; + + fp_sum = x0; + for (i = 0; i < dst_nb; i++) { + if (fp_sum < 0) { + *left_pad += 1; + } else { + int index = SRC_INDEX(fp_sum); + if (index > src_nb - 2) { + *right_pad += 1; + } + } + fp_sum += step; + } + // SDL_Log("%d -> %d x0=%d step=%d left_pad=%d right_pad=%d", src_nb, dst_nb, *fp_start, *fp_step, *left_pad, *right_pad); +} + +typedef struct color_t +{ + Uint8 a; + Uint8 b; + Uint8 c; + Uint8 d; +} color_t; + +#if 0 +static void printf_64(const char *str, void *var) +{ + uint8_t *val = (uint8_t*) var; + printf(" * %s: %02x %02x %02x %02x _ %02x %02x %02x %02x\n", + str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]); +} +#endif + +/* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + +static SDL_INLINE void INTERPOL(const Uint32 *src_x0, const Uint32 *src_x1, int frac0, int frac1, Uint32 *dst) +{ + const color_t *c0 = (const color_t *)src_x0; + const color_t *c1 = (const color_t *)src_x1; + color_t *cx = (color_t *)dst; +#if 0 + cx->a = c0->a + INTEGER(frac0 * (c1->a - c0->a)); + cx->b = c0->b + INTEGER(frac0 * (c1->b - c0->b)); + cx->c = c0->c + INTEGER(frac0 * (c1->c - c0->c)); + cx->d = c0->d + INTEGER(frac0 * (c1->d - c0->d)); +#else + cx->a = (Uint8)INTEGER(frac1 * c0->a + frac0 * c1->a); + cx->b = (Uint8)INTEGER(frac1 * c0->b + frac0 * c1->b); + cx->c = (Uint8)INTEGER(frac1 * c0->c + frac0 * c1->c); + cx->d = (Uint8)INTEGER(frac1 * c0->d + frac0 * c1->d); +#endif +} + +static SDL_INLINE void INTERPOL_BILINEAR(const Uint32 *s0, const Uint32 *s1, int frac_w0, int frac_h0, int frac_h1, Uint32 *dst) +{ + Uint32 tmp[2]; + unsigned int frac_w1 = FRAC_ONE - frac_w0; + + // Vertical first, store to 'tmp' + INTERPOL(s0, s1, frac_h0, frac_h1, tmp); + INTERPOL(s0 + 1, s1 + 1, frac_h0, frac_h1, tmp + 1); + + // Horizontal, store to 'dst' + INTERPOL(tmp, tmp + 1, frac_w0, frac_w1, dst); +} + +static bool scale_mat(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + BILINEAR___START + + for (i = 0; i < dst_h; i++) { + + BILINEAR___HEIGHT + + while (left_pad_w--) { + INTERPOL_BILINEAR(src_h0, src_h1, FRAC_ZERO, frac_h0, frac_h1, dst); + dst += 1; + } + + while (middle--) { + const Uint32 *s_00_01; + const Uint32 *s_10_11; + int index_w = 4 * SRC_INDEX(fp_sum_w); + int frac_w = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + + /* + x00 ... x0_ ..... x01 + . . . + . x . + . . . + . . . + x10 ... x1_ ..... x11 + */ + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + + INTERPOL_BILINEAR(s_00_01, s_10_11, frac_w, frac_h0, frac_h1, dst); + + dst += 1; + } + + while (right_pad_w--) { + int index_w = 4 * (src_w - 2); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR(s_00_01, s_10_11, FRAC_ONE, frac_h0, frac_h1, dst); + dst += 1; + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return true; +} + +#ifdef SDL_NEON_INTRINSICS +#define CAST_uint8x8_t (uint8x8_t) +#define CAST_uint32x2_t (uint32x2_t) +#endif + +#if defined(_MSC_VER) +#ifdef SDL_NEON_INTRINSICS +#undef CAST_uint8x8_t +#undef CAST_uint32x2_t +#define CAST_uint8x8_t +#define CAST_uint32x2_t +#endif +#endif + +#ifdef SDL_SSE2_INTRINSICS + +#if 0 +static void SDL_TARGETING("sse2") printf_128(const char *str, __m128i var) +{ + uint16_t *val = (uint16_t*) &var; + printf(" * %s: %04x %04x %04x %04x _ %04x %04x %04x %04x\n", + str, val[0], val[1], val[2], val[3], val[4], val[5], val[6], val[7]); +} +#endif + +static SDL_INLINE int hasSSE2(void) +{ + static int val = -1; + if (val != -1) { + return val; + } + val = SDL_HasSSE2(); + return val; +} + +static SDL_INLINE void SDL_TARGETING("sse2") INTERPOL_BILINEAR_SSE(const Uint32 *s0, const Uint32 *s1, int frac_w, __m128i v_frac_h0, __m128i v_frac_h1, Uint32 *dst, __m128i zero) +{ + __m128i x_00_01, x_10_11; /* Pixels in 4*uint8 in row */ + __m128i v_frac_w0, k0, l0, d0, e0; + + int f, f2; + f = frac_w; + f2 = FRAC_ONE - frac_w; + v_frac_w0 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2); + + x_00_01 = _mm_loadl_epi64((const __m128i *)s0); // Load x00 and x01 + x_10_11 = _mm_loadl_epi64((const __m128i *)s1); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + + // Interpolation vertical + k0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_00_01, zero), v_frac_h1); + l0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_10_11, zero), v_frac_h0); + k0 = _mm_add_epi16(k0, l0); + + // For perfect match, clear the factionnal part eventually. + /* + k0 = _mm_srli_epi16(k0, PRECISION); + k0 = _mm_slli_epi16(k0, PRECISION); + */ + + // Interpolation horizontal + l0 = _mm_unpacklo_epi64(/* unused */ l0, k0); + k0 = _mm_madd_epi16(_mm_unpackhi_epi16(l0, k0), v_frac_w0); + + // Store 1 pixel + d0 = _mm_srli_epi32(k0, PRECISION * 2); + e0 = _mm_packs_epi32(d0, d0); + e0 = _mm_packus_epi16(e0, e0); + *dst = _mm_cvtsi128_si32(e0); +} + +static bool SDL_TARGETING("sse2") scale_mat_SSE(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + BILINEAR___START + + for (i = 0; i < dst_h; i++) { + int nb_block2; + __m128i v_frac_h0; + __m128i v_frac_h1; + __m128i zero; + + BILINEAR___HEIGHT + + nb_block2 = middle / 2; + + v_frac_h0 = _mm_set_epi16((short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0, (short)frac_h0); + v_frac_h1 = _mm_set_epi16((short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1, (short)frac_h1); + zero = _mm_setzero_si128(); + + while (left_pad_w--) { + INTERPOL_BILINEAR_SSE(src_h0, src_h1, FRAC_ZERO, v_frac_h0, v_frac_h1, dst, zero); + dst += 1; + } + + while (nb_block2--) { + int index_w_0, frac_w_0; + int index_w_1, frac_w_1; + + const Uint32 *s_00_01, *s_02_03, *s_10_11, *s_12_13; + + __m128i x_00_01, x_10_11, x_02_03, x_12_13; /* Pixels in 4*uint8 in row */ + __m128i v_frac_w0, k0, l0, d0, e0; + __m128i v_frac_w1, k1, l1, d1, e1; + + int f, f2; + index_w_0 = 4 * SRC_INDEX(fp_sum_w); + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_1 = 4 * SRC_INDEX(fp_sum_w); + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + /* + x00............ x01 x02...........x03 + . . . . . . + j0 f0 j1 j2 f1 j3 + . . . . . . + . . . . . . + . . . . . . + x10............ x11 x12...........x13 + */ + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); + s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); + s_12_13 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_1); + + f = frac_w_0; + f2 = FRAC_ONE - frac_w_0; + v_frac_w0 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2); + + f = frac_w_1; + f2 = FRAC_ONE - frac_w_1; + v_frac_w1 = _mm_set_epi16((short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2, (short)f, (short)f2); + + x_00_01 = _mm_loadl_epi64((const __m128i *)s_00_01); // Load x00 and x01 + x_02_03 = _mm_loadl_epi64((const __m128i *)s_02_03); + x_10_11 = _mm_loadl_epi64((const __m128i *)s_10_11); + x_12_13 = _mm_loadl_epi64((const __m128i *)s_12_13); + + // Interpolation vertical + k0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_00_01, zero), v_frac_h1); + l0 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_10_11, zero), v_frac_h0); + k0 = _mm_add_epi16(k0, l0); + k1 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_02_03, zero), v_frac_h1); + l1 = _mm_mullo_epi16(_mm_unpacklo_epi8(x_12_13, zero), v_frac_h0); + k1 = _mm_add_epi16(k1, l1); + + // Interpolation horizontal + l0 = _mm_unpacklo_epi64(/* unused */ l0, k0); + k0 = _mm_madd_epi16(_mm_unpackhi_epi16(l0, k0), v_frac_w0); + l1 = _mm_unpacklo_epi64(/* unused */ l1, k1); + k1 = _mm_madd_epi16(_mm_unpackhi_epi16(l1, k1), v_frac_w1); + + // Store 1 pixel + d0 = _mm_srli_epi32(k0, PRECISION * 2); + e0 = _mm_packs_epi32(d0, d0); + e0 = _mm_packus_epi16(e0, e0); + *dst++ = _mm_cvtsi128_si32(e0); + + // Store 1 pixel + d1 = _mm_srli_epi32(k1, PRECISION * 2); + e1 = _mm_packs_epi32(d1, d1); + e1 = _mm_packus_epi16(e1, e1); + *dst++ = _mm_cvtsi128_si32(e1); + } + + // Last point + if (middle & 0x1) { + const Uint32 *s_00_01; + const Uint32 *s_10_11; + int index_w = 4 * SRC_INDEX(fp_sum_w); + int frac_w = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_SSE(s_00_01, s_10_11, frac_w, v_frac_h0, v_frac_h1, dst, zero); + dst += 1; + } + + while (right_pad_w--) { + int index_w = 4 * (src_w - 2); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_SSE(s_00_01, s_10_11, FRAC_ONE, v_frac_h0, v_frac_h1, dst, zero); + dst += 1; + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return true; +} +#endif + +#ifdef SDL_NEON_INTRINSICS + +static SDL_INLINE int hasNEON(void) +{ + static int val = -1; + if (val != -1) { + return val; + } + val = SDL_HasNEON(); + return val; +} + +static SDL_INLINE void INTERPOL_BILINEAR_NEON(const Uint32 *s0, const Uint32 *s1, int frac_w, uint8x8_t v_frac_h0, uint8x8_t v_frac_h1, Uint32 *dst) +{ + uint8x8_t x_00_01, x_10_11; /* Pixels in 4*uint8 in row */ + uint16x8_t k0; + uint32x4_t l0; + uint16x8_t d0; + uint8x8_t e0; + + x_00_01 = CAST_uint8x8_t vld1_u32(s0); // Load 2 pixels + x_10_11 = CAST_uint8x8_t vld1_u32(s1); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + + // k0 now contains 2 interpolated pixels { j0, j1 } + l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); + l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w); + l0 = vmlal_n_u16(l0, vget_high_u16(k0), frac_w); + + // Shift and narrow + d0 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION)); + + // Narrow again + e0 = vmovn_u16(d0); + + // Store 1 pixel + *dst = vget_lane_u32(CAST_uint32x2_t e0, 0); +} + +static bool scale_mat_NEON(const Uint32 *src, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + BILINEAR___START + + for (i = 0; i < dst_h; i++) { + int nb_block4; + uint8x8_t v_frac_h0, v_frac_h1; + + BILINEAR___HEIGHT + + nb_block4 = middle / 4; + + v_frac_h0 = vmov_n_u8(frac_h0); + v_frac_h1 = vmov_n_u8(frac_h1); + + while (left_pad_w--) { + INTERPOL_BILINEAR_NEON(src_h0, src_h1, FRAC_ZERO, v_frac_h0, v_frac_h1, dst); + dst += 1; + } + + while (nb_block4--) { + int index_w_0, frac_w_0; + int index_w_1, frac_w_1; + int index_w_2, frac_w_2; + int index_w_3, frac_w_3; + + const Uint32 *s_00_01, *s_02_03, *s_04_05, *s_06_07; + const Uint32 *s_10_11, *s_12_13, *s_14_15, *s_16_17; + + uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13; /* Pixels in 4*uint8 in row */ + uint8x8_t x_04_05, x_14_15, x_06_07, x_16_17; + + uint16x8_t k0, k1, k2, k3; + uint32x4_t l0, l1, l2, l3; + uint16x8_t d0, d1; + uint8x8_t e0, e1; + uint32x4_t f0; + + index_w_0 = 4 * SRC_INDEX(fp_sum_w); + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_1 = 4 * SRC_INDEX(fp_sum_w); + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_2 = 4 * SRC_INDEX(fp_sum_w); + frac_w_2 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_3 = 4 * SRC_INDEX(fp_sum_w); + frac_w_3 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); + s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); + s_04_05 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_2); + s_06_07 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_3); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); + s_12_13 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_1); + s_14_15 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_2); + s_16_17 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_3); + + // Interpolation vertical + x_00_01 = CAST_uint8x8_t vld1_u32(s_00_01); // Load 2 pixels + x_02_03 = CAST_uint8x8_t vld1_u32(s_02_03); + x_04_05 = CAST_uint8x8_t vld1_u32(s_04_05); + x_06_07 = CAST_uint8x8_t vld1_u32(s_06_07); + x_10_11 = CAST_uint8x8_t vld1_u32(s_10_11); + x_12_13 = CAST_uint8x8_t vld1_u32(s_12_13); + x_14_15 = CAST_uint8x8_t vld1_u32(s_14_15); + x_16_17 = CAST_uint8x8_t vld1_u32(s_16_17); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + + k1 = vmull_u8(x_02_03, v_frac_h1); + k1 = vmlal_u8(k1, x_12_13, v_frac_h0); + + k2 = vmull_u8(x_04_05, v_frac_h1); + k2 = vmlal_u8(k2, x_14_15, v_frac_h0); + + k3 = vmull_u8(x_06_07, v_frac_h1); + k3 = vmlal_u8(k3, x_16_17, v_frac_h0); + + // k0 now contains 2 interpolated pixels { j0, j1 } + // k1 now contains 2 interpolated pixels { j2, j3 } + // k2 now contains 2 interpolated pixels { j4, j5 } + // k3 now contains 2 interpolated pixels { j6, j7 } + + l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); + l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w_0); + l0 = vmlal_n_u16(l0, vget_high_u16(k0), frac_w_0); + + l1 = vshll_n_u16(vget_low_u16(k1), PRECISION); + l1 = vmlsl_n_u16(l1, vget_low_u16(k1), frac_w_1); + l1 = vmlal_n_u16(l1, vget_high_u16(k1), frac_w_1); + + l2 = vshll_n_u16(vget_low_u16(k2), PRECISION); + l2 = vmlsl_n_u16(l2, vget_low_u16(k2), frac_w_2); + l2 = vmlal_n_u16(l2, vget_high_u16(k2), frac_w_2); + + l3 = vshll_n_u16(vget_low_u16(k3), PRECISION); + l3 = vmlsl_n_u16(l3, vget_low_u16(k3), frac_w_3); + l3 = vmlal_n_u16(l3, vget_high_u16(k3), frac_w_3); + + // shift and narrow + d0 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION)); + // narrow again + e0 = vmovn_u16(d0); + + // Shift and narrow + d1 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l2, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l3, 2 * PRECISION)); + // Narrow again + e1 = vmovn_u16(d1); + + f0 = vcombine_u32(CAST_uint32x2_t e0, CAST_uint32x2_t e1); + // Store 4 pixels + vst1q_u32(dst, f0); + + dst += 4; + } + + if (middle & 0x2) { + int index_w_0, frac_w_0; + int index_w_1, frac_w_1; + const Uint32 *s_00_01, *s_02_03; + const Uint32 *s_10_11, *s_12_13; + uint8x8_t x_00_01, x_10_11, x_02_03, x_12_13; /* Pixels in 4*uint8 in row */ + uint16x8_t k0, k1; + uint32x4_t l0, l1; + uint16x8_t d0; + uint8x8_t e0; + + index_w_0 = 4 * SRC_INDEX(fp_sum_w); + frac_w_0 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + index_w_1 = 4 * SRC_INDEX(fp_sum_w); + frac_w_1 = FRAC(fp_sum_w); + fp_sum_w += fp_step_w; + /* + x00............ x01 x02...........x03 + . . . . . . + j0 dest0 j1 j2 dest1 j3 + . . . . . . + . . . . . . + . . . . . . + x10............ x11 x12...........x13 + */ + s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_0); + s_02_03 = (const Uint32 *)((const Uint8 *)src_h0 + index_w_1); + s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_0); + s_12_13 = (const Uint32 *)((const Uint8 *)src_h1 + index_w_1); + + // Interpolation vertical + x_00_01 = CAST_uint8x8_t vld1_u32(s_00_01); // Load 2 pixels + x_02_03 = CAST_uint8x8_t vld1_u32(s_02_03); + x_10_11 = CAST_uint8x8_t vld1_u32(s_10_11); + x_12_13 = CAST_uint8x8_t vld1_u32(s_12_13); + + /* Interpolated == x0 + frac * (x1 - x0) == x0 * (1 - frac) + x1 * frac */ + k0 = vmull_u8(x_00_01, v_frac_h1); /* k0 := x0 * (1 - frac) */ + k0 = vmlal_u8(k0, x_10_11, v_frac_h0); /* k0 += x1 * frac */ + + k1 = vmull_u8(x_02_03, v_frac_h1); + k1 = vmlal_u8(k1, x_12_13, v_frac_h0); + + // k0 now contains 2 interpolated pixels { j0, j1 } + // k1 now contains 2 interpolated pixels { j2, j3 } + + l0 = vshll_n_u16(vget_low_u16(k0), PRECISION); + l0 = vmlsl_n_u16(l0, vget_low_u16(k0), frac_w_0); + l0 = vmlal_n_u16(l0, vget_high_u16(k0), frac_w_0); + + l1 = vshll_n_u16(vget_low_u16(k1), PRECISION); + l1 = vmlsl_n_u16(l1, vget_low_u16(k1), frac_w_1); + l1 = vmlal_n_u16(l1, vget_high_u16(k1), frac_w_1); + + // Shift and narrow + + d0 = vcombine_u16( + /* uint16x4_t */ vshrn_n_u32(l0, 2 * PRECISION), + /* uint16x4_t */ vshrn_n_u32(l1, 2 * PRECISION)); + + // Narrow again + e0 = vmovn_u16(d0); + + // Store 2 pixels + vst1_u32(dst, CAST_uint32x2_t e0); + dst += 2; + } + + // Last point + if (middle & 0x1) { + int index_w = 4 * SRC_INDEX(fp_sum_w); + int frac_w = FRAC(fp_sum_w); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_NEON(s_00_01, s_10_11, frac_w, v_frac_h0, v_frac_h1, dst); + dst += 1; + } + + while (right_pad_w--) { + int index_w = 4 * (src_w - 2); + const Uint32 *s_00_01 = (const Uint32 *)((const Uint8 *)src_h0 + index_w); + const Uint32 *s_10_11 = (const Uint32 *)((const Uint8 *)src_h1 + index_w); + INTERPOL_BILINEAR_NEON(s_00_01, s_10_11, FRAC_ONE, v_frac_h0, v_frac_h1, dst); + dst += 1; + } + + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return true; +} +#endif + +bool SDL_StretchSurfaceUncheckedLinear(SDL_Surface *s, const SDL_Rect *srcrect, SDL_Surface *d, const SDL_Rect *dstrect) +{ + bool result = false; + int src_w = srcrect->w; + int src_h = srcrect->h; + int dst_w = dstrect->w; + int dst_h = dstrect->h; + int src_pitch = s->pitch; + int dst_pitch = d->pitch; + Uint32 *src = (Uint32 *)((Uint8 *)s->pixels + srcrect->x * 4 + srcrect->y * src_pitch); + Uint32 *dst = (Uint32 *)((Uint8 *)d->pixels + dstrect->x * 4 + dstrect->y * dst_pitch); + +#ifdef SDL_NEON_INTRINSICS + if (!result && hasNEON()) { + result = scale_mat_NEON(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } +#endif + +#ifdef SDL_SSE2_INTRINSICS + if (!result && hasSSE2()) { + result = scale_mat_SSE(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } +#endif + + if (!result) { + result = scale_mat(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } + + return result; +} + +#define SDL_SCALE_NEAREST__START \ + int i; \ + Uint64 posy, incy; \ + Uint64 posx, incx; \ + Uint64 srcy, srcx; \ + int dst_gap, n; \ + const Uint32 *src_h0; \ + incy = ((Uint64)src_h << 16) / dst_h; \ + incx = ((Uint64)src_w << 16) / dst_w; \ + dst_gap = dst_pitch - bpp * dst_w; \ + posy = incy / 2; + +#define SDL_SCALE_NEAREST__HEIGHT \ + srcy = (posy >> 16); \ + src_h0 = (const Uint32 *)((const Uint8 *)src_ptr + srcy * src_pitch); \ + posy += incy; \ + posx = incx / 2; \ + n = dst_w; + +static bool scale_mat_nearest_1(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 1; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint8 *src; + srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint8 *)src_h0 + srcx; + *(Uint8 *)dst = *src; + dst = (Uint32 *)((Uint8 *)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return true; +} + +static bool scale_mat_nearest_2(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 2; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint16 *src; + srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint16 *)((const Uint8 *)src_h0 + srcx); + *(Uint16 *)dst = *src; + dst = (Uint32 *)((Uint8 *)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return true; +} + +static bool scale_mat_nearest_3(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 3; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint8 *src; + srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint8 *)src_h0 + srcx; + ((Uint8 *)dst)[0] = src[0]; + ((Uint8 *)dst)[1] = src[1]; + ((Uint8 *)dst)[2] = src[2]; + dst = (Uint32 *)((Uint8 *)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return true; +} + +static bool scale_mat_nearest_4(const Uint32 *src_ptr, int src_w, int src_h, int src_pitch, Uint32 *dst, int dst_w, int dst_h, int dst_pitch) +{ + Uint32 bpp = 4; + SDL_SCALE_NEAREST__START + for (i = 0; i < dst_h; i++) { + SDL_SCALE_NEAREST__HEIGHT + while (n--) { + const Uint32 *src; + srcx = bpp * (posx >> 16); + posx += incx; + src = (const Uint32 *)((const Uint8 *)src_h0 + srcx); + *dst = *src; + dst = (Uint32 *)((Uint8 *)dst + bpp); + } + dst = (Uint32 *)((Uint8 *)dst + dst_gap); + } + return true; +} + +bool SDL_StretchSurfaceUncheckedNearest(SDL_Surface *s, const SDL_Rect *srcrect, SDL_Surface *d, const SDL_Rect *dstrect) +{ + int src_w = srcrect->w; + int src_h = srcrect->h; + int dst_w = dstrect->w; + int dst_h = dstrect->h; + int src_pitch = s->pitch; + int dst_pitch = d->pitch; + int bpp = SDL_BYTESPERPIXEL(d->format); + + Uint32 *src = (Uint32 *)((Uint8 *)s->pixels + srcrect->x * bpp + srcrect->y * src_pitch); + Uint32 *dst = (Uint32 *)((Uint8 *)d->pixels + dstrect->x * bpp + dstrect->y * dst_pitch); + + if (bpp == 4) { + return scale_mat_nearest_4(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } else if (bpp == 3) { + return scale_mat_nearest_3(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } else if (bpp == 2) { + return scale_mat_nearest_2(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } else { + return scale_mat_nearest_1(src, src_w, src_h, src_pitch, dst, dst_w, dst_h, dst_pitch); + } +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_surface.c b/contrib/SDL-3.2.8/src/video/SDL_surface.c new file mode 100644 index 0000000..945fda6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_surface.c @@ -0,0 +1,2995 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_sysvideo.h" +#include "SDL_video_c.h" +#include "SDL_RLEaccel_c.h" +#include "SDL_pixels_c.h" +#include "SDL_stb_c.h" +#include "SDL_yuv_c.h" +#include "../render/SDL_sysrender.h" + +#include "SDL_surface_c.h" + + +// Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t +SDL_COMPILE_TIME_ASSERT(surface_size_assumptions, + sizeof(int) == sizeof(Sint32) && sizeof(size_t) >= sizeof(Sint32)); + +SDL_COMPILE_TIME_ASSERT(can_indicate_overflow, SDL_SIZE_MAX > SDL_MAX_SINT32); + +// Magic! +static char SDL_surface_magic; + +// Public routines + +bool SDL_SurfaceValid(SDL_Surface *surface) +{ + return (surface && surface->reserved == &SDL_surface_magic); +} + +void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface) +{ + if (SDL_SurfaceHasRLE(surface)) { + surface->flags |= SDL_SURFACE_LOCK_NEEDED; + } else { + surface->flags &= ~SDL_SURFACE_LOCK_NEEDED; + } +} + +/* + * Calculate the pad-aligned scanline width of a surface. + * + * for FOURCC, use SDL_CalculateYUVSize() + */ +static bool SDL_CalculateRGBSize(Uint32 format, size_t width, size_t height, size_t *size, size_t *pitch, bool minimal) +{ + if (SDL_BITSPERPIXEL(format) >= 8) { + if (!SDL_size_mul_check_overflow(width, SDL_BYTESPERPIXEL(format), pitch)) { + return SDL_SetError("width * bpp would overflow"); + } + } else { + if (!SDL_size_mul_check_overflow(width, SDL_BITSPERPIXEL(format), pitch)) { + return SDL_SetError("width * bpp would overflow"); + } + if (!SDL_size_add_check_overflow(*pitch, 7, pitch)) { + return SDL_SetError("aligning pitch would overflow"); + } + *pitch /= 8; + } + if (!minimal) { + // 4-byte aligning for speed + if (!SDL_size_add_check_overflow(*pitch, 3, pitch)) { + return SDL_SetError("aligning pitch would overflow"); + } + *pitch &= ~3; + } + + if (!SDL_size_mul_check_overflow(height, *pitch, size)) { + return SDL_SetError("height * pitch would overflow"); + } + + return true; +} + +bool SDL_CalculateSurfaceSize(SDL_PixelFormat format, int width, int height, size_t *size, size_t *pitch, bool minimalPitch) +{ + size_t p = 0, sz = 0; + + if (size) { + *size = 0; + } + + if (pitch) { + *pitch = 0; + } + + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + if (!SDL_CalculateYUVSize(format, width, height, &sz, &p)) { + // Overflow... + return false; + } + } else { + if (!SDL_CalculateRGBSize(format, width, height, &sz, &p, minimalPitch)) { + // Overflow... + return false; + } + } + + if (size) { + *size = sz; + } + + if (pitch) { + *pitch = p; + } + + return true; +} + +static bool SDL_InitializeSurface(SDL_Surface *surface, int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, SDL_PropertiesID props, void *pixels, int pitch, bool onstack) +{ + SDL_zerop(surface); + + surface->flags = SDL_SURFACE_PREALLOCATED; + surface->format = format; + surface->w = width; + surface->h = height; + surface->pixels = pixels; + surface->pitch = pitch; + surface->reserved = &SDL_surface_magic; + + if (onstack) { + surface->internal_flags |= SDL_INTERNAL_SURFACE_STACK; + } + + surface->fmt = SDL_GetPixelFormatDetails(format); + if (!surface->fmt) { + SDL_DestroySurface(surface); + return false; + } + + // Initialize the clip rect + surface->clip_rect.w = width; + surface->clip_rect.h = height; + + // Allocate an empty mapping + surface->map.info.r = 0xFF; + surface->map.info.g = 0xFF; + surface->map.info.b = 0xFF; + surface->map.info.a = 0xFF; + + if (colorspace == SDL_COLORSPACE_UNKNOWN) { + surface->colorspace = SDL_GetDefaultColorspaceForFormat(format); + } else { + surface->colorspace = colorspace; + } + + if (props) { + if (!SDL_CopyProperties(props, SDL_GetSurfaceProperties(surface))) { + SDL_DestroySurface(surface); + return false; + } + } + + // By default surfaces with an alpha mask are set up for blending + if (SDL_ISPIXELFORMAT_ALPHA(surface->format)) { + SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); + } + + // The surface is ready to go + surface->refcount = 1; + return true; +} + +/* + * Create an empty surface of the appropriate depth using the given format + */ +SDL_Surface *SDL_CreateSurface(int width, int height, SDL_PixelFormat format) +{ + size_t pitch, size; + SDL_Surface *surface; + + if (width < 0) { + SDL_InvalidParamError("width"); + return NULL; + } + + if (height < 0) { + SDL_InvalidParamError("height"); + return NULL; + } + + if (!SDL_CalculateSurfaceSize(format, width, height, &size, &pitch, false /* not minimal pitch */)) { + // Overflow... + return NULL; + } + + // Allocate and initialize the surface + surface = (SDL_Surface *)SDL_malloc(sizeof(*surface)); + if (!surface) { + return NULL; + } + + if (!SDL_InitializeSurface(surface, width, height, format, SDL_COLORSPACE_UNKNOWN, 0, NULL, (int)pitch, false)) { + return NULL; + } + + if (surface->w && surface->h) { + surface->flags &= ~SDL_SURFACE_PREALLOCATED; + surface->pixels = SDL_aligned_alloc(SDL_GetSIMDAlignment(), size); + if (!surface->pixels) { + SDL_DestroySurface(surface); + return NULL; + } + surface->flags |= SDL_SURFACE_SIMD_ALIGNED; + + // This is important for bitmaps + SDL_memset(surface->pixels, 0, size); + } + return surface; +} + +/* + * Create an RGB surface from an existing memory buffer using the given + * enum SDL_PIXELFORMAT_* format + */ +SDL_Surface *SDL_CreateSurfaceFrom(int width, int height, SDL_PixelFormat format, void *pixels, int pitch) +{ + if (width < 0) { + SDL_InvalidParamError("width"); + return NULL; + } + + if (height < 0) { + SDL_InvalidParamError("height"); + return NULL; + } + + if (pitch == 0 && !pixels) { + // The application will fill these in later with valid values + } else { + size_t minimalPitch; + + if (!SDL_CalculateSurfaceSize(format, width, height, NULL, &minimalPitch, true /* minimal pitch */)) { + // Overflow... + return NULL; + } + + if (pitch < 0 || (size_t)pitch < minimalPitch) { + SDL_InvalidParamError("pitch"); + return NULL; + } + } + + // Allocate and initialize the surface + SDL_Surface *surface = (SDL_Surface *)SDL_malloc(sizeof(*surface)); + if (!surface || + !SDL_InitializeSurface(surface, width, height, format, SDL_COLORSPACE_UNKNOWN, 0, pixels, pitch, false)) { + return NULL; + } + return surface; +} + +SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + return 0; + } + + if (!surface->props) { + surface->props = SDL_CreateProperties(); + } + return surface->props; +} + +bool SDL_SetSurfaceColorspace(SDL_Surface *surface, SDL_Colorspace colorspace) +{ + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + surface->colorspace = colorspace; + return true; +} + +SDL_Colorspace SDL_GetSurfaceColorspace(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return SDL_COLORSPACE_UNKNOWN; + } + + return surface->colorspace; +} + +float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace) +{ + return SDL_GetSurfaceSDRWhitePoint(NULL, colorspace); +} + +float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace) +{ + SDL_TransferCharacteristics transfer = SDL_COLORSPACETRANSFER(colorspace); + + if (transfer == SDL_TRANSFER_CHARACTERISTICS_LINEAR || + transfer == SDL_TRANSFER_CHARACTERISTICS_PQ) { + SDL_PropertiesID props; + float default_value = 1.0f; + + if (SDL_SurfaceValid(surface)) { + props = surface->props; + } else { + props = 0; + } + if (transfer == SDL_TRANSFER_CHARACTERISTICS_PQ) { + /* The older standards use an SDR white point of 100 nits. + * ITU-R BT.2408-6 recommends using an SDR white point of 203 nits. + * This is the default Chrome uses, and what a lot of game content + * assumes, so we'll go with that. + */ + const float DEFAULT_PQ_SDR_WHITE_POINT = 203.0f; + default_value = DEFAULT_PQ_SDR_WHITE_POINT; + } + return SDL_GetFloatProperty(props, SDL_PROP_SURFACE_SDR_WHITE_POINT_FLOAT, default_value); + } + return 1.0f; +} + +float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace) +{ + return SDL_GetSurfaceHDRHeadroom(NULL, colorspace); +} + +float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace) +{ + SDL_TransferCharacteristics transfer = SDL_COLORSPACETRANSFER(colorspace); + + if (transfer == SDL_TRANSFER_CHARACTERISTICS_LINEAR || + transfer == SDL_TRANSFER_CHARACTERISTICS_PQ) { + SDL_PropertiesID props; + float default_value = 0.0f; + + if (SDL_SurfaceValid(surface)) { + props = surface->props; + } else { + props = 0; + } + return SDL_GetFloatProperty(props, SDL_PROP_SURFACE_HDR_HEADROOM_FLOAT, default_value); + } + return 1.0f; +} + +SDL_Palette *SDL_CreateSurfacePalette(SDL_Surface *surface) +{ + SDL_Palette *palette; + + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + return NULL; + } + + if (!SDL_ISPIXELFORMAT_INDEXED(surface->format)) { + SDL_SetError("The surface is not indexed format"); + return NULL; + } + + palette = SDL_CreatePalette((1 << SDL_BITSPERPIXEL(surface->format))); + if (!palette) { + return NULL; + } + + if (palette->ncolors == 2) { + // Create a black and white bitmap palette + palette->colors[0].r = 0xFF; + palette->colors[0].g = 0xFF; + palette->colors[0].b = 0xFF; + palette->colors[1].r = 0x00; + palette->colors[1].g = 0x00; + palette->colors[1].b = 0x00; + } + + if (!SDL_SetSurfacePalette(surface, palette)) { + SDL_DestroyPalette(palette); + return NULL; + } + + // The surface has retained the palette, we can remove the reference here + SDL_assert(palette->refcount == 2); + SDL_DestroyPalette(palette); + return palette; +} + +bool SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette) +{ + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + if (palette && palette->ncolors > (1 << SDL_BITSPERPIXEL(surface->format))) { + return SDL_SetError("SDL_SetSurfacePalette() passed a palette that doesn't match the surface format"); + } + + if (palette != surface->palette) { + if (surface->palette) { + SDL_DestroyPalette(surface->palette); + } + + surface->palette = palette; + + if (surface->palette) { + ++surface->palette->refcount; + } + } + + SDL_InvalidateMap(&surface->map); + + return true; +} + +SDL_Palette *SDL_GetSurfacePalette(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return NULL; + } + + return surface->palette; +} + +bool SDL_AddSurfaceAlternateImage(SDL_Surface *surface, SDL_Surface *image) +{ + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + if (!SDL_SurfaceValid(image)) { + return SDL_InvalidParamError("image"); + } + + SDL_Surface **images = (SDL_Surface **)SDL_realloc(surface->images, (surface->num_images + 1) * sizeof(*images)); + if (!images) { + return false; + } + images[surface->num_images] = image; + surface->images = images; + ++surface->num_images; + ++image->refcount; + return true; +} + +bool SDL_SurfaceHasAlternateImages(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return false; + } + + return (surface->num_images > 0); +} + +SDL_Surface **SDL_GetSurfaceImages(SDL_Surface *surface, int *count) +{ + if (count) { + *count = 0; + } + + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + return NULL; + } + + int num_images = 1 + surface->num_images; + SDL_Surface **images = (SDL_Surface **)SDL_malloc((num_images + 1) * sizeof(*images)); + if (!images) { + return NULL; + } + images[0] = surface; + if (surface->num_images > 0) { + SDL_memcpy(&images[1], surface->images, (surface->num_images * sizeof(images[1]))); + } + images[num_images] = NULL; + + if (count) { + *count = num_images; + } + return images; +} + +SDL_Surface *SDL_GetSurfaceImage(SDL_Surface *surface, float display_scale) +{ + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + return NULL; + } + + if (!SDL_SurfaceHasAlternateImages(surface)) { + ++surface->refcount; + return surface; + } + + // This surface has high DPI images, pick the best one available, or scale one to the correct size + SDL_Surface **images = SDL_GetSurfaceImages(surface, NULL); + if (!images) { + // Failure, fall back to the existing surface + ++surface->refcount; + return surface; + } + + // Find closest image. Images that are larger than the + // desired size are preferred over images that are smaller. + SDL_Surface *closest = NULL; + int desired_w = (int)SDL_round(surface->w * display_scale); + int desired_h = (int)SDL_round(surface->h * display_scale); + int desired_size = desired_w * desired_h; + int closest_distance = -1; + int closest_size = -1; + for (int i = 0; images[i]; ++i) { + SDL_Surface *candidate = images[i]; + int size = candidate->w * candidate->h; + int delta_w = (candidate->w - desired_w); + int delta_h = (candidate->h - desired_h); + int distance = (delta_w * delta_w) + (delta_h * delta_h); + if (closest_distance < 0 || distance < closest_distance || + (size > desired_size && closest_size < desired_size)) { + closest = candidate; + closest_distance = distance; + closest_size = size; + } + } + SDL_free(images); + SDL_assert(closest != NULL); // We should always have at least one surface + + if (closest->w == desired_w && closest->h == desired_h) { + ++closest->refcount; + return closest; + } + + // We need to scale the image to the correct size. To maintain good image quality, downscaling + // is done in steps, never reducing the width and height by more than half each time. + SDL_Surface *scaled = closest; + do { + int next_scaled_w = SDL_max(desired_w, (scaled->w + 1) / 2); + int next_scaled_h = SDL_max(desired_h, (scaled->h + 1) / 2); + SDL_Surface *next_scaled = SDL_ScaleSurface(scaled, next_scaled_w, next_scaled_h, SDL_SCALEMODE_LINEAR); + if (scaled != closest) { + SDL_DestroySurface(scaled); + } + scaled = next_scaled; + if (!scaled) { + // Failure, fall back to the closest surface + ++closest->refcount; + return closest; + } + } while (scaled->w != desired_w || scaled->h != desired_h); + + return scaled; +} + +void SDL_RemoveSurfaceAlternateImages(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return; + } + + if (surface->num_images > 0) { + for (int i = 0; i < surface->num_images; ++i) { + SDL_DestroySurface(surface->images[i]); + } + SDL_free(surface->images); + surface->images = NULL; + surface->num_images = 0; + } +} + +bool SDL_SetSurfaceRLE(SDL_Surface *surface, bool enabled) +{ + int flags; + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + flags = surface->map.info.flags; + if (enabled) { + surface->map.info.flags |= SDL_COPY_RLE_DESIRED; + } else { + surface->map.info.flags &= ~SDL_COPY_RLE_DESIRED; + } + if (surface->map.info.flags != flags) { + SDL_InvalidateMap(&surface->map); + } + SDL_UpdateSurfaceLockFlag(surface); + return true; +} + +bool SDL_SurfaceHasRLE(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return false; + } + + if (!(surface->map.info.flags & SDL_COPY_RLE_DESIRED)) { + return false; + } + + return true; +} + +bool SDL_SetSurfaceColorKey(SDL_Surface *surface, bool enabled, Uint32 key) +{ + int flags; + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + if (surface->palette && key >= ((Uint32)surface->palette->ncolors)) { + return SDL_InvalidParamError("key"); + } + + flags = surface->map.info.flags; + if (enabled) { + surface->map.info.flags |= SDL_COPY_COLORKEY; + surface->map.info.colorkey = key; + } else { + surface->map.info.flags &= ~SDL_COPY_COLORKEY; + } + if (surface->map.info.flags != flags) { + SDL_InvalidateMap(&surface->map); + } + + return true; +} + +bool SDL_SurfaceHasColorKey(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return false; + } + + if (!(surface->map.info.flags & SDL_COPY_COLORKEY)) { + return false; + } + + return true; +} + +bool SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key) +{ + if (key) { + *key = 0; + } + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + if (!(surface->map.info.flags & SDL_COPY_COLORKEY)) { + return SDL_SetError("Surface doesn't have a colorkey"); + } + + if (key) { + *key = surface->map.info.colorkey; + } + return true; +} + +/* This is a fairly slow function to switch from colorkey to alpha + NB: it doesn't handle bpp 1 or 3, because they have no alpha channel */ +static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, bool ignore_alpha) +{ + int x, y, bpp; + + if (!SDL_SurfaceValid(surface)) { + return; + } + + if (!(surface->map.info.flags & SDL_COPY_COLORKEY) || + !SDL_ISPIXELFORMAT_ALPHA(surface->format)) { + return; + } + + bpp = SDL_BYTESPERPIXEL(surface->format); + + SDL_LockSurface(surface); + + if (bpp == 2) { + Uint16 *row, *spot; + Uint16 ckey = (Uint16)surface->map.info.colorkey; + Uint16 mask = (Uint16)(~surface->fmt->Amask); + + // Ignore, or not, alpha in colorkey comparison + if (ignore_alpha) { + ckey &= mask; + row = (Uint16 *)surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if ((*spot & mask) == ckey) { + *spot &= mask; + } + ++spot; + } + row += surface->pitch / 2; + } + } else { + row = (Uint16 *)surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if (*spot == ckey) { + *spot &= mask; + } + ++spot; + } + row += surface->pitch / 2; + } + } + } else if (bpp == 4) { + Uint32 *row, *spot; + Uint32 ckey = surface->map.info.colorkey; + Uint32 mask = ~surface->fmt->Amask; + + // Ignore, or not, alpha in colorkey comparison + if (ignore_alpha) { + ckey &= mask; + row = (Uint32 *)surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if ((*spot & mask) == ckey) { + *spot &= mask; + } + ++spot; + } + row += surface->pitch / 4; + } + } else { + row = (Uint32 *)surface->pixels; + for (y = surface->h; y--;) { + spot = row; + for (x = surface->w; x--;) { + if (*spot == ckey) { + *spot &= mask; + } + ++spot; + } + row += surface->pitch / 4; + } + } + } + + SDL_UnlockSurface(surface); + + SDL_SetSurfaceColorKey(surface, false, 0); + SDL_SetSurfaceBlendMode(surface, SDL_BLENDMODE_BLEND); +} + +bool SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) +{ + int flags; + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + surface->map.info.r = r; + surface->map.info.g = g; + surface->map.info.b = b; + + flags = surface->map.info.flags; + if (r != 0xFF || g != 0xFF || b != 0xFF) { + surface->map.info.flags |= SDL_COPY_MODULATE_COLOR; + } else { + surface->map.info.flags &= ~SDL_COPY_MODULATE_COLOR; + } + if (surface->map.info.flags != flags) { + SDL_InvalidateMap(&surface->map); + } + return true; +} + +bool SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b) +{ + if (!SDL_SurfaceValid(surface)) { + if (r) { + *r = 255; + } + if (g) { + *g = 255; + } + if (b) { + *b = 255; + } + return SDL_InvalidParamError("surface"); + } + + if (r) { + *r = surface->map.info.r; + } + if (g) { + *g = surface->map.info.g; + } + if (b) { + *b = surface->map.info.b; + } + return true; +} + +bool SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) +{ + int flags; + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + surface->map.info.a = alpha; + + flags = surface->map.info.flags; + if (alpha != 0xFF) { + surface->map.info.flags |= SDL_COPY_MODULATE_ALPHA; + } else { + surface->map.info.flags &= ~SDL_COPY_MODULATE_ALPHA; + } + if (surface->map.info.flags != flags) { + SDL_InvalidateMap(&surface->map); + } + return true; +} + +bool SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha) +{ + if (!SDL_SurfaceValid(surface)) { + if (alpha) { + *alpha = 255; + } + return SDL_InvalidParamError("surface"); + } + + if (alpha) { + *alpha = surface->map.info.a; + } + return true; +} + +bool SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) +{ + int flags; + bool result = true; + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + if (blendMode == SDL_BLENDMODE_INVALID) { + return SDL_InvalidParamError("blendMode"); + } + + flags = surface->map.info.flags; + surface->map.info.flags &= ~SDL_COPY_BLEND_MASK; + switch (blendMode) { + case SDL_BLENDMODE_NONE: + break; + case SDL_BLENDMODE_BLEND: + surface->map.info.flags |= SDL_COPY_BLEND; + break; + case SDL_BLENDMODE_BLEND_PREMULTIPLIED: + surface->map.info.flags |= SDL_COPY_BLEND_PREMULTIPLIED; + break; + case SDL_BLENDMODE_ADD: + surface->map.info.flags |= SDL_COPY_ADD; + break; + case SDL_BLENDMODE_ADD_PREMULTIPLIED: + surface->map.info.flags |= SDL_COPY_ADD_PREMULTIPLIED; + break; + case SDL_BLENDMODE_MOD: + surface->map.info.flags |= SDL_COPY_MOD; + break; + case SDL_BLENDMODE_MUL: + surface->map.info.flags |= SDL_COPY_MUL; + break; + default: + result = SDL_Unsupported(); + break; + } + + if (surface->map.info.flags != flags) { + SDL_InvalidateMap(&surface->map); + } + + return result; +} + +bool SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode) +{ + if (blendMode) { + *blendMode = SDL_BLENDMODE_INVALID; + } + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + if (!blendMode) { + return true; + } + + switch (surface->map.info.flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: + *blendMode = SDL_BLENDMODE_BLEND; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: + *blendMode = SDL_BLENDMODE_BLEND_PREMULTIPLIED; + break; + case SDL_COPY_ADD: + *blendMode = SDL_BLENDMODE_ADD; + break; + case SDL_COPY_ADD_PREMULTIPLIED: + *blendMode = SDL_BLENDMODE_ADD_PREMULTIPLIED; + break; + case SDL_COPY_MOD: + *blendMode = SDL_BLENDMODE_MOD; + break; + case SDL_COPY_MUL: + *blendMode = SDL_BLENDMODE_MUL; + break; + default: + *blendMode = SDL_BLENDMODE_NONE; + break; + } + return true; +} + +bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect) +{ + SDL_Rect full_rect; + + // Don't do anything if there's no surface to act on + if (!SDL_SurfaceValid(surface)) { + return false; + } + + // Set up the full surface rectangle + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = surface->w; + full_rect.h = surface->h; + + // Set the clipping rectangle + if (!rect) { + surface->clip_rect = full_rect; + return true; + } + return SDL_GetRectIntersection(rect, &full_rect, &surface->clip_rect); +} + +bool SDL_GetSurfaceClipRect(SDL_Surface *surface, SDL_Rect *rect) +{ + if (!SDL_SurfaceValid(surface)) { + if (rect) { + SDL_zerop(rect); + } + return SDL_InvalidParamError("surface"); + } + if (!rect) { + return SDL_InvalidParamError("rect"); + } + *rect = surface->clip_rect; + return true; +} + +/* + * Set up a blit between two surfaces -- split into three parts: + * The upper part, SDL_BlitSurface(), performs clipping and rectangle + * verification. The lower part is a pointer to a low level + * accelerated blitting function. + * + * These parts are separated out and each used internally by this + * library in the optimum places. They are exported so that if + * you know exactly what you are doing, you can optimize your code + * by calling the one(s) you need. + */ +bool SDL_BlitSurfaceUnchecked(SDL_Surface *src, const SDL_Rect *srcrect, + SDL_Surface *dst, const SDL_Rect *dstrect) +{ + // Check to make sure the blit mapping is valid + if (!SDL_ValidateMap(src, dst)) { + return false; + } + return src->map.blit(src, srcrect, dst, dstrect); +} + +bool SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect) +{ + SDL_Rect r_src, r_dst; + + // Make sure the surfaces aren't locked + if (!SDL_SurfaceValid(src)) { + return SDL_InvalidParamError("src"); + } else if (!SDL_SurfaceValid(dst)) { + return SDL_InvalidParamError("dst"); + } else if ((src->flags & SDL_SURFACE_LOCKED) || (dst->flags & SDL_SURFACE_LOCKED)) { + return SDL_SetError("Surfaces must not be locked during blit"); + } + + // Full src surface + r_src.x = 0; + r_src.y = 0; + r_src.w = src->w; + r_src.h = src->h; + + if (dstrect) { + r_dst.x = dstrect->x; + r_dst.y = dstrect->y; + } else { + r_dst.x = 0; + r_dst.y = 0; + } + + // clip the source rectangle to the source surface + if (srcrect) { + SDL_Rect tmp; + if (SDL_GetRectIntersection(srcrect, &r_src, &tmp) == false) { + return true; + } + + // Shift dstrect, if srcrect origin has changed + r_dst.x += tmp.x - srcrect->x; + r_dst.y += tmp.y - srcrect->y; + + // Update srcrect + r_src = tmp; + } + + // There're no dstrect.w/h parameters. It's the same as srcrect + r_dst.w = r_src.w; + r_dst.h = r_src.h; + + // clip the destination rectangle against the clip rectangle + { + SDL_Rect tmp; + if (SDL_GetRectIntersection(&r_dst, &dst->clip_rect, &tmp) == false) { + return true; + } + + // Shift srcrect, if dstrect has changed + r_src.x += tmp.x - r_dst.x; + r_src.y += tmp.y - r_dst.y; + r_src.w = tmp.w; + r_src.h = tmp.h; + + // Update dstrect + r_dst = tmp; + } + + if (r_dst.w <= 0 || r_dst.h <= 0) { + // No-op. + return true; + } + + // Switch back to a fast blit if we were previously stretching + if (src->map.info.flags & SDL_COPY_NEAREST) { + src->map.info.flags &= ~SDL_COPY_NEAREST; + SDL_InvalidateMap(&src->map); + } + + return SDL_BlitSurfaceUnchecked(src, &r_src, dst, &r_dst); +} + +bool SDL_BlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode) +{ + SDL_Rect *clip_rect; + double src_x0, src_y0, src_x1, src_y1; + double dst_x0, dst_y0, dst_x1, dst_y1; + SDL_Rect final_src, final_dst; + double scaling_w, scaling_h; + int src_w, src_h; + int dst_w, dst_h; + + // Make sure the surfaces aren't locked + if (!SDL_SurfaceValid(src)) { + return SDL_InvalidParamError("src"); + } else if (!SDL_SurfaceValid(dst)) { + return SDL_InvalidParamError("dst"); + } else if ((src->flags & SDL_SURFACE_LOCKED) || (dst->flags & SDL_SURFACE_LOCKED)) { + return SDL_SetError("Surfaces must not be locked during blit"); + } else if (scaleMode != SDL_SCALEMODE_NEAREST && + scaleMode != SDL_SCALEMODE_LINEAR) { + return SDL_InvalidParamError("scaleMode"); + } + + if (!srcrect) { + src_w = src->w; + src_h = src->h; + } else { + src_w = srcrect->w; + src_h = srcrect->h; + } + + if (!dstrect) { + dst_w = dst->w; + dst_h = dst->h; + } else { + dst_w = dstrect->w; + dst_h = dstrect->h; + } + + if (dst_w == src_w && dst_h == src_h) { + // No scaling, defer to regular blit + return SDL_BlitSurface(src, srcrect, dst, dstrect); + } + + scaling_w = (double)dst_w / src_w; + scaling_h = (double)dst_h / src_h; + + if (!dstrect) { + dst_x0 = 0; + dst_y0 = 0; + dst_x1 = dst_w; + dst_y1 = dst_h; + } else { + dst_x0 = dstrect->x; + dst_y0 = dstrect->y; + dst_x1 = dst_x0 + dst_w; + dst_y1 = dst_y0 + dst_h; + } + + if (!srcrect) { + src_x0 = 0; + src_y0 = 0; + src_x1 = src_w; + src_y1 = src_h; + } else { + src_x0 = srcrect->x; + src_y0 = srcrect->y; + src_x1 = src_x0 + src_w; + src_y1 = src_y0 + src_h; + + // Clip source rectangle to the source surface + + if (src_x0 < 0) { + dst_x0 -= src_x0 * scaling_w; + src_x0 = 0; + } + + if (src_x1 > src->w) { + dst_x1 -= (src_x1 - src->w) * scaling_w; + src_x1 = src->w; + } + + if (src_y0 < 0) { + dst_y0 -= src_y0 * scaling_h; + src_y0 = 0; + } + + if (src_y1 > src->h) { + dst_y1 -= (src_y1 - src->h) * scaling_h; + src_y1 = src->h; + } + } + + // Clip destination rectangle to the clip rectangle + clip_rect = &dst->clip_rect; + + // Translate to clip space for easier calculations + dst_x0 -= clip_rect->x; + dst_x1 -= clip_rect->x; + dst_y0 -= clip_rect->y; + dst_y1 -= clip_rect->y; + + if (dst_x0 < 0) { + src_x0 -= dst_x0 / scaling_w; + dst_x0 = 0; + } + + if (dst_x1 > clip_rect->w) { + src_x1 -= (dst_x1 - clip_rect->w) / scaling_w; + dst_x1 = clip_rect->w; + } + + if (dst_y0 < 0) { + src_y0 -= dst_y0 / scaling_h; + dst_y0 = 0; + } + + if (dst_y1 > clip_rect->h) { + src_y1 -= (dst_y1 - clip_rect->h) / scaling_h; + dst_y1 = clip_rect->h; + } + + // Translate back to surface coordinates + dst_x0 += clip_rect->x; + dst_x1 += clip_rect->x; + dst_y0 += clip_rect->y; + dst_y1 += clip_rect->y; + + final_src.x = (int)SDL_round(src_x0); + final_src.y = (int)SDL_round(src_y0); + final_src.w = (int)SDL_round(src_x1 - src_x0); + final_src.h = (int)SDL_round(src_y1 - src_y0); + + final_dst.x = (int)SDL_round(dst_x0); + final_dst.y = (int)SDL_round(dst_y0); + final_dst.w = (int)SDL_round(dst_x1 - dst_x0); + final_dst.h = (int)SDL_round(dst_y1 - dst_y0); + + // Clip again + { + SDL_Rect tmp; + tmp.x = 0; + tmp.y = 0; + tmp.w = src->w; + tmp.h = src->h; + SDL_GetRectIntersection(&tmp, &final_src, &final_src); + } + + // Clip again + SDL_GetRectIntersection(clip_rect, &final_dst, &final_dst); + + if (final_dst.w == 0 || final_dst.h == 0 || + final_src.w < 0 || final_src.h < 0) { + // No-op. + return true; + } + + return SDL_BlitSurfaceUncheckedScaled(src, &final_src, dst, &final_dst, scaleMode); +} + +/** + * This is a semi-private blit function and it performs low-level surface + * scaled blitting only. + */ +bool SDL_BlitSurfaceUncheckedScaled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect, SDL_ScaleMode scaleMode) +{ + static const Uint32 complex_copy_flags = (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_COLORKEY); + + if (srcrect->w > SDL_MAX_UINT16 || srcrect->h > SDL_MAX_UINT16 || + dstrect->w > SDL_MAX_UINT16 || dstrect->h > SDL_MAX_UINT16) { + return SDL_SetError("Size too large for scaling"); + } + + if (!(src->map.info.flags & SDL_COPY_NEAREST)) { + src->map.info.flags |= SDL_COPY_NEAREST; + SDL_InvalidateMap(&src->map); + } + + if (scaleMode == SDL_SCALEMODE_NEAREST) { + if (!(src->map.info.flags & complex_copy_flags) && + src->format == dst->format && + !SDL_ISPIXELFORMAT_INDEXED(src->format) && + SDL_BYTESPERPIXEL(src->format) <= 4) { + return SDL_StretchSurface(src, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST); + } else if (SDL_BITSPERPIXEL(src->format) < 8) { + // Scaling bitmap not yet supported, convert to RGBA for blit + bool result = false; + SDL_Surface *tmp = SDL_ConvertSurface(src, SDL_PIXELFORMAT_ARGB8888); + if (tmp) { + result = SDL_BlitSurfaceUncheckedScaled(tmp, srcrect, dst, dstrect, SDL_SCALEMODE_NEAREST); + SDL_DestroySurface(tmp); + } + return result; + } else { + return SDL_BlitSurfaceUnchecked(src, srcrect, dst, dstrect); + } + } else { + if (!(src->map.info.flags & complex_copy_flags) && + src->format == dst->format && + !SDL_ISPIXELFORMAT_INDEXED(src->format) && + SDL_BYTESPERPIXEL(src->format) == 4 && + src->format != SDL_PIXELFORMAT_ARGB2101010) { + // fast path + return SDL_StretchSurface(src, srcrect, dst, dstrect, SDL_SCALEMODE_LINEAR); + } else if (SDL_BITSPERPIXEL(src->format) < 8) { + // Scaling bitmap not yet supported, convert to RGBA for blit + bool result = false; + SDL_Surface *tmp = SDL_ConvertSurface(src, SDL_PIXELFORMAT_ARGB8888); + if (tmp) { + result = SDL_BlitSurfaceUncheckedScaled(tmp, srcrect, dst, dstrect, scaleMode); + SDL_DestroySurface(tmp); + } + return result; + } else { + // Use intermediate surface(s) + SDL_Surface *tmp1 = NULL; + bool result; + SDL_Rect srcrect2; + int is_complex_copy_flags = (src->map.info.flags & complex_copy_flags); + + Uint8 r, g, b; + Uint8 alpha; + SDL_BlendMode blendMode; + + // Save source infos + SDL_GetSurfaceColorMod(src, &r, &g, &b); + SDL_GetSurfaceAlphaMod(src, &alpha); + SDL_GetSurfaceBlendMode(src, &blendMode); + srcrect2.x = srcrect->x; + srcrect2.y = srcrect->y; + srcrect2.w = srcrect->w; + srcrect2.h = srcrect->h; + + // Change source format if not appropriate for scaling + if (SDL_BYTESPERPIXEL(src->format) != 4 || src->format == SDL_PIXELFORMAT_ARGB2101010) { + SDL_Rect tmprect; + SDL_PixelFormat fmt; + tmprect.x = 0; + tmprect.y = 0; + tmprect.w = src->w; + tmprect.h = src->h; + if (SDL_BYTESPERPIXEL(dst->format) == 4 && dst->format != SDL_PIXELFORMAT_ARGB2101010) { + fmt = dst->format; + } else { + fmt = SDL_PIXELFORMAT_ARGB8888; + } + tmp1 = SDL_CreateSurface(src->w, src->h, fmt); + SDL_BlitSurfaceUnchecked(src, srcrect, tmp1, &tmprect); + + srcrect2.x = 0; + srcrect2.y = 0; + SDL_SetSurfaceColorMod(tmp1, r, g, b); + SDL_SetSurfaceAlphaMod(tmp1, alpha); + SDL_SetSurfaceBlendMode(tmp1, blendMode); + + src = tmp1; + } + + // Intermediate scaling + if (is_complex_copy_flags || src->format != dst->format) { + SDL_Rect tmprect; + SDL_Surface *tmp2 = SDL_CreateSurface(dstrect->w, dstrect->h, src->format); + SDL_StretchSurface(src, &srcrect2, tmp2, NULL, SDL_SCALEMODE_LINEAR); + + SDL_SetSurfaceColorMod(tmp2, r, g, b); + SDL_SetSurfaceAlphaMod(tmp2, alpha); + SDL_SetSurfaceBlendMode(tmp2, blendMode); + + tmprect.x = 0; + tmprect.y = 0; + tmprect.w = dstrect->w; + tmprect.h = dstrect->h; + result = SDL_BlitSurfaceUnchecked(tmp2, &tmprect, dst, dstrect); + SDL_DestroySurface(tmp2); + } else { + result = SDL_StretchSurface(src, &srcrect2, dst, dstrect, SDL_SCALEMODE_LINEAR); + } + + SDL_DestroySurface(tmp1); + return result; + } + } +} + +bool SDL_BlitSurfaceTiled(SDL_Surface *src, const SDL_Rect *srcrect, SDL_Surface *dst, const SDL_Rect *dstrect) +{ + SDL_Rect r_src, r_dst; + + // Make sure the surfaces aren't locked + if (!SDL_SurfaceValid(src)) { + return SDL_InvalidParamError("src"); + } else if (!SDL_SurfaceValid(dst)) { + return SDL_InvalidParamError("dst"); + } else if ((src->flags & SDL_SURFACE_LOCKED) || (dst->flags & SDL_SURFACE_LOCKED)) { + return SDL_SetError("Surfaces must not be locked during blit"); + } + + // Full src surface + r_src.x = 0; + r_src.y = 0; + r_src.w = src->w; + r_src.h = src->h; + + if (dstrect) { + r_dst.x = dstrect->x; + r_dst.y = dstrect->y; + r_dst.w = dstrect->w; + r_dst.h = dstrect->h; + } else { + r_dst.x = 0; + r_dst.y = 0; + r_dst.w = dst->w; + r_dst.h = dst->h; + } + + // clip the source rectangle to the source surface + if (srcrect) { + if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == false) { + return true; + } + + // For tiling we don't adjust the destination rectangle + } + + // clip the destination rectangle against the clip rectangle + { + if (SDL_GetRectIntersection(&r_dst, &dst->clip_rect, &r_dst) == false) { + return true; + } + + // For tiling we don't adjust the source rectangle + } + + // Switch back to a fast blit if we were previously stretching + if (src->map.info.flags & SDL_COPY_NEAREST) { + src->map.info.flags &= ~SDL_COPY_NEAREST; + SDL_InvalidateMap(&src->map); + } + + int rows = r_dst.h / r_src.h; + int cols = r_dst.w / r_src.w; + int remaining_w = r_dst.w % r_src.w; + int remaining_h = r_dst.h % r_src.h; + SDL_Rect curr_src, curr_dst; + + SDL_copyp(&curr_src, &r_src); + curr_dst.y = r_dst.y; + curr_dst.w = r_src.w; + curr_dst.h = r_src.h; + for (int y = 0; y < rows; ++y) { + curr_dst.x = r_dst.x; + for (int x = 0; x < cols; ++x) { + if (!SDL_BlitSurfaceUnchecked(src, &curr_src, dst, &curr_dst)) { + return false; + } + curr_dst.x += curr_dst.w; + } + if (remaining_w) { + curr_src.w = remaining_w; + curr_dst.w = remaining_w; + if (!SDL_BlitSurfaceUnchecked(src, &curr_src, dst, &curr_dst)) { + return false; + } + curr_src.w = r_src.w; + curr_dst.w = r_src.w; + } + curr_dst.y += curr_dst.h; + } + if (remaining_h) { + curr_src.h = remaining_h; + curr_dst.h = remaining_h; + curr_dst.x = r_dst.x; + for (int x = 0; x < cols; ++x) { + if (!SDL_BlitSurfaceUnchecked(src, &curr_src, dst, &curr_dst)) { + return false; + } + curr_dst.x += curr_dst.w; + } + if (remaining_w) { + curr_src.w = remaining_w; + curr_dst.w = remaining_w; + if (!SDL_BlitSurfaceUnchecked(src, &curr_src, dst, &curr_dst)) { + return false; + } + } + } + return true; +} + +bool SDL_BlitSurfaceTiledWithScale(SDL_Surface *src, const SDL_Rect *srcrect, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect) +{ + SDL_Rect r_src, r_dst; + + // Make sure the surfaces aren't locked + if (!SDL_SurfaceValid(src)) { + return SDL_InvalidParamError("src"); + } else if (!SDL_SurfaceValid(dst)) { + return SDL_InvalidParamError("dst"); + } else if ((src->flags & SDL_SURFACE_LOCKED) || (dst->flags & SDL_SURFACE_LOCKED)) { + return SDL_SetError("Surfaces must not be locked during blit"); + } + + if (scale <= 0.0f) { + return SDL_InvalidParamError("scale"); + } + + // Full src surface + r_src.x = 0; + r_src.y = 0; + r_src.w = src->w; + r_src.h = src->h; + + if (dstrect) { + r_dst.x = dstrect->x; + r_dst.y = dstrect->y; + r_dst.w = dstrect->w; + r_dst.h = dstrect->h; + } else { + r_dst.x = 0; + r_dst.y = 0; + r_dst.w = dst->w; + r_dst.h = dst->h; + } + + // clip the source rectangle to the source surface + if (srcrect) { + if (SDL_GetRectIntersection(srcrect, &r_src, &r_src) == false) { + return true; + } + + // For tiling we don't adjust the destination rectangle + } + + // clip the destination rectangle against the clip rectangle + { + if (SDL_GetRectIntersection(&r_dst, &dst->clip_rect, &r_dst) == false) { + return true; + } + + // For tiling we don't adjust the source rectangle + } + + // Switch back to a fast blit if we were previously stretching + if (src->map.info.flags & SDL_COPY_NEAREST) { + src->map.info.flags &= ~SDL_COPY_NEAREST; + SDL_InvalidateMap(&src->map); + } + + int tile_width = (int)(r_src.w * scale); + int tile_height = (int)(r_src.h * scale); + int rows = r_dst.h / tile_height; + int cols = r_dst.w / tile_width; + int remaining_dst_w = (r_dst.w - cols * tile_width); + int remaining_dst_h = (r_dst.h - rows * tile_height); + int remaining_src_w = (int)(remaining_dst_w / scale); + int remaining_src_h = (int)(remaining_dst_h / scale); + SDL_Rect curr_src, curr_dst; + + SDL_copyp(&curr_src, &r_src); + curr_dst.y = r_dst.y; + curr_dst.w = tile_width; + curr_dst.h = tile_height; + for (int y = 0; y < rows; ++y) { + curr_dst.x = r_dst.x; + for (int x = 0; x < cols; ++x) { + if (!SDL_BlitSurfaceUncheckedScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + curr_dst.x += curr_dst.w; + } + if (remaining_dst_w > 0) { + curr_src.w = remaining_src_w; + curr_dst.w = remaining_dst_w; + if (!SDL_BlitSurfaceUncheckedScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + curr_src.w = r_src.w; + curr_dst.w = tile_width; + } + curr_dst.y += curr_dst.h; + } + if (remaining_dst_h > 0) { + curr_src.h = remaining_src_h; + curr_dst.h = remaining_dst_h; + curr_dst.x = r_dst.x; + for (int x = 0; x < cols; ++x) { + if (!SDL_BlitSurfaceUncheckedScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + curr_dst.x += curr_dst.w; + } + if (remaining_dst_w > 0) { + curr_src.w = remaining_src_w; + curr_dst.w = remaining_dst_w; + if (!SDL_BlitSurfaceUncheckedScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + } + } + return true; +} + +bool SDL_BlitSurface9Grid(SDL_Surface *src, const SDL_Rect *srcrect, int left_width, int right_width, int top_height, int bottom_height, float scale, SDL_ScaleMode scaleMode, SDL_Surface *dst, const SDL_Rect *dstrect) +{ + SDL_Rect full_src, full_dst; + SDL_Rect curr_src, curr_dst; + int dst_left_width; + int dst_right_width; + int dst_top_height; + int dst_bottom_height; + + // Make sure the surfaces aren't locked + if (!SDL_SurfaceValid(src)) { + return SDL_InvalidParamError("src"); + } else if (!SDL_SurfaceValid(dst)) { + return SDL_InvalidParamError("dst"); + } + + if (!srcrect) { + full_src.x = 0; + full_src.y = 0; + full_src.w = src->w; + full_src.h = src->h; + srcrect = &full_src; + } + + if (!dstrect) { + full_dst.x = 0; + full_dst.y = 0; + full_dst.w = dst->w; + full_dst.h = dst->h; + dstrect = &full_dst; + } + + if (scale <= 0.0f || scale == 1.0f) { + dst_left_width = left_width; + dst_right_width = right_width; + dst_top_height = top_height; + dst_bottom_height = bottom_height; + } else { + dst_left_width = (int)SDL_roundf(left_width * scale); + dst_right_width = (int)SDL_roundf(right_width * scale); + dst_top_height = (int)SDL_roundf(top_height * scale); + dst_bottom_height = (int)SDL_roundf(bottom_height * scale); + } + + // Upper-left corner + curr_src.x = srcrect->x; + curr_src.y = srcrect->y; + curr_src.w = left_width; + curr_src.h = top_height; + curr_dst.x = dstrect->x; + curr_dst.y = dstrect->y; + curr_dst.w = dst_left_width; + curr_dst.h = dst_top_height; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Upper-right corner + curr_src.x = srcrect->x + srcrect->w - right_width; + curr_src.w = right_width; + curr_dst.x = dstrect->x + dstrect->w - dst_right_width; + curr_dst.w = dst_right_width; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Lower-right corner + curr_src.y = srcrect->y + srcrect->h - bottom_height; + curr_dst.y = dstrect->y + dstrect->h - dst_bottom_height; + curr_dst.h = dst_bottom_height; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Lower-left corner + curr_src.x = srcrect->x; + curr_src.w = left_width; + curr_dst.x = dstrect->x; + curr_dst.w = dst_left_width; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Left + curr_src.y = srcrect->y + top_height; + curr_src.h = srcrect->h - top_height - bottom_height; + curr_dst.y = dstrect->y + dst_top_height; + curr_dst.h = dstrect->h - dst_top_height - dst_bottom_height; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Right + curr_src.x = srcrect->x + srcrect->w - right_width; + curr_src.w = right_width; + curr_dst.x = dstrect->x + dstrect->w - dst_right_width; + curr_dst.w = dst_right_width; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Top + curr_src.x = srcrect->x + left_width; + curr_src.y = srcrect->y; + curr_src.w = srcrect->w - left_width - right_width; + curr_src.h = top_height; + curr_dst.x = dstrect->x + dst_left_width; + curr_dst.y = dstrect->y; + curr_dst.w = dstrect->w - dst_left_width - dst_right_width; + curr_dst.h = dst_top_height; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Bottom + curr_src.y = srcrect->y + srcrect->h - bottom_height; + curr_dst.y = dstrect->y + dstrect->h - dst_bottom_height; + curr_dst.h = dst_bottom_height; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + // Center + curr_src.x = srcrect->x + left_width; + curr_src.y = srcrect->y + top_height; + curr_src.w = srcrect->w - left_width - right_width; + curr_src.h = srcrect->h - top_height - bottom_height; + curr_dst.x = dstrect->x + dst_left_width; + curr_dst.y = dstrect->y + dst_top_height; + curr_dst.w = dstrect->w - dst_left_width - dst_right_width; + curr_dst.h = dstrect->h - dst_top_height - dst_bottom_height; + if (!SDL_BlitSurfaceScaled(src, &curr_src, dst, &curr_dst, scaleMode)) { + return false; + } + + return true; +} + +/* + * Lock a surface to directly access the pixels + */ +bool SDL_LockSurface(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + if (!surface->locked) { +#ifdef SDL_HAVE_RLE + // Perform the lock + if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) { + SDL_UnRLESurface(surface, true); + surface->internal_flags |= SDL_INTERNAL_SURFACE_RLEACCEL; // save accel'd state + } +#endif + } + + // Increment the surface lock count, for recursive locks + ++surface->locked; + surface->flags |= SDL_SURFACE_LOCKED; + + // Ready to go.. + return true; +} + +/* + * Unlock a previously locked surface + */ +void SDL_UnlockSurface(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return; + } + + // Only perform an unlock if we are locked + if (!surface->locked || (--surface->locked > 0)) { + return; + } + +#ifdef SDL_HAVE_RLE + // Update RLE encoded surface with new data + if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) { + surface->internal_flags &= ~SDL_INTERNAL_SURFACE_RLEACCEL; // stop lying + SDL_RLESurface(surface); + } +#endif + + surface->flags &= ~SDL_SURFACE_LOCKED; +} + +static bool SDL_FlipSurfaceHorizontal(SDL_Surface *surface) +{ + bool isstack; + Uint8 *row, *a, *b, *tmp; + int i, j, bpp; + + if (SDL_BITSPERPIXEL(surface->format) < 8) { + // We could implement this if needed, but we'd have to flip sets of bits within a byte + return SDL_Unsupported(); + } + + if (surface->h <= 0) { + return true; + } + + if (surface->w <= 1) { + return true; + } + + bpp = SDL_BYTESPERPIXEL(surface->format); + row = (Uint8 *)surface->pixels; + tmp = SDL_small_alloc(Uint8, surface->pitch, &isstack); + if (!tmp) { + return false; + } + for (i = surface->h; i--; ) { + a = row; + b = a + (surface->w - 1) * bpp; + for (j = surface->w / 2; j--; ) { + SDL_memcpy(tmp, a, bpp); + SDL_memcpy(a, b, bpp); + SDL_memcpy(b, tmp, bpp); + a += bpp; + b -= bpp; + } + row += surface->pitch; + } + SDL_small_free(tmp, isstack); + return true; +} + +static bool SDL_FlipSurfaceVertical(SDL_Surface *surface) +{ + bool isstack; + Uint8 *a, *b, *tmp; + int i; + + if (surface->h <= 1) { + return true; + } + + a = (Uint8 *)surface->pixels; + b = a + (surface->h - 1) * surface->pitch; + tmp = SDL_small_alloc(Uint8, surface->pitch, &isstack); + if (!tmp) { + return false; + } + for (i = surface->h / 2; i--; ) { + SDL_memcpy(tmp, a, surface->pitch); + SDL_memcpy(a, b, surface->pitch); + SDL_memcpy(b, tmp, surface->pitch); + a += surface->pitch; + b -= surface->pitch; + } + SDL_small_free(tmp, isstack); + return true; +} + +bool SDL_FlipSurface(SDL_Surface *surface, SDL_FlipMode flip) +{ + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + if (!surface->pixels) { + return true; + } + + switch (flip) { + case SDL_FLIP_HORIZONTAL: + return SDL_FlipSurfaceHorizontal(surface); + case SDL_FLIP_VERTICAL: + return SDL_FlipSurfaceVertical(surface); + default: + return SDL_InvalidParamError("flip"); + } +} + +SDL_Surface *SDL_ConvertSurfaceAndColorspace(SDL_Surface *surface, SDL_PixelFormat format, SDL_Palette *palette, SDL_Colorspace colorspace, SDL_PropertiesID props) +{ + SDL_Palette *temp_palette = NULL; + SDL_Surface *convert = NULL; + SDL_Colorspace src_colorspace; + SDL_PropertiesID src_properties; + Uint32 copy_flags; + SDL_Color copy_color; + SDL_Rect bounds; + bool result; + bool palette_ck_transform = false; + Uint8 palette_ck_value = 0; + Uint8 *palette_saved_alpha = NULL; + int palette_saved_alpha_ncolors = 0; + + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + goto error; + } + + if (format == SDL_PIXELFORMAT_UNKNOWN) { + SDL_InvalidParamError("format"); + goto error; + } + + // Check for empty destination palette! (results in empty image) + if (palette) { + int i; + for (i = 0; i < palette->ncolors; ++i) { + if ((palette->colors[i].r != 0xFF) || (palette->colors[i].g != 0xFF) || (palette->colors[i].b != 0xFF)) { + break; + } + } + if (i == palette->ncolors) { + SDL_SetError("Empty destination palette"); + goto error; + } + } else if (SDL_ISPIXELFORMAT_INDEXED(format)) { + // Create a dither palette for conversion + temp_palette = SDL_CreatePalette(1 << SDL_BITSPERPIXEL(format)); + if (temp_palette) { + SDL_DitherPalette(temp_palette); + palette = temp_palette; + } + } + + src_colorspace = surface->colorspace; + src_properties = surface->props; + + // Create a new surface with the desired format + convert = SDL_CreateSurface(surface->w, surface->h, format); + if (!convert) { + goto error; + } + if (SDL_ISPIXELFORMAT_INDEXED(format)) { + SDL_SetSurfacePalette(convert, palette); + } + + if (colorspace == SDL_COLORSPACE_UNKNOWN) { + colorspace = src_colorspace; + } + SDL_SetSurfaceColorspace(convert, colorspace); + + if (SDL_ISPIXELFORMAT_FOURCC(format) || SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + if (!SDL_ConvertPixelsAndColorspace(surface->w, surface->h, surface->format, src_colorspace, src_properties, surface->pixels, surface->pitch, convert->format, colorspace, props, convert->pixels, convert->pitch)) { + goto error; + } + + // Save the original copy flags + copy_flags = surface->map.info.flags; + + goto end; + } + + // Save the original copy flags + copy_flags = surface->map.info.flags; + copy_color.r = surface->map.info.r; + copy_color.g = surface->map.info.g; + copy_color.b = surface->map.info.b; + copy_color.a = surface->map.info.a; + surface->map.info.r = 0xFF; + surface->map.info.g = 0xFF; + surface->map.info.b = 0xFF; + surface->map.info.a = 0xFF; + surface->map.info.flags = (copy_flags & (SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY)); + SDL_InvalidateMap(&surface->map); + + // Copy over the image data + bounds.x = 0; + bounds.y = 0; + bounds.w = surface->w; + bounds.h = surface->h; + + /* Source surface has a palette with no real alpha (0 or OPAQUE). + * Destination format has alpha. + * -> set alpha channel to be opaque */ + if (surface->palette && SDL_ISPIXELFORMAT_ALPHA(format)) { + bool set_opaque = false; + + bool is_opaque, has_alpha_channel; + SDL_DetectPalette(surface->palette, &is_opaque, &has_alpha_channel); + + if (is_opaque) { + if (!has_alpha_channel) { + set_opaque = true; + } + } + + // Set opaque and backup palette alpha values + if (set_opaque) { + int i; + palette_saved_alpha_ncolors = surface->palette->ncolors; + if (palette_saved_alpha_ncolors > 0) { + palette_saved_alpha = SDL_stack_alloc(Uint8, palette_saved_alpha_ncolors); + for (i = 0; i < palette_saved_alpha_ncolors; i++) { + palette_saved_alpha[i] = surface->palette->colors[i].a; + surface->palette->colors[i].a = SDL_ALPHA_OPAQUE; + } + } + } + } + + // Transform colorkey to alpha. for cases where source palette has duplicate values, and colorkey is one of them + if (copy_flags & SDL_COPY_COLORKEY) { + if (surface->palette && !palette) { + palette_ck_transform = true; + palette_ck_value = surface->palette->colors[surface->map.info.colorkey].a; + surface->palette->colors[surface->map.info.colorkey].a = SDL_ALPHA_TRANSPARENT; + } + } + + result = SDL_BlitSurfaceUnchecked(surface, &bounds, convert, &bounds); + + // Restore colorkey alpha value + if (palette_ck_transform) { + surface->palette->colors[surface->map.info.colorkey].a = palette_ck_value; + } + + // Restore palette alpha values + if (palette_saved_alpha) { + int i; + for (i = 0; i < palette_saved_alpha_ncolors; i++) { + surface->palette->colors[i].a = palette_saved_alpha[i]; + } + SDL_stack_free(palette_saved_alpha); + } + + // Clean up the original surface, and update converted surface + convert->map.info.r = copy_color.r; + convert->map.info.g = copy_color.g; + convert->map.info.b = copy_color.b; + convert->map.info.a = copy_color.a; + convert->map.info.flags = + (copy_flags & + ~(SDL_COPY_COLORKEY | SDL_COPY_BLEND | SDL_COPY_RLE_DESIRED | SDL_COPY_RLE_COLORKEY | + SDL_COPY_RLE_ALPHAKEY)); + surface->map.info.r = copy_color.r; + surface->map.info.g = copy_color.g; + surface->map.info.b = copy_color.b; + surface->map.info.a = copy_color.a; + surface->map.info.flags = copy_flags; + SDL_InvalidateMap(&surface->map); + + // SDL_BlitSurfaceUnchecked failed, and so the conversion + if (!result) { + goto error; + } + + if (copy_flags & SDL_COPY_COLORKEY) { + bool set_colorkey_by_color = false; + bool convert_colorkey = true; + + if (surface->palette) { + if (palette && + surface->palette->ncolors <= palette->ncolors && + (SDL_memcmp(surface->palette->colors, palette->colors, + surface->palette->ncolors * sizeof(SDL_Color)) == 0)) { + // The palette is identical, just set the same colorkey + SDL_SetSurfaceColorKey(convert, true, surface->map.info.colorkey); + } else if (!palette) { + if (SDL_ISPIXELFORMAT_ALPHA(format)) { + // No need to add the colorkey, transparency is in the alpha channel + } else { + // Only set the colorkey information + set_colorkey_by_color = true; + convert_colorkey = false; + } + } else { + set_colorkey_by_color = true; + } + } else { + set_colorkey_by_color = true; + } + + if (set_colorkey_by_color) { + SDL_Surface *tmp; + SDL_Surface *tmp2; + int converted_colorkey = 0; + + // Create a dummy surface to get the colorkey converted + tmp = SDL_CreateSurface(1, 1, surface->format); + if (!tmp) { + goto error; + } + + // Share the palette, if any + if (surface->palette) { + SDL_SetSurfacePalette(tmp, surface->palette); + } + + SDL_FillSurfaceRect(tmp, NULL, surface->map.info.colorkey); + + tmp->map.info.flags &= ~SDL_COPY_COLORKEY; + + // Conversion of the colorkey + tmp2 = SDL_ConvertSurfaceAndColorspace(tmp, format, palette, colorspace, props); + if (!tmp2) { + SDL_DestroySurface(tmp); + goto error; + } + + // Get the converted colorkey + SDL_memcpy(&converted_colorkey, tmp2->pixels, tmp2->fmt->bytes_per_pixel); + + SDL_DestroySurface(tmp); + SDL_DestroySurface(tmp2); + + // Set the converted colorkey on the new surface + SDL_SetSurfaceColorKey(convert, true, converted_colorkey); + + // This is needed when converting for 3D texture upload + if (convert_colorkey) { + SDL_ConvertColorkeyToAlpha(convert, true); + } + } + } + +end: + if (temp_palette) { + SDL_DestroyPalette(temp_palette); + } + + SDL_SetSurfaceClipRect(convert, &surface->clip_rect); + + /* Enable alpha blending by default if the new surface has an + * alpha channel or alpha modulation */ + if (SDL_ISPIXELFORMAT_ALPHA(format) || + (copy_flags & SDL_COPY_MODULATE_ALPHA)) { + SDL_SetSurfaceBlendMode(convert, SDL_BLENDMODE_BLEND); + } + if (copy_flags & SDL_COPY_RLE_DESIRED) { + SDL_SetSurfaceRLE(convert, true); + } + + // Copy alternate images + for (int i = 0; i < surface->num_images; ++i) { + if (!SDL_AddSurfaceAlternateImage(convert, surface->images[i])) { + goto error; + } + } + + // We're ready to go! + return convert; + +error: + if (temp_palette) { + SDL_DestroyPalette(temp_palette); + } + if (convert) { + SDL_DestroySurface(convert); + } + return NULL; +} + +SDL_Surface *SDL_DuplicateSurface(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + return NULL; + } + + return SDL_ConvertSurfaceAndColorspace(surface, surface->format, surface->palette, surface->colorspace, surface->props); +} + +SDL_Surface *SDL_ScaleSurface(SDL_Surface *surface, int width, int height, SDL_ScaleMode scaleMode) +{ + SDL_Surface *convert = NULL; + Uint32 copy_flags; + SDL_Color copy_color; + bool rc; + + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + goto error; + } + + if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + // We can't directly scale a YUV surface (yet!) + SDL_Surface *tmp = SDL_CreateSurface(surface->w, surface->h, SDL_PIXELFORMAT_ARGB8888); + if (!tmp) { + return NULL; + } + + SDL_Surface *scaled = SDL_ScaleSurface(tmp, width, height, scaleMode); + SDL_DestroySurface(tmp); + if (!scaled) { + return NULL; + } + tmp = scaled; + + SDL_Surface *result = SDL_ConvertSurfaceAndColorspace(tmp, surface->format, NULL, surface->colorspace, surface->props); + SDL_DestroySurface(tmp); + return result; + } + + // Create a new surface with the desired size + convert = SDL_CreateSurface(width, height, surface->format); + if (!convert) { + goto error; + } + SDL_SetSurfacePalette(convert, surface->palette); + SDL_SetSurfaceColorspace(convert, surface->colorspace); + + // Save the original copy flags + copy_flags = surface->map.info.flags; + copy_color.r = surface->map.info.r; + copy_color.g = surface->map.info.g; + copy_color.b = surface->map.info.b; + copy_color.a = surface->map.info.a; + surface->map.info.r = 0xFF; + surface->map.info.g = 0xFF; + surface->map.info.b = 0xFF; + surface->map.info.a = 0xFF; + surface->map.info.flags = (copy_flags & (SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY)); + SDL_InvalidateMap(&surface->map); + + rc = SDL_BlitSurfaceScaled(surface, NULL, convert, NULL, scaleMode); + + // Clean up the original surface, and update converted surface + convert->map.info.r = copy_color.r; + convert->map.info.g = copy_color.g; + convert->map.info.b = copy_color.b; + convert->map.info.a = copy_color.a; + convert->map.info.flags = (copy_flags & ~(SDL_COPY_RLE_COLORKEY | SDL_COPY_RLE_ALPHAKEY)); + surface->map.info.r = copy_color.r; + surface->map.info.g = copy_color.g; + surface->map.info.b = copy_color.b; + surface->map.info.a = copy_color.a; + surface->map.info.flags = copy_flags; + SDL_InvalidateMap(&surface->map); + + // SDL_BlitSurfaceScaled failed, and so the conversion + if (!rc) { + goto error; + } + + // We're ready to go! + return convert; + +error: + if (convert) { + SDL_DestroySurface(convert); + } + return NULL; +} + +SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, SDL_PixelFormat format) +{ + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + return NULL; + } + + return SDL_ConvertSurfaceAndColorspace(surface, format, NULL, SDL_GetDefaultColorspaceForFormat(format), surface->props); +} + +SDL_Surface *SDL_DuplicatePixels(int width, int height, SDL_PixelFormat format, SDL_Colorspace colorspace, void *pixels, int pitch) +{ + SDL_Surface *surface = SDL_CreateSurface(width, height, format); + if (surface) { + int length = width * SDL_BYTESPERPIXEL(format); + Uint8 *src = (Uint8 *)pixels; + Uint8 *dst = (Uint8 *)surface->pixels; + int rows = height; + while (rows--) { + SDL_memcpy(dst, src, length); + dst += surface->pitch; + src += pitch; + } + + SDL_SetSurfaceColorspace(surface, colorspace); + } + return surface; +} + +bool SDL_ConvertPixelsAndColorspace(int width, int height, + SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, + SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch) +{ + SDL_Surface src_surface; + SDL_Surface dst_surface; + SDL_Rect rect; + void *nonconst_src = (void *)src; + bool result; + + if (!src) { + return SDL_InvalidParamError("src"); + } + if (!src_pitch) { + return SDL_InvalidParamError("src_pitch"); + } + if (!dst) { + return SDL_InvalidParamError("dst"); + } + if (!dst_pitch) { + return SDL_InvalidParamError("dst_pitch"); + } + + if (src_colorspace == SDL_COLORSPACE_UNKNOWN) { + src_colorspace = SDL_GetDefaultColorspaceForFormat(src_format); + } + if (dst_colorspace == SDL_COLORSPACE_UNKNOWN) { + dst_colorspace = SDL_GetDefaultColorspaceForFormat(dst_format); + } + + if (src_format == SDL_PIXELFORMAT_MJPG) { + return SDL_ConvertPixels_STB(width, height, src_format, src_colorspace, src_properties, src, src_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); + } + +#ifdef SDL_HAVE_YUV + if (SDL_ISPIXELFORMAT_FOURCC(src_format) && SDL_ISPIXELFORMAT_FOURCC(dst_format)) { + return SDL_ConvertPixels_YUV_to_YUV(width, height, src_format, src_colorspace, src_properties, src, src_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); + } else if (SDL_ISPIXELFORMAT_FOURCC(src_format)) { + return SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src_colorspace, src_properties, src, src_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); + } else if (SDL_ISPIXELFORMAT_FOURCC(dst_format)) { + return SDL_ConvertPixels_RGB_to_YUV(width, height, src_format, src_colorspace, src_properties, src, src_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); + } +#else + if (SDL_ISPIXELFORMAT_FOURCC(src_format) || SDL_ISPIXELFORMAT_FOURCC(dst_format)) { + return SDL_SetError("SDL not built with YUV support"); + } +#endif + + // Fast path for same format copy + if (src_format == dst_format && src_colorspace == dst_colorspace) { + if (src_pitch == dst_pitch) { + SDL_memcpy(dst, src, height * src_pitch); + } else { + int i; + const int bpp = SDL_BYTESPERPIXEL(src_format); + width *= bpp; + for (i = height; i--;) { + SDL_memcpy(dst, src, width); + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } + } + return true; + } + + if (!SDL_InitializeSurface(&src_surface, width, height, src_format, src_colorspace, src_properties, nonconst_src, src_pitch, true)) { + return false; + } + SDL_SetSurfaceBlendMode(&src_surface, SDL_BLENDMODE_NONE); + + if (!SDL_InitializeSurface(&dst_surface, width, height, dst_format, dst_colorspace, dst_properties, dst, dst_pitch, true)) { + return false; + } + + // Set up the rect and go! + rect.x = 0; + rect.y = 0; + rect.w = width; + rect.h = height; + result = SDL_BlitSurfaceUnchecked(&src_surface, &rect, &dst_surface, &rect); + + SDL_DestroySurface(&src_surface); + SDL_DestroySurface(&dst_surface); + + return result; +} + +bool SDL_ConvertPixels(int width, int height, SDL_PixelFormat src_format, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch) +{ + return SDL_ConvertPixelsAndColorspace(width, height, + src_format, SDL_COLORSPACE_UNKNOWN, 0, src, src_pitch, + dst_format, SDL_COLORSPACE_UNKNOWN, 0, dst, dst_pitch); +} + +/* + * Premultiply the alpha on a block of pixels + * + * Here are some ideas for optimization: + * https://github.com/Wizermil/premultiply_alpha/tree/master/premultiply_alpha + * https://developer.arm.com/documentation/101964/0201/Pre-multiplied-alpha-channel-data + */ + +static void SDL_PremultiplyAlpha_AXYZ8888(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int c; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (height--) { + const Uint32 *src_px = (const Uint32 *)src; + Uint32 *dst_px = (Uint32 *)dst; + for (c = width; c; --c) { + // Component bytes extraction. + srcpixel = *src_px++; + RGBA_FROM_ARGB8888(srcpixel, srcR, srcG, srcB, srcA); + + // Alpha pre-multiplication of each component. + dstA = srcA; + dstR = (srcA * srcR) / 255; + dstG = (srcA * srcG) / 255; + dstB = (srcA * srcB) / 255; + + // ARGB8888 pixel recomposition. + ARGB8888_FROM_RGBA(dstpixel, dstR, dstG, dstB, dstA); + *dst_px++ = dstpixel; + } + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } +} + +static void SDL_PremultiplyAlpha_XYZA8888(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int c; + Uint32 srcpixel; + Uint32 srcR, srcG, srcB, srcA; + Uint32 dstpixel; + Uint32 dstR, dstG, dstB, dstA; + + while (height--) { + const Uint32 *src_px = (const Uint32 *)src; + Uint32 *dst_px = (Uint32 *)dst; + for (c = width; c; --c) { + // Component bytes extraction. + srcpixel = *src_px++; + RGBA_FROM_RGBA8888(srcpixel, srcR, srcG, srcB, srcA); + + // Alpha pre-multiplication of each component. + dstA = srcA; + dstR = (srcA * srcR) / 255; + dstG = (srcA * srcG) / 255; + dstB = (srcA * srcB) / 255; + + // RGBA8888 pixel recomposition. + RGBA8888_FROM_RGBA(dstpixel, dstR, dstG, dstB, dstA); + *dst_px++ = dstpixel; + } + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } +} + +static void SDL_PremultiplyAlpha_AXYZ128(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int c; + float flR, flG, flB, flA; + + while (height--) { + const float *src_px = (const float *)src; + float *dst_px = (float *)dst; + for (c = width; c; --c) { + flA = *src_px++; + flR = *src_px++; + flG = *src_px++; + flB = *src_px++; + + // Alpha pre-multiplication of each component. + flR *= flA; + flG *= flA; + flB *= flA; + + *dst_px++ = flA; + *dst_px++ = flR; + *dst_px++ = flG; + *dst_px++ = flB; + } + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } +} + +static bool SDL_PremultiplyAlphaPixelsAndColorspace(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch, bool linear) +{ + SDL_Surface *convert = NULL; + void *final_dst = dst; + int final_dst_pitch = dst_pitch; + SDL_PixelFormat format; + SDL_Colorspace colorspace; + bool result = false; + + if (!src) { + return SDL_InvalidParamError("src"); + } + if (!src_pitch) { + return SDL_InvalidParamError("src_pitch"); + } + if (!dst) { + return SDL_InvalidParamError("dst"); + } + if (!dst_pitch) { + return SDL_InvalidParamError("dst_pitch"); + } + + // Use a high precision format if we're converting to linear colorspace or using high precision pixel formats + if (linear || + SDL_ISPIXELFORMAT_10BIT(src_format) || SDL_BITSPERPIXEL(src_format) > 32 || + SDL_ISPIXELFORMAT_10BIT(dst_format) || SDL_BITSPERPIXEL(dst_format) > 32) { + if (src_format == SDL_PIXELFORMAT_ARGB128_FLOAT || + src_format == SDL_PIXELFORMAT_ABGR128_FLOAT) { + format = src_format; + } else { + format = SDL_PIXELFORMAT_ARGB128_FLOAT; + } + } else { + if (src_format == SDL_PIXELFORMAT_ARGB8888 || + src_format == SDL_PIXELFORMAT_ABGR8888 || + src_format == SDL_PIXELFORMAT_RGBA8888 || + src_format == SDL_PIXELFORMAT_BGRA8888) { + format = src_format; + } else { + format = SDL_PIXELFORMAT_ARGB8888; + } + } + if (linear) { + colorspace = SDL_COLORSPACE_SRGB_LINEAR; + } else { + colorspace = SDL_COLORSPACE_SRGB; + } + + if (src_format != format || src_colorspace != colorspace) { + convert = SDL_CreateSurface(width, height, format); + if (!convert) { + goto done; + } + if (!SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, format, colorspace, 0, convert->pixels, convert->pitch)) { + goto done; + } + + src = convert->pixels; + src_pitch = convert->pitch; + dst = convert->pixels; + dst_pitch = convert->pitch; + + } else if (dst_format != format || dst_colorspace != colorspace) { + convert = SDL_CreateSurface(width, height, format); + if (!convert) { + goto done; + } + dst = convert->pixels; + dst_pitch = convert->pitch; + } + + switch (format) { + case SDL_PIXELFORMAT_ARGB8888: + case SDL_PIXELFORMAT_ABGR8888: + SDL_PremultiplyAlpha_AXYZ8888(width, height, src, src_pitch, dst, dst_pitch); + break; + case SDL_PIXELFORMAT_RGBA8888: + case SDL_PIXELFORMAT_BGRA8888: + SDL_PremultiplyAlpha_XYZA8888(width, height, src, src_pitch, dst, dst_pitch); + break; + case SDL_PIXELFORMAT_ARGB128_FLOAT: + case SDL_PIXELFORMAT_ABGR128_FLOAT: + SDL_PremultiplyAlpha_AXYZ128(width, height, src, src_pitch, dst, dst_pitch); + break; + default: + SDL_SetError("Unexpected internal pixel format"); + goto done; + } + + if (dst != final_dst) { + if (!SDL_ConvertPixelsAndColorspace(width, height, format, colorspace, 0, convert->pixels, convert->pitch, dst_format, dst_colorspace, dst_properties, final_dst, final_dst_pitch)) { + goto done; + } + } + result = true; + +done: + if (convert) { + SDL_DestroySurface(convert); + } + return result; +} + +bool SDL_PremultiplyAlpha(int width, int height, + SDL_PixelFormat src_format, const void *src, int src_pitch, + SDL_PixelFormat dst_format, void *dst, int dst_pitch, bool linear) +{ + SDL_Colorspace src_colorspace = SDL_GetDefaultColorspaceForFormat(src_format); + SDL_Colorspace dst_colorspace = SDL_GetDefaultColorspaceForFormat(dst_format); + + return SDL_PremultiplyAlphaPixelsAndColorspace(width, height, src_format, src_colorspace, 0, src, src_pitch, dst_format, dst_colorspace, 0, dst, dst_pitch, linear); +} + +bool SDL_PremultiplySurfaceAlpha(SDL_Surface *surface, bool linear) +{ + SDL_Colorspace colorspace; + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + colorspace = surface->colorspace; + + return SDL_PremultiplyAlphaPixelsAndColorspace(surface->w, surface->h, surface->format, colorspace, surface->props, surface->pixels, surface->pitch, surface->format, colorspace, surface->props, surface->pixels, surface->pitch, linear); +} + +bool SDL_ClearSurface(SDL_Surface *surface, float r, float g, float b, float a) +{ + SDL_Rect clip_rect; + bool result = false; + + if (!SDL_SurfaceValid(surface)) { + return SDL_InvalidParamError("surface"); + } + + SDL_GetSurfaceClipRect(surface, &clip_rect); + SDL_SetSurfaceClipRect(surface, NULL); + + if (!SDL_ISPIXELFORMAT_FOURCC(surface->format) && + SDL_BYTESPERPIXEL(surface->format) <= sizeof(Uint32)) { + Uint32 color; + + color = SDL_MapSurfaceRGBA(surface, + (Uint8)SDL_roundf(SDL_clamp(r, 0.0f, 1.0f) * 255.0f), + (Uint8)SDL_roundf(SDL_clamp(g, 0.0f, 1.0f) * 255.0f), + (Uint8)SDL_roundf(SDL_clamp(b, 0.0f, 1.0f) * 255.0f), + (Uint8)SDL_roundf(SDL_clamp(a, 0.0f, 1.0f) * 255.0f)); + result = SDL_FillSurfaceRect(surface, NULL, color); + } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + // We can't directly set an RGB value on a YUV surface + SDL_Surface *tmp = SDL_CreateSurface(surface->w, surface->h, SDL_PIXELFORMAT_ARGB8888); + if (!tmp) { + goto done; + } + + if (SDL_ClearSurface(tmp, r, g, b, a)) { + result = SDL_ConvertPixelsAndColorspace(surface->w, surface->h, tmp->format, tmp->colorspace, tmp->props, tmp->pixels, tmp->pitch, surface->format, surface->colorspace, surface->props, surface->pixels, surface->pitch); + } + SDL_DestroySurface(tmp); + } else { + // Take advantage of blit color conversion + SDL_Surface *tmp = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_RGBA128_FLOAT); + if (!tmp) { + goto done; + } + SDL_SetSurfaceColorspace(tmp, surface->colorspace); + SDL_SetSurfaceBlendMode(tmp, SDL_BLENDMODE_NONE); + + float *pixels = (float *)tmp->pixels; + pixels[0] = r; + pixels[1] = g; + pixels[2] = b; + pixels[3] = a; + + result = SDL_BlitSurfaceScaled(tmp, NULL, surface, NULL, SDL_SCALEMODE_NEAREST); + SDL_DestroySurface(tmp); + } + +done: + SDL_SetSurfaceClipRect(surface, &clip_rect); + + return result; +} + +Uint32 SDL_MapSurfaceRGB(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) +{ + return SDL_MapSurfaceRGBA(surface, r, g, b, SDL_ALPHA_OPAQUE); +} + +Uint32 SDL_MapSurfaceRGBA(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + if (!SDL_SurfaceValid(surface)) { + SDL_InvalidParamError("surface"); + return true; + } + return SDL_MapRGBA(surface->fmt, surface->palette, r, g, b, a); +} + +// This function Copyright 2023 Collabora Ltd., contributed to SDL under the ZLib license +bool SDL_ReadSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) +{ + Uint32 pixel = 0; + size_t bytes_per_pixel; + Uint8 unused; + Uint8 *p; + bool result = false; + + if (r) { + *r = 0; + } else { + r = &unused; + } + + if (g) { + *g = 0; + } else { + g = &unused; + } + + if (b) { + *b = 0; + } else { + b = &unused; + } + + if (a) { + *a = 0; + } else { + a = &unused; + } + + if (!SDL_SurfaceValid(surface) || !surface->format || !surface->pixels) { + return SDL_InvalidParamError("surface"); + } + + if (x < 0 || x >= surface->w) { + return SDL_InvalidParamError("x"); + } + + if (y < 0 || y >= surface->h) { + return SDL_InvalidParamError("y"); + } + + bytes_per_pixel = SDL_BYTESPERPIXEL(surface->format); + + if (SDL_MUSTLOCK(surface)) { + if (!SDL_LockSurface(surface)) { + return false; + } + } + + p = (Uint8 *)surface->pixels + y * surface->pitch + x * bytes_per_pixel; + + if (bytes_per_pixel <= sizeof(pixel) && !SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + /* Fill the appropriate number of least-significant bytes of pixel, + * leaving the most-significant bytes set to zero */ +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + SDL_memcpy(((Uint8 *)&pixel) + (sizeof(pixel) - bytes_per_pixel), p, bytes_per_pixel); +#else + SDL_memcpy(&pixel, p, bytes_per_pixel); +#endif + SDL_GetRGBA(pixel, surface->fmt, surface->palette, r, g, b, a); + result = true; + } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + // FIXME: We need code to extract a single macroblock from a YUV surface + SDL_Surface *converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888); + if (converted) { + result = SDL_ReadSurfacePixel(converted, x, y, r, g, b, a); + SDL_DestroySurface(converted); + } + } else { + // This is really slow, but it gets the job done + Uint8 rgba[4]; + + if (SDL_ConvertPixelsAndColorspace(1, 1, surface->format, surface->colorspace, surface->props, p, surface->pitch, SDL_PIXELFORMAT_RGBA32, SDL_COLORSPACE_SRGB, 0, rgba, sizeof(rgba))) { + *r = rgba[0]; + *g = rgba[1]; + *b = rgba[2]; + *a = rgba[3]; + result = true; + } + } + + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); + } + return result; +} + +bool SDL_ReadSurfacePixelFloat(SDL_Surface *surface, int x, int y, float *r, float *g, float *b, float *a) +{ + float unused; + bool result = false; + + if (r) { + *r = 0.0f; + } else { + r = &unused; + } + + if (g) { + *g = 0.0f; + } else { + g = &unused; + } + + if (b) { + *b = 0.0f; + } else { + b = &unused; + } + + if (a) { + *a = 0.0f; + } else { + a = &unused; + } + + if (!SDL_SurfaceValid(surface) || !surface->format || !surface->pixels) { + return SDL_InvalidParamError("surface"); + } + + if (x < 0 || x >= surface->w) { + return SDL_InvalidParamError("x"); + } + + if (y < 0 || y >= surface->h) { + return SDL_InvalidParamError("y"); + } + + if (SDL_BYTESPERPIXEL(surface->format) <= sizeof(Uint32) && !SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + Uint8 r8, g8, b8, a8; + + if (SDL_ReadSurfacePixel(surface, x, y, &r8, &g8, &b8, &a8)) { + *r = (float)r8 / 255.0f; + *g = (float)g8 / 255.0f; + *b = (float)b8 / 255.0f; + *a = (float)a8 / 255.0f; + result = true; + } + } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + // FIXME: We need code to extract a single macroblock from a YUV surface + SDL_Surface *converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888); + if (converted) { + result = SDL_ReadSurfacePixelFloat(converted, x, y, r, g, b, a); + SDL_DestroySurface(converted); + } + } else { + // This is really slow, but it gets the job done + float rgba[4]; + Uint8 *p; + + if (SDL_MUSTLOCK(surface)) { + if (!SDL_LockSurface(surface)) { + return false; + } + } + + p = (Uint8 *)surface->pixels + y * surface->pitch + x * SDL_BYTESPERPIXEL(surface->format); + + if (surface->format == SDL_PIXELFORMAT_RGBA128_FLOAT) { + SDL_memcpy(rgba, p, sizeof(rgba)); + result = true; + } else { + SDL_Colorspace src_colorspace = surface->colorspace; + SDL_Colorspace dst_colorspace = (src_colorspace == SDL_COLORSPACE_SRGB_LINEAR ? SDL_COLORSPACE_SRGB_LINEAR : SDL_COLORSPACE_SRGB); + + if (SDL_ConvertPixelsAndColorspace(1, 1, surface->format, src_colorspace, surface->props, p, surface->pitch, SDL_PIXELFORMAT_RGBA128_FLOAT, dst_colorspace, 0, rgba, sizeof(rgba))) { + result = true; + } + } + + if (result) { + *r = rgba[0]; + *g = rgba[1]; + *b = rgba[2]; + *a = rgba[3]; + } + + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); + } + } + return result; +} + +bool SDL_WriteSurfacePixel(SDL_Surface *surface, int x, int y, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 pixel = 0; + size_t bytes_per_pixel; + Uint8 *p; + bool result = false; + + if (!SDL_SurfaceValid(surface) || !surface->format || !surface->pixels) { + return SDL_InvalidParamError("surface"); + } + + if (x < 0 || x >= surface->w) { + return SDL_InvalidParamError("x"); + } + + if (y < 0 || y >= surface->h) { + return SDL_InvalidParamError("y"); + } + + bytes_per_pixel = SDL_BYTESPERPIXEL(surface->format); + + if (SDL_MUSTLOCK(surface)) { + if (!SDL_LockSurface(surface)) { + return false; + } + } + + p = (Uint8 *)surface->pixels + y * surface->pitch + x * bytes_per_pixel; + + if (bytes_per_pixel <= sizeof(pixel) && !SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + pixel = SDL_MapRGBA(surface->fmt, surface->palette, r, g, b, a); +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + SDL_memcpy(p, ((Uint8 *)&pixel) + (sizeof(pixel) - bytes_per_pixel), bytes_per_pixel); +#else + SDL_memcpy(p, &pixel, bytes_per_pixel); +#endif + result = true; + } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + result = SDL_Unsupported(); + } else { + // This is really slow, but it gets the job done + Uint8 rgba[4]; + + rgba[0] = r; + rgba[1] = g; + rgba[2] = b; + rgba[3] = a; + result = SDL_ConvertPixelsAndColorspace(1, 1, SDL_PIXELFORMAT_RGBA32, SDL_COLORSPACE_SRGB, 0, rgba, sizeof(rgba), surface->format, surface->colorspace, surface->props, p, surface->pitch); + } + + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); + } + return result; +} + +bool SDL_WriteSurfacePixelFloat(SDL_Surface *surface, int x, int y, float r, float g, float b, float a) +{ + bool result = false; + + if (!SDL_SurfaceValid(surface) || !surface->format || !surface->pixels) { + return SDL_InvalidParamError("surface"); + } + + if (x < 0 || x >= surface->w) { + return SDL_InvalidParamError("x"); + } + + if (y < 0 || y >= surface->h) { + return SDL_InvalidParamError("y"); + } + + if (SDL_BYTESPERPIXEL(surface->format) <= sizeof(Uint32) && !SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + Uint8 r8, g8, b8, a8; + + r8 = (Uint8)SDL_round(SDL_clamp(r, 0.0f, 1.0f) * 255.0f); + g8 = (Uint8)SDL_round(SDL_clamp(g, 0.0f, 1.0f) * 255.0f); + b8 = (Uint8)SDL_round(SDL_clamp(b, 0.0f, 1.0f) * 255.0f); + a8 = (Uint8)SDL_round(SDL_clamp(a, 0.0f, 1.0f) * 255.0f); + if (SDL_WriteSurfacePixel(surface, x, y, r8, g8, b8, a8)) { + result = true; + } + } else if (SDL_ISPIXELFORMAT_FOURCC(surface->format)) { + result = SDL_Unsupported(); + } else { + // This is really slow, but it gets the job done + float rgba[4]; + Uint8 *p; + + if (SDL_MUSTLOCK(surface)) { + if (!SDL_LockSurface(surface)) { + return false; + } + } + + p = (Uint8 *)surface->pixels + y * surface->pitch + x * SDL_BYTESPERPIXEL(surface->format); + + rgba[0] = r; + rgba[1] = g; + rgba[2] = b; + rgba[3] = a; + + if (surface->format == SDL_PIXELFORMAT_RGBA128_FLOAT) { + SDL_memcpy(p, rgba, sizeof(rgba)); + result = true; + } else { + SDL_Colorspace dst_colorspace = surface->colorspace; + SDL_Colorspace src_colorspace = (dst_colorspace == SDL_COLORSPACE_SRGB_LINEAR ? SDL_COLORSPACE_SRGB_LINEAR : SDL_COLORSPACE_SRGB); + + result = SDL_ConvertPixelsAndColorspace(1, 1, SDL_PIXELFORMAT_RGBA128_FLOAT, src_colorspace, 0, rgba, sizeof(rgba), surface->format, dst_colorspace, surface->props, p, surface->pitch); + } + + if (SDL_MUSTLOCK(surface)) { + SDL_UnlockSurface(surface); + } + } + return result; +} + +/* + * Free a surface created by the above function. + */ +void SDL_DestroySurface(SDL_Surface *surface) +{ + if (!SDL_SurfaceValid(surface)) { + return; + } + if (surface->internal_flags & SDL_INTERNAL_SURFACE_DONTFREE) { + return; + } + if (--surface->refcount > 0) { + return; + } + + SDL_RemoveSurfaceAlternateImages(surface); + + SDL_DestroyProperties(surface->props); + + SDL_InvalidateMap(&surface->map); + + while (surface->locked > 0) { + SDL_UnlockSurface(surface); + } +#ifdef SDL_HAVE_RLE + if (surface->internal_flags & SDL_INTERNAL_SURFACE_RLEACCEL) { + SDL_UnRLESurface(surface, false); + } +#endif + SDL_SetSurfacePalette(surface, NULL); + + if (surface->flags & SDL_SURFACE_PREALLOCATED) { + // Don't free + } else if (surface->flags & SDL_SURFACE_SIMD_ALIGNED) { + // Free aligned + SDL_aligned_free(surface->pixels); + } else { + // Normal + SDL_free(surface->pixels); + } + + surface->reserved = NULL; + + if (!(surface->internal_flags & SDL_INTERNAL_SURFACE_STACK)) { + SDL_free(surface); + } +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_surface_c.h b/contrib/SDL-3.2.8/src/video/SDL_surface_c.h new file mode 100644 index 0000000..27dc88a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_surface_c.h @@ -0,0 +1,92 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_surface_c_h_ +#define SDL_surface_c_h_ + +// Useful functions and variables from SDL_surface.c + +#include "SDL_blit.h" + +// Surface internal flags +typedef Uint32 SDL_SurfaceDataFlags; + +#define SDL_INTERNAL_SURFACE_DONTFREE 0x00000001u /**< Surface is referenced internally */ +#define SDL_INTERNAL_SURFACE_STACK 0x00000002u /**< Surface is allocated on the stack */ +#define SDL_INTERNAL_SURFACE_RLEACCEL 0x00000004u /**< Surface is RLE encoded */ + +// Surface internal data definition +struct SDL_Surface +{ + // Public API definition + SDL_SurfaceFlags flags; /**< The flags of the surface, read-only */ + SDL_PixelFormat format; /**< The format of the surface, read-only */ + int w; /**< The width of the surface, read-only. */ + int h; /**< The height of the surface, read-only. */ + int pitch; /**< The distance in bytes between rows of pixels, read-only */ + void *pixels; /**< A pointer to the pixels of the surface, the pixels are writeable if non-NULL */ + + int refcount; /**< Application reference count, used when freeing surface */ + + void *reserved; /**< Reserved for internal use */ + + // Private API definition + + /** flags for this surface */ + SDL_SurfaceDataFlags internal_flags; + + /** properties for this surface */ + SDL_PropertiesID props; + + /** detailed format for this surface */ + const SDL_PixelFormatDetails *fmt; + + /** Pixel colorspace */ + SDL_Colorspace colorspace; + + /** palette for indexed surfaces */ + SDL_Palette *palette; + + /** Alternate representation of images */ + int num_images; + SDL_Surface **images; + + /** information needed for surfaces requiring locks */ + int locked; + + /** clipping information */ + SDL_Rect clip_rect; + + /** info for fast blit mapping to other surfaces */ + SDL_BlitMap map; +}; + +// Surface functions +extern bool SDL_SurfaceValid(SDL_Surface *surface); +extern void SDL_UpdateSurfaceLockFlag(SDL_Surface *surface); +extern float SDL_GetDefaultSDRWhitePoint(SDL_Colorspace colorspace); +extern float SDL_GetSurfaceSDRWhitePoint(SDL_Surface *surface, SDL_Colorspace colorspace); +extern float SDL_GetDefaultHDRHeadroom(SDL_Colorspace colorspace); +extern float SDL_GetSurfaceHDRHeadroom(SDL_Surface *surface, SDL_Colorspace colorspace); +extern SDL_Surface *SDL_GetSurfaceImage(SDL_Surface *surface, float display_scale); + +#endif // SDL_surface_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_sysvideo.h b/contrib/SDL-3.2.8/src/video/SDL_sysvideo.h new file mode 100644 index 0000000..6da8bd2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_sysvideo.h @@ -0,0 +1,602 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_sysvideo_h_ +#define SDL_sysvideo_h_ + +#include + +#include "SDL_surface_c.h" + +// The SDL video driver + +typedef struct SDL_VideoDisplay SDL_VideoDisplay; +typedef struct SDL_VideoDevice SDL_VideoDevice; +typedef struct SDL_VideoData SDL_VideoData; +typedef struct SDL_DisplayData SDL_DisplayData; +typedef struct SDL_WindowData SDL_WindowData; + +typedef struct +{ + float SDR_white_level; + float HDR_headroom; +} SDL_HDROutputProperties; + +// Define the SDL window structure, corresponding to toplevel windows +struct SDL_Window +{ + SDL_WindowID id; + char *title; + SDL_Surface *icon; + int x, y; + int w, h; + int min_w, min_h; + int max_w, max_h; + float min_aspect; + float max_aspect; + int last_pixel_w, last_pixel_h; + SDL_WindowFlags flags; + SDL_WindowFlags pending_flags; + float display_scale; + bool external_graphics_context; + bool fullscreen_exclusive; // The window is currently fullscreen exclusive + SDL_DisplayID last_fullscreen_exclusive_display; // The last fullscreen_exclusive display + SDL_DisplayID last_displayID; + + /* Stored position and size for the window in the non-fullscreen state, + * including when the window is maximized or tiled. + * + * This is the size and position to which the window should return when + * leaving the fullscreen state. + */ + SDL_Rect windowed; + + /* Stored position and size for the window in the base 'floating' state; + * when not fullscreen, nor in a state such as maximized or tiled. + * + * This is the size and position to which the window should return when + * it's maximized and SDL_RestoreWindow() is called. + */ + SDL_Rect floating; + + // The last client requested size and position for the window. + SDL_Rect pending; + + /* Toggle for drivers to indicate that the current window state is tiled, + * and sizes set non-programmatically shouldn't be cached. + */ + bool tiled; + + // Whether or not the initial position was defined + bool undefined_x; + bool undefined_y; + + SDL_DisplayMode requested_fullscreen_mode; + SDL_DisplayMode current_fullscreen_mode; + SDL_HDROutputProperties HDR; + + float opacity; + + SDL_Surface *surface; + bool surface_valid; + + bool is_hiding; + bool restore_on_show; // Child was hidden recursively by the parent, restore when shown. + bool last_position_pending; // This should NOT be cleared by the backend, as it is used for fullscreen positioning. + bool last_size_pending; // This should be cleared by the backend if the new size cannot be applied. + bool is_destroying; + bool is_dropping; // drag/drop in progress, expecting SDL_SendDropComplete(). + + int safe_inset_left; + int safe_inset_right; + int safe_inset_top; + int safe_inset_bottom; + SDL_Rect safe_rect; + + SDL_PropertiesID text_input_props; + bool text_input_active; + SDL_Rect text_input_rect; + int text_input_cursor; + + SDL_Rect mouse_rect; + + SDL_HitTest hit_test; + void *hit_test_data; + + SDL_PropertiesID props; + + int num_renderers; + SDL_Renderer **renderers; + + SDL_WindowData *internal; + + SDL_Window *prev; + SDL_Window *next; + + SDL_Window *parent; + SDL_Window *first_child; + SDL_Window *prev_sibling; + SDL_Window *next_sibling; +}; +#define SDL_WINDOW_FULLSCREEN_VISIBLE(W) \ + ((((W)->flags & SDL_WINDOW_FULLSCREEN) != 0) && \ + (((W)->flags & SDL_WINDOW_HIDDEN) == 0) && \ + (((W)->flags & SDL_WINDOW_MINIMIZED) == 0)) + +#define SDL_WINDOW_IS_POPUP(W) \ + (((W)->flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU)) != 0) + +/* + * Define the SDL display structure. + * This corresponds to physical monitors attached to the system. + */ +struct SDL_VideoDisplay +{ + SDL_DisplayID id; + char *name; + int max_fullscreen_modes; + int num_fullscreen_modes; + SDL_DisplayMode *fullscreen_modes; + SDL_DisplayMode desktop_mode; + const SDL_DisplayMode *current_mode; + SDL_DisplayOrientation natural_orientation; + SDL_DisplayOrientation current_orientation; + float content_scale; + SDL_HDROutputProperties HDR; + + // This is true if we are fullscreen or fullscreen is pending + bool fullscreen_active; + SDL_Window *fullscreen_window; + + SDL_VideoDevice *device; + + SDL_PropertiesID props; + + SDL_DisplayData *internal; +}; + +// Video device flags +typedef enum +{ + VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED = 0x01, + VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT = 0x02, + VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS = 0x04, + VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY = 0x08, + VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES = 0x10, + VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS = 0x20, + VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES = 0x40 +} DeviceCaps; + +// Fullscreen operations +typedef enum +{ + SDL_FULLSCREEN_OP_LEAVE = 0, + SDL_FULLSCREEN_OP_ENTER, + SDL_FULLSCREEN_OP_UPDATE +} SDL_FullscreenOp; + +typedef enum +{ + SDL_FULLSCREEN_FAILED, + SDL_FULLSCREEN_SUCCEEDED, + SDL_FULLSCREEN_PENDING +} SDL_FullscreenResult; + +struct SDL_VideoDevice +{ + /* * * */ + // The name of this video driver + const char *name; + + /* * * */ + // Initialization/Query functions + + /* + * Initialize the native video subsystem, filling in the list of + * displays for this driver, returning 0 or -1 if there's an error. + */ + bool (*VideoInit)(SDL_VideoDevice *_this); + + /* + * Reverse the effects VideoInit() -- called if VideoInit() fails or + * if the application is shutting down the video subsystem. + */ + void (*VideoQuit)(SDL_VideoDevice *_this); + + /* + * Reinitialize the touch devices -- called if an unknown touch ID occurs. + */ + void (*ResetTouch)(SDL_VideoDevice *_this); + + /* * * */ + /* + * Display functions + */ + + /* + * Refresh the display list + */ + void (*RefreshDisplays)(SDL_VideoDevice *_this); + + /* + * Get the bounds of a display + */ + bool (*GetDisplayBounds)(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); + + /* + * Get the usable bounds of a display (bounds minus menubar or whatever) + */ + bool (*GetDisplayUsableBounds)(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); + + /* + * Get a list of the available display modes for a display. + */ + bool (*GetDisplayModes)(SDL_VideoDevice *_this, SDL_VideoDisplay *display); + + /* + * Setting the display mode is independent of creating windows, so + * when the display mode is changed, all existing windows should have + * their data updated accordingly, including the display surfaces + * associated with them. + */ + bool (*SetDisplayMode)(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); + + /* * * */ + /* + * Window functions + */ + bool (*CreateSDLWindow)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); + void (*SetWindowTitle)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*SetWindowIcon)(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); + bool (*SetWindowPosition)(SDL_VideoDevice *_this, SDL_Window *window); + void (*SetWindowSize)(SDL_VideoDevice *_this, SDL_Window *window); + void (*SetWindowMinimumSize)(SDL_VideoDevice *_this, SDL_Window *window); + void (*SetWindowMaximumSize)(SDL_VideoDevice *_this, SDL_Window *window); + void (*SetWindowAspectRatio)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*GetWindowBordersSize)(SDL_VideoDevice *_this, SDL_Window *window, int *top, int *left, int *bottom, int *right); + float (*GetWindowContentScale)(SDL_VideoDevice *_this, SDL_Window *window); + void (*GetWindowSizeInPixels)(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); + bool (*SetWindowOpacity)(SDL_VideoDevice *_this, SDL_Window *window, float opacity); + bool (*SetWindowParent)(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); + bool (*SetWindowModal)(SDL_VideoDevice *_this, SDL_Window *window, bool modal); + void (*ShowWindow)(SDL_VideoDevice *_this, SDL_Window *window); + void (*HideWindow)(SDL_VideoDevice *_this, SDL_Window *window); + void (*RaiseWindow)(SDL_VideoDevice *_this, SDL_Window *window); + void (*MaximizeWindow)(SDL_VideoDevice *_this, SDL_Window *window); + void (*MinimizeWindow)(SDL_VideoDevice *_this, SDL_Window *window); + void (*RestoreWindow)(SDL_VideoDevice *_this, SDL_Window *window); + void (*SetWindowBordered)(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); + void (*SetWindowResizable)(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); + void (*SetWindowAlwaysOnTop)(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); + SDL_FullscreenResult (*SetWindowFullscreen)(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); + void *(*GetWindowICCProfile)(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); + SDL_DisplayID (*GetDisplayForWindow)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*SetWindowMouseRect)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*SetWindowMouseGrab)(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); + bool (*SetWindowKeyboardGrab)(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); + void (*DestroyWindow)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*CreateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); + bool (*SetWindowFramebufferVSync)(SDL_VideoDevice *_this, SDL_Window *window, int vsync); + bool (*GetWindowFramebufferVSync)(SDL_VideoDevice *_this, SDL_Window *window, int *vsync); + bool (*UpdateWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); + void (*DestroyWindowFramebuffer)(SDL_VideoDevice *_this, SDL_Window *window); + void (*OnWindowEnter)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*UpdateWindowShape)(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); + bool (*FlashWindow)(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); + bool (*SetWindowFocusable)(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); + bool (*SyncWindow)(SDL_VideoDevice *_this, SDL_Window *window); + + /* * * */ + /* + * OpenGL support + */ + bool (*GL_LoadLibrary)(SDL_VideoDevice *_this, const char *path); + SDL_FunctionPointer (*GL_GetProcAddress)(SDL_VideoDevice *_this, const char *proc); + void (*GL_UnloadLibrary)(SDL_VideoDevice *_this); + SDL_GLContext (*GL_CreateContext)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*GL_MakeCurrent)(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); + SDL_EGLSurface (*GL_GetEGLSurface)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*GL_SetSwapInterval)(SDL_VideoDevice *_this, int interval); + bool (*GL_GetSwapInterval)(SDL_VideoDevice *_this, int *interval); + bool (*GL_SwapWindow)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*GL_DestroyContext)(SDL_VideoDevice *_this, SDL_GLContext context); + void (*GL_DefaultProfileConfig)(SDL_VideoDevice *_this, int *mask, int *major, int *minor); + + /* * * */ + /* + * Vulkan support + */ + bool (*Vulkan_LoadLibrary)(SDL_VideoDevice *_this, const char *path); + void (*Vulkan_UnloadLibrary)(SDL_VideoDevice *_this); + char const* const* (*Vulkan_GetInstanceExtensions)(SDL_VideoDevice *_this, Uint32 *count); + bool (*Vulkan_CreateSurface)(SDL_VideoDevice *_this, SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface); + void (*Vulkan_DestroySurface)(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); + bool (*Vulkan_GetPresentationSupport)(SDL_VideoDevice *_this, VkInstance instance, VkPhysicalDevice physicalDevice, Uint32 queueFamilyIndex); + + /* * * */ + /* + * Metal support + */ + SDL_MetalView (*Metal_CreateView)(SDL_VideoDevice *_this, SDL_Window *window); + void (*Metal_DestroyView)(SDL_VideoDevice *_this, SDL_MetalView view); + void *(*Metal_GetLayer)(SDL_VideoDevice *_this, SDL_MetalView view); + + /* * * */ + /* + * Event manager functions + */ + int (*WaitEventTimeout)(SDL_VideoDevice *_this, Sint64 timeoutNS); + void (*SendWakeupEvent)(SDL_VideoDevice *_this, SDL_Window *window); + void (*PumpEvents)(SDL_VideoDevice *_this); + + // Suspend/resume the screensaver + bool (*SuspendScreenSaver)(SDL_VideoDevice *_this); + + // Text input + bool (*StartTextInput)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); + bool (*StopTextInput)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*UpdateTextInputArea)(SDL_VideoDevice *_this, SDL_Window *window); + bool (*ClearComposition)(SDL_VideoDevice *_this, SDL_Window *window); + + // Screen keyboard + bool (*HasScreenKeyboardSupport)(SDL_VideoDevice *_this); + void (*ShowScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); + void (*HideScreenKeyboard)(SDL_VideoDevice *_this, SDL_Window *window); + void (*SetTextInputProperties)(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); + bool (*IsScreenKeyboardShown)(SDL_VideoDevice *_this, SDL_Window *window); + + // Clipboard + const char **(*GetTextMimeTypes)(SDL_VideoDevice *_this, size_t *num_mime_types); + bool (*SetClipboardData)(SDL_VideoDevice *_this); + void *(*GetClipboardData)(SDL_VideoDevice *_this, const char *mime_type, size_t *size); + bool (*HasClipboardData)(SDL_VideoDevice *_this, const char *mime_type); + /* If you implement *ClipboardData, you don't need to implement *ClipboardText */ + bool (*SetClipboardText)(SDL_VideoDevice *_this, const char *text); + char *(*GetClipboardText)(SDL_VideoDevice *_this); + bool (*HasClipboardText)(SDL_VideoDevice *_this); + // These functions are only needed if the platform has a separate primary selection buffer + bool (*SetPrimarySelectionText)(SDL_VideoDevice *_this, const char *text); + char *(*GetPrimarySelectionText)(SDL_VideoDevice *_this); + bool (*HasPrimarySelectionText)(SDL_VideoDevice *_this); + + // MessageBox + bool (*ShowMessageBox)(SDL_VideoDevice *_this, const SDL_MessageBoxData *messageboxdata, int *buttonID); + + // Hit-testing + bool (*SetWindowHitTest)(SDL_Window *window, bool enabled); + + // Tell window that app enabled drag'n'drop events + void (*AcceptDragAndDrop)(SDL_Window *window, bool accept); + + // Display the system-level window menu + void (*ShowWindowSystemMenu)(SDL_Window *window, int x, int y); + + /* * * */ + // Data common to all drivers + SDL_ThreadID thread; + bool checked_texture_framebuffer; + bool is_dummy; + bool suspend_screensaver; + SDL_Window *wakeup_window; + SDL_Mutex *wakeup_lock; // Initialized only if WaitEventTimeout/SendWakeupEvent are supported + int num_displays; + SDL_VideoDisplay **displays; + SDL_Rect desktop_bounds; + SDL_Window *windows; + SDL_Window *grabbed_window; + Uint32 clipboard_sequence; + SDL_ClipboardDataCallback clipboard_callback; + SDL_ClipboardCleanupCallback clipboard_cleanup; + void *clipboard_userdata; + char **clipboard_mime_types; + size_t num_clipboard_mime_types; + char *primary_selection_text; + bool setting_display_mode; + Uint32 device_caps; + SDL_SystemTheme system_theme; + + /* * * */ + // Data used by the GL drivers + struct + { + int red_size; + int green_size; + int blue_size; + int alpha_size; + int depth_size; + int buffer_size; + int stencil_size; + int double_buffer; + int accum_red_size; + int accum_green_size; + int accum_blue_size; + int accum_alpha_size; + int stereo; + int multisamplebuffers; + int multisamplesamples; + int floatbuffers; + int accelerated; + int major_version; + int minor_version; + int flags; + int profile_mask; + int share_with_current_context; + int release_behavior; + int reset_notification; + int framebuffer_srgb_capable; + int no_error; + int retained_backing; + int egl_platform; + int driver_loaded; + char driver_path[256]; + SDL_SharedObject *dll_handle; + } gl_config; + + SDL_EGLAttribArrayCallback egl_platformattrib_callback; + SDL_EGLIntArrayCallback egl_surfaceattrib_callback; + SDL_EGLIntArrayCallback egl_contextattrib_callback; + void *egl_attrib_callback_userdata; + + /* * * */ + // Cache current GL context; don't call the OS when it hasn't changed. + /* We have the global pointers here so Cocoa continues to work the way + it always has, and the thread-local storage for the general case. + */ + SDL_Window *current_glwin; + SDL_GLContext current_glctx; + SDL_TLSID current_glwin_tls; + SDL_TLSID current_glctx_tls; + + /* Flag that stores whether it's allowed to call SDL_GL_MakeCurrent() + * with a NULL window, but a non-NULL context. (Not allowed in most cases, + * except on EGL under some circumstances.) */ + bool gl_allow_no_surface; + + /* * * */ + // Data used by the Vulkan drivers + struct + { + SDL_FunctionPointer vkGetInstanceProcAddr; + SDL_FunctionPointer vkEnumerateInstanceExtensionProperties; + int loader_loaded; + char loader_path[256]; + SDL_SharedObject *loader_handle; + } vulkan_config; + + /* * * */ + // Data private to this driver + SDL_VideoData *internal; + struct SDL_GLDriverData *gl_data; + +#ifdef SDL_VIDEO_OPENGL_EGL + struct SDL_EGL_VideoData *egl_data; +#endif + +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + struct SDL_PrivateGLESData *gles_data; +#endif + + /* * * */ + // The function used to dispose of this structure + void (*free)(SDL_VideoDevice *_this); +}; + +typedef struct VideoBootStrap +{ + const char *name; + const char *desc; + SDL_VideoDevice *(*create)(void); + bool (*ShowMessageBox)(const SDL_MessageBoxData *messageboxdata, int *buttonID); // can be done without initializing backend! + bool is_preferred; +} VideoBootStrap; + +// Not all of these are available in a given build. Use #ifdefs, etc. +extern VideoBootStrap PRIVATE_bootstrap; +extern VideoBootStrap COCOA_bootstrap; +extern VideoBootStrap X11_bootstrap; +extern VideoBootStrap WINDOWS_bootstrap; +extern VideoBootStrap HAIKU_bootstrap; +extern VideoBootStrap UIKIT_bootstrap; +extern VideoBootStrap Android_bootstrap; +extern VideoBootStrap PS2_bootstrap; +extern VideoBootStrap PSP_bootstrap; +extern VideoBootStrap VITA_bootstrap; +extern VideoBootStrap RISCOS_bootstrap; +extern VideoBootStrap N3DS_bootstrap; +extern VideoBootStrap RPI_bootstrap; +extern VideoBootStrap KMSDRM_bootstrap; +extern VideoBootStrap DUMMY_bootstrap; +extern VideoBootStrap DUMMY_evdev_bootstrap; +extern VideoBootStrap Wayland_preferred_bootstrap; +extern VideoBootStrap Wayland_bootstrap; +extern VideoBootStrap VIVANTE_bootstrap; +extern VideoBootStrap Emscripten_bootstrap; +extern VideoBootStrap OFFSCREEN_bootstrap; +extern VideoBootStrap QNX_bootstrap; +extern VideoBootStrap OPENVR_bootstrap; + +extern bool SDL_UninitializedVideo(void); +// Use SDL_OnVideoThread() sparingly, to avoid regressions in use cases that currently happen to work +extern bool SDL_OnVideoThread(void); +extern SDL_VideoDevice *SDL_GetVideoDevice(void); +extern void SDL_SetSystemTheme(SDL_SystemTheme theme); +extern SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode); +extern SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, bool send_event); +extern void SDL_DelVideoDisplay(SDL_DisplayID display, bool send_event); +extern bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); +extern void SDL_ResetFullscreenDisplayModes(SDL_VideoDisplay *display); +extern void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); +extern void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode); +extern void SDL_SetDisplayContentScale(SDL_VideoDisplay *display, float scale); +extern void SDL_SetDisplayHDRProperties(SDL_VideoDisplay *display, const SDL_HDROutputProperties *HDR); +extern bool SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern SDL_VideoDisplay *SDL_GetVideoDisplay(SDL_DisplayID display); +extern SDL_DisplayID SDL_GetDisplayForWindowPosition(SDL_Window *window); +extern SDL_VideoDisplay *SDL_GetVideoDisplayForWindow(SDL_Window *window); +extern SDL_VideoDisplay *SDL_GetVideoDisplayForFullscreenWindow(SDL_Window *window); +extern int SDL_GetDisplayIndex(SDL_DisplayID displayID); +extern SDL_DisplayData *SDL_GetDisplayDriverData(SDL_DisplayID display); +extern SDL_DisplayData *SDL_GetDisplayDriverDataForWindow(SDL_Window *window); +extern int SDL_GetMessageBoxCount(void); +extern void SDL_SetWindowHDRProperties(SDL_Window *window, const SDL_HDROutputProperties *HDR, bool send_event); +extern void SDL_SetWindowSafeAreaInsets(SDL_Window *window, int left, int right, int top, int bottom); + +extern void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor); + +extern bool SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags); +extern bool SDL_HasWindows(void); +extern void SDL_RelativeToGlobalForWindow(SDL_Window *window, int rel_x, int rel_y, int *abs_x, int *abs_y); +extern void SDL_GlobalToRelativeForWindow(SDL_Window *window, int abs_x, int abs_y, int *rel_x, int *rel_y); + +extern void SDL_OnDisplayAdded(SDL_VideoDisplay *display); +extern void SDL_OnDisplayMoved(SDL_VideoDisplay *display); +extern void SDL_OnWindowShown(SDL_Window *window); +extern void SDL_OnWindowHidden(SDL_Window *window); +extern void SDL_OnWindowMoved(SDL_Window *window); +extern void SDL_OnWindowResized(SDL_Window *window); +extern void SDL_CheckWindowPixelSizeChanged(SDL_Window *window); +extern void SDL_OnWindowPixelSizeChanged(SDL_Window *window); +extern void SDL_OnWindowLiveResizeUpdate(SDL_Window *window); +extern void SDL_OnWindowMinimized(SDL_Window *window); +extern void SDL_OnWindowMaximized(SDL_Window *window); +extern void SDL_OnWindowRestored(SDL_Window *window); +extern void SDL_OnWindowEnter(SDL_Window *window); +extern void SDL_OnWindowLeave(SDL_Window *window); +extern void SDL_OnWindowFocusGained(SDL_Window *window); +extern void SDL_OnWindowFocusLost(SDL_Window *window); +extern void SDL_OnWindowDisplayChanged(SDL_Window *window); +extern void SDL_UpdateWindowGrab(SDL_Window *window); +extern bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, bool commit); +extern SDL_Window *SDL_GetToplevelForKeyboardFocus(void); + +extern bool SDL_ShouldAllowTopmost(void); + +extern void SDL_ToggleDragAndDropSupport(void); + +extern void SDL_UpdateDesktopBounds(void); + +extern SDL_TextInputType SDL_GetTextInputType(SDL_PropertiesID props); +extern SDL_Capitalization SDL_GetTextInputCapitalization(SDL_PropertiesID props); +extern bool SDL_GetTextInputAutocorrect(SDL_PropertiesID props); +extern bool SDL_GetTextInputMultiline(SDL_PropertiesID props); + +#endif // SDL_sysvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_video.c b/contrib/SDL-3.2.8/src/video/SDL_video.c new file mode 100644 index 0000000..3ed4994 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_video.c @@ -0,0 +1,6130 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +// The high-level video driver subsystem + +#include "SDL_sysvideo.h" +#include "SDL_clipboard_c.h" +#include "SDL_egl_c.h" +#include "SDL_surface_c.h" +#include "SDL_pixels_c.h" +#include "SDL_rect_c.h" +#include "SDL_video_c.h" +#include "../events/SDL_events_c.h" +#include "../SDL_hints_c.h" +#include "../SDL_properties_c.h" +#include "../timer/SDL_timer_c.h" +#include "../camera/SDL_camera_c.h" +#include "../render/SDL_sysrender.h" +#include "../main/SDL_main_callbacks.h" + +#ifdef SDL_VIDEO_OPENGL +#include +#endif // SDL_VIDEO_OPENGL + +#if defined(SDL_VIDEO_OPENGL_ES) && !defined(SDL_VIDEO_OPENGL) +#include +#endif // SDL_VIDEO_OPENGL_ES && !SDL_VIDEO_OPENGL + +// GL and GLES2 headers conflict on Linux 32 bits +#if defined(SDL_VIDEO_OPENGL_ES2) && !defined(SDL_VIDEO_OPENGL) +#include +#endif // SDL_VIDEO_OPENGL_ES2 && !SDL_VIDEO_OPENGL + +// GL_CONTEXT_RELEASE_BEHAVIOR and GL_CONTEXT_RELEASE_BEHAVIOR_KHR have the same number. +#ifndef GL_CONTEXT_RELEASE_BEHAVIOR +#define GL_CONTEXT_RELEASE_BEHAVIOR 0x82FB +#endif + +// GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH and GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR have the same number. +#ifndef GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82FC +#endif + +#ifdef SDL_PLATFORM_EMSCRIPTEN +#include +#endif + +#ifdef SDL_PLATFORM_3DS +#include <3ds.h> +#endif + +#ifdef SDL_PLATFORM_LINUX +#include +#include +#include +#endif + +// Available video drivers +static VideoBootStrap *bootstrap[] = { +#ifdef SDL_VIDEO_DRIVER_PRIVATE + &PRIVATE_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_COCOA + &COCOA_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_X11 +#ifdef SDL_VIDEO_DRIVER_WAYLAND + &Wayland_preferred_bootstrap, +#endif + &X11_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND + &Wayland_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_VIVANTE + &VIVANTE_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_WINDOWS + &WINDOWS_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_HAIKU + &HAIKU_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_UIKIT + &UIKIT_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_ANDROID + &Android_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_PS2 + &PS2_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_PSP + &PSP_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_VITA + &VITA_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_N3DS + &N3DS_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_KMSDRM + &KMSDRM_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_RISCOS + &RISCOS_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_RPI + &RPI_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN + &Emscripten_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_QNX + &QNX_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN + &OFFSCREEN_bootstrap, +#endif +#ifdef SDL_VIDEO_DRIVER_DUMMY + &DUMMY_bootstrap, +#ifdef SDL_INPUT_LINUXEV + &DUMMY_evdev_bootstrap, +#endif +#endif +#ifdef SDL_VIDEO_DRIVER_OPENVR + &OPENVR_bootstrap, +#endif + NULL +}; + +#define CHECK_WINDOW_MAGIC(window, result) \ + if (!_this) { \ + SDL_UninitializedVideo(); \ + return result; \ + } \ + if (!SDL_ObjectValid(window, SDL_OBJECT_TYPE_WINDOW)) { \ + SDL_SetError("Invalid window"); \ + return result; \ + } + +#define CHECK_DISPLAY_MAGIC(display, result) \ + if (!display) { \ + return result; \ + } \ + +#define CHECK_WINDOW_NOT_POPUP(window, result) \ + if (SDL_WINDOW_IS_POPUP(window)) { \ + SDL_SetError("Operation invalid on popup windows"); \ + return result; \ + } + +#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) +// Support for macOS fullscreen spaces +extern bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window); +extern bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, bool state, bool blocking); +#endif + +#ifdef SDL_VIDEO_DRIVER_UIKIT +extern void SDL_UpdateLifecycleObserver(void); +#endif + +static void SDL_CheckWindowDisplayChanged(SDL_Window *window); +static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window); +static void SDL_CheckWindowSafeAreaChanged(SDL_Window *window); + +// Convenience functions for reading driver flags +static bool SDL_ModeSwitchingEmulated(SDL_VideoDevice *_this) +{ + if (_this->device_caps & VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED) { + return true; + } + return false; +} + +static bool SDL_SendsFullscreenDimensions(SDL_VideoDevice *_this) +{ + return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS); +} + +static bool IsFullscreenOnly(SDL_VideoDevice *_this) +{ + return !!(_this->device_caps & VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY); +} + +static bool SDL_SendsDisplayChanges(SDL_VideoDevice *_this) +{ + return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES); +} + +static bool SDL_DisableMouseWarpOnFullscreenTransitions(SDL_VideoDevice *_this) +{ + return !!(_this->device_caps & VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS); +} + +static bool SDL_DriverSendsHDRChanges(SDL_VideoDevice *_this) +{ + return !!(_this->device_caps & VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES); +} + +// Hint to treat all window ops as synchronous +static bool syncHint; + +static void SDL_SyncHintWatcher(void *userdata, const char *name, const char *oldValue, const char *newValue) +{ + syncHint = SDL_GetStringBoolean(newValue, false); +} + +static void SDL_SyncIfRequired(SDL_Window *window) +{ + if (syncHint) { + SDL_SyncWindow(window); + } +} + +static void SDL_UpdateWindowHierarchy(SDL_Window *window, SDL_Window *parent) +{ + // Unlink the window from the existing parent. + if (window->parent) { + if (window->next_sibling) { + window->next_sibling->prev_sibling = window->prev_sibling; + } + if (window->prev_sibling) { + window->prev_sibling->next_sibling = window->next_sibling; + } else { + window->parent->first_child = window->next_sibling; + } + + window->parent = NULL; + } + + if (parent) { + window->parent = parent; + + window->next_sibling = parent->first_child; + if (parent->first_child) { + parent->first_child->prev_sibling = window; + } + parent->first_child = window; + } +} + +// Support for framebuffer emulation using an accelerated renderer + +#define SDL_PROP_WINDOW_TEXTUREDATA_POINTER "SDL.internal.window.texturedata" + +typedef struct +{ + SDL_Renderer *renderer; + SDL_Texture *texture; + void *pixels; + int pitch; + int bytes_per_pixel; +} SDL_WindowTextureData; + +static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) +{ +#if (defined(SDL_VIDEO_OPENGL) && defined(SDL_PLATFORM_MACOS)) || (defined(SDL_PLATFORM_IOS) && !TARGET_OS_MACCATALYST) + if (_this->GL_CreateContext) { + return SDL_WINDOW_OPENGL; + } +#endif +#if defined(SDL_VIDEO_METAL) && (TARGET_OS_MACCATALYST || defined(SDL_PLATFORM_MACOS) || defined(SDL_PLATFORM_IOS)) + if (_this->Metal_CreateView) { + return SDL_WINDOW_METAL; + } +#endif +#if defined(SDL_VIDEO_OPENGL) && defined(SDL_VIDEO_DRIVER_OPENVR) + if (SDL_strcmp(_this->name, "openvr") == 0) { + return SDL_WINDOW_OPENGL; + } +#endif + return 0; +} + +static void SDLCALL SDL_CleanupWindowTextureData(void *userdata, void *value) +{ + SDL_WindowTextureData *data = (SDL_WindowTextureData *)value; + + if (data->texture) { + SDL_DestroyTexture(data->texture); + } + if (data->renderer) { + SDL_DestroyRenderer(data->renderer); + } + SDL_free(data->pixels); + SDL_free(data); +} + +static bool SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_WindowTextureData *data = (SDL_WindowTextureData *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL); + const bool transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? true : false; + int i; + int w, h; + const SDL_PixelFormat *texture_formats; + + SDL_GetWindowSizeInPixels(window, &w, &h); + + if (!data) { + SDL_Renderer *renderer = NULL; + const char *render_driver = NULL; + + // See if there's a render driver being requested + const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); + if (hint && *hint != '0' && *hint != '1' && + SDL_strcasecmp(hint, "true") != 0 && + SDL_strcasecmp(hint, "false") != 0 && + SDL_strcasecmp(hint, SDL_SOFTWARE_RENDERER) != 0) { + render_driver = hint; + } + + if (!render_driver) { + render_driver = SDL_GetHint(SDL_HINT_RENDER_DRIVER); + } + if (render_driver && SDL_strcasecmp(render_driver, SDL_SOFTWARE_RENDERER) == 0) { + render_driver = NULL; + } + + char *render_driver_copy = NULL; + if (render_driver && *render_driver) { + render_driver_copy = SDL_strdup(render_driver); + render_driver = render_driver_copy; + if (render_driver_copy) { // turn any "software" requests into "xxxxxxxx" so we don't end up in infinite recursion. + char *prev = render_driver_copy; + char *ptr = prev; + while ((ptr = SDL_strchr(ptr, ',')) != NULL) { + *ptr = '\0'; + const bool is_sw = (SDL_strcasecmp(prev, SDL_SOFTWARE_RENDERER) == 0); + *ptr = ','; + if (is_sw) { + SDL_memset(prev, 'x', SDL_strlen(SDL_SOFTWARE_RENDERER)); + ptr = prev; + } else { + ptr++; + prev = ptr; + } + } + + if (SDL_strcasecmp(prev, SDL_SOFTWARE_RENDERER) == 0) { + SDL_memset(prev, 'x', SDL_strlen(SDL_SOFTWARE_RENDERER)); + } + } + } + + // Check to see if there's a specific driver requested + if (render_driver) { + renderer = SDL_CreateRenderer(window, render_driver); + SDL_free(render_driver_copy); + if (!renderer) { + // The error for this specific renderer has already been set + return false; + } + } else { + SDL_assert(render_driver_copy == NULL); + const int total = SDL_GetNumRenderDrivers(); + for (i = 0; i < total; ++i) { + const char *name = SDL_GetRenderDriver(i); + if (name && SDL_strcmp(name, SDL_SOFTWARE_RENDERER) != 0) { + renderer = SDL_CreateRenderer(window, name); + if (renderer) { + break; // this will work. + } + } + } + if (!renderer) { + return SDL_SetError("No hardware accelerated renderers available"); + } + } + + SDL_assert(renderer != NULL); // should have explicitly checked this above. + + // Create the data after we successfully create the renderer (bug #1116) + data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_DestroyRenderer(renderer); + return false; + } + if (!SDL_SetPointerPropertyWithCleanup(props, SDL_PROP_WINDOW_TEXTUREDATA_POINTER, data, SDL_CleanupWindowTextureData, NULL)) { + SDL_DestroyRenderer(renderer); + return false; + } + + data->renderer = renderer; + } + + texture_formats = (const SDL_PixelFormat *)SDL_GetPointerProperty(SDL_GetRendererProperties(data->renderer), SDL_PROP_RENDERER_TEXTURE_FORMATS_POINTER, NULL); + if (!texture_formats) { + return false; + } + + // Free any old texture and pixel data + if (data->texture) { + SDL_DestroyTexture(data->texture); + data->texture = NULL; + } + SDL_free(data->pixels); + data->pixels = NULL; + + // Find the first format with or without an alpha channel + *format = texture_formats[0]; + + for (i = 0; texture_formats[i] != SDL_PIXELFORMAT_UNKNOWN; ++i) { + SDL_PixelFormat texture_format = texture_formats[i]; + if (!SDL_ISPIXELFORMAT_FOURCC(texture_format) && + !SDL_ISPIXELFORMAT_10BIT(texture_format) && + !SDL_ISPIXELFORMAT_FLOAT(texture_format) && + transparent == SDL_ISPIXELFORMAT_ALPHA(texture_format)) { + *format = texture_format; + break; + } + } + + data->texture = SDL_CreateTexture(data->renderer, *format, + SDL_TEXTUREACCESS_STREAMING, + w, h); + if (!data->texture) { + // codechecker_false_positive [Malloc] Static analyzer doesn't realize allocated `data` is saved to SDL_PROP_WINDOW_TEXTUREDATA_POINTER and not leaked here. + return false; // NOLINT(clang-analyzer-unix.Malloc) + } + + // Create framebuffer data + data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format); + data->pitch = (((w * data->bytes_per_pixel) + 3) & ~3); + + { + // Make static analysis happy about potential SDL_malloc(0) calls. + const size_t allocsize = (size_t)h * data->pitch; + data->pixels = SDL_malloc((allocsize > 0) ? allocsize : 1); + if (!data->pixels) { + return false; + } + } + + *pixels = data->pixels; + *pitch = data->pitch; + + // Make sure we're not double-scaling the viewport + SDL_SetRenderViewport(data->renderer, NULL); + + return true; +} + +bool SDL_SetWindowTextureVSync(SDL_VideoDevice *_this, SDL_Window *window, int vsync) +{ + SDL_WindowTextureData *data; + + data = (SDL_WindowTextureData *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL); + if (!data) { + return false; + } + if (!data->renderer) { + return false; + } + return SDL_SetRenderVSync(data->renderer, vsync); +} + +static bool SDL_GetWindowTextureVSync(SDL_VideoDevice *_this, SDL_Window *window, int *vsync) +{ + SDL_WindowTextureData *data; + + data = (SDL_WindowTextureData *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL); + if (!data) { + return false; + } + if (!data->renderer) { + return false; + } + return SDL_GetRenderVSync(data->renderer, vsync); +} + +static bool SDL_UpdateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_WindowTextureData *data; + SDL_Rect rect; + void *src; + int w, h; + + SDL_GetWindowSizeInPixels(window, &w, &h); + + data = (SDL_WindowTextureData *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER, NULL); + if (!data || !data->texture) { + return SDL_SetError("No window texture data"); + } + + // Update a single rect that contains subrects for best DMA performance + if (SDL_GetSpanEnclosingRect(w, h, numrects, rects, &rect)) { + src = (void *)((Uint8 *)data->pixels + + rect.y * data->pitch + + rect.x * data->bytes_per_pixel); + if (!SDL_UpdateTexture(data->texture, &rect, src, data->pitch)) { + return false; + } + + if (!SDL_RenderTexture(data->renderer, data->texture, NULL, NULL)) { + return false; + } + + SDL_RenderPresent(data->renderer); + } + return true; +} + +static void SDL_DestroyWindowTexture(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_ClearProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_TEXTUREDATA_POINTER); +} + +static SDL_VideoDevice *_this = NULL; +static SDL_AtomicInt SDL_messagebox_count; + +static int SDLCALL cmpmodes(const void *A, const void *B) +{ + const SDL_DisplayMode *a = (const SDL_DisplayMode *)A; + const SDL_DisplayMode *b = (const SDL_DisplayMode *)B; + int a_refresh_rate = (int)(a->refresh_rate * 100); + int b_refresh_rate = (int)(b->refresh_rate * 100); + int a_pixel_density = (int)(a->pixel_density * 100); + int b_pixel_density = (int)(b->pixel_density * 100); + + if (a->w != b->w) { + return b->w - a->w; + } else if (a->h != b->h) { + return b->h - a->h; + } else if (SDL_BITSPERPIXEL(a->format) != SDL_BITSPERPIXEL(b->format)) { + return SDL_BITSPERPIXEL(b->format) - SDL_BITSPERPIXEL(a->format); + } else if (SDL_PIXELLAYOUT(a->format) != SDL_PIXELLAYOUT(b->format)) { + return SDL_PIXELLAYOUT(b->format) - SDL_PIXELLAYOUT(a->format); + } else if (a_refresh_rate != b_refresh_rate) { + return b_refresh_rate - a_refresh_rate; + } else if (a_pixel_density != b_pixel_density) { + return a_pixel_density - b_pixel_density; + } + return 0; +} + +bool SDL_UninitializedVideo(void) +{ + return SDL_SetError("Video subsystem has not been initialized"); +} + +// Deduplicated list of video bootstrap drivers. +static const VideoBootStrap *deduped_bootstrap[SDL_arraysize(bootstrap) - 1]; + +int SDL_GetNumVideoDrivers(void) +{ + static int num_drivers = -1; + + if (num_drivers >= 0) { + return num_drivers; + } + + num_drivers = 0; + + // Build a list of unique video drivers. + for (int i = 0; bootstrap[i] != NULL; ++i) { + bool duplicate = false; + for (int j = 0; j < i; ++j) { + if (SDL_strcmp(bootstrap[i]->name, bootstrap[j]->name) == 0) { + duplicate = true; + break; + } + } + + if (!duplicate) { + deduped_bootstrap[num_drivers++] = bootstrap[i]; + } + } + + return num_drivers; +} + +const char *SDL_GetVideoDriver(int index) +{ + if (index >= 0 && index < SDL_GetNumVideoDrivers()) { + return deduped_bootstrap[index]->name; + } + SDL_InvalidParamError("index"); + return NULL; +} + +/* + * Initialize the video and event subsystems -- determine native pixel format + */ +bool SDL_VideoInit(const char *driver_name) +{ + SDL_VideoDevice *video; + bool init_events = false; + bool init_keyboard = false; + bool init_mouse = false; + bool init_touch = false; + bool init_pen = false; + int i = 0; + + // Check to make sure we don't overwrite '_this' + if (_this) { + SDL_VideoQuit(); + } + + SDL_InitTicks(); + + // Start the event loop + if (!SDL_InitSubSystem(SDL_INIT_EVENTS)) { + goto pre_driver_error; + } + init_events = true; + if (!SDL_InitKeyboard()) { + goto pre_driver_error; + } + init_keyboard = true; + if (!SDL_PreInitMouse()) { + goto pre_driver_error; + } + init_mouse = true; + if (!SDL_InitTouch()) { + goto pre_driver_error; + } + init_touch = true; + if (!SDL_InitPen()) { + goto pre_driver_error; + } + init_pen = true; + + // Select the proper video driver + video = NULL; + if (!driver_name) { + driver_name = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); + } + if (driver_name && *driver_name != 0) { + const char *driver_attempt = driver_name; + while (driver_attempt && *driver_attempt != 0 && !video) { + const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); + size_t driver_attempt_len = (driver_attempt_end) ? (driver_attempt_end - driver_attempt) + : SDL_strlen(driver_attempt); + + for (i = 0; bootstrap[i]; ++i) { + if (!bootstrap[i]->is_preferred && + (driver_attempt_len == SDL_strlen(bootstrap[i]->name)) && + (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0)) { + video = bootstrap[i]->create(); + if (video) { + break; + } + } + } + + driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL; + } + } else { + for (i = 0; bootstrap[i]; ++i) { + video = bootstrap[i]->create(); + if (video) { + break; + } + } + } + if (!video) { + if (driver_name) { + SDL_SetError("%s not available", driver_name); + goto pre_driver_error; + } + SDL_SetError("No available video device"); + goto pre_driver_error; + } + + /* From this point on, use SDL_VideoQuit to cleanup on error, rather than + pre_driver_error. */ + _this = video; + _this->name = bootstrap[i]->name; + _this->thread = SDL_GetCurrentThreadID(); + + // Set some very sane GL defaults + _this->gl_config.driver_loaded = 0; + _this->gl_config.dll_handle = NULL; + SDL_GL_ResetAttributes(); + + // Initialize the video subsystem + if (!_this->VideoInit(_this)) { + SDL_VideoQuit(); + return false; + } + + // Make sure some displays were added + if (_this->num_displays == 0) { + SDL_VideoQuit(); + return SDL_SetError("The video driver did not add any displays"); + } + + SDL_AddHintCallback(SDL_HINT_VIDEO_SYNC_WINDOW_OPERATIONS, SDL_SyncHintWatcher, NULL); + + /* Disable the screen saver by default. This is a change from <= 2.0.1, + but most things using SDL are games or media players; you wouldn't + want a screensaver to trigger if you're playing exclusively with a + joystick, or passively watching a movie. Things that use SDL but + function more like a normal desktop app should explicitly reenable the + screensaver. */ + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, false)) { + SDL_DisableScreenSaver(); + } + + SDL_PostInitMouse(); + + // We're ready to go! + return true; + +pre_driver_error: + SDL_assert(_this == NULL); + if (init_pen) { + SDL_QuitPen(); + } + if (init_touch) { + SDL_QuitTouch(); + } + if (init_mouse) { + SDL_QuitMouse(); + } + if (init_keyboard) { + SDL_QuitKeyboard(); + } + if (init_events) { + SDL_QuitSubSystem(SDL_INIT_EVENTS); + } + return false; +} + +const char *SDL_GetCurrentVideoDriver(void) +{ + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + return _this->name; +} + +SDL_VideoDevice *SDL_GetVideoDevice(void) +{ + return _this; +} + +bool SDL_OnVideoThread(void) +{ + return (_this && SDL_GetCurrentThreadID() == _this->thread); +} + +void SDL_SetSystemTheme(SDL_SystemTheme theme) +{ + if (_this && theme != _this->system_theme) { + _this->system_theme = theme; + SDL_SendSystemThemeChangedEvent(); + } +} + +SDL_SystemTheme SDL_GetSystemTheme(void) +{ + if (_this) { + return _this->system_theme; + } else { + return SDL_SYSTEM_THEME_UNKNOWN; + } +} + +void SDL_UpdateDesktopBounds(void) +{ + SDL_Rect rect; + SDL_zero(rect); + + SDL_DisplayID *displays = SDL_GetDisplays(NULL); + if (displays) { + for (int i = 0; displays[i]; ++i) { + SDL_Rect bounds; + if (SDL_GetDisplayBounds(displays[i], &bounds)) { + if (i == 0) { + SDL_copyp(&rect, &bounds); + } else { + SDL_GetRectUnion(&rect, &bounds, &rect); + } + } + } + SDL_free(displays); + } + SDL_copyp(&_this->desktop_bounds, &rect); +} + +static void SDL_FinalizeDisplayMode(SDL_DisplayMode *mode) +{ + // Make sure all the fields are set up correctly + if (mode->pixel_density <= 0.0f) { + mode->pixel_density = 1.0f; + } + + if (mode->refresh_rate_numerator > 0) { + if (mode->refresh_rate_denominator <= 0) { + mode->refresh_rate_denominator = 1; + } + mode->refresh_rate = ((100 * (Sint64)mode->refresh_rate_numerator) / mode->refresh_rate_denominator) / 100.0f; + } else { + SDL_CalculateFraction(mode->refresh_rate, &mode->refresh_rate_numerator, &mode->refresh_rate_denominator); + mode->refresh_rate = (int)(mode->refresh_rate * 100) / 100.0f; + } +} + +SDL_DisplayID SDL_AddBasicVideoDisplay(const SDL_DisplayMode *desktop_mode) +{ + SDL_VideoDisplay display; + + SDL_zero(display); + if (desktop_mode) { + SDL_memcpy(&display.desktop_mode, desktop_mode, sizeof(display.desktop_mode)); + } + return SDL_AddVideoDisplay(&display, false); +} + +SDL_DisplayID SDL_AddVideoDisplay(const SDL_VideoDisplay *display, bool send_event) +{ + SDL_VideoDisplay **displays, *new_display; + SDL_DisplayID id; + SDL_PropertiesID props; + int i; + + new_display = (SDL_VideoDisplay *)SDL_malloc(sizeof(*new_display)); + if (!new_display) { + return true; + } + + displays = (SDL_VideoDisplay **)SDL_realloc(_this->displays, (_this->num_displays + 1) * sizeof(*displays)); + if (!displays) { + SDL_free(new_display); + return true; + } + _this->displays = displays; + _this->displays[_this->num_displays++] = new_display; + + id = SDL_GetNextObjectID(); + SDL_copyp(new_display, display); + new_display->id = id; + new_display->device = _this; + if (display->name) { + new_display->name = SDL_strdup(display->name); + } else { + char name[32]; + + SDL_itoa(id, name, 10); + new_display->name = SDL_strdup(name); + } + if (new_display->content_scale == 0.0f) { + new_display->content_scale = 1.0f; + } + + new_display->desktop_mode.displayID = id; + new_display->current_mode = &new_display->desktop_mode; + SDL_FinalizeDisplayMode(&new_display->desktop_mode); + + for (i = 0; i < new_display->num_fullscreen_modes; ++i) { + new_display->fullscreen_modes[i].displayID = id; + } + + new_display->HDR.HDR_headroom = SDL_max(display->HDR.HDR_headroom, 1.0f); + new_display->HDR.SDR_white_level = SDL_max(display->HDR.SDR_white_level, 1.0f); + + props = SDL_GetDisplayProperties(id); + SDL_SetBooleanProperty(props, SDL_PROP_DISPLAY_HDR_ENABLED_BOOLEAN, new_display->HDR.HDR_headroom > 1.0f); + + SDL_UpdateDesktopBounds(); + + if (send_event) { + SDL_SendDisplayEvent(new_display, SDL_EVENT_DISPLAY_ADDED, 0, 0); + } + + return id; +} + +void SDL_OnDisplayAdded(SDL_VideoDisplay *display) +{ + SDL_Window *window; + + // See if any windows have changed to the new display + for (window = _this->windows; window; window = window->next) { + SDL_CheckWindowDisplayChanged(window); + } +} + +void SDL_OnDisplayMoved(SDL_VideoDisplay *display) +{ + SDL_UpdateDesktopBounds(); +} + +void SDL_DelVideoDisplay(SDL_DisplayID displayID, bool send_event) +{ + SDL_VideoDisplay *display; + int display_index = SDL_GetDisplayIndex(displayID); + if (display_index < 0) { + return; + } + + display = _this->displays[display_index]; + + if (send_event) { + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_REMOVED, 0, 0); + } + + SDL_DestroyProperties(display->props); + SDL_free(display->name); + SDL_ResetFullscreenDisplayModes(display); + SDL_free(display->desktop_mode.internal); + display->desktop_mode.internal = NULL; + SDL_free(display->internal); + display->internal = NULL; + SDL_free(display); + + if (display_index < (_this->num_displays - 1)) { + SDL_memmove(&_this->displays[display_index], &_this->displays[display_index + 1], (_this->num_displays - display_index - 1) * sizeof(_this->displays[display_index])); + } + --_this->num_displays; + + SDL_UpdateDesktopBounds(); +} + +SDL_DisplayID *SDL_GetDisplays(int *count) +{ + int i; + SDL_DisplayID *displays; + + if (!_this) { + if (count) { + *count = 0; + } + + SDL_UninitializedVideo(); + return NULL; + } + + displays = (SDL_DisplayID *)SDL_malloc((_this->num_displays + 1) * sizeof(*displays)); + if (displays) { + if (count) { + *count = _this->num_displays; + } + + for (i = 0; i < _this->num_displays; ++i) { + displays[i] = _this->displays[i]->id; + } + displays[i] = 0; + } else { + if (count) { + *count = 0; + } + } + return displays; +} + +SDL_VideoDisplay *SDL_GetVideoDisplay(SDL_DisplayID displayID) +{ + int display_index; + + display_index = SDL_GetDisplayIndex(displayID); + if (display_index < 0) { + return NULL; + } + return _this->displays[display_index]; +} + +SDL_VideoDisplay *SDL_GetVideoDisplayForWindow(SDL_Window *window) +{ + return SDL_GetVideoDisplay(SDL_GetDisplayForWindow(window)); +} + +SDL_DisplayID SDL_GetPrimaryDisplay(void) +{ + if (!_this || _this->num_displays == 0) { + SDL_UninitializedVideo(); + return 0; + } + return _this->displays[0]->id; +} + +int SDL_GetDisplayIndex(SDL_DisplayID displayID) +{ + int display_index; + + if (!_this) { + SDL_UninitializedVideo(); + return -1; + } + + for (display_index = 0; display_index < _this->num_displays; ++display_index) { + if (displayID == _this->displays[display_index]->id) { + return display_index; + } + } + SDL_SetError("Invalid display"); + return -1; +} + +SDL_DisplayData *SDL_GetDisplayDriverData(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, NULL); + + return display->internal; +} + +SDL_DisplayData *SDL_GetDisplayDriverDataForWindow(SDL_Window *window) +{ + return SDL_GetDisplayDriverData(SDL_GetDisplayForWindow(window)); +} + +SDL_PropertiesID SDL_GetDisplayProperties(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, 0); + + if (display->props == 0) { + display->props = SDL_CreateProperties(); + } + return display->props; +} + +const char *SDL_GetDisplayName(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, NULL); + + return display->name; +} + +bool SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, false); + + if (!rect) { + return SDL_InvalidParamError("rect"); + } + + if (_this->GetDisplayBounds) { + if (_this->GetDisplayBounds(_this, display, rect)) { + return true; + } + } + + // Assume that the displays are left to right + if (displayID == SDL_GetPrimaryDisplay()) { + rect->x = 0; + rect->y = 0; + } else { + SDL_GetDisplayBounds(_this->displays[SDL_GetDisplayIndex(displayID) - 1]->id, rect); + rect->x += rect->w; + } + rect->w = display->current_mode->w; + rect->h = display->current_mode->h; + return true; +} + +static int ParseDisplayUsableBoundsHint(SDL_Rect *rect) +{ + const char *hint = SDL_GetHint(SDL_HINT_DISPLAY_USABLE_BOUNDS); + return hint && (SDL_sscanf(hint, "%d,%d,%d,%d", &rect->x, &rect->y, &rect->w, &rect->h) == 4); +} + +bool SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, false); + + if (!rect) { + return SDL_InvalidParamError("rect"); + } + + if (displayID == SDL_GetPrimaryDisplay() && ParseDisplayUsableBoundsHint(rect)) { + return true; + } + + if (_this->GetDisplayUsableBounds) { + if (_this->GetDisplayUsableBounds(_this, display, rect)) { + return true; + } + } + + // Oh well, just give the entire display bounds. + return SDL_GetDisplayBounds(displayID, rect); +} + +SDL_DisplayOrientation SDL_GetNaturalDisplayOrientation(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, SDL_ORIENTATION_UNKNOWN); + + if (display->natural_orientation != SDL_ORIENTATION_UNKNOWN) { + return display->natural_orientation; + } else { + // Default to landscape if the driver hasn't set it + return SDL_ORIENTATION_LANDSCAPE; + } +} + +SDL_DisplayOrientation SDL_GetCurrentDisplayOrientation(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, SDL_ORIENTATION_UNKNOWN); + + if (display->current_orientation != SDL_ORIENTATION_UNKNOWN) { + return display->current_orientation; + } else { + // Default to landscape if the driver hasn't set it + return SDL_ORIENTATION_LANDSCAPE; + } +} + +void SDL_SetDisplayContentScale(SDL_VideoDisplay *display, float scale) +{ + if (scale != display->content_scale) { + SDL_Window *window; + + display->content_scale = scale; + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, 0, 0); + + // Check the windows on this display + for (window = _this->windows; window; window = window->next) { + if (display->id == window->last_displayID) { + SDL_CheckWindowDisplayScaleChanged(window); + } + } + } +} + +float SDL_GetDisplayContentScale(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, 0.0f); + + return display->content_scale; +} + +void SDL_SetWindowHDRProperties(SDL_Window *window, const SDL_HDROutputProperties *HDR, bool send_event) +{ + if (window->HDR.HDR_headroom != HDR->HDR_headroom || window->HDR.SDR_white_level != window->HDR.SDR_white_level) { + SDL_PropertiesID window_props = SDL_GetWindowProperties(window); + + SDL_SetFloatProperty(window_props, SDL_PROP_WINDOW_HDR_HEADROOM_FLOAT, SDL_max(HDR->HDR_headroom, 1.0f)); + SDL_SetFloatProperty(window_props, SDL_PROP_WINDOW_SDR_WHITE_LEVEL_FLOAT, SDL_max(HDR->SDR_white_level, 1.0f)); + SDL_SetBooleanProperty(window_props, SDL_PROP_WINDOW_HDR_ENABLED_BOOLEAN, HDR->HDR_headroom > 1.0f); + SDL_copyp(&window->HDR, HDR); + + if (send_event) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HDR_STATE_CHANGED, HDR->HDR_headroom > 1.0f, 0); + } + } +} + +void SDL_SetDisplayHDRProperties(SDL_VideoDisplay *display, const SDL_HDROutputProperties *HDR) +{ + bool changed = false; + + if (HDR->SDR_white_level != display->HDR.SDR_white_level) { + display->HDR.SDR_white_level = SDL_max(HDR->SDR_white_level, 1.0f); + changed = true; + } + if (HDR->HDR_headroom != display->HDR.HDR_headroom) { + display->HDR.HDR_headroom = SDL_max(HDR->HDR_headroom, 1.0f); + changed = true; + } + SDL_copyp(&display->HDR, HDR); + + if (changed && !SDL_DriverSendsHDRChanges(_this)) { + for (SDL_Window *w = display->device->windows; w; w = w->next) { + if (SDL_GetDisplayForWindow(w) == display->id) { + SDL_SetWindowHDRProperties(w, &display->HDR, true); + } + } + } +} + +static void SDL_UpdateFullscreenDisplayModes(SDL_VideoDisplay *display) +{ + if (display->num_fullscreen_modes == 0 && _this->GetDisplayModes) { + _this->GetDisplayModes(_this, display); + } +} + +// Return the matching mode as a pointer into our current mode list +static const SDL_DisplayMode *SDL_GetFullscreenModeMatch(const SDL_DisplayMode *mode) +{ + SDL_VideoDisplay *display; + SDL_DisplayMode fullscreen_mode; + + if (mode->w <= 0 || mode->h <= 0) { + // Use the desktop mode + return NULL; + } + + SDL_memcpy(&fullscreen_mode, mode, sizeof(fullscreen_mode)); + if (fullscreen_mode.displayID == 0) { + fullscreen_mode.displayID = SDL_GetPrimaryDisplay(); + } + SDL_FinalizeDisplayMode(&fullscreen_mode); + + mode = NULL; + + display = SDL_GetVideoDisplay(fullscreen_mode.displayID); + if (display) { + SDL_UpdateFullscreenDisplayModes(display); + + // Search for an exact match + if (!mode) { + for (int i = 0; i < display->num_fullscreen_modes; ++i) { + if (SDL_memcmp(&fullscreen_mode, &display->fullscreen_modes[i], sizeof(fullscreen_mode)) == 0) { + mode = &display->fullscreen_modes[i]; + break; + } + } + } + + // Search for a mode with the same characteristics + if (!mode) { + for (int i = 0; i < display->num_fullscreen_modes; ++i) { + if (cmpmodes(&fullscreen_mode, &display->fullscreen_modes[i]) == 0) { + mode = &display->fullscreen_modes[i]; + break; + } + } + } + } + return mode; +} + +bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) +{ + SDL_DisplayMode *modes; + SDL_DisplayMode new_mode; + int i, nmodes; + + // Finalize the mode for the display + SDL_memcpy(&new_mode, mode, sizeof(new_mode)); + new_mode.displayID = display->id; + SDL_FinalizeDisplayMode(&new_mode); + + // Make sure we don't already have the mode in the list + modes = display->fullscreen_modes; + nmodes = display->num_fullscreen_modes; + for (i = 0; i < nmodes; ++i) { + if (cmpmodes(&new_mode, &modes[i]) == 0) { + return false; + } + } + + // Go ahead and add the new mode + if (nmodes == display->max_fullscreen_modes) { + modes = (SDL_DisplayMode *)SDL_malloc((display->max_fullscreen_modes + 32) * sizeof(*modes)); + if (!modes) { + return false; + } + + if (display->fullscreen_modes) { + // Copy the list and update the current mode pointer, if necessary. + SDL_memcpy(modes, display->fullscreen_modes, nmodes * sizeof(*modes)); + for (i = 0; i < nmodes; ++i) { + if (display->current_mode == &display->fullscreen_modes[i]) { + display->current_mode = &modes[i]; + } + } + + SDL_free(display->fullscreen_modes); + } + + display->fullscreen_modes = modes; + display->max_fullscreen_modes += 32; + } + SDL_memcpy(&modes[display->num_fullscreen_modes++], &new_mode, sizeof(new_mode)); + + // Re-sort video modes + SDL_qsort(display->fullscreen_modes, display->num_fullscreen_modes, + sizeof(SDL_DisplayMode), cmpmodes); + + return true; +} + +void SDL_ResetFullscreenDisplayModes(SDL_VideoDisplay *display) +{ + int i; + + for (i = display->num_fullscreen_modes; i--;) { + SDL_free(display->fullscreen_modes[i].internal); + display->fullscreen_modes[i].internal = NULL; + } + SDL_free(display->fullscreen_modes); + display->fullscreen_modes = NULL; + display->num_fullscreen_modes = 0; + display->max_fullscreen_modes = 0; + display->current_mode = &display->desktop_mode; +} + +SDL_DisplayMode **SDL_GetFullscreenDisplayModes(SDL_DisplayID displayID, int *count) +{ + int i; + int num_modes; + SDL_DisplayMode **result; + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + if (count) { + *count = 0; + } + + CHECK_DISPLAY_MAGIC(display, NULL); + + SDL_UpdateFullscreenDisplayModes(display); + + num_modes = display->num_fullscreen_modes; + result = (SDL_DisplayMode **)SDL_malloc((num_modes + 1) * sizeof(*result) + num_modes * sizeof(**result)); + if (result) { + SDL_DisplayMode *modes = (SDL_DisplayMode *)((Uint8 *)result + ((num_modes + 1) * sizeof(*result))); + SDL_memcpy(modes, display->fullscreen_modes, num_modes * sizeof(*modes)); + for (i = 0; i < num_modes; ++i) { + result[i] = modes++; + } + result[i] = NULL; + + if (count) { + *count = num_modes; + } + } else { + if (count) { + *count = 0; + } + } + return result; +} + +bool SDL_GetClosestFullscreenDisplayMode(SDL_DisplayID displayID, int w, int h, float refresh_rate, bool include_high_density_modes, SDL_DisplayMode *result) +{ + if (!result) { + return SDL_InvalidParamError("closest"); // Parameter `result` is called `closest` in the header. + } + + const SDL_DisplayMode *mode, *closest = NULL; + float aspect_ratio; + int i; + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + SDL_zerop(result); + + CHECK_DISPLAY_MAGIC(display, false); + + if (h > 0) { + aspect_ratio = (float)w / h; + } else { + aspect_ratio = 1.0f; + } + + if (refresh_rate == 0.0f) { + refresh_rate = display->desktop_mode.refresh_rate; + } + + SDL_UpdateFullscreenDisplayModes(display); + + for (i = 0; i < display->num_fullscreen_modes; ++i) { + mode = &display->fullscreen_modes[i]; + + if (w > mode->w) { + // Out of sorted modes large enough here + break; + } + if (h > mode->h) { + /* Wider, but not tall enough, due to a different aspect ratio. + * This mode must be skipped, but closer modes may still follow */ + continue; + } + if (mode->pixel_density > 1.0f && !include_high_density_modes) { + continue; + } + if (closest) { + float current_aspect_ratio = (float)mode->w / mode->h; + float closest_aspect_ratio = (float)closest->w / closest->h; + if (SDL_fabsf(aspect_ratio - closest_aspect_ratio) < SDL_fabsf(aspect_ratio - current_aspect_ratio)) { + // The mode we already found has a better aspect ratio match + continue; + } + + if (mode->w == closest->w && mode->h == closest->h && + SDL_fabsf(closest->refresh_rate - refresh_rate) < SDL_fabsf(mode->refresh_rate - refresh_rate)) { + /* We already found a mode and the new mode is further from our + * refresh rate target */ + continue; + } + } + + closest = mode; + } + if (!closest) { + return SDL_SetError("Couldn't find any matching video modes"); + } + + SDL_copyp(result, closest); + + return true; +} + +static bool DisplayModeChanged(const SDL_DisplayMode *old_mode, const SDL_DisplayMode *new_mode) +{ + return ((old_mode->displayID && old_mode->displayID != new_mode->displayID) || + (old_mode->format && old_mode->format != new_mode->format) || + (old_mode->w && old_mode->h && (old_mode->w != new_mode->w ||old_mode->h != new_mode->h)) || + (old_mode->pixel_density != 0.0f && old_mode->pixel_density != new_mode->pixel_density) || + (old_mode->refresh_rate != 0.0f && old_mode->refresh_rate != new_mode->refresh_rate)); +} + +void SDL_SetDesktopDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) +{ + SDL_DisplayMode last_mode; + + if (display->fullscreen_active) { + // This is a temporary mode change, don't save the desktop mode + return; + } + + SDL_copyp(&last_mode, &display->desktop_mode); + + if (display->desktop_mode.internal) { + SDL_free(display->desktop_mode.internal); + } + SDL_copyp(&display->desktop_mode, mode); + display->desktop_mode.displayID = display->id; + SDL_FinalizeDisplayMode(&display->desktop_mode); + + if (DisplayModeChanged(&last_mode, &display->desktop_mode)) { + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_DESKTOP_MODE_CHANGED, mode->w, mode->h); + if (display->current_mode == &display->desktop_mode) { + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, mode->w, mode->h); + } + } +} + +const SDL_DisplayMode *SDL_GetDesktopDisplayMode(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, NULL); + + return &display->desktop_mode; +} + +void SDL_SetCurrentDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mode) +{ + SDL_DisplayMode last_mode; + + if (display->current_mode) { + SDL_copyp(&last_mode, display->current_mode); + } else { + SDL_zero(last_mode); + } + + display->current_mode = mode; + + if (DisplayModeChanged(&last_mode, mode)) { + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_CURRENT_MODE_CHANGED, mode->w, mode->h); + } +} + +const SDL_DisplayMode *SDL_GetCurrentDisplayMode(SDL_DisplayID displayID) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displayID); + + CHECK_DISPLAY_MAGIC(display, NULL); + + // Make sure our mode list is updated + SDL_UpdateFullscreenDisplayModes(display); + + return display->current_mode; +} + +bool SDL_SetDisplayModeForDisplay(SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + /* Mode switching is being emulated per-window; nothing to do and cannot fail, + * except for XWayland, which still needs the actual mode setting call since + * it's emulated via the XRandR interface. + */ + if (SDL_ModeSwitchingEmulated(_this) && SDL_strcmp(_this->name, "x11") != 0) { + return true; + } + + if (!mode) { + mode = &display->desktop_mode; + } + + if (mode == display->current_mode) { + return true; + } + + // Actually change the display mode + if (_this->SetDisplayMode) { + bool result; + + _this->setting_display_mode = true; + result = _this->SetDisplayMode(_this, display, mode); + _this->setting_display_mode = false; + if (!result) { + return false; + } + } + + SDL_SetCurrentDisplayMode(display, mode); + + return true; +} + +/** + * If x, y are outside of rect, snaps them to the closest point inside rect + * (between rect->x, rect->y, inclusive, and rect->x + w, rect->y + h, exclusive) + */ +static void SDL_GetClosestPointOnRect(const SDL_Rect *rect, SDL_Point *point) +{ + const int right = rect->x + rect->w - 1; + const int bottom = rect->y + rect->h - 1; + + if (point->x < rect->x) { + point->x = rect->x; + } else if (point->x > right) { + point->x = right; + } + + if (point->y < rect->y) { + point->y = rect->y; + } else if (point->y > bottom) { + point->y = bottom; + } +} + +static SDL_DisplayID GetDisplayForRect(int x, int y, int w, int h) +{ + int i, dist; + SDL_DisplayID closest = 0; + int closest_dist = 0x7FFFFFFF; + SDL_Point closest_point_on_display; + SDL_Point delta; + SDL_Point center; + center.x = x + w / 2; + center.y = y + h / 2; + + if (_this) { + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *display = _this->displays[i]; + SDL_Rect display_rect; + SDL_GetDisplayBounds(display->id, &display_rect); + + // Check if the window is fully enclosed + if (SDL_GetRectEnclosingPoints(¢er, 1, &display_rect, NULL)) { + return display->id; + } + + // Snap window center to the display rect + closest_point_on_display = center; + SDL_GetClosestPointOnRect(&display_rect, &closest_point_on_display); + + delta.x = center.x - closest_point_on_display.x; + delta.y = center.y - closest_point_on_display.y; + dist = (delta.x * delta.x + delta.y * delta.y); + if (dist < closest_dist) { + closest = display->id; + closest_dist = dist; + } + } + } + + if (closest == 0) { + SDL_SetError("Couldn't find any displays"); + } + + return closest; +} + +void SDL_RelativeToGlobalForWindow(SDL_Window *window, int rel_x, int rel_y, int *abs_x, int *abs_y) +{ + SDL_Window *w; + + if (SDL_WINDOW_IS_POPUP(window)) { + // Calculate the total offset of the popup from the parents + for (w = window->parent; w; w = w->parent) { + rel_x += w->x; + rel_y += w->y; + + if (!SDL_WINDOW_IS_POPUP(w)) { + break; + } + } + } + + if (abs_x) { + *abs_x = rel_x; + } + if (abs_y) { + *abs_y = rel_y; + } +} + +void SDL_GlobalToRelativeForWindow(SDL_Window *window, int abs_x, int abs_y, int *rel_x, int *rel_y) +{ + SDL_Window *w; + + if (SDL_WINDOW_IS_POPUP(window)) { + // Convert absolute window coordinates to relative for a popup + for (w = window->parent; w; w = w->parent) { + abs_x -= w->x; + abs_y -= w->y; + + if (!SDL_WINDOW_IS_POPUP(w)) { + break; + } + } + } + + if (rel_x) { + *rel_x = abs_x; + } + if (rel_y) { + *rel_y = abs_y; + } +} + +SDL_DisplayID SDL_GetDisplayForPoint(const SDL_Point *point) +{ + if (!point) { + SDL_InvalidParamError("point"); + return 0; + } + + return GetDisplayForRect(point->x, point->y, 1, 1); +} + +SDL_DisplayID SDL_GetDisplayForRect(const SDL_Rect *rect) +{ + if (!rect) { + SDL_InvalidParamError("rect"); + return 0; + } + + return GetDisplayForRect(rect->x, rect->y, rect->w, rect->h); +} + +SDL_DisplayID SDL_GetDisplayForWindowPosition(SDL_Window *window) +{ + int x, y; + SDL_DisplayID displayID = 0; + + CHECK_WINDOW_MAGIC(window, 0); + + if (_this->GetDisplayForWindow) { + displayID = _this->GetDisplayForWindow(_this, window); + } + + /* A backend implementation may fail to get a display for the window + * (for example if the window is off-screen), but other code may expect it + * to succeed in that situation, so we fall back to a generic position- + * based implementation in that case. */ + SDL_RelativeToGlobalForWindow(window, window->x, window->y, &x, &y); + + if (!displayID) { + /* Fullscreen windows may be larger than the display if they were moved between differently sized + * displays and the new position was received before the new size or vice versa. Using the center + * of the window rect in this case can report the wrong display, so use the origin. + */ + if (window->flags & SDL_WINDOW_FULLSCREEN) { + displayID = GetDisplayForRect(x, y, 1, 1); + } else { + displayID = GetDisplayForRect(x, y, window->w, window->h); + } + } + if (!displayID) { + // Use the primary display for a window if we can't find it anywhere else + displayID = SDL_GetPrimaryDisplay(); + } + return displayID; +} + +SDL_VideoDisplay *SDL_GetVideoDisplayForFullscreenWindow(SDL_Window *window) +{ + SDL_DisplayID displayID = 0; + + CHECK_WINDOW_MAGIC(window, 0); + + // An explicit fullscreen display overrides all + if (window->current_fullscreen_mode.displayID) { + displayID = window->current_fullscreen_mode.displayID; + } + + /* This is used to handle the very common pattern of SDL_SetWindowPosition() + * followed immediately by SDL_SetWindowFullscreen() to make the window fullscreen + * desktop on a specific display. If the backend doesn't support changing the + * window position, or an async window manager hasn't yet actually moved the window, + * the current position won't be updated at the time of the fullscreen call. + */ + if (!displayID) { + // Use the pending position and dimensions, if available, otherwise, use the current. + const int x = window->last_position_pending ? window->pending.x : window->x; + const int y = window->last_position_pending ? window->pending.y : window->y; + const int w = window->last_size_pending ? window->pending.w : window->w; + const int h = window->last_size_pending ? window->pending.h : window->h; + + displayID = GetDisplayForRect(x, y, w, h); + } + if (!displayID) { + // Use the primary display for a window if we can't find it anywhere else + displayID = SDL_GetPrimaryDisplay(); + } + return SDL_GetVideoDisplay(displayID); +} + +SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window) +{ + SDL_DisplayID displayID = 0; + + CHECK_WINDOW_MAGIC(window, 0); + + // An explicit fullscreen display overrides all + if (window->flags & SDL_WINDOW_FULLSCREEN) { + displayID = window->current_fullscreen_mode.displayID; + } + + if (!displayID) { + displayID = SDL_GetDisplayForWindowPosition(window); + } + return displayID; +} + +static void SDL_CheckWindowDisplayChanged(SDL_Window *window) +{ + if (SDL_SendsDisplayChanges(_this)) { + return; + } + + SDL_DisplayID displayID = SDL_GetDisplayForWindowPosition(window); + + if (displayID != window->last_displayID) { + int i, display_index; + + // Sanity check our fullscreen windows + display_index = SDL_GetDisplayIndex(displayID); + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *display = _this->displays[i]; + + if (display->fullscreen_window == window) { + if (display_index != i) { + if (display_index < 0) { + display_index = i; + } else { + SDL_VideoDisplay *new_display = _this->displays[display_index]; + + // The window was moved to a different display + if (new_display->fullscreen_window && + new_display->fullscreen_window != window) { + // Uh oh, there's already a fullscreen window here; minimize it + SDL_MinimizeWindow(new_display->fullscreen_window); + } + new_display->fullscreen_window = window; + display->fullscreen_window = NULL; + } + } + break; + } + } + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DISPLAY_CHANGED, (int)displayID, 0); + } +} + +float SDL_GetWindowPixelDensity(SDL_Window *window) +{ + int window_w, window_h, pixel_w, pixel_h; + float pixel_density = 1.0f; + + CHECK_WINDOW_MAGIC(window, 0.0f); + + if (SDL_GetWindowSize(window, &window_w, &window_h) && + SDL_GetWindowSizeInPixels(window, &pixel_w, &pixel_h)) { + pixel_density = (float)pixel_w / window_w; + } + return pixel_density; +} + +float SDL_GetWindowDisplayScale(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, 0.0f); + + return window->display_scale; +} + +static void SDL_CheckWindowDisplayScaleChanged(SDL_Window *window) +{ + float display_scale; + + if (_this->GetWindowContentScale) { + display_scale = _this->GetWindowContentScale(_this, window); + } else { + const float pixel_density = SDL_GetWindowPixelDensity(window); + const float content_scale = SDL_GetDisplayContentScale(SDL_GetDisplayForWindowPosition(window)); + + display_scale = pixel_density * content_scale; + } + + if (display_scale != window->display_scale) { + window->display_scale = display_scale; + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DISPLAY_SCALE_CHANGED, 0, 0); + } +} + +static void SDL_RestoreMousePosition(SDL_Window *window) +{ + float x, y; + SDL_Mouse *mouse = SDL_GetMouse(); + + if (window == SDL_GetMouseFocus()) { + const bool prev_warp_val = mouse->warp_emulation_prohibited; + SDL_GetMouseState(&x, &y); + + // Disable the warp emulation so it isn't accidentally activated on a fullscreen transitions. + mouse->warp_emulation_prohibited = true; + SDL_WarpMouseInWindow(window, x, y); + mouse->warp_emulation_prohibited = prev_warp_val; + } +} + +bool SDL_UpdateFullscreenMode(SDL_Window *window, SDL_FullscreenOp fullscreen, bool commit) +{ + SDL_VideoDisplay *display = NULL; + SDL_DisplayMode *mode = NULL; + int i; + + CHECK_WINDOW_MAGIC(window, false); + + window->fullscreen_exclusive = false; + + // If we are in the process of hiding don't go back to fullscreen + if (window->is_destroying || window->is_hiding) { + fullscreen = SDL_FULLSCREEN_OP_LEAVE; + } + + // Get the correct display for this operation + if (fullscreen) { + display = SDL_GetVideoDisplayForFullscreenWindow(window); + if (!display) { + // This should never happen, but it did... + goto done; + } + } else { + for (i = 0; i < _this->num_displays; ++i) { + display = _this->displays[i]; + if (display->fullscreen_window == window) { + break; + } + } + if (!display || i == _this->num_displays) { + // Already not fullscreen on any display + display = NULL; + } + } + + if (fullscreen) { + mode = (SDL_DisplayMode *)SDL_GetWindowFullscreenMode(window); + if (mode) { + window->fullscreen_exclusive = true; + } else { + // Make sure the current mode is zeroed for fullscreen desktop. + SDL_zero(window->current_fullscreen_mode); + } + } + +#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) + /* if the window is going away and no resolution change is necessary, + do nothing, or else we may trigger an ugly double-transition + */ + if (SDL_strcmp(_this->name, "cocoa") == 0) { // don't do this for X11, etc + if (window->is_destroying && !window->last_fullscreen_exclusive_display) { + window->fullscreen_exclusive = false; + if (display) { + display->fullscreen_window = NULL; + } + goto done; + } + if (commit) { + // If we're switching between a fullscreen Space and exclusive fullscreen, we need to get back to normal first. + if (fullscreen && Cocoa_IsWindowInFullscreenSpace(window) && !window->last_fullscreen_exclusive_display && window->fullscreen_exclusive) { + if (!Cocoa_SetWindowFullscreenSpace(window, false, true)) { + goto error; + } + } else if (fullscreen && window->last_fullscreen_exclusive_display && !window->fullscreen_exclusive) { + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *last_display = _this->displays[i]; + if (last_display->fullscreen_window == window) { + SDL_SetDisplayModeForDisplay(last_display, NULL); + if (_this->SetWindowFullscreen) { + _this->SetWindowFullscreen(_this, window, last_display, false); + } + last_display->fullscreen_window = NULL; + } + } + } + + if (Cocoa_SetWindowFullscreenSpace(window, !!fullscreen, syncHint)) { + goto done; + } + } + } +#endif + + if (display) { + // Restore the video mode on other displays if needed + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *other = _this->displays[i]; + if (other != display && other->fullscreen_window == window) { + SDL_SetDisplayModeForDisplay(other, NULL); + other->fullscreen_window = NULL; + } + } + } + + if (fullscreen) { + int mode_w = 0, mode_h = 0; + bool resized = false; + + // Hide any other fullscreen window on this display + if (display->fullscreen_window && + display->fullscreen_window != window) { + SDL_MinimizeWindow(display->fullscreen_window); + } + + display->fullscreen_active = window->fullscreen_exclusive; + + if (!SDL_SetDisplayModeForDisplay(display, mode)) { + goto error; + } + if (commit) { + SDL_FullscreenResult ret = SDL_FULLSCREEN_SUCCEEDED; + if (_this->SetWindowFullscreen) { + ret = _this->SetWindowFullscreen(_this, window, display, fullscreen); + } else { + resized = true; + } + + if (ret == SDL_FULLSCREEN_SUCCEEDED) { + // Window is fullscreen immediately upon return. If the driver hasn't already sent the event, do so now. + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); + } + } else if (ret == SDL_FULLSCREEN_FAILED) { + display->fullscreen_active = false; + goto error; + } + } + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + display->fullscreen_window = window; + + /* Android may not resize the window to exactly what our fullscreen mode is, + * especially on windowed Android environments like the Chromebook or Samsung DeX. + * Given this, we shouldn't use the mode size. Android's SetWindowFullscreen + * will generate the window event for us with the proper final size. + * + * This is also unnecessary on Cocoa, Wayland, Win32, and X11 (will send SDL_EVENT_WINDOW_RESIZED). + */ + if (!SDL_SendsFullscreenDimensions(_this)) { + SDL_Rect displayRect; + + if (mode) { + mode_w = mode->w; + mode_h = mode->h; + SDL_GetDisplayBounds(mode->displayID, &displayRect); + } else { + mode_w = display->desktop_mode.w; + mode_h = display->desktop_mode.h; + SDL_GetDisplayBounds(display->id, &displayRect); + } + + if (window->w != mode_w || window->h != mode_h) { + resized = true; + } + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, displayRect.x, displayRect.y); + + if (resized) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, mode_w, mode_h); + } else { + SDL_OnWindowResized(window); + } + } + + // Restore the cursor position + if (!SDL_DisableMouseWarpOnFullscreenTransitions(_this)) { + SDL_RestoreMousePosition(window); + } + } + } else { + bool resized = false; + + // Restore the desktop mode + if (display) { + display->fullscreen_active = false; + + SDL_SetDisplayModeForDisplay(display, NULL); + } + if (commit) { + SDL_FullscreenResult ret = SDL_FULLSCREEN_SUCCEEDED; + if (_this->SetWindowFullscreen) { + SDL_VideoDisplay *full_screen_display = display ? display : SDL_GetVideoDisplayForFullscreenWindow(window); + if (full_screen_display) { + ret = _this->SetWindowFullscreen(_this, window, full_screen_display, SDL_FULLSCREEN_OP_LEAVE); + } + } else { + resized = true; + } + + if (ret == SDL_FULLSCREEN_SUCCEEDED) { + // Window left fullscreen immediately upon return. If the driver hasn't already sent the event, do so now. + if (window->flags & SDL_WINDOW_FULLSCREEN) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + } + } else if (ret == SDL_FULLSCREEN_FAILED) { + goto error; + } + } + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + if (display) { + display->fullscreen_window = NULL; + } + + if (!SDL_SendsFullscreenDimensions(_this)) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, window->windowed.x, window->windowed.y); + if (resized) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->windowed.w, window->windowed.h); + } else { + SDL_OnWindowResized(window); + } + } + + // Restore the cursor position if we've exited fullscreen on a display + if (display && !SDL_DisableMouseWarpOnFullscreenTransitions(_this)) { + SDL_RestoreMousePosition(window); + } + } + } + +done: + window->last_fullscreen_exclusive_display = display && (window->flags & SDL_WINDOW_FULLSCREEN) && window->fullscreen_exclusive ? display->id : 0; + return true; + +error: + if (fullscreen) { + // Something went wrong and the window is no longer fullscreen. + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, commit); + } + return false; +} + +bool SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (mode) { + if (!SDL_GetFullscreenModeMatch(mode)) { + return SDL_SetError("Invalid fullscreen display mode"); + } + + // Save the mode so we can look up the closest match later + SDL_copyp(&window->requested_fullscreen_mode, mode); + } else { + SDL_zero(window->requested_fullscreen_mode); + } + + /* Copy to the current mode now, in case an asynchronous fullscreen window request + * is in progress. It will be overwritten if a new request is made. + */ + SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode); + if (SDL_WINDOW_FULLSCREEN_VISIBLE(window)) { + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true); + SDL_SyncIfRequired(window); + } + + return true; +} + +const SDL_DisplayMode *SDL_GetWindowFullscreenMode(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, NULL); + CHECK_WINDOW_NOT_POPUP(window, NULL); + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + return SDL_GetFullscreenModeMatch(&window->current_fullscreen_mode); + } else { + return SDL_GetFullscreenModeMatch(&window->requested_fullscreen_mode); + } +} + +void *SDL_GetWindowICCProfile(SDL_Window *window, size_t *size) +{ + if (!_this->GetWindowICCProfile) { + SDL_Unsupported(); + return NULL; + } + return _this->GetWindowICCProfile(_this, window, size); +} + +SDL_PixelFormat SDL_GetWindowPixelFormat(SDL_Window *window) +{ + SDL_DisplayID displayID; + const SDL_DisplayMode *mode; + + CHECK_WINDOW_MAGIC(window, SDL_PIXELFORMAT_UNKNOWN); + + displayID = SDL_GetDisplayForWindow(window); + mode = SDL_GetCurrentDisplayMode(displayID); + if (mode) { + return mode->format; + } else { + return SDL_PIXELFORMAT_UNKNOWN; + } +} + +#define CREATE_FLAGS \ + (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE | SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_VULKAN | SDL_WINDOW_MINIMIZED | SDL_WINDOW_METAL | SDL_WINDOW_TRANSPARENT | SDL_WINDOW_NOT_FOCUSABLE) + +static SDL_INLINE bool IsAcceptingDragAndDrop(void) +{ + if (SDL_EventEnabled(SDL_EVENT_DROP_FILE) || SDL_EventEnabled(SDL_EVENT_DROP_TEXT)) { + return true; + } + return false; +} + +// prepare a newly-created window +static SDL_INLINE void PrepareDragAndDropSupport(SDL_Window *window) +{ + if (_this->AcceptDragAndDrop) { + _this->AcceptDragAndDrop(window, IsAcceptingDragAndDrop()); + } +} + +// toggle d'n'd for all existing windows. +void SDL_ToggleDragAndDropSupport(void) +{ + if (_this && _this->AcceptDragAndDrop) { + const bool enable = IsAcceptingDragAndDrop(); + SDL_Window *window; + for (window = _this->windows; window; window = window->next) { + _this->AcceptDragAndDrop(window, enable); + } + } +} + +SDL_Window ** SDLCALL SDL_GetWindows(int *count) +{ + if (count) { + *count = 0; + } + + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + + SDL_Window *window; + int num_added = 0; + int num_windows = 0; + for (window = _this->windows; window; window = window->next) { + ++num_windows; + } + + SDL_Window **windows = (SDL_Window **)SDL_malloc((num_windows + 1) * sizeof(*windows)); + if (!windows) { + return NULL; + } + + for (window = _this->windows; window; window = window->next) { + windows[num_added++] = window; + if (num_added == num_windows) { + // Race condition? Multi-threading not supported, ignore it + break; + } + } + windows[num_added] = NULL; + + if (count) { + *count = num_added; + } + return windows; +} + +static void ApplyWindowFlags(SDL_Window *window, SDL_WindowFlags flags) +{ + if (!SDL_WINDOW_IS_POPUP(window)) { + if (!(flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED))) { + SDL_RestoreWindow(window); + } + if (flags & SDL_WINDOW_MAXIMIZED) { + SDL_MaximizeWindow(window); + } + + SDL_SetWindowFullscreen(window, (flags & SDL_WINDOW_FULLSCREEN) != 0); + + if (flags & SDL_WINDOW_MINIMIZED) { + SDL_MinimizeWindow(window); + } + + if (flags & SDL_WINDOW_MODAL) { + SDL_SetWindowModal(window, true); + } + + if (flags & SDL_WINDOW_MOUSE_GRABBED) { + SDL_SetWindowMouseGrab(window, true); + } + if (flags & SDL_WINDOW_KEYBOARD_GRABBED) { + SDL_SetWindowKeyboardGrab(window, true); + } + } +} + +static void SDL_FinishWindowCreation(SDL_Window *window, SDL_WindowFlags flags) +{ + PrepareDragAndDropSupport(window); + + if (window->flags & SDL_WINDOW_EXTERNAL) { + // Whoever has created the window has already applied whatever flags are needed + } else { + ApplyWindowFlags(window, flags); + if (!(flags & SDL_WINDOW_HIDDEN)) { + SDL_ShowWindow(window); + } + } +} + +static bool SDL_ContextNotSupported(const char *name) +{ + return SDL_SetError("%s support is either not configured in SDL " + "or not available in current SDL video driver " + "(%s) or platform", + name, + _this->name); +} + +static bool SDL_DllNotSupported(const char *name) +{ + return SDL_SetError("No dynamic %s support in current SDL video driver (%s)", name, _this->name); +} + +static struct { + const char *property_name; + SDL_WindowFlags flag; + bool invert_value; +} SDL_WindowFlagProperties[] = { + { SDL_PROP_WINDOW_CREATE_ALWAYS_ON_TOP_BOOLEAN, SDL_WINDOW_ALWAYS_ON_TOP, false }, + { SDL_PROP_WINDOW_CREATE_BORDERLESS_BOOLEAN, SDL_WINDOW_BORDERLESS, false }, + { SDL_PROP_WINDOW_CREATE_FOCUSABLE_BOOLEAN, SDL_WINDOW_NOT_FOCUSABLE, true }, + { SDL_PROP_WINDOW_CREATE_FULLSCREEN_BOOLEAN, SDL_WINDOW_FULLSCREEN, false }, + { SDL_PROP_WINDOW_CREATE_HIDDEN_BOOLEAN, SDL_WINDOW_HIDDEN, false }, + { SDL_PROP_WINDOW_CREATE_HIGH_PIXEL_DENSITY_BOOLEAN, SDL_WINDOW_HIGH_PIXEL_DENSITY, false }, + { SDL_PROP_WINDOW_CREATE_MAXIMIZED_BOOLEAN, SDL_WINDOW_MAXIMIZED, false }, + { SDL_PROP_WINDOW_CREATE_MENU_BOOLEAN, SDL_WINDOW_POPUP_MENU, false }, + { SDL_PROP_WINDOW_CREATE_METAL_BOOLEAN, SDL_WINDOW_METAL, false }, + { SDL_PROP_WINDOW_CREATE_MINIMIZED_BOOLEAN, SDL_WINDOW_MINIMIZED, false }, + { SDL_PROP_WINDOW_CREATE_MODAL_BOOLEAN, SDL_WINDOW_MODAL, false }, + { SDL_PROP_WINDOW_CREATE_MOUSE_GRABBED_BOOLEAN, SDL_WINDOW_MOUSE_GRABBED, false }, + { SDL_PROP_WINDOW_CREATE_OPENGL_BOOLEAN, SDL_WINDOW_OPENGL, false }, + { SDL_PROP_WINDOW_CREATE_RESIZABLE_BOOLEAN, SDL_WINDOW_RESIZABLE, false }, + { SDL_PROP_WINDOW_CREATE_TRANSPARENT_BOOLEAN, SDL_WINDOW_TRANSPARENT, false }, + { SDL_PROP_WINDOW_CREATE_TOOLTIP_BOOLEAN, SDL_WINDOW_TOOLTIP, false }, + { SDL_PROP_WINDOW_CREATE_UTILITY_BOOLEAN, SDL_WINDOW_UTILITY, false }, + { SDL_PROP_WINDOW_CREATE_VULKAN_BOOLEAN, SDL_WINDOW_VULKAN, false } +}; + +static SDL_WindowFlags SDL_GetWindowFlagProperties(SDL_PropertiesID props) +{ + unsigned i; + SDL_WindowFlags flags = (SDL_WindowFlags)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, 0); + + for (i = 0; i < SDL_arraysize(SDL_WindowFlagProperties); ++i) { + if (SDL_WindowFlagProperties[i].invert_value) { + if (!SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, true)) { + flags |= SDL_WindowFlagProperties[i].flag; + } + } else { + if (SDL_GetBooleanProperty(props, SDL_WindowFlagProperties[i].property_name, false)) { + flags |= SDL_WindowFlagProperties[i].flag; + } + } + } + return flags; +} + +SDL_Window *SDL_CreateWindowWithProperties(SDL_PropertiesID props) +{ + SDL_Window *window; + const char *title = SDL_GetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, NULL); + int x = (int)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, SDL_WINDOWPOS_UNDEFINED); + int y = (int)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, SDL_WINDOWPOS_UNDEFINED); + int w = (int)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, 0); + int h = (int)SDL_GetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, 0); + SDL_Window *parent = (SDL_Window *)SDL_GetPointerProperty(props, SDL_PROP_WINDOW_CREATE_PARENT_POINTER, NULL); + SDL_WindowFlags flags = SDL_GetWindowFlagProperties(props); + SDL_WindowFlags type_flags, graphics_flags; + bool undefined_x = false; + bool undefined_y = false; + bool external_graphics_context = SDL_GetBooleanProperty(props, SDL_PROP_WINDOW_CREATE_EXTERNAL_GRAPHICS_CONTEXT_BOOLEAN, false); + + if (!_this) { + // Initialize the video system if needed + if (!SDL_Init(SDL_INIT_VIDEO)) { + return NULL; + } + + // Make clang-tidy happy + if (!_this) { + return NULL; + } + } + + if ((flags & SDL_WINDOW_MODAL) && !SDL_ObjectValid(parent, SDL_OBJECT_TYPE_WINDOW)) { + SDL_SetError("Modal windows must specify a parent window"); + return NULL; + } + + if ((flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU)) != 0) { + if (!(_this->device_caps & VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT)) { + SDL_Unsupported(); + return NULL; + } + + // Tooltip and popup menu window must specify a parent window + if (!SDL_ObjectValid(parent, SDL_OBJECT_TYPE_WINDOW)) { + SDL_SetError("Tooltip and popup menu windows must specify a parent window"); + return NULL; + } + + // Remove invalid flags + flags &= ~(SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS); + } + + // Ensure no more than one of these flags is set + type_flags = flags & (SDL_WINDOW_UTILITY | SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_MODAL); + if (type_flags & (type_flags - 1)) { + SDL_SetError("Conflicting window type flags specified: 0x%.8x", (unsigned int)type_flags); + return NULL; + } + + // Make sure the display list is up to date for window placement + if (_this->RefreshDisplays) { + _this->RefreshDisplays(_this); + } + + // Some platforms can't create zero-sized windows + if (w < 1) { + w = 1; + } + if (h < 1) { + h = 1; + } + + if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISUNDEFINED(y) || + SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { + SDL_DisplayID displayID = 0; + SDL_Rect bounds; + + if ((SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) && (x & 0xFFFF)) { + displayID = (x & 0xFFFF); + } else if ((SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) && (y & 0xFFFF)) { + displayID = (y & 0xFFFF); + } + if (displayID == 0 || SDL_GetDisplayIndex(displayID) < 0) { + displayID = SDL_GetPrimaryDisplay(); + } + + SDL_zero(bounds); + SDL_GetDisplayUsableBounds(displayID, &bounds); + if (w > bounds.w || h > bounds.h) { + // This window is larger than the usable bounds, just center on the display + SDL_GetDisplayBounds(displayID, &bounds); + } + if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISUNDEFINED(x)) { + if (SDL_WINDOWPOS_ISUNDEFINED(x)) { + undefined_x = true; + } + x = bounds.x + (bounds.w - w) / 2; + } + if (SDL_WINDOWPOS_ISCENTERED(y) || SDL_WINDOWPOS_ISUNDEFINED(y)) { + if (SDL_WINDOWPOS_ISUNDEFINED(y)) { + undefined_y = true; + } + y = bounds.y + (bounds.h - h) / 2; + } + } + + // ensure no more than one of these flags is set + graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN); + if (graphics_flags & (graphics_flags - 1)) { + SDL_SetError("Conflicting window graphics flags specified: 0x%.8x", (unsigned int)graphics_flags); + return NULL; + } + + // Some platforms have certain graphics backends enabled by default + if (!graphics_flags && !external_graphics_context) { + flags |= SDL_DefaultGraphicsBackends(_this); + } + + if (flags & SDL_WINDOW_OPENGL) { + if (!_this->GL_CreateContext) { + SDL_ContextNotSupported("OpenGL"); + return NULL; + } + if (!SDL_GL_LoadLibrary(NULL)) { + return NULL; + } + } + + if (flags & SDL_WINDOW_VULKAN) { + if (!_this->Vulkan_CreateSurface) { + SDL_ContextNotSupported("Vulkan"); + return NULL; + } + if (!SDL_Vulkan_LoadLibrary(NULL)) { + return NULL; + } + } + + if (flags & SDL_WINDOW_METAL) { + if (!_this->Metal_CreateView) { + SDL_ContextNotSupported("Metal"); + return NULL; + } + } + + window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); + if (!window) { + return NULL; + } + SDL_SetObjectValid(window, SDL_OBJECT_TYPE_WINDOW, true); + window->id = SDL_GetNextObjectID(); + window->floating.x = window->windowed.x = window->x = x; + window->floating.y = window->windowed.y = window->y = y; + window->floating.w = window->windowed.w = window->w = w; + window->floating.h = window->windowed.h = window->h = h; + window->undefined_x = undefined_x; + window->undefined_y = undefined_y; + + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + if (display) { + SDL_SetWindowHDRProperties(window, &display->HDR, false); + } + + if (flags & SDL_WINDOW_FULLSCREEN || IsFullscreenOnly(_this)) { + SDL_Rect bounds; + + SDL_GetDisplayBounds(display ? display->id : SDL_GetPrimaryDisplay(), &bounds); + window->x = bounds.x; + window->y = bounds.y; + window->w = bounds.w; + window->h = bounds.h; + window->pending_flags |= SDL_WINDOW_FULLSCREEN; + flags |= SDL_WINDOW_FULLSCREEN; + } + + window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN); + window->display_scale = 1.0f; + window->opacity = 1.0f; + window->next = _this->windows; + window->is_destroying = false; + window->last_displayID = SDL_GetDisplayForWindow(window); + window->external_graphics_context = external_graphics_context; + + if (_this->windows) { + _this->windows->prev = window; + } + _this->windows = window; + + // Set the parent before creation. + SDL_UpdateWindowHierarchy(window, parent); + + if (_this->CreateSDLWindow && !_this->CreateSDLWindow(_this, window, props)) { + SDL_DestroyWindow(window); + return NULL; + } + + /* Clear minimized if not on windows, only windows handles it at create rather than FinishWindowCreation, + * but it's important or window focus will get broken on windows! + */ +#if !defined(SDL_PLATFORM_WINDOWS) + if (window->flags & SDL_WINDOW_MINIMIZED) { + window->flags &= ~SDL_WINDOW_MINIMIZED; + } +#endif + + if (title) { + SDL_SetWindowTitle(window, title); + } + SDL_FinishWindowCreation(window, flags); + + // Make sure window pixel size is up to date + SDL_CheckWindowPixelSizeChanged(window); + +#ifdef SDL_VIDEO_DRIVER_UIKIT + SDL_UpdateLifecycleObserver(); +#endif + + SDL_ClearError(); + + return window; +} + +SDL_Window *SDL_CreateWindow(const char *title, int w, int h, SDL_WindowFlags flags) +{ + SDL_Window *window; + SDL_PropertiesID props = SDL_CreateProperties(); + if (title && *title) { + SDL_SetStringProperty(props, SDL_PROP_WINDOW_CREATE_TITLE_STRING, title); + } + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, w); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, h); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, flags); + window = SDL_CreateWindowWithProperties(props); + SDL_DestroyProperties(props); + return window; +} + +SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, SDL_WindowFlags flags) +{ + SDL_Window *window; + SDL_PropertiesID props = SDL_CreateProperties(); + + // Popups must specify either the tooltip or popup menu window flags + if (!(flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_POPUP_MENU))) { + SDL_SetError("Popup windows must specify either the 'SDL_WINDOW_TOOLTIP' or the 'SDL_WINDOW_POPUP_MENU' flag"); + return NULL; + } + + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_CREATE_PARENT_POINTER, parent); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_X_NUMBER, offset_x); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_Y_NUMBER, offset_y); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_WIDTH_NUMBER, w); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_HEIGHT_NUMBER, h); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_CREATE_FLAGS_NUMBER, flags); + window = SDL_CreateWindowWithProperties(props); + SDL_DestroyProperties(props); + return window; +} + +bool SDL_RecreateWindow(SDL_Window *window, SDL_WindowFlags flags) +{ + bool loaded_opengl = false; + bool need_gl_unload = false; + bool need_gl_load = false; + bool loaded_vulkan = false; + bool need_vulkan_unload = false; + bool need_vulkan_load = false; + SDL_WindowFlags graphics_flags; + + // ensure no more than one of these flags is set + graphics_flags = flags & (SDL_WINDOW_OPENGL | SDL_WINDOW_METAL | SDL_WINDOW_VULKAN); + if (graphics_flags & (graphics_flags - 1)) { + return SDL_SetError("Conflicting window flags specified"); + } + + if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) { + return SDL_ContextNotSupported("OpenGL"); + } + if ((flags & SDL_WINDOW_VULKAN) && !_this->Vulkan_CreateSurface) { + return SDL_ContextNotSupported("Vulkan"); + } + if ((flags & SDL_WINDOW_METAL) && !_this->Metal_CreateView) { + return SDL_ContextNotSupported("Metal"); + } + + if (window->flags & SDL_WINDOW_EXTERNAL) { + // Can't destroy and re-create external windows, hrm + flags |= SDL_WINDOW_EXTERNAL; + } else { + flags &= ~SDL_WINDOW_EXTERNAL; + } + + // If this is a modal dialog, clear the modal status. + if (window->flags & SDL_WINDOW_MODAL) { + SDL_SetWindowModal(window, false); + } + + // Restore video mode, etc. + if (!(window->flags & SDL_WINDOW_EXTERNAL)) { + const bool restore_on_show = window->restore_on_show; + SDL_HideWindow(window); + window->restore_on_show = restore_on_show; + } + + // Tear down the old native window + SDL_DestroyWindowSurface(window); + + if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) { + if (flags & SDL_WINDOW_OPENGL) { + need_gl_load = true; + } else { + need_gl_unload = true; + } + } else if (window->flags & SDL_WINDOW_OPENGL) { + need_gl_unload = true; + need_gl_load = true; + } + + if ((window->flags & SDL_WINDOW_VULKAN) != (flags & SDL_WINDOW_VULKAN)) { + if (flags & SDL_WINDOW_VULKAN) { + need_vulkan_load = true; + } else { + need_vulkan_unload = true; + } + } else if (window->flags & SDL_WINDOW_VULKAN) { + need_vulkan_unload = true; + need_vulkan_load = true; + } + + if (need_gl_unload) { + SDL_GL_UnloadLibrary(); + } + + if (need_vulkan_unload) { + SDL_Vulkan_UnloadLibrary(); + } + + if (_this->DestroyWindow && !(flags & SDL_WINDOW_EXTERNAL)) { + _this->DestroyWindow(_this, window); + } + + if (need_gl_load) { + if (!SDL_GL_LoadLibrary(NULL)) { + return false; + } + loaded_opengl = true; + } + + if (need_vulkan_load) { + if (!SDL_Vulkan_LoadLibrary(NULL)) { + return false; + } + loaded_vulkan = true; + } + + window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN); + window->is_destroying = false; + + if (_this->CreateSDLWindow && !(flags & SDL_WINDOW_EXTERNAL)) { + /* Reset the window size to the original floating value, so the + * recreated window has the proper base size. + */ + window->x = window->windowed.x = window->floating.x; + window->y = window->windowed.y = window->floating.y; + window->w = window->windowed.w = window->floating.w; + window->h = window->windowed.h = window->floating.h; + + if (!_this->CreateSDLWindow(_this, window, 0)) { + if (loaded_opengl) { + SDL_GL_UnloadLibrary(); + window->flags &= ~SDL_WINDOW_OPENGL; + } + if (loaded_vulkan) { + SDL_Vulkan_UnloadLibrary(); + window->flags &= ~SDL_WINDOW_VULKAN; + } + return false; + } + } + + if (flags & SDL_WINDOW_EXTERNAL) { + window->flags |= SDL_WINDOW_EXTERNAL; + } + + if (_this->SetWindowTitle && window->title) { + _this->SetWindowTitle(_this, window); + } + + if (_this->SetWindowIcon && window->icon) { + _this->SetWindowIcon(_this, window, window->icon); + } + + if (_this->SetWindowMinimumSize && (window->min_w || window->min_h)) { + _this->SetWindowMinimumSize(_this, window); + } + + if (_this->SetWindowMaximumSize && (window->max_w || window->max_h)) { + _this->SetWindowMaximumSize(_this, window); + } + + if (_this->SetWindowAspectRatio && (window->min_aspect > 0.0f || window->max_aspect > 0.0f)) { + _this->SetWindowAspectRatio(_this, window); + } + + if (window->hit_test) { + _this->SetWindowHitTest(window, true); + } + + SDL_FinishWindowCreation(window, flags); + + return true; +} + +bool SDL_HasWindows(void) +{ + return _this && _this->windows; +} + +SDL_WindowID SDL_GetWindowID(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, 0); + + return window->id; +} + +SDL_Window *SDL_GetWindowFromID(SDL_WindowID id) +{ + SDL_Window *window; + + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + if (id) { + for (window = _this->windows; window; window = window->next) { + if (window->id == id) { + return window; + } + } + } + SDL_SetError("Invalid window ID"); \ + return NULL; +} + +SDL_Window *SDL_GetWindowParent(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, NULL); + + return window->parent; +} + +SDL_PropertiesID SDL_GetWindowProperties(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, 0); + + if (window->props == 0) { + window->props = SDL_CreateProperties(); + } + return window->props; +} + +SDL_WindowFlags SDL_GetWindowFlags(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, 0); + + return window->flags | window->pending_flags; +} + +bool SDL_SetWindowTitle(SDL_Window *window, const char *title) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (title == window->title) { + return true; + } + if (!title) { + title = ""; + } + if (window->title && SDL_strcmp(title, window->title) == 0) { + return true; + } + + SDL_free(window->title); + + window->title = SDL_strdup(title); + + if (_this->SetWindowTitle) { + _this->SetWindowTitle(_this, window); + } + return true; +} + +const char *SDL_GetWindowTitle(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, ""); + + return window->title ? window->title : ""; +} + +bool SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (!icon) { + return SDL_InvalidParamError("icon"); + } + + SDL_DestroySurface(window->icon); + + // Convert the icon into ARGB8888 + window->icon = SDL_ConvertSurface(icon, SDL_PIXELFORMAT_ARGB8888); + if (!window->icon) { + return false; + } + + if (!_this->SetWindowIcon) { + return SDL_Unsupported(); + } + + return _this->SetWindowIcon(_this, window, window->icon); +} + +bool SDL_SetWindowPosition(SDL_Window *window, int x, int y) +{ + SDL_DisplayID original_displayID; + + CHECK_WINDOW_MAGIC(window, false); + + const int w = window->last_size_pending ? window->pending.w : window->windowed.w; + const int h = window->last_size_pending ? window->pending.h : window->windowed.h; + + original_displayID = SDL_GetDisplayForWindow(window); + + if (SDL_WINDOWPOS_ISUNDEFINED(x)) { + x = window->windowed.x; + } + if (SDL_WINDOWPOS_ISUNDEFINED(y)) { + y = window->windowed.y; + } + if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { + SDL_DisplayID displayID = original_displayID; + SDL_Rect bounds; + + if (SDL_WINDOWPOS_ISCENTERED(x) && (x & 0xFFFF)) { + displayID = (x & 0xFFFF); + } else if (SDL_WINDOWPOS_ISCENTERED(y) && (y & 0xFFFF)) { + displayID = (y & 0xFFFF); + } + if (displayID == 0 || SDL_GetDisplayIndex(displayID) < 0) { + displayID = SDL_GetPrimaryDisplay(); + } + + SDL_zero(bounds); + if (!SDL_GetDisplayUsableBounds(displayID, &bounds) || w > bounds.w || h > bounds.h) { + if (!SDL_GetDisplayBounds(displayID, &bounds)) { + return false; + } + } + if (SDL_WINDOWPOS_ISCENTERED(x)) { + x = bounds.x + (bounds.w - w) / 2; + } + if (SDL_WINDOWPOS_ISCENTERED(y)) { + y = bounds.y + (bounds.h - h) / 2; + } + } + + window->pending.x = x; + window->pending.y = y; + window->undefined_x = false; + window->undefined_y = false; + window->last_position_pending = true; + + if (_this->SetWindowPosition) { + const bool result = _this->SetWindowPosition(_this, window); + if (result) { + SDL_SyncIfRequired(window); + } + return result; + } + + return SDL_Unsupported(); +} + +bool SDL_GetWindowPosition(SDL_Window *window, int *x, int *y) +{ + CHECK_WINDOW_MAGIC(window, false); + + // Fullscreen windows are always at their display's origin + if (window->flags & SDL_WINDOW_FULLSCREEN) { + SDL_DisplayID displayID; + + if (x) { + *x = 0; + } + if (y) { + *y = 0; + } + + /* Find the window's monitor and update to the + monitor offset. */ + displayID = SDL_GetDisplayForWindow(window); + if (displayID != 0) { + SDL_Rect bounds; + + SDL_zero(bounds); + + SDL_GetDisplayBounds(displayID, &bounds); + if (x) { + *x = bounds.x; + } + if (y) { + *y = bounds.y; + } + } + } else { + if (x) { + *x = window->x; + } + if (y) { + *y = window->y; + } + } + return true; +} + +bool SDL_SetWindowBordered(SDL_Window *window, bool bordered) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + const bool want = (bordered != false); // normalize the flag. + const bool have = !(window->flags & SDL_WINDOW_BORDERLESS); + if ((want != have) && (_this->SetWindowBordered)) { + if (want) { + window->flags &= ~SDL_WINDOW_BORDERLESS; + } else { + window->flags |= SDL_WINDOW_BORDERLESS; + } + _this->SetWindowBordered(_this, window, want); + } + + return true; +} + +bool SDL_SetWindowResizable(SDL_Window *window, bool resizable) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + const bool want = (resizable != false); // normalize the flag. + const bool have = ((window->flags & SDL_WINDOW_RESIZABLE) != 0); + if ((want != have) && (_this->SetWindowResizable)) { + if (want) { + window->flags |= SDL_WINDOW_RESIZABLE; + } else { + window->flags &= ~SDL_WINDOW_RESIZABLE; + SDL_copyp(&window->windowed, &window->floating); + } + _this->SetWindowResizable(_this, window, want); + } + + return true; +} + +bool SDL_SetWindowAlwaysOnTop(SDL_Window *window, bool on_top) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + const bool want = (on_top != false); // normalize the flag. + const bool have = ((window->flags & SDL_WINDOW_ALWAYS_ON_TOP) != 0); + if ((want != have) && (_this->SetWindowAlwaysOnTop)) { + if (want) { + window->flags |= SDL_WINDOW_ALWAYS_ON_TOP; + } else { + window->flags &= ~SDL_WINDOW_ALWAYS_ON_TOP; + } + _this->SetWindowAlwaysOnTop(_this, window, want); + } + + return true; +} + +bool SDL_SetWindowSize(SDL_Window *window, int w, int h) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (w <= 0) { + return SDL_InvalidParamError("w"); + } + if (h <= 0) { + return SDL_InvalidParamError("h"); + } + + // It is possible for the aspect ratio constraints to not satisfy the size constraints. + // The size constraints will override the aspect ratio constraints so we will apply the + // the aspect ratio constraints first + float new_aspect = w / (float)h; + if (window->max_aspect > 0.0f && new_aspect > window->max_aspect) { + w = (int)SDL_roundf(h * window->max_aspect); + } else if (window->min_aspect > 0.0f && new_aspect < window->min_aspect) { + h = (int)SDL_roundf(w / window->min_aspect); + } + + // Make sure we don't exceed any window size limits + if (window->min_w && w < window->min_w) { + w = window->min_w; + } + if (window->max_w && w > window->max_w) { + w = window->max_w; + } + if (window->min_h && h < window->min_h) { + h = window->min_h; + } + if (window->max_h && h > window->max_h) { + h = window->max_h; + } + + window->last_size_pending = true; + window->pending.w = w; + window->pending.h = h; + + if (_this->SetWindowSize) { + _this->SetWindowSize(_this, window); + SDL_SyncIfRequired(window); + } else { + return SDL_Unsupported(); + } + return true; +} + +bool SDL_GetWindowSize(SDL_Window *window, int *w, int *h) +{ + CHECK_WINDOW_MAGIC(window, false); + if (w) { + *w = window->w; + } + if (h) { + *h = window->h; + } + return true; +} + +bool SDL_SetWindowAspectRatio(SDL_Window *window, float min_aspect, float max_aspect) +{ + CHECK_WINDOW_MAGIC(window, false); + + window->min_aspect = min_aspect; + window->max_aspect = max_aspect; + if (_this->SetWindowAspectRatio) { + _this->SetWindowAspectRatio(_this, window); + } + return SDL_SetWindowSize(window, window->floating.w, window->floating.h); +} + +bool SDL_GetWindowAspectRatio(SDL_Window *window, float *min_aspect, float *max_aspect) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (min_aspect) { + *min_aspect = window->min_aspect; + } + if (max_aspect) { + *max_aspect = window->max_aspect; + } + return true; +} + +bool SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *bottom, int *right) +{ + int dummy = 0; + + if (!top) { + top = &dummy; + } + if (!left) { + left = &dummy; + } + if (!right) { + right = &dummy; + } + if (!bottom) { + bottom = &dummy; + } + + // Always initialize, so applications don't have to care + *top = *left = *bottom = *right = 0; + + CHECK_WINDOW_MAGIC(window, false); + + if (!_this->GetWindowBordersSize) { + return SDL_Unsupported(); + } + + return _this->GetWindowBordersSize(_this, window, top, left, bottom, right); +} + +bool SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) +{ + int filter; + + CHECK_WINDOW_MAGIC(window, false); + + if (!w) { + w = &filter; + } + + if (!h) { + h = &filter; + } + + if (_this->GetWindowSizeInPixels) { + _this->GetWindowSizeInPixels(_this, window, w, h); + } else { + SDL_DisplayID displayID = SDL_GetDisplayForWindow(window); + const SDL_DisplayMode *mode; + + SDL_GetWindowSize(window, w, h); + + if ((window->flags & SDL_WINDOW_FULLSCREEN) && SDL_GetWindowFullscreenMode(window)) { + mode = SDL_GetCurrentDisplayMode(displayID); + } else { + mode = SDL_GetDesktopDisplayMode(displayID); + } + if (mode) { + *w = (int)SDL_ceilf(*w * mode->pixel_density); + *h = (int)SDL_ceilf(*h * mode->pixel_density); + } + } + return true; +} + +bool SDL_SetWindowMinimumSize(SDL_Window *window, int min_w, int min_h) +{ + CHECK_WINDOW_MAGIC(window, false); + if (min_w < 0) { + return SDL_InvalidParamError("min_w"); + } + if (min_h < 0) { + return SDL_InvalidParamError("min_h"); + } + + if ((window->max_w && min_w > window->max_w) || + (window->max_h && min_h > window->max_h)) { + return SDL_SetError("SDL_SetWindowMinimumSize(): Tried to set minimum size larger than maximum size"); + } + + window->min_w = min_w; + window->min_h = min_h; + + if (_this->SetWindowMinimumSize) { + _this->SetWindowMinimumSize(_this, window); + } + + // Ensure that window is not smaller than minimal size + int w = window->last_size_pending ? window->pending.w : window->floating.w; + int h = window->last_size_pending ? window->pending.h : window->floating.h; + w = window->min_w ? SDL_max(w, window->min_w) : w; + h = window->min_h ? SDL_max(h, window->min_h) : h; + return SDL_SetWindowSize(window, w, h); +} + +bool SDL_GetWindowMinimumSize(SDL_Window *window, int *min_w, int *min_h) +{ + CHECK_WINDOW_MAGIC(window, false); + if (min_w) { + *min_w = window->min_w; + } + if (min_h) { + *min_h = window->min_h; + } + return true; +} + +bool SDL_SetWindowMaximumSize(SDL_Window *window, int max_w, int max_h) +{ + CHECK_WINDOW_MAGIC(window, false); + if (max_w < 0) { + return SDL_InvalidParamError("max_w"); + } + if (max_h < 0) { + return SDL_InvalidParamError("max_h"); + } + + if ((max_w && max_w < window->min_w) || + (max_h && max_h < window->min_h)) { + return SDL_SetError("SDL_SetWindowMaximumSize(): Tried to set maximum size smaller than minimum size"); + } + + window->max_w = max_w; + window->max_h = max_h; + + if (_this->SetWindowMaximumSize) { + _this->SetWindowMaximumSize(_this, window); + } + + // Ensure that window is not larger than maximal size + int w = window->last_size_pending ? window->pending.w : window->floating.w; + int h = window->last_size_pending ? window->pending.h : window->floating.h; + w = window->max_w ? SDL_min(w, window->max_w) : w; + h = window->max_h ? SDL_min(h, window->max_h) : h; + return SDL_SetWindowSize(window, w, h); +} + +bool SDL_GetWindowMaximumSize(SDL_Window *window, int *max_w, int *max_h) +{ + CHECK_WINDOW_MAGIC(window, false); + if (max_w) { + *max_w = window->max_w; + } + if (max_h) { + *max_h = window->max_h; + } + return true; +} + +bool SDL_ShowWindow(SDL_Window *window) +{ + SDL_Window *child; + CHECK_WINDOW_MAGIC(window, false); + + if (!(window->flags & SDL_WINDOW_HIDDEN)) { + return true; + } + + // If the parent is hidden, set the flag to restore this when the parent is shown + if (window->parent && (window->parent->flags & SDL_WINDOW_HIDDEN)) { + window->restore_on_show = true; + return true; + } + + if (_this->ShowWindow) { + _this->ShowWindow(_this, window); + } else { + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + } + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_SHOWN, 0, 0); + + // Restore child windows + for (child = window->first_child; child; child = child->next_sibling) { + if (!child->restore_on_show && (child->flags & SDL_WINDOW_HIDDEN)) { + break; + } + SDL_ShowWindow(child); + child->restore_on_show = false; + } + return true; +} + +bool SDL_HideWindow(SDL_Window *window) +{ + SDL_Window *child; + CHECK_WINDOW_MAGIC(window, false); + + if (window->flags & SDL_WINDOW_HIDDEN) { + window->restore_on_show = false; + return true; + } + + // Hide all child windows + for (child = window->first_child; child; child = child->next_sibling) { + if (child->flags & SDL_WINDOW_HIDDEN) { + break; + } + SDL_HideWindow(child); + child->restore_on_show = true; + } + + // Store the flags for restoration later. + const SDL_WindowFlags pending_mask = (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_KEYBOARD_GRABBED | SDL_WINDOW_MOUSE_GRABBED); + window->pending_flags = (window->flags & pending_mask); + + window->is_hiding = true; + if (_this->HideWindow) { + _this->HideWindow(_this, window); + } else { + SDL_SetMouseFocus(NULL); + SDL_SetKeyboardFocus(NULL); + } + window->is_hiding = false; + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); + return true; +} + +bool SDL_RaiseWindow(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (window->flags & SDL_WINDOW_HIDDEN) { + return true; + } + if (_this->RaiseWindow) { + _this->RaiseWindow(_this, window); + } + return true; +} + +bool SDL_MaximizeWindow(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (!_this->MaximizeWindow) { + return SDL_Unsupported(); + } + + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + return SDL_SetError("A window without the 'SDL_WINDOW_RESIZABLE' flag can't be maximized"); + } + + if (window->flags & SDL_WINDOW_HIDDEN) { + window->pending_flags |= SDL_WINDOW_MAXIMIZED; + return true; + } + + _this->MaximizeWindow(_this, window); + SDL_SyncIfRequired(window); + return true; +} + +bool SDL_MinimizeWindow(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (!_this->MinimizeWindow) { + return SDL_Unsupported(); + } + + if (window->flags & SDL_WINDOW_HIDDEN) { + window->pending_flags |= SDL_WINDOW_MINIMIZED; + return true; + } + + _this->MinimizeWindow(_this, window); + SDL_SyncIfRequired(window); + return true; +} + +bool SDL_RestoreWindow(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (!_this->RestoreWindow) { + return SDL_Unsupported(); + } + + if (window->flags & SDL_WINDOW_HIDDEN) { + window->pending_flags &= ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED); + return true; + } + + _this->RestoreWindow(_this, window); + SDL_SyncIfRequired(window); + return true; +} + +bool SDL_SetWindowFullscreen(SDL_Window *window, bool fullscreen) +{ + bool result; + + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (window->flags & SDL_WINDOW_HIDDEN) { + if (fullscreen) { + window->pending_flags |= SDL_WINDOW_FULLSCREEN; + } else { + window->pending_flags &= ~SDL_WINDOW_FULLSCREEN; + } + return true; + } + + if (fullscreen) { + // Set the current fullscreen mode to the desired mode + SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode); + } + + result = SDL_UpdateFullscreenMode(window, fullscreen ? SDL_FULLSCREEN_OP_ENTER : SDL_FULLSCREEN_OP_LEAVE, true); + + if (!fullscreen || !result) { + // Clear the current fullscreen mode. + SDL_zero(window->current_fullscreen_mode); + } + + if (result) { + SDL_SyncIfRequired(window); + } + + return result; +} + +bool SDL_SyncWindow(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false) + + if (_this->SyncWindow) { + return _this->SyncWindow(_this, window); + } else { + return true; + } +} + +static bool ShouldAttemptTextureFramebuffer(void) +{ + const char *hint; + bool attempt_texture_framebuffer = true; + + // The dummy driver never has GPU support, of course. + if (_this->is_dummy) { + return false; + } + + // See if there's a hint override + hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); + if (hint && *hint) { + if (*hint == '0' || SDL_strcasecmp(hint, "false") == 0 || SDL_strcasecmp(hint, SDL_SOFTWARE_RENDERER) == 0) { + attempt_texture_framebuffer = false; + } else { + attempt_texture_framebuffer = true; + } + } else { + // Check for platform specific defaults +#ifdef SDL_PLATFORM_LINUX + // On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. + if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { + struct stat sb; + if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { // if either of these exist, we're on WSL. + attempt_texture_framebuffer = false; + } + } +#endif +#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_WINGDK) // GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) + if (_this->CreateWindowFramebuffer && (SDL_strcmp(_this->name, "windows") == 0)) { + attempt_texture_framebuffer = false; + } +#endif +#ifdef SDL_PLATFORM_EMSCRIPTEN + attempt_texture_framebuffer = false; +#endif + } + return attempt_texture_framebuffer; +} + +static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) +{ + SDL_PixelFormat format = SDL_PIXELFORMAT_UNKNOWN; + void *pixels = NULL; + int pitch = 0; + bool created_framebuffer = false; + int w, h; + + SDL_GetWindowSizeInPixels(window, &w, &h); + + /* This will switch the video backend from using a software surface to + using a GPU texture through the 2D render API, if we think this would + be more efficient. This only checks once, on demand. */ + if (!_this->checked_texture_framebuffer) { + if (ShouldAttemptTextureFramebuffer()) { + if (!SDL_CreateWindowTexture(_this, window, &format, &pixels, &pitch)) { + /* !!! FIXME: if this failed halfway (made renderer, failed to make texture, etc), + !!! FIXME: we probably need to clean this up so it doesn't interfere with + !!! FIXME: a software fallback at the system level (can we blit to an + !!! FIXME: OpenGL window? etc). */ + } else { + // future attempts will just try to use a texture framebuffer. + /* !!! FIXME: maybe we shouldn't override these but check if we used a texture + !!! FIXME: framebuffer at the right places; is it feasible we could have an + !!! FIXME: accelerated OpenGL window and a second ends up in software? */ + _this->CreateWindowFramebuffer = SDL_CreateWindowTexture; + _this->SetWindowFramebufferVSync = SDL_SetWindowTextureVSync; + _this->GetWindowFramebufferVSync = SDL_GetWindowTextureVSync; + _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture; + _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; + created_framebuffer = true; + } + } + + _this->checked_texture_framebuffer = true; // don't check this again. + } + + if (!created_framebuffer) { + if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) { + SDL_SetError("Window framebuffer support not available"); + return NULL; + } + + if (!_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch)) { + return NULL; + } + } + + if (window->surface) { + // We may have gone recursive and already created the surface + return window->surface; + } + + return SDL_CreateSurfaceFrom(w, h, format, pixels, pitch); +} + +bool SDL_WindowHasSurface(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + return window->surface ? true : false; +} + +SDL_Surface *SDL_GetWindowSurface(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, NULL); + + if (!window->surface_valid) { + if (window->surface) { + window->surface->internal_flags &= ~SDL_INTERNAL_SURFACE_DONTFREE; + SDL_DestroySurface(window->surface); + window->surface = NULL; + } + + window->surface = SDL_CreateWindowFramebuffer(window); + if (window->surface) { + window->surface_valid = true; + window->surface->internal_flags |= SDL_INTERNAL_SURFACE_DONTFREE; + } + } + return window->surface; +} + +bool SDL_SetWindowSurfaceVSync(SDL_Window *window, int vsync) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (!_this->SetWindowFramebufferVSync) { + return SDL_Unsupported(); + } + return _this->SetWindowFramebufferVSync(_this, window, vsync); +} + +bool SDL_GetWindowSurfaceVSync(SDL_Window *window, int *vsync) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (!_this->GetWindowFramebufferVSync) { + return SDL_Unsupported(); + } + return _this->GetWindowFramebufferVSync(_this, window, vsync); +} + +bool SDL_UpdateWindowSurface(SDL_Window *window) +{ + SDL_Rect full_rect; + + CHECK_WINDOW_MAGIC(window, false); + + full_rect.x = 0; + full_rect.y = 0; + SDL_GetWindowSizeInPixels(window, &full_rect.w, &full_rect.h); + + return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1); +} + +bool SDL_UpdateWindowSurfaceRects(SDL_Window *window, const SDL_Rect *rects, + int numrects) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (!window->surface_valid) { + return SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface"); + } + + SDL_assert(_this->checked_texture_framebuffer); // we should have done this before we had a valid surface. + + return _this->UpdateWindowFramebuffer(_this, window, rects, numrects); +} + +bool SDL_DestroyWindowSurface(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (window->surface) { + window->surface->internal_flags &= ~SDL_INTERNAL_SURFACE_DONTFREE; + SDL_DestroySurface(window->surface); + window->surface = NULL; + window->surface_valid = false; + } + + if (_this->checked_texture_framebuffer) { // never checked? No framebuffer to destroy. Don't risk calling the wrong implementation. + if (_this->DestroyWindowFramebuffer) { + _this->DestroyWindowFramebuffer(_this, window); + } + } + return true; +} + +bool SDL_SetWindowOpacity(SDL_Window *window, float opacity) +{ + bool result; + + CHECK_WINDOW_MAGIC(window, false); + + if (!_this->SetWindowOpacity) { + return SDL_Unsupported(); + } + + if (opacity < 0.0f) { + opacity = 0.0f; + } else if (opacity > 1.0f) { + opacity = 1.0f; + } + + result = _this->SetWindowOpacity(_this, window, opacity); + if (result) { + window->opacity = opacity; + } + + return result; +} + +float SDL_GetWindowOpacity(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, -1.0f); + + return window->opacity; +} + +bool SDL_SetWindowParent(SDL_Window *window, SDL_Window *parent) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (parent) { + CHECK_WINDOW_MAGIC(parent, false); + CHECK_WINDOW_NOT_POPUP(parent, false); + } + + if (!_this->SetWindowParent) { + return SDL_Unsupported(); + } + + if (window->flags & SDL_WINDOW_MODAL) { + return SDL_SetError("Modal windows cannot change parents; call SDL_SetWindowModal() to clear modal status first."); + } + + if (window->parent == parent) { + return true; + } + + const bool ret = _this->SetWindowParent(_this, window, parent); + SDL_UpdateWindowHierarchy(window, ret ? parent : NULL); + + return ret; +} + +bool SDL_SetWindowModal(SDL_Window *window, bool modal) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (!_this->SetWindowModal) { + return SDL_Unsupported(); + } + + if (modal) { + if (!window->parent) { + return SDL_SetError("Window must have a parent to enable the modal state; use SDL_SetWindowParent() to set the parent first."); + } + window->flags |= SDL_WINDOW_MODAL; + } else if (window->flags & SDL_WINDOW_MODAL) { + window->flags &= ~SDL_WINDOW_MODAL; + } else { + return true; // Already not modal, so nothing to do. + } + + if (window->flags & SDL_WINDOW_HIDDEN) { + return true; + } + + return _this->SetWindowModal(_this, window, modal); +} + +bool SDL_SetWindowFocusable(SDL_Window *window, bool focusable) +{ + CHECK_WINDOW_MAGIC(window, false); + + const bool want = (focusable != false); // normalize the flag. + const bool have = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE); + if ((want != have) && (_this->SetWindowFocusable)) { + if (want) { + window->flags &= ~SDL_WINDOW_NOT_FOCUSABLE; + } else { + window->flags |= SDL_WINDOW_NOT_FOCUSABLE; + } + if (!_this->SetWindowFocusable(_this, window, want)) { + return false; + } + } + + return true; +} + +void SDL_UpdateWindowGrab(SDL_Window *window) +{ + bool keyboard_grabbed, mouse_grabbed; + + if (window->flags & SDL_WINDOW_INPUT_FOCUS) { + if (SDL_GetMouse()->relative_mode || (window->flags & SDL_WINDOW_MOUSE_GRABBED)) { + mouse_grabbed = true; + } else { + mouse_grabbed = false; + } + + if (window->flags & SDL_WINDOW_KEYBOARD_GRABBED) { + keyboard_grabbed = true; + } else { + keyboard_grabbed = false; + } + } else { + mouse_grabbed = false; + keyboard_grabbed = false; + } + + if (mouse_grabbed || keyboard_grabbed) { + if (_this->grabbed_window && (_this->grabbed_window != window)) { + // stealing a grab from another window! + _this->grabbed_window->flags &= ~(SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED); + if (_this->SetWindowMouseGrab) { + _this->SetWindowMouseGrab(_this, _this->grabbed_window, false); + } + if (_this->SetWindowKeyboardGrab) { + _this->SetWindowKeyboardGrab(_this, _this->grabbed_window, false); + } + } + _this->grabbed_window = window; + } else if (_this->grabbed_window == window) { + _this->grabbed_window = NULL; // ungrabbing input. + } + + if (_this->SetWindowMouseGrab) { + if (!_this->SetWindowMouseGrab(_this, window, mouse_grabbed)) { + window->flags &= ~SDL_WINDOW_MOUSE_GRABBED; + } + } + if (_this->SetWindowKeyboardGrab) { + if (!_this->SetWindowKeyboardGrab(_this, window, keyboard_grabbed)) { + window->flags &= ~SDL_WINDOW_KEYBOARD_GRABBED; + } + } + + if (_this->grabbed_window && !(_this->grabbed_window->flags & (SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED))) { + _this->grabbed_window = NULL; + } +} + +bool SDL_SetWindowKeyboardGrab(SDL_Window *window, bool grabbed) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (window->flags & SDL_WINDOW_HIDDEN) { + if (grabbed) { + window->pending_flags |= SDL_WINDOW_KEYBOARD_GRABBED; + } else { + window->pending_flags &= ~SDL_WINDOW_KEYBOARD_GRABBED; + } + return true; + } + + if (!!grabbed == !!(window->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { + return true; + } + if (grabbed) { + window->flags |= SDL_WINDOW_KEYBOARD_GRABBED; + } else { + window->flags &= ~SDL_WINDOW_KEYBOARD_GRABBED; + } + SDL_UpdateWindowGrab(window); + + if (grabbed && !(window->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { + return false; + } + return true; +} + +bool SDL_SetWindowMouseGrab(SDL_Window *window, bool grabbed) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (window->flags & SDL_WINDOW_HIDDEN) { + if (grabbed) { + window->pending_flags |= SDL_WINDOW_MOUSE_GRABBED; + } else { + window->pending_flags &= ~SDL_WINDOW_MOUSE_GRABBED; + } + return true; + } + + if (!!grabbed == !!(window->flags & SDL_WINDOW_MOUSE_GRABBED)) { + return true; + } + if (grabbed) { + window->flags |= SDL_WINDOW_MOUSE_GRABBED; + } else { + window->flags &= ~SDL_WINDOW_MOUSE_GRABBED; + } + SDL_UpdateWindowGrab(window); + + if (grabbed && !(window->flags & SDL_WINDOW_MOUSE_GRABBED)) { + return false; + } + return true; +} + +bool SDL_GetWindowKeyboardGrab(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + return window == _this->grabbed_window && (_this->grabbed_window->flags & SDL_WINDOW_KEYBOARD_GRABBED); +} + +bool SDL_GetWindowMouseGrab(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + return window == _this->grabbed_window && (_this->grabbed_window->flags & SDL_WINDOW_MOUSE_GRABBED); +} + +SDL_Window *SDL_GetGrabbedWindow(void) +{ + if (_this->grabbed_window && + (_this->grabbed_window->flags & (SDL_WINDOW_MOUSE_GRABBED | SDL_WINDOW_KEYBOARD_GRABBED)) != 0) { + return _this->grabbed_window; + } else { + return NULL; + } +} + +bool SDL_SetWindowMouseRect(SDL_Window *window, const SDL_Rect *rect) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (rect) { + SDL_memcpy(&window->mouse_rect, rect, sizeof(*rect)); + } else { + SDL_zero(window->mouse_rect); + } + + if (_this->SetWindowMouseRect) { + return _this->SetWindowMouseRect(_this, window); + } + return true; +} + +const SDL_Rect *SDL_GetWindowMouseRect(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, NULL); + + if (SDL_RectEmpty(&window->mouse_rect)) { + return NULL; + } else { + return &window->mouse_rect; + } +} + +bool SDL_SetWindowRelativeMouseMode(SDL_Window *window, bool enabled) +{ + CHECK_WINDOW_MAGIC(window, false); + + /* If the app toggles relative mode directly, it probably shouldn't + * also be emulating it using repeated mouse warps, so disable + * mouse warp emulation by default. + */ + SDL_DisableMouseWarpEmulation(); + + if (enabled == SDL_GetWindowRelativeMouseMode(window)) { + return true; + } + + if (enabled) { + window->flags |= SDL_WINDOW_MOUSE_RELATIVE_MODE; + } else { + window->flags &= ~SDL_WINDOW_MOUSE_RELATIVE_MODE; + } + SDL_UpdateRelativeMouseMode(); + + return true; +} + +bool SDL_GetWindowRelativeMouseMode(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (window->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE) { + return true; + } else { + return false; + } +} + +bool SDL_FlashWindow(SDL_Window *window, SDL_FlashOperation operation) +{ + CHECK_WINDOW_MAGIC(window, false); + CHECK_WINDOW_NOT_POPUP(window, false); + + if (_this->FlashWindow) { + return _this->FlashWindow(_this, window, operation); + } + + return SDL_Unsupported(); +} + +void SDL_OnWindowShown(SDL_Window *window) +{ + // Set window state if we have pending window flags cached + ApplyWindowFlags(window, window->pending_flags); + window->pending_flags = 0; +} + +void SDL_OnWindowHidden(SDL_Window *window) +{ + /* Store the maximized and fullscreen flags for restoration later, in case + * this was initiated by the window manager due to the window being unmapped + * when minimized. + */ + window->pending_flags |= (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED)); + + // The window is already hidden at this point, so just change the mode back if necessary. + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, false); +} + +void SDL_OnWindowDisplayChanged(SDL_Window *window) +{ + if (window->flags & SDL_WINDOW_FULLSCREEN) { + SDL_DisplayID displayID = SDL_GetDisplayForWindowPosition(window); + + if (window->requested_fullscreen_mode.w != 0 || window->requested_fullscreen_mode.h != 0) { + bool include_high_density_modes = false; + + if (window->requested_fullscreen_mode.pixel_density > 1.0f) { + include_high_density_modes = true; + } + SDL_GetClosestFullscreenDisplayMode(displayID, window->requested_fullscreen_mode.w, window->requested_fullscreen_mode.h, window->requested_fullscreen_mode.refresh_rate, include_high_density_modes, &window->current_fullscreen_mode); + } else { + SDL_zero(window->current_fullscreen_mode); + } + + if (SDL_WINDOW_FULLSCREEN_VISIBLE(window)) { + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true); + } + } + + SDL_CheckWindowPixelSizeChanged(window); +} + +void SDL_OnWindowMoved(SDL_Window *window) +{ + SDL_CheckWindowDisplayChanged(window); +} + +void SDL_OnWindowResized(SDL_Window *window) +{ + SDL_CheckWindowDisplayChanged(window); + SDL_CheckWindowPixelSizeChanged(window); + SDL_CheckWindowSafeAreaChanged(window); + + if ((window->flags & SDL_WINDOW_TRANSPARENT) && _this->UpdateWindowShape) { + SDL_Surface *surface = (SDL_Surface *)SDL_GetPointerProperty(window->props, SDL_PROP_WINDOW_SHAPE_POINTER, NULL); + if (surface) { + _this->UpdateWindowShape(_this, window, surface); + } + } +} + +void SDL_CheckWindowPixelSizeChanged(SDL_Window *window) +{ + int pixel_w = 0, pixel_h = 0; + + SDL_GetWindowSizeInPixels(window, &pixel_w, &pixel_h); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED, pixel_w, pixel_h); + + SDL_CheckWindowDisplayScaleChanged(window); +} + +void SDL_OnWindowPixelSizeChanged(SDL_Window *window) +{ + window->surface_valid = false; +} + +void SDL_OnWindowLiveResizeUpdate(SDL_Window *window) +{ + if (SDL_HasMainCallbacks()) { + SDL_IterateMainCallbacks(false); + } else { + // Send an expose event so the application can redraw + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } + + SDL_PumpEventMaintenance(); +} + +static void SDL_CheckWindowSafeAreaChanged(SDL_Window *window) +{ + SDL_Rect rect; + + rect.x = window->safe_inset_left; + rect.y = window->safe_inset_top; + rect.w = window->w - (window->safe_inset_right + window->safe_inset_left); + rect.h = window->h - (window->safe_inset_top + window->safe_inset_bottom); + if (SDL_memcmp(&rect, &window->safe_rect, sizeof(rect)) != 0) { + SDL_copyp(&window->safe_rect, &rect); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_SAFE_AREA_CHANGED, 0, 0); + } +} + +void SDL_SetWindowSafeAreaInsets(SDL_Window *window, int left, int right, int top, int bottom) +{ + window->safe_inset_left = left; + window->safe_inset_right = right; + window->safe_inset_top = top; + window->safe_inset_bottom = bottom; + SDL_CheckWindowSafeAreaChanged(window); +} + +bool SDL_GetWindowSafeArea(SDL_Window *window, SDL_Rect *rect) +{ + if (rect) { + SDL_zerop(rect); + } + + CHECK_WINDOW_MAGIC(window, false); + + if (rect) { + if (SDL_RectEmpty(&window->safe_rect)) { + rect->w = window->w; + rect->h = window->h; + } else { + SDL_copyp(rect, &window->safe_rect); + } + } + return true; +} + +void SDL_OnWindowMinimized(SDL_Window *window) +{ + if (window->flags & SDL_WINDOW_FULLSCREEN) { + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, false); + } +} + +void SDL_OnWindowMaximized(SDL_Window *window) +{ +} + +void SDL_OnWindowRestored(SDL_Window *window) +{ + /* + * FIXME: Is this fine to just remove this, or should it be preserved just + * for the fullscreen case? In principle it seems like just hiding/showing + * windows shouldn't affect the stacking order; maybe the right fix is to + * re-decouple OnWindowShown and OnWindowRestored. + */ + // SDL_RaiseWindow(window); + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, false); + } +} + +void SDL_OnWindowEnter(SDL_Window *window) +{ + if (_this->OnWindowEnter) { + _this->OnWindowEnter(_this, window); + } +} + +void SDL_OnWindowLeave(SDL_Window *window) +{ +} + +void SDL_OnWindowFocusGained(SDL_Window *window) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse && mouse->relative_mode) { + SDL_SetMouseFocus(window); + } + + SDL_UpdateWindowGrab(window); +} + +static bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) +{ + const char *hint; + + if (!(window->flags & SDL_WINDOW_FULLSCREEN) || window->is_destroying) { + return false; + } + +#if defined(SDL_PLATFORM_MACOS) && defined(SDL_VIDEO_DRIVER_COCOA) + if (SDL_strcmp(_this->name, "cocoa") == 0) { // don't do this for X11, etc + if (Cocoa_IsWindowInFullscreenSpace(window)) { + return false; + } + } +#endif + +#ifdef SDL_PLATFORM_ANDROID + { + extern bool Android_JNI_ShouldMinimizeOnFocusLoss(void); + if (!Android_JNI_ShouldMinimizeOnFocusLoss()) { + return false; + } + } +#endif + + // Real fullscreen windows should minimize on focus loss so the desktop video mode is restored + hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); + if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) { + if (window->fullscreen_exclusive && !SDL_ModeSwitchingEmulated(_this)) { + return true; + } else { + return false; + } + } + return SDL_GetHintBoolean(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, false); +} + +void SDL_OnWindowFocusLost(SDL_Window *window) +{ + SDL_UpdateWindowGrab(window); + + if (SDL_ShouldMinimizeOnFocusLoss(window)) { + SDL_MinimizeWindow(window); + } +} + +SDL_Window *SDL_GetToplevelForKeyboardFocus(void) +{ + SDL_Window *focus = SDL_GetKeyboardFocus(); + + if (focus) { + // Get the toplevel parent window. + while (focus->parent) { + focus = focus->parent; + } + } + + return focus; +} + +bool SDL_AddWindowRenderer(SDL_Window *window, SDL_Renderer *renderer) +{ + SDL_Renderer **renderers = (SDL_Renderer **)SDL_realloc(window->renderers, (window->num_renderers + 1) * sizeof(*renderers)); + if (!renderers) { + return false; + } + + window->renderers = renderers; + window->renderers[window->num_renderers++] = renderer; + return true; +} + +void SDL_RemoveWindowRenderer(SDL_Window *window, SDL_Renderer *renderer) +{ + for (int i = 0; i < window->num_renderers; ++i) { + if (window->renderers[i] == renderer) { + if (i < (window->num_renderers - 1)) { + SDL_memmove(&window->renderers[i], &window->renderers[i + 1], (window->num_renderers - i - 1) * sizeof(window->renderers[i])); + } + --window->num_renderers; + break; + } + } +} + +void SDL_DestroyWindow(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window,); + + window->is_destroying = true; + + // Destroy any child windows of this window + while (window->first_child) { + SDL_DestroyWindow(window->first_child); + } + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DESTROYED, 0, 0); + + SDL_Renderer *renderer = SDL_GetRenderer(window); + if (renderer) { + SDL_DestroyRendererWithoutFreeing(renderer); + } + + // Restore video mode, etc. + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, true); + if (!(window->flags & SDL_WINDOW_EXTERNAL)) { + SDL_HideWindow(window); + } + + SDL_DestroyProperties(window->text_input_props); + SDL_DestroyProperties(window->props); + + /* Clear the modal status, but don't unset the parent just yet, as it + * may be needed later in the destruction process if a backend needs + * to update the input focus. + */ + if (_this->SetWindowModal && (window->flags & SDL_WINDOW_MODAL)) { + _this->SetWindowModal(_this, window, false); + } + + // Make sure the destroyed window isn't referenced by any display as a fullscreen window. + for (int i = 0; i < _this->num_displays; ++i) { + if (_this->displays[i]->fullscreen_window == window) { + _this->displays[i]->fullscreen_window = NULL; + } + } + + // Make sure this window no longer has focus + if (SDL_GetKeyboardFocus() == window) { + SDL_SetKeyboardFocus(NULL); + } + if ((window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { + SDL_UpdateMouseCapture(true); + } + if (SDL_GetMouseFocus() == window) { + SDL_SetMouseFocus(NULL); + } + + SDL_DestroyWindowSurface(window); + + // Make no context current if this is the current context window + if (window->flags & SDL_WINDOW_OPENGL) { + if (_this->current_glwin == window) { + SDL_GL_MakeCurrent(window, NULL); + } + } + + if (_this->DestroyWindow) { + _this->DestroyWindow(_this, window); + } + + // Unload the graphics libraries after the window is destroyed, which may clean up EGL surfaces + if (window->flags & SDL_WINDOW_OPENGL) { + SDL_GL_UnloadLibrary(); + } + if (window->flags & SDL_WINDOW_VULKAN) { + SDL_Vulkan_UnloadLibrary(); + } + + if (_this->grabbed_window == window) { + _this->grabbed_window = NULL; // ungrabbing input. + } + + if (_this->current_glwin == window) { + _this->current_glwin = NULL; + } + + if (_this->wakeup_window == window) { + _this->wakeup_window = NULL; + } + + // Now invalidate magic + SDL_SetObjectValid(window, SDL_OBJECT_TYPE_WINDOW, false); + + // Free memory associated with the window + SDL_free(window->title); + SDL_DestroySurface(window->icon); + + // Unlink the window from its siblings. + SDL_UpdateWindowHierarchy(window, NULL); + + // Unlink the window from the global window list + if (window->next) { + window->next->prev = window->prev; + } + if (window->prev) { + window->prev->next = window->next; + } else { + _this->windows = window->next; + } + + SDL_free(window->renderers); + SDL_free(window); + +#ifdef SDL_VIDEO_DRIVER_UIKIT + SDL_UpdateLifecycleObserver(); +#endif +} + +bool SDL_ScreenSaverEnabled(void) +{ + if (!_this) { + return true; + } + return !_this->suspend_screensaver; +} + +bool SDL_EnableScreenSaver(void) +{ + if (!_this) { + return SDL_UninitializedVideo(); + } + if (!_this->suspend_screensaver) { + return true; + } + _this->suspend_screensaver = false; + if (_this->SuspendScreenSaver) { + return _this->SuspendScreenSaver(_this); + } + + return SDL_Unsupported(); +} + +bool SDL_DisableScreenSaver(void) +{ + if (!_this) { + return SDL_UninitializedVideo(); + } + if (_this->suspend_screensaver) { + return true; + } + _this->suspend_screensaver = true; + if (_this->SuspendScreenSaver) { + return _this->SuspendScreenSaver(_this); + } + + return SDL_Unsupported(); +} + +void SDL_VideoQuit(void) +{ + int i; + + if (!_this) { + return; + } + + // Halt event processing before doing anything else +#if 0 // This was moved to the end to fix a memory leak + SDL_QuitPen(); +#endif + SDL_QuitTouch(); + SDL_QuitMouse(); + SDL_QuitKeyboard(); + SDL_QuitSubSystem(SDL_INIT_EVENTS); + + SDL_EnableScreenSaver(); + + // Clean up the system video + while (_this->windows) { + SDL_DestroyWindow(_this->windows); + } + _this->VideoQuit(_this); + + for (i = _this->num_displays; i--; ) { + SDL_VideoDisplay *display = _this->displays[i]; + SDL_DelVideoDisplay(display->id, false); + } + + SDL_assert(_this->num_displays == 0); + SDL_free(_this->displays); + _this->displays = NULL; + + SDL_CancelClipboardData(0); + + if (_this->primary_selection_text) { + SDL_free(_this->primary_selection_text); + _this->primary_selection_text = NULL; + } + _this->free(_this); + _this = NULL; + + // This needs to happen after the video subsystem has removed pen data + SDL_QuitPen(); +} + +bool SDL_GL_LoadLibrary(const char *path) +{ + bool result; + + if (!_this) { + return SDL_UninitializedVideo(); + } + if (_this->gl_config.driver_loaded) { + if (path && SDL_strcmp(path, _this->gl_config.driver_path) != 0) { + return SDL_SetError("OpenGL library already loaded"); + } + result = true; + } else { + if (!_this->GL_LoadLibrary) { + return SDL_DllNotSupported("OpenGL"); + } + result = _this->GL_LoadLibrary(_this, path); + } + if (result) { + ++_this->gl_config.driver_loaded; + } else { + if (_this->GL_UnloadLibrary) { + _this->GL_UnloadLibrary(_this); + } + } + return result; +} + +SDL_FunctionPointer SDL_GL_GetProcAddress(const char *proc) +{ + SDL_FunctionPointer func; + + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + func = NULL; + if (_this->GL_GetProcAddress) { + if (_this->gl_config.driver_loaded) { + func = _this->GL_GetProcAddress(_this, proc); + } else { + SDL_SetError("No GL driver has been loaded"); + } + } else { + SDL_SetError("No dynamic GL support in current SDL video driver (%s)", _this->name); + } + return func; +} + +SDL_FunctionPointer SDL_EGL_GetProcAddress(const char *proc) +{ +#ifdef SDL_VIDEO_OPENGL_EGL + SDL_FunctionPointer func; + + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + func = NULL; + + if (_this->egl_data) { + func = SDL_EGL_GetProcAddressInternal(_this, proc); + } else { + SDL_SetError("No EGL library has been loaded"); + } + + return func; +#else + SDL_SetError("SDL was not built with EGL support"); + return NULL; +#endif +} + +void SDL_GL_UnloadLibrary(void) +{ + if (!_this) { + SDL_UninitializedVideo(); + return; + } + if (_this->gl_config.driver_loaded > 0) { + if (--_this->gl_config.driver_loaded > 0) { + return; + } + if (_this->GL_UnloadLibrary) { + _this->GL_UnloadLibrary(_this); + } + } +} + +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) +typedef GLenum (APIENTRY* PFNGLGETERRORPROC) (void); +typedef void (APIENTRY* PFNGLGETINTEGERVPROC) (GLenum pname, GLint *params); +typedef const GLubyte *(APIENTRY* PFNGLGETSTRINGPROC) (GLenum name); +#ifndef SDL_VIDEO_OPENGL +typedef const GLubyte *(APIENTRY* PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +#endif + +static SDL_INLINE bool isAtLeastGL3(const char *verstr) +{ + return verstr && (SDL_atoi(verstr) >= 3); +} +#endif // SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 + +bool SDL_GL_ExtensionSupported(const char *extension) +{ +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + PFNGLGETSTRINGPROC glGetStringFunc; + const char *extensions; + const char *start; + const char *where, *terminator; + + // Extension names should not have spaces. + where = SDL_strchr(extension, ' '); + if (where || *extension == '\0') { + return false; + } + // See if there's a hint or environment variable override + start = SDL_GetHint(extension); + if (start && *start == '0') { + return false; + } + + // Lookup the available extensions + + glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString"); + if (!glGetStringFunc) { + return false; + } + + if (isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) { + PFNGLGETSTRINGIPROC glGetStringiFunc; + PFNGLGETINTEGERVPROC glGetIntegervFunc; + GLint num_exts = 0; + GLint i; + + glGetStringiFunc = (PFNGLGETSTRINGIPROC)SDL_GL_GetProcAddress("glGetStringi"); + glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv"); + if ((!glGetStringiFunc) || (!glGetIntegervFunc)) { + return false; + } + +#ifndef GL_NUM_EXTENSIONS +#define GL_NUM_EXTENSIONS 0x821D +#endif + glGetIntegervFunc(GL_NUM_EXTENSIONS, &num_exts); + for (i = 0; i < num_exts; i++) { + const char *thisext = (const char *)glGetStringiFunc(GL_EXTENSIONS, i); + if (SDL_strcmp(thisext, extension) == 0) { + return true; + } + } + + return false; + } + + // Try the old way with glGetString(GL_EXTENSIONS) ... + + extensions = (const char *)glGetStringFunc(GL_EXTENSIONS); + if (!extensions) { + return false; + } + /* + * It takes a bit of care to be fool-proof about parsing the OpenGL + * extensions string. Don't be fooled by sub-strings, etc. + */ + + start = extensions; + + for (;;) { + where = SDL_strstr(start, extension); + if (!where) { + break; + } + + terminator = where + SDL_strlen(extension); + if (where == extensions || *(where - 1) == ' ') { + if (*terminator == ' ' || *terminator == '\0') { + return true; + } + } + + start = terminator; + } + return false; +#else + return false; +#endif +} + +/* Deduce supported ES profile versions from the supported + ARB_ES*_compatibility extensions. There is no direct query. + + This is normally only called when the OpenGL driver supports + {GLX,WGL}_EXT_create_context_es2_profile. + */ +void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor) +{ +// THIS REQUIRES AN EXISTING GL CONTEXT THAT HAS BEEN MADE CURRENT. +// Please refer to https://bugzilla.libsdl.org/show_bug.cgi?id=3725 for discussion. +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + /* XXX This is fragile; it will break in the event of release of + * new versions of OpenGL ES. + */ + if (SDL_GL_ExtensionSupported("GL_ARB_ES3_2_compatibility")) { + *major = 3; + *minor = 2; + } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_1_compatibility")) { + *major = 3; + *minor = 1; + } else if (SDL_GL_ExtensionSupported("GL_ARB_ES3_compatibility")) { + *major = 3; + *minor = 0; + } else { + *major = 2; + *minor = 0; + } +#endif +} + +void SDL_EGL_SetAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribCallback, + SDL_EGLIntArrayCallback surfaceAttribCallback, + SDL_EGLIntArrayCallback contextAttribCallback, + void *userdata) +{ + if (!_this) { + return; + } + _this->egl_platformattrib_callback = platformAttribCallback; + _this->egl_surfaceattrib_callback = surfaceAttribCallback; + _this->egl_contextattrib_callback = contextAttribCallback; + _this->egl_attrib_callback_userdata = userdata; +} + +void SDL_GL_ResetAttributes(void) +{ + if (!_this) { + return; + } + + _this->egl_platformattrib_callback = NULL; + _this->egl_surfaceattrib_callback = NULL; + _this->egl_contextattrib_callback = NULL; + _this->egl_attrib_callback_userdata = NULL; + + _this->gl_config.red_size = 8; + _this->gl_config.green_size = 8; + _this->gl_config.blue_size = 8; + _this->gl_config.alpha_size = 8; + _this->gl_config.buffer_size = 0; + _this->gl_config.depth_size = 16; + _this->gl_config.stencil_size = 0; + _this->gl_config.double_buffer = 1; + _this->gl_config.accum_red_size = 0; + _this->gl_config.accum_green_size = 0; + _this->gl_config.accum_blue_size = 0; + _this->gl_config.accum_alpha_size = 0; + _this->gl_config.stereo = 0; + _this->gl_config.multisamplebuffers = 0; + _this->gl_config.multisamplesamples = 0; + _this->gl_config.floatbuffers = 0; + _this->gl_config.retained_backing = 1; + _this->gl_config.accelerated = -1; // accelerated or not, both are fine + +#ifdef SDL_VIDEO_OPENGL + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = 0; +#elif defined(SDL_VIDEO_OPENGL_ES2) + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 0; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#elif defined(SDL_VIDEO_OPENGL_ES) + _this->gl_config.major_version = 1; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; +#endif + + if (_this->GL_DefaultProfileConfig) { + _this->GL_DefaultProfileConfig(_this, &_this->gl_config.profile_mask, + &_this->gl_config.major_version, + &_this->gl_config.minor_version); + } + + _this->gl_config.flags = 0; + _this->gl_config.framebuffer_srgb_capable = 0; + _this->gl_config.no_error = 0; + _this->gl_config.release_behavior = SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH; + _this->gl_config.reset_notification = SDL_GL_CONTEXT_RESET_NO_NOTIFICATION; + + _this->gl_config.share_with_current_context = 0; + + _this->gl_config.egl_platform = 0; +} + +bool SDL_GL_SetAttribute(SDL_GLAttr attr, int value) +{ +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + bool result; + + if (!_this) { + return SDL_UninitializedVideo(); + } + result = true; + switch (attr) { + case SDL_GL_RED_SIZE: + _this->gl_config.red_size = value; + break; + case SDL_GL_GREEN_SIZE: + _this->gl_config.green_size = value; + break; + case SDL_GL_BLUE_SIZE: + _this->gl_config.blue_size = value; + break; + case SDL_GL_ALPHA_SIZE: + _this->gl_config.alpha_size = value; + break; + case SDL_GL_DOUBLEBUFFER: + _this->gl_config.double_buffer = value; + break; + case SDL_GL_BUFFER_SIZE: + _this->gl_config.buffer_size = value; + break; + case SDL_GL_DEPTH_SIZE: + _this->gl_config.depth_size = value; + break; + case SDL_GL_STENCIL_SIZE: + _this->gl_config.stencil_size = value; + break; + case SDL_GL_ACCUM_RED_SIZE: + _this->gl_config.accum_red_size = value; + break; + case SDL_GL_ACCUM_GREEN_SIZE: + _this->gl_config.accum_green_size = value; + break; + case SDL_GL_ACCUM_BLUE_SIZE: + _this->gl_config.accum_blue_size = value; + break; + case SDL_GL_ACCUM_ALPHA_SIZE: + _this->gl_config.accum_alpha_size = value; + break; + case SDL_GL_STEREO: + _this->gl_config.stereo = value; + break; + case SDL_GL_MULTISAMPLEBUFFERS: + _this->gl_config.multisamplebuffers = value; + break; + case SDL_GL_MULTISAMPLESAMPLES: + _this->gl_config.multisamplesamples = value; + break; + case SDL_GL_FLOATBUFFERS: + _this->gl_config.floatbuffers = value; + break; + case SDL_GL_ACCELERATED_VISUAL: + _this->gl_config.accelerated = value; + break; + case SDL_GL_RETAINED_BACKING: + _this->gl_config.retained_backing = value; + break; + case SDL_GL_CONTEXT_MAJOR_VERSION: + _this->gl_config.major_version = value; + break; + case SDL_GL_CONTEXT_MINOR_VERSION: + _this->gl_config.minor_version = value; + break; + case SDL_GL_CONTEXT_FLAGS: + if (value & ~(SDL_GL_CONTEXT_DEBUG_FLAG | + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG | + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG | + SDL_GL_CONTEXT_RESET_ISOLATION_FLAG)) { + result = SDL_SetError("Unknown OpenGL context flag %d", value); + break; + } + _this->gl_config.flags = value; + break; + case SDL_GL_CONTEXT_PROFILE_MASK: + if (value != 0 && + value != SDL_GL_CONTEXT_PROFILE_CORE && + value != SDL_GL_CONTEXT_PROFILE_COMPATIBILITY && + value != SDL_GL_CONTEXT_PROFILE_ES) { + result = SDL_SetError("Unknown OpenGL context profile %d", value); + break; + } + _this->gl_config.profile_mask = value; + break; + case SDL_GL_SHARE_WITH_CURRENT_CONTEXT: + _this->gl_config.share_with_current_context = value; + break; + case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE: + _this->gl_config.framebuffer_srgb_capable = value; + break; + case SDL_GL_CONTEXT_RELEASE_BEHAVIOR: + _this->gl_config.release_behavior = value; + break; + case SDL_GL_CONTEXT_RESET_NOTIFICATION: + _this->gl_config.reset_notification = value; + break; + case SDL_GL_CONTEXT_NO_ERROR: + _this->gl_config.no_error = value; + break; + case SDL_GL_EGL_PLATFORM: + _this->gl_config.egl_platform = value; + break; + default: + result = SDL_SetError("Unknown OpenGL attribute"); + break; + } + return result; +#else + return SDL_Unsupported(); +#endif // SDL_VIDEO_OPENGL +} + +bool SDL_GL_GetAttribute(SDL_GLAttr attr, int *value) +{ +#if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + PFNGLGETERRORPROC glGetErrorFunc; + GLenum attrib = 0; + GLenum error = 0; + + /* + * Some queries in Core Profile desktop OpenGL 3+ contexts require + * glGetFramebufferAttachmentParameteriv instead of glGetIntegerv. Note that + * the enums we use for the former function don't exist in OpenGL ES 2, and + * the function itself doesn't exist prior to OpenGL 3 and OpenGL ES 2. + */ +#ifdef SDL_VIDEO_OPENGL + PFNGLGETSTRINGPROC glGetStringFunc; + PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC glGetFramebufferAttachmentParameterivFunc; + GLenum attachment = GL_BACK_LEFT; + GLenum attachmentattrib = 0; +#endif + + if (!value) { + return SDL_InvalidParamError("value"); + } + + // Clear value in any case + *value = 0; + + if (!_this) { + return SDL_UninitializedVideo(); + } + + switch (attr) { + case SDL_GL_RED_SIZE: +#ifdef SDL_VIDEO_OPENGL + attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE; +#endif + attrib = GL_RED_BITS; + break; + case SDL_GL_BLUE_SIZE: +#ifdef SDL_VIDEO_OPENGL + attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE; +#endif + attrib = GL_BLUE_BITS; + break; + case SDL_GL_GREEN_SIZE: +#ifdef SDL_VIDEO_OPENGL + attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE; +#endif + attrib = GL_GREEN_BITS; + break; + case SDL_GL_ALPHA_SIZE: +#ifdef SDL_VIDEO_OPENGL + attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE; +#endif + attrib = GL_ALPHA_BITS; + break; + case SDL_GL_DOUBLEBUFFER: +#ifdef SDL_VIDEO_OPENGL + attrib = GL_DOUBLEBUFFER; + break; +#else + // OpenGL ES 1.0 and above specifications have EGL_SINGLE_BUFFER + // parameter which switches double buffer to single buffer. OpenGL ES + // SDL driver must set proper value after initialization + *value = _this->gl_config.double_buffer; + return true; +#endif + case SDL_GL_DEPTH_SIZE: +#ifdef SDL_VIDEO_OPENGL + attachment = GL_DEPTH; + attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE; +#endif + attrib = GL_DEPTH_BITS; + break; + case SDL_GL_STENCIL_SIZE: +#ifdef SDL_VIDEO_OPENGL + attachment = GL_STENCIL; + attachmentattrib = GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE; +#endif + attrib = GL_STENCIL_BITS; + break; +#ifdef SDL_VIDEO_OPENGL + case SDL_GL_ACCUM_RED_SIZE: + attrib = GL_ACCUM_RED_BITS; + break; + case SDL_GL_ACCUM_GREEN_SIZE: + attrib = GL_ACCUM_GREEN_BITS; + break; + case SDL_GL_ACCUM_BLUE_SIZE: + attrib = GL_ACCUM_BLUE_BITS; + break; + case SDL_GL_ACCUM_ALPHA_SIZE: + attrib = GL_ACCUM_ALPHA_BITS; + break; + case SDL_GL_STEREO: + attrib = GL_STEREO; + break; +#else + case SDL_GL_ACCUM_RED_SIZE: + case SDL_GL_ACCUM_GREEN_SIZE: + case SDL_GL_ACCUM_BLUE_SIZE: + case SDL_GL_ACCUM_ALPHA_SIZE: + case SDL_GL_STEREO: + // none of these are supported in OpenGL ES + *value = 0; + return true; +#endif + case SDL_GL_MULTISAMPLEBUFFERS: + attrib = GL_SAMPLE_BUFFERS; + break; + case SDL_GL_MULTISAMPLESAMPLES: + attrib = GL_SAMPLES; + break; + case SDL_GL_CONTEXT_RELEASE_BEHAVIOR: + attrib = GL_CONTEXT_RELEASE_BEHAVIOR; + break; + case SDL_GL_BUFFER_SIZE: + { + int rsize = 0, gsize = 0, bsize = 0, asize = 0; + + // There doesn't seem to be a single flag in OpenGL for this! + if (!SDL_GL_GetAttribute(SDL_GL_RED_SIZE, &rsize)) { + return false; + } + if (!SDL_GL_GetAttribute(SDL_GL_GREEN_SIZE, &gsize)) { + return false; + } + if (!SDL_GL_GetAttribute(SDL_GL_BLUE_SIZE, &bsize)) { + return false; + } + if (!SDL_GL_GetAttribute(SDL_GL_ALPHA_SIZE, &asize)) { + return false; + } + + *value = rsize + gsize + bsize + asize; + return true; + } + case SDL_GL_ACCELERATED_VISUAL: + { + // FIXME: How do we get this information? + *value = (_this->gl_config.accelerated != 0); + return true; + } + case SDL_GL_RETAINED_BACKING: + { + *value = _this->gl_config.retained_backing; + return true; + } + case SDL_GL_CONTEXT_MAJOR_VERSION: + { + *value = _this->gl_config.major_version; + return true; + } + case SDL_GL_CONTEXT_MINOR_VERSION: + { + *value = _this->gl_config.minor_version; + return true; + } + case SDL_GL_CONTEXT_FLAGS: + { + *value = _this->gl_config.flags; + return true; + } + case SDL_GL_CONTEXT_PROFILE_MASK: + { + *value = _this->gl_config.profile_mask; + return true; + } + case SDL_GL_SHARE_WITH_CURRENT_CONTEXT: + { + *value = _this->gl_config.share_with_current_context; + return true; + } + case SDL_GL_FRAMEBUFFER_SRGB_CAPABLE: + { + *value = _this->gl_config.framebuffer_srgb_capable; + return true; + } + case SDL_GL_CONTEXT_NO_ERROR: + { + *value = _this->gl_config.no_error; + return true; + } + case SDL_GL_EGL_PLATFORM: + { + *value = _this->gl_config.egl_platform; + return true; + } + default: + return SDL_SetError("Unknown OpenGL attribute"); + } + +#ifdef SDL_VIDEO_OPENGL + glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString"); + if (!glGetStringFunc) { + return false; + } + + if (attachmentattrib && isAtLeastGL3((const char *)glGetStringFunc(GL_VERSION))) { + // glGetFramebufferAttachmentParameteriv needs to operate on the window framebuffer for this, so bind FBO 0 if necessary. + GLint current_fbo = 0; + PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC) SDL_GL_GetProcAddress("glGetIntegerv"); + PFNGLBINDFRAMEBUFFERPROC glBindFramebufferFunc = (PFNGLBINDFRAMEBUFFERPROC)SDL_GL_GetProcAddress("glBindFramebuffer"); + if (glGetIntegervFunc && glBindFramebufferFunc) { + glGetIntegervFunc(GL_DRAW_FRAMEBUFFER_BINDING, ¤t_fbo); + } + + glGetFramebufferAttachmentParameterivFunc = (PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC)SDL_GL_GetProcAddress("glGetFramebufferAttachmentParameteriv"); + if (glGetFramebufferAttachmentParameterivFunc) { + if (glBindFramebufferFunc && (current_fbo != 0)) { + glBindFramebufferFunc(GL_DRAW_FRAMEBUFFER, 0); + } + // glGetFramebufferAttachmentParameterivFunc may cause GL_INVALID_OPERATION when querying depth/stencil size if the + // bits is 0. From the GL docs: + // If the value of GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE is GL_NONE, then either no framebuffer is bound to target; + // or a default framebuffer is queried, attachment is GL_DEPTH or GL_STENCIL, and the number of depth or stencil bits, + // respectively, is zero. In this case querying pname GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME will return zero, and all + // other queries will generate an error. + GLint fbo_type = GL_FRAMEBUFFER_DEFAULT; + if (attachment == GL_DEPTH || attachment == GL_STENCIL) { + glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE, &fbo_type); + } + if (fbo_type != GL_NONE) { + glGetFramebufferAttachmentParameterivFunc(GL_FRAMEBUFFER, attachment, attachmentattrib, (GLint *)value); + } + else { + *value = 0; + } + if (glBindFramebufferFunc && (current_fbo != 0)) { + glBindFramebufferFunc(GL_DRAW_FRAMEBUFFER, current_fbo); + } + } else { + return false; + } + } else +#endif + { + PFNGLGETINTEGERVPROC glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv"); + if (glGetIntegervFunc) { + glGetIntegervFunc(attrib, (GLint *)value); + } else { + return false; + } + } + + glGetErrorFunc = (PFNGLGETERRORPROC)SDL_GL_GetProcAddress("glGetError"); + if (!glGetErrorFunc) { + return false; + } + + error = glGetErrorFunc(); + if (error != GL_NO_ERROR) { + if (error == GL_INVALID_ENUM) { + return SDL_SetError("OpenGL error: GL_INVALID_ENUM"); + } else if (error == GL_INVALID_VALUE) { + return SDL_SetError("OpenGL error: GL_INVALID_VALUE"); + } + return SDL_SetError("OpenGL error: %08X", error); + } + + // convert GL_CONTEXT_RELEASE_BEHAVIOR values back to SDL_GL_CONTEXT_RELEASE_BEHAVIOR values + if (attr == SDL_GL_CONTEXT_RELEASE_BEHAVIOR) { + *value = (*value == GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH) ? SDL_GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH : SDL_GL_CONTEXT_RELEASE_BEHAVIOR_NONE; + } + + return true; +#else + return SDL_Unsupported(); +#endif // SDL_VIDEO_OPENGL +} + +#define NOT_AN_OPENGL_WINDOW "The specified window isn't an OpenGL window" + +SDL_GLContext SDL_GL_CreateContext(SDL_Window *window) +{ + SDL_GLContext ctx = NULL; + CHECK_WINDOW_MAGIC(window, NULL); + + if (!(window->flags & SDL_WINDOW_OPENGL)) { + SDL_SetError(NOT_AN_OPENGL_WINDOW); + return NULL; + } + + ctx = _this->GL_CreateContext(_this, window); + + // Creating a context is assumed to make it current in the SDL driver. + if (ctx) { + _this->current_glwin = window; + _this->current_glctx = ctx; + SDL_SetTLS(&_this->current_glwin_tls, window, NULL); + SDL_SetTLS(&_this->current_glctx_tls, ctx, NULL); + } + return ctx; +} + +bool SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) +{ + bool result; + + if (!_this) { + return SDL_UninitializedVideo(); + } + + if (window == SDL_GL_GetCurrentWindow() && + context == SDL_GL_GetCurrentContext()) { + // We're already current. + return true; + } + + if (!context) { + window = NULL; + } else if (window) { + CHECK_WINDOW_MAGIC(window, false); + + if (!(window->flags & SDL_WINDOW_OPENGL)) { + return SDL_SetError(NOT_AN_OPENGL_WINDOW); + } + } else if (!_this->gl_allow_no_surface) { + return SDL_SetError("Use of OpenGL without a window is not supported on this platform"); + } + + result = _this->GL_MakeCurrent(_this, window, context); + if (result) { + _this->current_glwin = window; + _this->current_glctx = context; + SDL_SetTLS(&_this->current_glwin_tls, window, NULL); + SDL_SetTLS(&_this->current_glctx_tls, context, NULL); + } + return result; +} + +SDL_Window *SDL_GL_GetCurrentWindow(void) +{ + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + return (SDL_Window *)SDL_GetTLS(&_this->current_glwin_tls); +} + +SDL_GLContext SDL_GL_GetCurrentContext(void) +{ + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + return (SDL_GLContext)SDL_GetTLS(&_this->current_glctx_tls); +} + +SDL_EGLDisplay SDL_EGL_GetCurrentDisplay(void) +{ +#ifdef SDL_VIDEO_OPENGL_EGL + if (!_this) { + SDL_UninitializedVideo(); + return EGL_NO_DISPLAY; + } + if (!_this->egl_data) { + SDL_SetError("There is no current EGL display"); + return EGL_NO_DISPLAY; + } + return _this->egl_data->egl_display; +#else + SDL_SetError("SDL was not built with EGL support"); + return NULL; +#endif +} + +SDL_EGLConfig SDL_EGL_GetCurrentConfig(void) +{ +#ifdef SDL_VIDEO_OPENGL_EGL + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + if (!_this->egl_data) { + SDL_SetError("There is no current EGL display"); + return NULL; + } + return _this->egl_data->egl_config; +#else + SDL_SetError("SDL was not built with EGL support"); + return NULL; +#endif +} + +SDL_EGLConfig SDL_EGL_GetWindowSurface(SDL_Window *window) +{ +#ifdef SDL_VIDEO_OPENGL_EGL + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + if (!_this->egl_data) { + SDL_SetError("There is no current EGL display"); + return NULL; + } + if (_this->GL_GetEGLSurface) { + return _this->GL_GetEGLSurface(_this, window); + } + return NULL; +#else + SDL_SetError("SDL was not built with EGL support"); + return NULL; +#endif +} + +bool SDL_GL_SetSwapInterval(int interval) +{ + if (!_this) { + return SDL_UninitializedVideo(); + } else if (SDL_GL_GetCurrentContext() == NULL) { + return SDL_SetError("No OpenGL context has been made current"); + } else if (_this->GL_SetSwapInterval) { + return _this->GL_SetSwapInterval(_this, interval); + } else { + return SDL_SetError("Setting the swap interval is not supported"); + } +} + +bool SDL_GL_GetSwapInterval(int *interval) +{ + if (!interval) { + return SDL_InvalidParamError("interval"); + } + + *interval = 0; + + if (!_this) { + return SDL_SetError("no video driver"); + } else if (SDL_GL_GetCurrentContext() == NULL) { + return SDL_SetError("no current context"); + } else if (_this->GL_GetSwapInterval) { + return _this->GL_GetSwapInterval(_this, interval); + } else { + return SDL_SetError("not implemented"); + } +} + +bool SDL_GL_SwapWindow(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (!(window->flags & SDL_WINDOW_OPENGL)) { + return SDL_SetError(NOT_AN_OPENGL_WINDOW); + } + + if (SDL_GL_GetCurrentWindow() != window) { + return SDL_SetError("The specified window has not been made current"); + } + + return _this->GL_SwapWindow(_this, window); +} + +bool SDL_GL_DestroyContext(SDL_GLContext context) +{ + if (!_this) { + return SDL_UninitializedVideo(); \ + } + if (!context) { + return SDL_InvalidParamError("context"); + } + + if (SDL_GL_GetCurrentContext() == context) { + SDL_GL_MakeCurrent(NULL, NULL); + } + + return _this->GL_DestroyContext(_this, context); +} + +#if 0 // FIXME +/* + * Utility function used by SDL_WM_SetIcon(); flags & 1 for color key, flags + * & 2 for alpha channel. + */ +static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags) +{ + int x, y; + Uint32 colorkey; +#define SET_MASKBIT(icon, x, y, mask) \ + mask[(y * ((icon->w + 7) / 8)) + (x / 8)] &= ~(0x01 << (7 - (x % 8))) + + colorkey = icon->format->colorkey; + switch (SDL_BYTESPERPIXEL(icon->format)) { + case 1: + { + Uint8 *pixels; + for (y = 0; y < icon->h; ++y) { + pixels = (Uint8 *) icon->pixels + y * icon->pitch; + for (x = 0; x < icon->w; ++x) { + if (*pixels++ == colorkey) { + SET_MASKBIT(icon, x, y, mask); + } + } + } + } + break; + + case 2: + { + Uint16 *pixels; + for (y = 0; y < icon->h; ++y) { + pixels = (Uint16 *) icon->pixels + y * icon->pitch / 2; + for (x = 0; x < icon->w; ++x) { + if ((flags & 1) && *pixels == colorkey) { + SET_MASKBIT(icon, x, y, mask); + } else if ((flags & 2) + && (*pixels & icon->format->Amask) == 0) { + SET_MASKBIT(icon, x, y, mask); + } + pixels++; + } + } + } + break; + + case 4: + { + Uint32 *pixels; + for (y = 0; y < icon->h; ++y) { + pixels = (Uint32 *) icon->pixels + y * icon->pitch / 4; + for (x = 0; x < icon->w; ++x) { + if ((flags & 1) && *pixels == colorkey) { + SET_MASKBIT(icon, x, y, mask); + } else if ((flags & 2) + && (*pixels & icon->format->Amask) == 0) { + SET_MASKBIT(icon, x, y, mask); + } + pixels++; + } + } + } + break; + } +} + +/* + * Sets the window manager icon for the display window. + */ +void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) +{ + if (icon && _this->SetIcon) { + // Generate a mask if necessary, and create the icon! + if (mask == NULL) { + int mask_len = icon->h * (icon->w + 7) / 8; + int flags = 0; + mask = (Uint8 *) SDL_malloc(mask_len); + if (mask == NULL) { + return; + } + SDL_memset(mask, ~0, mask_len); + if (icon->flags & SDL_SRCCOLORKEY) + flags |= 1; + if (icon->flags & SDL_SRCALPHA) + flags |= 2; + if (flags) { + CreateMaskFromColorKeyOrAlpha(icon, mask, flags); + } + _this->SetIcon(_this, icon, mask); + SDL_free(mask); + } else { + _this->SetIcon(_this, icon, mask); + } + } +} +#endif + +SDL_TextInputType SDL_GetTextInputType(SDL_PropertiesID props) +{ + return (SDL_TextInputType)SDL_GetNumberProperty(props, SDL_PROP_TEXTINPUT_TYPE_NUMBER, SDL_TEXTINPUT_TYPE_TEXT); +} + +SDL_Capitalization SDL_GetTextInputCapitalization(SDL_PropertiesID props) +{ + if (SDL_HasProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER)) { + return (SDL_Capitalization)SDL_GetNumberProperty(props, SDL_PROP_TEXTINPUT_CAPITALIZATION_NUMBER, SDL_CAPITALIZE_NONE); + } + + switch (SDL_GetTextInputType(props)) { + case SDL_TEXTINPUT_TYPE_TEXT: + return SDL_CAPITALIZE_SENTENCES; + case SDL_TEXTINPUT_TYPE_TEXT_NAME: + return SDL_CAPITALIZE_WORDS; + default: + return SDL_CAPITALIZE_NONE; + } +} + +bool SDL_GetTextInputAutocorrect(SDL_PropertiesID props) +{ + return SDL_GetBooleanProperty(props, SDL_PROP_TEXTINPUT_AUTOCORRECT_BOOLEAN, true); +} + +bool SDL_GetTextInputMultiline(SDL_PropertiesID props) +{ + if (SDL_HasProperty(props, SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN)) { + return SDL_GetBooleanProperty(props, SDL_PROP_TEXTINPUT_MULTILINE_BOOLEAN, false); + } + + if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, false)) { + return false; + } else { + return true; + } +} + +static bool AutoShowingScreenKeyboard(void) +{ + const char *hint = SDL_GetHint(SDL_HINT_ENABLE_SCREEN_KEYBOARD); + if (((!hint || SDL_strcasecmp(hint, "auto") == 0) && !SDL_HasKeyboard()) || + SDL_GetStringBoolean(hint, false)) { + return true; + } else { + return false; + } +} + +bool SDL_StartTextInput(SDL_Window *window) +{ + return SDL_StartTextInputWithProperties(window, 0); +} + +bool SDL_StartTextInputWithProperties(SDL_Window *window, SDL_PropertiesID props) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (window->text_input_props) { + SDL_DestroyProperties(window->text_input_props); + window->text_input_props = 0; + } + + if (props) { + window->text_input_props = SDL_CreateProperties(); + if (!window->text_input_props) { + return false; + } + if (!SDL_CopyProperties(props, window->text_input_props)) { + return false; + } + } + + if (_this->SetTextInputProperties) { + _this->SetTextInputProperties(_this, window, props); + } + + // Show the on-screen keyboard, if desired + if (AutoShowingScreenKeyboard() && !SDL_ScreenKeyboardShown(window)) { + if (_this->ShowScreenKeyboard) { + _this->ShowScreenKeyboard(_this, window, props); + } + } + + if (!window->text_input_active) { + // Finally start the text input system + if (_this->StartTextInput) { + if (!_this->StartTextInput(_this, window, props)) { + return false; + } + } + window->text_input_active = true; + } + return true; +} + +bool SDL_TextInputActive(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + return window->text_input_active; +} + +bool SDL_StopTextInput(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (window->text_input_active) { + // Stop the text input system + if (_this->StopTextInput) { + _this->StopTextInput(_this, window); + } + window->text_input_active = false; + } + + // Hide the on-screen keyboard, if desired + if (AutoShowingScreenKeyboard() && SDL_ScreenKeyboardShown(window)) { + if (_this->HideScreenKeyboard) { + _this->HideScreenKeyboard(_this, window); + } + } + return true; +} + +bool SDL_SetTextInputArea(SDL_Window *window, const SDL_Rect *rect, int cursor) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (rect) { + SDL_copyp(&window->text_input_rect, rect); + window->text_input_cursor = cursor; + } else { + SDL_zero(window->text_input_rect); + window->text_input_cursor = 0; + } + + if (_this && _this->UpdateTextInputArea) { + if (!_this->UpdateTextInputArea(_this, window)) { + return false; + } + } + return true; +} + +bool SDL_GetTextInputArea(SDL_Window *window, SDL_Rect *rect, int *cursor) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (rect) { + SDL_copyp(rect, &window->text_input_rect); + } + if (cursor) { + *cursor = window->text_input_cursor; + } + return true; +} + +bool SDL_ClearComposition(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (_this->ClearComposition) { + return _this->ClearComposition(_this, window); + } + return true; +} + +bool SDL_HasScreenKeyboardSupport(void) +{ + if (_this && _this->HasScreenKeyboardSupport) { + return _this->HasScreenKeyboardSupport(_this); + } + return false; +} + +bool SDL_ScreenKeyboardShown(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (_this->IsScreenKeyboardShown) { + return _this->IsScreenKeyboardShown(_this, window); + } + return false; +} + +int SDL_GetMessageBoxCount(void) +{ + return SDL_GetAtomicInt(&SDL_messagebox_count); +} + +#ifdef SDL_VIDEO_DRIVER_ANDROID +#include "android/SDL_androidmessagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_WINDOWS +#include "windows/SDL_windowsmessagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_COCOA +#include "cocoa/SDL_cocoamessagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_UIKIT +#include "uikit/SDL_uikitmessagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND +#include "wayland/SDL_waylandmessagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_X11 +#include "x11/SDL_x11messagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_HAIKU +#include "haiku/SDL_bmessagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_RISCOS +#include "riscos/SDL_riscosmessagebox.h" +#endif +#ifdef SDL_VIDEO_DRIVER_VITA +#include "vita/SDL_vitamessagebox.h" +#endif + +bool SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + int dummybutton; + bool result = false; + bool show_cursor_prev; + SDL_Window *current_window; + SDL_MessageBoxData mbdata; + + if (!messageboxdata) { + return SDL_InvalidParamError("messageboxdata"); + } else if (messageboxdata->numbuttons < 0) { + return SDL_SetError("Invalid number of buttons"); + } + + // in case either the title or message was a pointer from SDL_GetError(), make a copy + // now, as we'll likely overwrite error state in here. + bool titleisstack = false, msgisstack = false; + char *titlecpy = NULL; + char *msgcpy = NULL; + if (messageboxdata->title) { + const size_t slen = SDL_strlen(messageboxdata->title) + 1; + titlecpy = SDL_small_alloc(char, slen, &titleisstack); + if (!titlecpy) { + return false; + } + SDL_memcpy(titlecpy, messageboxdata->title, slen); + } + + if (messageboxdata->message) { + const size_t slen = SDL_strlen(messageboxdata->message) + 1; + msgcpy = SDL_small_alloc(char, slen, &msgisstack); + if (!msgcpy) { + SDL_small_free(titlecpy, titleisstack); + return false; + } + SDL_memcpy(msgcpy, messageboxdata->message, slen); + } + + (void)SDL_AtomicIncRef(&SDL_messagebox_count); + + current_window = SDL_GetKeyboardFocus(); + SDL_UpdateMouseCapture(false); + SDL_SetRelativeMouseMode(false); + show_cursor_prev = SDL_CursorVisible(); + SDL_ShowCursor(); + SDL_ResetKeyboard(); + + if (!buttonID) { + buttonID = &dummybutton; + } + + SDL_memcpy(&mbdata, messageboxdata, sizeof(*messageboxdata)); + mbdata.title = titlecpy; + if (!mbdata.title) { + mbdata.title = ""; + } + mbdata.message = msgcpy; + if (!mbdata.message) { + mbdata.message = ""; + } + messageboxdata = &mbdata; + + SDL_ClearError(); + + if (_this && _this->ShowMessageBox) { + result = _this->ShowMessageBox(_this, messageboxdata, buttonID); + } else { + // It's completely fine to call this function before video is initialized + const char *driver_name = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); + if (driver_name && *driver_name != 0) { + const char *driver_attempt = driver_name; + while (driver_attempt && (*driver_attempt != 0) && !result) { + const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); + size_t driver_attempt_len = (driver_attempt_end) ? (driver_attempt_end - driver_attempt) + : SDL_strlen(driver_attempt); + for (int i = 0; bootstrap[i]; ++i) { + if (bootstrap[i]->ShowMessageBox && (driver_attempt_len == SDL_strlen(bootstrap[i]->name)) && + (SDL_strncasecmp(bootstrap[i]->name, driver_attempt, driver_attempt_len) == 0)) { + if (bootstrap[i]->ShowMessageBox(messageboxdata, buttonID)) { + result = true; + } + break; + } + } + + driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL; + } + } else { + for (int i = 0; bootstrap[i]; ++i) { + if (bootstrap[i]->ShowMessageBox && bootstrap[i]->ShowMessageBox(messageboxdata, buttonID)) { + result = true; + break; + } + } + } + } + + if (!result) { + const char *error = SDL_GetError(); + + if (!*error) { + SDL_SetError("No message system available"); + } + } else { + SDL_ClearError(); + } + + (void)SDL_AtomicDecRef(&SDL_messagebox_count); + + if (current_window) { + SDL_RaiseWindow(current_window); + } + + if (!show_cursor_prev) { + SDL_HideCursor(); + } + SDL_UpdateRelativeMouseMode(); + SDL_UpdateMouseCapture(false); + + SDL_small_free(msgcpy, msgisstack); + SDL_small_free(titlecpy, titleisstack); + + return result; +} + +bool SDL_ShowSimpleMessageBox(SDL_MessageBoxFlags flags, const char *title, const char *message, SDL_Window *window) +{ +#ifdef SDL_PLATFORM_EMSCRIPTEN + // !!! FIXME: propose a browser API for this, get this #ifdef out of here? + /* Web browsers don't (currently) have an API for a custom message box + that can block, but for the most common case (SDL_ShowSimpleMessageBox), + we can use the standard Javascript alert() function. */ + if (!title) { + title = ""; + } + if (!message) { + message = ""; + } + EM_ASM({ + alert(UTF8ToString($0) + "\n\n" + UTF8ToString($1)); + }, + title, message); + return true; +#elif defined(SDL_PLATFORM_3DS) + errorConf errCnf; + bool hasGpuRight; + + // If the video subsystem has not been initialised, set up graphics temporarily + hasGpuRight = gspHasGpuRight(); + if (!hasGpuRight) + gfxInitDefault(); + + errorInit(&errCnf, ERROR_TEXT_WORD_WRAP, CFG_LANGUAGE_EN); + errorText(&errCnf, message); + errorDisp(&errCnf); + + if (!hasGpuRight) + gfxExit(); + + return true; +#else + SDL_MessageBoxData data; + SDL_MessageBoxButtonData button; + + SDL_zero(data); + data.flags = flags; + data.title = title; + data.message = message; + data.numbuttons = 1; + data.buttons = &button; + data.window = window; + + SDL_zero(button); + button.flags |= SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT; + button.flags |= SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; + button.text = "OK"; + + return SDL_ShowMessageBox(&data, NULL); +#endif +} + +bool SDL_ShouldAllowTopmost(void) +{ + return SDL_GetHintBoolean(SDL_HINT_WINDOW_ALLOW_TOPMOST, true); +} + +bool SDL_ShowWindowSystemMenu(SDL_Window *window, int x, int y) +{ + CHECK_WINDOW_MAGIC(window, false) + CHECK_WINDOW_NOT_POPUP(window, false) + + if (_this->ShowWindowSystemMenu) { + _this->ShowWindowSystemMenu(window, x, y); + return true; + } + + return SDL_Unsupported(); +} + +bool SDL_SetWindowHitTest(SDL_Window *window, SDL_HitTest callback, void *callback_data) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (!_this->SetWindowHitTest) { + return SDL_Unsupported(); + } + + window->hit_test = callback; + window->hit_test_data = callback_data; + + return _this->SetWindowHitTest(window, callback != NULL); +} + +bool SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape) +{ + SDL_PropertiesID props; + SDL_Surface *surface; + + CHECK_WINDOW_MAGIC(window, false); + + if (!(window->flags & SDL_WINDOW_TRANSPARENT)) { + return SDL_SetError("Window must be created with SDL_WINDOW_TRANSPARENT"); + } + + props = SDL_GetWindowProperties(window); + if (!props) { + return false; + } + + surface = SDL_ConvertSurface(shape, SDL_PIXELFORMAT_ARGB32); + if (!surface) { + return false; + } + + if (!SDL_SetSurfaceProperty(props, SDL_PROP_WINDOW_SHAPE_POINTER, surface)) { + return false; + } + + if (_this->UpdateWindowShape) { + if (!_this->UpdateWindowShape(_this, window, surface)) { + return false; + } + } + return true; +} + +/* + * Functions used by iOS application delegates + */ +void SDL_OnApplicationWillTerminate(void) +{ + SDL_SendAppEvent(SDL_EVENT_TERMINATING); +} + +void SDL_OnApplicationDidReceiveMemoryWarning(void) +{ + SDL_SendAppEvent(SDL_EVENT_LOW_MEMORY); +} + +void SDL_OnApplicationWillEnterBackground(void) +{ + if (_this) { + SDL_Window *window; + for (window = _this->windows; window; window = window->next) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); + } + SDL_SetKeyboardFocus(NULL); + } + SDL_SendAppEvent(SDL_EVENT_WILL_ENTER_BACKGROUND); +} + +void SDL_OnApplicationDidEnterBackground(void) +{ + SDL_SendAppEvent(SDL_EVENT_DID_ENTER_BACKGROUND); +} + +void SDL_OnApplicationWillEnterForeground(void) +{ + SDL_SendAppEvent(SDL_EVENT_WILL_ENTER_FOREGROUND); +} + +void SDL_OnApplicationDidEnterForeground(void) +{ + SDL_SendAppEvent(SDL_EVENT_DID_ENTER_FOREGROUND); + + if (_this) { + SDL_Window *window; + for (window = _this->windows; window; window = window->next) { + SDL_SetKeyboardFocus(window); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + } + } +} + +#define NOT_A_VULKAN_WINDOW "The specified window isn't a Vulkan window" + +bool SDL_Vulkan_LoadLibrary(const char *path) +{ + bool result; + + if (!_this) { + return SDL_UninitializedVideo(); + } + if (_this->vulkan_config.loader_loaded) { + if (path && SDL_strcmp(path, _this->vulkan_config.loader_path) != 0) { + return SDL_SetError("Vulkan loader library already loaded"); + } + result = true; + } else { + if (!_this->Vulkan_LoadLibrary) { + return SDL_DllNotSupported("Vulkan"); + } + result = _this->Vulkan_LoadLibrary(_this, path); + } + if (result) { + _this->vulkan_config.loader_loaded++; + } + return result; +} + +SDL_FunctionPointer SDL_Vulkan_GetVkGetInstanceProcAddr(void) +{ + if (!_this) { + SDL_UninitializedVideo(); + return NULL; + } + if (!_this->vulkan_config.loader_loaded) { + SDL_SetError("No Vulkan loader has been loaded"); + return NULL; + } + return (SDL_FunctionPointer)_this->vulkan_config.vkGetInstanceProcAddr; +} + +void SDL_Vulkan_UnloadLibrary(void) +{ + if (!_this) { + SDL_UninitializedVideo(); + return; + } + if (_this->vulkan_config.loader_loaded > 0) { + if (--_this->vulkan_config.loader_loaded > 0) { + return; + } + if (_this->Vulkan_UnloadLibrary) { + _this->Vulkan_UnloadLibrary(_this); + } + } +} + +char const* const* SDL_Vulkan_GetInstanceExtensions(Uint32 *count) +{ + return _this->Vulkan_GetInstanceExtensions(_this, count); +} + +bool SDL_Vulkan_CreateSurface(SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + CHECK_WINDOW_MAGIC(window, false); + + if (!(window->flags & SDL_WINDOW_VULKAN)) { + return SDL_SetError(NOT_A_VULKAN_WINDOW); + } + + if (!instance) { + return SDL_InvalidParamError("instance"); + } + + if (!surface) { + return SDL_InvalidParamError("surface"); + } + + return _this->Vulkan_CreateSurface(_this, window, instance, allocator, surface); +} + +void SDL_Vulkan_DestroySurface(VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this && instance && surface && _this->Vulkan_DestroySurface) { + _this->Vulkan_DestroySurface(_this, instance, surface, allocator); + } +} + +bool SDL_Vulkan_GetPresentationSupport(VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex) +{ + if (!_this) { + SDL_UninitializedVideo(); + return false; + } + + if (!instance) { + SDL_InvalidParamError("instance"); + return false; + } + + if (!physicalDevice) { + SDL_InvalidParamError("physicalDevice"); + return false; + } + + if (_this->Vulkan_GetPresentationSupport) { + return _this->Vulkan_GetPresentationSupport(_this, instance, physicalDevice, queueFamilyIndex); + } + + /* If the backend does not have this function then it does not have a + * WSI function to query it; in other words it's not necessary to check + * as it is always supported. + */ + return true; +} + +SDL_MetalView SDL_Metal_CreateView(SDL_Window *window) +{ + CHECK_WINDOW_MAGIC(window, NULL); + + if (!_this->Metal_CreateView) { + SDL_Unsupported(); + return NULL; + } + + if (!(window->flags & SDL_WINDOW_METAL)) { + // No problem, we can convert to Metal + if (window->flags & SDL_WINDOW_OPENGL) { + window->flags &= ~SDL_WINDOW_OPENGL; + SDL_GL_UnloadLibrary(); + } + if (window->flags & SDL_WINDOW_VULKAN) { + window->flags &= ~SDL_WINDOW_VULKAN; + SDL_Vulkan_UnloadLibrary(); + } + window->flags |= SDL_WINDOW_METAL; + } + + return _this->Metal_CreateView(_this, window); +} + +void SDL_Metal_DestroyView(SDL_MetalView view) +{ + if (_this && view && _this->Metal_DestroyView) { + _this->Metal_DestroyView(_this, view); + } +} + +void *SDL_Metal_GetLayer(SDL_MetalView view) +{ + if (_this && _this->Metal_GetLayer) { + if (view) { + return _this->Metal_GetLayer(_this, view); + } else { + SDL_InvalidParamError("view"); + return NULL; + } + } else { + SDL_SetError("Metal is not supported."); + return NULL; + } +} + +#if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_EMSCRIPTEN) +const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name) +{ + // Reference: https://www.w3.org/TR/css-ui-4/#cursor + // Also in: https://www.freedesktop.org/wiki/Specifications/cursor-spec/ + switch (id) { + case SDL_SYSTEM_CURSOR_DEFAULT: + return "default"; + + case SDL_SYSTEM_CURSOR_TEXT: + return "text"; + + case SDL_SYSTEM_CURSOR_WAIT: + return "wait"; + + case SDL_SYSTEM_CURSOR_CROSSHAIR: + return "crosshair"; + + case SDL_SYSTEM_CURSOR_PROGRESS: + return "progress"; + + case SDL_SYSTEM_CURSOR_NWSE_RESIZE: + if (fallback_name) { + // only a single arrow + *fallback_name = "nw-resize"; + } + return "nwse-resize"; + + case SDL_SYSTEM_CURSOR_NESW_RESIZE: + if (fallback_name) { + // only a single arrow + *fallback_name = "ne-resize"; + } + return "nesw-resize"; + + case SDL_SYSTEM_CURSOR_EW_RESIZE: + if (fallback_name) { + *fallback_name = "col-resize"; + } + return "ew-resize"; + + case SDL_SYSTEM_CURSOR_NS_RESIZE: + if (fallback_name) { + *fallback_name = "row-resize"; + } + return "ns-resize"; + + case SDL_SYSTEM_CURSOR_MOVE: + return "all-scroll"; + + case SDL_SYSTEM_CURSOR_NOT_ALLOWED: + return "not-allowed"; + + case SDL_SYSTEM_CURSOR_POINTER: + return "pointer"; + + case SDL_SYSTEM_CURSOR_NW_RESIZE: + return "nw-resize"; + + case SDL_SYSTEM_CURSOR_N_RESIZE: + return "n-resize"; + + case SDL_SYSTEM_CURSOR_NE_RESIZE: + return "ne-resize"; + + case SDL_SYSTEM_CURSOR_E_RESIZE: + return "e-resize"; + + case SDL_SYSTEM_CURSOR_SE_RESIZE: + return "se-resize"; + + case SDL_SYSTEM_CURSOR_S_RESIZE: + return "s-resize"; + + case SDL_SYSTEM_CURSOR_SW_RESIZE: + return "sw-resize"; + + case SDL_SYSTEM_CURSOR_W_RESIZE: + return "w-resize"; + + default: + return "default"; + } +} +#endif diff --git a/contrib/SDL-3.2.8/src/video/SDL_video_c.h b/contrib/SDL-3.2.8/src/video/SDL_video_c.h new file mode 100644 index 0000000..fc0843b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_video_c.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_video_c_h_ +#define SDL_video_c_h_ + +#include "SDL_internal.h" + +struct SDL_VideoDevice; + +/** + * Initialize the video subsystem, optionally specifying a video driver. + * + * This function initializes the video subsystem, setting up a connection to + * the window manager, etc, and determines the available display modes and + * pixel formats, but does not initialize a window or graphics mode. + * + * If you use this function and you haven't used the SDL_INIT_VIDEO flag with + * either SDL_Init() or SDL_InitSubSystem(), you should call SDL_VideoQuit() + * before calling SDL_Quit(). + * + * It is safe to call this function multiple times. SDL_VideoInit() will call + * SDL_VideoQuit() itself if the video subsystem has already been initialized. + * + * You can use SDL_GetNumVideoDrivers() and SDL_GetVideoDriver() to find a + * specific `driver_name`. + * + * \param driver_name the name of a video driver to initialize, or NULL for + * the default driver + * \returns true on success or false on failure; call + * SDL_GetError() for more information. + */ +extern bool SDL_VideoInit(const char *driver_name); + +/** + * Shut down the video subsystem, if initialized with SDL_VideoInit(). + * + * This function closes all windows, and restores the original video mode. + */ +extern void SDL_VideoQuit(void); + +extern bool SDL_SetWindowTextureVSync(struct SDL_VideoDevice *_this, SDL_Window *window, int vsync); + +#if defined(SDL_VIDEO_DRIVER_X11) || defined(SDL_VIDEO_DRIVER_WAYLAND) || defined(SDL_VIDEO_DRIVER_EMSCRIPTEN) +const char *SDL_GetCSSCursorName(SDL_SystemCursor id, const char **fallback_name); +#endif + +extern bool SDL_AddWindowRenderer(SDL_Window *window, SDL_Renderer *renderer); +extern void SDL_RemoveWindowRenderer(SDL_Window *window, SDL_Renderer *renderer); + +#endif // SDL_video_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_video_unsupported.c b/contrib/SDL-3.2.8/src/video/SDL_video_unsupported.c new file mode 100644 index 0000000..52e5b8b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_video_unsupported.c @@ -0,0 +1,115 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_VIDEO_DRIVER_WINDOWS + +#if defined(SDL_PLATFORM_WINDOWS) + +bool SDL_RegisterApp(const char *name, Uint32 style, void *hInst) +{ + (void)name; + (void)style; + (void)hInst; + return true; +} + +void SDL_UnregisterApp(void) +{ +} + +void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) +{ +} + +#endif // defined(SDL_PLATFORM_WINDOWS) + +SDL_DECLSPEC bool SDLCALL SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex); +bool SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex) +{ + (void)displayID; + (void)adapterIndex; + (void)outputIndex; + return SDL_Unsupported(); +} + +SDL_DECLSPEC int SDLCALL SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID); +int SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID) +{ + (void)displayID; + SDL_Unsupported(); + return -1; +} + +#elif defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + +SDL_DECLSPEC int SDLCALL SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID); +int SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID) +{ + (void)displayID; + SDL_Unsupported(); + return -1; +} + +#endif // !SDL_VIDEO_DRIVER_WINDOWS + +#ifndef SDL_PLATFORM_GDK + +SDL_DECLSPEC bool SDLCALL SDL_GetGDKTaskQueue(void *outTaskQueue); +bool SDL_GetGDKTaskQueue(void *outTaskQueue) +{ + (void)outTaskQueue; + return SDL_Unsupported(); +} + +#endif + +#ifndef SDL_VIDEO_DRIVER_UIKIT + +SDL_DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void); +void SDL_OnApplicationDidChangeStatusBarOrientation(void) +{ + SDL_Unsupported(); +} + +#endif + +#ifndef SDL_VIDEO_DRIVER_UIKIT + +typedef void (SDLCALL *SDL_iOSAnimationCallback)(void *userdata); +SDL_DECLSPEC bool SDLCALL SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam); +bool SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam) +{ + (void)window; + (void)interval; + (void)callback; + (void)callbackParam; + return SDL_Unsupported(); +} + +SDL_DECLSPEC void SDLCALL SDL_SetiOSEventPump(bool enabled); +void SDL_SetiOSEventPump(bool enabled) +{ + (void)enabled; + SDL_Unsupported(); +} +#endif + diff --git a/contrib/SDL-3.2.8/src/video/SDL_vulkan_internal.h b/contrib/SDL-3.2.8/src/video/SDL_vulkan_internal.h new file mode 100644 index 0000000..b8f9b85 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_vulkan_internal.h @@ -0,0 +1,91 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_vulkan_internal_h_ +#define SDL_vulkan_internal_h_ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_VULKAN +#ifdef SDL_VIDEO_DRIVER_ANDROID +#define VK_USE_PLATFORM_ANDROID_KHR +#endif +#ifdef SDL_VIDEO_DRIVER_COCOA +#define VK_USE_PLATFORM_METAL_EXT +#define VK_USE_PLATFORM_MACOS_MVK +#endif +#ifdef SDL_VIDEO_DRIVER_UIKIT +#define VK_USE_PLATFORM_METAL_EXT +#define VK_USE_PLATFORM_IOS_MVK +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND +#define VK_USE_PLATFORM_WAYLAND_KHR +#include "wayland/SDL_waylanddyn.h" +#endif +#ifdef SDL_VIDEO_DRIVER_WINDOWS +#define VK_USE_PLATFORM_WIN32_KHR +#include "../core/windows/SDL_windows.h" +#endif +#ifdef SDL_VIDEO_DRIVER_X11 +#define VK_USE_PLATFORM_XLIB_KHR +#define VK_USE_PLATFORM_XCB_KHR +#endif + +#define VK_NO_PROTOTYPES +#include "./khronos/vulkan/vulkan.h" + +#include + +extern const char *SDL_Vulkan_GetResultString(VkResult result); + +extern VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( + PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties, + Uint32 *extensionCount); // free returned list with SDL_free + +/* Create a surface directly from a display connected to a physical device + * using the DisplayKHR extension. + * This needs to be passed an instance that was created with the VK_KHR_DISPLAY_EXTENSION_NAME + * extension. */ +extern bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); + +/* Platform independent base function for destroying the Vulkan surface. Unlike surface + * creation, surface destruction doesn't require platform specific extensions like + * VK_KHR_wayland_surface, VK_KHR_android_surface or VK_EXT_metal_surface. The only + * necessary extension is cross platform VK_KHR_surface, which is a dependency to all + * WSI platform extensions, so we can handle surface destruction in an platform-independent + * manner. */ +extern void SDL_Vulkan_DestroySurface_Internal(void *vkGetInstanceProcAddr, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); +#else + +// No SDL Vulkan support, just include the header for typedefs +#include + +typedef void (*PFN_vkGetInstanceProcAddr)(void); +typedef int (*PFN_vkEnumerateInstanceExtensionProperties)(void); + +#endif // SDL_VIDEO_VULKAN + +#endif // SDL_vulkan_internal_h_ diff --git a/contrib/SDL-3.2.8/src/video/SDL_vulkan_utils.c b/contrib/SDL-3.2.8/src/video/SDL_vulkan_utils.c new file mode 100644 index 0000000..4fd950a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_vulkan_utils.c @@ -0,0 +1,487 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_vulkan_internal.h" + +#ifdef SDL_VIDEO_VULKAN + +const char *SDL_Vulkan_GetResultString(VkResult result) +{ + switch ((int)result) { + case VK_SUCCESS: + return "VK_SUCCESS"; + case VK_NOT_READY: + return "VK_NOT_READY"; + case VK_TIMEOUT: + return "VK_TIMEOUT"; + case VK_EVENT_SET: + return "VK_EVENT_SET"; + case VK_EVENT_RESET: + return "VK_EVENT_RESET"; + case VK_INCOMPLETE: + return "VK_INCOMPLETE"; + case VK_ERROR_OUT_OF_HOST_MEMORY: + return "VK_ERROR_OUT_OF_HOST_MEMORY"; + case VK_ERROR_OUT_OF_DEVICE_MEMORY: + return "VK_ERROR_OUT_OF_DEVICE_MEMORY"; + case VK_ERROR_INITIALIZATION_FAILED: + return "VK_ERROR_INITIALIZATION_FAILED"; + case VK_ERROR_DEVICE_LOST: + return "VK_ERROR_DEVICE_LOST"; + case VK_ERROR_MEMORY_MAP_FAILED: + return "VK_ERROR_MEMORY_MAP_FAILED"; + case VK_ERROR_LAYER_NOT_PRESENT: + return "VK_ERROR_LAYER_NOT_PRESENT"; + case VK_ERROR_EXTENSION_NOT_PRESENT: + return "VK_ERROR_EXTENSION_NOT_PRESENT"; + case VK_ERROR_FEATURE_NOT_PRESENT: + return "VK_ERROR_FEATURE_NOT_PRESENT"; + case VK_ERROR_INCOMPATIBLE_DRIVER: + return "VK_ERROR_INCOMPATIBLE_DRIVER"; + case VK_ERROR_TOO_MANY_OBJECTS: + return "VK_ERROR_TOO_MANY_OBJECTS"; + case VK_ERROR_FORMAT_NOT_SUPPORTED: + return "VK_ERROR_FORMAT_NOT_SUPPORTED"; + case VK_ERROR_FRAGMENTED_POOL: + return "VK_ERROR_FRAGMENTED_POOL"; + case VK_ERROR_UNKNOWN: + return "VK_ERROR_UNKNOWN"; + case VK_ERROR_OUT_OF_POOL_MEMORY: + return "VK_ERROR_OUT_OF_POOL_MEMORY"; + case VK_ERROR_INVALID_EXTERNAL_HANDLE: + return "VK_ERROR_INVALID_EXTERNAL_HANDLE"; + case VK_ERROR_FRAGMENTATION: + return "VK_ERROR_FRAGMENTATION"; + case VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS: + return "VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS"; + case VK_ERROR_SURFACE_LOST_KHR: + return "VK_ERROR_SURFACE_LOST_KHR"; + case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR: + return "VK_ERROR_NATIVE_WINDOW_IN_USE_KHR"; + case VK_SUBOPTIMAL_KHR: + return "VK_SUBOPTIMAL_KHR"; + case VK_ERROR_OUT_OF_DATE_KHR: + return "VK_ERROR_OUT_OF_DATE_KHR"; + case VK_ERROR_INCOMPATIBLE_DISPLAY_KHR: + return "VK_ERROR_INCOMPATIBLE_DISPLAY_KHR"; + case VK_ERROR_VALIDATION_FAILED_EXT: + return "VK_ERROR_VALIDATION_FAILED_EXT"; + case VK_ERROR_INVALID_SHADER_NV: + return "VK_ERROR_INVALID_SHADER_NV"; +#if VK_HEADER_VERSION >= 135 && VK_HEADER_VERSION < 162 + case VK_ERROR_INCOMPATIBLE_VERSION_KHR: + return "VK_ERROR_INCOMPATIBLE_VERSION_KHR"; +#endif + case VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT: + return "VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT"; + case VK_ERROR_NOT_PERMITTED_EXT: + return "VK_ERROR_NOT_PERMITTED_EXT"; + case VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT: + return "VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT"; + case VK_THREAD_IDLE_KHR: + return "VK_THREAD_IDLE_KHR"; + case VK_THREAD_DONE_KHR: + return "VK_THREAD_DONE_KHR"; + case VK_OPERATION_DEFERRED_KHR: + return "VK_OPERATION_DEFERRED_KHR"; + case VK_OPERATION_NOT_DEFERRED_KHR: + return "VK_OPERATION_NOT_DEFERRED_KHR"; + case VK_PIPELINE_COMPILE_REQUIRED_EXT: + return "VK_PIPELINE_COMPILE_REQUIRED_EXT"; + default: + break; + } + if (result < 0) { + return "VK_ERROR_"; + } + return "VK_"; +} + +VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( + PFN_vkEnumerateInstanceExtensionProperties vkEnumerateInstanceExtensionProperties, + Uint32 *extensionCount) +{ + Uint32 count = 0; + VkResult rc = vkEnumerateInstanceExtensionProperties(NULL, &count, NULL); + VkExtensionProperties *result; + + if (rc == VK_ERROR_INCOMPATIBLE_DRIVER) { + // Avoid the ERR_MAX_STRLEN limit by passing part of the message as a string argument. + SDL_SetError( + "You probably don't have a working Vulkan driver installed. %s %s %s(%d)", + "Getting Vulkan extensions failed:", + "vkEnumerateInstanceExtensionProperties returned", + SDL_Vulkan_GetResultString(rc), + (int)rc); + return NULL; + } else if (rc != VK_SUCCESS) { + SDL_SetError( + "Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned " + "%s(%d)", + SDL_Vulkan_GetResultString(rc), + (int)rc); + return NULL; + } + + if (count == 0) { + result = (VkExtensionProperties *)SDL_calloc(1, sizeof(VkExtensionProperties)); // so we can return non-null + } else { + result = (VkExtensionProperties *)SDL_calloc(count, sizeof(VkExtensionProperties)); + } + + if (!result) { + return NULL; + } + + rc = vkEnumerateInstanceExtensionProperties(NULL, &count, result); + if (rc != VK_SUCCESS) { + SDL_SetError( + "Getting Vulkan extensions failed: vkEnumerateInstanceExtensionProperties returned " + "%s(%d)", + SDL_Vulkan_GetResultString(rc), + (int)rc); + SDL_free(result); + return NULL; + } + *extensionCount = count; + return result; +} + +// Alpha modes, in order of preference +static const VkDisplayPlaneAlphaFlagBitsKHR alphaModes[4] = { + VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR, + VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR, +}; + +bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)vkGetInstanceProcAddr_; +#define VULKAN_INSTANCE_FUNCTION(name) \ + PFN_##name name = (PFN_##name)vkGetInstanceProcAddr((VkInstance)instance, #name) + VULKAN_INSTANCE_FUNCTION(vkEnumeratePhysicalDevices); + VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPropertiesKHR); + VULKAN_INSTANCE_FUNCTION(vkGetDisplayModePropertiesKHR); + VULKAN_INSTANCE_FUNCTION(vkGetPhysicalDeviceDisplayPlanePropertiesKHR); + VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneCapabilitiesKHR); + VULKAN_INSTANCE_FUNCTION(vkGetDisplayPlaneSupportedDisplaysKHR); + VULKAN_INSTANCE_FUNCTION(vkCreateDisplayPlaneSurfaceKHR); +#undef VULKAN_INSTANCE_FUNCTION + VkDisplaySurfaceCreateInfoKHR createInfo; + VkResult rc; + uint32_t physicalDeviceCount = 0; + VkPhysicalDevice *physicalDevices = NULL; + uint32_t physicalDeviceIndex; + const char *chosenDisplayId; + int displayId = 0; // Counting from physical device 0, display 0 + + if (!vkEnumeratePhysicalDevices || + !vkGetPhysicalDeviceDisplayPropertiesKHR || + !vkGetDisplayModePropertiesKHR || + !vkGetPhysicalDeviceDisplayPlanePropertiesKHR || + !vkGetDisplayPlaneCapabilitiesKHR || + !vkGetDisplayPlaneSupportedDisplaysKHR || + !vkCreateDisplayPlaneSurfaceKHR) { + SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); + goto error; + } + chosenDisplayId = SDL_GetHint(SDL_HINT_VULKAN_DISPLAY); + if (chosenDisplayId) { + displayId = SDL_atoi(chosenDisplayId); + } + + // Enumerate physical devices + rc = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, NULL); + if (rc != VK_SUCCESS) { + SDL_SetError("Could not enumerate Vulkan physical devices"); + goto error; + } + + if (physicalDeviceCount == 0) { + SDL_SetError("No Vulkan physical devices"); + goto error; + } + + physicalDevices = (VkPhysicalDevice *)SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); + if (!physicalDevices) { + goto error; + } + + rc = vkEnumeratePhysicalDevices(instance, &physicalDeviceCount, physicalDevices); + if (rc != VK_SUCCESS) { + SDL_SetError("Error enumerating physical devices"); + goto error; + } + + for (physicalDeviceIndex = 0; physicalDeviceIndex < physicalDeviceCount; physicalDeviceIndex++) { + VkPhysicalDevice physicalDevice = physicalDevices[physicalDeviceIndex]; + uint32_t displayPropertiesCount = 0; + VkDisplayPropertiesKHR *displayProperties = NULL; + uint32_t displayModePropertiesCount = 0; + VkDisplayModePropertiesKHR *displayModeProperties = NULL; + int bestMatchIndex = -1; + uint32_t refreshRate = 0; + uint32_t i; + uint32_t displayPlanePropertiesCount = 0; + int planeIndex = -1; + VkDisplayKHR display; + VkDisplayPlanePropertiesKHR *displayPlaneProperties = NULL; + VkExtent2D extent; + VkDisplayPlaneCapabilitiesKHR planeCaps = { 0 }; + + // Get information about the physical displays + rc = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, NULL); + if (rc != VK_SUCCESS || displayPropertiesCount == 0) { + // This device has no physical device display properties, move on to next. + continue; + } + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display properties for device %u: %u", + physicalDeviceIndex, displayPropertiesCount); + + if (displayId < 0 || (uint32_t)displayId >= displayPropertiesCount) { + // Display id specified was higher than number of available displays, move to next physical device. + displayId -= displayPropertiesCount; + continue; + } + + displayProperties = (VkDisplayPropertiesKHR *)SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount); + if (!displayProperties) { + goto error; + } + + rc = vkGetPhysicalDeviceDisplayPropertiesKHR(physicalDevice, &displayPropertiesCount, displayProperties); + if (rc != VK_SUCCESS || displayPropertiesCount == 0) { + SDL_free(displayProperties); + SDL_SetError("Error enumerating physical device displays"); + goto error; + } + + display = displayProperties[displayId].display; + extent = displayProperties[displayId].physicalResolution; + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Display: %s Native resolution: %ux%u", + displayProperties[displayId].displayName, extent.width, extent.height); + + SDL_free(displayProperties); + displayProperties = NULL; + + // Get display mode properties for the chosen display + rc = vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, NULL); + if (rc != VK_SUCCESS || displayModePropertiesCount == 0) { + SDL_SetError("Error enumerating display modes"); + goto error; + } + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display modes: %u", displayModePropertiesCount); + + displayModeProperties = (VkDisplayModePropertiesKHR *)SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount); + if (!displayModeProperties) { + goto error; + } + + rc = vkGetDisplayModePropertiesKHR(physicalDevice, display, &displayModePropertiesCount, displayModeProperties); + if (rc != VK_SUCCESS || displayModePropertiesCount == 0) { + SDL_SetError("Error enumerating display modes"); + SDL_free(displayModeProperties); + goto error; + } + + // Try to find a display mode that matches the native resolution + for (i = 0; i < displayModePropertiesCount; ++i) { + if (displayModeProperties[i].parameters.visibleRegion.width == extent.width && + displayModeProperties[i].parameters.visibleRegion.height == extent.height && + displayModeProperties[i].parameters.refreshRate > refreshRate) { + bestMatchIndex = i; + refreshRate = displayModeProperties[i].parameters.refreshRate; + } + } + + if (bestMatchIndex < 0) { + SDL_SetError("Found no matching display mode"); + SDL_free(displayModeProperties); + goto error; + } + + SDL_zero(createInfo); + createInfo.displayMode = displayModeProperties[bestMatchIndex].displayMode; + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Matching mode %ux%u with refresh rate %u", + displayModeProperties[bestMatchIndex].parameters.visibleRegion.width, + displayModeProperties[bestMatchIndex].parameters.visibleRegion.height, + refreshRate); + + SDL_free(displayModeProperties); + displayModeProperties = NULL; + + // Try to find a plane index that supports our display + rc = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, NULL); + if (rc != VK_SUCCESS || displayPlanePropertiesCount == 0) { + SDL_SetError("Error enumerating display planes"); + goto error; + } + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount); + + displayPlaneProperties = (VkDisplayPlanePropertiesKHR *)SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount); + if (!displayPlaneProperties) { + goto error; + } + + rc = vkGetPhysicalDeviceDisplayPlanePropertiesKHR(physicalDevice, &displayPlanePropertiesCount, displayPlaneProperties); + if (rc != VK_SUCCESS || displayPlanePropertiesCount == 0) { + SDL_SetError("Error enumerating display plane properties"); + SDL_free(displayPlaneProperties); + goto error; + } + + for (i = 0; i < displayPlanePropertiesCount; ++i) { + uint32_t planeSupportedDisplaysCount = 0; + VkDisplayKHR *planeSupportedDisplays = NULL; + uint32_t j; + + // Check if plane is attached to a display, if not, continue. + if (displayPlaneProperties[i].currentDisplay == VK_NULL_HANDLE) { + continue; + } + + // Check supported displays for this plane. + rc = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, NULL); + if (rc != VK_SUCCESS || planeSupportedDisplaysCount == 0) { + continue; // No supported displays, on to next plane. + } + + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount); + + planeSupportedDisplays = (VkDisplayKHR *)SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount); + if (!planeSupportedDisplays) { + SDL_free(displayPlaneProperties); + goto error; + } + + rc = vkGetDisplayPlaneSupportedDisplaysKHR(physicalDevice, i, &planeSupportedDisplaysCount, planeSupportedDisplays); + if (rc != VK_SUCCESS || planeSupportedDisplaysCount == 0) { + SDL_SetError("Error enumerating supported displays, or no supported displays"); + SDL_free(planeSupportedDisplays); + SDL_free(displayPlaneProperties); + goto error; + } + + for (j = 0; j < planeSupportedDisplaysCount && planeSupportedDisplays[j] != display; ++j) { + } + + SDL_free(planeSupportedDisplays); + planeSupportedDisplays = NULL; + + if (j == planeSupportedDisplaysCount) { + // This display is not supported for this plane, move on. + continue; + } + + rc = vkGetDisplayPlaneCapabilitiesKHR(physicalDevice, createInfo.displayMode, i, &planeCaps); + if (rc != VK_SUCCESS) { + SDL_SetError("Error getting display plane capabilities"); + SDL_free(displayPlaneProperties); + goto error; + } + + // Check if plane fulfills extent requirements. + if (extent.width >= planeCaps.minDstExtent.width && extent.height >= planeCaps.minDstExtent.height && + extent.width <= planeCaps.maxDstExtent.width && extent.height <= planeCaps.maxDstExtent.height) { + // If it does, choose this plane. + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Choosing plane %u, minimum extent %ux%u maximum extent %ux%u", i, + planeCaps.minDstExtent.width, planeCaps.minDstExtent.height, + planeCaps.maxDstExtent.width, planeCaps.maxDstExtent.height); + planeIndex = i; + break; + } + } + + if (planeIndex < 0) { + SDL_SetError("No plane supports the selected resolution"); + SDL_free(displayPlaneProperties); + goto error; + } + + createInfo.planeIndex = planeIndex; + createInfo.planeStackIndex = displayPlaneProperties[planeIndex].currentStackIndex; + SDL_free(displayPlaneProperties); + displayPlaneProperties = NULL; + + // Find a supported alpha mode. Not all planes support OPAQUE + createInfo.alphaMode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR; + for (i = 0; i < SDL_arraysize(alphaModes); i++) { + if (planeCaps.supportedAlpha & alphaModes[i]) { + createInfo.alphaMode = alphaModes[i]; + break; + } + } + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Chose alpha mode 0x%x", createInfo.alphaMode); + + // Found a match, finally! Fill in extent, and break from loop + createInfo.imageExtent = extent; + break; + } + + SDL_free(physicalDevices); + physicalDevices = NULL; + + if (physicalDeviceIndex == physicalDeviceCount) { + SDL_SetError("No usable displays found or requested display out of range"); + goto error; + } + + createInfo.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR; + createInfo.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; + createInfo.globalAlpha = 1.0f; + + rc = vkCreateDisplayPlaneSurfaceKHR(instance, &createInfo, allocator, surface); + if (rc != VK_SUCCESS) { + SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(rc)); + goto error; + } + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Created surface"); + return true; + +error: + SDL_free(physicalDevices); + return false; +} + +void SDL_Vulkan_DestroySurface_Internal(void *vkGetInstanceProcAddr_, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)vkGetInstanceProcAddr_; + PFN_vkDestroySurfaceKHR vkDestroySurfaceKHR = + (PFN_vkDestroySurfaceKHR)vkGetInstanceProcAddr( + instance, + "vkDestroySurfaceKHR"); + + if (vkDestroySurfaceKHR) { + vkDestroySurfaceKHR(instance, surface, allocator); + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/SDL_yuv.c b/contrib/SDL-3.2.8/src/video/SDL_yuv.c new file mode 100644 index 0000000..ccacfcf --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_yuv.c @@ -0,0 +1,2592 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_pixels_c.h" +#include "SDL_yuv_c.h" + +#include "yuv2rgb/yuv_rgb.h" + + +#ifdef SDL_HAVE_YUV +static bool IsPlanar2x2Format(SDL_PixelFormat format); +#endif + +/* + * Calculate YUV size and pitch. Check for overflow. + * Output 'pitch' that can be used with SDL_ConvertPixels() + */ +bool SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, size_t *pitch) +{ +#ifdef SDL_HAVE_YUV + int sz_plane = 0, sz_plane_chroma = 0, sz_plane_packed = 0; + + if (IsPlanar2x2Format(format) == true) { + { + /* sz_plane == w * h; */ + size_t s1; + if (!SDL_size_mul_check_overflow(w, h, &s1)) { + return SDL_SetError("width * height would overflow"); + } + sz_plane = (int) s1; + } + + { + /* sz_plane_chroma == ((w + 1) / 2) * ((h + 1) / 2); */ + size_t s1, s2, s3; + if (!SDL_size_add_check_overflow(w, 1, &s1)) { + return SDL_SetError("width + 1 would overflow"); + } + s1 = s1 / 2; + if (!SDL_size_add_check_overflow(h, 1, &s2)) { + return SDL_SetError("height + 1 would overflow"); + } + s2 = s2 / 2; + if (!SDL_size_mul_check_overflow(s1, s2, &s3)) { + return SDL_SetError("width * height would overflow"); + } + sz_plane_chroma = (int) s3; + } + } else { + /* sz_plane_packed == ((w + 1) / 2) * h; */ + size_t s1, s2; + if (!SDL_size_add_check_overflow(w, 1, &s1)) { + return SDL_SetError("width + 1 would overflow"); + } + s1 = s1 / 2; + if (!SDL_size_mul_check_overflow(s1, h, &s2)) { + return SDL_SetError("width * height would overflow"); + } + sz_plane_packed = (int) s2; + } + + switch (format) { + case SDL_PIXELFORMAT_YV12: /**< Planar mode: Y + V + U (3 planes) */ + case SDL_PIXELFORMAT_IYUV: /**< Planar mode: Y + U + V (3 planes) */ + + if (pitch) { + *pitch = w; + } + + if (size) { + // dst_size == sz_plane + sz_plane_chroma + sz_plane_chroma; + size_t s1, s2; + if (!SDL_size_add_check_overflow(sz_plane, sz_plane_chroma, &s1)) { + return SDL_SetError("Y + U would overflow"); + } + if (!SDL_size_add_check_overflow(s1, sz_plane_chroma, &s2)) { + return SDL_SetError("Y + U + V would overflow"); + } + *size = (int)s2; + } + break; + + case SDL_PIXELFORMAT_YUY2: /**< Packed mode: Y0+U0+Y1+V0 (1 plane) */ + case SDL_PIXELFORMAT_UYVY: /**< Packed mode: U0+Y0+V0+Y1 (1 plane) */ + case SDL_PIXELFORMAT_YVYU: /**< Packed mode: Y0+V0+Y1+U0 (1 plane) */ + + if (pitch) { + /* pitch == ((w + 1) / 2) * 4; */ + size_t p1, p2; + if (!SDL_size_add_check_overflow(w, 1, &p1)) { + return SDL_SetError("width + 1 would overflow"); + } + p1 = p1 / 2; + if (!SDL_size_mul_check_overflow(p1, 4, &p2)) { + return SDL_SetError("width * 4 would overflow"); + } + *pitch = p2; + } + + if (size) { + /* dst_size == 4 * sz_plane_packed; */ + size_t s1; + if (!SDL_size_mul_check_overflow(sz_plane_packed, 4, &s1)) { + return SDL_SetError("plane * 4 would overflow"); + } + *size = (int) s1; + } + break; + + case SDL_PIXELFORMAT_NV12: /**< Planar mode: Y + U/V interleaved (2 planes) */ + case SDL_PIXELFORMAT_NV21: /**< Planar mode: Y + V/U interleaved (2 planes) */ + if (pitch) { + *pitch = w; + } + + if (size) { + // dst_size == sz_plane + sz_plane_chroma + sz_plane_chroma; + size_t s1, s2; + if (!SDL_size_add_check_overflow(sz_plane, sz_plane_chroma, &s1)) { + return SDL_SetError("Y + U would overflow"); + } + if (!SDL_size_add_check_overflow(s1, sz_plane_chroma, &s2)) { + return SDL_SetError("Y + U + V would overflow"); + } + *size = (int) s2; + } + break; + + default: + return SDL_Unsupported(); + } + + return true; +#else + return SDL_Unsupported(); +#endif +} + +#ifdef SDL_HAVE_YUV + +static bool GetYUVConversionType(SDL_Colorspace colorspace, YCbCrType *yuv_type) +{ + if (SDL_ISCOLORSPACE_MATRIX_BT601(colorspace)) { + if (SDL_ISCOLORSPACE_LIMITED_RANGE(colorspace)) { + *yuv_type = YCBCR_601_LIMITED; + } else { + *yuv_type = YCBCR_601_FULL; + } + return true; + } + + if (SDL_ISCOLORSPACE_MATRIX_BT709(colorspace)) { + if (SDL_ISCOLORSPACE_LIMITED_RANGE(colorspace)) { + *yuv_type = YCBCR_709_LIMITED; + } else { + *yuv_type = YCBCR_709_FULL; + } + return true; + } + + if (SDL_ISCOLORSPACE_MATRIX_BT2020_NCL(colorspace)) { + if (SDL_ISCOLORSPACE_FULL_RANGE(colorspace)) { + *yuv_type = YCBCR_2020_NCL_FULL; + return true; + } + } + + return SDL_SetError("Unsupported YUV colorspace"); +} + +static bool IsPlanar2x2Format(SDL_PixelFormat format) +{ + return format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV || format == SDL_PIXELFORMAT_NV12 || format == SDL_PIXELFORMAT_NV21 || format == SDL_PIXELFORMAT_P010; +} + +static bool IsPacked4Format(Uint32 format) +{ + return format == SDL_PIXELFORMAT_YUY2 || format == SDL_PIXELFORMAT_UYVY || format == SDL_PIXELFORMAT_YVYU; +} + +static bool GetYUVPlanes(int width, int height, SDL_PixelFormat format, const void *yuv, int yuv_pitch, + const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride) +{ + const Uint8 *planes[3] = { NULL, NULL, NULL }; + int pitches[3] = { 0, 0, 0 }; + int uv_width; + + switch (format) { + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + pitches[0] = yuv_pitch; + pitches[1] = (pitches[0] + 1) / 2; + pitches[2] = (pitches[0] + 1) / 2; + planes[0] = (const Uint8 *)yuv; + planes[1] = planes[0] + pitches[0] * height; + planes[2] = planes[1] + pitches[1] * ((height + 1) / 2); + break; + case SDL_PIXELFORMAT_YUY2: + case SDL_PIXELFORMAT_UYVY: + case SDL_PIXELFORMAT_YVYU: + pitches[0] = yuv_pitch; + planes[0] = (const Uint8 *)yuv; + break; + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + pitches[0] = yuv_pitch; + pitches[1] = 2 * ((pitches[0] + 1) / 2); + planes[0] = (const Uint8 *)yuv; + planes[1] = planes[0] + pitches[0] * height; + break; + case SDL_PIXELFORMAT_P010: + pitches[0] = yuv_pitch; + uv_width = ((width + 1) / 2) * 2; + pitches[1] = SDL_max(pitches[0], (int)(uv_width * sizeof(Uint16))); + planes[0] = (const Uint8 *)yuv; + planes[1] = planes[0] + pitches[0] * height; + break; + default: + return SDL_SetError("GetYUVPlanes(): Unsupported YUV format: %s", SDL_GetPixelFormatName(format)); + } + + switch (format) { + case SDL_PIXELFORMAT_YV12: + *y = planes[0]; + *y_stride = pitches[0]; + *v = planes[1]; + *u = planes[2]; + *uv_stride = pitches[1]; + break; + case SDL_PIXELFORMAT_IYUV: + *y = planes[0]; + *y_stride = pitches[0]; + *v = planes[2]; + *u = planes[1]; + *uv_stride = pitches[1]; + break; + case SDL_PIXELFORMAT_YUY2: + *y = planes[0]; + *y_stride = pitches[0]; + *v = *y + 3; + *u = *y + 1; + *uv_stride = pitches[0]; + break; + case SDL_PIXELFORMAT_UYVY: + *y = planes[0] + 1; + *y_stride = pitches[0]; + *v = *y + 1; + *u = *y - 1; + *uv_stride = pitches[0]; + break; + case SDL_PIXELFORMAT_YVYU: + *y = planes[0]; + *y_stride = pitches[0]; + *v = *y + 1; + *u = *y + 3; + *uv_stride = pitches[0]; + break; + case SDL_PIXELFORMAT_NV12: + *y = planes[0]; + *y_stride = pitches[0]; + *u = planes[1]; + *v = *u + 1; + *uv_stride = pitches[1]; + break; + case SDL_PIXELFORMAT_NV21: + *y = planes[0]; + *y_stride = pitches[0]; + *v = planes[1]; + *u = *v + 1; + *uv_stride = pitches[1]; + break; + case SDL_PIXELFORMAT_P010: + *y = planes[0]; + *y_stride = pitches[0]; + *u = planes[1]; + *v = *u + sizeof(Uint16); + *uv_stride = pitches[1]; + break; + default: + // Should have caught this above + return SDL_SetError("GetYUVPlanes[2]: Unsupported YUV format: %s", SDL_GetPixelFormatName(format)); + } + return true; +} + +#ifdef SDL_SSE2_INTRINSICS +static bool SDL_TARGETING("sse2") yuv_rgb_sse( + SDL_PixelFormat src_format, SDL_PixelFormat dst_format, + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, + YCbCrType yuv_type) +{ + if (!SDL_HasSSE2()) { + return false; + } + + if (src_format == SDL_PIXELFORMAT_YV12 || + src_format == SDL_PIXELFORMAT_IYUV) { + + switch (dst_format) { + case SDL_PIXELFORMAT_RGB565: + yuv420_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGB24: + yuv420_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGBX8888: + case SDL_PIXELFORMAT_RGBA8888: + yuv420_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_BGRX8888: + case SDL_PIXELFORMAT_BGRA8888: + yuv420_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XRGB8888: + case SDL_PIXELFORMAT_ARGB8888: + yuv420_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XBGR8888: + case SDL_PIXELFORMAT_ABGR8888: + yuv420_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + + if (src_format == SDL_PIXELFORMAT_YUY2 || + src_format == SDL_PIXELFORMAT_UYVY || + src_format == SDL_PIXELFORMAT_YVYU) { + + switch (dst_format) { + case SDL_PIXELFORMAT_RGB565: + yuv422_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGB24: + yuv422_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGBX8888: + case SDL_PIXELFORMAT_RGBA8888: + yuv422_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_BGRX8888: + case SDL_PIXELFORMAT_BGRA8888: + yuv422_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XRGB8888: + case SDL_PIXELFORMAT_ARGB8888: + yuv422_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XBGR8888: + case SDL_PIXELFORMAT_ABGR8888: + yuv422_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + + if (src_format == SDL_PIXELFORMAT_NV12 || + src_format == SDL_PIXELFORMAT_NV21) { + + switch (dst_format) { + case SDL_PIXELFORMAT_RGB565: + yuvnv12_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGB24: + yuvnv12_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGBX8888: + case SDL_PIXELFORMAT_RGBA8888: + yuvnv12_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_BGRX8888: + case SDL_PIXELFORMAT_BGRA8888: + yuvnv12_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XRGB8888: + case SDL_PIXELFORMAT_ARGB8888: + yuvnv12_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XBGR8888: + case SDL_PIXELFORMAT_ABGR8888: + yuvnv12_abgr_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + return false; +} +#else +static bool yuv_rgb_sse( + SDL_PixelFormat src_format, SDL_PixelFormat dst_format, + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, + YCbCrType yuv_type) +{ + return false; +} +#endif + +#ifdef SDL_LSX_INTRINSICS +static bool yuv_rgb_lsx( + SDL_PixelFormat src_format, SDL_PixelFormat dst_format, + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, + YCbCrType yuv_type) +{ + if (!SDL_HasLSX()) { + return false; + } + if (src_format == SDL_PIXELFORMAT_YV12 || + src_format == SDL_PIXELFORMAT_IYUV) { + + switch (dst_format) { + case SDL_PIXELFORMAT_RGB24: + yuv420_rgb24_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGBX8888: + case SDL_PIXELFORMAT_RGBA8888: + yuv420_rgba_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_BGRX8888: + case SDL_PIXELFORMAT_BGRA8888: + yuv420_bgra_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XRGB8888: + case SDL_PIXELFORMAT_ARGB8888: + yuv420_argb_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XBGR8888: + case SDL_PIXELFORMAT_ABGR8888: + yuv420_abgr_lsx(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + return false; +} +#else +static bool yuv_rgb_lsx( + SDL_PixelFormat src_format, SDL_PixelFormat dst_format, + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, + YCbCrType yuv_type) +{ + return false; +} +#endif + +static bool yuv_rgb_std( + SDL_PixelFormat src_format, SDL_PixelFormat dst_format, + Uint32 width, Uint32 height, + const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride, + Uint8 *rgb, Uint32 rgb_stride, + YCbCrType yuv_type) +{ + if (src_format == SDL_PIXELFORMAT_YV12 || + src_format == SDL_PIXELFORMAT_IYUV) { + + switch (dst_format) { + case SDL_PIXELFORMAT_RGB565: + yuv420_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGB24: + yuv420_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGBX8888: + case SDL_PIXELFORMAT_RGBA8888: + yuv420_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_BGRX8888: + case SDL_PIXELFORMAT_BGRA8888: + yuv420_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XRGB8888: + case SDL_PIXELFORMAT_ARGB8888: + yuv420_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XBGR8888: + case SDL_PIXELFORMAT_ABGR8888: + yuv420_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + + if (src_format == SDL_PIXELFORMAT_YUY2 || + src_format == SDL_PIXELFORMAT_UYVY || + src_format == SDL_PIXELFORMAT_YVYU) { + + switch (dst_format) { + case SDL_PIXELFORMAT_RGB565: + yuv422_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGB24: + yuv422_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGBX8888: + case SDL_PIXELFORMAT_RGBA8888: + yuv422_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_BGRX8888: + case SDL_PIXELFORMAT_BGRA8888: + yuv422_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XRGB8888: + case SDL_PIXELFORMAT_ARGB8888: + yuv422_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XBGR8888: + case SDL_PIXELFORMAT_ABGR8888: + yuv422_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + + if (src_format == SDL_PIXELFORMAT_NV12 || + src_format == SDL_PIXELFORMAT_NV21) { + + switch (dst_format) { + case SDL_PIXELFORMAT_RGB565: + yuvnv12_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGB24: + yuvnv12_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_RGBX8888: + case SDL_PIXELFORMAT_RGBA8888: + yuvnv12_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_BGRX8888: + case SDL_PIXELFORMAT_BGRA8888: + yuvnv12_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XRGB8888: + case SDL_PIXELFORMAT_ARGB8888: + yuvnv12_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + case SDL_PIXELFORMAT_XBGR8888: + case SDL_PIXELFORMAT_ABGR8888: + yuvnv12_abgr_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + + if (src_format == SDL_PIXELFORMAT_P010) { + switch (dst_format) { + case SDL_PIXELFORMAT_XBGR2101010: + yuvp010_xbgr2101010_std(width, height, (const uint16_t *)y, (const uint16_t *)u, (const uint16_t *)v, y_stride, uv_stride, rgb, rgb_stride, yuv_type); + return true; + default: + break; + } + } + return false; +} + +bool SDL_ConvertPixels_YUV_to_RGB(int width, int height, + SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, + SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch) +{ + const Uint8 *y = NULL; + const Uint8 *u = NULL; + const Uint8 *v = NULL; + Uint32 y_stride = 0; + Uint32 uv_stride = 0; + + if (!GetYUVPlanes(width, height, src_format, src, src_pitch, &y, &u, &v, &y_stride, &uv_stride)) { + return false; + } + + if (SDL_COLORSPACEPRIMARIES(src_colorspace) == SDL_COLORSPACEPRIMARIES(dst_colorspace)) { + YCbCrType yuv_type = YCBCR_601_LIMITED; + + if (!GetYUVConversionType(src_colorspace, &yuv_type)) { + return false; + } + + if (yuv_rgb_sse(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8 *)dst, dst_pitch, yuv_type)) { + return true; + } + + if (yuv_rgb_lsx(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8 *)dst, dst_pitch, yuv_type)) { + return true; + } + + if (yuv_rgb_std(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8 *)dst, dst_pitch, yuv_type)) { + return true; + } + } + + // No fast path for the RGB format, instead convert using an intermediate buffer + if (src_format == SDL_PIXELFORMAT_P010 && dst_format != SDL_PIXELFORMAT_XBGR2101010) { + bool result; + void *tmp; + int tmp_pitch = (width * sizeof(Uint32)); + + tmp = SDL_malloc((size_t)tmp_pitch * height); + if (!tmp) { + return false; + } + + // convert src/src_format to tmp/XBGR2101010 + result = SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_XBGR2101010, src_colorspace, src_properties, tmp, tmp_pitch); + if (!result) { + SDL_free(tmp); + return false; + } + + // convert tmp/XBGR2101010 to dst/RGB + result = SDL_ConvertPixelsAndColorspace(width, height, SDL_PIXELFORMAT_XBGR2101010, src_colorspace, src_properties, tmp, tmp_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); + SDL_free(tmp); + return result; + } + + if (dst_format != SDL_PIXELFORMAT_ARGB8888) { + bool result; + void *tmp; + int tmp_pitch = (width * sizeof(Uint32)); + + tmp = SDL_malloc((size_t)tmp_pitch * height); + if (!tmp) { + return false; + } + + // convert src/src_format to tmp/ARGB8888 + result = SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, SDL_COLORSPACE_SRGB, 0, tmp, tmp_pitch); + if (!result) { + SDL_free(tmp); + return false; + } + + // convert tmp/ARGB8888 to dst/RGB + result = SDL_ConvertPixelsAndColorspace(width, height, SDL_PIXELFORMAT_ARGB8888, SDL_COLORSPACE_SRGB, 0, tmp, tmp_pitch, dst_format, dst_colorspace, dst_properties, dst, dst_pitch); + SDL_free(tmp); + return result; + } + + return SDL_SetError("Unsupported YUV conversion"); +} + +struct RGB2YUVFactors +{ + int y_offset; + float y[3]; // Rfactor, Gfactor, Bfactor + float u[3]; // Rfactor, Gfactor, Bfactor + float v[3]; // Rfactor, Gfactor, Bfactor +}; + +static struct RGB2YUVFactors RGB2YUVFactorTables[] = { + // ITU-T T.871 (JPEG) + { + 0, + { 0.2990f, 0.5870f, 0.1140f }, + { -0.1687f, -0.3313f, 0.5000f }, + { 0.5000f, -0.4187f, -0.0813f }, + }, + // ITU-R BT.601-7 + { + 16, + { 0.2568f, 0.5041f, 0.0979f }, + { -0.1482f, -0.2910f, 0.4392f }, + { 0.4392f, -0.3678f, -0.0714f }, + }, + // ITU-R BT.709-6 full range + { + 0, + { 0.2126f, 0.7152f, 0.0722f }, + { -0.1141f, -0.3839f, 0.498f }, + { 0.498f, -0.4524f, -0.0457f }, + }, + // ITU-R BT.709-6 + { + 16, + { 0.1826f, 0.6142f, 0.0620f }, + { -0.1006f, -0.3386f, 0.4392f }, + { 0.4392f, -0.3989f, -0.0403f }, + }, + // ITU-R BT.2020 10-bit full range + { + 0, + { 0.2627f, 0.6780f, 0.0593f }, + { -0.1395f, -0.3600f, 0.4995f }, + { 0.4995f, -0.4593f, -0.0402f }, + }, +}; + +static bool SDL_ConvertPixels_XRGB8888_to_YUV(int width, int height, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, YCbCrType yuv_type) +{ + const int src_pitch_x_2 = src_pitch * 2; + const int height_half = height / 2; + const int height_remainder = (height & 0x1); + const int width_half = width / 2; + const int width_remainder = (width & 0x1); + int i, j; + + const struct RGB2YUVFactors *cvt = &RGB2YUVFactorTables[yuv_type]; + +#define MAKE_Y(r, g, b) (Uint8)SDL_clamp(((int)(cvt->y[0] * (r) + cvt->y[1] * (g) + cvt->y[2] * (b) + 0.5f) + cvt->y_offset), 0, 255) +#define MAKE_U(r, g, b) (Uint8)SDL_clamp(((int)(cvt->u[0] * (r) + cvt->u[1] * (g) + cvt->u[2] * (b) + 0.5f) + 128), 0, 255) +#define MAKE_V(r, g, b) (Uint8)SDL_clamp(((int)(cvt->v[0] * (r) + cvt->v[1] * (g) + cvt->v[2] * (b) + 0.5f) + 128), 0, 255) + +#define READ_2x2_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 p3 = ((const Uint32 *)next_row)[2 * i]; \ + const Uint32 p4 = ((const Uint32 *)next_row)[2 * i + 1]; \ + const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000) + (p3 & 0x00ff0000) + (p4 & 0x00ff0000)) >> 18; \ + const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00) + (p3 & 0x0000ff00) + (p4 & 0x0000ff00)) >> 10; \ + const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff) + (p3 & 0x000000ff) + (p4 & 0x000000ff)) >> 2; + +#define READ_2x1_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)next_row)[2 * i]; \ + const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \ + const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \ + const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; + +#define READ_1x2_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \ + const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \ + const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; + +#define READ_1x1_PIXEL \ + const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 r = (p & 0x00ff0000) >> 16; \ + const Uint32 g = (p & 0x0000ff00) >> 8; \ + const Uint32 b = (p & 0x000000ff); + +#define READ_TWO_RGB_PIXELS \ + const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 r = (p & 0x00ff0000) >> 16; \ + const Uint32 g = (p & 0x0000ff00) >> 8; \ + const Uint32 b = (p & 0x000000ff); \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 r1 = (p1 & 0x00ff0000) >> 16; \ + const Uint32 g1 = (p1 & 0x0000ff00) >> 8; \ + const Uint32 b1 = (p1 & 0x000000ff); \ + const Uint32 R = (r + r1) / 2; \ + const Uint32 G = (g + g1) / 2; \ + const Uint32 B = (b + b1) / 2; + +#define READ_ONE_RGB_PIXEL READ_1x1_PIXEL + + switch (dst_format) { + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + case SDL_PIXELFORMAT_NV12: + case SDL_PIXELFORMAT_NV21: + { + const Uint8 *curr_row, *next_row; + + Uint8 *plane_y; + Uint8 *plane_u; + Uint8 *plane_v; + Uint8 *plane_interleaved_uv; + Uint32 y_stride, uv_stride, y_skip, uv_skip; + + if (!GetYUVPlanes(width, height, dst_format, dst, dst_pitch, + (const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v, + &y_stride, &uv_stride)) { + return false; + } + + plane_interleaved_uv = (plane_y + height * y_stride); + y_skip = (y_stride - width); + + curr_row = (const Uint8 *)src; + + // Write Y plane + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + const Uint32 p1 = ((const Uint32 *)curr_row)[i]; + const Uint32 r = (p1 & 0x00ff0000) >> 16; + const Uint32 g = (p1 & 0x0000ff00) >> 8; + const Uint32 b = (p1 & 0x000000ff); + *plane_y++ = MAKE_Y(r, g, b); + } + plane_y += y_skip; + curr_row += src_pitch; + } + + curr_row = (const Uint8 *)src; + next_row = (const Uint8 *)src; + next_row += src_pitch; + + if (dst_format == SDL_PIXELFORMAT_YV12 || dst_format == SDL_PIXELFORMAT_IYUV) { + // Write UV planes, not interleaved + uv_skip = (uv_stride - (width + 1) / 2); + for (j = 0; j < height_half; j++) { + for (i = 0; i < width_half; i++) { + READ_2x2_PIXELS; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); + } + if (width_remainder) { + READ_2x1_PIXELS; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); + } + plane_u += uv_skip; + plane_v += uv_skip; + curr_row += src_pitch_x_2; + next_row += src_pitch_x_2; + } + if (height_remainder) { + for (i = 0; i < width_half; i++) { + READ_1x2_PIXELS; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); + } + if (width_remainder) { + READ_1x1_PIXEL; + *plane_u++ = MAKE_U(r, g, b); + *plane_v++ = MAKE_V(r, g, b); + } + plane_u += uv_skip; + plane_v += uv_skip; + } + } else if (dst_format == SDL_PIXELFORMAT_NV12) { + uv_skip = (uv_stride - ((width + 1) / 2) * 2); + for (j = 0; j < height_half; j++) { + for (i = 0; i < width_half; i++) { + READ_2x2_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + if (width_remainder) { + READ_2x1_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + plane_interleaved_uv += uv_skip; + curr_row += src_pitch_x_2; + next_row += src_pitch_x_2; + } + if (height_remainder) { + for (i = 0; i < width_half; i++) { + READ_1x2_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + if (width_remainder) { + READ_1x1_PIXEL; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + } + } else /* dst_format == SDL_PIXELFORMAT_NV21 */ { + uv_skip = (uv_stride - ((width + 1) / 2) * 2); + for (j = 0; j < height_half; j++) { + for (i = 0; i < width_half; i++) { + READ_2x2_PIXELS; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); + } + if (width_remainder) { + READ_2x1_PIXELS; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); + } + plane_interleaved_uv += uv_skip; + curr_row += src_pitch_x_2; + next_row += src_pitch_x_2; + } + if (height_remainder) { + for (i = 0; i < width_half; i++) { + READ_1x2_PIXELS; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); + } + if (width_remainder) { + READ_1x1_PIXEL; + *plane_interleaved_uv++ = MAKE_V(r, g, b); + *plane_interleaved_uv++ = MAKE_U(r, g, b); + } + } + } + } break; + + case SDL_PIXELFORMAT_YUY2: + case SDL_PIXELFORMAT_UYVY: + case SDL_PIXELFORMAT_YVYU: + { + const Uint8 *curr_row = (const Uint8 *)src; + Uint8 *plane = (Uint8 *)dst; + const int row_size = (4 * ((width + 1) / 2)); + int plane_skip; + + if (dst_pitch < row_size) { + return SDL_SetError("Destination pitch is too small, expected at least %d", row_size); + } + plane_skip = (dst_pitch - row_size); + + // Write YUV plane, packed + if (dst_format == SDL_PIXELFORMAT_YUY2) { + for (j = 0; j < height; j++) { + for (i = 0; i < width_half; i++) { + READ_TWO_RGB_PIXELS; + // Y U Y1 V + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_U(R, G, B); + *plane++ = MAKE_Y(r1, g1, b1); + *plane++ = MAKE_V(R, G, B); + } + if (width_remainder) { + READ_ONE_RGB_PIXEL; + // Y U Y V + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_U(r, g, b); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(r, g, b); + } + plane += plane_skip; + curr_row += src_pitch; + } + } else if (dst_format == SDL_PIXELFORMAT_UYVY) { + for (j = 0; j < height; j++) { + for (i = 0; i < width_half; i++) { + READ_TWO_RGB_PIXELS; + // U Y V Y1 + *plane++ = MAKE_U(R, G, B); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(R, G, B); + *plane++ = MAKE_Y(r1, g1, b1); + } + if (width_remainder) { + READ_ONE_RGB_PIXEL; + // U Y V Y + *plane++ = MAKE_U(r, g, b); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(r, g, b); + *plane++ = MAKE_Y(r, g, b); + } + plane += plane_skip; + curr_row += src_pitch; + } + } else if (dst_format == SDL_PIXELFORMAT_YVYU) { + for (j = 0; j < height; j++) { + for (i = 0; i < width_half; i++) { + READ_TWO_RGB_PIXELS; + // Y V Y1 U + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(R, G, B); + *plane++ = MAKE_Y(r1, g1, b1); + *plane++ = MAKE_U(R, G, B); + } + if (width_remainder) { + READ_ONE_RGB_PIXEL; + // Y V Y U + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_V(r, g, b); + *plane++ = MAKE_Y(r, g, b); + *plane++ = MAKE_U(r, g, b); + } + plane += plane_skip; + curr_row += src_pitch; + } + } + } break; + + default: + return SDL_SetError("Unsupported YUV destination format: %s", SDL_GetPixelFormatName(dst_format)); + } +#undef MAKE_Y +#undef MAKE_U +#undef MAKE_V +#undef READ_2x2_PIXELS +#undef READ_2x1_PIXELS +#undef READ_1x2_PIXELS +#undef READ_1x1_PIXEL +#undef READ_TWO_RGB_PIXELS +#undef READ_ONE_RGB_PIXEL + return true; +} + +static bool SDL_ConvertPixels_XBGR2101010_to_P010(int width, int height, const void *src, int src_pitch, SDL_PixelFormat dst_format, void *dst, int dst_pitch, YCbCrType yuv_type) +{ + const int src_pitch_x_2 = src_pitch * 2; + const int height_half = height / 2; + const int height_remainder = (height & 0x1); + const int width_half = width / 2; + const int width_remainder = (width & 0x1); + int i, j; + + const struct RGB2YUVFactors *cvt = &RGB2YUVFactorTables[yuv_type]; + +#define MAKE_Y(r, g, b) (Uint16)(((int)(cvt->y[0] * (r) + cvt->y[1] * (g) + cvt->y[2] * (b) + 0.5f) + cvt->y_offset) << 6) +#define MAKE_U(r, g, b) (Uint16)(((int)(cvt->u[0] * (r) + cvt->u[1] * (g) + cvt->u[2] * (b) + 0.5f) + 512) << 6) +#define MAKE_V(r, g, b) (Uint16)(((int)(cvt->v[0] * (r) + cvt->v[1] * (g) + cvt->v[2] * (b) + 0.5f) + 512) << 6) + +#define READ_2x2_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 p3 = ((const Uint32 *)next_row)[2 * i]; \ + const Uint32 p4 = ((const Uint32 *)next_row)[2 * i + 1]; \ + const Uint32 r = ((p1 & 0x000003ff) + (p2 & 0x000003ff) + (p3 & 0x000003ff) + (p4 & 0x000003ff)) >> 2; \ + const Uint32 g = ((p1 & 0x000ffc00) + (p2 & 0x000ffc00) + (p3 & 0x000ffc00) + (p4 & 0x000ffc00)) >> 12; \ + const Uint32 b = ((p1 & 0x3ff00000) + (p2 & 0x3ff00000) + (p3 & 0x3ff00000) + (p4 & 0x3ff00000)) >> 22; + +#define READ_2x1_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)next_row)[2 * i]; \ + const Uint32 r = ((p1 & 0x000003ff) + (p2 & 0x000003ff)) >> 1; \ + const Uint32 g = ((p1 & 0x000ffc00) + (p2 & 0x000ffc00)) >> 11; \ + const Uint32 b = ((p1 & 0x3ff00000) + (p2 & 0x3ff00000)) >> 21; + +#define READ_1x2_PIXELS \ + const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \ + const Uint32 r = ((p1 & 0x000003ff) + (p2 & 0x000003ff)) >> 1; \ + const Uint32 g = ((p1 & 0x000ffc00) + (p2 & 0x000ffc00)) >> 11; \ + const Uint32 b = ((p1 & 0x3ff00000) + (p2 & 0x3ff00000)) >> 21; + +#define READ_1x1_PIXEL \ + const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \ + const Uint32 r = (p & 0x000003ff); \ + const Uint32 g = (p & 0x000ffc00) >> 10; \ + const Uint32 b = (p & 0x3ff00000) >> 20; + + const Uint8 *curr_row, *next_row; + + Uint16 *plane_y; + Uint16 *plane_u; + Uint16 *plane_v; + Uint16 *plane_interleaved_uv; + Uint32 y_stride, uv_stride, y_skip, uv_skip; + + if (!GetYUVPlanes(width, height, dst_format, dst, dst_pitch, + (const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v, + &y_stride, &uv_stride)) { + return false; + } + + y_stride /= sizeof(Uint16); + uv_stride /= sizeof(Uint16); + + plane_interleaved_uv = (plane_y + height * y_stride); + y_skip = (y_stride - width); + + curr_row = (const Uint8 *)src; + + // Write Y plane + for (j = 0; j < height; j++) { + for (i = 0; i < width; i++) { + const Uint32 p1 = ((const Uint32 *)curr_row)[i]; + const Uint32 r = (p1 >> 0) & 0x03ff; + const Uint32 g = (p1 >> 10) & 0x03ff; + const Uint32 b = (p1 >> 20) & 0x03ff; + *plane_y++ = MAKE_Y(r, g, b); + } + plane_y += y_skip; + curr_row += src_pitch; + } + + curr_row = (const Uint8 *)src; + next_row = (const Uint8 *)src; + next_row += src_pitch; + + uv_skip = (uv_stride - ((width + 1) / 2) * 2); + for (j = 0; j < height_half; j++) { + for (i = 0; i < width_half; i++) { + READ_2x2_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + if (width_remainder) { + READ_2x1_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + plane_interleaved_uv += uv_skip; + curr_row += src_pitch_x_2; + next_row += src_pitch_x_2; + } + if (height_remainder) { + for (i = 0; i < width_half; i++) { + READ_1x2_PIXELS; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + if (width_remainder) { + READ_1x1_PIXEL; + *plane_interleaved_uv++ = MAKE_U(r, g, b); + *plane_interleaved_uv++ = MAKE_V(r, g, b); + } + } + +#undef MAKE_Y +#undef MAKE_U +#undef MAKE_V +#undef READ_2x2_PIXELS +#undef READ_2x1_PIXELS +#undef READ_1x2_PIXELS +#undef READ_1x1_PIXEL + return true; +} + +bool SDL_ConvertPixels_RGB_to_YUV(int width, int height, + SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, + SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch) +{ + YCbCrType yuv_type = YCBCR_601_LIMITED; + + if (!GetYUVConversionType(dst_colorspace, &yuv_type)) { + return false; + } + +#if 0 // Doesn't handle odd widths + // RGB24 to FOURCC + if (src_format == SDL_PIXELFORMAT_RGB24) { + Uint8 *y; + Uint8 *u; + Uint8 *v; + Uint32 y_stride; + Uint32 uv_stride; + + if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch, (const Uint8 **)&y, (const Uint8 **)&u, (const Uint8 **)&v, &y_stride, &uv_stride) < 0) { + return false; + } + + rgb24_yuv420_std(width, height, src, src_pitch, y, u, v, y_stride, uv_stride, yuv_type); + return true; + } +#endif + + // ARGB8888 to FOURCC + if ((src_format == SDL_PIXELFORMAT_ARGB8888 || src_format == SDL_PIXELFORMAT_XRGB8888) && + SDL_COLORSPACEPRIMARIES(src_colorspace) == SDL_COLORSPACEPRIMARIES(dst_colorspace)) { + return SDL_ConvertPixels_XRGB8888_to_YUV(width, height, src, src_pitch, dst_format, dst, dst_pitch, yuv_type); + } + + if (dst_format == SDL_PIXELFORMAT_P010) { + if (src_format == SDL_PIXELFORMAT_XBGR2101010 && + SDL_COLORSPACEPRIMARIES(src_colorspace) == SDL_COLORSPACEPRIMARIES(dst_colorspace)) { + return SDL_ConvertPixels_XBGR2101010_to_P010(width, height, src, src_pitch, dst_format, dst, dst_pitch, yuv_type); + } + + // We currently only support converting from XBGR2101010 to P010 + bool result; + void *tmp; + int tmp_pitch = (width * sizeof(Uint32)); + + tmp = SDL_malloc((size_t)tmp_pitch * height); + if (!tmp) { + return false; + } + + // convert src/src_format to tmp/XBGR2101010 + result = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_XBGR2101010, dst_colorspace, dst_properties, tmp, tmp_pitch); + if (!result) { + SDL_free(tmp); + return false; + } + + // convert tmp/XBGR2101010 to dst/P010 + result = SDL_ConvertPixels_XBGR2101010_to_P010(width, height, tmp, tmp_pitch, dst_format, dst, dst_pitch, yuv_type); + SDL_free(tmp); + return result; + } + + // not ARGB8888 to FOURCC : need an intermediate conversion + { + bool result; + void *tmp; + int tmp_pitch = (width * sizeof(Uint32)); + + tmp = SDL_malloc((size_t)tmp_pitch * height); + if (!tmp) { + return false; + } + + // convert src/src_format to tmp/XRGB8888 + result = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_XRGB8888, SDL_COLORSPACE_SRGB, 0, tmp, tmp_pitch); + if (!result) { + SDL_free(tmp); + return false; + } + + // convert tmp/XRGB8888 to dst/FOURCC + result = SDL_ConvertPixels_XRGB8888_to_YUV(width, height, tmp, tmp_pitch, dst_format, dst, dst_pitch, yuv_type); + SDL_free(tmp); + return result; + } +} + +static bool SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, SDL_PixelFormat format, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int i; + + if (IsPlanar2x2Format(format)) { + // Y plane + for (i = height; i--;) { + SDL_memcpy(dst, src, width); + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } + + if (format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV) { + // U and V planes are a quarter the size of the Y plane, rounded up + width = (width + 1) / 2; + height = (height + 1) / 2; + src_pitch = (src_pitch + 1) / 2; + dst_pitch = (dst_pitch + 1) / 2; + for (i = height * 2; i--;) { + SDL_memcpy(dst, src, width); + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } + } else if (format == SDL_PIXELFORMAT_NV12 || format == SDL_PIXELFORMAT_NV21) { + // U/V plane is half the height of the Y plane, rounded up + height = (height + 1) / 2; + width = ((width + 1) / 2) * 2; + src_pitch = ((src_pitch + 1) / 2) * 2; + dst_pitch = ((dst_pitch + 1) / 2) * 2; + for (i = height; i--;) { + SDL_memcpy(dst, src, width); + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } + } else if (format == SDL_PIXELFORMAT_P010) { + // U/V plane is half the height of the Y plane, rounded up + height = (height + 1) / 2; + width = ((width + 1) / 2) * 2; + src_pitch = ((src_pitch + 1) / 2) * 2; + dst_pitch = ((dst_pitch + 1) / 2) * 2; + for (i = height; i--;) { + SDL_memcpy(dst, src, width * sizeof(Uint16)); + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } + } + return true; + } + + if (IsPacked4Format(format)) { + // Packed planes + width = 4 * ((width + 1) / 2); + for (i = height; i--;) { + SDL_memcpy(dst, src, width); + src = (const Uint8 *)src + src_pitch; + dst = (Uint8 *)dst + dst_pitch; + } + return true; + } + + return SDL_SetError("SDL_ConvertPixels_YUV_to_YUV_Copy: Unsupported YUV format: %s", SDL_GetPixelFormatName(format)); +} + +static bool SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int y; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + + // Skip the Y plane + src = (const Uint8 *)src + height * src_pitch; + dst = (Uint8 *)dst + height * dst_pitch; + + if (src == dst) { + int UVpitch = (dst_pitch + 1) / 2; + Uint8 *tmp; + Uint8 *row1 = (Uint8 *)dst; + Uint8 *row2 = row1 + UVheight * UVpitch; + + // Allocate a temporary row for the swap + tmp = (Uint8 *)SDL_malloc(UVwidth); + if (!tmp) { + return false; + } + for (y = 0; y < UVheight; ++y) { + SDL_memcpy(tmp, row1, UVwidth); + SDL_memcpy(row1, row2, UVwidth); + SDL_memcpy(row2, tmp, UVwidth); + row1 += UVpitch; + row2 += UVpitch; + } + SDL_free(tmp); + } else { + const Uint8 *srcUV; + Uint8 *dstUV; + int srcUVPitch = ((src_pitch + 1) / 2); + int dstUVPitch = ((dst_pitch + 1) / 2); + + // Copy the first plane + srcUV = (const Uint8 *)src; + dstUV = (Uint8 *)dst + UVheight * dstUVPitch; + for (y = 0; y < UVheight; ++y) { + SDL_memcpy(dstUV, srcUV, UVwidth); + srcUV += srcUVPitch; + dstUV += dstUVPitch; + } + + // Copy the second plane + dstUV = (Uint8 *)dst; + for (y = 0; y < UVheight; ++y) { + SDL_memcpy(dstUV, srcUV, UVwidth); + srcUV += srcUVPitch; + dstUV += dstUVPitch; + } + } + return true; +} + +#ifdef SDL_SSE2_INTRINSICS +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) +{ + int x, y; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2); + const int srcUVPitchLeft = srcUVPitch - UVwidth; + const int dstUVPitch = ((dst_pitch + 1) / 2) * 2; + const int dstUVPitchLeft = dstUVPitch - UVwidth * 2; + const Uint8 *src1, *src2; + Uint8 *dstUV; + Uint8 *tmp = NULL; + + // Skip the Y plane + src = (const Uint8 *)src + height * src_pitch; + dst = (Uint8 *)dst + height * dst_pitch; + + if (src == dst) { + // Need to make a copy of the buffer so we don't clobber it while converting + tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch); + if (tmp == NULL) { + return false; + } + SDL_memcpy(tmp, src, (size_t)2 * UVheight * srcUVPitch); + src = tmp; + } + + if (reverseUV) { + src2 = (const Uint8 *)src; + src1 = src2 + UVheight * srcUVPitch; + } else { + src1 = (const Uint8 *)src; + src2 = src1 + UVheight * srcUVPitch; + } + dstUV = (Uint8 *)dst; + + y = UVheight; + while (y--) { + x = UVwidth; + while (x >= 16) { + __m128i u = _mm_loadu_si128((__m128i *)src1); + __m128i v = _mm_loadu_si128((__m128i *)src2); + __m128i uv1 = _mm_unpacklo_epi8(u, v); + __m128i uv2 = _mm_unpackhi_epi8(u, v); + _mm_storeu_si128((__m128i *)dstUV, uv1); + _mm_storeu_si128((__m128i *)(dstUV + 16), uv2); + src1 += 16; + src2 += 16; + dstUV += 32; + x -= 16; + } + while (x--) { + *dstUV++ = *src1++; + *dstUV++ = *src2++; + } + src1 += srcUVPitchLeft; + src2 += srcUVPitchLeft; + dstUV += dstUVPitchLeft; + } + + if (tmp) { + SDL_free(tmp); + } + return true; +} + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) +{ + int x, y; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2) * 2; + const int srcUVPitchLeft = srcUVPitch - UVwidth * 2; + const int dstUVPitch = ((dst_pitch + 1) / 2); + const int dstUVPitchLeft = dstUVPitch - UVwidth; + const Uint8 *srcUV; + Uint8 *dst1, *dst2; + Uint8 *tmp = NULL; + + // Skip the Y plane + src = (const Uint8 *)src + height * src_pitch; + dst = (Uint8 *)dst + height * dst_pitch; + + if (src == dst) { + // Need to make a copy of the buffer so we don't clobber it while converting + tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch); + if (tmp == NULL) { + return false; + } + SDL_memcpy(tmp, src, (size_t)UVheight * srcUVPitch); + src = tmp; + } + + if (reverseUV) { + dst2 = (Uint8 *)dst; + dst1 = dst2 + UVheight * dstUVPitch; + } else { + dst1 = (Uint8 *)dst; + dst2 = dst1 + UVheight * dstUVPitch; + } + srcUV = (const Uint8 *)src; + + y = UVheight; + while (y--) { + __m128i mask = _mm_set1_epi16(0x00FF); + x = UVwidth; + while (x >= 16) { + __m128i uv1 = _mm_loadu_si128((__m128i *)srcUV); + __m128i uv2 = _mm_loadu_si128((__m128i *)(srcUV + 16)); + __m128i u1 = _mm_and_si128(uv1, mask); + __m128i u2 = _mm_and_si128(uv2, mask); + __m128i u = _mm_packus_epi16(u1, u2); + __m128i v1 = _mm_srli_epi16(uv1, 8); + __m128i v2 = _mm_srli_epi16(uv2, 8); + __m128i v = _mm_packus_epi16(v1, v2); + _mm_storeu_si128((__m128i *)dst1, u); + _mm_storeu_si128((__m128i *)dst2, v); + srcUV += 32; + dst1 += 16; + dst2 += 16; + x -= 16; + } + while (x--) { + *dst1++ = *srcUV++; + *dst2++ = *srcUV++; + } + srcUV += srcUVPitchLeft; + dst1 += dstUVPitchLeft; + dst2 += dstUVPitchLeft; + } + + if (tmp) { + SDL_free(tmp); + } + return true; +} + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_SwapNV_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2) * 2; + const int srcUVPitchLeft = (srcUVPitch - UVwidth * 2) / sizeof(Uint16); + const int dstUVPitch = ((dst_pitch + 1) / 2) * 2; + const int dstUVPitchLeft = (dstUVPitch - UVwidth * 2) / sizeof(Uint16); + const Uint16 *srcUV; + Uint16 *dstUV; + + // Skip the Y plane + src = (const Uint8 *)src + height * src_pitch; + dst = (Uint8 *)dst + height * dst_pitch; + + srcUV = (const Uint16 *)src; + dstUV = (Uint16 *)dst; + y = UVheight; + while (y--) { + x = UVwidth; + while (x >= 8) { + __m128i uv = _mm_loadu_si128((__m128i *)srcUV); + __m128i v = _mm_slli_epi16(uv, 8); + __m128i u = _mm_srli_epi16(uv, 8); + __m128i vu = _mm_or_si128(v, u); + _mm_storeu_si128((__m128i *)dstUV, vu); + srcUV += 8; + dstUV += 8; + x -= 8; + } + while (x--) { + *dstUV++ = SDL_Swap16(*srcUV++); + } + srcUV += srcUVPitchLeft; + dstUV += dstUVPitchLeft; + } + return true; +} +#endif + +static bool SDL_ConvertPixels_PackUVPlanes_to_NV_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) +{ + int x, y; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2); + const int srcUVPitchLeft = srcUVPitch - UVwidth; + const int dstUVPitch = ((dst_pitch + 1) / 2) * 2; + const int dstUVPitchLeft = dstUVPitch - UVwidth * 2; + const Uint8 *src1, *src2; + Uint8 *dstUV; + Uint8 *tmp = NULL; + + // Skip the Y plane + src = (const Uint8 *)src + height * src_pitch; + dst = (Uint8 *)dst + height * dst_pitch; + + if (src == dst) { + // Need to make a copy of the buffer so we don't clobber it while converting + tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch); + if (!tmp) { + return false; + } + SDL_memcpy(tmp, src, (size_t)2 * UVheight * srcUVPitch); + src = tmp; + } + + if (reverseUV) { + src2 = (const Uint8 *)src; + src1 = src2 + UVheight * srcUVPitch; + } else { + src1 = (const Uint8 *)src; + src2 = src1 + UVheight * srcUVPitch; + } + dstUV = (Uint8 *)dst; + + y = UVheight; + while (y--) { + x = UVwidth; + while (x--) { + *dstUV++ = *src1++; + *dstUV++ = *src2++; + } + src1 += srcUVPitchLeft; + src2 += srcUVPitchLeft; + dstUV += dstUVPitchLeft; + } + + if (tmp) { + SDL_free(tmp); + } + return true; +} + +static bool SDL_ConvertPixels_SplitNV_to_UVPlanes_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) +{ + int x, y; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2) * 2; + const int srcUVPitchLeft = srcUVPitch - UVwidth * 2; + const int dstUVPitch = ((dst_pitch + 1) / 2); + const int dstUVPitchLeft = dstUVPitch - UVwidth; + const Uint8 *srcUV; + Uint8 *dst1, *dst2; + Uint8 *tmp = NULL; + + // Skip the Y plane + src = (const Uint8 *)src + height * src_pitch; + dst = (Uint8 *)dst + height * dst_pitch; + + if (src == dst) { + // Need to make a copy of the buffer so we don't clobber it while converting + tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch); + if (!tmp) { + return false; + } + SDL_memcpy(tmp, src, (size_t)UVheight * srcUVPitch); + src = tmp; + } + + if (reverseUV) { + dst2 = (Uint8 *)dst; + dst1 = dst2 + UVheight * dstUVPitch; + } else { + dst1 = (Uint8 *)dst; + dst2 = dst1 + UVheight * dstUVPitch; + } + srcUV = (const Uint8 *)src; + + y = UVheight; + while (y--) { + x = UVwidth; + while (x--) { + *dst1++ = *srcUV++; + *dst2++ = *srcUV++; + } + srcUV += srcUVPitchLeft; + dst1 += dstUVPitchLeft; + dst2 += dstUVPitchLeft; + } + + if (tmp) { + SDL_free(tmp); + } + return true; +} + +static bool SDL_ConvertPixels_SwapNV_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int UVwidth = (width + 1) / 2; + const int UVheight = (height + 1) / 2; + const int srcUVPitch = ((src_pitch + 1) / 2) * 2; + const int srcUVPitchLeft = (srcUVPitch - UVwidth * 2) / sizeof(Uint16); + const int dstUVPitch = ((dst_pitch + 1) / 2) * 2; + const int dstUVPitchLeft = (dstUVPitch - UVwidth * 2) / sizeof(Uint16); + const Uint16 *srcUV; + Uint16 *dstUV; + + // Skip the Y plane + src = (const Uint8 *)src + height * src_pitch; + dst = (Uint8 *)dst + height * dst_pitch; + + srcUV = (const Uint16 *)src; + dstUV = (Uint16 *)dst; + y = UVheight; + while (y--) { + x = UVwidth; + while (x--) { + *dstUV++ = SDL_Swap16(*srcUV++); + } + srcUV += srcUVPitchLeft; + dstUV += dstUVPitchLeft; + } + return true; +} + +static bool SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_PackUVPlanes_to_NV_SSE2(width, height, src, src_pitch, dst, dst_pitch, reverseUV); + } +#endif + return SDL_ConvertPixels_PackUVPlanes_to_NV_std(width, height, src, src_pitch, dst, dst_pitch, reverseUV); +} + +static bool SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, bool reverseUV) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_SplitNV_to_UVPlanes_SSE2(width, height, src, src_pitch, dst, dst_pitch, reverseUV); + } +#endif + return SDL_ConvertPixels_SplitNV_to_UVPlanes_std(width, height, src, src_pitch, dst, dst_pitch, reverseUV); +} + +static bool SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_SwapNV_SSE2(width, height, src, src_pitch, dst, dst_pitch); + } +#endif + return SDL_ConvertPixels_SwapNV_std(width, height, src, src_pitch, dst, dst_pitch); +} + +static bool SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height, + SDL_PixelFormat src_format, const void *src, int src_pitch, + SDL_PixelFormat dst_format, void *dst, int dst_pitch) +{ + if (src != dst) { + // Copy Y plane + int i; + const Uint8 *srcY = (const Uint8 *)src; + Uint8 *dstY = (Uint8 *)dst; + for (i = height; i--;) { + SDL_memcpy(dstY, srcY, width); + srcY += src_pitch; + dstY += dst_pitch; + } + } + + switch (src_format) { + case SDL_PIXELFORMAT_YV12: + switch (dst_format) { + case SDL_PIXELFORMAT_IYUV: + return SDL_ConvertPixels_SwapUVPlanes(width, height, src, src_pitch, dst, dst_pitch); + case SDL_PIXELFORMAT_NV12: + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, true); + case SDL_PIXELFORMAT_NV21: + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, false); + default: + break; + } + break; + case SDL_PIXELFORMAT_IYUV: + switch (dst_format) { + case SDL_PIXELFORMAT_YV12: + return SDL_ConvertPixels_SwapUVPlanes(width, height, src, src_pitch, dst, dst_pitch); + case SDL_PIXELFORMAT_NV12: + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, false); + case SDL_PIXELFORMAT_NV21: + return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, true); + default: + break; + } + break; + case SDL_PIXELFORMAT_NV12: + switch (dst_format) { + case SDL_PIXELFORMAT_YV12: + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, true); + case SDL_PIXELFORMAT_IYUV: + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, false); + case SDL_PIXELFORMAT_NV21: + return SDL_ConvertPixels_SwapNV(width, height, src, src_pitch, dst, dst_pitch); + default: + break; + } + break; + case SDL_PIXELFORMAT_NV21: + switch (dst_format) { + case SDL_PIXELFORMAT_YV12: + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, false); + case SDL_PIXELFORMAT_IYUV: + return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, true); + case SDL_PIXELFORMAT_NV12: + return SDL_ConvertPixels_SwapNV(width, height, src, src_pitch, dst, dst_pitch); + default: + break; + } + break; + default: + break; + } + return SDL_SetError("SDL_ConvertPixels_Planar2x2_to_Planar2x2: Unsupported YUV conversion: %s -> %s", SDL_GetPixelFormatName(src_format), + SDL_GetPixelFormatName(dst_format)); +} + +#ifdef SDL_SSE2_INTRINSICS +#define PACKED4_TO_PACKED4_ROW_SSE2(shuffle) \ + while (x >= 4) { \ + __m128i yuv = _mm_loadu_si128((__m128i *)srcYUV); \ + __m128i lo = _mm_unpacklo_epi8(yuv, _mm_setzero_si128()); \ + __m128i hi = _mm_unpackhi_epi8(yuv, _mm_setzero_si128()); \ + lo = _mm_shufflelo_epi16(lo, shuffle); \ + lo = _mm_shufflehi_epi16(lo, shuffle); \ + hi = _mm_shufflelo_epi16(hi, shuffle); \ + hi = _mm_shufflehi_epi16(hi, shuffle); \ + yuv = _mm_packus_epi16(lo, hi); \ + _mm_storeu_si128((__m128i *)dstYUV, yuv); \ + srcYUV += 16; \ + dstYUV += 16; \ + x -= 4; \ + } + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_YUY2_to_UYVY_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + x = YUVwidth; + while (y--) { + PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(2, 3, 0, 1)); + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + U = srcYUV[1]; + Y2 = srcYUV[2]; + V = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = U; + dstYUV[1] = Y1; + dstYUV[2] = V; + dstYUV[3] = Y2; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + x = YUVwidth; + } + return true; +} + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_YUY2_to_YVYU_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + x = YUVwidth; + while (y--) { + PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(1, 2, 3, 0)); + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + U = srcYUV[1]; + Y2 = srcYUV[2]; + V = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = V; + dstYUV[2] = Y2; + dstYUV[3] = U; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + x = YUVwidth; + } + return true; +} + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_UYVY_to_YUY2_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + x = YUVwidth; + while (y--) { + PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(2, 3, 0, 1)); + while (x--) { + Uint8 Y1, U, Y2, V; + + U = srcYUV[0]; + Y1 = srcYUV[1]; + V = srcYUV[2]; + Y2 = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = U; + dstYUV[2] = Y2; + dstYUV[3] = V; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + x = YUVwidth; + } + return true; +} + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_UYVY_to_YVYU_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + x = YUVwidth; + while (y--) { + PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(0, 3, 2, 1)); + while (x--) { + Uint8 Y1, U, Y2, V; + + U = srcYUV[0]; + Y1 = srcYUV[1]; + V = srcYUV[2]; + Y2 = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = V; + dstYUV[2] = Y2; + dstYUV[3] = U; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + x = YUVwidth; + } + return true; +} + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_YVYU_to_YUY2_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + x = YUVwidth; + while (y--) { + PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(1, 2, 3, 0)); + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + V = srcYUV[1]; + Y2 = srcYUV[2]; + U = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = U; + dstYUV[2] = Y2; + dstYUV[3] = V; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + x = YUVwidth; + } + return true; +} + +static bool SDL_TARGETING("sse2") SDL_ConvertPixels_YVYU_to_UYVY_SSE2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + x = YUVwidth; + while (y--) { + PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(2, 1, 0, 3)); + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + V = srcYUV[1]; + Y2 = srcYUV[2]; + U = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = U; + dstYUV[1] = Y1; + dstYUV[2] = V; + dstYUV[3] = Y2; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + x = YUVwidth; + } + return true; +} +#endif + +static bool SDL_ConvertPixels_YUY2_to_UYVY_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + while (y--) { + x = YUVwidth; + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + U = srcYUV[1]; + Y2 = srcYUV[2]; + V = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = U; + dstYUV[1] = Y1; + dstYUV[2] = V; + dstYUV[3] = Y2; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + } + return true; +} + +static bool SDL_ConvertPixels_YUY2_to_YVYU_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + while (y--) { + x = YUVwidth; + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + U = srcYUV[1]; + Y2 = srcYUV[2]; + V = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = V; + dstYUV[2] = Y2; + dstYUV[3] = U; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + } + return true; +} + +static bool SDL_ConvertPixels_UYVY_to_YUY2_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + while (y--) { + x = YUVwidth; + while (x--) { + Uint8 Y1, U, Y2, V; + + U = srcYUV[0]; + Y1 = srcYUV[1]; + V = srcYUV[2]; + Y2 = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = U; + dstYUV[2] = Y2; + dstYUV[3] = V; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + } + return true; +} + +static bool SDL_ConvertPixels_UYVY_to_YVYU_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + while (y--) { + x = YUVwidth; + while (x--) { + Uint8 Y1, U, Y2, V; + + U = srcYUV[0]; + Y1 = srcYUV[1]; + V = srcYUV[2]; + Y2 = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = V; + dstYUV[2] = Y2; + dstYUV[3] = U; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + } + return true; +} + +static bool SDL_ConvertPixels_YVYU_to_YUY2_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + while (y--) { + x = YUVwidth; + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + V = srcYUV[1]; + Y2 = srcYUV[2]; + U = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = Y1; + dstYUV[1] = U; + dstYUV[2] = Y2; + dstYUV[3] = V; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + } + return true; +} + +static bool SDL_ConvertPixels_YVYU_to_UYVY_std(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ + int x, y; + const int YUVwidth = (width + 1) / 2; + const int srcYUVPitchLeft = (src_pitch - YUVwidth * 4); + const int dstYUVPitchLeft = (dst_pitch - YUVwidth * 4); + const Uint8 *srcYUV = (const Uint8 *)src; + Uint8 *dstYUV = (Uint8 *)dst; + + y = height; + while (y--) { + x = YUVwidth; + while (x--) { + Uint8 Y1, U, Y2, V; + + Y1 = srcYUV[0]; + V = srcYUV[1]; + Y2 = srcYUV[2]; + U = srcYUV[3]; + srcYUV += 4; + + dstYUV[0] = U; + dstYUV[1] = Y1; + dstYUV[2] = V; + dstYUV[3] = Y2; + dstYUV += 4; + } + srcYUV += srcYUVPitchLeft; + dstYUV += dstYUVPitchLeft; + } + return true; +} + +static bool SDL_ConvertPixels_YUY2_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_YUY2_to_UYVY_SSE2(width, height, src, src_pitch, dst, dst_pitch); + } +#endif + return SDL_ConvertPixels_YUY2_to_UYVY_std(width, height, src, src_pitch, dst, dst_pitch); +} + +static bool SDL_ConvertPixels_YUY2_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_YUY2_to_YVYU_SSE2(width, height, src, src_pitch, dst, dst_pitch); + } +#endif + return SDL_ConvertPixels_YUY2_to_YVYU_std(width, height, src, src_pitch, dst, dst_pitch); +} + +static bool SDL_ConvertPixels_UYVY_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_UYVY_to_YUY2_SSE2(width, height, src, src_pitch, dst, dst_pitch); + } +#endif + return SDL_ConvertPixels_UYVY_to_YUY2_std(width, height, src, src_pitch, dst, dst_pitch); +} + +static bool SDL_ConvertPixels_UYVY_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_UYVY_to_YVYU_SSE2(width, height, src, src_pitch, dst, dst_pitch); + } +#endif + return SDL_ConvertPixels_UYVY_to_YVYU_std(width, height, src, src_pitch, dst, dst_pitch); +} + +static bool SDL_ConvertPixels_YVYU_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_YVYU_to_YUY2_SSE2(width, height, src, src_pitch, dst, dst_pitch); + } +#endif + return SDL_ConvertPixels_YVYU_to_YUY2_std(width, height, src, src_pitch, dst, dst_pitch); +} + +static bool SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch) +{ +#ifdef SDL_SSE2_INTRINSICS + if (SDL_HasSSE2()) { + return SDL_ConvertPixels_YVYU_to_UYVY_SSE2(width, height, src, src_pitch, dst, dst_pitch); + } +#endif + return SDL_ConvertPixels_YVYU_to_UYVY_std(width, height, src, src_pitch, dst, dst_pitch); +} + +static bool SDL_ConvertPixels_Packed4_to_Packed4(int width, int height, + SDL_PixelFormat src_format, const void *src, int src_pitch, + SDL_PixelFormat dst_format, void *dst, int dst_pitch) +{ + switch (src_format) { + case SDL_PIXELFORMAT_YUY2: + switch (dst_format) { + case SDL_PIXELFORMAT_UYVY: + return SDL_ConvertPixels_YUY2_to_UYVY(width, height, src, src_pitch, dst, dst_pitch); + case SDL_PIXELFORMAT_YVYU: + return SDL_ConvertPixels_YUY2_to_YVYU(width, height, src, src_pitch, dst, dst_pitch); + default: + break; + } + break; + case SDL_PIXELFORMAT_UYVY: + switch (dst_format) { + case SDL_PIXELFORMAT_YUY2: + return SDL_ConvertPixels_UYVY_to_YUY2(width, height, src, src_pitch, dst, dst_pitch); + case SDL_PIXELFORMAT_YVYU: + return SDL_ConvertPixels_UYVY_to_YVYU(width, height, src, src_pitch, dst, dst_pitch); + default: + break; + } + break; + case SDL_PIXELFORMAT_YVYU: + switch (dst_format) { + case SDL_PIXELFORMAT_YUY2: + return SDL_ConvertPixels_YVYU_to_YUY2(width, height, src, src_pitch, dst, dst_pitch); + case SDL_PIXELFORMAT_UYVY: + return SDL_ConvertPixels_YVYU_to_UYVY(width, height, src, src_pitch, dst, dst_pitch); + default: + break; + } + break; + default: + break; + } + return SDL_SetError("SDL_ConvertPixels_Packed4_to_Packed4: Unsupported YUV conversion: %s -> %s", SDL_GetPixelFormatName(src_format), + SDL_GetPixelFormatName(dst_format)); +} + +static bool SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height, + SDL_PixelFormat src_format, const void *src, int src_pitch, + SDL_PixelFormat dst_format, void *dst, int dst_pitch) +{ + int x, y; + const Uint8 *srcY1, *srcY2, *srcU, *srcV; + Uint32 srcY_pitch, srcUV_pitch; + Uint32 srcY_pitch_left, srcUV_pitch_left, srcUV_pixel_stride; + Uint8 *dstY1, *dstY2, *dstU1, *dstU2, *dstV1, *dstV2; + Uint32 dstY_pitch, dstUV_pitch; + Uint32 dst_pitch_left; + + if (src == dst) { + return SDL_SetError("Can't change YUV plane types in-place"); + } + + if (!GetYUVPlanes(width, height, src_format, src, src_pitch, + &srcY1, &srcU, &srcV, &srcY_pitch, &srcUV_pitch)) { + return false; + } + srcY2 = srcY1 + srcY_pitch; + srcY_pitch_left = (srcY_pitch - width); + + if (src_format == SDL_PIXELFORMAT_NV12 || src_format == SDL_PIXELFORMAT_NV21) { + srcUV_pixel_stride = 2; + srcUV_pitch_left = (srcUV_pitch - 2 * ((width + 1) / 2)); + } else { + srcUV_pixel_stride = 1; + srcUV_pitch_left = (srcUV_pitch - ((width + 1) / 2)); + } + + if (!GetYUVPlanes(width, height, dst_format, dst, dst_pitch, + (const Uint8 **)&dstY1, (const Uint8 **)&dstU1, (const Uint8 **)&dstV1, + &dstY_pitch, &dstUV_pitch)) { + return false; + } + dstY2 = dstY1 + dstY_pitch; + dstU2 = dstU1 + dstUV_pitch; + dstV2 = dstV1 + dstUV_pitch; + dst_pitch_left = (dstY_pitch - 4 * ((width + 1) / 2)); + + // Copy 2x2 blocks of pixels at a time + for (y = 0; y < (height - 1); y += 2) { + for (x = 0; x < (width - 1); x += 2) { + // Row 1 + *dstY1 = *srcY1++; + dstY1 += 2; + *dstY1 = *srcY1++; + dstY1 += 2; + *dstU1 = *srcU; + *dstV1 = *srcV; + + // Row 2 + *dstY2 = *srcY2++; + dstY2 += 2; + *dstY2 = *srcY2++; + dstY2 += 2; + *dstU2 = *srcU; + *dstV2 = *srcV; + + srcU += srcUV_pixel_stride; + srcV += srcUV_pixel_stride; + dstU1 += 4; + dstU2 += 4; + dstV1 += 4; + dstV2 += 4; + } + + // Last column + if (x == (width - 1)) { + // Row 1 + *dstY1 = *srcY1; + dstY1 += 2; + *dstY1 = *srcY1++; + dstY1 += 2; + *dstU1 = *srcU; + *dstV1 = *srcV; + + // Row 2 + *dstY2 = *srcY2; + dstY2 += 2; + *dstY2 = *srcY2++; + dstY2 += 2; + *dstU2 = *srcU; + *dstV2 = *srcV; + + srcU += srcUV_pixel_stride; + srcV += srcUV_pixel_stride; + dstU1 += 4; + dstU2 += 4; + dstV1 += 4; + dstV2 += 4; + } + + srcY1 += srcY_pitch_left + srcY_pitch; + srcY2 += srcY_pitch_left + srcY_pitch; + srcU += srcUV_pitch_left; + srcV += srcUV_pitch_left; + dstY1 += dst_pitch_left + dstY_pitch; + dstY2 += dst_pitch_left + dstY_pitch; + dstU1 += dst_pitch_left + dstUV_pitch; + dstU2 += dst_pitch_left + dstUV_pitch; + dstV1 += dst_pitch_left + dstUV_pitch; + dstV2 += dst_pitch_left + dstUV_pitch; + } + + // Last row + if (y == (height - 1)) { + for (x = 0; x < (width - 1); x += 2) { + // Row 1 + *dstY1 = *srcY1++; + dstY1 += 2; + *dstY1 = *srcY1++; + dstY1 += 2; + *dstU1 = *srcU; + *dstV1 = *srcV; + + srcU += srcUV_pixel_stride; + srcV += srcUV_pixel_stride; + dstU1 += 4; + dstV1 += 4; + } + + // Last column + if (x == (width - 1)) { + // Row 1 + *dstY1 = *srcY1; + dstY1 += 2; + *dstY1 = *srcY1++; + dstY1 += 2; + *dstU1 = *srcU; + *dstV1 = *srcV; + + srcU += srcUV_pixel_stride; + srcV += srcUV_pixel_stride; + dstU1 += 4; + dstV1 += 4; + } + } + return true; +} + +static bool SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height, + SDL_PixelFormat src_format, const void *src, int src_pitch, + SDL_PixelFormat dst_format, void *dst, int dst_pitch) +{ + int x, y; + const Uint8 *srcY1, *srcY2, *srcU1, *srcU2, *srcV1, *srcV2; + Uint32 srcY_pitch, srcUV_pitch; + Uint32 src_pitch_left; + Uint8 *dstY1, *dstY2, *dstU, *dstV; + Uint32 dstY_pitch, dstUV_pitch; + Uint32 dstY_pitch_left, dstUV_pitch_left, dstUV_pixel_stride; + + if (src == dst) { + return SDL_SetError("Can't change YUV plane types in-place"); + } + + if (!GetYUVPlanes(width, height, src_format, src, src_pitch, + &srcY1, &srcU1, &srcV1, &srcY_pitch, &srcUV_pitch)) { + return false; + } + srcY2 = srcY1 + srcY_pitch; + srcU2 = srcU1 + srcUV_pitch; + srcV2 = srcV1 + srcUV_pitch; + src_pitch_left = (srcY_pitch - 4 * ((width + 1) / 2)); + + if (!GetYUVPlanes(width, height, dst_format, dst, dst_pitch, + (const Uint8 **)&dstY1, (const Uint8 **)&dstU, (const Uint8 **)&dstV, + &dstY_pitch, &dstUV_pitch)) { + return false; + } + dstY2 = dstY1 + dstY_pitch; + dstY_pitch_left = (dstY_pitch - width); + + if (dst_format == SDL_PIXELFORMAT_NV12 || dst_format == SDL_PIXELFORMAT_NV21) { + dstUV_pixel_stride = 2; + dstUV_pitch_left = (dstUV_pitch - 2 * ((width + 1) / 2)); + } else { + dstUV_pixel_stride = 1; + dstUV_pitch_left = (dstUV_pitch - ((width + 1) / 2)); + } + + // Copy 2x2 blocks of pixels at a time + for (y = 0; y < (height - 1); y += 2) { + for (x = 0; x < (width - 1); x += 2) { + // Row 1 + *dstY1++ = *srcY1; + srcY1 += 2; + *dstY1++ = *srcY1; + srcY1 += 2; + + // Row 2 + *dstY2++ = *srcY2; + srcY2 += 2; + *dstY2++ = *srcY2; + srcY2 += 2; + + *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2) / 2); + *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2) / 2); + + srcU1 += 4; + srcU2 += 4; + srcV1 += 4; + srcV2 += 4; + dstU += dstUV_pixel_stride; + dstV += dstUV_pixel_stride; + } + + // Last column + if (x == (width - 1)) { + // Row 1 + *dstY1 = *srcY1; + srcY1 += 2; + *dstY1++ = *srcY1; + srcY1 += 2; + + // Row 2 + *dstY2 = *srcY2; + srcY2 += 2; + *dstY2++ = *srcY2; + srcY2 += 2; + + *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2) / 2); + *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2) / 2); + + srcU1 += 4; + srcU2 += 4; + srcV1 += 4; + srcV2 += 4; + dstU += dstUV_pixel_stride; + dstV += dstUV_pixel_stride; + } + + srcY1 += src_pitch_left + srcY_pitch; + srcY2 += src_pitch_left + srcY_pitch; + srcU1 += src_pitch_left + srcUV_pitch; + srcU2 += src_pitch_left + srcUV_pitch; + srcV1 += src_pitch_left + srcUV_pitch; + srcV2 += src_pitch_left + srcUV_pitch; + dstY1 += dstY_pitch_left + dstY_pitch; + dstY2 += dstY_pitch_left + dstY_pitch; + dstU += dstUV_pitch_left; + dstV += dstUV_pitch_left; + } + + // Last row + if (y == (height - 1)) { + for (x = 0; x < (width - 1); x += 2) { + *dstY1++ = *srcY1; + srcY1 += 2; + *dstY1++ = *srcY1; + srcY1 += 2; + + *dstU = *srcU1; + *dstV = *srcV1; + + srcU1 += 4; + srcV1 += 4; + dstU += dstUV_pixel_stride; + dstV += dstUV_pixel_stride; + } + + // Last column + if (x == (width - 1)) { + *dstY1 = *srcY1; + *dstU = *srcU1; + *dstV = *srcV1; + } + } + return true; +} + +#endif // SDL_HAVE_YUV + +bool SDL_ConvertPixels_YUV_to_YUV(int width, int height, + SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, + SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch) +{ +#ifdef SDL_HAVE_YUV + if (src_colorspace != dst_colorspace) { + return SDL_SetError("SDL_ConvertPixels_YUV_to_YUV: colorspace conversion not supported"); + } + + if (src_format == dst_format) { + if (src == dst) { + // Nothing to do + return true; + } + return SDL_ConvertPixels_YUV_to_YUV_Copy(width, height, src_format, src, src_pitch, dst, dst_pitch); + } + + if (IsPlanar2x2Format(src_format) && IsPlanar2x2Format(dst_format)) { + return SDL_ConvertPixels_Planar2x2_to_Planar2x2(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch); + } else if (IsPacked4Format(src_format) && IsPacked4Format(dst_format)) { + return SDL_ConvertPixels_Packed4_to_Packed4(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch); + } else if (IsPlanar2x2Format(src_format) && IsPacked4Format(dst_format)) { + return SDL_ConvertPixels_Planar2x2_to_Packed4(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch); + } else if (IsPacked4Format(src_format) && IsPlanar2x2Format(dst_format)) { + return SDL_ConvertPixels_Packed4_to_Planar2x2(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch); + } else { + return SDL_SetError("SDL_ConvertPixels_YUV_to_YUV: Unsupported YUV conversion: %s -> %s", SDL_GetPixelFormatName(src_format), + SDL_GetPixelFormatName(dst_format)); + } +#else + return SDL_SetError("SDL not built with YUV support"); +#endif +} diff --git a/contrib/SDL-3.2.8/src/video/SDL_yuv_c.h b/contrib/SDL-3.2.8/src/video/SDL_yuv_c.h new file mode 100644 index 0000000..af1d484 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/SDL_yuv_c.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_yuv_c_h_ +#define SDL_yuv_c_h_ + +#include "SDL_internal.h" + +// YUV conversion functions + +extern bool SDL_ConvertPixels_YUV_to_RGB(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); +extern bool SDL_ConvertPixels_RGB_to_YUV(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); +extern bool SDL_ConvertPixels_YUV_to_YUV(int width, int height, SDL_PixelFormat src_format, SDL_Colorspace src_colorspace, SDL_PropertiesID src_properties, const void *src, int src_pitch, SDL_PixelFormat dst_format, SDL_Colorspace dst_colorspace, SDL_PropertiesID dst_properties, void *dst, int dst_pitch); + + +extern bool SDL_CalculateYUVSize(SDL_PixelFormat format, int w, int h, size_t *size, size_t *pitch); + +#endif // SDL_yuv_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.c new file mode 100644 index 0000000..ec02350 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.c @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include "SDL_androidvideo.h" +#include "SDL_androidclipboard.h" +#include "../../core/android/SDL_android.h" + +bool Android_SetClipboardText(SDL_VideoDevice *_this, const char *text) +{ + return Android_JNI_SetClipboardText(text); +} + +char *Android_GetClipboardText(SDL_VideoDevice *_this) +{ + return Android_JNI_GetClipboardText(); +} + +bool Android_HasClipboardText(SDL_VideoDevice *_this) +{ + return Android_JNI_HasClipboardText(); +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.h new file mode 100644 index 0000000..d102112 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidclipboard.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_androidclipboard_h_ +#define SDL_androidclipboard_h_ + +extern bool Android_SetClipboardText(SDL_VideoDevice *_this, const char *text); +extern char *Android_GetClipboardText(SDL_VideoDevice *_this); +extern bool Android_HasClipboardText(SDL_VideoDevice *_this); + +#endif // SDL_androidclipboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidevents.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidevents.c new file mode 100644 index 0000000..e32d272 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidevents.c @@ -0,0 +1,269 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include "SDL_androidevents.h" +#include "SDL_androidkeyboard.h" +#include "SDL_androidwindow.h" +#include "../SDL_sysvideo.h" +#include "../../events/SDL_events_c.h" + +#include "../../audio/aaudio/SDL_aaudio.h" +#include "../../audio/openslES/SDL_openslES.h" + + +#ifdef SDL_VIDEO_OPENGL_EGL +static void android_egl_context_restore(SDL_Window *window) +{ + if (window) { + SDL_WindowData *data = window->internal; + SDL_GL_MakeCurrent(window, NULL); + if (!SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context)) { + // The context is no longer valid, create a new one + data->egl_context = (EGLContext)SDL_GL_CreateContext(window); + SDL_GL_MakeCurrent(window, (SDL_GLContext)data->egl_context); + SDL_Event event; + SDL_zero(event); + event.type = SDL_EVENT_RENDER_DEVICE_RESET; + event.render.windowID = SDL_GetWindowID(window); + SDL_PushEvent(&event); + } + data->backup_done = false; + + if (data->has_swap_interval) { + SDL_GL_SetSwapInterval(data->swap_interval); + } + + } +} + +static void android_egl_context_backup(SDL_Window *window) +{ + if (window) { + int interval = 0; + // Keep a copy of the EGL Context so we can try to restore it when we resume + SDL_WindowData *data = window->internal; + data->egl_context = SDL_GL_GetCurrentContext(); + + // Save/Restore the swap interval / vsync + if (SDL_GL_GetSwapInterval(&interval)) { + data->has_swap_interval = 1; + data->swap_interval = interval; + } + + // We need to do this so the EGLSurface can be freed + SDL_GL_MakeCurrent(window, NULL); + data->backup_done = true; + } +} +#endif + +/* + * Android_ResumeSem and Android_PauseSem are signaled from Java_org_libsdl_app_SDLActivity_nativePause and Java_org_libsdl_app_SDLActivity_nativeResume + */ +static bool Android_EventsInitialized; +static bool Android_BlockOnPause = true; +static bool Android_Paused; +static bool Android_PausedAudio; +static bool Android_Destroyed; + +void Android_InitEvents(void) +{ + if (!Android_EventsInitialized) { + Android_BlockOnPause = SDL_GetHintBoolean(SDL_HINT_ANDROID_BLOCK_ON_PAUSE, true); + Android_Paused = false; + Android_Destroyed = false; + Android_EventsInitialized = true; + } +} + +static void Android_PauseAudio(void) +{ + OPENSLES_PauseDevices(); + AAUDIO_PauseDevices(); + Android_PausedAudio = true; +} + +static void Android_ResumeAudio(void) +{ + if (Android_PausedAudio) { + OPENSLES_ResumeDevices(); + AAUDIO_ResumeDevices(); + Android_PausedAudio = false; + } +} + +static void Android_OnPause(void) +{ + SDL_OnApplicationWillEnterBackground(); + SDL_OnApplicationDidEnterBackground(); + + /* The semantics are that as soon as the enter background event + * has been queued, the app will block. The application should + * do any life cycle handling in an event filter while the event + * was being queued. + */ +#ifdef SDL_VIDEO_OPENGL_EGL + if (Android_Window && !Android_Window->external_graphics_context) { + Android_LockActivityMutex(); + android_egl_context_backup(Android_Window); + Android_UnlockActivityMutex(); + } +#endif + + if (Android_BlockOnPause) { + // We're blocking, also pause audio + Android_PauseAudio(); + } + + Android_Paused = true; +} + +static void Android_OnResume(void) +{ + Android_Paused = false; + + SDL_OnApplicationWillEnterForeground(); + + Android_ResumeAudio(); + +#ifdef SDL_VIDEO_OPENGL_EGL + // Restore the GL Context from here, as this operation is thread dependent + if (Android_Window && !Android_Window->external_graphics_context && !SDL_HasEvent(SDL_EVENT_QUIT)) { + Android_LockActivityMutex(); + android_egl_context_restore(Android_Window); + Android_UnlockActivityMutex(); + } +#endif + + // Make sure SW Keyboard is restored when an app becomes foreground + if (Android_Window) { + Android_RestoreScreenKeyboardOnResume(SDL_GetVideoDevice(), Android_Window); + } + + SDL_OnApplicationDidEnterForeground(); +} + +static void Android_OnLowMemory(void) +{ + SDL_SendAppEvent(SDL_EVENT_LOW_MEMORY); +} + +static void Android_OnDestroy(void) +{ + // Make sure we unblock any audio processing before we quit + Android_ResumeAudio(); + + /* Discard previous events. The user should have handled state storage + * in SDL_EVENT_WILL_ENTER_BACKGROUND. After nativeSendQuit() is called, no + * events other than SDL_EVENT_QUIT and SDL_EVENT_TERMINATING should fire */ + SDL_FlushEvents(SDL_EVENT_FIRST, SDL_EVENT_LAST); + SDL_SendQuit(); + SDL_SendAppEvent(SDL_EVENT_TERMINATING); + + Android_Destroyed = true; +} + +static void Android_HandleLifecycleEvent(SDL_AndroidLifecycleEvent event) +{ + switch (event) { + case SDL_ANDROID_LIFECYCLE_WAKE: + // Nothing to do, just return + break; + case SDL_ANDROID_LIFECYCLE_PAUSE: + Android_OnPause(); + break; + case SDL_ANDROID_LIFECYCLE_RESUME: + Android_OnResume(); + break; + case SDL_ANDROID_LIFECYCLE_LOWMEMORY: + Android_OnLowMemory(); + break; + case SDL_ANDROID_LIFECYCLE_DESTROY: + Android_OnDestroy(); + break; + default: + break; + } +} + +static Sint64 GetLifecycleEventTimeout(bool paused, Sint64 timeoutNS) +{ + if (Android_Paused) { + if (Android_BlockOnPause) { + timeoutNS = -1; + } else if (timeoutNS == 0) { + timeoutNS = SDL_MS_TO_NS(100); + } + } + return timeoutNS; +} + +void Android_PumpEvents(Sint64 timeoutNS) +{ + SDL_AndroidLifecycleEvent event; + bool paused = Android_Paused; + + while (!Android_Destroyed && + Android_WaitLifecycleEvent(&event, GetLifecycleEventTimeout(paused, timeoutNS))) { + Android_HandleLifecycleEvent(event); + + switch (event) { + case SDL_ANDROID_LIFECYCLE_WAKE: + // Finish handling events quickly if we're not paused + timeoutNS = 0; + break; + case SDL_ANDROID_LIFECYCLE_PAUSE: + // Finish handling events at the current timeout and return to process events one more time before blocking. + break; + case SDL_ANDROID_LIFECYCLE_RESUME: + // Finish handling events at the resume state timeout + paused = false; + break; + default: + break; + } + } +} + +bool Android_WaitActiveAndLockActivity(void) +{ + while (Android_Paused && !Android_Destroyed) { + Android_PumpEvents(-1); + } + + if (Android_Destroyed) { + SDL_SetError("Android activity has been destroyed"); + return false; + } + + Android_LockActivityMutex(); + return true; +} + +void Android_QuitEvents(void) +{ + Android_EventsInitialized = false; +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidevents.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidevents.h new file mode 100644 index 0000000..bb57d3b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidevents.h @@ -0,0 +1,26 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +extern void Android_InitEvents(void); +extern void Android_PumpEvents(Sint64 timeoutNS); +extern bool Android_WaitActiveAndLockActivity(void); +extern void Android_QuitEvents(void); diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidgl.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidgl.c new file mode 100644 index 0000000..37fb2d5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidgl.c @@ -0,0 +1,88 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_ANDROID) && defined(SDL_VIDEO_OPENGL_EGL) + +// Android SDL video driver implementation + +#include "../SDL_egl_c.h" +#include "SDL_androidwindow.h" + +#include "SDL_androidvideo.h" +#include "SDL_androidevents.h" +#include "SDL_androidgl.h" +#include "../../core/android/SDL_android.h" + +#include + +#include + +bool Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + if (window && context) { + return SDL_EGL_MakeCurrent(_this, window->internal->egl_surface, context); + } else { + return SDL_EGL_MakeCurrent(_this, NULL, NULL); + } +} + +SDL_GLContext Android_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_GLContext result; + + if (!Android_WaitActiveAndLockActivity()) { + return NULL; + } + + result = SDL_EGL_CreateContext(_this, window->internal->egl_surface); + + Android_UnlockActivityMutex(); + + return result; +} + +bool Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + bool result; + + Android_LockActivityMutex(); + + /* The following two calls existed in the original Java code + * If you happen to have a device that's affected by their removal, + * please report to our bug tracker. -- Gabriel + */ + + /*_this->egl_data->eglWaitNative(EGL_CORE_NATIVE_ENGINE); + _this->egl_data->eglWaitGL();*/ + result = SDL_EGL_SwapBuffers(_this, window->internal->egl_surface); + + Android_UnlockActivityMutex(); + + return result; +} + +bool Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidgl.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidgl.h new file mode 100644 index 0000000..99c84d0 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidgl.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_androidgl_h_ +#define SDL_androidgl_h_ + +extern SDL_GLContext Android_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Android_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool Android_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Android_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); + +#endif // SDL_androidgl_h_ diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.c new file mode 100644 index 0000000..03af7c6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.c @@ -0,0 +1,468 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include + +#include "../../events/SDL_events_c.h" + +#include "SDL_androidkeyboard.h" + +#include "../../core/android/SDL_android.h" + +#define TYPE_CLASS_TEXT 0x00000001 +#define TYPE_CLASS_NUMBER 0x00000002 +#define TYPE_CLASS_PHONE 0x00000003 +#define TYPE_CLASS_DATETIME 0x00000004 + +#define TYPE_DATETIME_VARIATION_NORMAL 0x00000000 +#define TYPE_DATETIME_VARIATION_DATE 0x00000010 +#define TYPE_DATETIME_VARIATION_TIME 0x00000020 + +#define TYPE_NUMBER_VARIATION_NORMAL 0x00000000 +#define TYPE_NUMBER_VARIATION_PASSWORD 0x00000010 +#define TYPE_NUMBER_FLAG_SIGNED 0x00001000 +#define TYPE_NUMBER_FLAG_DECIMAL 0x00002000 + +#define TYPE_TEXT_FLAG_CAP_CHARACTERS 0x00001000 +#define TYPE_TEXT_FLAG_CAP_WORDS 0x00002000 +#define TYPE_TEXT_FLAG_CAP_SENTENCES 0x00004000 +#define TYPE_TEXT_FLAG_AUTO_CORRECT 0x00008000 +#define TYPE_TEXT_FLAG_AUTO_COMPLETE 0x00010000 +#define TYPE_TEXT_FLAG_MULTI_LINE 0x00020000 +#define TYPE_TEXT_FLAG_IME_MULTI_LINE 0x00040000 +#define TYPE_TEXT_FLAG_NO_SUGGESTIONS 0x00080000 + +#define TYPE_TEXT_VARIATION_NORMAL 0x00000000 +#define TYPE_TEXT_VARIATION_URI 0x00000010 +#define TYPE_TEXT_VARIATION_EMAIL_ADDRESS 0x00000020 +#define TYPE_TEXT_VARIATION_EMAIL_SUBJECT 0x00000030 +#define TYPE_TEXT_VARIATION_SHORT_MESSAGE 0x00000040 +#define TYPE_TEXT_VARIATION_LONG_MESSAGE 0x00000050 +#define TYPE_TEXT_VARIATION_PERSON_NAME 0x00000060 +#define TYPE_TEXT_VARIATION_POSTAL_ADDRESS 0x00000070 +#define TYPE_TEXT_VARIATION_PASSWORD 0x00000080 +#define TYPE_TEXT_VARIATION_VISIBLE_PASSWORD 0x00000090 +#define TYPE_TEXT_VARIATION_WEB_EDIT_TEXT 0x000000a0 +#define TYPE_TEXT_VARIATION_FILTER 0x000000b0 +#define TYPE_TEXT_VARIATION_PHONETIC 0x000000c0 +#define TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS 0x000000d0 +#define TYPE_TEXT_VARIATION_WEB_PASSWORD 0x000000e0 + + +static SDL_Scancode Android_Keycodes[] = { + SDL_SCANCODE_UNKNOWN, // AKEYCODE_UNKNOWN + SDL_SCANCODE_SOFTLEFT, // AKEYCODE_SOFT_LEFT + SDL_SCANCODE_SOFTRIGHT, // AKEYCODE_SOFT_RIGHT + SDL_SCANCODE_AC_HOME, // AKEYCODE_HOME + SDL_SCANCODE_AC_BACK, // AKEYCODE_BACK + SDL_SCANCODE_CALL, // AKEYCODE_CALL + SDL_SCANCODE_ENDCALL, // AKEYCODE_ENDCALL + SDL_SCANCODE_0, // AKEYCODE_0 + SDL_SCANCODE_1, // AKEYCODE_1 + SDL_SCANCODE_2, // AKEYCODE_2 + SDL_SCANCODE_3, // AKEYCODE_3 + SDL_SCANCODE_4, // AKEYCODE_4 + SDL_SCANCODE_5, // AKEYCODE_5 + SDL_SCANCODE_6, // AKEYCODE_6 + SDL_SCANCODE_7, // AKEYCODE_7 + SDL_SCANCODE_8, // AKEYCODE_8 + SDL_SCANCODE_9, // AKEYCODE_9 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_STAR + SDL_SCANCODE_UNKNOWN, // AKEYCODE_POUND + SDL_SCANCODE_UP, // AKEYCODE_DPAD_UP + SDL_SCANCODE_DOWN, // AKEYCODE_DPAD_DOWN + SDL_SCANCODE_LEFT, // AKEYCODE_DPAD_LEFT + SDL_SCANCODE_RIGHT, // AKEYCODE_DPAD_RIGHT + SDL_SCANCODE_SELECT, // AKEYCODE_DPAD_CENTER + SDL_SCANCODE_VOLUMEUP, // AKEYCODE_VOLUME_UP + SDL_SCANCODE_VOLUMEDOWN, // AKEYCODE_VOLUME_DOWN + SDL_SCANCODE_POWER, // AKEYCODE_POWER + SDL_SCANCODE_UNKNOWN, // AKEYCODE_CAMERA + SDL_SCANCODE_CLEAR, // AKEYCODE_CLEAR + SDL_SCANCODE_A, // AKEYCODE_A + SDL_SCANCODE_B, // AKEYCODE_B + SDL_SCANCODE_C, // AKEYCODE_C + SDL_SCANCODE_D, // AKEYCODE_D + SDL_SCANCODE_E, // AKEYCODE_E + SDL_SCANCODE_F, // AKEYCODE_F + SDL_SCANCODE_G, // AKEYCODE_G + SDL_SCANCODE_H, // AKEYCODE_H + SDL_SCANCODE_I, // AKEYCODE_I + SDL_SCANCODE_J, // AKEYCODE_J + SDL_SCANCODE_K, // AKEYCODE_K + SDL_SCANCODE_L, // AKEYCODE_L + SDL_SCANCODE_M, // AKEYCODE_M + SDL_SCANCODE_N, // AKEYCODE_N + SDL_SCANCODE_O, // AKEYCODE_O + SDL_SCANCODE_P, // AKEYCODE_P + SDL_SCANCODE_Q, // AKEYCODE_Q + SDL_SCANCODE_R, // AKEYCODE_R + SDL_SCANCODE_S, // AKEYCODE_S + SDL_SCANCODE_T, // AKEYCODE_T + SDL_SCANCODE_U, // AKEYCODE_U + SDL_SCANCODE_V, // AKEYCODE_V + SDL_SCANCODE_W, // AKEYCODE_W + SDL_SCANCODE_X, // AKEYCODE_X + SDL_SCANCODE_Y, // AKEYCODE_Y + SDL_SCANCODE_Z, // AKEYCODE_Z + SDL_SCANCODE_COMMA, // AKEYCODE_COMMA + SDL_SCANCODE_PERIOD, // AKEYCODE_PERIOD + SDL_SCANCODE_LALT, // AKEYCODE_ALT_LEFT + SDL_SCANCODE_RALT, // AKEYCODE_ALT_RIGHT + SDL_SCANCODE_LSHIFT, // AKEYCODE_SHIFT_LEFT + SDL_SCANCODE_RSHIFT, // AKEYCODE_SHIFT_RIGHT + SDL_SCANCODE_TAB, // AKEYCODE_TAB + SDL_SCANCODE_SPACE, // AKEYCODE_SPACE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_SYM + SDL_SCANCODE_UNKNOWN, // AKEYCODE_EXPLORER + SDL_SCANCODE_UNKNOWN, // AKEYCODE_ENVELOPE + SDL_SCANCODE_RETURN, // AKEYCODE_ENTER + SDL_SCANCODE_BACKSPACE, // AKEYCODE_DEL + SDL_SCANCODE_GRAVE, // AKEYCODE_GRAVE + SDL_SCANCODE_MINUS, // AKEYCODE_MINUS + SDL_SCANCODE_EQUALS, // AKEYCODE_EQUALS + SDL_SCANCODE_LEFTBRACKET, // AKEYCODE_LEFT_BRACKET + SDL_SCANCODE_RIGHTBRACKET, // AKEYCODE_RIGHT_BRACKET + SDL_SCANCODE_BACKSLASH, // AKEYCODE_BACKSLASH + SDL_SCANCODE_SEMICOLON, // AKEYCODE_SEMICOLON + SDL_SCANCODE_APOSTROPHE, // AKEYCODE_APOSTROPHE + SDL_SCANCODE_SLASH, // AKEYCODE_SLASH + SDL_SCANCODE_UNKNOWN, // AKEYCODE_AT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_NUM + SDL_SCANCODE_UNKNOWN, // AKEYCODE_HEADSETHOOK + SDL_SCANCODE_UNKNOWN, // AKEYCODE_FOCUS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_PLUS + SDL_SCANCODE_MENU, // AKEYCODE_MENU + SDL_SCANCODE_UNKNOWN, // AKEYCODE_NOTIFICATION + SDL_SCANCODE_AC_SEARCH, // AKEYCODE_SEARCH + SDL_SCANCODE_MEDIA_PLAY_PAUSE, // AKEYCODE_MEDIA_PLAY_PAUSE + SDL_SCANCODE_MEDIA_STOP, // AKEYCODE_MEDIA_STOP + SDL_SCANCODE_MEDIA_NEXT_TRACK, // AKEYCODE_MEDIA_NEXT + SDL_SCANCODE_MEDIA_PREVIOUS_TRACK, // AKEYCODE_MEDIA_PREVIOUS + SDL_SCANCODE_MEDIA_REWIND, // AKEYCODE_MEDIA_REWIND + SDL_SCANCODE_MEDIA_FAST_FORWARD, // AKEYCODE_MEDIA_FAST_FORWARD + SDL_SCANCODE_MUTE, // AKEYCODE_MUTE + SDL_SCANCODE_PAGEUP, // AKEYCODE_PAGE_UP + SDL_SCANCODE_PAGEDOWN, // AKEYCODE_PAGE_DOWN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_PICTSYMBOLS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_SWITCH_CHARSET + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_A + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_B + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_C + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_X + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_Y + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_Z + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_L1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_R1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_L2 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_R2 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_THUMBL + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_THUMBR + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_START + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_SELECT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_MODE + SDL_SCANCODE_ESCAPE, // AKEYCODE_ESCAPE + SDL_SCANCODE_DELETE, // AKEYCODE_FORWARD_DEL + SDL_SCANCODE_LCTRL, // AKEYCODE_CTRL_LEFT + SDL_SCANCODE_RCTRL, // AKEYCODE_CTRL_RIGHT + SDL_SCANCODE_CAPSLOCK, // AKEYCODE_CAPS_LOCK + SDL_SCANCODE_SCROLLLOCK, // AKEYCODE_SCROLL_LOCK + SDL_SCANCODE_LGUI, // AKEYCODE_META_LEFT + SDL_SCANCODE_RGUI, // AKEYCODE_META_RIGHT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_FUNCTION + SDL_SCANCODE_PRINTSCREEN, // AKEYCODE_SYSRQ + SDL_SCANCODE_PAUSE, // AKEYCODE_BREAK + SDL_SCANCODE_HOME, // AKEYCODE_MOVE_HOME + SDL_SCANCODE_END, // AKEYCODE_MOVE_END + SDL_SCANCODE_INSERT, // AKEYCODE_INSERT + SDL_SCANCODE_AC_FORWARD, // AKEYCODE_FORWARD + SDL_SCANCODE_MEDIA_PLAY, // AKEYCODE_MEDIA_PLAY + SDL_SCANCODE_MEDIA_PAUSE, // AKEYCODE_MEDIA_PAUSE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_CLOSE + SDL_SCANCODE_MEDIA_EJECT, // AKEYCODE_MEDIA_EJECT + SDL_SCANCODE_MEDIA_RECORD, // AKEYCODE_MEDIA_RECORD + SDL_SCANCODE_F1, // AKEYCODE_F1 + SDL_SCANCODE_F2, // AKEYCODE_F2 + SDL_SCANCODE_F3, // AKEYCODE_F3 + SDL_SCANCODE_F4, // AKEYCODE_F4 + SDL_SCANCODE_F5, // AKEYCODE_F5 + SDL_SCANCODE_F6, // AKEYCODE_F6 + SDL_SCANCODE_F7, // AKEYCODE_F7 + SDL_SCANCODE_F8, // AKEYCODE_F8 + SDL_SCANCODE_F9, // AKEYCODE_F9 + SDL_SCANCODE_F10, // AKEYCODE_F10 + SDL_SCANCODE_F11, // AKEYCODE_F11 + SDL_SCANCODE_F12, // AKEYCODE_F12 + SDL_SCANCODE_NUMLOCKCLEAR, // AKEYCODE_NUM_LOCK + SDL_SCANCODE_KP_0, // AKEYCODE_NUMPAD_0 + SDL_SCANCODE_KP_1, // AKEYCODE_NUMPAD_1 + SDL_SCANCODE_KP_2, // AKEYCODE_NUMPAD_2 + SDL_SCANCODE_KP_3, // AKEYCODE_NUMPAD_3 + SDL_SCANCODE_KP_4, // AKEYCODE_NUMPAD_4 + SDL_SCANCODE_KP_5, // AKEYCODE_NUMPAD_5 + SDL_SCANCODE_KP_6, // AKEYCODE_NUMPAD_6 + SDL_SCANCODE_KP_7, // AKEYCODE_NUMPAD_7 + SDL_SCANCODE_KP_8, // AKEYCODE_NUMPAD_8 + SDL_SCANCODE_KP_9, // AKEYCODE_NUMPAD_9 + SDL_SCANCODE_KP_DIVIDE, // AKEYCODE_NUMPAD_DIVIDE + SDL_SCANCODE_KP_MULTIPLY, // AKEYCODE_NUMPAD_MULTIPLY + SDL_SCANCODE_KP_MINUS, // AKEYCODE_NUMPAD_SUBTRACT + SDL_SCANCODE_KP_PLUS, // AKEYCODE_NUMPAD_ADD + SDL_SCANCODE_KP_PERIOD, // AKEYCODE_NUMPAD_DOT + SDL_SCANCODE_KP_COMMA, // AKEYCODE_NUMPAD_COMMA + SDL_SCANCODE_KP_ENTER, // AKEYCODE_NUMPAD_ENTER + SDL_SCANCODE_KP_EQUALS, // AKEYCODE_NUMPAD_EQUALS + SDL_SCANCODE_KP_LEFTPAREN, // AKEYCODE_NUMPAD_LEFT_PAREN + SDL_SCANCODE_KP_RIGHTPAREN, // AKEYCODE_NUMPAD_RIGHT_PAREN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_VOLUME_MUTE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_INFO + SDL_SCANCODE_CHANNEL_INCREMENT, // AKEYCODE_CHANNEL_UP + SDL_SCANCODE_CHANNEL_INCREMENT, // AKEYCODE_CHANNEL_DOWN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_ZOOM_IN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_ZOOM_OUT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV + SDL_SCANCODE_UNKNOWN, // AKEYCODE_WINDOW + SDL_SCANCODE_UNKNOWN, // AKEYCODE_GUIDE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_DVR + SDL_SCANCODE_AC_BOOKMARKS, // AKEYCODE_BOOKMARK + SDL_SCANCODE_UNKNOWN, // AKEYCODE_CAPTIONS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_SETTINGS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_POWER + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_STB_POWER + SDL_SCANCODE_UNKNOWN, // AKEYCODE_STB_INPUT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_AVR_POWER + SDL_SCANCODE_UNKNOWN, // AKEYCODE_AVR_INPUT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_PROG_RED + SDL_SCANCODE_UNKNOWN, // AKEYCODE_PROG_GREEN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_PROG_YELLOW + SDL_SCANCODE_UNKNOWN, // AKEYCODE_PROG_BLUE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_APP_SWITCH + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_2 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_3 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_4 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_5 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_6 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_7 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_8 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_9 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_10 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_11 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_12 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_13 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_14 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_15 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BUTTON_16 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_LANGUAGE_SWITCH + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MANNER_MODE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_3D_MODE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_CONTACTS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_CALENDAR + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MUSIC + SDL_SCANCODE_UNKNOWN, // AKEYCODE_CALCULATOR + SDL_SCANCODE_LANG5, // AKEYCODE_ZENKAKU_HANKAKU + SDL_SCANCODE_UNKNOWN, // AKEYCODE_EISU + SDL_SCANCODE_INTERNATIONAL5, // AKEYCODE_MUHENKAN + SDL_SCANCODE_INTERNATIONAL4, // AKEYCODE_HENKAN + SDL_SCANCODE_LANG3, // AKEYCODE_KATAKANA_HIRAGANA + SDL_SCANCODE_INTERNATIONAL3, // AKEYCODE_YEN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_RO + SDL_SCANCODE_UNKNOWN, // AKEYCODE_KANA + SDL_SCANCODE_UNKNOWN, // AKEYCODE_ASSIST + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BRIGHTNESS_DOWN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_BRIGHTNESS_UP + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_AUDIO_TRACK + SDL_SCANCODE_SLEEP, // AKEYCODE_SLEEP + SDL_SCANCODE_UNKNOWN, // AKEYCODE_WAKEUP + SDL_SCANCODE_UNKNOWN, // AKEYCODE_PAIRING + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_TOP_MENU + SDL_SCANCODE_UNKNOWN, // AKEYCODE_11 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_12 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_LAST_CHANNEL + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_DATA_SERVICE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_VOICE_ASSIST + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_RADIO_SERVICE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_TELETEXT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_NUMBER_ENTRY + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_TERRESTRIAL_ANALOG + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_TERRESTRIAL_DIGITAL + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_SATELLITE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_SATELLITE_BS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_SATELLITE_CS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_SATELLITE_SERVICE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_NETWORK + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_ANTENNA_CABLE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_HDMI_1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_HDMI_2 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_HDMI_3 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_HDMI_4 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_COMPOSITE_1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_COMPOSITE_2 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_COMPONENT_1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_COMPONENT_2 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_INPUT_VGA_1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_AUDIO_DESCRIPTION + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_UP + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_AUDIO_DESCRIPTION_MIX_DOWN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_ZOOM_MODE + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_CONTENTS_MENU + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_MEDIA_CONTEXT_MENU + SDL_SCANCODE_UNKNOWN, // AKEYCODE_TV_TIMER_PROGRAMMING + SDL_SCANCODE_HELP, // AKEYCODE_HELP + SDL_SCANCODE_UNKNOWN, // AKEYCODE_NAVIGATE_PREVIOUS + SDL_SCANCODE_UNKNOWN, // AKEYCODE_NAVIGATE_NEXT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_NAVIGATE_IN + SDL_SCANCODE_UNKNOWN, // AKEYCODE_NAVIGATE_OUT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_STEM_PRIMARY + SDL_SCANCODE_UNKNOWN, // AKEYCODE_STEM_1 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_STEM_2 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_STEM_3 + SDL_SCANCODE_UNKNOWN, // AKEYCODE_DPAD_UP_LEFT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_DPAD_DOWN_LEFT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_DPAD_UP_RIGHT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_DPAD_DOWN_RIGHT + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_SKIP_FORWARD + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_SKIP_BACKWARD + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_STEP_FORWARD + SDL_SCANCODE_UNKNOWN, // AKEYCODE_MEDIA_STEP_BACKWARD + SDL_SCANCODE_UNKNOWN, // AKEYCODE_SOFT_SLEEP + SDL_SCANCODE_CUT, // AKEYCODE_CUT + SDL_SCANCODE_COPY, // AKEYCODE_COPY + SDL_SCANCODE_PASTE, // AKEYCODE_PASTE +}; + +static bool SDL_screen_keyboard_shown; + +static SDL_Scancode TranslateKeycode(int keycode) +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + + if (keycode < SDL_arraysize(Android_Keycodes)) { + scancode = Android_Keycodes[keycode]; + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "Unknown keycode %d", keycode); + } + return scancode; +} + +void Android_OnKeyDown(int keycode) +{ + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, keycode, TranslateKeycode(keycode), true); +} + +void Android_OnKeyUp(int keycode) +{ + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, keycode, TranslateKeycode(keycode), false); +} + +bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + return true; +} + +void Android_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + int input_type = 0; + if (SDL_HasProperty(props, SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER)) { + input_type = (int)SDL_GetNumberProperty(props, SDL_PROP_TEXTINPUT_ANDROID_INPUTTYPE_NUMBER, 0); + } else { + switch (SDL_GetTextInputType(props)) { + default: + case SDL_TEXTINPUT_TYPE_TEXT: + input_type = (TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_NORMAL); + break; + case SDL_TEXTINPUT_TYPE_TEXT_NAME: + input_type = (TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PERSON_NAME); + break; + case SDL_TEXTINPUT_TYPE_TEXT_EMAIL: + input_type = (TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_EMAIL_ADDRESS); + break; + case SDL_TEXTINPUT_TYPE_TEXT_USERNAME: + input_type = (TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_NORMAL); + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN: + input_type = (TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_PASSWORD); + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE: + input_type = (TYPE_CLASS_TEXT | TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); + break; + case SDL_TEXTINPUT_TYPE_NUMBER: + input_type = (TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_NORMAL); + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + input_type = (TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_PASSWORD); + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE: + input_type = (TYPE_CLASS_NUMBER | TYPE_NUMBER_VARIATION_NORMAL); + break; + } + + switch (SDL_GetTextInputCapitalization(props)) { + default: + case SDL_CAPITALIZE_NONE: + break; + case SDL_CAPITALIZE_LETTERS: + input_type |= TYPE_TEXT_FLAG_CAP_CHARACTERS; + break; + case SDL_CAPITALIZE_WORDS: + input_type |= TYPE_TEXT_FLAG_CAP_WORDS; + break; + case SDL_CAPITALIZE_SENTENCES: + input_type |= TYPE_TEXT_FLAG_CAP_SENTENCES; + break; + } + + if (SDL_GetTextInputAutocorrect(props)) { + input_type |= (TYPE_TEXT_FLAG_AUTO_CORRECT | TYPE_TEXT_FLAG_AUTO_COMPLETE); + } + + if (SDL_GetTextInputMultiline(props)) { + input_type |= TYPE_TEXT_FLAG_MULTI_LINE; + } + } + Android_JNI_ShowScreenKeyboard(input_type, &window->text_input_rect); + SDL_screen_keyboard_shown = true; +} + +void Android_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +{ + Android_JNI_HideScreenKeyboard(); + SDL_screen_keyboard_shown = false; +} + +void Android_RestoreScreenKeyboardOnResume(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (SDL_screen_keyboard_shown) { + Android_ShowScreenKeyboard(_this, window, window->text_input_props); + } +} + +bool Android_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +{ + return Android_JNI_IsScreenKeyboardShown(); +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.h new file mode 100644 index 0000000..c192991 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidkeyboard.h @@ -0,0 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_androidvideo.h" + +extern void Android_OnKeyDown(int keycode); +extern void Android_OnKeyUp(int keycode); + +extern bool Android_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern void Android_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern void Android_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); +extern void Android_RestoreScreenKeyboardOnResume(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Android_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.c new file mode 100644 index 0000000..9387082 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.c @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include "SDL_androidmessagebox.h" +#include "../../core/android/SDL_android.h" + +bool Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + return Android_JNI_ShowMessageBox(messageboxdata, buttonID); +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.h new file mode 100644 index 0000000..6cd5d7c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidmessagebox.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +extern bool Android_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.c new file mode 100644 index 0000000..2facf0d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.c @@ -0,0 +1,250 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include "SDL_androidmouse.h" + +#include "../../events/SDL_mouse_c.h" + +#include "../../core/android/SDL_android.h" + +// See Android's MotionEvent class for constants +#define ACTION_DOWN 0 +#define ACTION_UP 1 +#define ACTION_MOVE 2 +#define ACTION_HOVER_MOVE 7 +#define ACTION_SCROLL 8 +#define BUTTON_PRIMARY 1 +#define BUTTON_SECONDARY 2 +#define BUTTON_TERTIARY 4 +#define BUTTON_BACK 8 +#define BUTTON_FORWARD 16 + +struct SDL_CursorData +{ + int custom_cursor; + int system_cursor; +}; + +// Last known Android mouse button state (includes all buttons) +static int last_state; + +// Blank cursor +static SDL_Cursor *empty_cursor; + +static SDL_Cursor *Android_WrapCursor(int custom_cursor, int system_cursor) +{ + SDL_Cursor *cursor; + + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + SDL_CursorData *data = (SDL_CursorData *)SDL_calloc(1, sizeof(*data)); + if (data) { + data->custom_cursor = custom_cursor; + data->system_cursor = system_cursor; + cursor->internal = data; + } else { + SDL_free(cursor); + cursor = NULL; + } + } + + return cursor; +} + +static SDL_Cursor *Android_CreateDefaultCursor(void) +{ + SDL_SystemCursor id = SDL_GetDefaultSystemCursor(); + return Android_WrapCursor(0, id); +} + +static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + int custom_cursor; + SDL_Surface *converted; + + converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888); + if (!converted) { + return NULL; + } + custom_cursor = Android_JNI_CreateCustomCursor(converted, hot_x, hot_y); + SDL_DestroySurface(converted); + if (!custom_cursor) { + SDL_Unsupported(); + return NULL; + } + return Android_WrapCursor(custom_cursor, 0); +} + +static SDL_Cursor *Android_CreateSystemCursor(SDL_SystemCursor id) +{ + return Android_WrapCursor(0, id); +} + +static void Android_FreeCursor(SDL_Cursor *cursor) +{ + SDL_CursorData *data = cursor->internal; + if (data->custom_cursor != 0) { + Android_JNI_DestroyCustomCursor(data->custom_cursor); + } + SDL_free(cursor->internal); + SDL_free(cursor); +} + +static SDL_Cursor *Android_CreateEmptyCursor(void) +{ + if (!empty_cursor) { + SDL_Surface *empty_surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888); + if (empty_surface) { + SDL_memset(empty_surface->pixels, 0, (size_t)empty_surface->h * empty_surface->pitch); + empty_cursor = Android_CreateCursor(empty_surface, 0, 0); + SDL_DestroySurface(empty_surface); + } + } + return empty_cursor; +} + +static void Android_DestroyEmptyCursor(void) +{ + if (empty_cursor) { + Android_FreeCursor(empty_cursor); + empty_cursor = NULL; + } +} + +static bool Android_ShowCursor(SDL_Cursor *cursor) +{ + if (!cursor) { + cursor = Android_CreateEmptyCursor(); + } + if (cursor) { + SDL_CursorData *data = cursor->internal; + if (data->custom_cursor) { + if (!Android_JNI_SetCustomCursor(data->custom_cursor)) { + return SDL_Unsupported(); + } + } else { + if (!Android_JNI_SetSystemCursor(data->system_cursor)) { + return SDL_Unsupported(); + } + } + return true; + } else { + // SDL error set inside Android_CreateEmptyCursor() + return false; + } +} + +static bool Android_SetRelativeMouseMode(bool enabled) +{ + if (!Android_JNI_SupportsRelativeMouse()) { + return SDL_Unsupported(); + } + + if (!Android_JNI_SetRelativeMouseEnabled(enabled)) { + return SDL_Unsupported(); + } + + return true; +} + +void Android_InitMouse(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = Android_CreateCursor; + mouse->CreateSystemCursor = Android_CreateSystemCursor; + mouse->ShowCursor = Android_ShowCursor; + mouse->FreeCursor = Android_FreeCursor; + mouse->SetRelativeMouseMode = Android_SetRelativeMouseMode; + + SDL_SetDefaultCursor(Android_CreateDefaultCursor()); + + last_state = 0; +} + +void Android_QuitMouse(void) +{ + Android_DestroyEmptyCursor(); +} + +// Translate Android mouse button state to SDL mouse button +static Uint8 TranslateButton(int state) +{ + if (state & BUTTON_PRIMARY) { + return SDL_BUTTON_LEFT; + } else if (state & BUTTON_SECONDARY) { + return SDL_BUTTON_RIGHT; + } else if (state & BUTTON_TERTIARY) { + return SDL_BUTTON_MIDDLE; + } else if (state & BUTTON_FORWARD) { + return SDL_BUTTON_X1; + } else if (state & BUTTON_BACK) { + return SDL_BUTTON_X2; + } else { + return 0; + } +} + +void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y, bool relative) +{ + int changes; + Uint8 button; + + if (!window) { + return; + } + + switch (action) { + case ACTION_DOWN: + changes = state & ~last_state; + button = TranslateButton(changes); + last_state = state; + SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y); + SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, button, true); + break; + + case ACTION_UP: + changes = last_state & ~state; + button = TranslateButton(changes); + last_state = state; + SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y); + SDL_SendMouseButton(0, window, SDL_DEFAULT_MOUSE_ID, button, false); + break; + + case ACTION_MOVE: + case ACTION_HOVER_MOVE: + SDL_SendMouseMotion(0, window, SDL_DEFAULT_MOUSE_ID, relative, x, y); + break; + + case ACTION_SCROLL: + SDL_SendMouseWheel(0, window, SDL_DEFAULT_MOUSE_ID, x, y, SDL_MOUSEWHEEL_NORMAL); + break; + + default: + break; + } +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.h new file mode 100644 index 0000000..3a5d01a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidmouse.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_androidmouse_h_ +#define SDL_androidmouse_h_ + +#include "SDL_androidvideo.h" + +extern void Android_InitMouse(void); +extern void Android_OnMouse(SDL_Window *window, int button, int action, float x, float y, bool relative); +extern void Android_QuitMouse(void); + +#endif // SDL_androidmouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidpen.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidpen.c new file mode 100644 index 0000000..e287cab --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidpen.c @@ -0,0 +1,98 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include "SDL_androidpen.h" +#include "../../events/SDL_pen_c.h" +#include "../../core/android/SDL_android.h" + +#define ACTION_DOWN 0 +#define ACTION_UP 1 +#define ACTION_CANCEL 3 +#define ACTION_POINTER_DOWN 5 +#define ACTION_POINTER_UP 6 +#define ACTION_HOVER_EXIT 10 + +void Android_OnPen(SDL_Window *window, int pen_id_in, int button, int action, float x, float y, float p) +{ + if (!window) { + return; + } + + // pointer index starts from zero. + pen_id_in++; + + SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) pen_id_in); + if (!pen) { + // TODO: Query JNI for pen device info + SDL_PenInfo peninfo; + SDL_zero(peninfo); + peninfo.capabilities = SDL_PEN_CAPABILITY_PRESSURE | SDL_PEN_CAPABILITY_ERASER; + peninfo.num_buttons = 2; + peninfo.subtype = SDL_PEN_TYPE_PEN; + pen = SDL_AddPenDevice(0, NULL, &peninfo, (void *) (size_t) pen_id_in); + if (!pen) { + SDL_Log("error: can't add a pen device %d", pen_id_in); + return; + } + } + + SDL_SendPenMotion(0, pen, window, x, y); + SDL_SendPenAxis(0, pen, window, SDL_PEN_AXIS_PRESSURE, p); + // TODO: add more axis + + SDL_PenInputFlags current = SDL_GetPenStatus(pen, NULL, 0); + int diff = current ^ button; + if (diff != 0) { + // Android only exposes BUTTON_STYLUS_PRIMARY and BUTTON_STYLUS_SECONDARY + if (diff & SDL_PEN_INPUT_BUTTON_1) + SDL_SendPenButton(0, pen, window, 1, (button & SDL_PEN_INPUT_BUTTON_1) != 0); + + if (diff & SDL_PEN_INPUT_BUTTON_2) + SDL_SendPenButton(0, pen, window, 2, (button & SDL_PEN_INPUT_BUTTON_2) != 0); + } + + // button contains DOWN/ERASER_TIP on DOWN/UP regardless of pressed state, use action to distinguish + // we don't compare tip flags above because MotionEvent.getButtonState doesn't return stylus tip/eraser state. + switch (action) { + case ACTION_CANCEL: + case ACTION_HOVER_EXIT: + SDL_RemovePenDevice(0, pen); + break; + + case ACTION_DOWN: + case ACTION_POINTER_DOWN: + SDL_SendPenTouch(0, pen, window, (button & SDL_PEN_INPUT_ERASER_TIP) != 0, true); + break; + + case ACTION_UP: + case ACTION_POINTER_UP: + SDL_SendPenTouch(0, pen, window, (button & SDL_PEN_INPUT_ERASER_TIP) != 0, false); + break; + + default: + break; + } +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidpen.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidpen.h new file mode 100644 index 0000000..99a5aee --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidpen.h @@ -0,0 +1,25 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_androidvideo.h" + +extern void Android_OnPen(SDL_Window *window, int pen_id_in, int button, int action, float x, float y, float p); diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.c new file mode 100644 index 0000000..661c9a1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.c @@ -0,0 +1,96 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include + +#include "SDL_androidtouch.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" +#include "../../core/android/SDL_android.h" + +#define ACTION_DOWN 0 +#define ACTION_UP 1 +#define ACTION_MOVE 2 +#define ACTION_CANCEL 3 +// #define ACTION_OUTSIDE 4 +#define ACTION_POINTER_DOWN 5 +#define ACTION_POINTER_UP 6 + +void Android_InitTouch(void) +{ + // Add all touch devices + Android_JNI_InitTouch(); +} + +void Android_QuitTouch(void) +{ +} + +void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p) +{ + SDL_TouchID touchDeviceId = 0; + SDL_FingerID fingerId = 0; + + if (!window) { + return; + } + + /* Touch device -1 appears when using Android emulator, eg: + * adb shell input mouse tap 100 100 + * adb shell input touchscreen tap 100 100 + */ + touchDeviceId = (SDL_TouchID)(touch_device_id_in + 2); + + // Finger ID should be greater than 0 + fingerId = (SDL_FingerID)(pointer_finger_id_in + 1); + + if (SDL_AddTouch(touchDeviceId, SDL_TOUCH_DEVICE_DIRECT, "") < 0) { + SDL_Log("error: can't add touch %s, %d", __FILE__, __LINE__); + } + + switch (action) { + case ACTION_DOWN: + case ACTION_POINTER_DOWN: + SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_EVENT_FINGER_DOWN, x, y, p); + break; + + case ACTION_MOVE: + SDL_SendTouchMotion(0, touchDeviceId, fingerId, window, x, y, p); + break; + + case ACTION_UP: + case ACTION_POINTER_UP: + SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_EVENT_FINGER_UP, x, y, p); + break; + + case ACTION_CANCEL: + SDL_SendTouch(0, touchDeviceId, fingerId, window, SDL_EVENT_FINGER_CANCELED, x, y, p); + break; + + default: + break; + } +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.h new file mode 100644 index 0000000..2aef822 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidtouch.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_androidvideo.h" + +extern void Android_InitTouch(void); +extern void Android_QuitTouch(void); +extern void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p); diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.c new file mode 100644 index 0000000..b154ff7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.c @@ -0,0 +1,331 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +// Android SDL video driver implementation + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_windowevents_c.h" + +#include "SDL_androidvideo.h" +#include "SDL_androidgl.h" +#include "SDL_androidclipboard.h" +#include "SDL_androidevents.h" +#include "SDL_androidkeyboard.h" +#include "SDL_androidmouse.h" +#include "SDL_androidtouch.h" +#include "SDL_androidwindow.h" +#include "SDL_androidvulkan.h" +#include "SDL_androidmessagebox.h" + +#define ANDROID_VID_DRIVER_NAME "android" + +// Initialization/Query functions +static bool Android_VideoInit(SDL_VideoDevice *_this); +static void Android_VideoQuit(SDL_VideoDevice *_this); + +#include "../SDL_egl_c.h" +#define Android_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define Android_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define Android_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define Android_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define Android_GLES_DestroyContext SDL_EGL_DestroyContext + +// Android driver bootstrap functions + +// These are filled in with real values in Android_SetScreenResolution on init (before SDL_main()) +int Android_SurfaceWidth = 0; +int Android_SurfaceHeight = 0; +static int Android_DeviceWidth = 0; +static int Android_DeviceHeight = 0; +static Uint32 Android_ScreenFormat = SDL_PIXELFORMAT_RGB565; // Default SurfaceView format, in case this is queried before being filled +float Android_ScreenDensity = 1.0f; +static float Android_ScreenRate = 0.0f; +static SDL_DisplayOrientation Android_ScreenOrientation = SDL_ORIENTATION_UNKNOWN; +int Android_SafeInsetLeft = 0; +int Android_SafeInsetRight = 0; +int Android_SafeInsetTop = 0; +int Android_SafeInsetBottom = 0; +static SDL_SystemTheme Android_SystemTheme; + +static bool Android_SuspendScreenSaver(SDL_VideoDevice *_this) +{ + return Android_JNI_SuspendScreenSaver(_this->suspend_screensaver); +} + +static void Android_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *Android_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!data) { + SDL_free(device); + return NULL; + } + + device->internal = data; + device->system_theme = Android_SystemTheme; + + // Set the function pointers + device->VideoInit = Android_VideoInit; + device->VideoQuit = Android_VideoQuit; + + device->CreateSDLWindow = Android_CreateWindow; + device->SetWindowTitle = Android_SetWindowTitle; + device->SetWindowFullscreen = Android_SetWindowFullscreen; + device->MinimizeWindow = Android_MinimizeWindow; + device->SetWindowResizable = Android_SetWindowResizable; + device->DestroyWindow = Android_DestroyWindow; + + device->free = Android_DeleteDevice; + + // GL pointers +#ifdef SDL_VIDEO_OPENGL_EGL + device->GL_LoadLibrary = Android_GLES_LoadLibrary; + device->GL_GetProcAddress = Android_GLES_GetProcAddress; + device->GL_UnloadLibrary = Android_GLES_UnloadLibrary; + device->GL_CreateContext = Android_GLES_CreateContext; + device->GL_MakeCurrent = Android_GLES_MakeCurrent; + device->GL_SetSwapInterval = Android_GLES_SetSwapInterval; + device->GL_GetSwapInterval = Android_GLES_GetSwapInterval; + device->GL_SwapWindow = Android_GLES_SwapWindow; + device->GL_DestroyContext = Android_GLES_DestroyContext; +#endif + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = Android_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = Android_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = Android_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = Android_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = Android_Vulkan_DestroySurface; +#endif + + // Screensaver + device->SuspendScreenSaver = Android_SuspendScreenSaver; + + // Screen keyboard + device->HasScreenKeyboardSupport = Android_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = Android_ShowScreenKeyboard; + device->HideScreenKeyboard = Android_HideScreenKeyboard; + device->IsScreenKeyboardShown = Android_IsScreenKeyboardShown; + + // Clipboard + device->SetClipboardText = Android_SetClipboardText; + device->GetClipboardText = Android_GetClipboardText; + device->HasClipboardText = Android_HasClipboardText; + + device->device_caps = VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; + + return device; +} + +VideoBootStrap Android_bootstrap = { + ANDROID_VID_DRIVER_NAME, "SDL Android video driver", + Android_CreateDevice, + Android_ShowMessageBox, + false +}; + +bool Android_VideoInit(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + SDL_DisplayID displayID; + SDL_VideoDisplay *display; + SDL_DisplayMode mode; + + videodata->isPaused = false; + videodata->isPausing = false; + + SDL_zero(mode); + mode.format = Android_ScreenFormat; + mode.w = Android_DeviceWidth; + mode.h = Android_DeviceHeight; + mode.refresh_rate = Android_ScreenRate; + + displayID = SDL_AddBasicVideoDisplay(&mode); + if (displayID == 0) { + return false; + } + display = SDL_GetVideoDisplay(displayID); + display->natural_orientation = Android_JNI_GetDisplayNaturalOrientation(); + display->current_orientation = Android_JNI_GetDisplayCurrentOrientation(); + display->content_scale = Android_ScreenDensity; + + Android_InitTouch(); + + Android_InitMouse(); + + // We're done! + return true; +} + +void Android_VideoQuit(SDL_VideoDevice *_this) +{ + Android_QuitMouse(); + Android_QuitTouch(); +} + +void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float density, float rate) +{ + Android_SurfaceWidth = surfaceWidth; + Android_SurfaceHeight = surfaceHeight; + Android_DeviceWidth = deviceWidth; + Android_DeviceHeight = deviceHeight; + Android_ScreenDensity = (density > 0.0f) ? density : 1.0f; + Android_ScreenRate = rate; +} + +static Uint32 format_to_pixelFormat(int format) +{ + Uint32 pf; + if (format == AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM) { // 1 + pf = SDL_PIXELFORMAT_RGBA8888; + } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM) { // 2 + pf = SDL_PIXELFORMAT_RGBX8888; + } else if (format == AHARDWAREBUFFER_FORMAT_R8G8B8_UNORM) { // 3 + pf = SDL_PIXELFORMAT_RGB24; + } else if (format == AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM) { // 4 + pf = SDL_PIXELFORMAT_RGB565; + } else if (format == 5) { + pf = SDL_PIXELFORMAT_BGRA8888; + } else if (format == 6) { + pf = SDL_PIXELFORMAT_RGBA5551; + } else if (format == 7) { + pf = SDL_PIXELFORMAT_RGBA4444; + } else if (format == 0x115) { + // HAL_PIXEL_FORMAT_BGR_565 + pf = SDL_PIXELFORMAT_RGB565; + } else { + pf = SDL_PIXELFORMAT_UNKNOWN; + } + return pf; +} + +void Android_SetFormat(int format_wanted, int format_got) +{ + Uint32 pf_wanted; + Uint32 pf_got; + + pf_wanted = format_to_pixelFormat(format_wanted); + pf_got = format_to_pixelFormat(format_got); + + Android_ScreenFormat = pf_got; + + SDL_Log("pixel format wanted %s (%d), got %s (%d)", + SDL_GetPixelFormatName(pf_wanted), format_wanted, + SDL_GetPixelFormatName(pf_got), format_got); +} + +static void Android_SendOrientationUpdate(void) +{ + /* If we've received a compatible resize event, update the + * orientation immediately, otherwise wait for the display + * resize event. + */ + SDL_VideoDevice *device = SDL_GetVideoDevice(); + if (device && device->num_displays > 0) { + SDL_VideoDisplay *display = device->displays[0]; + bool mode_landscape = (display->desktop_mode.w > display->desktop_mode.h); + bool sensor_landscape = (Android_ScreenOrientation == SDL_ORIENTATION_LANDSCAPE || Android_ScreenOrientation == SDL_ORIENTATION_LANDSCAPE_FLIPPED); + if (sensor_landscape == mode_landscape) { + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, Android_ScreenOrientation, 0); + } + } +} + +void Android_SetOrientation(SDL_DisplayOrientation orientation) +{ + Android_ScreenOrientation = orientation; + Android_SendOrientationUpdate(); +} + +void Android_SendResize(SDL_Window *window) +{ + /* + Update the resolution of the desktop mode, so that the window + can be properly resized. The screen resolution change can for + example happen when the Activity enters or exits immersive mode, + which can happen after VideoInit(). + */ + SDL_VideoDevice *device = SDL_GetVideoDevice(); + if (device && device->num_displays > 0) { + SDL_VideoDisplay *display = device->displays[0]; + SDL_DisplayMode desktop_mode; + + SDL_zero(desktop_mode); + desktop_mode.format = Android_ScreenFormat; + desktop_mode.w = Android_DeviceWidth; + desktop_mode.h = Android_DeviceHeight; + desktop_mode.refresh_rate = Android_ScreenRate; + SDL_SetDesktopDisplayMode(display, &desktop_mode); + Android_SendOrientationUpdate(); + } + + if (window) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, Android_SurfaceWidth, Android_SurfaceHeight); + } +} + +void Android_SetWindowSafeAreaInsets(int left, int right, int top, int bottom) +{ + Android_SafeInsetLeft = left; + Android_SafeInsetRight = right; + Android_SafeInsetTop = top; + Android_SafeInsetBottom = bottom; + + if (Android_Window) { + SDL_SetWindowSafeAreaInsets(Android_Window, left, right, top, bottom); + } +} + +void Android_SetDarkMode(bool enabled) +{ + SDL_VideoDevice *device = SDL_GetVideoDevice(); + + if (enabled) { + Android_SystemTheme = SDL_SYSTEM_THEME_DARK; + } else { + Android_SystemTheme = SDL_SYSTEM_THEME_LIGHT; + } + + if (device) { + SDL_SetSystemTheme(Android_SystemTheme); + } +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.h new file mode 100644 index 0000000..c561637 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidvideo.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_androidvideo_h_ +#define SDL_androidvideo_h_ + +#include "../SDL_sysvideo.h" + +// Called by the JNI layer when the screen changes size or format +extern void Android_SetScreenResolution(int surfaceWidth, int surfaceHeight, int deviceWidth, int deviceHeight, float density, float rate); +extern void Android_SetFormat(int format_wanted, int format_got); +extern void Android_SetOrientation(SDL_DisplayOrientation orientation); +extern void Android_SendResize(SDL_Window *window); +extern void Android_SetWindowSafeAreaInsets(int left, int right, int top, int bottom); +extern void Android_SetDarkMode(bool enabled); + +// Private display data + +struct SDL_VideoData +{ + int isPaused; + int isPausing; +}; + +extern int Android_SurfaceWidth; +extern int Android_SurfaceHeight; +extern float Android_ScreenDensity; +extern int Android_SafeInsetLeft; +extern int Android_SafeInsetRight; +extern int Android_SafeInsetTop; +extern int Android_SafeInsetBottom; + +#endif // SDL_androidvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.c new file mode 100644 index 0000000..4d38388 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.c @@ -0,0 +1,171 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.c. + */ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_ANDROID) + +#include "../SDL_vulkan_internal.h" + +#include "SDL_androidvideo.h" +#include "SDL_androidwindow.h" + +#include "SDL_androidvulkan.h" + + +bool Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 i, extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasAndroidSurfaceExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan already loaded"); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + if (!path) { + path = "libvulkan.so"; + } + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + if (!_this->vulkan_config.loader_handle) { + return false; + } + SDL_strlcpy(_this->vulkan_config.loader_path, path, + SDL_arraysize(_this->vulkan_config.loader_path)); + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + if (!vkGetInstanceProcAddr) { + goto fail; + } + _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + if (!extensions) { + goto fail; + } + for (i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasAndroidSurfaceExtension = true; + } + } + SDL_free(extensions); + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else if (!hasAndroidSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "extension"); + goto fail; + } + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + } +} + +char const* const* Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ + static const char *const extensionsForAndroid[] = { + VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_ANDROID_SURFACE_EXTENSION_NAME + }; + if (count) { + *count = SDL_arraysize(extensionsForAndroid); + } + return extensionsForAndroid; +} + +bool Android_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + SDL_WindowData *windowData = window->internal; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkCreateAndroidSurfaceKHR vkCreateAndroidSurfaceKHR = + (PFN_vkCreateAndroidSurfaceKHR)vkGetInstanceProcAddr( + instance, + "vkCreateAndroidSurfaceKHR"); + VkAndroidSurfaceCreateInfoKHR createInfo; + VkResult result; + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + if (!vkCreateAndroidSurfaceKHR) { + return SDL_SetError(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME + " extension is not enabled in the Vulkan instance."); + } + SDL_zero(createInfo); + createInfo.sType = VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.window = windowData->native_window; + result = vkCreateAndroidSurfaceKHR(instance, &createInfo, allocator, surface); + if (result != VK_SUCCESS) { + return SDL_SetError("vkCreateAndroidSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); + } + return true; +} + +void Android_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.h new file mode 100644 index 0000000..4f7cd51 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidvulkan.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.h. + */ + +#include "SDL_internal.h" + +#ifndef SDL_androidvulkan_h_ +#define SDL_androidvulkan_h_ + +#include "../SDL_vulkan_internal.h" +#include "../SDL_sysvideo.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_ANDROID) + +extern bool Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void Android_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* Android_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool Android_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void Android_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); + +#endif + +#endif // SDL_androidvulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.c b/contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.c new file mode 100644 index 0000000..af840b2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.c @@ -0,0 +1,204 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_ANDROID + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_windowevents_c.h" +#include "../../core/android/SDL_android.h" + +#include "SDL_androidvideo.h" +#include "SDL_androidevents.h" +#include "SDL_androidwindow.h" + + +// Currently only one window +SDL_Window *Android_Window = NULL; + +bool Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *data; + bool result = true; + + if (!Android_WaitActiveAndLockActivity()) { + return false; + } + + if (Android_Window) { + result = SDL_SetError("Android only supports one window"); + goto endfunction; + } + + // Set orientation + Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS)); + + // Adjust the window data to match the screen + window->x = 0; + window->y = 0; + window->w = Android_SurfaceWidth; + window->h = Android_SurfaceHeight; + + // One window, it always has focus + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + result = false; + goto endfunction; + } + + data->native_window = Android_JNI_GetNativeWindow(); + if (!data->native_window) { + SDL_free(data); + result = SDL_SetError("Could not fetch native window"); + goto endfunction; + } + SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_ANDROID_WINDOW_POINTER, data->native_window); + + /* Do not create EGLSurface for Vulkan window since it will then make the window + incompatible with vkCreateAndroidSurfaceKHR */ +#ifdef SDL_VIDEO_OPENGL_EGL + if (window->flags & SDL_WINDOW_OPENGL) { + data->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)data->native_window); + + if (data->egl_surface == EGL_NO_SURFACE) { + ANativeWindow_release(data->native_window); + SDL_free(data); + result = false; + goto endfunction; + } + } + SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_ANDROID_SURFACE_POINTER, data->egl_surface); +#endif + + SDL_SetWindowSafeAreaInsets(window, Android_SafeInsetLeft, Android_SafeInsetRight, Android_SafeInsetTop, Android_SafeInsetBottom); + + window->internal = data; + Android_Window = window; + +endfunction: + + Android_UnlockActivityMutex(); + + return result; +} + +void Android_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ + Android_JNI_SetActivityTitle(window->title); +} + +SDL_FullscreenResult Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) +{ + Android_LockActivityMutex(); + + if (window == Android_Window) { + SDL_WindowData *data; + int old_w, old_h, new_w, new_h; + + // If the window is being destroyed don't change visible state + if (!window->is_destroying) { + Android_JNI_SetWindowStyle(fullscreen); + } + + /* Ensure our size matches reality after we've executed the window style change. + * + * It is possible that we've set width and height to the full-size display, but on + * Samsung DeX or Chromebooks or other windowed Android environemtns, our window may + * still not be the full display size. + */ + if (!SDL_IsDeXMode() && !SDL_IsChromebook()) { + goto endfunction; + } + + data = window->internal; + if (!data || !data->native_window) { + if (data && !data->native_window) { + SDL_SetError("Missing native window"); + } + goto endfunction; + } + + old_w = window->w; + old_h = window->h; + + new_w = ANativeWindow_getWidth(data->native_window); + new_h = ANativeWindow_getHeight(data->native_window); + + if (new_w < 0 || new_h < 0) { + SDL_SetError("ANativeWindow_getWidth/Height() fails"); + } + + if (old_w != new_w || old_h != new_h) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, new_w, new_h); + } + } + +endfunction: + + Android_UnlockActivityMutex(); + + return SDL_FULLSCREEN_SUCCEEDED; +} + +void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + Android_JNI_MinizeWindow(); +} + +void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) +{ + // Set orientation + Android_JNI_SetOrientation(window->w, window->h, window->flags & SDL_WINDOW_RESIZABLE, SDL_GetHint(SDL_HINT_ORIENTATIONS)); +} + +void Android_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + Android_LockActivityMutex(); + + if (window == Android_Window) { + Android_Window = NULL; + + if (window->internal) { + SDL_WindowData *data = window->internal; + +#ifdef SDL_VIDEO_OPENGL_EGL + if (data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_DestroySurface(_this, data->egl_surface); + } +#endif + + if (data->native_window) { + ANativeWindow_release(data->native_window); + } + SDL_free(window->internal); + window->internal = NULL; + } + } + + Android_UnlockActivityMutex(); +} + +#endif // SDL_VIDEO_DRIVER_ANDROID diff --git a/contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.h b/contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.h new file mode 100644 index 0000000..5590b59 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/android/SDL_androidwindow.h @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_androidwindow_h_ +#define SDL_androidwindow_h_ + +#include "../../core/android/SDL_android.h" +#include "../SDL_egl_c.h" + +extern bool Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void Android_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_FullscreenResult Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); +extern void Android_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Android_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); + +extern void Android_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_Window *Android_Window; + +struct SDL_WindowData +{ +#ifdef SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; + EGLContext egl_context; // We use this to preserve the context when losing focus + int has_swap_interval; // Save/Restore the swap interval / vsync + int swap_interval; +#endif + bool backup_done; + ANativeWindow *native_window; + +}; + +#endif // SDL_androidwindow_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.h new file mode 100644 index 0000000..758f45a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoaclipboard_h_ +#define SDL_cocoaclipboard_h_ + +// Forward declaration +@class SDL_CocoaVideoData; + +extern void Cocoa_CheckClipboardUpdate(SDL_CocoaVideoData *data); +extern bool Cocoa_SetClipboardData(SDL_VideoDevice *_this); +extern void *Cocoa_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); +extern bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); + +#endif // SDL_cocoaclipboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.m new file mode 100644 index 0000000..42c2ad6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaclipboard.m @@ -0,0 +1,262 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoavideo.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_clipboardevents_c.h" + +#include + +@interface Cocoa_PasteboardDataProvider : NSObject +{ + SDL_ClipboardDataCallback m_callback; + void *m_userdata; +} +@end + +@implementation Cocoa_PasteboardDataProvider + +- (nullable instancetype)initWith:(SDL_ClipboardDataCallback)callback + userData:(void *)userdata +{ + self = [super init]; + if (!self) { + return self; + } + m_callback = callback; + m_userdata = userdata; + return self; +} + +- (void)pasteboard:(NSPasteboard *)pasteboard + item:(NSPasteboardItem *)item +provideDataForType:(NSPasteboardType)type +{ + @autoreleasepool { + size_t size = 0; + CFStringRef mimeType; + const void *callbackData; + NSData *data; + mimeType = UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)type, kUTTagClassMIMEType); + callbackData = m_callback(m_userdata, [(__bridge NSString *)mimeType UTF8String], &size); + CFRelease(mimeType); + if (callbackData == NULL || size == 0) { + return; + } + data = [NSData dataWithBytes: callbackData length: size]; + [item setData: data forType: type]; + } +} + +@end + +static char **GetMimeTypes(int *pnformats) +{ + char **new_mime_types = NULL; + + *pnformats = 0; + + int nformats = 0; + int formatsSz = 0; + NSArray *items = [[NSPasteboard generalPasteboard] pasteboardItems]; + NSUInteger nitems = [items count]; + if (nitems > 0) { + for (NSPasteboardItem *item in items) { + NSArray *types = [item types]; + for (NSString *type in types) { + if (@available(macOS 11.0, *)) { + UTType *uttype = [UTType typeWithIdentifier:type]; + NSString *mime_type = [uttype preferredMIMEType]; + if (mime_type) { + NSUInteger len = [mime_type lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1; + formatsSz += len; + ++nformats; + } + } + NSUInteger len = [type lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1; + formatsSz += len; + ++nformats; + } + } + + new_mime_types = SDL_AllocateTemporaryMemory((nformats + 1) * sizeof(char *) + formatsSz); + if (new_mime_types) { + int i = 0; + char *strPtr = (char *)(new_mime_types + nformats + 1); + for (NSPasteboardItem *item in items) { + NSArray *types = [item types]; + for (NSString *type in types) { + if (@available(macOS 11.0, *)) { + UTType *uttype = [UTType typeWithIdentifier:type]; + NSString *mime_type = [uttype preferredMIMEType]; + if (mime_type) { + NSUInteger len = [mime_type lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1; + SDL_memcpy(strPtr, [mime_type UTF8String], len); + new_mime_types[i++] = strPtr; + strPtr += len; + } + } + NSUInteger len = [type lengthOfBytesUsingEncoding:NSUTF8StringEncoding] + 1; + SDL_memcpy(strPtr, [type UTF8String], len); + new_mime_types[i++] = strPtr; + strPtr += len; + } + } + + new_mime_types[nformats] = NULL; + *pnformats = nformats; + } + } + return new_mime_types; +} + + +void Cocoa_CheckClipboardUpdate(SDL_CocoaVideoData *data) +{ + @autoreleasepool { + NSPasteboard *pasteboard; + NSInteger count; + + pasteboard = [NSPasteboard generalPasteboard]; + count = [pasteboard changeCount]; + if (count != data.clipboard_count) { + if (count) { + int nformats = 0; + char **new_mime_types = GetMimeTypes(&nformats); + if (new_mime_types) { + SDL_SendClipboardUpdate(false, new_mime_types, nformats); + } + } + data.clipboard_count = count; + } + } +} + +bool Cocoa_SetClipboardData(SDL_VideoDevice *_this) +{ + @autoreleasepool { + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + NSPasteboardItem *newItem = [NSPasteboardItem new]; + NSMutableArray *utiTypes = [NSMutableArray new]; + Cocoa_PasteboardDataProvider *provider = [[Cocoa_PasteboardDataProvider alloc] initWith: _this->clipboard_callback userData: _this->clipboard_userdata]; + BOOL itemResult = FALSE; + BOOL writeResult = FALSE; + + if (_this->clipboard_callback) { + for (int i = 0; i < _this->num_clipboard_mime_types; i++) { + CFStringRef mimeType = CFStringCreateWithCString(NULL, _this->clipboard_mime_types[i], kCFStringEncodingUTF8); + CFStringRef utiType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL); + CFRelease(mimeType); + + [utiTypes addObject: (__bridge NSString *)utiType]; + CFRelease(utiType); + } + itemResult = [newItem setDataProvider: provider forTypes: utiTypes]; + if (itemResult == FALSE) { + return SDL_SetError("Unable to set clipboard item data"); + } + + [pasteboard clearContents]; + writeResult = [pasteboard writeObjects: @[newItem]]; + if (writeResult == FALSE) { + return SDL_SetError("Unable to set clipboard data"); + } + } else { + [pasteboard clearContents]; + } + data.clipboard_count = [pasteboard changeCount]; + } + return true; +} + +static bool IsMimeType(const char *tag) +{ + if (SDL_strchr(tag, '/')) { + // MIME types have slashes + return true; + } else if (SDL_strchr(tag, '.')) { + // UTI identifiers have periods + return false; + } else { + // Not sure, but it's not a UTI identifier + return true; + } +} + +static CFStringRef GetUTIType(const char *tag) +{ + CFStringRef utiType; + if (IsMimeType(tag)) { + CFStringRef mimeType = CFStringCreateWithCString(NULL, tag, kCFStringEncodingUTF8); + utiType = UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, mimeType, NULL); + CFRelease(mimeType); + } else { + utiType = CFStringCreateWithCString(NULL, tag, kCFStringEncodingUTF8); + } + return utiType; +} + +void *Cocoa_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size) +{ + @autoreleasepool { + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + void *data = NULL; + *size = 0; + for (NSPasteboardItem *item in [pasteboard pasteboardItems]) { + NSData *itemData; + CFStringRef utiType = GetUTIType(mime_type); + itemData = [item dataForType: (__bridge NSString *)utiType]; + CFRelease(utiType); + if (itemData != nil) { + NSUInteger length = [itemData length]; + *size = (size_t)length; + data = SDL_malloc(*size + sizeof(Uint32)); + if (data) { + [itemData getBytes: data length: length]; + SDL_memset((Uint8 *)data + length, 0, sizeof(Uint32)); + } + break; + } + } + return data; + } +} + +bool Cocoa_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +{ + bool result = false; + @autoreleasepool { + NSPasteboard *pasteboard = [NSPasteboard generalPasteboard]; + CFStringRef utiType = GetUTIType(mime_type); + if ([pasteboard canReadItemWithDataConformingToTypes: @[(__bridge NSString *)utiType]]) { + result = true; + } + CFRelease(utiType); + } + return result; + +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.h new file mode 100644 index 0000000..4944207 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoaevents_h_ +#define SDL_cocoaevents_h_ + +extern void Cocoa_RegisterApp(void); +extern Uint64 Cocoa_GetEventTimestamp(NSTimeInterval nsTimestamp); +extern void Cocoa_PumpEvents(SDL_VideoDevice *_this); +extern int Cocoa_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); +extern void Cocoa_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_SuspendScreenSaver(SDL_VideoDevice *_this); + +#endif // SDL_cocoaevents_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.m new file mode 100644 index 0000000..58cae99 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaevents.m @@ -0,0 +1,680 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoavideo.h" +#include "../../events/SDL_events_c.h" + +static SDL_Window *FindSDLWindowForNSWindow(NSWindow *win) +{ + SDL_Window *sdlwindow = NULL; + SDL_VideoDevice *device = SDL_GetVideoDevice(); + if (device && device->windows) { + for (sdlwindow = device->windows; sdlwindow; sdlwindow = sdlwindow->next) { + NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)sdlwindow->internal).nswindow; + if (win == nswindow) { + return sdlwindow; + } + } + } + + return sdlwindow; +} + +@interface SDL3Application : NSApplication + +- (void)terminate:(id)sender; +- (void)sendEvent:(NSEvent *)theEvent; + ++ (void)registerUserDefaults; + +@end + +@implementation SDL3Application + +// Override terminate to handle Quit and System Shutdown smoothly. +- (void)terminate:(id)sender +{ + SDL_SendQuit(); +} + +static bool s_bShouldHandleEventsInSDLApplication = false; + +static void Cocoa_DispatchEvent(NSEvent *theEvent) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + switch ([theEvent type]) { + case NSEventTypeLeftMouseDown: + case NSEventTypeOtherMouseDown: + case NSEventTypeRightMouseDown: + case NSEventTypeLeftMouseUp: + case NSEventTypeOtherMouseUp: + case NSEventTypeRightMouseUp: + case NSEventTypeLeftMouseDragged: + case NSEventTypeRightMouseDragged: + case NSEventTypeOtherMouseDragged: // usually middle mouse dragged + case NSEventTypeMouseMoved: + case NSEventTypeScrollWheel: + case NSEventTypeMouseEntered: + case NSEventTypeMouseExited: + Cocoa_HandleMouseEvent(_this, theEvent); + break; + case NSEventTypeKeyDown: + case NSEventTypeKeyUp: + case NSEventTypeFlagsChanged: + Cocoa_HandleKeyEvent(_this, theEvent); + break; + default: + break; + } +} + +// Dispatch events here so that we can handle events caught by +// nextEventMatchingMask in SDL, as well as events caught by other +// processes (such as CEF) that are passed down to NSApp. +- (void)sendEvent:(NSEvent *)theEvent +{ + if (s_bShouldHandleEventsInSDLApplication) { + Cocoa_DispatchEvent(theEvent); + } + + [super sendEvent:theEvent]; +} + ++ (void)registerUserDefaults +{ + BOOL momentumScrollSupported = (BOOL)SDL_GetHintBoolean(SDL_HINT_MAC_SCROLL_MOMENTUM, false); + + NSDictionary *appDefaults = [[NSDictionary alloc] initWithObjectsAndKeys: + [NSNumber numberWithBool:momentumScrollSupported], @"AppleMomentumScrollSupported", + [NSNumber numberWithBool:YES], @"ApplePressAndHoldEnabled", + [NSNumber numberWithBool:YES], @"ApplePersistenceIgnoreState", + nil]; + [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; +} + +@end // SDL3Application + +// setAppleMenu disappeared from the headers in 10.4 +@interface NSApplication (NSAppleMenu) +- (void)setAppleMenu:(NSMenu *)menu; +@end + +@interface SDL3AppDelegate : NSObject +{ + @public + BOOL seenFirstActivate; +} + +- (id)init; +- (void)localeDidChange:(NSNotification *)notification; +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context; +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app; +- (IBAction)menu:(id)sender; +@end + +@implementation SDL3AppDelegate : NSObject +- (id)init +{ + self = [super init]; + if (self) { + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + bool registerActivationHandlers = SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true); + + seenFirstActivate = NO; + + if (registerActivationHandlers) { + [center addObserver:self + selector:@selector(windowWillClose:) + name:NSWindowWillCloseNotification + object:nil]; + + [center addObserver:self + selector:@selector(focusSomeWindow:) + name:NSApplicationDidBecomeActiveNotification + object:nil]; + + [center addObserver:self + selector:@selector(screenParametersChanged:) + name:NSApplicationDidChangeScreenParametersNotification + object:nil]; + } + + [center addObserver:self + selector:@selector(localeDidChange:) + name:NSCurrentLocaleDidChangeNotification + object:nil]; + + [NSApp addObserver:self + forKeyPath:@"effectiveAppearance" + options:NSKeyValueObservingOptionInitial + context:nil]; + } + + return self; +} + +- (void)dealloc +{ + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + [center removeObserver:self name:NSWindowWillCloseNotification object:nil]; + [center removeObserver:self name:NSApplicationDidBecomeActiveNotification object:nil]; + [center removeObserver:self name:NSApplicationDidChangeScreenParametersNotification object:nil]; + [center removeObserver:self name:NSCurrentLocaleDidChangeNotification object:nil]; + [NSApp removeObserver:self forKeyPath:@"effectiveAppearance"]; + + // Remove our URL event handler only if we set it + if ([NSApp delegate] == self) { + [[NSAppleEventManager sharedAppleEventManager] + removeEventHandlerForEventClass:kInternetEventClass + andEventID:kAEGetURL]; + } +} + +- (void)windowWillClose:(NSNotification *)notification +{ + NSWindow *win = (NSWindow *)[notification object]; + + if (![win isKeyWindow]) { + return; + } + + // Don't do anything if this was not an SDL window that was closed + if (FindSDLWindowForNSWindow(win) == NULL) { + return; + } + + /* HACK: Make the next window in the z-order key when the key window is + * closed. The custom event loop and/or windowing code we have seems to + * prevent the normal behavior: https://bugzilla.libsdl.org/show_bug.cgi?id=1825 + */ + + /* +[NSApp orderedWindows] never includes the 'About' window, but we still + * want to try its list first since the behavior in other apps is to only + * make the 'About' window key if no other windows are on-screen. + */ + for (NSWindow *window in [NSApp orderedWindows]) { + if (window != win && [window canBecomeKeyWindow]) { + if (![window isOnActiveSpace]) { + continue; + } + [window makeKeyAndOrderFront:self]; + return; + } + } + + /* If a window wasn't found above, iterate through all visible windows in + * the active Space in z-order (including the 'About' window, if it's shown) + * and make the first one key. + */ + for (NSNumber *num in [NSWindow windowNumbersWithOptions:0]) { + NSWindow *window = [NSApp windowWithWindowNumber:[num integerValue]]; + if (window && window != win && [window canBecomeKeyWindow]) { + [window makeKeyAndOrderFront:self]; + return; + } + } +} + +- (void)focusSomeWindow:(NSNotification *)aNotification +{ + SDL_VideoDevice *device; + /* HACK: Ignore the first call. The application gets a + * applicationDidBecomeActive: a little bit after the first window is + * created, and if we don't ignore it, a window that has been created with + * SDL_WINDOW_MINIMIZED will ~immediately be restored. + */ + if (!seenFirstActivate) { + seenFirstActivate = YES; + return; + } + + /* Don't do anything if the application already has a key window + * that is not an SDL window. + */ + if ([NSApp keyWindow] && FindSDLWindowForNSWindow([NSApp keyWindow]) == NULL) { + return; + } + + device = SDL_GetVideoDevice(); + if (device && device->windows) { + SDL_Window *window = device->windows; + int i; + for (i = 0; i < device->num_displays; ++i) { + SDL_Window *fullscreen_window = device->displays[i]->fullscreen_window; + if (fullscreen_window) { + if (fullscreen_window->flags & SDL_WINDOW_MINIMIZED) { + SDL_RestoreWindow(fullscreen_window); + } + return; + } + } + + if (window->flags & SDL_WINDOW_MINIMIZED) { + SDL_RestoreWindow(window); + } else { + SDL_RaiseWindow(window); + } + } +} + +- (void)screenParametersChanged:(NSNotification *)aNotification +{ + SDL_VideoDevice *device = SDL_GetVideoDevice(); + if (device) { + Cocoa_UpdateDisplays(device); + } +} + +- (void)localeDidChange:(NSNotification *)notification +{ + SDL_SendLocaleChangedEvent(); +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context +{ + SDL_SetSystemTheme(Cocoa_GetSystemTheme()); +} + +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + return (BOOL)SDL_SendDropFile(NULL, NULL, [filename UTF8String]) && SDL_SendDropComplete(NULL); +} + +- (void)applicationDidFinishLaunching:(NSNotification *)notification +{ + if (!SDL_GetHintBoolean("SDL_MAC_REGISTER_ACTIVATION_HANDLERS", true)) + return; + + /* The menu bar of SDL apps which don't have the typical .app bundle + * structure fails to work the first time a window is created (until it's + * de-focused and re-focused), if this call is in Cocoa_RegisterApp instead + * of here. https://bugzilla.libsdl.org/show_bug.cgi?id=3051 + */ + if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, false)) { + // Get more aggressive for Catalina: activate the Dock first so we definitely reset all activation state. + for (NSRunningApplication *i in [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.apple.dock"]) { + [i activateWithOptions:NSApplicationActivateIgnoringOtherApps]; + break; + } + SDL_Delay(300); // !!! FIXME: this isn't right. + [NSApp activateIgnoringOtherApps:YES]; + } + + /* If we call this before NSApp activation, macOS might print a complaint + * about ApplePersistenceIgnoreState. */ + [SDL3Application registerUserDefaults]; +} + +- (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent +{ + NSString *path = [[event paramDescriptorForKeyword:keyDirectObject] stringValue]; + SDL_SendDropFile(NULL, NULL, [path UTF8String]); + SDL_SendDropComplete(NULL); +} + +- (BOOL)applicationSupportsSecureRestorableState:(NSApplication *)app +{ + // This just tells Cocoa that we didn't do any custom save state magic for the app, + // so the system is safe to use NSSecureCoding internally, instead of using unencrypted + // save states for backwards compatibility. If we don't return YES here, we'll get a + // warning on the console at startup: + // + // ``` + // WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES. + // ``` + // + // More-detailed explanation: + // https://stackoverflow.com/questions/77283578/sonoma-and-nsapplicationdelegate-applicationsupportssecurerestorablestate/77320845#77320845 + return YES; +} + +- (IBAction)menu:(id)sender +{ + SDL_TrayEntry *entry = [[sender representedObject] pointerValue]; + + SDL_ClickTrayEntry(entry); +} + +@end + +static SDL3AppDelegate *appDelegate = nil; + +static NSString *GetApplicationName(void) +{ + NSString *appName = nil; + + const char *metaname = SDL_GetStringProperty(SDL_GetGlobalProperties(), SDL_PROP_APP_METADATA_NAME_STRING, NULL); + if (metaname && *metaname) { + appName = [NSString stringWithUTF8String:metaname]; + } + + // Determine the application name + if (!appName) { + appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]; + if (!appName) { + appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]; + } + } + + if (![appName length]) { + appName = [[NSProcessInfo processInfo] processName]; + } + + return appName; +} + +static bool LoadMainMenuNibIfAvailable(void) +{ + NSDictionary *infoDict; + NSString *mainNibFileName; + bool success = false; + + infoDict = [[NSBundle mainBundle] infoDictionary]; + if (infoDict) { + mainNibFileName = [infoDict valueForKey:@"NSMainNibFile"]; + + if (mainNibFileName) { + success = [[NSBundle mainBundle] loadNibNamed:mainNibFileName owner:[NSApplication sharedApplication] topLevelObjects:nil]; + } + } + + return success; +} + +static void CreateApplicationMenus(void) +{ + NSString *appName; + NSString *title; + NSMenu *appleMenu; + NSMenu *serviceMenu; + NSMenu *windowMenu; + NSMenuItem *menuItem; + NSMenu *mainMenu; + + if (NSApp == nil) { + return; + } + + mainMenu = [[NSMenu alloc] init]; + + // Create the main menu bar + [NSApp setMainMenu:mainMenu]; + + // Create the application menu + appName = GetApplicationName(); + appleMenu = [[NSMenu alloc] initWithTitle:@""]; + + // Add menu items + title = [@"About " stringByAppendingString:appName]; + + // !!! FIXME: Menu items can't take parameters, just a basic selector, so this should instead call a selector + // !!! FIXME: that itself calls -[NSApplication orderFrontStandardAboutPanelWithOptions:optionsDictionary], + // !!! FIXME: filling in that NSDictionary with SDL_GetAppMetadataProperty() + [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""]; + + [appleMenu addItem:[NSMenuItem separatorItem]]; + + [appleMenu addItemWithTitle:@"Preferences
" action:nil keyEquivalent:@","]; + + [appleMenu addItem:[NSMenuItem separatorItem]]; + + serviceMenu = [[NSMenu alloc] initWithTitle:@""]; + menuItem = [appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""]; + [menuItem setSubmenu:serviceMenu]; + + [NSApp setServicesMenu:serviceMenu]; + + [appleMenu addItem:[NSMenuItem separatorItem]]; + + title = [@"Hide " stringByAppendingString:appName]; + [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"]; + + menuItem = [appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"]; + [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption | NSEventModifierFlagCommand)]; + + [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""]; + + [appleMenu addItem:[NSMenuItem separatorItem]]; + + title = [@"Quit " stringByAppendingString:appName]; + [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"]; + + // Put menu into the menubar + menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""]; + [menuItem setSubmenu:appleMenu]; + [[NSApp mainMenu] addItem:menuItem]; + + // Tell the application object that this is now the application menu + [NSApp setAppleMenu:appleMenu]; + + // Create the window menu + windowMenu = [[NSMenu alloc] initWithTitle:@"Window"]; + + // Add menu items + [windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"]; + + [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"]; + + [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""]; + + // Add the fullscreen toggle menu option. + /* Cocoa should update the title to Enter or Exit Full Screen automatically. + * But if not, then just fallback to Toggle Full Screen. + */ + menuItem = [[NSMenuItem alloc] initWithTitle:@"Toggle Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"]; + [menuItem setKeyEquivalentModifierMask:NSEventModifierFlagControl | NSEventModifierFlagCommand]; + [windowMenu addItem:menuItem]; + + // Put menu into the menubar + menuItem = [[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""]; + [menuItem setSubmenu:windowMenu]; + [[NSApp mainMenu] addItem:menuItem]; + + // Tell the application object that this is now the window menu + [NSApp setWindowsMenu:windowMenu]; +} + +void Cocoa_RegisterApp(void) +{ + @autoreleasepool { + // This can get called more than once! Be careful what you initialize! + + if (NSApp == nil) { + [SDL3Application sharedApplication]; + SDL_assert(NSApp != nil); + + s_bShouldHandleEventsInSDLApplication = true; + + if (!SDL_GetHintBoolean(SDL_HINT_MAC_BACKGROUND_APP, false)) { + [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]; + } + + /* If there aren't already menus in place, look to see if there's + * a nib we should use. If not, then manually create the basic + * menus we meed. + */ + if ([NSApp mainMenu] == nil) { + bool nibLoaded; + + nibLoaded = LoadMainMenuNibIfAvailable(); + if (!nibLoaded) { + CreateApplicationMenus(); + } + } + [NSApp finishLaunching]; + if ([NSApp delegate]) { + /* The SDL app delegate calls this in didFinishLaunching if it's + * attached to the NSApp, otherwise we need to call it manually. + */ + [SDL3Application registerUserDefaults]; + } + } + if (NSApp && !appDelegate) { + appDelegate = [[SDL3AppDelegate alloc] init]; + + /* If someone else has an app delegate, it means we can't turn a + * termination into SDL_Quit, and we can't handle application:openFile: + */ + if (![NSApp delegate]) { + /* Only register the URL event handler if we are being set as the + * app delegate to avoid replacing any existing event handler. + */ + [[NSAppleEventManager sharedAppleEventManager] + setEventHandler:appDelegate + andSelector:@selector(handleURLEvent:withReplyEvent:) + forEventClass:kInternetEventClass + andEventID:kAEGetURL]; + + [(NSApplication *)NSApp setDelegate:appDelegate]; + } else { + appDelegate->seenFirstActivate = YES; + } + } + } +} + +Uint64 Cocoa_GetEventTimestamp(NSTimeInterval nsTimestamp) +{ + static Uint64 timestamp_offset; + Uint64 timestamp = (Uint64)(nsTimestamp * SDL_NS_PER_SECOND); + Uint64 now = SDL_GetTicksNS(); + + if (!timestamp_offset) { + timestamp_offset = (now - timestamp); + } + timestamp += timestamp_offset; + + if (timestamp > now) { + timestamp_offset -= (timestamp - now); + timestamp = now; + } + return timestamp; +} + +int Cocoa_PumpEventsUntilDate(SDL_VideoDevice *_this, NSDate *expiration, bool accumulate) +{ + // Run any existing modal sessions. + for (SDL_Window *w = _this->windows; w; w = w->next) { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)w->internal; + if (data.modal_session) { + [NSApp runModalSession:data.modal_session]; + } + } + + for (;;) { + NSEvent *event = [NSApp nextEventMatchingMask:NSEventMaskAny untilDate:expiration inMode:NSDefaultRunLoopMode dequeue:YES]; + if (event == nil) { + return 0; + } + + if (!s_bShouldHandleEventsInSDLApplication) { + Cocoa_DispatchEvent(event); + } + + // Pass events down to SDL3Application to be handled in sendEvent: + [NSApp sendEvent:event]; + if (!accumulate) { + break; + } + } + return 1; +} + +int Cocoa_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) +{ + @autoreleasepool { + if (timeoutNS > 0) { + NSDate *limitDate = [NSDate dateWithTimeIntervalSinceNow:(double)timeoutNS / SDL_NS_PER_SECOND]; + return Cocoa_PumpEventsUntilDate(_this, limitDate, false); + } else if (timeoutNS == 0) { + return Cocoa_PumpEventsUntilDate(_this, [NSDate distantPast], false); + } else { + while (Cocoa_PumpEventsUntilDate(_this, [NSDate distantFuture], false) == 0) { + } + } + return 1; + } +} + +void Cocoa_PumpEvents(SDL_VideoDevice *_this) +{ + @autoreleasepool { + Cocoa_PumpEventsUntilDate(_this, [NSDate distantPast], true); + } +} + +void Cocoa_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + NSEvent *event = [NSEvent otherEventWithType:NSEventTypeApplicationDefined + location:NSMakePoint(0, 0) + modifierFlags:0 + timestamp:0.0 + windowNumber:((__bridge SDL_CocoaWindowData *)window->internal).window_number + context:nil + subtype:0 + data1:0 + data2:0]; + + [NSApp postEvent:event atStart:YES]; + } +} + +bool Cocoa_SuspendScreenSaver(SDL_VideoDevice *_this) +{ + @autoreleasepool { + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + + if (data.screensaver_assertion) { + IOPMAssertionRelease(data.screensaver_assertion); + data.screensaver_assertion = kIOPMNullAssertionID; + } + + if (_this->suspend_screensaver) { + /* FIXME: this should ideally describe the real reason why the game + * called SDL_DisableScreenSaver. Note that the name is only meant to be + * seen by macOS power users. there's an additional optional human-readable + * (localized) reason parameter which we don't set. + */ + IOPMAssertionID assertion = kIOPMNullAssertionID; + NSString *name = [GetApplicationName() stringByAppendingString:@" using SDL_DisableScreenSaver"]; + IOPMAssertionCreateWithDescription(kIOPMAssertPreventUserIdleDisplaySleep, + (__bridge CFStringRef)name, + NULL, NULL, NULL, 0, NULL, + &assertion); + data.screensaver_assertion = assertion; + } + } + return true; +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.h new file mode 100644 index 0000000..145f6cf --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoakeyboard_h_ +#define SDL_cocoakeyboard_h_ + +extern void Cocoa_InitKeyboard(SDL_VideoDevice *_this); +extern void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event); +extern void Cocoa_QuitKeyboard(SDL_VideoDevice *_this); + +extern bool Cocoa_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern bool Cocoa_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); + +extern bool Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); + +#endif // SDL_cocoakeyboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.m new file mode 100644 index 0000000..e458be9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoakeyboard.m @@ -0,0 +1,604 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoavideo.h" + +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/scancodes_darwin.h" + +#include + +#if 0 +#define DEBUG_IME NSLog +#else +#define DEBUG_IME(...) +#endif + +@interface SDL3TranslatorResponder : NSView +{ + NSString *_markedText; + NSRange _markedRange; + NSRange _selectedRange; + SDL_Rect _inputRect; + int _pendingRawCode; + SDL_Scancode _pendingScancode; + Uint64 _pendingTimestamp; +} +- (void)doCommandBySelector:(SEL)myselector; +- (void)setInputRect:(const SDL_Rect *)rect; +- (void)setPendingKey:(int)rawcode scancode:(SDL_Scancode)scancode timestamp:(Uint64)timestamp; +- (void)sendPendingKey; +- (void)clearPendingKey; +@end + +@implementation SDL3TranslatorResponder + +- (void)setInputRect:(const SDL_Rect *)rect +{ + SDL_copyp(&_inputRect, rect); +} + +- (void)insertText:(id)aString replacementRange:(NSRange)replacementRange +{ + const char *str; + + DEBUG_IME(@"insertText: %@ replacementRange: (%d, %d)", aString, + (int)replacementRange.location, (int)replacementRange.length); + + /* Could be NSString or NSAttributedString, so we have + * to test and convert it before return as SDL event */ + if ([aString isKindOfClass:[NSAttributedString class]]) { + str = [[aString string] UTF8String]; + } else { + str = [aString UTF8String]; + } + + // We're likely sending the composed text, so we reset the IME status. + if ([self hasMarkedText]) { + [self unmarkText]; + } + + // Deliver the raw key event that generated this text + [self sendPendingKey]; + + if ((int)replacementRange.location != -1) { + // We're replacing the last character + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, true); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, false); + } + + SDL_SendKeyboardText(str); +} + +- (void)doCommandBySelector:(SEL)myselector +{ + /* No need to do anything since we are not using Cocoa + selectors to handle special keys, instead we use SDL + key events to do the same job. + */ +} + +- (BOOL)hasMarkedText +{ + return _markedText != nil; +} + +- (NSRange)markedRange +{ + return _markedRange; +} + +- (NSRange)selectedRange +{ + return _selectedRange; +} + +- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange +{ + if ([aString isKindOfClass:[NSAttributedString class]]) { + aString = [aString string]; + } + + if ([aString length] == 0) { + [self unmarkText]; + return; + } + + if (_markedText != aString) { + _markedText = aString; + } + + _selectedRange = selectedRange; + _markedRange = NSMakeRange(0, [aString length]); + + // This key event was consumed by the IME + [self clearPendingKey]; + + NSUInteger utf32SelectedRangeLocation = [[aString substringToIndex:selectedRange.location] lengthOfBytesUsingEncoding:NSUTF32StringEncoding] / 4; + NSUInteger utf32SelectionRangeEnd = [[aString substringToIndex:(selectedRange.location + selectedRange.length)] lengthOfBytesUsingEncoding:NSUTF32StringEncoding] / 4; + NSUInteger utf32SelectionRangeLength = utf32SelectionRangeEnd - utf32SelectedRangeLocation; + + SDL_SendEditingText([aString UTF8String], + (int)utf32SelectedRangeLocation, (int)utf32SelectionRangeLength); + + DEBUG_IME(@"setMarkedText: %@, (%d, %d) replacement range (%d, %d)", _markedText, + (int)selectedRange.location, (int)selectedRange.length, + (int)replacementRange.location, (int)replacementRange.length); +} + +- (void)unmarkText +{ + _markedText = nil; + + // This key event was consumed by the IME + [self clearPendingKey]; + + SDL_SendEditingText("", 0, 0); +} + +- (NSRect)firstRectForCharacterRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange +{ + NSWindow *window = [self window]; + NSRect contentRect = [window contentRectForFrameRect:[window frame]]; + float windowHeight = contentRect.size.height; + NSRect rect = NSMakeRect(_inputRect.x, windowHeight - _inputRect.y - _inputRect.h, + _inputRect.w, _inputRect.h); + + if (actualRange) { + *actualRange = aRange; + } + + DEBUG_IME(@"firstRectForCharacterRange: (%d, %d): windowHeight = %g, rect = %@", + (int)aRange.location, (int)aRange.length, windowHeight, + NSStringFromRect(rect)); + + rect = [window convertRectToScreen:rect]; + + return rect; +} + +- (NSAttributedString *)attributedSubstringForProposedRange:(NSRange)aRange actualRange:(NSRangePointer)actualRange +{ + DEBUG_IME(@"attributedSubstringFromRange: (%d, %d)", (int)aRange.location, (int)aRange.length); + return nil; +} + +- (NSInteger)conversationIdentifier +{ + return (NSInteger)self; +} + +/* This method returns the index for character that is + * nearest to thePoint. thPoint is in screen coordinate system. + */ +- (NSUInteger)characterIndexForPoint:(NSPoint)thePoint +{ + DEBUG_IME(@"characterIndexForPoint: (%g, %g)", thePoint.x, thePoint.y); + return 0; +} + +/* This method is the key to attribute extension. + * We could add new attributes through this method. + * NSInputServer examines the return value of this + * method & constructs appropriate attributed string. + */ +- (NSArray *)validAttributesForMarkedText +{ + return [NSArray array]; +} + +- (void)setPendingKey:(int)rawcode scancode:(SDL_Scancode)scancode timestamp:(Uint64)timestamp +{ + _pendingRawCode = rawcode; + _pendingScancode = scancode; + _pendingTimestamp = timestamp; +} + +- (void)sendPendingKey +{ + if (_pendingRawCode < 0) { + return; + } + + SDL_SendKeyboardKey(_pendingTimestamp, SDL_DEFAULT_KEYBOARD_ID, _pendingRawCode, _pendingScancode, true); + [self clearPendingKey]; +} + +- (void)clearPendingKey +{ + _pendingRawCode = -1; +} + +@end + +static bool IsModifierKeyPressed(unsigned int flags, + unsigned int target_mask, + unsigned int other_mask, + unsigned int either_mask) +{ + bool target_pressed = (flags & target_mask) != 0; + bool other_pressed = (flags & other_mask) != 0; + bool either_pressed = (flags & either_mask) != 0; + + if (either_pressed != (target_pressed || other_pressed)) + return either_pressed; + + return target_pressed; +} + +static void HandleModifiers(SDL_VideoDevice *_this, SDL_Scancode code, unsigned int modifierFlags) +{ + bool pressed = false; + + if (code == SDL_SCANCODE_LSHIFT) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICELSHIFTKEYMASK, + NX_DEVICERSHIFTKEYMASK, NX_SHIFTMASK); + } else if (code == SDL_SCANCODE_LCTRL) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICELCTLKEYMASK, + NX_DEVICERCTLKEYMASK, NX_CONTROLMASK); + } else if (code == SDL_SCANCODE_LALT) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICELALTKEYMASK, + NX_DEVICERALTKEYMASK, NX_ALTERNATEMASK); + } else if (code == SDL_SCANCODE_LGUI) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICELCMDKEYMASK, + NX_DEVICERCMDKEYMASK, NX_COMMANDMASK); + } else if (code == SDL_SCANCODE_RSHIFT) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICERSHIFTKEYMASK, + NX_DEVICELSHIFTKEYMASK, NX_SHIFTMASK); + } else if (code == SDL_SCANCODE_RCTRL) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICERCTLKEYMASK, + NX_DEVICELCTLKEYMASK, NX_CONTROLMASK); + } else if (code == SDL_SCANCODE_RALT) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICERALTKEYMASK, + NX_DEVICELALTKEYMASK, NX_ALTERNATEMASK); + } else if (code == SDL_SCANCODE_RGUI) { + pressed = IsModifierKeyPressed(modifierFlags, NX_DEVICERCMDKEYMASK, + NX_DEVICELCMDKEYMASK, NX_COMMANDMASK); + } else { + return; + } + + if (pressed) { + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, code, true); + } else { + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, code, false); + } +} + +static void UpdateKeymap(SDL_CocoaVideoData *data, bool send_event) +{ + TISInputSourceRef key_layout; + UCKeyboardLayout *keyLayoutPtr = NULL; + CFDataRef uchrDataRef; + + // See if the keymap needs to be updated + key_layout = TISCopyCurrentKeyboardLayoutInputSource(); + if (key_layout == data.key_layout) { + return; + } + data.key_layout = key_layout; + + // Try Unicode data first + uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData); + if (uchrDataRef) { + keyLayoutPtr = (UCKeyboardLayout *)CFDataGetBytePtr(uchrDataRef); + } + + if (!keyLayoutPtr) { + CFRelease(key_layout); + return; + } + + static struct { + int flags; + SDL_Keymod modstate; + } mods[] = { + { 0, SDL_KMOD_NONE }, + { shiftKey, SDL_KMOD_SHIFT }, + { alphaLock, SDL_KMOD_CAPS }, + { (shiftKey | alphaLock), (SDL_KMOD_SHIFT | SDL_KMOD_CAPS) }, + { optionKey, SDL_KMOD_ALT }, + { (optionKey | shiftKey), (SDL_KMOD_ALT | SDL_KMOD_SHIFT) }, + { (optionKey | alphaLock), (SDL_KMOD_ALT | SDL_KMOD_CAPS) }, + { (optionKey | shiftKey | alphaLock), (SDL_KMOD_ALT | SDL_KMOD_SHIFT | SDL_KMOD_CAPS) } + }; + + UInt32 keyboard_type = LMGetKbdType(); + + SDL_Keymap *keymap = SDL_CreateKeymap(); + for (int m = 0; m < SDL_arraysize(mods); ++m) { + for (int i = 0; i < SDL_arraysize(darwin_scancode_table); i++) { + OSStatus err; + UniChar s[8]; + UniCharCount len; + UInt32 dead_key_state; + + // Make sure this scancode is a valid character scancode + SDL_Scancode scancode = darwin_scancode_table[i]; + if (scancode == SDL_SCANCODE_UNKNOWN || + scancode == SDL_SCANCODE_DELETE || + (SDL_GetKeymapKeycode(NULL, scancode, SDL_KMOD_NONE) & SDLK_SCANCODE_MASK)) { + continue; + } + + /* + * Swap the scancode for these two wrongly translated keys + * UCKeyTranslate() function does not do its job properly for ISO layout keyboards, where the key '@', + * which is located in the top left corner of the keyboard right under the Escape key, and the additional + * key '<', which is on the right of the Shift key, are inverted + */ + if ((scancode == SDL_SCANCODE_NONUSBACKSLASH || scancode == SDL_SCANCODE_GRAVE) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { + // see comments in scancodes_darwin.h + scancode = (SDL_Scancode)((SDL_SCANCODE_NONUSBACKSLASH + SDL_SCANCODE_GRAVE) - scancode); + } + + dead_key_state = 0; + err = UCKeyTranslate(keyLayoutPtr, i, kUCKeyActionDown, + ((mods[m].flags >> 8) & 0xFF), keyboard_type, + kUCKeyTranslateNoDeadKeysMask, + &dead_key_state, 8, &len, s); + if (err != noErr) { + continue; + } + + if (len > 0 && s[0] != 0x10) { + SDL_SetKeymapEntry(keymap, scancode, mods[m].modstate, s[0]); + } else { + // The default keymap doesn't have any SDL_KMOD_ALT entries, so we don't need to override them + if (!(mods[m].modstate & SDL_KMOD_ALT)) { + SDL_SetKeymapEntry(keymap, scancode, mods[m].modstate, SDLK_UNKNOWN); + } + } + } + } + SDL_SetKeymap(keymap, send_event); +} + +static void SDLCALL SDL_MacOptionAsAltChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_VideoDevice *_this = (SDL_VideoDevice *)userdata; + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + + if (hint && *hint) { + if (SDL_strcmp(hint, "none") == 0) { + data.option_as_alt = OptionAsAltNone; + } else if (SDL_strcmp(hint, "only_left") == 0) { + data.option_as_alt = OptionAsAltOnlyLeft; + } else if (SDL_strcmp(hint, "only_right") == 0) { + data.option_as_alt = OptionAsAltOnlyRight; + } else if (SDL_strcmp(hint, "both") == 0) { + data.option_as_alt = OptionAsAltBoth; + } + } else { + data.option_as_alt = OptionAsAltNone; + } +} + +void Cocoa_InitKeyboard(SDL_VideoDevice *_this) +{ + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + + UpdateKeymap(data, false); + + // Set our own names for the platform-dependent but layout-independent keys + // This key is NumLock on the MacBook keyboard. :) + // SDL_SetScancodeName(SDL_SCANCODE_NUMLOCKCLEAR, "Clear"); + SDL_SetScancodeName(SDL_SCANCODE_LALT, "Left Option"); + SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Command"); + SDL_SetScancodeName(SDL_SCANCODE_RALT, "Right Option"); + SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Command"); + + data.modifierFlags = (unsigned int)[NSEvent modifierFlags]; + SDL_ToggleModState(SDL_KMOD_CAPS, (data.modifierFlags & NSEventModifierFlagCapsLock) ? true : false); + + SDL_AddHintCallback(SDL_HINT_MAC_OPTION_AS_ALT, SDL_MacOptionAsAltChanged, _this); +} + +bool Cocoa_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + @autoreleasepool { + NSView *parentView; + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; + + parentView = [nswindow contentView]; + + /* We only keep one field editor per process, since only the front most + * window can receive text input events, so it make no sense to keep more + * than one copy. When we switched to another window and requesting for + * text input, simply remove the field editor from its superview then add + * it to the front most window's content view */ + if (!data.fieldEdit) { + data.fieldEdit = [[SDL3TranslatorResponder alloc] initWithFrame:NSMakeRect(0.0, 0.0, 0.0, 0.0)]; + } + + if (![[data.fieldEdit superview] isEqual:parentView]) { + // DEBUG_IME(@"add fieldEdit to window contentView"); + [data.fieldEdit removeFromSuperview]; + [parentView addSubview:data.fieldEdit]; + [nswindow makeFirstResponder:data.fieldEdit]; + } + } + return Cocoa_UpdateTextInputArea(_this, window); +} + +bool Cocoa_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + + if (data && data.fieldEdit) { + [data.fieldEdit removeFromSuperview]; + data.fieldEdit = nil; + } + } + return true; +} + +bool Cocoa_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + if (data.fieldEdit) { + [data.fieldEdit setInputRect:&window->text_input_rect]; + } + return true; +} + +static NSEvent *ReplaceEvent(NSEvent *event, OptionAsAlt option_as_alt) +{ + if (option_as_alt == OptionAsAltNone) { + return event; + } + + const unsigned int modflags = (unsigned int)[event modifierFlags]; + + bool ignore_alt_characters = false; + + bool lalt_pressed = IsModifierKeyPressed(modflags, NX_DEVICELALTKEYMASK, + NX_DEVICERALTKEYMASK, NX_ALTERNATEMASK); + bool ralt_pressed = IsModifierKeyPressed(modflags, NX_DEVICERALTKEYMASK, + NX_DEVICELALTKEYMASK, NX_ALTERNATEMASK); + + if (option_as_alt == OptionAsAltOnlyLeft && lalt_pressed) { + ignore_alt_characters = true; + } else if (option_as_alt == OptionAsAltOnlyRight && ralt_pressed) { + ignore_alt_characters = true; + } else if (option_as_alt == OptionAsAltBoth && (lalt_pressed || ralt_pressed)) { + ignore_alt_characters = true; + } + + bool cmd_pressed = modflags & NX_COMMANDMASK; + bool ctrl_pressed = modflags & NX_CONTROLMASK; + + ignore_alt_characters = ignore_alt_characters && !cmd_pressed && !ctrl_pressed; + + if (ignore_alt_characters) { + NSString *charactersIgnoringModifiers = [event charactersIgnoringModifiers]; + return [NSEvent keyEventWithType:[event type] + location:[event locationInWindow] + modifierFlags:modflags + timestamp:[event timestamp] + windowNumber:[event windowNumber] + context:nil + characters:charactersIgnoringModifiers + charactersIgnoringModifiers:charactersIgnoringModifiers + isARepeat:[event isARepeat] + keyCode:[event keyCode]]; + } + + return event; +} + +void Cocoa_HandleKeyEvent(SDL_VideoDevice *_this, NSEvent *event) +{ + unsigned short scancode; + SDL_Scancode code; + SDL_CocoaVideoData *data = _this ? ((__bridge SDL_CocoaVideoData *)_this->internal) : nil; + if (!data) { + return; // can happen when returning from fullscreen Space on shutdown + } + + if ([event type] == NSEventTypeKeyDown || [event type] == NSEventTypeKeyUp) { + event = ReplaceEvent(event, data.option_as_alt); + } + + scancode = [event keyCode]; + + if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { + // see comments in scancodes_darwin.h + scancode = 60 - scancode; + } + + if (scancode < SDL_arraysize(darwin_scancode_table)) { + code = darwin_scancode_table[scancode]; + } else { + // Hmm, does this ever happen? If so, need to extend the keymap... + code = SDL_SCANCODE_UNKNOWN; + } + + switch ([event type]) { + case NSEventTypeKeyDown: + if (![event isARepeat]) { + // See if we need to rebuild the keyboard layout + UpdateKeymap(data, true); + } + +#ifdef DEBUG_SCANCODES + if (code == SDL_SCANCODE_UNKNOWN) { + SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, report this to the SDL forums/mailing list or to Christian Walther . Mac virtual key code is %d.", scancode); + } +#endif + if (SDL_TextInputActive(SDL_GetKeyboardFocus())) { + [data.fieldEdit setPendingKey:scancode scancode:code timestamp:Cocoa_GetEventTimestamp([event timestamp])]; + [data.fieldEdit interpretKeyEvents:[NSArray arrayWithObject:event]]; + [data.fieldEdit sendPendingKey]; + } else if (SDL_GetKeyboardFocus()) { + SDL_SendKeyboardKey(Cocoa_GetEventTimestamp([event timestamp]), SDL_DEFAULT_KEYBOARD_ID, scancode, code, true); + } + break; + case NSEventTypeKeyUp: + SDL_SendKeyboardKey(Cocoa_GetEventTimestamp([event timestamp]), SDL_DEFAULT_KEYBOARD_ID, scancode, code, false); + break; + case NSEventTypeFlagsChanged: { + // see if the new modifierFlags mean any existing keys should be pressed/released... + const unsigned int modflags = (unsigned int)[event modifierFlags]; + HandleModifiers(_this, SDL_SCANCODE_LSHIFT, modflags); + HandleModifiers(_this, SDL_SCANCODE_LCTRL, modflags); + HandleModifiers(_this, SDL_SCANCODE_LALT, modflags); + HandleModifiers(_this, SDL_SCANCODE_LGUI, modflags); + HandleModifiers(_this, SDL_SCANCODE_RSHIFT, modflags); + HandleModifiers(_this, SDL_SCANCODE_RCTRL, modflags); + HandleModifiers(_this, SDL_SCANCODE_RALT, modflags); + HandleModifiers(_this, SDL_SCANCODE_RGUI, modflags); + break; + } + default: // just to avoid compiler warnings + break; + } +} + +void Cocoa_QuitKeyboard(SDL_VideoDevice *_this) +{ +} + +typedef int CGSConnection; +typedef enum +{ + CGSGlobalHotKeyEnable = 0, + CGSGlobalHotKeyDisable = 1, +} CGSGlobalHotKeyOperatingMode; + +extern CGSConnection _CGSDefaultConnection(void); +extern CGError CGSSetGlobalHotKeyOperatingMode(CGSConnection connection, CGSGlobalHotKeyOperatingMode mode); + +bool Cocoa_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ +#ifdef SDL_MAC_NO_SANDBOX + CGSSetGlobalHotKeyOperatingMode(_CGSDefaultConnection(), grabbed ? CGSGlobalHotKeyDisable : CGSGlobalHotKeyEnable); +#endif + return true; +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.h new file mode 100644 index 0000000..ea02052 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +extern bool Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.m new file mode 100644 index 0000000..d54adb1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamessagebox.m @@ -0,0 +1,145 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoavideo.h" + +@interface SDL3MessageBoxPresenter : NSObject +{ + @public + NSInteger clicked; + NSWindow *nswindow; +} +- (id)initWithParentWindow:(SDL_Window *)window; +@end + +@implementation SDL3MessageBoxPresenter +- (id)initWithParentWindow:(SDL_Window *)window +{ + self = [super init]; + if (self) { + clicked = -1; + + // Retain the NSWindow because we'll show the alert later on the main thread + if (window) { + nswindow = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; + } else { + nswindow = nil; + } + } + + return self; +} + +- (void)showAlert:(NSAlert *)alert +{ + if (nswindow) { + [alert beginSheetModalForWindow:nswindow + completionHandler:^(NSModalResponse returnCode) { + [NSApp stopModalWithCode:returnCode]; + }]; + clicked = [NSApp runModalForWindow:nswindow]; + nswindow = nil; + } else { + clicked = [alert runModal]; + } +} +@end + +static void Cocoa_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonID, bool *result) +{ + NSAlert *alert; + const SDL_MessageBoxButtonData *buttons = messageboxdata->buttons; + SDL3MessageBoxPresenter *presenter; + NSInteger clicked; + int i; + Cocoa_RegisterApp(); + + alert = [[NSAlert alloc] init]; + + if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) { + [alert setAlertStyle:NSAlertStyleCritical]; + } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) { + [alert setAlertStyle:NSAlertStyleWarning]; + } else { + [alert setAlertStyle:NSAlertStyleInformational]; + } + + [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]]; + [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]]; + + for (i = 0; i < messageboxdata->numbuttons; ++i) { + const SDL_MessageBoxButtonData *sdlButton; + NSButton *button; + + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { + sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i]; + } else { + sdlButton = &messageboxdata->buttons[i]; + } + + button = [alert addButtonWithTitle:[NSString stringWithUTF8String:sdlButton->text]]; + if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { + [button setKeyEquivalent:@"\r"]; + } else if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) { + [button setKeyEquivalent:@"\033"]; + } else { + [button setKeyEquivalent:@""]; + } + } + + presenter = [[SDL3MessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window]; + + [presenter showAlert:alert]; + + clicked = presenter->clicked; + if (clicked >= NSAlertFirstButtonReturn) { + clicked -= NSAlertFirstButtonReturn; + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { + clicked = messageboxdata->numbuttons - 1 - clicked; + } + *buttonID = buttons[clicked].buttonID; + *result = true; + } else { + *result = SDL_SetError("Did not get a valid `clicked button' id: %ld", (long)clicked); + } +} + +// Display a Cocoa message box +bool Cocoa_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + @autoreleasepool { + __block bool result = 0; + + if ([NSThread isMainThread]) { + Cocoa_ShowMessageBoxImpl(messageboxdata, buttonID, &result); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + Cocoa_ShowMessageBoxImpl(messageboxdata, buttonID, &result); + }); + } + return result; + } +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.h new file mode 100644 index 0000000..3b76836 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.h @@ -0,0 +1,66 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +/* + * @author Mark Callow, www.edgewise-consulting.com. + * + * Thanks to @slime73 on GitHub for their gist showing how to add a CAMetalLayer + * backed view. + */ +#include "SDL_internal.h" + +#ifndef SDL_cocoametalview_h_ +#define SDL_cocoametalview_h_ + +#if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) + +#import "../SDL_sysvideo.h" + +#import "SDL_cocoawindow.h" + +#import +#import +#import + +@interface SDL3_cocoametalview : NSView + +- (instancetype)initWithFrame:(NSRect)frame + highDPI:(BOOL)highDPI + windowID:(Uint32)windowID + opaque:(BOOL)opaque; + +- (void)updateDrawableSize; +- (NSView *)hitTest:(NSPoint)point; + +// Override superclass tag so this class can set it. +@property(assign, readonly) NSInteger tag; + +@property(nonatomic) BOOL highDPI; +@property(nonatomic) Uint32 sdlWindowID; + +@end + +SDL_MetalView Cocoa_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window); +void Cocoa_Metal_DestroyView(SDL_VideoDevice *_this, SDL_MetalView view); +void *Cocoa_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view); + +#endif // SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) + +#endif // SDL_cocoametalview_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.m new file mode 100644 index 0000000..af84e93 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoametalview.m @@ -0,0 +1,182 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +/* + * @author Mark Callow, www.edgewise-consulting.com. + * + * Thanks to @slime73 on GitHub for their gist showing how to add a CAMetalLayer + * backed view. + */ +#include "SDL_internal.h" + +#include "../../events/SDL_windowevents_c.h" + +#import "SDL_cocoametalview.h" + +#if defined(SDL_VIDEO_DRIVER_COCOA) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) + +static bool SDLCALL SDL_MetalViewEventWatch(void *userdata, SDL_Event *event) +{ + /* Update the drawable size when SDL receives a size changed event for + * the window that contains the metal view. It would be nice to use + * - (void)resizeWithOldSuperviewSize:(NSSize)oldSize and + * - (void)viewDidChangeBackingProperties instead, but SDL's size change + * events don't always happen in the same frame (for example when a + * resizable window exits a fullscreen Space via the user pressing the OS + * exit-space button). */ + if (event->type == SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED) { + @autoreleasepool { + SDL3_cocoametalview *view = (__bridge SDL3_cocoametalview *)userdata; + if (view.sdlWindowID == event->window.windowID) { + [view updateDrawableSize]; + } + } + } + return false; +} + +@implementation SDL3_cocoametalview + +// Return a Metal-compatible layer. ++ (Class)layerClass +{ + return NSClassFromString(@"CAMetalLayer"); +} + +// Indicate the view wants to draw using a backing layer instead of drawRect. +- (BOOL)wantsUpdateLayer +{ + return YES; +} + +/* When the wantsLayer property is set to YES, this method will be invoked to + * return a layer instance. + */ +- (CALayer *)makeBackingLayer +{ + return [self.class.layerClass layer]; +} + +- (instancetype)initWithFrame:(NSRect)frame + highDPI:(BOOL)highDPI + windowID:(Uint32)windowID + opaque:(BOOL)opaque +{ + self = [super initWithFrame:frame]; + if (self != nil) { + self.highDPI = highDPI; + self.sdlWindowID = windowID; + self.wantsLayer = YES; + + // Allow resize. + self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; + + self.layer.opaque = opaque; + + SDL_AddWindowEventWatch(SDL_WINDOW_EVENT_WATCH_EARLY, SDL_MetalViewEventWatch, (__bridge void *)(self)); + + [self updateDrawableSize]; + } + + return self; +} + +- (void)dealloc +{ + SDL_RemoveWindowEventWatch(SDL_WINDOW_EVENT_WATCH_EARLY, SDL_MetalViewEventWatch, (__bridge void *)(self)); +} + +- (NSInteger)tag +{ + return SDL_METALVIEW_TAG; +} + +- (void)updateDrawableSize +{ + CAMetalLayer *metalLayer = (CAMetalLayer *)self.layer; + NSSize size = self.bounds.size; + NSSize backingSize = size; + + if (self.highDPI) { + /* Note: NSHighResolutionCapable must be set to true in the app's + * Info.plist in order for the backing size to be high res. + */ + backingSize = [self convertSizeToBacking:size]; + } + + metalLayer.contentsScale = backingSize.height / size.height; + metalLayer.drawableSize = NSSizeToCGSize(backingSize); +} + +- (NSView *)hitTest:(NSPoint)point +{ + return nil; +} + +@end + +SDL_MetalView Cocoa_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSView *view = data.nswindow.contentView; + BOOL highDPI = (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) != 0; + BOOL opaque = (window->flags & SDL_WINDOW_TRANSPARENT) == 0; + Uint32 windowID = SDL_GetWindowID(window); + SDL3_cocoametalview *newview; + SDL_MetalView metalview; + + newview = [[SDL3_cocoametalview alloc] initWithFrame:view.frame + highDPI:highDPI + windowID:windowID + opaque:opaque]; + if (newview == nil) { + SDL_OutOfMemory(); + return NULL; + } + + [view addSubview:newview]; + + // Make sure the drawable size is up to date after attaching the view. + [newview updateDrawableSize]; + + metalview = (SDL_MetalView)CFBridgingRetain(newview); + + return metalview; + } +} + +void Cocoa_Metal_DestroyView(SDL_VideoDevice *_this, SDL_MetalView view) +{ + @autoreleasepool { + SDL3_cocoametalview *metalview = CFBridgingRelease(view); + [metalview removeFromSuperview]; + } +} + +void *Cocoa_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view) +{ + @autoreleasepool { + SDL3_cocoametalview *cocoaview = (__bridge SDL3_cocoametalview *)view; + return (__bridge void *)cocoaview.layer; + } +} + +#endif // SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.h new file mode 100644 index 0000000..37f3aa5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.h @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoamodes_h_ +#define SDL_cocoamodes_h_ + +struct SDL_DisplayData +{ + CGDirectDisplayID display; +}; + +struct SDL_DisplayModeData +{ + CFMutableArrayRef modes; +}; + +extern void Cocoa_InitModes(SDL_VideoDevice *_this); +extern void Cocoa_UpdateDisplays(SDL_VideoDevice *_this); +extern bool Cocoa_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); +extern bool Cocoa_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); +extern bool Cocoa_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool Cocoa_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern void Cocoa_QuitModes(SDL_VideoDevice *_this); +extern SDL_VideoDisplay *Cocoa_FindSDLDisplayByCGDirectDisplayID(SDL_VideoDevice *_this, CGDirectDisplayID displayid); + +#endif // SDL_cocoamodes_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.m new file mode 100644 index 0000000..b3c34ba --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamodes.m @@ -0,0 +1,716 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoavideo.h" +#include "../../events/SDL_events_c.h" + +// We need this for IODisplayCreateInfoDictionary and kIODisplayOnlyPreferredName +#include + +// We need this for CVDisplayLinkGetNominalOutputVideoRefreshPeriod +#include +#include + +#if (IOGRAPHICSTYPES_REV < 40) +#define kDisplayModeNativeFlag 0x02000000 +#endif + +static bool CG_SetError(const char *prefix, CGDisplayErr result) +{ + const char *error; + + switch (result) { + case kCGErrorFailure: + error = "kCGErrorFailure"; + break; + case kCGErrorIllegalArgument: + error = "kCGErrorIllegalArgument"; + break; + case kCGErrorInvalidConnection: + error = "kCGErrorInvalidConnection"; + break; + case kCGErrorInvalidContext: + error = "kCGErrorInvalidContext"; + break; + case kCGErrorCannotComplete: + error = "kCGErrorCannotComplete"; + break; + case kCGErrorNotImplemented: + error = "kCGErrorNotImplemented"; + break; + case kCGErrorRangeCheck: + error = "kCGErrorRangeCheck"; + break; + case kCGErrorTypeCheck: + error = "kCGErrorTypeCheck"; + break; + case kCGErrorInvalidOperation: + error = "kCGErrorInvalidOperation"; + break; + case kCGErrorNoneAvailable: + error = "kCGErrorNoneAvailable"; + break; + default: + error = "Unknown Error"; + break; + } + return SDL_SetError("%s: %s", prefix, error); +} + +static NSScreen *GetNSScreenForDisplayID(CGDirectDisplayID displayID) +{ + NSArray *screens = [NSScreen screens]; + + // !!! FIXME: maybe track the NSScreen in SDL_DisplayData? + for (NSScreen *screen in screens) { + const CGDirectDisplayID thisDisplay = (CGDirectDisplayID)[[[screen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue]; + if (thisDisplay == displayID) { + return screen; + } + } + return nil; +} + +SDL_VideoDisplay *Cocoa_FindSDLDisplayByCGDirectDisplayID(SDL_VideoDevice *_this, CGDirectDisplayID displayid) +{ + for (int i = 0; i < _this->num_displays; i++) { + const SDL_DisplayData *displaydata = _this->displays[i]->internal; + if (displaydata && (displaydata->display == displayid)) { + return _this->displays[i]; + } + } + return NULL; +} + +static float GetDisplayModeRefreshRate(CGDisplayModeRef vidmode, CVDisplayLinkRef link) +{ + float refreshRate = (float)CGDisplayModeGetRefreshRate(vidmode); + + // CGDisplayModeGetRefreshRate can return 0 (eg for built-in displays). + if (refreshRate == 0 && link != NULL) { + CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link); + if ((time.flags & kCVTimeIsIndefinite) == 0 && time.timeValue != 0) { + refreshRate = (float)time.timeScale / time.timeValue; + } + } + + return refreshRate; +} + +static bool HasValidDisplayModeFlags(CGDisplayModeRef vidmode) +{ + uint32_t ioflags = CGDisplayModeGetIOFlags(vidmode); + + // Filter out modes which have flags that we don't want. + if (ioflags & (kDisplayModeNeverShowFlag | kDisplayModeNotGraphicsQualityFlag)) { + return false; + } + + // Filter out modes which don't have flags that we want. + if (!(ioflags & kDisplayModeValidFlag) || !(ioflags & kDisplayModeSafeFlag)) { + return false; + } + + return true; +} + +static Uint32 GetDisplayModePixelFormat(CGDisplayModeRef vidmode) +{ + // This API is deprecated in 10.11 with no good replacement (as of 10.15). + CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode); + Uint32 pixelformat = SDL_PIXELFORMAT_UNKNOWN; + + if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + pixelformat = SDL_PIXELFORMAT_ARGB8888; + } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + pixelformat = SDL_PIXELFORMAT_ARGB1555; + } else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + pixelformat = SDL_PIXELFORMAT_ARGB2101010; + } else { + // ignore 8-bit and such for now. + } + + CFRelease(fmt); + + return pixelformat; +} + +static bool GetDisplayMode(CGDisplayModeRef vidmode, bool vidmodeCurrent, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode) +{ + SDL_DisplayModeData *data; + bool usableForGUI = CGDisplayModeIsUsableForDesktopGUI(vidmode); + size_t width = CGDisplayModeGetWidth(vidmode); + size_t height = CGDisplayModeGetHeight(vidmode); + size_t pixelW = width; + size_t pixelH = height; + uint32_t ioflags = CGDisplayModeGetIOFlags(vidmode); + float refreshrate = GetDisplayModeRefreshRate(vidmode, link); + Uint32 format = GetDisplayModePixelFormat(vidmode); + bool interlaced = (ioflags & kDisplayModeInterlacedFlag) != 0; + CFMutableArrayRef modes; + + if (format == SDL_PIXELFORMAT_UNKNOWN) { + return false; + } + + /* Don't fail the current mode based on flags because this could prevent Cocoa_InitModes from + * succeeding if the current mode lacks certain flags (esp kDisplayModeSafeFlag). */ + if (!vidmodeCurrent && !HasValidDisplayModeFlags(vidmode)) { + return false; + } + + modes = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks); + CFArrayAppendValue(modes, vidmode); + + /* If a list of possible display modes is passed in, use it to filter out + * modes that have duplicate sizes. We don't just rely on SDL's higher level + * duplicate filtering because this code can choose what properties are + * preferred, and it can add CGDisplayModes to the DisplayModeData's list of + * modes to try (see comment below for why that's necessary). */ + pixelW = CGDisplayModeGetPixelWidth(vidmode); + pixelH = CGDisplayModeGetPixelHeight(vidmode); + + if (modelist != NULL) { + CFIndex modescount = CFArrayGetCount(modelist); + int i; + + for (i = 0; i < modescount; i++) { + size_t otherW, otherH, otherpixelW, otherpixelH; + float otherrefresh; + Uint32 otherformat; + bool otherGUI; + CGDisplayModeRef othermode = (CGDisplayModeRef)CFArrayGetValueAtIndex(modelist, i); + uint32_t otherioflags = CGDisplayModeGetIOFlags(othermode); + + if (CFEqual(vidmode, othermode)) { + continue; + } + + if (!HasValidDisplayModeFlags(othermode)) { + continue; + } + + otherW = CGDisplayModeGetWidth(othermode); + otherH = CGDisplayModeGetHeight(othermode); + otherpixelW = CGDisplayModeGetPixelWidth(othermode); + otherpixelH = CGDisplayModeGetPixelHeight(othermode); + otherrefresh = GetDisplayModeRefreshRate(othermode, link); + otherformat = GetDisplayModePixelFormat(othermode); + otherGUI = CGDisplayModeIsUsableForDesktopGUI(othermode); + + /* Ignore this mode if it's interlaced and there's a non-interlaced + * mode in the list with the same properties. + */ + if (interlaced && ((otherioflags & kDisplayModeInterlacedFlag) == 0) && width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && refreshrate == otherrefresh && format == otherformat && usableForGUI == otherGUI) { + CFRelease(modes); + return false; + } + + /* Ignore this mode if it's not usable for desktop UI and its + * properties are equal to another GUI-capable mode in the list. + */ + if (width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && !usableForGUI && otherGUI && refreshrate == otherrefresh && format == otherformat) { + CFRelease(modes); + return false; + } + + /* If multiple modes have the exact same properties, they'll all + * go in the list of modes to try when SetDisplayMode is called. + * This is needed because kCGDisplayShowDuplicateLowResolutionModes + * (which is used to expose highdpi display modes) can make the + * list of modes contain duplicates (according to their properties + * obtained via public APIs) which don't work with SetDisplayMode. + * Those duplicate non-functional modes *do* have different pixel + * formats according to their internal data structure viewed with + * NSLog, but currently no public API can detect that. + * https://bugzilla.libsdl.org/show_bug.cgi?id=4822 + * + * As of macOS 10.15.0, those duplicates have the exact same + * properties via public APIs in every way (even their IO flags and + * CGDisplayModeGetIODisplayModeID is the same), so we could test + * those for equality here too, but I'm intentionally not doing that + * in case there are duplicate modes with different IO flags or IO + * display mode IDs in the future. In that case I think it's better + * to try them all in SetDisplayMode than to risk one of them being + * correct but it being filtered out by SDL_AddFullscreenDisplayMode + * as being a duplicate. + */ + if (width == otherW && height == otherH && pixelW == otherpixelW && pixelH == otherpixelH && usableForGUI == otherGUI && refreshrate == otherrefresh && format == otherformat) { + CFArrayAppendValue(modes, othermode); + } + } + } + + SDL_zerop(mode); + data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); + if (!data) { + CFRelease(modes); + return false; + } + data->modes = modes; + mode->format = format; + mode->w = (int)width; + mode->h = (int)height; + mode->pixel_density = (float)pixelW / width; + mode->refresh_rate = refreshrate; + mode->internal = data; + return true; +} + +static char *Cocoa_GetDisplayName(CGDirectDisplayID displayID) +{ + if (@available(macOS 10.15, *)) { + NSScreen *screen = GetNSScreenForDisplayID(displayID); + if (screen) { + const char *name = [screen.localizedName UTF8String]; + if (name) { + return SDL_strdup(name); + } + } + } + + // This API is deprecated in 10.9 with no good replacement (as of 10.15). + io_service_t servicePort = CGDisplayIOServicePort(displayID); + CFDictionaryRef deviceInfo = IODisplayCreateInfoDictionary(servicePort, kIODisplayOnlyPreferredName); + NSDictionary *localizedNames = [(__bridge NSDictionary *)deviceInfo objectForKey:[NSString stringWithUTF8String:kDisplayProductName]]; + char *displayName = NULL; + + if ([localizedNames count] > 0) { + displayName = SDL_strdup([[localizedNames objectForKey:[[localizedNames allKeys] objectAtIndex:0]] UTF8String]); + } + CFRelease(deviceInfo); + return displayName; +} + +static void Cocoa_GetHDRProperties(CGDirectDisplayID displayID, SDL_HDROutputProperties *HDR) +{ + HDR->SDR_white_level = 1.0f; + HDR->HDR_headroom = 1.0f; + + if (@available(macOS 10.15, *)) { + NSScreen *screen = GetNSScreenForDisplayID(displayID); + if (screen) { + if (screen.maximumExtendedDynamicRangeColorComponentValue > 1.0f) { + HDR->HDR_headroom = screen.maximumExtendedDynamicRangeColorComponentValue; + } else { + HDR->HDR_headroom = screen.maximumPotentialExtendedDynamicRangeColorComponentValue; + } + } + } +} + + +bool Cocoa_AddDisplay(CGDirectDisplayID display, bool send_event) +{ + CGDisplayModeRef moderef = CGDisplayCopyDisplayMode(display); + if (!moderef) { + return false; + } + + SDL_DisplayData *displaydata = (SDL_DisplayData *)SDL_malloc(sizeof(*displaydata)); + if (!displaydata) { + CGDisplayModeRelease(moderef); + return false; + } + displaydata->display = display; + + CVDisplayLinkRef link = NULL; + CVDisplayLinkCreateWithCGDisplay(display, &link); + + SDL_VideoDisplay viddisplay; + SDL_zero(viddisplay); + viddisplay.name = Cocoa_GetDisplayName(display); // this returns a strdup'ed string + + SDL_DisplayMode mode; + if (!GetDisplayMode(moderef, true, NULL, link, &mode)) { + CVDisplayLinkRelease(link); + CGDisplayModeRelease(moderef); + SDL_free(viddisplay.name); + SDL_free(displaydata); + return false; + } + + CVDisplayLinkRelease(link); + CGDisplayModeRelease(moderef); + + Cocoa_GetHDRProperties(displaydata->display, &viddisplay.HDR); + + viddisplay.desktop_mode = mode; + viddisplay.internal = displaydata; + const bool retval = SDL_AddVideoDisplay(&viddisplay, send_event); + SDL_free(viddisplay.name); + return retval; +} + +static void Cocoa_DisplayReconfigurationCallback(CGDirectDisplayID displayid, CGDisplayChangeSummaryFlags flags, void *userInfo) +{ + #if 0 + SDL_Log("COCOA DISPLAY RECONFIG CALLBACK! display=%u", (unsigned int) displayid); + #define CHECK_DISPLAY_RECONFIG_FLAG(x) if (flags & x) { SDL_Log(" - " #x); } + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayBeginConfigurationFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayMovedFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplaySetMainFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplaySetModeFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayAddFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayRemoveFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayEnabledFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayDisabledFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayMirrorFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayUnMirrorFlag); + CHECK_DISPLAY_RECONFIG_FLAG(kCGDisplayDesktopShapeChangedFlag); + #undef CHECK_DISPLAY_RECONFIG_FLAG + #endif + + SDL_VideoDevice *_this = (SDL_VideoDevice *) userInfo; + SDL_VideoDisplay *display = Cocoa_FindSDLDisplayByCGDirectDisplayID(_this, displayid); // will be NULL for newly-added (or newly-unmirrored) displays! + + if (flags & kCGDisplayDisabledFlag) { + flags |= kCGDisplayRemoveFlag; // treat this like a display leaving, even though it's still plugged in. + } + + if (flags & kCGDisplayEnabledFlag) { + flags |= kCGDisplayAddFlag; // treat this like a display leaving, even though it's still plugged in. + } + + if (flags & kCGDisplayMirrorFlag) { + flags |= kCGDisplayRemoveFlag; // treat this like a display leaving, even though it's still actually here. + } + + if (flags & kCGDisplayUnMirrorFlag) { + flags |= kCGDisplayAddFlag; // treat this like a new display arriving, even though it was here all along. + } + + if ((flags & kCGDisplayAddFlag) && (flags & kCGDisplayRemoveFlag)) { + // sometimes you get a removed device that gets Add and Remove flags at the same time but the display dimensions are 0x0 or 1x1, hence the `> 1` test. + // Mirrored things are always removed, since they don't represent a discrete display in this state. + if (((flags & kCGDisplayMirrorFlag) == 0) && (CGDisplayPixelsWide(displayid) > 1)) { + // Final state is connected + flags &= ~kCGDisplayRemoveFlag; + } else { + // Final state is disconnected + flags &= ~kCGDisplayAddFlag; + } + } + + if (flags & kCGDisplayAddFlag) { + if (!display) { + if (!Cocoa_AddDisplay(displayid, true)) { + return; // oh well. + } + display = Cocoa_FindSDLDisplayByCGDirectDisplayID(_this, displayid); + SDL_assert(display != NULL); + } + } + + if (flags & kCGDisplayRemoveFlag) { + if (display) { + SDL_DelVideoDisplay(display->id, true); + display = NULL; + } + } + + if (flags & kCGDisplaySetModeFlag) { + if (display) { + CGDisplayModeRef moderef = CGDisplayCopyDisplayMode(displayid); + if (moderef) { + CVDisplayLinkRef link = NULL; + CVDisplayLinkCreateWithCGDisplay(displayid, &link); + if (link) { + SDL_DisplayMode mode; + if (GetDisplayMode(moderef, true, NULL, link, &mode)) { + SDL_SetDesktopDisplayMode(display, &mode); + } + CVDisplayLinkRelease(link); + } + CGDisplayModeRelease(moderef); + } + } + } + + if (flags & kCGDisplaySetMainFlag) { + if (display) { + for (int i = 0; i < _this->num_displays; i++) { + if (_this->displays[i] == display) { + if (i > 0) { + // move this display to the front of _this->displays so it's treated as primary. + SDL_memmove(&_this->displays[1], &_this->displays[0], sizeof (*_this->displays) * i); + _this->displays[0] = display; + } + flags |= kCGDisplayMovedFlag; // we don't have an SDL event atm for "this display became primary," so at least let everyone know it "moved". + break; + } + } + } + } + + if (flags & kCGDisplayMovedFlag) { + if (display) { + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_MOVED, 0, 0); + } + } + + if (flags & kCGDisplayDesktopShapeChangedFlag) { + SDL_UpdateDesktopBounds(); + } +} + +void Cocoa_InitModes(SDL_VideoDevice *_this) +{ + @autoreleasepool { + CGDisplayErr result; + CGDisplayCount numDisplays = 0; + + result = CGGetOnlineDisplayList(0, NULL, &numDisplays); + if (result != kCGErrorSuccess) { + CG_SetError("CGGetOnlineDisplayList()", result); + return; + } + + bool isstack; + CGDirectDisplayID *displays = SDL_small_alloc(CGDirectDisplayID, numDisplays, &isstack); + + result = CGGetOnlineDisplayList(numDisplays, displays, &numDisplays); + if (result != kCGErrorSuccess) { + CG_SetError("CGGetOnlineDisplayList()", result); + SDL_small_free(displays, isstack); + return; + } + + // future updates to the display graph will come through this callback. + CGDisplayRegisterReconfigurationCallback(Cocoa_DisplayReconfigurationCallback, _this); + + // Pick up the primary display in the first pass, then get the rest + for (int pass = 0; pass < 2; ++pass) { + for (int i = 0; i < numDisplays; ++i) { + if (pass == 0) { + if (!CGDisplayIsMain(displays[i])) { + continue; + } + } else { + if (CGDisplayIsMain(displays[i])) { + continue; + } + } + + if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) { + continue; + } + + Cocoa_AddDisplay(displays[i], false); + } + } + SDL_small_free(displays, isstack); + } +} + +void Cocoa_UpdateDisplays(SDL_VideoDevice *_this) +{ + SDL_HDROutputProperties HDR; + int i; + + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *display = _this->displays[i]; + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->internal; + + Cocoa_GetHDRProperties(displaydata->display, &HDR); + SDL_SetDisplayHDRProperties(display, &HDR); + } +} + +bool Cocoa_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->internal; + CGRect cgrect; + + cgrect = CGDisplayBounds(displaydata->display); + rect->x = (int)cgrect.origin.x; + rect->y = (int)cgrect.origin.y; + rect->w = (int)cgrect.size.width; + rect->h = (int)cgrect.size.height; + return true; +} + +bool Cocoa_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->internal; + NSScreen *screen = GetNSScreenForDisplayID(displaydata->display); + + if (screen == nil) { + return SDL_SetError("Couldn't get NSScreen for display"); + } + + { + const NSRect frame = [screen visibleFrame]; + rect->x = (int)frame.origin.x; + rect->y = (int)(CGDisplayPixelsHigh(kCGDirectMainDisplay) - frame.origin.y - frame.size.height); + rect->w = (int)frame.size.width; + rect->h = (int)frame.size.height; + } + + return true; +} + +bool Cocoa_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayData *data = (SDL_DisplayData *)display->internal; + CVDisplayLinkRef link = NULL; + CFArrayRef modes; + CFDictionaryRef dict = NULL; + const CFStringRef dictkeys[] = { kCGDisplayShowDuplicateLowResolutionModes }; + const CFBooleanRef dictvalues[] = { kCFBooleanTrue }; + + CVDisplayLinkCreateWithCGDisplay(data->display, &link); + + /* By default, CGDisplayCopyAllDisplayModes will only get a subset of the + * system's available modes. For example on a 15" 2016 MBP, users can + * choose 1920x1080@2x in System Preferences but it won't show up here, + * unless we specify the option below. + * The display modes returned by CGDisplayCopyAllDisplayModes are also not + * high dpi-capable unless this option is set. + * macOS 10.15 also seems to have a bug where entering, exiting, and + * re-entering exclusive fullscreen with a low dpi display mode can cause + * the content of the screen to move up, which this setting avoids: + * https://bugzilla.libsdl.org/show_bug.cgi?id=4822 + */ + + dict = CFDictionaryCreate(NULL, + (const void **)dictkeys, + (const void **)dictvalues, + 1, + &kCFCopyStringDictionaryKeyCallBacks, + &kCFTypeDictionaryValueCallBacks); + + modes = CGDisplayCopyAllDisplayModes(data->display, dict); + + if (dict) { + CFRelease(dict); + } + + if (modes) { + CFIndex i; + const CFIndex count = CFArrayGetCount(modes); + + for (i = 0; i < count; i++) { + CGDisplayModeRef moderef = (CGDisplayModeRef)CFArrayGetValueAtIndex(modes, i); + SDL_DisplayMode mode; + + if (GetDisplayMode(moderef, false, modes, link, &mode)) { + if (!SDL_AddFullscreenDisplayMode(display, &mode)) { + CFRelease(mode.internal->modes); + SDL_free(mode.internal); + } + } + } + + CFRelease(modes); + } + + CVDisplayLinkRelease(link); + return true; +} + +static CGError SetDisplayModeForDisplay(CGDirectDisplayID display, SDL_DisplayModeData *data) +{ + /* SDL_DisplayModeData can contain multiple CGDisplayModes to try (with + * identical properties), some of which might not work. See GetDisplayMode. + */ + CGError result = kCGErrorFailure; + for (CFIndex i = 0; i < CFArrayGetCount(data->modes); i++) { + CGDisplayModeRef moderef = (CGDisplayModeRef)CFArrayGetValueAtIndex(data->modes, i); + result = CGDisplaySetDisplayMode(display, moderef, NULL); + if (result == kCGErrorSuccess) { + // If this mode works, try it first next time. + if (i > 0) { + CFArrayExchangeValuesAtIndices(data->modes, i, 0); + } + break; + } + } + return result; +} + +bool Cocoa_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->internal; + SDL_DisplayModeData *data = mode->internal; + CGDisplayFadeReservationToken fade_token = kCGDisplayFadeReservationInvalidToken; + CGError result = kCGErrorSuccess; + + b_inModeTransition = true; + + // Fade to black to hide resolution-switching flicker + if (CGAcquireDisplayFadeReservation(5, &fade_token) == kCGErrorSuccess) { + CGDisplayFade(fade_token, 0.3, kCGDisplayBlendNormal, kCGDisplayBlendSolidColor, 0.0, 0.0, 0.0, TRUE); + } + + if (data == display->desktop_mode.internal) { + // Restoring desktop mode + SetDisplayModeForDisplay(displaydata->display, data); + } else { + // Do the physical switch + result = SetDisplayModeForDisplay(displaydata->display, data); + } + + // Fade in again (asynchronously) + if (fade_token != kCGDisplayFadeReservationInvalidToken) { + CGDisplayFade(fade_token, 0.5, kCGDisplayBlendSolidColor, kCGDisplayBlendNormal, 0.0, 0.0, 0.0, FALSE); + CGReleaseDisplayFadeReservation(fade_token); + } + + b_inModeTransition = false; + + if (result != kCGErrorSuccess) { + return CG_SetError("CGDisplaySwitchToMode()", result); + } + return true; +} + +void Cocoa_QuitModes(SDL_VideoDevice *_this) +{ + int i, j; + + CGDisplayRemoveReconfigurationCallback(Cocoa_DisplayReconfigurationCallback, _this); + + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *display = _this->displays[i]; + SDL_DisplayModeData *mode; + + if (display->current_mode->internal != display->desktop_mode.internal) { + Cocoa_SetDisplayMode(_this, display, &display->desktop_mode); + } + + mode = display->desktop_mode.internal; + CFRelease(mode->modes); + + for (j = 0; j < display->num_fullscreen_modes; j++) { + mode = display->fullscreen_modes[j].internal; + CFRelease(mode->modes); + } + } +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.h new file mode 100644 index 0000000..70282be --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.h @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoamouse_h_ +#define SDL_cocoamouse_h_ + +#include "SDL_cocoavideo.h" + +extern bool Cocoa_InitMouse(SDL_VideoDevice *_this); +extern NSWindow *Cocoa_GetMouseFocus(); +extern void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event); +extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event); +extern void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y); +extern void Cocoa_QuitMouse(SDL_VideoDevice *_this); + +typedef struct +{ + // Whether we've seen a cursor warp since the last move event. + bool seenWarp; + // What location our last cursor warp was to. + CGFloat lastWarpX; + CGFloat lastWarpY; + // What location we last saw the cursor move to. + CGFloat lastMoveX; + CGFloat lastMoveY; +} SDL_MouseData; + +@interface NSCursor (InvisibleCursor) ++ (NSCursor *)invisibleCursor; +@end + +#endif // SDL_cocoamouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.m new file mode 100644 index 0000000..530ca0c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoamouse.m @@ -0,0 +1,591 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoamouse.h" +#include "SDL_cocoavideo.h" + +#include "../../events/SDL_mouse_c.h" + +#if 0 +#define DEBUG_COCOAMOUSE +#endif + +#ifdef DEBUG_COCOAMOUSE +#define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) +#else +#define DLog(...) \ + do { \ + } while (0) +#endif + +@implementation NSCursor (InvisibleCursor) ++ (NSCursor *)invisibleCursor +{ + static NSCursor *invisibleCursor = NULL; + if (!invisibleCursor) { + // RAW 16x16 transparent GIF + static unsigned char cursorBytes[] = { + 0x47, 0x49, 0x46, 0x38, 0x37, 0x61, 0x10, 0x00, 0x10, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xF9, 0x04, + 0x01, 0x00, 0x00, 0x01, 0x00, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x10, 0x00, 0x00, 0x02, 0x0E, 0x8C, 0x8F, 0xA9, 0xCB, 0xED, + 0x0F, 0xA3, 0x9C, 0xB4, 0xDA, 0x8B, 0xB3, 0x3E, 0x05, 0x00, 0x3B + }; + + NSData *cursorData = [NSData dataWithBytesNoCopy:&cursorBytes[0] + length:sizeof(cursorBytes) + freeWhenDone:NO]; + NSImage *cursorImage = [[NSImage alloc] initWithData:cursorData]; + invisibleCursor = [[NSCursor alloc] initWithImage:cursorImage + hotSpot:NSZeroPoint]; + } + + return invisibleCursor; +} +@end + +static SDL_Cursor *Cocoa_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + @autoreleasepool { + NSImage *nsimage; + NSCursor *nscursor = NULL; + SDL_Cursor *cursor = NULL; + + nsimage = Cocoa_CreateImage(surface); + if (nsimage) { + nscursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(hot_x, hot_y)]; + } + + if (nscursor) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->internal = (void *)CFBridgingRetain(nscursor); + } + } + + return cursor; + } +} + +/* there are .pdf files of some of the cursors we need, installed by default on macOS, but not available through NSCursor. + If we can load them ourselves, use them, otherwise fallback to something standard but not super-great. + Since these are under /System, they should be available even to sandboxed apps. */ +static NSCursor *LoadHiddenSystemCursor(NSString *cursorName, SEL fallback) +{ + NSString *cursorPath = [@"/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/Resources/cursors" stringByAppendingPathComponent:cursorName]; + NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"info.plist"]]; + // we can't do animation atm. :/ + const int frames = (int)[[info valueForKey:@"frames"] integerValue]; + NSCursor *cursor; + NSImage *image = [[NSImage alloc] initWithContentsOfFile:[cursorPath stringByAppendingPathComponent:@"cursor.pdf"]]; + if ((image == nil) || (image.isValid == NO)) { + return [NSCursor performSelector:fallback]; + } + + if (frames > 1) { +#ifdef MAC_OS_VERSION_12_0 // same value as deprecated symbol. + const NSCompositingOperation operation = NSCompositingOperationCopy; +#else + const NSCompositingOperation operation = NSCompositeCopy; +#endif + const NSSize cropped_size = NSMakeSize(image.size.width, (int)(image.size.height / frames)); + NSImage *cropped = [[NSImage alloc] initWithSize:cropped_size]; + if (cropped == nil) { + return [NSCursor performSelector:fallback]; + } + + [cropped lockFocus]; + { + const NSRect cropped_rect = NSMakeRect(0, 0, cropped_size.width, cropped_size.height); + [image drawInRect:cropped_rect fromRect:cropped_rect operation:operation fraction:1]; + } + [cropped unlockFocus]; + image = cropped; + } + + cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint([[info valueForKey:@"hotx"] doubleValue], [[info valueForKey:@"hoty"] doubleValue])]; + return cursor; +} + +static SDL_Cursor *Cocoa_CreateSystemCursor(SDL_SystemCursor id) +{ + @autoreleasepool { + NSCursor *nscursor = NULL; + SDL_Cursor *cursor = NULL; + + switch (id) { + case SDL_SYSTEM_CURSOR_DEFAULT: + nscursor = [NSCursor arrowCursor]; + break; + case SDL_SYSTEM_CURSOR_TEXT: + nscursor = [NSCursor IBeamCursor]; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + nscursor = [NSCursor crosshairCursor]; + break; + case SDL_SYSTEM_CURSOR_WAIT: // !!! FIXME: this is more like WAITARROW + nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); + break; + case SDL_SYSTEM_CURSOR_PROGRESS: // !!! FIXME: this is meant to be animated + nscursor = LoadHiddenSystemCursor(@"busybutclickable", @selector(arrowCursor)); + break; + case SDL_SYSTEM_CURSOR_NWSE_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_NESW_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_EW_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor)); + break; + case SDL_SYSTEM_CURSOR_NS_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor)); + break; + case SDL_SYSTEM_CURSOR_MOVE: + nscursor = LoadHiddenSystemCursor(@"move", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_NOT_ALLOWED: + nscursor = [NSCursor operationNotAllowedCursor]; + break; + case SDL_SYSTEM_CURSOR_POINTER: + nscursor = [NSCursor pointingHandCursor]; + break; + case SDL_SYSTEM_CURSOR_NW_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_N_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor)); + break; + case SDL_SYSTEM_CURSOR_NE_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_E_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor)); + break; + case SDL_SYSTEM_CURSOR_SE_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenorthwestsoutheast", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_S_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenorthsouth", @selector(resizeUpDownCursor)); + break; + case SDL_SYSTEM_CURSOR_SW_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizenortheastsouthwest", @selector(closedHandCursor)); + break; + case SDL_SYSTEM_CURSOR_W_RESIZE: + nscursor = LoadHiddenSystemCursor(@"resizeeastwest", @selector(resizeLeftRightCursor)); + break; + default: + SDL_assert(!"Unknown system cursor"); + return NULL; + } + + if (nscursor) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + // We'll free it later, so retain it here + cursor->internal = (void *)CFBridgingRetain(nscursor); + } + } + + return cursor; + } +} + +static SDL_Cursor *Cocoa_CreateDefaultCursor(void) +{ + SDL_SystemCursor id = SDL_GetDefaultSystemCursor(); + return Cocoa_CreateSystemCursor(id); +} + +static void Cocoa_FreeCursor(SDL_Cursor *cursor) +{ + @autoreleasepool { + CFBridgingRelease((void *)cursor->internal); + SDL_free(cursor); + } +} + +static bool Cocoa_ShowCursor(SDL_Cursor *cursor) +{ + @autoreleasepool { + SDL_VideoDevice *device = SDL_GetVideoDevice(); + SDL_Window *window = (device ? device->windows : NULL); + for (; window != NULL; window = window->next) { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + if (data) { + [data.nswindow performSelectorOnMainThread:@selector(invalidateCursorRectsForView:) + withObject:[data.nswindow contentView] + waitUntilDone:NO]; + } + } + return true; + } +} + +static SDL_Window *SDL_FindWindowAtPoint(const float x, const float y) +{ + const SDL_FPoint pt = { x, y }; + SDL_Window *i; + for (i = SDL_GetVideoDevice()->windows; i; i = i->next) { + const SDL_FRect r = { (float)i->x, (float)i->y, (float)i->w, (float)i->h }; + if (SDL_PointInRectFloat(&pt, &r)) { + return i; + } + } + + return NULL; +} + +static bool Cocoa_WarpMouseGlobal(float x, float y) +{ + CGPoint point; + SDL_Mouse *mouse = SDL_GetMouse(); + if (mouse->focus) { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)mouse->focus->internal; + if ([data.listener isMovingOrFocusClickPending]) { + DLog("Postponing warp, window being moved or focused."); + [data.listener setPendingMoveX:x Y:y]; + return true; + } + } + point = CGPointMake(x, y); + + Cocoa_HandleMouseWarp(point.x, point.y); + + CGWarpMouseCursorPosition(point); + + /* CGWarpMouse causes a short delay by default, which is preventable by + * Calling this directly after. CGSetLocalEventsSuppressionInterval can also + * prevent it, but it's deprecated as macOS 10.6. + */ + if (!mouse->relative_mode) { + CGAssociateMouseAndMouseCursorPosition(YES); + } + + /* CGWarpMouseCursorPosition doesn't generate a window event, unlike our + * other implementations' APIs. Send what's appropriate. + */ + if (!mouse->relative_mode) { + SDL_Window *win = SDL_FindWindowAtPoint(x, y); + SDL_SetMouseFocus(win); + if (win) { + SDL_assert(win == mouse->focus); + SDL_SendMouseMotion(0, win, SDL_GLOBAL_MOUSE_ID, false, x - win->x, y - win->y); + } + } + + return true; +} + +static bool Cocoa_WarpMouse(SDL_Window *window, float x, float y) +{ + return Cocoa_WarpMouseGlobal(window->x + x, window->y + y); +} + +static bool Cocoa_SetRelativeMouseMode(bool enabled) +{ + CGError result; + + if (enabled) { + SDL_Window *window = SDL_GetKeyboardFocus(); + if (window) { + /* We will re-apply the relative mode when the window finishes being moved, + * if it is being moved right now. + */ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + if ([data.listener isMovingOrFocusClickPending]) { + return true; + } + + // make sure the mouse isn't at the corner of the window, as this can confuse things if macOS thinks a window resize is happening on the first click. + const CGPoint point = CGPointMake((float)(window->x + (window->w / 2)), (float)(window->y + (window->h / 2))); + Cocoa_HandleMouseWarp(point.x, point.y); + CGWarpMouseCursorPosition(point); + } + DLog("Turning on."); + result = CGAssociateMouseAndMouseCursorPosition(NO); + } else { + DLog("Turning off."); + result = CGAssociateMouseAndMouseCursorPosition(YES); + } + if (result != kCGErrorSuccess) { + return SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed"); + } + + /* The hide/unhide calls are redundant most of the time, but they fix + * https://bugzilla.libsdl.org/show_bug.cgi?id=2550 + */ + if (enabled) { + [NSCursor hide]; + } else { + [NSCursor unhide]; + } + return true; +} + +static bool Cocoa_CaptureMouse(SDL_Window *window) +{ + /* our Cocoa event code already tracks the mouse outside the window, + so all we have to do here is say "okay" and do what we always do. */ + return true; +} + +static SDL_MouseButtonFlags Cocoa_GetGlobalMouseState(float *x, float *y) +{ + const NSUInteger cocoaButtons = [NSEvent pressedMouseButtons]; + const NSPoint cocoaLocation = [NSEvent mouseLocation]; + SDL_MouseButtonFlags result = 0; + + *x = cocoaLocation.x; + *y = (CGDisplayPixelsHigh(kCGDirectMainDisplay) - cocoaLocation.y); + + result |= (cocoaButtons & (1 << 0)) ? SDL_BUTTON_LMASK : 0; + result |= (cocoaButtons & (1 << 1)) ? SDL_BUTTON_RMASK : 0; + result |= (cocoaButtons & (1 << 2)) ? SDL_BUTTON_MMASK : 0; + result |= (cocoaButtons & (1 << 3)) ? SDL_BUTTON_X1MASK : 0; + result |= (cocoaButtons & (1 << 4)) ? SDL_BUTTON_X2MASK : 0; + + return result; +} + +bool Cocoa_InitMouse(SDL_VideoDevice *_this) +{ + NSPoint location; + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_MouseData *internal = (SDL_MouseData *)SDL_calloc(1, sizeof(SDL_MouseData)); + if (internal == NULL) { + return false; + } + + mouse->internal = internal; + mouse->CreateCursor = Cocoa_CreateCursor; + mouse->CreateSystemCursor = Cocoa_CreateSystemCursor; + mouse->ShowCursor = Cocoa_ShowCursor; + mouse->FreeCursor = Cocoa_FreeCursor; + mouse->WarpMouse = Cocoa_WarpMouse; + mouse->WarpMouseGlobal = Cocoa_WarpMouseGlobal; + mouse->SetRelativeMouseMode = Cocoa_SetRelativeMouseMode; + mouse->CaptureMouse = Cocoa_CaptureMouse; + mouse->GetGlobalMouseState = Cocoa_GetGlobalMouseState; + + SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor()); + + location = [NSEvent mouseLocation]; + internal->lastMoveX = location.x; + internal->lastMoveY = location.y; + return true; +} + +static void Cocoa_HandleTitleButtonEvent(SDL_VideoDevice *_this, NSEvent *event) +{ + SDL_Window *window; + NSWindow *nswindow = [event window]; + + /* You might land in this function before SDL_Init if showing a message box. + Don't dereference a NULL pointer if that happens. */ + if (_this == NULL) { + return; + } + + for (window = _this->windows; window; window = window->next) { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + if (data && data.nswindow == nswindow) { + switch ([event type]) { + case NSEventTypeLeftMouseDown: + case NSEventTypeRightMouseDown: + case NSEventTypeOtherMouseDown: + [data.listener setFocusClickPending:[event buttonNumber]]; + break; + case NSEventTypeLeftMouseUp: + case NSEventTypeRightMouseUp: + case NSEventTypeOtherMouseUp: + [data.listener clearFocusClickPending:[event buttonNumber]]; + break; + default: + break; + } + break; + } + } +} + +static NSWindow *Cocoa_MouseFocus; + +NSWindow *Cocoa_GetMouseFocus() +{ + return Cocoa_MouseFocus; +} + +void Cocoa_HandleMouseEvent(SDL_VideoDevice *_this, NSEvent *event) +{ + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; + SDL_Mouse *mouse; + SDL_MouseData *data; + NSPoint location; + CGFloat lastMoveX, lastMoveY; + float deltaX, deltaY; + bool seenWarp; + + // All events except NSEventTypeMouseExited can only happen if the window + // has mouse focus, so we'll always set the focus even if we happen to miss + // NSEventTypeMouseEntered, which apparently happens if the window is + // created under the mouse on macOS 12.7 + NSEventType event_type = [event type]; + if (event_type == NSEventTypeMouseExited) { + Cocoa_MouseFocus = NULL; + } else { + Cocoa_MouseFocus = [event window]; + } + + switch (event_type) { + case NSEventTypeMouseEntered: + case NSEventTypeMouseExited: + // Focus is handled above + return; + + case NSEventTypeMouseMoved: + case NSEventTypeLeftMouseDragged: + case NSEventTypeRightMouseDragged: + case NSEventTypeOtherMouseDragged: + break; + + case NSEventTypeLeftMouseDown: + case NSEventTypeLeftMouseUp: + case NSEventTypeRightMouseDown: + case NSEventTypeRightMouseUp: + case NSEventTypeOtherMouseDown: + case NSEventTypeOtherMouseUp: + if ([event window]) { + NSRect windowRect = [[[event window] contentView] frame]; + if (!NSMouseInRect([event locationInWindow], windowRect, NO)) { + Cocoa_HandleTitleButtonEvent(_this, event); + return; + } + } + return; + + default: + // Ignore any other events. + return; + } + + mouse = SDL_GetMouse(); + data = (SDL_MouseData *)mouse->internal; + if (!data) { + return; // can happen when returning from fullscreen Space on shutdown + } + + seenWarp = data->seenWarp; + data->seenWarp = NO; + + location = [NSEvent mouseLocation]; + lastMoveX = data->lastMoveX; + lastMoveY = data->lastMoveY; + data->lastMoveX = location.x; + data->lastMoveY = location.y; + DLog("Last seen mouse: (%g, %g)", location.x, location.y); + + // Non-relative movement is handled in -[SDL3Cocoa_WindowListener mouseMoved:] + if (!mouse->relative_mode) { + return; + } + + // Ignore events that aren't inside the client area (i.e. title bar.) + if ([event window]) { + NSRect windowRect = [[[event window] contentView] frame]; + if (!NSMouseInRect([event locationInWindow], windowRect, NO)) { + return; + } + } + + deltaX = [event deltaX]; + deltaY = [event deltaY]; + + if (seenWarp) { + deltaX += (lastMoveX - data->lastWarpX); + deltaY += ((CGDisplayPixelsHigh(kCGDirectMainDisplay) - lastMoveY) - data->lastWarpY); + + DLog("Motion was (%g, %g), offset to (%g, %g)", [event deltaX], [event deltaY], deltaX, deltaY); + } + + SDL_SendMouseMotion(Cocoa_GetEventTimestamp([event timestamp]), mouse->focus, mouseID, true, deltaX, deltaY); +} + +void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) +{ + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; + SDL_MouseWheelDirection direction; + CGFloat x, y; + + x = -[event deltaX]; + y = [event deltaY]; + direction = SDL_MOUSEWHEEL_NORMAL; + + if ([event isDirectionInvertedFromDevice] == YES) { + direction = SDL_MOUSEWHEEL_FLIPPED; + } + + /* For discrete scroll events from conventional mice, always send a full tick. + For continuous scroll events from trackpads, send fractional deltas for smoother scrolling. */ + if (![event hasPreciseScrollingDeltas]) { + if (x > 0) { + x = SDL_ceil(x); + } else if (x < 0) { + x = SDL_floor(x); + } + if (y > 0) { + y = SDL_ceil(y); + } else if (y < 0) { + y = SDL_floor(y); + } + } + + SDL_SendMouseWheel(Cocoa_GetEventTimestamp([event timestamp]), window, mouseID, x, y, direction); +} + +void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y) +{ + /* This makes Cocoa_HandleMouseEvent ignore the delta caused by the warp, + * since it gets included in the next movement event. + */ + SDL_MouseData *data = (SDL_MouseData *)SDL_GetMouse()->internal; + data->lastWarpX = x; + data->lastWarpY = y; + data->seenWarp = true; + + DLog("(%g, %g)", x, y); +} + +void Cocoa_QuitMouse(SDL_VideoDevice *_this) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + if (mouse) { + if (mouse->internal) { + SDL_free(mouse->internal); + mouse->internal = NULL; + } + } +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.h new file mode 100644 index 0000000..33d7b0e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.h @@ -0,0 +1,88 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoaopengl_h_ +#define SDL_cocoaopengl_h_ + +#ifdef SDL_VIDEO_OPENGL_CGL + +#import +#import + +// We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + +struct SDL_GLDriverData +{ + int initialized; +}; + +@interface SDL3OpenGLContext : NSOpenGLContext +{ + SDL_AtomicInt dirty; + SDL_Window *window; + CVDisplayLinkRef displayLink; + @public + SDL_Mutex *swapIntervalMutex; + @public + SDL_Condition *swapIntervalCond; + @public + SDL_AtomicInt swapIntervalSetting; + @public + SDL_AtomicInt swapIntervalsPassed; +} + +- (id)initWithFormat:(NSOpenGLPixelFormat *)format + shareContext:(NSOpenGLContext *)share; +- (void)scheduleUpdate; +- (void)updateIfNeeded; +- (void)movedToNewScreen; +- (void)setWindow:(SDL_Window *)window; +- (SDL_Window *)window; +- (void)explicitUpdate; +- (void)cleanup; + +@property(retain, nonatomic) NSOpenGLPixelFormat *openglPixelFormat; // macOS 10.10 has -[NSOpenGLContext pixelFormat] but this handles older OS releases. + +@end + +// OpenGL functions +extern bool Cocoa_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_FunctionPointer Cocoa_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern void Cocoa_GL_UnloadLibrary(SDL_VideoDevice *_this); +extern SDL_GLContext Cocoa_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool Cocoa_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool Cocoa_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern bool Cocoa_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // SDL_VIDEO_OPENGL_CGL + +#endif // SDL_cocoaopengl_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.m new file mode 100644 index 0000000..34002ec --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengl.m @@ -0,0 +1,559 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +// NSOpenGL implementation of SDL OpenGL support + +#ifdef SDL_VIDEO_OPENGL_CGL +#include "SDL_cocoavideo.h" +#include "SDL_cocoaopengl.h" +#include "SDL_cocoaopengles.h" + +#include +#include +#include + +#include +#include "../../SDL_hints_c.h" + +#define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" + +// We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + +// _Nullable is available starting Xcode 7 +#ifdef __has_feature +#if __has_feature(nullability) +#define HAS_FEATURE_NULLABLE +#endif +#endif +#ifndef HAS_FEATURE_NULLABLE +#define _Nullable +#endif + +static bool SDL_opengl_async_dispatch = false; + +static void SDLCALL SDL_OpenGLAsyncDispatchChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + SDL_opengl_async_dispatch = SDL_GetStringBoolean(hint, false); +} + +static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, CVOptionFlags flagsIn, CVOptionFlags *flagsOut, void *displayLinkContext) +{ + SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)displayLinkContext; + + // printf("DISPLAY LINK! %u\n", (unsigned int) SDL_GetTicks()); + const int setting = SDL_GetAtomicInt(&nscontext->swapIntervalSetting); + if (setting != 0) { // nothing to do if vsync is disabled, don't even lock + SDL_LockMutex(nscontext->swapIntervalMutex); + SDL_AddAtomicInt(&nscontext->swapIntervalsPassed, 1); + SDL_SignalCondition(nscontext->swapIntervalCond); + SDL_UnlockMutex(nscontext->swapIntervalMutex); + } + + return kCVReturnSuccess; +} + +@implementation SDL3OpenGLContext : NSOpenGLContext + +- (id)initWithFormat:(NSOpenGLPixelFormat *)format + shareContext:(NSOpenGLContext *)share +{ + self = [super initWithFormat:format shareContext:share]; + if (self) { + self.openglPixelFormat = format; + SDL_SetAtomicInt(&self->dirty, 0); + self->window = NULL; + SDL_SetAtomicInt(&self->swapIntervalSetting, 0); + SDL_SetAtomicInt(&self->swapIntervalsPassed, 0); + self->swapIntervalCond = SDL_CreateCondition(); + self->swapIntervalMutex = SDL_CreateMutex(); + if (!self->swapIntervalCond || !self->swapIntervalMutex) { + return nil; + } + + // !!! FIXME: check return values. + CVDisplayLinkCreateWithActiveCGDisplays(&self->displayLink); + CVDisplayLinkSetOutputCallback(self->displayLink, &DisplayLinkCallback, (__bridge void *_Nullable)self); + CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(self->displayLink, [self CGLContextObj], [format CGLPixelFormatObj]); + CVDisplayLinkStart(displayLink); + } + + SDL_AddHintCallback(SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH, SDL_OpenGLAsyncDispatchChanged, NULL); + return self; +} + +- (void)movedToNewScreen +{ + if (self->displayLink) { + CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(self->displayLink, [self CGLContextObj], [[self openglPixelFormat] CGLPixelFormatObj]); + } +} + +- (void)scheduleUpdate +{ + SDL_AddAtomicInt(&self->dirty, 1); +} + +// This should only be called on the thread on which a user is using the context. +- (void)updateIfNeeded +{ + const int value = SDL_SetAtomicInt(&self->dirty, 0); + if (value > 0) { + // We call the real underlying update here, since -[SDL3OpenGLContext update] just calls us. + [self explicitUpdate]; + } +} + +// This should only be called on the thread on which a user is using the context. +- (void)update +{ + // This ensures that regular 'update' calls clear the atomic dirty flag. + [self scheduleUpdate]; + [self updateIfNeeded]; +} + +// Updates the drawable for the contexts and manages related state. +- (void)setWindow:(SDL_Window *)newWindow +{ + if (self->window) { + SDL_CocoaWindowData *oldwindowdata = (__bridge SDL_CocoaWindowData *)self->window->internal; + + // Make sure to remove us from the old window's context list, or we'll get scheduled updates from it too. + NSMutableArray *contexts = oldwindowdata.nscontexts; + @synchronized(contexts) { + [contexts removeObject:self]; + } + } + + self->window = newWindow; + + if (newWindow) { + SDL_CocoaWindowData *windowdata = (__bridge SDL_CocoaWindowData *)newWindow->internal; + NSView *contentview = windowdata.sdlContentView; + + // Now sign up for scheduled updates for the new window. + NSMutableArray *contexts = windowdata.nscontexts; + @synchronized(contexts) { + [contexts addObject:self]; + } + + if ([self view] != contentview) { + if ([NSThread isMainThread]) { + [self setView:contentview]; + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + [self setView:contentview]; + }); + } + if (self == [NSOpenGLContext currentContext]) { + [self explicitUpdate]; + } else { + [self scheduleUpdate]; + } + } + } else { + if ([NSThread isMainThread]) { + [self setView:nil]; + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ [self setView:nil]; }); + } + } +} + +- (SDL_Window *)window +{ + return self->window; +} + +- (void)explicitUpdate +{ + if ([NSThread isMainThread]) { + [super update]; + } else { + if (SDL_opengl_async_dispatch) { + dispatch_async(dispatch_get_main_queue(), ^{ + [super update]; + }); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + [super update]; + }); + } + } +} + +- (void)cleanup +{ + [self setWindow:NULL]; + + SDL_RemoveHintCallback(SDL_HINT_MAC_OPENGL_ASYNC_DISPATCH, SDL_OpenGLAsyncDispatchChanged, NULL); + if (self->displayLink) { + CVDisplayLinkRelease(self->displayLink); + self->displayLink = nil; + } + if (self->swapIntervalCond) { + SDL_DestroyCondition(self->swapIntervalCond); + self->swapIntervalCond = NULL; + } + if (self->swapIntervalMutex) { + SDL_DestroyMutex(self->swapIntervalMutex); + self->swapIntervalMutex = NULL; + } +} + +@end + +bool Cocoa_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + // Load the OpenGL library + if (path == NULL) { + path = SDL_GetHint(SDL_HINT_OPENGL_LIBRARY); + } + if (path == NULL) { + path = DEFAULT_OPENGL; + } + _this->gl_config.dll_handle = SDL_LoadObject(path); + if (!_this->gl_config.dll_handle) { + return false; + } + SDL_strlcpy(_this->gl_config.driver_path, path, + SDL_arraysize(_this->gl_config.driver_path)); + return true; +} + +SDL_FunctionPointer Cocoa_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + return SDL_LoadFunction(_this->gl_config.dll_handle, proc); +} + +void Cocoa_GL_UnloadLibrary(SDL_VideoDevice *_this) +{ + SDL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; +} + +SDL_GLContext Cocoa_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + SDL_DisplayData *displaydata = (SDL_DisplayData *)display->internal; + NSOpenGLPixelFormatAttribute attr[32]; + NSOpenGLPixelFormat *fmt; + SDL3OpenGLContext *context; + SDL_GLContext sdlcontext; + NSOpenGLContext *share_context = nil; + int i = 0; + const char *glversion; + int glversion_major; + int glversion_minor; + NSOpenGLPixelFormatAttribute profile; + int interval; + int opaque; + + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { +#ifdef SDL_VIDEO_OPENGL_EGL + // Switch to EGL based functions + Cocoa_GL_UnloadLibrary(_this); + _this->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; + _this->GL_GetProcAddress = Cocoa_GLES_GetProcAddress; + _this->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary; + _this->GL_CreateContext = Cocoa_GLES_CreateContext; + _this->GL_MakeCurrent = Cocoa_GLES_MakeCurrent; + _this->GL_SetSwapInterval = Cocoa_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = Cocoa_GLES_GetSwapInterval; + _this->GL_SwapWindow = Cocoa_GLES_SwapWindow; + _this->GL_DestroyContext = Cocoa_GLES_DestroyContext; + + if (!Cocoa_GLES_LoadLibrary(_this, NULL)) { + return NULL; + } + return Cocoa_GLES_CreateContext(_this, window); +#else + SDL_SetError("SDL not configured with EGL support"); + return NULL; +#endif + } + + attr[i++] = NSOpenGLPFAAllowOfflineRenderers; + + profile = NSOpenGLProfileVersionLegacy; + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_CORE) { + profile = NSOpenGLProfileVersion3_2Core; + } + attr[i++] = NSOpenGLPFAOpenGLProfile; + attr[i++] = profile; + + attr[i++] = NSOpenGLPFAColorSize; + attr[i++] = SDL_BYTESPERPIXEL(display->current_mode->format) * 8; + + attr[i++] = NSOpenGLPFADepthSize; + attr[i++] = _this->gl_config.depth_size; + + if (_this->gl_config.double_buffer) { + attr[i++] = NSOpenGLPFADoubleBuffer; + } + + if (_this->gl_config.stereo) { + attr[i++] = NSOpenGLPFAStereo; + } + + if (_this->gl_config.stencil_size) { + attr[i++] = NSOpenGLPFAStencilSize; + attr[i++] = _this->gl_config.stencil_size; + } + + if ((_this->gl_config.accum_red_size + + _this->gl_config.accum_green_size + + _this->gl_config.accum_blue_size + + _this->gl_config.accum_alpha_size) > 0) { + attr[i++] = NSOpenGLPFAAccumSize; + attr[i++] = _this->gl_config.accum_red_size + _this->gl_config.accum_green_size + _this->gl_config.accum_blue_size + _this->gl_config.accum_alpha_size; + } + + if (_this->gl_config.multisamplebuffers) { + attr[i++] = NSOpenGLPFASampleBuffers; + attr[i++] = _this->gl_config.multisamplebuffers; + } + + if (_this->gl_config.multisamplesamples) { + attr[i++] = NSOpenGLPFASamples; + attr[i++] = _this->gl_config.multisamplesamples; + attr[i++] = NSOpenGLPFANoRecovery; + } + if (_this->gl_config.floatbuffers) { + attr[i++] = NSOpenGLPFAColorFloat; + } + + if (_this->gl_config.accelerated >= 0) { + if (_this->gl_config.accelerated) { + attr[i++] = NSOpenGLPFAAccelerated; + } else { + attr[i++] = NSOpenGLPFARendererID; + attr[i++] = kCGLRendererGenericFloatID; + } + } + + attr[i++] = NSOpenGLPFAScreenMask; + attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display); + attr[i] = 0; + + fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; + if (fmt == nil) { + SDL_SetError("Failed creating OpenGL pixel format"); + return NULL; + } + + if (_this->gl_config.share_with_current_context) { + share_context = (__bridge NSOpenGLContext *)SDL_GL_GetCurrentContext(); + } + + context = [[SDL3OpenGLContext alloc] initWithFormat:fmt shareContext:share_context]; + + if (context == nil) { + SDL_SetError("Failed creating OpenGL context"); + return NULL; + } + + sdlcontext = (SDL_GLContext)CFBridgingRetain(context); + + // vsync is handled separately by synchronizing with a display link. + interval = 0; + [context setValues:&interval forParameter:NSOpenGLCPSwapInterval]; + + opaque = (window->flags & SDL_WINDOW_TRANSPARENT) ? 0 : 1; + [context setValues:&opaque forParameter:NSOpenGLCPSurfaceOpacity]; + + if (!Cocoa_GL_MakeCurrent(_this, window, sdlcontext)) { + SDL_GL_DestroyContext(sdlcontext); + SDL_SetError("Failed making OpenGL context current"); + return NULL; + } + + if (_this->gl_config.major_version < 3 && + _this->gl_config.profile_mask == 0 && + _this->gl_config.flags == 0) { + // This is a legacy profile, so to match other backends, we're done. + } else { + const GLubyte *(APIENTRY * glGetStringFunc)(GLenum); + + glGetStringFunc = (const GLubyte *(APIENTRY *)(GLenum))SDL_GL_GetProcAddress("glGetString"); + if (!glGetStringFunc) { + SDL_GL_DestroyContext(sdlcontext); + SDL_SetError("Failed getting OpenGL glGetString entry point"); + return NULL; + } + + glversion = (const char *)glGetStringFunc(GL_VERSION); + if (glversion == NULL) { + SDL_GL_DestroyContext(sdlcontext); + SDL_SetError("Failed getting OpenGL context version"); + return NULL; + } + + if (SDL_sscanf(glversion, "%d.%d", &glversion_major, &glversion_minor) != 2) { + SDL_GL_DestroyContext(sdlcontext); + SDL_SetError("Failed parsing OpenGL context version"); + return NULL; + } + + if ((glversion_major < _this->gl_config.major_version) || + ((glversion_major == _this->gl_config.major_version) && (glversion_minor < _this->gl_config.minor_version))) { + SDL_GL_DestroyContext(sdlcontext); + SDL_SetError("Failed creating OpenGL context at version requested"); + return NULL; + } + + /* In the future we'll want to do this, but to match other platforms + we'll leave the OpenGL version the way it is for now + */ + // _this->gl_config.major_version = glversion_major; + // _this->gl_config.minor_version = glversion_minor; + } + return sdlcontext; + } +} + +bool Cocoa_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + @autoreleasepool { + if (context) { + SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)context; + if ([nscontext window] != window) { + [nscontext setWindow:window]; + [nscontext updateIfNeeded]; + } + [nscontext makeCurrentContext]; + } else { + [NSOpenGLContext clearCurrentContext]; + } + + return true; + } +} + +bool Cocoa_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + @autoreleasepool { + SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)SDL_GL_GetCurrentContext(); + bool result; + + if (nscontext == nil) { + result = SDL_SetError("No current OpenGL context"); + } else { + SDL_LockMutex(nscontext->swapIntervalMutex); + SDL_SetAtomicInt(&nscontext->swapIntervalsPassed, 0); + SDL_SetAtomicInt(&nscontext->swapIntervalSetting, interval); + SDL_UnlockMutex(nscontext->swapIntervalMutex); + result = true; + } + + return result; + } +} + +bool Cocoa_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + @autoreleasepool { + SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)SDL_GL_GetCurrentContext(); + if (nscontext) { + *interval = SDL_GetAtomicInt(&nscontext->swapIntervalSetting); + return true; + } else { + return SDL_SetError("no OpenGL context"); + } + } +} + +bool Cocoa_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)SDL_GL_GetCurrentContext(); + SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->internal; + const int setting = SDL_GetAtomicInt(&nscontext->swapIntervalSetting); + + if (setting == 0) { + // nothing to do if vsync is disabled, don't even lock + } else if (setting < 0) { // late swap tearing + SDL_LockMutex(nscontext->swapIntervalMutex); + while (SDL_GetAtomicInt(&nscontext->swapIntervalsPassed) == 0) { + SDL_WaitCondition(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); + } + SDL_SetAtomicInt(&nscontext->swapIntervalsPassed, 0); + SDL_UnlockMutex(nscontext->swapIntervalMutex); + } else { + SDL_LockMutex(nscontext->swapIntervalMutex); + do { // always wait here so we know we just hit a swap interval. + SDL_WaitCondition(nscontext->swapIntervalCond, nscontext->swapIntervalMutex); + } while ((SDL_GetAtomicInt(&nscontext->swapIntervalsPassed) % setting) != 0); + SDL_SetAtomicInt(&nscontext->swapIntervalsPassed, 0); + SDL_UnlockMutex(nscontext->swapIntervalMutex); + } + + // { static Uint64 prev = 0; const Uint64 now = SDL_GetTicks(); const unsigned int diff = (unsigned int) (now - prev); prev = now; printf("GLSWAPBUFFERS TICKS %u\n", diff); } + + /* on 10.14 ("Mojave") and later, this deadlocks if two contexts in two + threads try to swap at the same time, so put a mutex around it. */ + SDL_LockMutex(videodata.swaplock); + [nscontext flushBuffer]; + [nscontext updateIfNeeded]; + SDL_UnlockMutex(videodata.swaplock); + return true; + } +} + +static void DispatchedDestroyContext(SDL_GLContext context) +{ + @autoreleasepool { + SDL3OpenGLContext *nscontext = (__bridge SDL3OpenGLContext *)context; + [nscontext cleanup]; + CFRelease(context); + } +} + +bool Cocoa_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + if ([NSThread isMainThread]) { + DispatchedDestroyContext(context); + } else { + if (SDL_opengl_async_dispatch) { + dispatch_async(dispatch_get_main_queue(), ^{ + DispatchedDestroyContext(context); + }); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + DispatchedDestroyContext(context); + }); + } + } + + return true; +} + +// We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // SDL_VIDEO_OPENGL_CGL diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.h new file mode 100644 index 0000000..5cf97e3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoaopengles_h_ +#define SDL_cocoaopengles_h_ + +#ifdef SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +// OpenGLES functions +#define Cocoa_GLES_GetAttribute SDL_EGL_GetAttribute +#define Cocoa_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define Cocoa_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define Cocoa_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define Cocoa_GLES_SetSwapInterval SDL_EGL_SetSwapInterval + +extern bool Cocoa_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_GLContext Cocoa_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool Cocoa_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern bool Cocoa_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_EGLSurface Cocoa_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_VIDEO_OPENGL_EGL + +#endif // SDL_cocoaopengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.m new file mode 100644 index 0000000..053ddc9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoaopengles.m @@ -0,0 +1,156 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_COCOA) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "SDL_cocoavideo.h" +#include "SDL_cocoaopengles.h" +#include "SDL_cocoaopengl.h" + +// EGL implementation of SDL OpenGL support + +bool Cocoa_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + // If the profile requested is not GL ES, switch over to WIN_GL functions + if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { +#ifdef SDL_VIDEO_OPENGL_CGL + Cocoa_GLES_UnloadLibrary(_this); + _this->GL_LoadLibrary = Cocoa_GL_LoadLibrary; + _this->GL_GetProcAddress = Cocoa_GL_GetProcAddress; + _this->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; + _this->GL_CreateContext = Cocoa_GL_CreateContext; + _this->GL_MakeCurrent = Cocoa_GL_MakeCurrent; + _this->GL_SetSwapInterval = Cocoa_GL_SetSwapInterval; + _this->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; + _this->GL_SwapWindow = Cocoa_GL_SwapWindow; + _this->GL_DestroyContext = Cocoa_GL_DestroyContext; + _this->GL_GetEGLSurface = NULL; + return Cocoa_GL_LoadLibrary(_this, path); +#else + return SDL_SetError("SDL not configured with OpenGL/CGL support"); +#endif + } + + if (_this->egl_data == NULL) { + return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform); + } + + return true; +} + +SDL_GLContext Cocoa_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_GLContext context; + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + +#ifdef SDL_VIDEO_OPENGL_CGL + if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) { + // Switch to CGL based functions + Cocoa_GLES_UnloadLibrary(_this); + _this->GL_LoadLibrary = Cocoa_GL_LoadLibrary; + _this->GL_GetProcAddress = Cocoa_GL_GetProcAddress; + _this->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; + _this->GL_CreateContext = Cocoa_GL_CreateContext; + _this->GL_MakeCurrent = Cocoa_GL_MakeCurrent; + _this->GL_SetSwapInterval = Cocoa_GL_SetSwapInterval; + _this->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; + _this->GL_SwapWindow = Cocoa_GL_SwapWindow; + _this->GL_DestroyContext = Cocoa_GL_DestroyContext; + _this->GL_GetEGLSurface = NULL; + + if (!Cocoa_GL_LoadLibrary(_this, NULL)) { + return NULL; + } + + return Cocoa_GL_CreateContext(_this, window); + } +#endif + + context = SDL_EGL_CreateContext(_this, data.egl_surface); + return context; + } +} + +bool Cocoa_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + @autoreleasepool { + SDL_EGL_DestroyContext(_this, context); + } + return true; +} + +bool Cocoa_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + return SDL_EGL_SwapBuffers(_this, ((__bridge SDL_CocoaWindowData *)window->internal).egl_surface); + } +} + +bool Cocoa_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + @autoreleasepool { + return SDL_EGL_MakeCurrent(_this, window ? ((__bridge SDL_CocoaWindowData *)window->internal).egl_surface : EGL_NO_SURFACE, context); + } +} + +bool Cocoa_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + NSView *v; + // The current context is lost in here; save it and reset it. + SDL_CocoaWindowData *windowdata = (__bridge SDL_CocoaWindowData *)window->internal; + SDL_Window *current_win = SDL_GL_GetCurrentWindow(); + SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); + + if (_this->egl_data == NULL) { +// !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. +#if 0 // When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. + SDL_assert(!_this->gl_config.driver_loaded); +#endif + if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform)) { + SDL_EGL_UnloadLibrary(_this); + return false; + } + _this->gl_config.driver_loaded = 1; + } + + // Create the GLES window surface + v = windowdata.nswindow.contentView; + windowdata.egl_surface = SDL_EGL_CreateSurface(_this, window, (__bridge NativeWindowType)[v layer]); + + if (windowdata.egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + + return Cocoa_GLES_MakeCurrent(_this, current_win, current_ctx); + } +} + +SDL_EGLSurface Cocoa_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + return ((__bridge SDL_CocoaWindowData *)window->internal).egl_surface; + } +} + +#endif // SDL_VIDEO_DRIVER_COCOA && SDL_VIDEO_OPENGL_EGL diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.h new file mode 100644 index 0000000..b659ba4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.h @@ -0,0 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoapen_h_ +#define SDL_cocoapenm_h_ + +#include "SDL_cocoavideo.h" + +extern bool Cocoa_InitPen(SDL_VideoDevice *_this); +extern bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event); // return false if we didn't handle this event. +extern void Cocoa_QuitPen(SDL_VideoDevice *_this); + +#endif // SDL_cocoapen_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.m new file mode 100644 index 0000000..6c30bfb --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoapen.m @@ -0,0 +1,178 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoapen.h" +#include "SDL_cocoavideo.h" + +#include "../../events/SDL_pen_c.h" + +bool Cocoa_InitPen(SDL_VideoDevice *_this) +{ + return true; +} + +typedef struct Cocoa_PenHandle +{ + NSUInteger deviceid; + NSUInteger toolid; + SDL_PenID pen; + bool is_eraser; +} Cocoa_PenHandle; + +typedef struct FindPenByDeviceAndToolIDData +{ + NSUInteger deviceid; + NSUInteger toolid; + void *handle; +} FindPenByDeviceAndToolIDData; + +static bool FindPenByDeviceAndToolID(void *handle, void *userdata) +{ + const Cocoa_PenHandle *cocoa_handle = (const Cocoa_PenHandle *) handle; + FindPenByDeviceAndToolIDData *data = (FindPenByDeviceAndToolIDData *) userdata; + + if (cocoa_handle->deviceid != data->deviceid) { + return false; + } else if (cocoa_handle->toolid != data->toolid) { + return false; + } + data->handle = handle; + return true; +} + +static Cocoa_PenHandle *Cocoa_FindPenByDeviceID(NSUInteger deviceid, NSUInteger toolid) +{ + FindPenByDeviceAndToolIDData data; + data.deviceid = deviceid; + data.toolid = toolid; + data.handle = NULL; + SDL_FindPenByCallback(FindPenByDeviceAndToolID, &data); + return (Cocoa_PenHandle *) data.handle; +} + +static void Cocoa_HandlePenProximityEvent(SDL_CocoaWindowData *_data, NSEvent *event) +{ + const NSUInteger devid = [event deviceID]; + const NSUInteger toolid = [event pointingDeviceID]; + + if (event.enteringProximity) { // new pen coming! + const NSPointingDeviceType devtype = [event pointingDeviceType]; + const bool is_eraser = (devtype == NSPointingDeviceTypeEraser); + const bool is_pen = (devtype == NSPointingDeviceTypePen); + if (!is_eraser && !is_pen) { + return; // we ignore other things, which hopefully is right. + } + + Cocoa_PenHandle *handle = (Cocoa_PenHandle *) SDL_calloc(1, sizeof (*handle)); + if (!handle) { + return; // oh well. + } + + // Cocoa offers almost none of this information as specifics, but can without warning offer any of these specific things. + SDL_PenInfo peninfo; + SDL_zero(peninfo); + peninfo.capabilities = SDL_PEN_CAPABILITY_PRESSURE | SDL_PEN_CAPABILITY_ROTATION | SDL_PEN_CAPABILITY_XTILT | SDL_PEN_CAPABILITY_YTILT | SDL_PEN_CAPABILITY_TANGENTIAL_PRESSURE | (is_eraser ? SDL_PEN_CAPABILITY_ERASER : 0); + peninfo.max_tilt = 90.0f; + peninfo.num_buttons = 2; + peninfo.subtype = is_eraser ? SDL_PEN_TYPE_ERASER : SDL_PEN_TYPE_PEN; + + handle->deviceid = devid; + handle->toolid = toolid; + handle->is_eraser = is_eraser; + handle->pen = SDL_AddPenDevice(Cocoa_GetEventTimestamp([event timestamp]), NULL, &peninfo, handle); + if (!handle->pen) { + SDL_free(handle); // oh well. + } + } else { // old pen leaving! + Cocoa_PenHandle *handle = Cocoa_FindPenByDeviceID(devid, toolid); + if (handle) { + SDL_RemovePenDevice(Cocoa_GetEventTimestamp([event timestamp]), handle->pen); + SDL_free(handle); + } + } +} + +static void Cocoa_HandlePenPointEvent(SDL_CocoaWindowData *_data, NSEvent *event) +{ + const Uint64 timestamp = Cocoa_GetEventTimestamp([event timestamp]); + Cocoa_PenHandle *handle = Cocoa_FindPenByDeviceID([event deviceID], [event pointingDeviceID]); + if (!handle) { + return; + } + + const SDL_PenID pen = handle->pen; + const NSEventButtonMask buttons = [event buttonMask]; + const NSPoint tilt = [event tilt]; + const NSPoint point = [event locationInWindow]; + const bool is_touching = (buttons & NSEventButtonMaskPenTip) != 0; + SDL_Window *window = _data.window; + + SDL_SendPenTouch(timestamp, pen, window, handle->is_eraser, is_touching); + SDL_SendPenMotion(timestamp, pen, window, (float) point.x, (float) (window->h - point.y)); + SDL_SendPenButton(timestamp, pen, window, 1, ((buttons & NSEventButtonMaskPenLowerSide) != 0)); + SDL_SendPenButton(timestamp, pen, window, 2, ((buttons & NSEventButtonMaskPenUpperSide) != 0)); + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_PRESSURE, [event pressure]); + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_ROTATION, [event rotation]); + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_XTILT, ((float) tilt.x) * 90.0f); + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_YTILT, ((float) -tilt.y) * 90.0f); + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_TANGENTIAL_PRESSURE, event.tangentialPressure); +} + +bool Cocoa_HandlePenEvent(SDL_CocoaWindowData *_data, NSEvent *event) +{ + NSEventType type = [event type]; + + if ((type != NSEventTypeTabletPoint) && (type != NSEventTypeTabletProximity)) { + const NSEventSubtype subtype = [event subtype]; + if (subtype == NSEventSubtypeTabletPoint) { + type = NSEventTypeTabletPoint; + } else if (subtype == NSEventSubtypeTabletProximity) { + type = NSEventTypeTabletProximity; + } else { + return false; // not a tablet event. + } + } + + if (type == NSEventTypeTabletPoint) { + Cocoa_HandlePenPointEvent(_data, event); + } else if (type == NSEventTypeTabletProximity) { + Cocoa_HandlePenProximityEvent(_data, event); + } else { + return false; // not a tablet event. + } + + return true; +} + +static void Cocoa_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdata) +{ + SDL_free(handle); +} + +void Cocoa_QuitPen(SDL_VideoDevice *_this) +{ + SDL_RemoveAllPenDevices(Cocoa_FreePenHandle, NULL); +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.h new file mode 100644 index 0000000..9ca3c64 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoashape_h_ +#define SDL_cocoashape_h_ + +extern bool Cocoa_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); + +#endif // SDL_cocoashape_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.m new file mode 100644 index 0000000..26081bd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoashape.m @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include "SDL_cocoavideo.h" +#include "SDL_cocoashape.h" + + +bool Cocoa_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape) +{ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + BOOL ignoresMouseEvents = NO; + + if (shape) { + SDL_FPoint point; + SDL_GetGlobalMouseState(&point.x, &point.y); + point.x -= window->x; + point.y -= window->y; + if (point.x >= 0.0f && point.x < window->w && + point.y >= 0.0f && point.y < window->h) { + int x = (int)SDL_roundf((point.x / (window->w - 1)) * (shape->w - 1)); + int y = (int)SDL_roundf((point.y / (window->h - 1)) * (shape->h - 1)); + Uint8 a; + + if (!SDL_ReadSurfacePixel(shape, x, y, NULL, NULL, NULL, &a) || a == SDL_ALPHA_TRANSPARENT) { + ignoresMouseEvents = YES; + } + } + } + data.nswindow.ignoresMouseEvents = ignoresMouseEvents; + return true; +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.h new file mode 100644 index 0000000..353fb43 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.h @@ -0,0 +1,71 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoavideo_h_ +#define SDL_cocoavideo_h_ + +#include + +#include +#include +#include + +#include "../SDL_sysvideo.h" + +#include "SDL_cocoaclipboard.h" +#include "SDL_cocoaevents.h" +#include "SDL_cocoakeyboard.h" +#include "SDL_cocoamodes.h" +#include "SDL_cocoamouse.h" +#include "SDL_cocoaopengl.h" +#include "SDL_cocoawindow.h" +#include "SDL_cocoapen.h" + +// Private display data + +@class SDL3TranslatorResponder; + +typedef enum +{ + OptionAsAltNone, + OptionAsAltOnlyLeft, + OptionAsAltOnlyRight, + OptionAsAltBoth, +} OptionAsAlt; + +@interface SDL_CocoaVideoData : NSObject +@property(nonatomic) int allow_spaces; +@property(nonatomic) int trackpad_is_touch_only; +@property(nonatomic) unsigned int modifierFlags; +@property(nonatomic) void *key_layout; +@property(nonatomic) SDL3TranslatorResponder *fieldEdit; +@property(nonatomic) NSInteger clipboard_count; +@property(nonatomic) IOPMAssertionID screensaver_assertion; +@property(nonatomic) SDL_Mutex *swaplock; +@property(nonatomic) OptionAsAlt option_as_alt; +@end + +// Utility functions +extern SDL_SystemTheme Cocoa_GetSystemTheme(void); +extern NSImage *Cocoa_CreateImage(SDL_Surface *surface); + +#endif // SDL_cocoavideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.m new file mode 100644 index 0000000..81baf78 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavideo.m @@ -0,0 +1,337 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#if !__has_feature(objc_arc) +#error SDL must be built with Objective-C ARC (automatic reference counting) enabled +#endif + +#include "SDL_cocoavideo.h" +#include "SDL_cocoavulkan.h" +#include "SDL_cocoametalview.h" +#include "SDL_cocoaopengles.h" +#include "SDL_cocoamessagebox.h" +#include "SDL_cocoashape.h" + +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" + +@implementation SDL_CocoaVideoData + +@end + +// Initialization/Query functions +static bool Cocoa_VideoInit(SDL_VideoDevice *_this); +static void Cocoa_VideoQuit(SDL_VideoDevice *_this); + +// Cocoa driver bootstrap functions + +static void Cocoa_DeleteDevice(SDL_VideoDevice *device) +{ + @autoreleasepool { + if (device->wakeup_lock) { + SDL_DestroyMutex(device->wakeup_lock); + } + CFBridgingRelease(device->internal); + SDL_free(device); + } +} + +static SDL_VideoDevice *Cocoa_CreateDevice(void) +{ + @autoreleasepool { + SDL_VideoDevice *device; + SDL_CocoaVideoData *data; + + if (![NSThread isMainThread]) { + return NULL; // this doesn't SDL_SetError() because SDL_VideoInit is just going to overwrite it. + } + + Cocoa_RegisterApp(); + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device) { + data = [[SDL_CocoaVideoData alloc] init]; + } else { + data = nil; + } + if (!data) { + SDL_free(device); + return NULL; + } + device->internal = (SDL_VideoData *)CFBridgingRetain(data); + device->wakeup_lock = SDL_CreateMutex(); + device->system_theme = Cocoa_GetSystemTheme(); + + // Set the function pointers + device->VideoInit = Cocoa_VideoInit; + device->VideoQuit = Cocoa_VideoQuit; + device->GetDisplayBounds = Cocoa_GetDisplayBounds; + device->GetDisplayUsableBounds = Cocoa_GetDisplayUsableBounds; + device->GetDisplayModes = Cocoa_GetDisplayModes; + device->SetDisplayMode = Cocoa_SetDisplayMode; + device->PumpEvents = Cocoa_PumpEvents; + device->WaitEventTimeout = Cocoa_WaitEventTimeout; + device->SendWakeupEvent = Cocoa_SendWakeupEvent; + device->SuspendScreenSaver = Cocoa_SuspendScreenSaver; + + device->CreateSDLWindow = Cocoa_CreateWindow; + device->SetWindowTitle = Cocoa_SetWindowTitle; + device->SetWindowIcon = Cocoa_SetWindowIcon; + device->SetWindowPosition = Cocoa_SetWindowPosition; + device->SetWindowSize = Cocoa_SetWindowSize; + device->SetWindowMinimumSize = Cocoa_SetWindowMinimumSize; + device->SetWindowMaximumSize = Cocoa_SetWindowMaximumSize; + device->SetWindowAspectRatio = Cocoa_SetWindowAspectRatio; + device->SetWindowOpacity = Cocoa_SetWindowOpacity; + device->GetWindowSizeInPixels = Cocoa_GetWindowSizeInPixels; + device->ShowWindow = Cocoa_ShowWindow; + device->HideWindow = Cocoa_HideWindow; + device->RaiseWindow = Cocoa_RaiseWindow; + device->MaximizeWindow = Cocoa_MaximizeWindow; + device->MinimizeWindow = Cocoa_MinimizeWindow; + device->RestoreWindow = Cocoa_RestoreWindow; + device->SetWindowBordered = Cocoa_SetWindowBordered; + device->SetWindowResizable = Cocoa_SetWindowResizable; + device->SetWindowAlwaysOnTop = Cocoa_SetWindowAlwaysOnTop; + device->SetWindowFullscreen = Cocoa_SetWindowFullscreen; + device->GetWindowICCProfile = Cocoa_GetWindowICCProfile; + device->GetDisplayForWindow = Cocoa_GetDisplayForWindow; + device->SetWindowMouseRect = Cocoa_SetWindowMouseRect; + device->SetWindowMouseGrab = Cocoa_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = Cocoa_SetWindowKeyboardGrab; + device->DestroyWindow = Cocoa_DestroyWindow; + device->SetWindowHitTest = Cocoa_SetWindowHitTest; + device->AcceptDragAndDrop = Cocoa_AcceptDragAndDrop; + device->UpdateWindowShape = Cocoa_UpdateWindowShape; + device->FlashWindow = Cocoa_FlashWindow; + device->SetWindowFocusable = Cocoa_SetWindowFocusable; + device->SetWindowParent = Cocoa_SetWindowParent; + device->SetWindowModal = Cocoa_SetWindowModal; + device->SyncWindow = Cocoa_SyncWindow; + +#ifdef SDL_VIDEO_OPENGL_CGL + device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; + device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; + device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; + device->GL_CreateContext = Cocoa_GL_CreateContext; + device->GL_MakeCurrent = Cocoa_GL_MakeCurrent; + device->GL_SetSwapInterval = Cocoa_GL_SetSwapInterval; + device->GL_GetSwapInterval = Cocoa_GL_GetSwapInterval; + device->GL_SwapWindow = Cocoa_GL_SwapWindow; + device->GL_DestroyContext = Cocoa_GL_DestroyContext; + device->GL_GetEGLSurface = NULL; +#endif +#ifdef SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_CGL + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { +#endif + device->GL_LoadLibrary = Cocoa_GLES_LoadLibrary; + device->GL_GetProcAddress = Cocoa_GLES_GetProcAddress; + device->GL_UnloadLibrary = Cocoa_GLES_UnloadLibrary; + device->GL_CreateContext = Cocoa_GLES_CreateContext; + device->GL_MakeCurrent = Cocoa_GLES_MakeCurrent; + device->GL_SetSwapInterval = Cocoa_GLES_SetSwapInterval; + device->GL_GetSwapInterval = Cocoa_GLES_GetSwapInterval; + device->GL_SwapWindow = Cocoa_GLES_SwapWindow; + device->GL_DestroyContext = Cocoa_GLES_DestroyContext; + device->GL_GetEGLSurface = Cocoa_GLES_GetEGLSurface; +#ifdef SDL_VIDEO_OPENGL_CGL + } +#endif +#endif + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = Cocoa_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = Cocoa_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = Cocoa_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = Cocoa_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = Cocoa_Vulkan_DestroySurface; +#endif + +#ifdef SDL_VIDEO_METAL + device->Metal_CreateView = Cocoa_Metal_CreateView; + device->Metal_DestroyView = Cocoa_Metal_DestroyView; + device->Metal_GetLayer = Cocoa_Metal_GetLayer; +#endif + + device->StartTextInput = Cocoa_StartTextInput; + device->StopTextInput = Cocoa_StopTextInput; + device->UpdateTextInputArea = Cocoa_UpdateTextInputArea; + + device->SetClipboardData = Cocoa_SetClipboardData; + device->GetClipboardData = Cocoa_GetClipboardData; + device->HasClipboardData = Cocoa_HasClipboardData; + + device->free = Cocoa_DeleteDevice; + + device->device_caps = VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT | + VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; + return device; + } +} + +VideoBootStrap COCOA_bootstrap = { + "cocoa", "SDL Cocoa video driver", + Cocoa_CreateDevice, + Cocoa_ShowMessageBox, + false +}; + +static bool Cocoa_VideoInit(SDL_VideoDevice *_this) +{ + @autoreleasepool { + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + + Cocoa_InitModes(_this); + Cocoa_InitKeyboard(_this); + if (!Cocoa_InitMouse(_this)) { + return false; + } + if (!Cocoa_InitPen(_this)) { + return false; + } + + // Assume we have a mouse and keyboard + // We could use GCMouse and GCKeyboard if we needed to, as is done in SDL_uikitevents.m + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); + + data.allow_spaces = SDL_GetHintBoolean(SDL_HINT_VIDEO_MAC_FULLSCREEN_SPACES, true); + data.trackpad_is_touch_only = SDL_GetHintBoolean(SDL_HINT_TRACKPAD_IS_TOUCH_ONLY, false); + SDL_AddHintCallback(SDL_HINT_VIDEO_MAC_FULLSCREEN_MENU_VISIBILITY, Cocoa_MenuVisibilityCallback, NULL); + + data.swaplock = SDL_CreateMutex(); + if (!data.swaplock) { + return false; + } + + return true; + } +} + +void Cocoa_VideoQuit(SDL_VideoDevice *_this) +{ + @autoreleasepool { + SDL_CocoaVideoData *data = (__bridge SDL_CocoaVideoData *)_this->internal; + Cocoa_QuitModes(_this); + Cocoa_QuitKeyboard(_this); + Cocoa_QuitMouse(_this); + Cocoa_QuitPen(_this); + SDL_DestroyMutex(data.swaplock); + data.swaplock = NULL; + } +} + +// This function assumes that it's called from within an autorelease pool +SDL_SystemTheme Cocoa_GetSystemTheme(void) +{ + if (@available(macOS 10.14, *)) { + NSAppearance* appearance = [[NSApplication sharedApplication] effectiveAppearance]; + + if ([appearance.name containsString: @"Dark"]) { + return SDL_SYSTEM_THEME_DARK; + } + } + return SDL_SYSTEM_THEME_LIGHT; +} + +// This function assumes that it's called from within an autorelease pool +NSImage *Cocoa_CreateImage(SDL_Surface *surface) +{ + NSImage *img; + + img = [[NSImage alloc] initWithSize:NSMakeSize(surface->w, surface->h)]; + if (img == nil) { + return nil; + } + + SDL_Surface **images = SDL_GetSurfaceImages(surface, NULL); + if (!images) { + return nil; + } + + for (int i = 0; images[i]; ++i) { + SDL_Surface *converted = SDL_ConvertSurface(images[i], SDL_PIXELFORMAT_RGBA32); + if (!converted) { + SDL_free(images); + return nil; + } + + // Premultiply the alpha channel + SDL_PremultiplySurfaceAlpha(converted, false); + + NSBitmapImageRep *imgrep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL + pixelsWide:converted->w + pixelsHigh:converted->h + bitsPerSample:8 + samplesPerPixel:4 + hasAlpha:YES + isPlanar:NO + colorSpaceName:NSDeviceRGBColorSpace + bytesPerRow:converted->pitch + bitsPerPixel:SDL_BITSPERPIXEL(converted->format)]; + if (imgrep == nil) { + SDL_free(images); + SDL_DestroySurface(converted); + return nil; + } + + // Copy the pixels + Uint8 *pixels = [imgrep bitmapData]; + SDL_memcpy(pixels, converted->pixels, (size_t)converted->h * converted->pitch); + SDL_DestroySurface(converted); + + // Add the image representation + [img addRepresentation:imgrep]; + } + SDL_free(images); + + return img; +} + +/* + * macOS log support. + * + * This doesn't really have anything to do with the interfaces of the SDL video + * subsystem, but we need to stuff this into an Objective-C source code file. + * + * NOTE: This is copypasted in src/video/uikit/SDL_uikitvideo.m! Be sure both + * versions remain identical! + */ + +void SDL_NSLog(const char *prefix, const char *text) +{ + @autoreleasepool { + NSString *nsText = [NSString stringWithUTF8String:text]; + if (prefix && *prefix) { + NSString *nsPrefix = [NSString stringWithUTF8String:prefix]; + NSLog(@"%@%@", nsPrefix, nsText); + } else { + NSLog(@"%@", nsText); + } + } +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.h new file mode 100644 index 0000000..86e634e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.h. + */ + +#include "SDL_internal.h" + +#ifndef SDL_cocoavulkan_h_ +#define SDL_cocoavulkan_h_ + +#include "../SDL_vulkan_internal.h" +#include "../SDL_sysvideo.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_COCOA) + +extern bool Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void Cocoa_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* Cocoa_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool Cocoa_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void Cocoa_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); + +#endif + +#endif // SDL_cocoavulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.m new file mode 100644 index 0000000..a440627 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoavulkan.m @@ -0,0 +1,304 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.c. + */ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_COCOA) + +#include "SDL_cocoavideo.h" +#include "SDL_cocoawindow.h" + +#include "SDL_cocoametalview.h" +#include "SDL_cocoavulkan.h" + +#include + +const char *defaultPaths[] = { + "vulkan.framework/vulkan", + "libvulkan.1.dylib", + "libvulkan.dylib", + "MoltenVK.framework/MoltenVK", + "libMoltenVK.dylib" +}; + +// Since libSDL is most likely a .dylib, need RTLD_DEFAULT not RTLD_SELF. +#define DEFAULT_HANDLE RTLD_DEFAULT + +bool Cocoa_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasMetalSurfaceExtension = false; + bool hasMacOSSurfaceExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan Portability library is already loaded."); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + + if (!path) { + // Handle the case where Vulkan Portability is linked statically. + vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, + "vkGetInstanceProcAddr"); + } + + if (vkGetInstanceProcAddr) { + _this->vulkan_config.loader_handle = DEFAULT_HANDLE; + } else { + const char **paths; + const char *foundPath = NULL; + int numPaths; + int i; + + if (path) { + paths = &path; + numPaths = 1; + } else { + /* Look for framework or .dylib packaged with the application + * instead. */ + paths = defaultPaths; + numPaths = SDL_arraysize(defaultPaths); + } + + for (i = 0; i < numPaths && _this->vulkan_config.loader_handle == NULL; i++) { + foundPath = paths[i]; + _this->vulkan_config.loader_handle = SDL_LoadObject(foundPath); + } + + if (_this->vulkan_config.loader_handle == NULL) { + return SDL_SetError("Failed to load Vulkan Portability library"); + } + + SDL_strlcpy(_this->vulkan_config.loader_path, foundPath, + SDL_arraysize(_this->vulkan_config.loader_path)); + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + } + + if (!vkGetInstanceProcAddr) { + SDL_SetError("Failed to find %s in either executable or %s: %s", + "vkGetInstanceProcAddr", + _this->vulkan_config.loader_path, + (const char *)dlerror()); + goto fail; + } + + _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + if (!extensions) { + goto fail; + } + for (Uint32 i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_EXT_METAL_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasMetalSurfaceExtension = true; + } else if (SDL_strcmp(VK_MVK_MACOS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasMacOSSurfaceExtension = true; + } + } + SDL_free(extensions); + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan Portability library doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else if (!hasMetalSurfaceExtension && !hasMacOSSurfaceExtension) { + SDL_SetError("Installed Vulkan Portability library doesn't implement the " VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " VK_MVK_MACOS_SURFACE_EXTENSION_NAME " extensions"); + goto fail; + } + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void Cocoa_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + if (_this->vulkan_config.loader_handle != DEFAULT_HANDLE) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + } + _this->vulkan_config.loader_handle = NULL; + } +} + +char const* const* Cocoa_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ + static const char *const extensionsForCocoa[] = { + VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME, VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME + }; + if(count) { + *count = SDL_arraysize(extensionsForCocoa); + } + return extensionsForCocoa; +} + +static bool Cocoa_Vulkan_CreateSurfaceViaMetalView(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface, + PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT, + PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK) +{ + VkResult rc; + SDL_MetalView metalview = Cocoa_Metal_CreateView(_this, window); + if (metalview == NULL) { + return false; + } + + if (vkCreateMetalSurfaceEXT) { + VkMetalSurfaceCreateInfoEXT createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.pLayer = (__bridge const CAMetalLayer *) + Cocoa_Metal_GetLayer(_this, metalview); + rc = vkCreateMetalSurfaceEXT(instance, &createInfo, allocator, surface); + if (rc != VK_SUCCESS) { + Cocoa_Metal_DestroyView(_this, metalview); + return SDL_SetError("vkCreateMetalSurfaceEXT failed: %s", SDL_Vulkan_GetResultString(rc)); + } + } else { + VkMacOSSurfaceCreateInfoMVK createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.pView = (const void *)metalview; + rc = vkCreateMacOSSurfaceMVK(instance, &createInfo, + NULL, surface); + if (rc != VK_SUCCESS) { + Cocoa_Metal_DestroyView(_this, metalview); + return SDL_SetError("vkCreateMacOSSurfaceMVK failed: %s", SDL_Vulkan_GetResultString(rc)); + } + } + + /* Unfortunately there's no SDL_Vulkan_DestroySurface function we can call + * Metal_DestroyView from. Right now the metal view's ref count is +2 (one + * from returning a new view object in CreateView, and one because it's + * a subview of the window.) If we release the view here to make it +1, it + * will be destroyed when the window is destroyed. + * + * TODO: Now that we have SDL_Vulkan_DestroySurface someone with enough + * knowledge of Metal can proceed. */ + CFBridgingRelease(metalview); + + return true; // success! +} + +bool Cocoa_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT = + (PFN_vkCreateMetalSurfaceEXT)vkGetInstanceProcAddr( + instance, + "vkCreateMetalSurfaceEXT"); + PFN_vkCreateMacOSSurfaceMVK vkCreateMacOSSurfaceMVK = + (PFN_vkCreateMacOSSurfaceMVK)vkGetInstanceProcAddr( + instance, + "vkCreateMacOSSurfaceMVK"); + VkResult rc; + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + if (!vkCreateMetalSurfaceEXT && !vkCreateMacOSSurfaceMVK) { + return SDL_SetError(VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " VK_MVK_MACOS_SURFACE_EXTENSION_NAME + " extensions are not enabled in the Vulkan instance."); + } + + if (window->flags & SDL_WINDOW_EXTERNAL) { + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + if (![data.sdlContentView.layer isKindOfClass:[CAMetalLayer class]]) { + [data.sdlContentView setLayer:[CAMetalLayer layer]]; + } + + if (vkCreateMetalSurfaceEXT) { + VkMetalSurfaceCreateInfoEXT createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.pLayer = (CAMetalLayer *)data.sdlContentView.layer; + rc = vkCreateMetalSurfaceEXT(instance, &createInfo, allocator, surface); + if (rc != VK_SUCCESS) { + return SDL_SetError("vkCreateMetalSurfaceEXT failed: %s", SDL_Vulkan_GetResultString(rc)); + } + } else { + VkMacOSSurfaceCreateInfoMVK createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.pView = (__bridge const void *)data.sdlContentView; + rc = vkCreateMacOSSurfaceMVK(instance, &createInfo, + allocator, surface); + if (rc != VK_SUCCESS) { + return SDL_SetError("vkCreateMacOSSurfaceMVK failed: %s", SDL_Vulkan_GetResultString(rc)); + } + } + } + } else { + return Cocoa_Vulkan_CreateSurfaceViaMetalView(_this, window, instance, allocator, surface, vkCreateMetalSurfaceEXT, vkCreateMacOSSurfaceMVK); + } + + return true; +} + +void Cocoa_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + // TODO: Add CFBridgingRelease(metalview) here perhaps? + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h new file mode 100644 index 0000000..6df69f4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.h @@ -0,0 +1,199 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_cocoawindow_h_ +#define SDL_cocoawindow_h_ + +#import + +#ifdef SDL_VIDEO_OPENGL_EGL +#include "../SDL_egl_c.h" +#endif + +#define SDL_METALVIEW_TAG 255 + +@class SDL_CocoaWindowData; + +typedef enum +{ + PENDING_OPERATION_NONE = 0x00, + PENDING_OPERATION_ENTER_FULLSCREEN = 0x01, + PENDING_OPERATION_LEAVE_FULLSCREEN = 0x02, + PENDING_OPERATION_MINIMIZE = 0x04, + PENDING_OPERATION_ZOOM = 0x08 +} PendingWindowOperation; + +@interface SDL3Cocoa_WindowListener : NSResponder +{ + /* SDL_CocoaWindowData owns this Listener and has a strong reference to it. + * To avoid reference cycles, we could have either a weak or an + * unretained ref to the WindowData. */ + __weak SDL_CocoaWindowData *_data; + BOOL observingVisible; + BOOL wasCtrlLeft; + BOOL wasVisible; + BOOL isFullscreenSpace; + BOOL inFullscreenTransition; + PendingWindowOperation pendingWindowOperation; + BOOL isMoving; + BOOL isMiniaturizing; + NSInteger focusClickPending; + float pendingWindowWarpX, pendingWindowWarpY; + BOOL isDragAreaRunning; + NSTimer *liveResizeTimer; +} + +- (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent; +- (void)listen:(SDL_CocoaWindowData *)data; +- (void)pauseVisibleObservation; +- (void)resumeVisibleObservation; +- (BOOL)setFullscreenSpace:(BOOL)state; +- (BOOL)isInFullscreenSpace; +- (BOOL)isInFullscreenSpaceTransition; +- (void)addPendingWindowOperation:(PendingWindowOperation)operation; +- (void)close; + +- (BOOL)isMoving; +- (BOOL)isMovingOrFocusClickPending; +- (void)setFocusClickPending:(NSInteger)button; +- (void)clearFocusClickPending:(NSInteger)button; +- (void)updateIgnoreMouseState:(NSEvent *)theEvent; +- (void)setPendingMoveX:(float)x Y:(float)y; +- (void)windowDidFinishMoving; +- (void)onMovingOrFocusClickPendingStateCleared; + +// Window delegate functionality +- (BOOL)windowShouldClose:(id)sender; +- (void)windowDidExpose:(NSNotification *)aNotification; +- (void)windowDidChangeOcclusionState:(NSNotification *)aNotification; +- (void)windowWillStartLiveResize:(NSNotification *)aNotification; +- (void)windowDidEndLiveResize:(NSNotification *)aNotification; +- (void)windowDidMove:(NSNotification *)aNotification; +- (void)windowDidResize:(NSNotification *)aNotification; +- (void)windowDidMiniaturize:(NSNotification *)aNotification; +- (void)windowDidDeminiaturize:(NSNotification *)aNotification; +- (void)windowDidBecomeKey:(NSNotification *)aNotification; +- (void)windowDidResignKey:(NSNotification *)aNotification; +- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification; +- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification; +- (void)windowDidChangeScreen:(NSNotification *)aNotification; +- (void)windowWillEnterFullScreen:(NSNotification *)aNotification; +- (void)windowDidEnterFullScreen:(NSNotification *)aNotification; +- (void)windowWillExitFullScreen:(NSNotification *)aNotification; +- (void)windowDidExitFullScreen:(NSNotification *)aNotification; +- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions; + +// See if event is in a drag area, toggle on window dragging. +- (void)updateHitTest; +- (BOOL)processHitTest:(NSEvent *)theEvent; + +// Window event handling +- (void)mouseDown:(NSEvent *)theEvent; +- (void)rightMouseDown:(NSEvent *)theEvent; +- (void)otherMouseDown:(NSEvent *)theEvent; +- (void)mouseUp:(NSEvent *)theEvent; +- (void)rightMouseUp:(NSEvent *)theEvent; +- (void)otherMouseUp:(NSEvent *)theEvent; +- (void)mouseMoved:(NSEvent *)theEvent; +- (void)mouseDragged:(NSEvent *)theEvent; +- (void)rightMouseDragged:(NSEvent *)theEvent; +- (void)otherMouseDragged:(NSEvent *)theEvent; +- (void)scrollWheel:(NSEvent *)theEvent; +- (void)touchesBeganWithEvent:(NSEvent *)theEvent; +- (void)touchesMovedWithEvent:(NSEvent *)theEvent; +- (void)touchesEndedWithEvent:(NSEvent *)theEvent; +- (void)touchesCancelledWithEvent:(NSEvent *)theEvent; + +// Touch event handling +- (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent; + +// Tablet event handling (but these also come through on mouse events sometimes!) +- (void)tabletProximity:(NSEvent *)theEvent; +- (void)tabletPoint:(NSEvent *)theEvent; + +@end +/* *INDENT-ON* */ + +@class SDL3OpenGLContext; +@class SDL_CocoaVideoData; + +@interface SDL_CocoaWindowData : NSObject +@property(nonatomic) SDL_Window *window; +@property(nonatomic) NSWindow *nswindow; +@property(nonatomic) NSView *sdlContentView; +@property(nonatomic) NSMutableArray *nscontexts; +@property(nonatomic) BOOL in_blocking_transition; +@property(nonatomic) BOOL fullscreen_space_requested; +@property(nonatomic) BOOL was_zoomed; +@property(nonatomic) NSInteger window_number; +@property(nonatomic) NSInteger flash_request; +@property(nonatomic) SDL_Window *keyboard_focus; +@property(nonatomic) SDL3Cocoa_WindowListener *listener; +@property(nonatomic) NSModalSession modal_session; +@property(nonatomic) SDL_CocoaVideoData *videodata; +@property(nonatomic) bool pending_size; +@property(nonatomic) bool pending_position; +@property(nonatomic) bool border_toggled; + +#ifdef SDL_VIDEO_OPENGL_EGL +@property(nonatomic) EGLSurface egl_surface; +#endif +@end + +extern bool b_inModeTransition; + +extern bool Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void Cocoa_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); +extern bool Cocoa_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); +extern bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity); +extern void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); +extern SDL_FullscreenResult Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); +extern void *Cocoa_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); +extern SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Cocoa_SetWindowHitTest(SDL_Window *window, bool enabled); +extern void Cocoa_AcceptDragAndDrop(SDL_Window *window, bool accept); +extern bool Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); +extern bool Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); +extern bool Cocoa_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); +extern bool Cocoa_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); +extern bool Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); + +extern void Cocoa_MenuVisibilityCallback(void *userdata, const char *name, const char *oldValue, const char *newValue); + +#endif // SDL_cocoawindow_h_ diff --git a/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.m b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.m new file mode 100644 index 0000000..52943e8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/cocoa/SDL_cocoawindow.m @@ -0,0 +1,3277 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_COCOA + +#include // For FLT_MAX + +#include "../../events/SDL_dropevents_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" +#include "../../events/SDL_windowevents_c.h" +#include "../SDL_sysvideo.h" + +#include "SDL_cocoamouse.h" +#include "SDL_cocoaopengl.h" +#include "SDL_cocoaopengles.h" +#include "SDL_cocoavideo.h" + +#if 0 +#define DEBUG_COCOAWINDOW +#endif + +#ifdef DEBUG_COCOAWINDOW +#define DLog(fmt, ...) printf("%s: " fmt "\n", __func__, ##__VA_ARGS__) +#else +#define DLog(...) \ + do { \ + } while (0) +#endif + +#ifndef MAC_OS_X_VERSION_10_12 +#define NSEventModifierFlagCapsLock NSAlphaShiftKeyMask +#endif +#ifndef NSAppKitVersionNumber10_13_2 +#define NSAppKitVersionNumber10_13_2 1561.2 +#endif +#ifndef NSAppKitVersionNumber10_14 +#define NSAppKitVersionNumber10_14 1671 +#endif + +@implementation SDL_CocoaWindowData + +@end + +@interface NSScreen (SDL) +#if MAC_OS_X_VERSION_MAX_ALLOWED < 120000 // Added in the 12.0 SDK +@property(readonly) NSEdgeInsets safeAreaInsets; +#endif +@end + +@interface NSWindow (SDL) +// This is available as of 10.13.2, but isn't in public headers +@property(nonatomic) NSRect mouseConfinementRect; +@end + +@interface SDL3Window : NSWindow +// These are needed for borderless/fullscreen windows +- (BOOL)canBecomeKeyWindow; +- (BOOL)canBecomeMainWindow; +- (void)sendEvent:(NSEvent *)event; +- (void)doCommandBySelector:(SEL)aSelector; + +// Handle drag-and-drop of files onto the SDL window. +- (NSDragOperation)draggingEntered:(id)sender; +- (void)draggingExited:(id)sender; +- (NSDragOperation)draggingUpdated:(id)sender; +- (BOOL)performDragOperation:(id)sender; +- (BOOL)wantsPeriodicDraggingUpdates; +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem; + +- (SDL_Window *)findSDLWindow; +@end + +@implementation SDL3Window + +- (BOOL)validateMenuItem:(NSMenuItem *)menuItem +{ + /* Only allow using the macOS native fullscreen toggle menubar item if the + * window is resizable and not in a SDL fullscreen mode. + */ + if ([menuItem action] == @selector(toggleFullScreen:)) { + SDL_Window *window = [self findSDLWindow]; + if (!window) { + return NO; + } + + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + if ((window->flags & SDL_WINDOW_FULLSCREEN) && ![data.listener isInFullscreenSpace]) { + return NO; + } else if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + return NO; + } + } + return [super validateMenuItem:menuItem]; +} + +- (BOOL)canBecomeKeyWindow +{ + SDL_Window *window = [self findSDLWindow]; + if (window && !(window->flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_NOT_FOCUSABLE))) { + return YES; + } else { + return NO; + } +} + +- (BOOL)canBecomeMainWindow +{ + SDL_Window *window = [self findSDLWindow]; + if (window && !(window->flags & (SDL_WINDOW_TOOLTIP | SDL_WINDOW_NOT_FOCUSABLE)) && !SDL_WINDOW_IS_POPUP(window)) { + return YES; + } else { + return NO; + } +} + +- (void)sendEvent:(NSEvent *)event +{ + id delegate; + [super sendEvent:event]; + + if ([event type] != NSEventTypeLeftMouseUp) { + return; + } + + delegate = [self delegate]; + if (![delegate isKindOfClass:[SDL3Cocoa_WindowListener class]]) { + return; + } + + if ([delegate isMoving]) { + [delegate windowDidFinishMoving]; + } +} + +/* We'll respond to selectors by doing nothing so we don't beep. + * The escape key gets converted to a "cancel" selector, etc. + */ +- (void)doCommandBySelector:(SEL)aSelector +{ + // NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector)); +} + +- (NSDragOperation)draggingEntered:(id)sender +{ + if (([sender draggingSourceOperationMask] & NSDragOperationGeneric) == NSDragOperationGeneric) { + return NSDragOperationGeneric; + } else if (([sender draggingSourceOperationMask] & NSDragOperationCopy) == NSDragOperationCopy) { + return NSDragOperationCopy; + } + + return NSDragOperationNone; // no idea what to do with this, reject it. +} + +- (void)draggingExited:(id)sender +{ + SDL_Window *sdlwindow = [self findSDLWindow]; + SDL_SendDropComplete(sdlwindow); +} + +- (NSDragOperation)draggingUpdated:(id)sender +{ + if (([sender draggingSourceOperationMask] & NSDragOperationGeneric) == NSDragOperationGeneric) { + SDL_Window *sdlwindow = [self findSDLWindow]; + NSPoint point = [sender draggingLocation]; + float x, y; + x = point.x; + y = (sdlwindow->h - point.y); + SDL_SendDropPosition(sdlwindow, x, y); + return NSDragOperationGeneric; + } else if (([sender draggingSourceOperationMask] & NSDragOperationCopy) == NSDragOperationCopy) { + SDL_Window *sdlwindow = [self findSDLWindow]; + NSPoint point = [sender draggingLocation]; + float x, y; + x = point.x; + y = (sdlwindow->h - point.y); + SDL_SendDropPosition(sdlwindow, x, y); + return NSDragOperationCopy; + } + + return NSDragOperationNone; // no idea what to do with this, reject it. +} + +- (BOOL)performDragOperation:(id)sender +{ + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". [SDL] In performDragOperation, draggingSourceOperationMask %lx, " + "expected Generic %lx, others Copy %lx, Link %lx, Private %lx, Move %lx, Delete %lx\n", + (unsigned long)[sender draggingSourceOperationMask], + (unsigned long)NSDragOperationGeneric, + (unsigned long)NSDragOperationCopy, + (unsigned long)NSDragOperationLink, + (unsigned long)NSDragOperationPrivate, + (unsigned long)NSDragOperationMove, + (unsigned long)NSDragOperationDelete); + if ([sender draggingPasteboard]) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". [SDL] In performDragOperation, valid draggingPasteboard, " + "name [%s] '%s', changeCount %ld\n", + [[[[sender draggingPasteboard] name] className] UTF8String], + [[[[sender draggingPasteboard] name] description] UTF8String], + (long)[[sender draggingPasteboard] changeCount]); + } + @autoreleasepool { + NSPasteboard *pasteboard = [sender draggingPasteboard]; + NSString *desiredType = [pasteboard availableTypeFromArray:@[ NSFilenamesPboardType, NSPasteboardTypeString ]]; + SDL_Window *sdlwindow = [self findSDLWindow]; + NSData *pboardData; + id pboardPlist; + NSString *pboardString; + NSPoint point; + float x, y; + + for (NSString *supportedType in [pasteboard types]) { + NSString *typeString = [pasteboard stringForType:supportedType]; + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". [SDL] In performDragOperation, Pasteboard type '%s', stringForType (%lu) '%s'\n", + [[supportedType description] UTF8String], + (unsigned long)[[typeString description] length], + [[typeString description] UTF8String]); + } + + if (desiredType == nil) { + return NO; // can't accept anything that's being dropped here. + } + pboardData = [pasteboard dataForType:desiredType]; + if (pboardData == nil) { + return NO; + } + SDL_assert([desiredType isEqualToString:NSFilenamesPboardType] || + [desiredType isEqualToString:NSPasteboardTypeString]); + + pboardString = [pasteboard stringForType:desiredType]; + pboardPlist = [pasteboard propertyListForType:desiredType]; + + // Use SendDropPosition to update the mouse location + point = [sender draggingLocation]; + x = point.x; + y = (sdlwindow->h - point.y); + if (x >= 0.0f && x < (float)sdlwindow->w && y >= 0.0f && y < (float)sdlwindow->h) { + SDL_SendDropPosition(sdlwindow, x, y); + } + // Use SendDropPosition to update the mouse location + + if ([desiredType isEqualToString:NSFilenamesPboardType]) { + for (NSString *path in (NSArray *)pboardPlist) { + NSURL *fileURL = [NSURL fileURLWithPath:path]; + NSNumber *isAlias = nil; + + [fileURL getResourceValue:&isAlias forKey:NSURLIsAliasFileKey error:nil]; + + // If the URL is an alias, resolve it. + if ([isAlias boolValue]) { + NSURLBookmarkResolutionOptions opts = NSURLBookmarkResolutionWithoutMounting | + NSURLBookmarkResolutionWithoutUI; + NSData *bookmark = [NSURL bookmarkDataWithContentsOfURL:fileURL error:nil]; + if (bookmark != nil) { + NSURL *resolvedURL = [NSURL URLByResolvingBookmarkData:bookmark + options:opts + relativeToURL:nil + bookmarkDataIsStale:nil + error:nil]; + if (resolvedURL != nil) { + fileURL = resolvedURL; + } + } + } + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". [SDL] In performDragOperation, desiredType '%s', " + "Submitting DropFile as (%lu) '%s'\n", + [[desiredType description] UTF8String], + (unsigned long)[[[fileURL path] description] length], + [[[fileURL path] description] UTF8String]); + if (!SDL_SendDropFile(sdlwindow, NULL, [[[fileURL path] description] UTF8String])) { + return NO; + } + } + } else if ([desiredType isEqualToString:NSPasteboardTypeString]) { + char *buffer = SDL_strdup([[pboardString description] UTF8String]); + char *saveptr = NULL; + char *token = SDL_strtok_r(buffer, "\r\n", &saveptr); + while (token) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". [SDL] In performDragOperation, desiredType '%s', " + "Submitting DropText as (%lu) '%s'\n", + [[desiredType description] UTF8String], + SDL_strlen(token), token); + if (!SDL_SendDropText(sdlwindow, token)) { + SDL_free(buffer); + return NO; + } + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + SDL_free(buffer); + } + + SDL_SendDropComplete(sdlwindow); + return YES; + } +} + +- (BOOL)wantsPeriodicDraggingUpdates +{ + return NO; +} + +- (SDL_Window *)findSDLWindow +{ + SDL_Window *sdlwindow = NULL; + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + + // !!! FIXME: is there a better way to do this? + if (_this) { + for (sdlwindow = _this->windows; sdlwindow; sdlwindow = sdlwindow->next) { + NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)sdlwindow->internal).nswindow; + if (nswindow == self) { + break; + } + } + } + + return sdlwindow; +} + +@end + +bool b_inModeTransition; + +static CGFloat SqDistanceToRect(const NSPoint *point, const NSRect *rect) +{ + NSPoint edge = *point; + CGFloat left = NSMinX(*rect), right = NSMaxX(*rect); + CGFloat bottom = NSMinX(*rect), top = NSMaxY(*rect); + NSPoint delta; + + if (point->x < left) { + edge.x = left; + } else if (point->x > right) { + edge.x = right; + } + + if (point->y < bottom) { + edge.y = bottom; + } else if (point->y > top) { + edge.y = top; + } + + delta = NSMakePoint(edge.x - point->x, edge.y - point->y); + return delta.x * delta.x + delta.y * delta.y; +} + +static NSScreen *ScreenForPoint(const NSPoint *point) +{ + NSScreen *screen; + + // Do a quick check first to see if the point lies on a specific screen + for (NSScreen *candidate in [NSScreen screens]) { + if (NSPointInRect(*point, [candidate frame])) { + screen = candidate; + break; + } + } + + // Find the screen the point is closest to + if (!screen) { + CGFloat closest = MAXFLOAT; + for (NSScreen *candidate in [NSScreen screens]) { + NSRect screenRect = [candidate frame]; + + CGFloat sqdist = SqDistanceToRect(point, &screenRect); + if (sqdist < closest) { + screen = candidate; + closest = sqdist; + } + } + } + + return screen; +} + +bool Cocoa_IsWindowInFullscreenSpace(SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + if ([data.listener isInFullscreenSpace]) { + return true; + } else { + return false; + } + } +} + +bool Cocoa_IsWindowZoomed(SDL_Window *window) +{ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = data.nswindow; + bool zoomed = false; + + // isZoomed always returns true if the window is not resizable or the window is fullscreen + if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed] && + !(window->flags & SDL_WINDOW_FULLSCREEN) && !Cocoa_IsWindowInFullscreenSpace(window)) { + // If we are at our desired floating area, then we're not zoomed + bool floating = (window->x == window->floating.x && + window->y == window->floating.y && + window->w == window->floating.w && + window->h == window->floating.h); + if (!floating) { + zoomed = true; + } + } + return zoomed; +} + +typedef enum CocoaMenuVisibility +{ + COCOA_MENU_VISIBILITY_AUTO = 0, + COCOA_MENU_VISIBILITY_NEVER, + COCOA_MENU_VISIBILITY_ALWAYS +} CocoaMenuVisibility; + +static CocoaMenuVisibility menu_visibility_hint = COCOA_MENU_VISIBILITY_AUTO; + +static void Cocoa_ToggleFullscreenSpaceMenuVisibility(SDL_Window *window) +{ + if (window && Cocoa_IsWindowInFullscreenSpace(window)) { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + // 'Auto' sets the menu to visible if fullscreen wasn't explicitly entered via SDL_SetWindowFullscreen(). + if ((menu_visibility_hint == COCOA_MENU_VISIBILITY_AUTO && !data.fullscreen_space_requested) || + menu_visibility_hint == COCOA_MENU_VISIBILITY_ALWAYS) { + [NSMenu setMenuBarVisible:YES]; + } else { + [NSMenu setMenuBarVisible:NO]; + } + } +} + +void Cocoa_MenuVisibilityCallback(void *userdata, const char *name, const char *oldValue, const char *newValue) +{ + if (newValue) { + if (*newValue == '0' || SDL_strcasecmp(newValue, "false") == 0) { + menu_visibility_hint = COCOA_MENU_VISIBILITY_NEVER; + } else if (*newValue == '1' || SDL_strcasecmp(newValue, "true") == 0) { + menu_visibility_hint = COCOA_MENU_VISIBILITY_ALWAYS; + } else { + menu_visibility_hint = COCOA_MENU_VISIBILITY_AUTO; + } + } else { + menu_visibility_hint = COCOA_MENU_VISIBILITY_AUTO; + } + + // Update the current menu visibility. + Cocoa_ToggleFullscreenSpaceMenuVisibility(SDL_GetKeyboardFocus()); +} + +static NSScreen *ScreenForRect(const NSRect *rect) +{ + NSPoint center = NSMakePoint(NSMidX(*rect), NSMidY(*rect)); + return ScreenForPoint(¢er); +} + +static void ConvertNSRect(NSRect *r) +{ + r->origin.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - r->origin.y - r->size.height; +} + +static void ScheduleContextUpdates(SDL_CocoaWindowData *data) +{ +// We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. +#ifdef SDL_VIDEO_OPENGL + +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + + NSOpenGLContext *currentContext; + NSMutableArray *contexts; + if (!data || !data.nscontexts) { + return; + } + + currentContext = [NSOpenGLContext currentContext]; + contexts = data.nscontexts; + @synchronized(contexts) { + for (SDL3OpenGLContext *context in contexts) { + if (context == currentContext) { + [context update]; + } else { + [context scheduleUpdate]; + } + } + } + +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#endif // SDL_VIDEO_OPENGL +} + +// !!! FIXME: this should use a hint callback. +static bool GetHintCtrlClickEmulateRightClick(void) +{ + return SDL_GetHintBoolean(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, false); +} + +static NSUInteger GetWindowWindowedStyle(SDL_Window *window) +{ + /* IF YOU CHANGE ANY FLAGS IN HERE, PLEASE READ + the NSWindowStyleMaskBorderless comments in SetupWindowData()! */ + + /* always allow miniaturization, otherwise you can't programmatically + minimize the window, whether there's a title bar or not */ + NSUInteger style = NSWindowStyleMaskMiniaturizable; + + if (!SDL_WINDOW_IS_POPUP(window)) { + if (window->flags & SDL_WINDOW_BORDERLESS) { + style |= NSWindowStyleMaskBorderless; + } else { + style |= (NSWindowStyleMaskTitled | NSWindowStyleMaskClosable); + } + if (window->flags & SDL_WINDOW_RESIZABLE) { + style |= NSWindowStyleMaskResizable; + } + } else { + style |= NSWindowStyleMaskBorderless; + } + return style; +} + +static NSUInteger GetWindowStyle(SDL_Window *window) +{ + NSUInteger style = 0; + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + style = NSWindowStyleMaskBorderless; + } else { + style = GetWindowWindowedStyle(window); + } + return style; +} + +static bool SetWindowStyle(SDL_Window *window, NSUInteger style) +{ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = data.nswindow; + + // The view responder chain gets messed with during setStyleMask + if ([data.sdlContentView nextResponder] == data.listener) { + [data.sdlContentView setNextResponder:nil]; + } + + [nswindow setStyleMask:style]; + + // The view responder chain gets messed with during setStyleMask + if ([data.sdlContentView nextResponder] != data.listener) { + [data.sdlContentView setNextResponder:data.listener]; + } + + return true; +} + +static bool ShouldAdjustCoordinatesForGrab(SDL_Window *window) +{ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + if (!data || [data.listener isMovingOrFocusClickPending]) { + return false; + } + + if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { + return false; + } + + if ((window->flags & SDL_WINDOW_MOUSE_GRABBED) || (window->mouse_rect.w > 0 && window->mouse_rect.h > 0)) { + return true; + } + return false; +} + +static bool AdjustCoordinatesForGrab(SDL_Window *window, float x, float y, CGPoint *adjusted) +{ + if (window->mouse_rect.w > 0 && window->mouse_rect.h > 0) { + SDL_Rect window_rect; + SDL_Rect mouse_rect; + + window_rect.x = 0; + window_rect.y = 0; + window_rect.w = window->w; + window_rect.h = window->h; + + if (SDL_GetRectIntersection(&window->mouse_rect, &window_rect, &mouse_rect)) { + float left = (float)window->x + mouse_rect.x; + float right = left + mouse_rect.w - 1; + float top = (float)window->y + mouse_rect.y; + float bottom = top + mouse_rect.h - 1; + if (x < left || x > right || y < top || y > bottom) { + adjusted->x = SDL_clamp(x, left, right); + adjusted->y = SDL_clamp(y, top, bottom); + return true; + } + return false; + } + } + + if (window->flags & SDL_WINDOW_MOUSE_GRABBED) { + float left = (float)window->x; + float right = left + window->w - 1; + float top = (float)window->y; + float bottom = top + window->h - 1; + if (x < left || x > right || y < top || y > bottom) { + adjusted->x = SDL_clamp(x, left, right); + adjusted->y = SDL_clamp(y, top, bottom); + return true; + } + } + return false; +} + +static void Cocoa_UpdateClipCursor(SDL_Window *window) +{ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_13_2) { + NSWindow *nswindow = data.nswindow; + SDL_Rect mouse_rect; + + SDL_zero(mouse_rect); + + if (ShouldAdjustCoordinatesForGrab(window)) { + SDL_Rect window_rect; + + window_rect.x = 0; + window_rect.y = 0; + window_rect.w = window->w; + window_rect.h = window->h; + + if (window->mouse_rect.w > 0 && window->mouse_rect.h > 0) { + SDL_GetRectIntersection(&window->mouse_rect, &window_rect, &mouse_rect); + } + + if ((window->flags & SDL_WINDOW_MOUSE_GRABBED) != 0 && + SDL_RectEmpty(&mouse_rect)) { + SDL_memcpy(&mouse_rect, &window_rect, sizeof(mouse_rect)); + } + } + + if (SDL_RectEmpty(&mouse_rect)) { + nswindow.mouseConfinementRect = NSZeroRect; + } else { + NSRect rect; + rect.origin.x = mouse_rect.x; + rect.origin.y = [nswindow contentLayoutRect].size.height - mouse_rect.y - mouse_rect.h; + rect.size.width = mouse_rect.w; + rect.size.height = mouse_rect.h; + nswindow.mouseConfinementRect = rect; + } + } else { + // Move the cursor to the nearest point in the window + if (ShouldAdjustCoordinatesForGrab(window)) { + float x, y; + CGPoint cgpoint; + + SDL_GetGlobalMouseState(&x, &y); + if (AdjustCoordinatesForGrab(window, x, y, &cgpoint)) { + Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y); + CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); + } + } + } +} + +static SDL_Window *GetParentToplevelWindow(SDL_Window *window) +{ + SDL_Window *toplevel = window; + + // Find the topmost parent + while (SDL_WINDOW_IS_POPUP(toplevel)) { + toplevel = toplevel->parent; + } + + return toplevel; +} + +static void Cocoa_SetKeyboardFocus(SDL_Window *window, bool set_active_focus) +{ + SDL_Window *toplevel = GetParentToplevelWindow(window); + SDL_CocoaWindowData *toplevel_data; + + toplevel_data = (__bridge SDL_CocoaWindowData *)toplevel->internal; + toplevel_data.keyboard_focus = window; + + if (set_active_focus && !window->is_hiding && !window->is_destroying) { + SDL_SetKeyboardFocus(window); + } +} + +static void Cocoa_SendExposedEventIfVisible(SDL_Window *window) +{ + NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; + if ([nswindow occlusionState] & NSWindowOcclusionStateVisible) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } +} + +static void Cocoa_WaitForMiniaturizable(SDL_Window *window) +{ + NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; + NSButton *button = [nswindow standardWindowButton:NSWindowMiniaturizeButton]; + if (button) { + int iterations = 0; + while (![button isEnabled] && (iterations < 100)) { + SDL_Delay(10); + SDL_PumpEvents(); + iterations++; + } + } +} + +static NSCursor *Cocoa_GetDesiredCursor(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse->cursor_shown && mouse->cur_cursor && !mouse->relative_mode) { + return (__bridge NSCursor *)mouse->cur_cursor->internal; + } + + return [NSCursor invisibleCursor]; +} + +@implementation SDL3Cocoa_WindowListener + +- (void)listen:(SDL_CocoaWindowData *)data +{ + NSNotificationCenter *center; + NSWindow *window = data.nswindow; + NSView *view = data.sdlContentView; + + _data = data; + observingVisible = YES; + wasCtrlLeft = NO; + wasVisible = [window isVisible]; + isFullscreenSpace = NO; + inFullscreenTransition = NO; + pendingWindowOperation = PENDING_OPERATION_NONE; + isMoving = NO; + isMiniaturizing = NO; + isDragAreaRunning = NO; + pendingWindowWarpX = pendingWindowWarpY = FLT_MAX; + liveResizeTimer = nil; + + center = [NSNotificationCenter defaultCenter]; + + if ([window delegate] != nil) { + [center addObserver:self selector:@selector(windowDidExpose:) name:NSWindowDidExposeNotification object:window]; + [center addObserver:self selector:@selector(windowDidChangeOcclusionState:) name:NSWindowDidChangeOcclusionStateNotification object:window]; + [center addObserver:self selector:@selector(windowWillStartLiveResize:) name:NSWindowWillStartLiveResizeNotification object:window]; + [center addObserver:self selector:@selector(windowDidEndLiveResize:) name:NSWindowDidEndLiveResizeNotification object:window]; + [center addObserver:self selector:@selector(windowWillMove:) name:NSWindowWillMoveNotification object:window]; + [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:window]; + [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:window]; + [center addObserver:self selector:@selector(windowWillMiniaturize:) name:NSWindowWillMiniaturizeNotification object:window]; + [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:window]; + [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window]; + [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window]; + [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window]; + [center addObserver:self selector:@selector(windowDidChangeBackingProperties:) name:NSWindowDidChangeBackingPropertiesNotification object:window]; + [center addObserver:self selector:@selector(windowDidChangeScreenProfile:) name:NSWindowDidChangeScreenProfileNotification object:window]; + [center addObserver:self selector:@selector(windowDidChangeScreen:) name:NSWindowDidChangeScreenNotification object:window]; + [center addObserver:self selector:@selector(windowWillEnterFullScreen:) name:NSWindowWillEnterFullScreenNotification object:window]; + [center addObserver:self selector:@selector(windowDidEnterFullScreen:) name:NSWindowDidEnterFullScreenNotification object:window]; + [center addObserver:self selector:@selector(windowWillExitFullScreen:) name:NSWindowWillExitFullScreenNotification object:window]; + [center addObserver:self selector:@selector(windowDidExitFullScreen:) name:NSWindowDidExitFullScreenNotification object:window]; + [center addObserver:self selector:@selector(windowDidFailToEnterFullScreen:) name:@"NSWindowDidFailToEnterFullScreenNotification" object:window]; + [center addObserver:self selector:@selector(windowDidFailToExitFullScreen:) name:@"NSWindowDidFailToExitFullScreenNotification" object:window]; + } else { + [window setDelegate:self]; + } + + /* Haven't found a delegate / notification that triggers when the window is + * ordered out (is not visible any more). You can be ordered out without + * minimizing, so DidMiniaturize doesn't work. (e.g. -[NSWindow orderOut:]) + */ + [window addObserver:self + forKeyPath:@"visible" + options:NSKeyValueObservingOptionNew + context:NULL]; + + [window setNextResponder:self]; + [window setAcceptsMouseMovedEvents:YES]; + + [view setNextResponder:self]; + + [view setAcceptsTouchEvents:YES]; +} + +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context +{ + if (!observingVisible) { + return; + } + + if (object == _data.nswindow && [keyPath isEqualToString:@"visible"]) { + int newVisibility = [[change objectForKey:@"new"] intValue]; + if (newVisibility) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_SHOWN, 0, 0); + } else if (![_data.nswindow isMiniaturized]) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); + } + } +} + +- (void)pauseVisibleObservation +{ + observingVisible = NO; + wasVisible = [_data.nswindow isVisible]; +} + +- (void)resumeVisibleObservation +{ + BOOL isVisible = [_data.nswindow isVisible]; + observingVisible = YES; + if (wasVisible != isVisible) { + if (isVisible) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_SHOWN, 0, 0); + } else if (![_data.nswindow isMiniaturized]) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); + } + + wasVisible = isVisible; + } +} + +- (BOOL)setFullscreenSpace:(BOOL)state +{ + SDL_Window *window = _data.window; + NSWindow *nswindow = _data.nswindow; + SDL_CocoaVideoData *videodata = ((__bridge SDL_CocoaWindowData *)window->internal).videodata; + + if (!videodata.allow_spaces) { + return NO; // Spaces are forcibly disabled. + } else if (state && window->fullscreen_exclusive) { + return NO; // we only allow you to make a Space on fullscreen desktop windows. + } else if (!state && window->last_fullscreen_exclusive_display) { + return NO; // we only handle leaving the Space on windows that were previously fullscreen desktop. + } else if (state == isFullscreenSpace) { + return YES; // already there. + } + + if (inFullscreenTransition) { + if (state) { + [self addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN]; + } else { + [self addPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN]; + } + return YES; + } + inFullscreenTransition = YES; + + // you need to be FullScreenPrimary, or toggleFullScreen doesn't work. Unset it again in windowDidExitFullScreen. + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + [nswindow performSelectorOnMainThread:@selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO]; + return YES; +} + +- (BOOL)isInFullscreenSpace +{ + return isFullscreenSpace; +} + +- (BOOL)isInFullscreenSpaceTransition +{ + return inFullscreenTransition; +} + +- (void)clearPendingWindowOperation:(PendingWindowOperation)operation +{ + pendingWindowOperation &= ~operation; +} + +- (void)addPendingWindowOperation:(PendingWindowOperation)operation +{ + pendingWindowOperation |= operation; +} + +- (BOOL)windowOperationIsPending:(PendingWindowOperation)operation +{ + return !!(pendingWindowOperation & operation); +} + +- (BOOL)hasPendingWindowOperation +{ + // A pending zoom may be deferred until leaving fullscreen, so don't block on it. + return (pendingWindowOperation & ~PENDING_OPERATION_ZOOM) != PENDING_OPERATION_NONE || + isMiniaturizing || inFullscreenTransition; +} + +- (void)close +{ + NSNotificationCenter *center; + NSWindow *window = _data.nswindow; + NSView *view = [window contentView]; + + center = [NSNotificationCenter defaultCenter]; + + if ([window delegate] != self) { + [center removeObserver:self name:NSWindowDidExposeNotification object:window]; + [center removeObserver:self name:NSWindowDidChangeOcclusionStateNotification object:window]; + [center removeObserver:self name:NSWindowWillStartLiveResizeNotification object:window]; + [center removeObserver:self name:NSWindowDidEndLiveResizeNotification object:window]; + [center removeObserver:self name:NSWindowWillMoveNotification object:window]; + [center removeObserver:self name:NSWindowDidMoveNotification object:window]; + [center removeObserver:self name:NSWindowDidResizeNotification object:window]; + [center removeObserver:self name:NSWindowWillMiniaturizeNotification object:window]; + [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:window]; + [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window]; + [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window]; + [center removeObserver:self name:NSWindowDidResignKeyNotification object:window]; + [center removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window]; + [center removeObserver:self name:NSWindowDidChangeScreenProfileNotification object:window]; + [center removeObserver:self name:NSWindowDidChangeScreenNotification object:window]; + [center removeObserver:self name:NSWindowWillEnterFullScreenNotification object:window]; + [center removeObserver:self name:NSWindowDidEnterFullScreenNotification object:window]; + [center removeObserver:self name:NSWindowWillExitFullScreenNotification object:window]; + [center removeObserver:self name:NSWindowDidExitFullScreenNotification object:window]; + [center removeObserver:self name:@"NSWindowDidFailToEnterFullScreenNotification" object:window]; + [center removeObserver:self name:@"NSWindowDidFailToExitFullScreenNotification" object:window]; + } else { + [window setDelegate:nil]; + } + + [window removeObserver:self forKeyPath:@"visible"]; + + if ([window nextResponder] == self) { + [window setNextResponder:nil]; + } + if ([view nextResponder] == self) { + [view setNextResponder:nil]; + } +} + +- (BOOL)isMoving +{ + return isMoving; +} + +- (BOOL)isMovingOrFocusClickPending +{ + return isMoving || (focusClickPending != 0); +} + +- (void)setFocusClickPending:(NSInteger)button +{ + focusClickPending |= (1 << button); +} + +- (void)clearFocusClickPending:(NSInteger)button +{ + if (focusClickPending & (1 << button)) { + focusClickPending &= ~(1 << button); + if (focusClickPending == 0) { + [self onMovingOrFocusClickPendingStateCleared]; + } + } +} + +- (void)updateIgnoreMouseState:(NSEvent *)theEvent +{ + SDL_Window *window = _data.window; + SDL_Surface *shape = (SDL_Surface *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_SHAPE_POINTER, NULL); + BOOL ignoresMouseEvents = NO; + + if (shape) { + NSPoint point = [theEvent locationInWindow]; + NSRect windowRect = [[_data.nswindow contentView] frame]; + if (NSMouseInRect(point, windowRect, NO)) { + int x = (int)SDL_roundf((point.x / (window->w - 1)) * (shape->w - 1)); + int y = (int)SDL_roundf(((window->h - point.y) / (window->h - 1)) * (shape->h - 1)); + Uint8 a; + + if (!SDL_ReadSurfacePixel(shape, x, y, NULL, NULL, NULL, &a) || a == SDL_ALPHA_TRANSPARENT) { + ignoresMouseEvents = YES; + } + } + } + _data.nswindow.ignoresMouseEvents = ignoresMouseEvents; +} + +- (void)setPendingMoveX:(float)x Y:(float)y +{ + pendingWindowWarpX = x; + pendingWindowWarpY = y; +} + +- (void)windowDidFinishMoving +{ + if (isMoving) { + isMoving = NO; + [self onMovingOrFocusClickPendingStateCleared]; + } +} + +- (void)onMovingOrFocusClickPendingStateCleared +{ + if (![self isMovingOrFocusClickPending]) { + SDL_Mouse *mouse = SDL_GetMouse(); + if (pendingWindowWarpX != FLT_MAX && pendingWindowWarpY != FLT_MAX) { + mouse->WarpMouseGlobal(pendingWindowWarpX, pendingWindowWarpY); + pendingWindowWarpX = pendingWindowWarpY = FLT_MAX; + } + if (mouse->relative_mode && mouse->focus == _data.window) { + // Move the cursor to the nearest point in the window + { + float x, y; + CGPoint cgpoint; + + SDL_GetMouseState(&x, &y); + cgpoint.x = _data.window->x + x; + cgpoint.y = _data.window->y + y; + + Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y); + + DLog("Returning cursor to (%g, %g)", cgpoint.x, cgpoint.y); + CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); + } + + mouse->SetRelativeMouseMode(true); + } else { + Cocoa_UpdateClipCursor(_data.window); + } + } +} + +- (BOOL)windowShouldClose:(id)sender +{ + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); + return NO; +} + +- (void)windowDidExpose:(NSNotification *)aNotification +{ + Cocoa_SendExposedEventIfVisible(_data.window); +} + +- (void)windowDidChangeOcclusionState:(NSNotification *)aNotification +{ + if ([_data.nswindow occlusionState] & NSWindowOcclusionStateVisible) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } else { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_OCCLUDED, 0, 0); + } +} + +- (void)windowWillStartLiveResize:(NSNotification *)aNotification +{ + // We'll try to maintain 60 FPS during live resizing + const NSTimeInterval interval = 1.0 / 60.0; + liveResizeTimer = [NSTimer scheduledTimerWithTimeInterval:interval + repeats:TRUE + block:^(NSTimer *unusedTimer) + { + SDL_OnWindowLiveResizeUpdate(_data.window); + }]; + + [[NSRunLoop currentRunLoop] addTimer:liveResizeTimer forMode:NSRunLoopCommonModes]; +} + +- (void)windowDidEndLiveResize:(NSNotification *)aNotification +{ + [liveResizeTimer invalidate]; + liveResizeTimer = nil; +} + +- (void)windowWillMove:(NSNotification *)aNotification +{ + if ([_data.nswindow isKindOfClass:[SDL3Window class]]) { + pendingWindowWarpX = pendingWindowWarpY = FLT_MAX; + isMoving = YES; + } +} + +- (void)windowDidMove:(NSNotification *)aNotification +{ + int x, y; + SDL_Window *window = _data.window; + NSWindow *nswindow = _data.nswindow; + NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + ConvertNSRect(&rect); + + if (inFullscreenTransition || b_inModeTransition) { + // We'll take care of this at the end of the transition + return; + } + + x = (int)rect.origin.x; + y = (int)rect.origin.y; + + ScheduleContextUpdates(_data); + + // Get the parent-relative coordinates for child windows. + SDL_GlobalToRelativeForWindow(window, x, y, &x, &y); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, x, y); +} + +- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize +{ + SDL_Window *window = _data.window; + + if (window->min_aspect != window->max_aspect) { + NSWindow *nswindow = _data.nswindow; + NSRect newContentRect = [nswindow contentRectForFrameRect:NSMakeRect(0, 0, frameSize.width, frameSize.height)]; + NSSize newSize = newContentRect.size; + CGFloat minAspectRatio = window->min_aspect; + CGFloat maxAspectRatio = window->max_aspect; + CGFloat aspectRatio; + + if (newSize.height > 0) { + aspectRatio = newSize.width / newSize.height; + + if (maxAspectRatio > 0.0f && aspectRatio > maxAspectRatio) { + newSize.width = SDL_roundf(newSize.height * maxAspectRatio); + } else if (minAspectRatio > 0.0f && aspectRatio < minAspectRatio) { + newSize.height = SDL_roundf(newSize.width / minAspectRatio); + } + + NSRect newFrameRect = [nswindow frameRectForContentRect:NSMakeRect(0, 0, newSize.width, newSize.height)]; + frameSize = newFrameRect.size; + } + } + return frameSize; +} + +- (void)windowDidResize:(NSNotification *)aNotification +{ + SDL_Window *window; + NSWindow *nswindow; + NSRect rect; + int x, y, w, h; + BOOL zoomed; + + if (inFullscreenTransition || b_inModeTransition) { + // We'll take care of this at the end of the transition + return; + } + + if (focusClickPending) { + focusClickPending = 0; + [self onMovingOrFocusClickPendingStateCleared]; + } + window = _data.window; + nswindow = _data.nswindow; + rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + ConvertNSRect(&rect); + x = (int)rect.origin.x; + y = (int)rect.origin.y; + w = (int)rect.size.width; + h = (int)rect.size.height; + + ScheduleContextUpdates(_data); + + /* isZoomed always returns true if the window is not resizable + * and fullscreen windows are considered zoomed. + */ + if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed] && + !(window->flags & SDL_WINDOW_FULLSCREEN) && ![self isInFullscreenSpace]) { + zoomed = YES; + } else { + zoomed = NO; + } + if (!zoomed) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + } else { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); + if ([self windowOperationIsPending:PENDING_OPERATION_MINIMIZE]) { + [nswindow miniaturize:nil]; + } + } + + /* The window can move during a resize event, such as when maximizing + or resizing from a corner */ + SDL_GlobalToRelativeForWindow(window, x, y, &x, &y); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, x, y); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, w, h); +} + +- (void)windowWillMiniaturize:(NSNotification *)aNotification +{ + isMiniaturizing = YES; + Cocoa_WaitForMiniaturizable(_data.window); +} + +- (void)windowDidMiniaturize:(NSNotification *)aNotification +{ + if (focusClickPending) { + focusClickPending = 0; + [self onMovingOrFocusClickPendingStateCleared]; + } + isMiniaturizing = NO; + [self clearPendingWindowOperation:PENDING_OPERATION_MINIMIZE]; + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); +} + +- (void)windowDidDeminiaturize:(NSNotification *)aNotification +{ + // Always send restored before maximized. + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + + if (Cocoa_IsWindowZoomed(_data.window)) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); + } + + if ([self windowOperationIsPending:PENDING_OPERATION_ENTER_FULLSCREEN]) { + SDL_UpdateFullscreenMode(_data.window, true, true); + } +} + +- (void)windowDidBecomeKey:(NSNotification *)aNotification +{ + SDL_Window *window = _data.window; + + // We're going to get keyboard events, since we're key. + // This needs to be done before restoring the relative mouse mode. + Cocoa_SetKeyboardFocus(_data.keyboard_focus ? _data.keyboard_focus : window, true); + + // If we just gained focus we need the updated mouse position + if (!(window->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE)) { + NSPoint point; + float x, y; + + point = [_data.nswindow mouseLocationOutsideOfEventStream]; + x = point.x; + y = (window->h - point.y); + + if (x >= 0.0f && x < (float)window->w && y >= 0.0f && y < (float)window->h) { + SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); + } + } + + // Check to see if someone updated the clipboard + Cocoa_CheckClipboardUpdate(_data.videodata); + + if (isFullscreenSpace && !window->fullscreen_exclusive) { + Cocoa_ToggleFullscreenSpaceMenuVisibility(window); + } + { + const unsigned int newflags = [NSEvent modifierFlags] & NSEventModifierFlagCapsLock; + _data.videodata.modifierFlags = (_data.videodata.modifierFlags & ~NSEventModifierFlagCapsLock) | newflags; + SDL_ToggleModState(SDL_KMOD_CAPS, newflags ? true : false); + } + + /* Restore fullscreen mode unless the window is deminiaturizing. + * If it is, fullscreen will be restored when deminiaturization is complete. + */ + if (!(window->flags & SDL_WINDOW_MINIMIZED) && + [self windowOperationIsPending:PENDING_OPERATION_ENTER_FULLSCREEN]) { + SDL_UpdateFullscreenMode(window, true, true); + } +} + +- (void)windowDidResignKey:(NSNotification *)aNotification +{ + // Some other window will get mouse events, since we're not key. + if (SDL_GetMouseFocus() == _data.window) { + SDL_SetMouseFocus(NULL); + } + + // Some other window will get keyboard events, since we're not key. + if (SDL_GetKeyboardFocus() == _data.window) { + SDL_SetKeyboardFocus(NULL); + } + + if (isFullscreenSpace) { + [NSMenu setMenuBarVisible:YES]; + } +} + +- (void)windowDidChangeBackingProperties:(NSNotification *)aNotification +{ + NSNumber *oldscale = [[aNotification userInfo] objectForKey:NSBackingPropertyOldScaleFactorKey]; + + if (inFullscreenTransition) { + return; + } + + if ([oldscale doubleValue] != [_data.nswindow backingScaleFactor]) { + // Send a resize event when the backing scale factor changes. + [self windowDidResize:aNotification]; + } +} + +- (void)windowDidChangeScreenProfile:(NSNotification *)aNotification +{ + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_ICCPROF_CHANGED, 0, 0); +} + +- (void)windowDidChangeScreen:(NSNotification *)aNotification +{ + // printf("WINDOWDIDCHANGESCREEN\n"); + +#ifdef SDL_VIDEO_OPENGL + + if (_data && _data.nscontexts) { + for (SDL3OpenGLContext *context in _data.nscontexts) { + [context movedToNewScreen]; + } + } + +#endif // SDL_VIDEO_OPENGL +} + +- (void)windowWillEnterFullScreen:(NSNotification *)aNotification +{ + SDL_Window *window = _data.window; + const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable | NSWindowStyleMaskTitled; + + /* For some reason, the fullscreen window won't get any mouse button events + * without the NSWindowStyleMaskTitled flag being set when entering fullscreen, + * so it's needed even if the window is borderless. + */ + SetWindowStyle(window, flags); + + _data.was_zoomed = !!(window->flags & SDL_WINDOW_MAXIMIZED); + + isFullscreenSpace = YES; + inFullscreenTransition = YES; +} + +- (void)windowDidFailToEnterFullScreen:(NSNotification *)aNotification +{ + SDL_Window *window = _data.window; + + if (window->is_destroying) { + return; + } + + SetWindowStyle(window, GetWindowStyle(window)); + + [self clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN]; + isFullscreenSpace = NO; + inFullscreenTransition = NO; + + [self windowDidExitFullScreen:nil]; +} + +- (void)windowDidEnterFullScreen:(NSNotification *)aNotification +{ + SDL_Window *window = _data.window; + + inFullscreenTransition = NO; + [self clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN]; + + if ([self windowOperationIsPending:PENDING_OPERATION_LEAVE_FULLSCREEN]) { + [self setFullscreenSpace:NO]; + } else { + Cocoa_ToggleFullscreenSpaceMenuVisibility(window); + + /* Don't recurse back into UpdateFullscreenMode() if this was hit in + * a blocking transition, as the caller is already waiting in + * UpdateFullscreenMode(). + */ + if (!_data.in_blocking_transition) { + SDL_UpdateFullscreenMode(window, true, false); + } + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); + + _data.pending_position = NO; + _data.pending_size = NO; + + /* Force the size change event in case it was delivered earlier + while the window was still animating into place. + */ + window->w = 0; + window->h = 0; + [self windowDidMove:aNotification]; + [self windowDidResize:aNotification]; + + Cocoa_UpdateClipCursor(window); + } +} + +- (void)windowWillExitFullScreen:(NSNotification *)aNotification +{ + SDL_Window *window = _data.window; + + /* If the windowed mode borders were toggled on while in a fullscreen space, + * NSWindowStyleMaskTitled has to be cleared here, or the window can end up + * in a weird, semi-decorated state upon returning to windowed mode. + */ + if (_data.border_toggled && !(window->flags & SDL_WINDOW_BORDERLESS)) { + const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable; + + SetWindowStyle(window, flags); + _data.border_toggled = false; + } + + isFullscreenSpace = NO; + inFullscreenTransition = YES; +} + +- (void)windowDidFailToExitFullScreen:(NSNotification *)aNotification +{ + SDL_Window *window = _data.window; + const NSUInteger flags = NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable; + + if (window->is_destroying) { + return; + } + + _data.pending_position = NO; + _data.pending_size = NO; + window->last_position_pending = false; + window->last_size_pending = false; + + SetWindowStyle(window, flags); + + isFullscreenSpace = YES; + inFullscreenTransition = NO; + + [self windowDidEnterFullScreen:nil]; +} + +- (void)windowDidExitFullScreen:(NSNotification *)aNotification +{ + SDL_Window *window = _data.window; + NSWindow *nswindow = _data.nswindow; + + inFullscreenTransition = NO; + _data.fullscreen_space_requested = NO; + + /* As of macOS 10.15, the window decorations can go missing sometimes after + certain fullscreen-desktop->exlusive-fullscreen->windowed mode flows + sometimes. Making sure the style mask always uses the windowed mode style + when returning to windowed mode from a space (instead of using a pending + fullscreen mode style mask) seems to work around that issue. + */ + SetWindowStyle(window, GetWindowWindowedStyle(window)); + + /* Don't recurse back into UpdateFullscreenMode() if this was hit in + * a blocking transition, as the caller is already waiting in + * UpdateFullscreenMode(). + */ + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + if (!_data.in_blocking_transition) { + SDL_UpdateFullscreenMode(window, false, false); + } + + if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + [nswindow setLevel:NSFloatingWindowLevel]; + } else { + [nswindow setLevel:kCGNormalWindowLevel]; + } + + [self clearPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN]; + + if ([self windowOperationIsPending:PENDING_OPERATION_ENTER_FULLSCREEN]) { + [self setFullscreenSpace:YES]; + } else if ([self windowOperationIsPending:PENDING_OPERATION_MINIMIZE]) { + /* There's some state that isn't quite back to normal when + * windowDidExitFullScreen triggers. For example, the minimize button on + * the title bar doesn't actually enable for another 200 milliseconds or + * so on this MacBook. Camp here and wait for that to happen before + * going on, in case we're exiting fullscreen to minimize, which need + * that window state to be normal before it will work. + */ + Cocoa_WaitForMiniaturizable(_data.window); + [self addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN]; + [nswindow miniaturize:nil]; + } else { + // Adjust the fullscreen toggle button and readd menu now that we're here. + if (window->flags & SDL_WINDOW_RESIZABLE) { + // resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } else { + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; + } + [NSMenu setMenuBarVisible:YES]; + + // Toggle zoom, if changed while fullscreen. + if ([self windowOperationIsPending:PENDING_OPERATION_ZOOM]) { + [self clearPendingWindowOperation:PENDING_OPERATION_ZOOM]; + [nswindow zoom:nil]; + } + + if (![nswindow isZoomed]) { + // Apply a pending window size, if not zoomed. + NSRect rect; + rect.origin.x = _data.pending_position ? window->pending.x : window->floating.x; + rect.origin.y = _data.pending_position ? window->pending.y : window->floating.y; + rect.size.width = _data.pending_size ? window->pending.w : window->floating.w; + rect.size.height = _data.pending_size ? window->pending.h : window->floating.h; + ConvertNSRect(&rect); + + if (_data.pending_size) { + [nswindow setContentSize:rect.size]; + } + if (_data.pending_position) { + [nswindow setFrameOrigin:rect.origin]; + } + } + + _data.pending_size = NO; + _data.pending_position = NO; + _data.was_zoomed = NO; + + /* Force the size change event in case it was delivered earlier + * while the window was still animating into place. + */ + window->w = 0; + window->h = 0; + [self windowDidMove:aNotification]; + [self windowDidResize:aNotification]; + + // FIXME: Why does the window get hidden? + if (!(window->flags & SDL_WINDOW_HIDDEN)) { + Cocoa_ShowWindow(SDL_GetVideoDevice(), window); + } + + Cocoa_UpdateClipCursor(window); + } +} + +- (NSApplicationPresentationOptions)window:(NSWindow *)window willUseFullScreenPresentationOptions:(NSApplicationPresentationOptions)proposedOptions +{ + if (_data.window->fullscreen_exclusive) { + return NSApplicationPresentationFullScreen | NSApplicationPresentationHideDock | NSApplicationPresentationHideMenuBar; + } else { + return proposedOptions; + } +} + +/* We'll respond to key events by mostly doing nothing so we don't beep. + * We could handle key messages here, but we lose some in the NSApp dispatch, + * where they get converted to action messages, etc. + */ +- (void)flagsChanged:(NSEvent *)theEvent +{ + // Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); + + /* Catch capslock in here as a special case: + https://developer.apple.com/library/archive/qa/qa1519/_index.html + Note that technote's check of keyCode doesn't work. At least on the + 10.15 beta, capslock comes through here as keycode 255, but it's safe + to send duplicate key events; SDL filters them out quickly in + SDL_SendKeyboardKey(). */ + + /* Also note that SDL_SendKeyboardKey expects all capslock events to be + keypresses; it won't toggle the mod state if you send a keyrelease. */ + const bool osenabled = ([theEvent modifierFlags] & NSEventModifierFlagCapsLock) ? true : false; + const bool sdlenabled = (SDL_GetModState() & SDL_KMOD_CAPS) ? true : false; + if (osenabled ^ sdlenabled) { + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, SDL_SCANCODE_CAPSLOCK, true); + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, SDL_SCANCODE_CAPSLOCK, false); + } +} +- (void)keyDown:(NSEvent *)theEvent +{ + // Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); +} +- (void)keyUp:(NSEvent *)theEvent +{ + // Cocoa_HandleKeyEvent(SDL_GetVideoDevice(), theEvent); +} + +/* We'll respond to selectors by doing nothing so we don't beep. + * The escape key gets converted to a "cancel" selector, etc. + */ +- (void)doCommandBySelector:(SEL)aSelector +{ + // NSLog(@"doCommandBySelector: %@\n", NSStringFromSelector(aSelector)); +} + +- (void)updateHitTest +{ + SDL_Window *window = _data.window; + BOOL draggable = NO; + + if (window->hit_test) { + float x, y; + SDL_Point point; + + SDL_GetGlobalMouseState(&x, &y); + point.x = (int)SDL_roundf(x - window->x); + point.y = (int)SDL_roundf(y - window->y); + if (point.x >= 0 && point.x < window->w && point.y >= 0 && point.y < window->h) { + if (window->hit_test(window, &point, window->hit_test_data) == SDL_HITTEST_DRAGGABLE) { + draggable = YES; + } + } + } + + if (isDragAreaRunning != draggable) { + isDragAreaRunning = draggable; + [_data.nswindow setMovableByWindowBackground:draggable]; + } +} + +- (BOOL)processHitTest:(NSEvent *)theEvent +{ + SDL_Window *window = _data.window; + + if (window->hit_test) { // if no hit-test, skip this. + const NSPoint location = [theEvent locationInWindow]; + const SDL_Point point = { (int)location.x, window->h - (((int)location.y) - 1) }; + const SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); + if (rc == SDL_HITTEST_DRAGGABLE) { + if (!isDragAreaRunning) { + isDragAreaRunning = YES; + [_data.nswindow setMovableByWindowBackground:YES]; + } + return YES; // dragging! + } else { + if (isDragAreaRunning) { + isDragAreaRunning = NO; + [_data.nswindow setMovableByWindowBackground:NO]; + return YES; // was dragging, drop event. + } + } + } + + return NO; // not a special area, carry on. +} + +static void Cocoa_SendMouseButtonClicks(SDL_Mouse *mouse, NSEvent *theEvent, SDL_Window *window, Uint8 button, bool down) +{ + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; + //const int clicks = (int)[theEvent clickCount]; + SDL_Window *focus = SDL_GetKeyboardFocus(); + + // macOS will send non-left clicks to background windows without raising them, so we need to + // temporarily adjust the mouse position when this happens, as `mouse` will be tracking + // the position in the currently-focused window. We don't (currently) send a mousemove + // event for the background window, this just makes sure the button is reported at the + // correct position in its own event. + if (focus && ([theEvent window] == ((__bridge SDL_CocoaWindowData *)focus->internal).nswindow)) { + //SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down, clicks); + SDL_SendMouseButton(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down); + } else { + const float orig_x = mouse->x; + const float orig_y = mouse->y; + const NSPoint point = [theEvent locationInWindow]; + mouse->x = (int)point.x; + mouse->y = (int)(window->h - point.y); + //SDL_SendMouseButtonClicks(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down, clicks); + SDL_SendMouseButton(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, button, down); + mouse->x = orig_x; + mouse->y = orig_y; + } +} + +- (void)mouseDown:(NSEvent *)theEvent +{ + if (Cocoa_HandlePenEvent(_data, theEvent)) { + return; // pen code handled it. + } + + SDL_Mouse *mouse = SDL_GetMouse(); + int button; + + if (!mouse) { + return; + } + + // Ignore events that aren't inside the client area (i.e. title bar.) + if ([theEvent window]) { + NSRect windowRect = [[[theEvent window] contentView] frame]; + if (!NSMouseInRect([theEvent locationInWindow], windowRect, NO)) { + return; + } + } + + switch ([theEvent buttonNumber]) { + case 0: + if (([theEvent modifierFlags] & NSEventModifierFlagControl) && + GetHintCtrlClickEmulateRightClick()) { + wasCtrlLeft = YES; + button = SDL_BUTTON_RIGHT; + } else { + wasCtrlLeft = NO; + button = SDL_BUTTON_LEFT; + } + break; + case 1: + button = SDL_BUTTON_RIGHT; + break; + case 2: + button = SDL_BUTTON_MIDDLE; + break; + default: + button = (int)[theEvent buttonNumber] + 1; + break; + } + + if (button == SDL_BUTTON_LEFT && [self processHitTest:theEvent]) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); + return; // dragging, drop event. + } + + Cocoa_SendMouseButtonClicks(mouse, theEvent, _data.window, button, true); +} + +- (void)rightMouseDown:(NSEvent *)theEvent +{ + [self mouseDown:theEvent]; +} + +- (void)otherMouseDown:(NSEvent *)theEvent +{ + [self mouseDown:theEvent]; +} + +- (void)mouseUp:(NSEvent *)theEvent +{ + if (Cocoa_HandlePenEvent(_data, theEvent)) { + return; // pen code handled it. + } + + SDL_Mouse *mouse = SDL_GetMouse(); + int button; + + if (!mouse) { + return; + } + + switch ([theEvent buttonNumber]) { + case 0: + if (wasCtrlLeft) { + button = SDL_BUTTON_RIGHT; + wasCtrlLeft = NO; + } else { + button = SDL_BUTTON_LEFT; + } + break; + case 1: + button = SDL_BUTTON_RIGHT; + break; + case 2: + button = SDL_BUTTON_MIDDLE; + break; + default: + button = (int)[theEvent buttonNumber] + 1; + break; + } + + if (button == SDL_BUTTON_LEFT && [self processHitTest:theEvent]) { + SDL_SendWindowEvent(_data.window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); + return; // stopped dragging, drop event. + } + + Cocoa_SendMouseButtonClicks(mouse, theEvent, _data.window, button, false); +} + +- (void)rightMouseUp:(NSEvent *)theEvent +{ + [self mouseUp:theEvent]; +} + +- (void)otherMouseUp:(NSEvent *)theEvent +{ + [self mouseUp:theEvent]; +} + +- (void)mouseMoved:(NSEvent *)theEvent +{ + if (Cocoa_HandlePenEvent(_data, theEvent)) { + return; // pen code handled it. + } + + SDL_MouseID mouseID = SDL_DEFAULT_MOUSE_ID; + SDL_Mouse *mouse = SDL_GetMouse(); + NSPoint point; + float x, y; + SDL_Window *window; + NSView *contentView; + + if (!mouse) { + return; + } + + if (!Cocoa_GetMouseFocus()) { + // The mouse is no longer over any window in the application + SDL_SetMouseFocus(NULL); + return; + } + + window = _data.window; + contentView = _data.sdlContentView; + point = [theEvent locationInWindow]; + + if ([contentView mouse:[contentView convertPoint:point fromView:nil] inRect:[contentView bounds]] && + [NSCursor currentCursor] != Cocoa_GetDesiredCursor()) { + // The wrong cursor is on screen, fix it. This fixes an macOS bug that is only known to + // occur in fullscreen windows on the built-in displays of newer MacBooks with camera + // notches. When the mouse is moved near the top of such a window (within about 44 units) + // and then moved back down, the cursor rects aren't respected. + [_data.nswindow invalidateCursorRectsForView:contentView]; + } + + if (window->flags & SDL_WINDOW_TRANSPARENT) { + [self updateIgnoreMouseState:theEvent]; + } + + if ([self processHitTest:theEvent]) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); + return; // dragging, drop event. + } + + if (mouse->relative_mode) { + return; + } + + x = point.x; + y = (window->h - point.y); + + if (NSAppKitVersionNumber >= NSAppKitVersionNumber10_13_2) { + // Mouse grab is taken care of by the confinement rect + } else { + CGPoint cgpoint; + if (ShouldAdjustCoordinatesForGrab(window) && + AdjustCoordinatesForGrab(window, window->x + x, window->y + y, &cgpoint)) { + Cocoa_HandleMouseWarp(cgpoint.x, cgpoint.y); + CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); + CGAssociateMouseAndMouseCursorPosition(YES); + } + } + + SDL_SendMouseMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), window, mouseID, false, x, y); +} + +- (void)mouseDragged:(NSEvent *)theEvent +{ + [self mouseMoved:theEvent]; +} + +- (void)rightMouseDragged:(NSEvent *)theEvent +{ + [self mouseMoved:theEvent]; +} + +- (void)otherMouseDragged:(NSEvent *)theEvent +{ + [self mouseMoved:theEvent]; +} + +- (void)scrollWheel:(NSEvent *)theEvent +{ + Cocoa_HandleMouseWheel(_data.window, theEvent); +} + +- (BOOL)isTouchFromTrackpad:(NSEvent *)theEvent +{ + SDL_Window *window = _data.window; + SDL_CocoaVideoData *videodata = ((__bridge SDL_CocoaWindowData *)window->internal).videodata; + + /* if this a MacBook trackpad, we'll make input look like a synthesized + event. This is backwards from reality, but better matches user + expectations. You can make it look like a generic touch device instead + with the SDL_HINT_TRACKPAD_IS_TOUCH_ONLY hint. */ + BOOL istrackpad = NO; + if (!videodata.trackpad_is_touch_only) { + @try { + istrackpad = ([theEvent subtype] == NSEventSubtypeMouseEvent); + } + @catch (NSException *e) { + /* if NSEvent type doesn't have subtype, such as NSEventTypeBeginGesture on + * macOS 10.5 to 10.10, then NSInternalInconsistencyException is thrown. + * This still prints a message to terminal so catching it's not an ideal solution. + * + * *** Assertion failure in -[NSEvent subtype] + */ + } + } + return istrackpad; +} + +- (void)touchesBeganWithEvent:(NSEvent *)theEvent +{ + NSSet *touches; + SDL_TouchID touchID; + int existingTouchCount; + const BOOL istrackpad = [self isTouchFromTrackpad:theEvent]; + + touches = [theEvent touchesMatchingPhase:NSTouchPhaseAny inView:nil]; + touchID = istrackpad ? SDL_MOUSE_TOUCHID : (SDL_TouchID)(intptr_t)[[touches anyObject] device]; + existingTouchCount = 0; + + for (NSTouch *touch in touches) { + if ([touch phase] != NSTouchPhaseBegan) { + existingTouchCount++; + } + } + if (existingTouchCount == 0) { + int numFingers; + SDL_Finger **fingers = SDL_GetTouchFingers(touchID, &numFingers); + if (fingers) { + DLog("Reset Lost Fingers: %d", numFingers); + for (--numFingers; numFingers >= 0; --numFingers) { + const SDL_Finger *finger = fingers[numFingers]; + /* trackpad touches have no window. If we really wanted one we could + * use the window that has mouse or keyboard focus. + * Sending a null window currently also prevents synthetic mouse + * events from being generated from touch events. + */ + SDL_Window *window = NULL; + SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchID, finger->id, window, SDL_EVENT_FINGER_CANCELED, 0, 0, 0); + } + SDL_free(fingers); + } + } + + DLog("Began Fingers: %lu .. existing: %d", (unsigned long)[touches count], existingTouchCount); + [self handleTouches:NSTouchPhaseBegan withEvent:theEvent]; +} + +- (void)touchesMovedWithEvent:(NSEvent *)theEvent +{ + [self handleTouches:NSTouchPhaseMoved withEvent:theEvent]; +} + +- (void)touchesEndedWithEvent:(NSEvent *)theEvent +{ + [self handleTouches:NSTouchPhaseEnded withEvent:theEvent]; +} + +- (void)touchesCancelledWithEvent:(NSEvent *)theEvent +{ + [self handleTouches:NSTouchPhaseCancelled withEvent:theEvent]; +} + +- (void)handleTouches:(NSTouchPhase)phase withEvent:(NSEvent *)theEvent +{ + NSSet *touches = [theEvent touchesMatchingPhase:phase inView:nil]; + const BOOL istrackpad = [self isTouchFromTrackpad:theEvent]; + SDL_FingerID fingerId; + float x, y; + + for (NSTouch *touch in touches) { + const SDL_TouchID touchId = istrackpad ? SDL_MOUSE_TOUCHID : (SDL_TouchID)(uintptr_t)[touch device]; + SDL_TouchDeviceType devtype = SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE; + + /* trackpad touches have no window. If we really wanted one we could + * use the window that has mouse or keyboard focus. + * Sending a null window currently also prevents synthetic mouse events + * from being generated from touch events. + */ + SDL_Window *window = NULL; + + /* TODO: Before implementing direct touch support here, we need to + * figure out whether the OS generates mouse events from them on its + * own. If it does, we should prevent SendTouch from generating + * synthetic mouse events for these touches itself (while also + * sending a window.) It will also need to use normalized window- + * relative coordinates via [touch locationInView:]. + */ + if ([touch type] == NSTouchTypeDirect) { + continue; + } + + if (SDL_AddTouch(touchId, devtype, "") < 0) { + return; + } + + fingerId = (SDL_FingerID)(uintptr_t)[touch identity]; + x = [touch normalizedPosition].x; + y = [touch normalizedPosition].y; + // Make the origin the upper left instead of the lower left + y = 1.0f - y; + + switch (phase) { + case NSTouchPhaseBegan: + SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_EVENT_FINGER_DOWN, x, y, 1.0f); + break; + case NSTouchPhaseEnded: + SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_EVENT_FINGER_UP, x, y, 1.0f); + break; + case NSTouchPhaseCancelled: + SDL_SendTouch(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, SDL_EVENT_FINGER_CANCELED, x, y, 1.0f); + break; + case NSTouchPhaseMoved: + SDL_SendTouchMotion(Cocoa_GetEventTimestamp([theEvent timestamp]), touchId, fingerId, window, x, y, 1.0f); + break; + default: + break; + } + } +} + +- (void)tabletProximity:(NSEvent *)theEvent +{ + Cocoa_HandlePenEvent(_data, theEvent); +} + +- (void)tabletPoint:(NSEvent *)theEvent +{ + Cocoa_HandlePenEvent(_data, theEvent); +} + +@end + +@interface SDL3View : NSView +{ + SDL_Window *_sdlWindow; +} + +- (void)setSDLWindow:(SDL_Window *)window; + +// The default implementation doesn't pass rightMouseDown to responder chain +- (void)rightMouseDown:(NSEvent *)theEvent; +- (BOOL)mouseDownCanMoveWindow; +- (void)drawRect:(NSRect)dirtyRect; +- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent; +- (BOOL)wantsUpdateLayer; +- (void)updateLayer; +@end + +@implementation SDL3View + +- (void)setSDLWindow:(SDL_Window *)window +{ + _sdlWindow = window; +} + +/* this is used on older macOS revisions, and newer ones which emulate old + NSOpenGLContext behaviour while still using a layer under the hood. 10.8 and + later use updateLayer, up until 10.14.2 or so, which uses drawRect without + a GraphicsContext and with a layer active instead (for OpenGL contexts). */ +- (void)drawRect:(NSRect)dirtyRect +{ + /* Force the graphics context to clear to black so we don't get a flash of + white until the app is ready to draw. In practice on modern macOS, this + only gets called for window creation and other extraordinary events. */ + BOOL transparent = (_sdlWindow->flags & SDL_WINDOW_TRANSPARENT) != 0; + if ([NSGraphicsContext currentContext]) { + NSColor *fillColor = transparent ? [NSColor clearColor] : [NSColor blackColor]; + [fillColor setFill]; + NSRectFill(dirtyRect); + } else if (self.layer) { + CFStringRef color = transparent ? kCGColorClear : kCGColorBlack; + self.layer.backgroundColor = CGColorGetConstantColor(color); + } + + Cocoa_SendExposedEventIfVisible(_sdlWindow); +} + +- (BOOL)wantsUpdateLayer +{ + return YES; +} + +// This is also called when a Metal layer is active. +- (void)updateLayer +{ + /* Force the graphics context to clear to black so we don't get a flash of + white until the app is ready to draw. In practice on modern macOS, this + only gets called for window creation and other extraordinary events. */ + BOOL transparent = (_sdlWindow->flags & SDL_WINDOW_TRANSPARENT) != 0; + CFStringRef color = transparent ? kCGColorClear : kCGColorBlack; + self.layer.backgroundColor = CGColorGetConstantColor(color); + ScheduleContextUpdates((__bridge SDL_CocoaWindowData *)_sdlWindow->internal); + Cocoa_SendExposedEventIfVisible(_sdlWindow); +} + +- (void)rightMouseDown:(NSEvent *)theEvent +{ + [[self nextResponder] rightMouseDown:theEvent]; +} + +- (BOOL)mouseDownCanMoveWindow +{ + /* Always say YES, but this doesn't do anything until we call + -[NSWindow setMovableByWindowBackground:YES], which we ninja-toggle + during mouse events when we're using a drag area. */ + return YES; +} + +- (void)resetCursorRects +{ + [super resetCursorRects]; + [self addCursorRect:[self bounds] + cursor:Cocoa_GetDesiredCursor()]; +} + +- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent +{ + if (SDL_GetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH)) { + return SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); + } else { + return SDL_GetHintBoolean("SDL_MAC_MOUSE_FOCUS_CLICKTHROUGH", false); + } +} + +@end + +static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, NSWindow *nswindow, NSView *nsview) +{ + @autoreleasepool { + SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->internal; + SDL_CocoaWindowData *data; + + // Allocate the window data + data = [[SDL_CocoaWindowData alloc] init]; + if (!data) { + return SDL_OutOfMemory(); + } + data.window = window; + data.nswindow = nswindow; + data.videodata = videodata; + data.window_number = nswindow.windowNumber; + data.nscontexts = [[NSMutableArray alloc] init]; + data.sdlContentView = nsview; + + // Create an event listener for the window + data.listener = [[SDL3Cocoa_WindowListener alloc] init]; + + // Fill in the SDL window with the window data + { + int x, y; + NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + ConvertNSRect(&rect); + SDL_GlobalToRelativeForWindow(window, (int)rect.origin.x, (int)rect.origin.y, &x, &y); + window->x = x; + window->y = y; + window->w = (int)rect.size.width; + window->h = (int)rect.size.height; + } + + // Set up the listener after we create the view + [data.listener listen:data]; + + if ([nswindow isVisible]) { + window->flags &= ~SDL_WINDOW_HIDDEN; + } else { + window->flags |= SDL_WINDOW_HIDDEN; + } + + { + unsigned long style = [nswindow styleMask]; + + /* NSWindowStyleMaskBorderless is zero, and it's possible to be + Resizeable _and_ borderless, so we can't do a simple bitwise AND + of NSWindowStyleMaskBorderless here. */ + if ((style & ~(NSWindowStyleMaskResizable | NSWindowStyleMaskMiniaturizable)) == NSWindowStyleMaskBorderless) { + window->flags |= SDL_WINDOW_BORDERLESS; + } else { + window->flags &= ~SDL_WINDOW_BORDERLESS; + } + if (style & NSWindowStyleMaskResizable) { + window->flags |= SDL_WINDOW_RESIZABLE; + } else { + window->flags &= ~SDL_WINDOW_RESIZABLE; + } + } + + // isZoomed always returns true if the window is not resizable + if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) { + window->flags |= SDL_WINDOW_MAXIMIZED; + } else { + window->flags &= ~SDL_WINDOW_MAXIMIZED; + } + + if ([nswindow isMiniaturized]) { + window->flags |= SDL_WINDOW_MINIMIZED; + } else { + window->flags &= ~SDL_WINDOW_MINIMIZED; + } + + if (window->parent) { + NSWindow *nsparent = ((__bridge SDL_CocoaWindowData *)window->parent->internal).nswindow; + [nsparent addChildWindow:nswindow ordered:NSWindowAbove]; + + /* FIXME: Should not need to call addChildWindow then orderOut. + Attaching a hidden child window to a hidden parent window will cause the child window + to show when the parent does. We therefore shouldn't attach the child window here as we're + going to do so when the child window is explicitly shown later but skipping the addChildWindow + entirely causes the child window to not get key focus correctly the first time it's shown. Adding + then immediately ordering out (removing) the window does work. */ + if (window->flags & SDL_WINDOW_HIDDEN) { + [nswindow orderOut:nil]; + } + } + + if (!SDL_WINDOW_IS_POPUP(window)) { + if ([nswindow isKeyWindow]) { + window->flags |= SDL_WINDOW_INPUT_FOCUS; + Cocoa_SetKeyboardFocus(data.window, true); + } + } else { + if (window->flags & SDL_WINDOW_TOOLTIP) { + [nswindow setIgnoresMouseEvents:YES]; + } else if (window->flags & SDL_WINDOW_POPUP_MENU) { + Cocoa_SetKeyboardFocus(window, window->parent == SDL_GetKeyboardFocus()); + } + } + + if (nswindow.isOpaque) { + window->flags &= ~SDL_WINDOW_TRANSPARENT; + } else { + window->flags |= SDL_WINDOW_TRANSPARENT; + } + + /* SDL_CocoaWindowData will be holding a strong reference to the NSWindow, and + * it will also call [NSWindow close] in DestroyWindow before releasing the + * NSWindow, so the extra release provided by releasedWhenClosed isn't + * necessary. */ + nswindow.releasedWhenClosed = NO; + + /* Prevents the window's "window device" from being destroyed when it is + * hidden. See http://www.mikeash.com/pyblog/nsopenglcontext-and-one-shot.html + */ + [nswindow setOneShot:NO]; + + if (window->flags & SDL_WINDOW_EXTERNAL) { + // Query the title from the existing window + NSString *title = [nswindow title]; + if (title) { + window->title = SDL_strdup([title UTF8String]); + } + } + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_COCOA_WINDOW_POINTER, (__bridge void *)data.nswindow); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_COCOA_METAL_VIEW_TAG_NUMBER, SDL_METALVIEW_TAG); + + // All done! + window->internal = (SDL_WindowData *)CFBridgingRetain(data); + return true; + } +} + +bool Cocoa_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + @autoreleasepool { + SDL_CocoaVideoData *videodata = (__bridge SDL_CocoaVideoData *)_this->internal; + const void *data = SDL_GetPointerProperty(create_props, "sdl2-compat.external_window", NULL); + NSWindow *nswindow = nil; + NSView *nsview = nil; + + if (data) { + if ([(__bridge id)data isKindOfClass:[NSWindow class]]) { + nswindow = (__bridge NSWindow *)data; + } else if ([(__bridge id)data isKindOfClass:[NSView class]]) { + nsview = (__bridge NSView *)data; + } else { + SDL_assert(false); + } + } else { + nswindow = (__bridge NSWindow *)SDL_GetPointerProperty(create_props, SDL_PROP_WINDOW_CREATE_COCOA_WINDOW_POINTER, NULL); + nsview = (__bridge NSView *)SDL_GetPointerProperty(create_props, SDL_PROP_WINDOW_CREATE_COCOA_VIEW_POINTER, NULL); + } + if (nswindow && !nsview) { + nsview = [nswindow contentView]; + } + if (nsview && !nswindow) { + nswindow = [nsview window]; + } + if (nswindow) { + window->flags |= SDL_WINDOW_EXTERNAL; + } else { + int x, y; + NSScreen *screen; + NSRect rect, screenRect; + NSUInteger style; + SDL3View *contentView; + + SDL_RelativeToGlobalForWindow(window, window->x, window->y, &x, &y); + rect.origin.x = x; + rect.origin.y = y; + rect.size.width = window->w; + rect.size.height = window->h; + ConvertNSRect(&rect); + + style = GetWindowStyle(window); + + // Figure out which screen to place this window + screen = ScreenForRect(&rect); + screenRect = [screen frame]; + rect.origin.x -= screenRect.origin.x; + rect.origin.y -= screenRect.origin.y; + + // Constrain the popup + if (SDL_WINDOW_IS_POPUP(window)) { + if (rect.origin.x + rect.size.width > screenRect.origin.x + screenRect.size.width) { + rect.origin.x -= (rect.origin.x + rect.size.width) - (screenRect.origin.x + screenRect.size.width); + } + if (rect.origin.y + rect.size.height > screenRect.origin.y + screenRect.size.height) { + rect.origin.y -= (rect.origin.y + rect.size.height) - (screenRect.origin.y + screenRect.size.height); + } + rect.origin.x = SDL_max(rect.origin.x, screenRect.origin.x); + rect.origin.y = SDL_max(rect.origin.y, screenRect.origin.y); + } + + @try { + nswindow = [[SDL3Window alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:NO screen:screen]; + } + @catch (NSException *e) { + return SDL_SetError("%s", [[e reason] UTF8String]); + } + + [nswindow setColorSpace:[NSColorSpace sRGBColorSpace]]; + + [nswindow setTabbingMode:NSWindowTabbingModeDisallowed]; + + if (videodata.allow_spaces) { + // we put fullscreen desktop windows in their own Space, without a toggle button or menubar, later + if (window->flags & SDL_WINDOW_RESIZABLE) { + // resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } + } + + // Create a default view for this window + rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + contentView = [[SDL3View alloc] initWithFrame:rect]; + [contentView setSDLWindow:window]; + nsview = contentView; + } + + if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + [nswindow setLevel:NSFloatingWindowLevel]; + } + + if (window->flags & SDL_WINDOW_TRANSPARENT) { + nswindow.opaque = NO; + nswindow.hasShadow = NO; + nswindow.backgroundColor = [NSColor clearColor]; + } + +// We still support OpenGL as long as Apple offers it, deprecated or not, so disable deprecation warnings about it. +#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +#endif + /* Note: as of the macOS 10.15 SDK, this defaults to YES instead of NO when + * the NSHighResolutionCapable boolean is set in Info.plist. */ + BOOL highdpi = (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) ? YES : NO; + [nsview setWantsBestResolutionOpenGLSurface:highdpi]; +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + +#ifdef SDL_VIDEO_OPENGL_ES2 +#ifdef SDL_VIDEO_OPENGL_EGL + if ((window->flags & SDL_WINDOW_OPENGL) && + _this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { + [nsview setWantsLayer:TRUE]; + if ((window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY)) { + nsview.layer.contentsScale = nswindow.screen.backingScaleFactor; + } else { + nsview.layer.contentsScale = 1; + } + } +#endif // SDL_VIDEO_OPENGL_EGL +#endif // SDL_VIDEO_OPENGL_ES2 + [nswindow setContentView:nsview]; + + if (!SetupWindowData(_this, window, nswindow, nsview)) { + return false; + } + + if (!(window->flags & SDL_WINDOW_OPENGL)) { + return true; + } + + // The rest of this macro mess is for OpenGL or OpenGL ES windows +#ifdef SDL_VIDEO_OPENGL_ES2 + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { +#ifdef SDL_VIDEO_OPENGL_EGL + if (!Cocoa_GLES_SetupWindow(_this, window)) { + Cocoa_DestroyWindow(_this, window); + return false; + } + return true; +#else + return SDL_SetError("Could not create GLES window surface (EGL support not configured)"); +#endif // SDL_VIDEO_OPENGL_EGL + } +#endif // SDL_VIDEO_OPENGL_ES2 + return true; + } +} + +void Cocoa_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + const char *title = window->title ? window->title : ""; + NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; + NSString *string = [[NSString alloc] initWithUTF8String:title]; + [nswindow setTitle:string]; + } +} + +bool Cocoa_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon) +{ + @autoreleasepool { + NSImage *nsimage = Cocoa_CreateImage(icon); + + if (nsimage) { + [NSApp setApplicationIconImage:nsimage]; + + return true; + } + + return SDL_SetError("Unable to set the window's icon"); + } +} + +bool Cocoa_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = windata.nswindow; + NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + BOOL fullscreen = (window->flags & SDL_WINDOW_FULLSCREEN) ? YES : NO; + int x, y; + + if ([windata.listener isInFullscreenSpaceTransition]) { + windata.pending_position = YES; + return true; + } + + if (!(window->flags & SDL_WINDOW_MAXIMIZED)) { + if (fullscreen) { + SDL_VideoDisplay *display = SDL_GetVideoDisplayForFullscreenWindow(window); + SDL_Rect r; + SDL_GetDisplayBounds(display->id, &r); + + rect.origin.x = r.x; + rect.origin.y = r.y; + } else { + SDL_RelativeToGlobalForWindow(window, window->pending.x, window->pending.y, &x, &y); + rect.origin.x = x; + rect.origin.y = y; + } + ConvertNSRect(&rect); + + // Position and constrain the popup + if (SDL_WINDOW_IS_POPUP(window)) { + NSRect screenRect = [ScreenForRect(&rect) frame]; + + if (rect.origin.x + rect.size.width > screenRect.origin.x + screenRect.size.width) { + rect.origin.x -= (rect.origin.x + rect.size.width) - (screenRect.origin.x + screenRect.size.width); + } + if (rect.origin.y + rect.size.height > screenRect.origin.y + screenRect.size.height) { + rect.origin.y -= (rect.origin.y + rect.size.height) - (screenRect.origin.y + screenRect.size.height); + } + rect.origin.x = SDL_max(rect.origin.x, screenRect.origin.x); + rect.origin.y = SDL_max(rect.origin.y, screenRect.origin.y); + } + + [nswindow setFrameOrigin:rect.origin]; + + ScheduleContextUpdates(windata); + } + } + return true; +} + +void Cocoa_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = windata.nswindow; + + if ([windata.listener isInFullscreenSpaceTransition]) { + windata.pending_size = YES; + return; + } + + if (!Cocoa_IsWindowZoomed(window)) { + int x, y; + NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; + + /* Cocoa will resize the window from the bottom-left rather than the + * top-left when -[nswindow setContentSize:] is used, so we must set the + * entire frame based on the new size, in order to preserve the position. + */ + SDL_RelativeToGlobalForWindow(window, window->floating.x, window->floating.y, &x, &y); + rect.origin.x = x; + rect.origin.y = y; + rect.size.width = window->pending.w; + rect.size.height = window->pending.h; + ConvertNSRect(&rect); + + [nswindow setFrame:[nswindow frameRectForContentRect:rect] display:YES]; + ScheduleContextUpdates(windata); + } else { + // Can't set the window size. + window->last_size_pending = false; + } + } +} + +void Cocoa_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->internal; + + NSSize minSize; + minSize.width = window->min_w; + minSize.height = window->min_h; + + [windata.nswindow setContentMinSize:minSize]; + } +} + +void Cocoa_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->internal; + + NSSize maxSize; + maxSize.width = window->max_w; + maxSize.height = window->max_h; + + [windata.nswindow setContentMaxSize:maxSize]; + } +} + +void Cocoa_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->internal; + + if (window->min_aspect > 0.0f && window->min_aspect == window->max_aspect) { + int numerator = 0, denominator = 1; + SDL_CalculateFraction(window->max_aspect, &numerator, &denominator); + [windata.nswindow setContentAspectRatio:NSMakeSize(numerator, denominator)]; + } else { + [windata.nswindow setContentAspectRatio:NSMakeSize(0, 0)]; + } + } +} + +void Cocoa_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) +{ + @autoreleasepool { + SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->internal; + NSView *contentView = windata.sdlContentView; + NSRect viewport = [contentView bounds]; + + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + // This gives us the correct viewport for a Retina-enabled view. + viewport = [contentView convertRectToBacking:viewport]; + } + + *w = (int)viewport.size.width; + *h = (int)viewport.size.height; + } +} + +void Cocoa_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windowData = ((__bridge SDL_CocoaWindowData *)window->internal); + NSWindow *nswindow = windowData.nswindow; + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, true); + + if (![nswindow isMiniaturized]) { + [windowData.listener pauseVisibleObservation]; + if (window->parent) { + NSWindow *nsparent = ((__bridge SDL_CocoaWindowData *)window->parent->internal).nswindow; + [nsparent addChildWindow:nswindow ordered:NSWindowAbove]; + + if (window->flags & SDL_WINDOW_MODAL) { + Cocoa_SetWindowModal(_this, window, true); + } + } + if (!SDL_WINDOW_IS_POPUP(window)) { + if (bActivate) { + [nswindow makeKeyAndOrderFront:nil]; + } else { + // Order this window below the key window if we're not activating it + if ([NSApp keyWindow]) { + [nswindow orderWindow:NSWindowBelow relativeTo:[[NSApp keyWindow] windowNumber]]; + } + } + } + } + [nswindow setIsVisible:YES]; + [windowData.listener resumeVisibleObservation]; + } +} + +void Cocoa_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + NSWindow *nswindow = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; + const BOOL waskey = [nswindow isKeyWindow]; + + /* orderOut has no effect on miniaturized windows, so close must be used to remove + * the window from the desktop and window list in this case. + * + * SDL holds a strong reference to the window (oneShot/releasedWhenClosed are 'NO'), + * and calling 'close' doesn't send a 'windowShouldClose' message, so it's safe to + * use for this purpose as nothing is implicitly released. + */ + if (![nswindow isMiniaturized]) { + [nswindow orderOut:nil]; + } else { + [nswindow close]; + } + + /* If this window is the source of a modal session, end it when + * hidden, or other windows will be prevented from closing. + */ + Cocoa_SetWindowModal(_this, window, false); + + // Transfer keyboard focus back to the parent when closing a popup menu + if (window->flags & SDL_WINDOW_POPUP_MENU) { + SDL_Window *new_focus = window->parent; + bool set_focus = window == SDL_GetKeyboardFocus(); + + // Find the highest level window, up to the toplevel parent, that isn't being hidden or destroyed. + while (SDL_WINDOW_IS_POPUP(new_focus) && (new_focus->is_hiding || new_focus->is_destroying)) { + new_focus = new_focus->parent; + + // If some window in the chain currently had focus, set it to the new lowest-level window. + if (!set_focus) { + set_focus = new_focus == SDL_GetKeyboardFocus(); + } + } + + Cocoa_SetKeyboardFocus(new_focus, set_focus); + } else if (window->parent && waskey) { + /* Key status is not automatically set on the parent when a child is hidden. Check if the + * child window was key, and set the first visible parent to be key if so. + */ + SDL_Window *new_focus = window->parent; + + while (new_focus->parent != NULL && (new_focus->is_hiding || new_focus->is_destroying)) { + new_focus = new_focus->parent; + } + + if (new_focus) { + NSWindow *newkey = ((__bridge SDL_CocoaWindowData *)window->internal).nswindow; + [newkey makeKeyAndOrderFront:nil]; + } + } + } +} + +void Cocoa_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windowData = ((__bridge SDL_CocoaWindowData *)window->internal); + NSWindow *nswindow = windowData.nswindow; + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, true); + + /* makeKeyAndOrderFront: has the side-effect of deminiaturizing and showing + a minimized or hidden window, so check for that before showing it. + */ + [windowData.listener pauseVisibleObservation]; + if (![nswindow isMiniaturized] && [nswindow isVisible]) { + if (window->parent) { + NSWindow *nsparent = ((__bridge SDL_CocoaWindowData *)window->parent->internal).nswindow; + [nsparent addChildWindow:nswindow ordered:NSWindowAbove]; + } + if (!SDL_WINDOW_IS_POPUP(window)) { + if (bActivate) { + [NSApp activateIgnoringOtherApps:YES]; + [nswindow makeKeyAndOrderFront:nil]; + } else { + [nswindow orderFront:nil]; + } + } else { + if (bActivate) { + [nswindow makeKeyWindow]; + } + } + } + [windowData.listener resumeVisibleObservation]; + } +} + +void Cocoa_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *windata = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = windata.nswindow; + + if ([windata.listener windowOperationIsPending:(PENDING_OPERATION_ENTER_FULLSCREEN | PENDING_OPERATION_LEAVE_FULLSCREEN)] || + [windata.listener isInFullscreenSpaceTransition]) { + Cocoa_SyncWindow(_this, window); + } + + if (!(window->flags & SDL_WINDOW_FULLSCREEN) && + ![windata.listener isInFullscreenSpaceTransition] && + ![windata.listener isInFullscreenSpace]) { + [nswindow zoom:nil]; + ScheduleContextUpdates(windata); + } else if (!windata.was_zoomed) { + [windata.listener addPendingWindowOperation:PENDING_OPERATION_ZOOM]; + } else { + [windata.listener clearPendingWindowOperation:PENDING_OPERATION_ZOOM]; + } + } +} + +void Cocoa_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = data.nswindow; + + [data.listener addPendingWindowOperation:PENDING_OPERATION_MINIMIZE]; + if ([data.listener isInFullscreenSpace] || (window->flags & SDL_WINDOW_FULLSCREEN)) { + [data.listener addPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN]; + SDL_UpdateFullscreenMode(window, false, true); + } else if ([data.listener isInFullscreenSpaceTransition]) { + [data.listener addPendingWindowOperation:PENDING_OPERATION_LEAVE_FULLSCREEN]; + } else { + [nswindow miniaturize:nil]; + } + } +} + +void Cocoa_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = data.nswindow; + + if (([data.listener windowOperationIsPending:(PENDING_OPERATION_ENTER_FULLSCREEN | PENDING_OPERATION_LEAVE_FULLSCREEN)] && + ![data.nswindow isMiniaturized]) || [data.listener isInFullscreenSpaceTransition]) { + Cocoa_SyncWindow(_this, window); + } + + [data.listener clearPendingWindowOperation:(PENDING_OPERATION_MINIMIZE)]; + + if (!(window->flags & SDL_WINDOW_FULLSCREEN) && + ![data.listener isInFullscreenSpaceTransition] && + ![data.listener isInFullscreenSpace]) { + if ([nswindow isMiniaturized]) { + [nswindow deminiaturize:nil]; + } else if (Cocoa_IsWindowZoomed(window)) { + [nswindow zoom:nil]; + } + } else if (data.was_zoomed) { + [data.listener addPendingWindowOperation:PENDING_OPERATION_ZOOM]; + } else { + [data.listener clearPendingWindowOperation:PENDING_OPERATION_ZOOM]; + } + } +} + +void Cocoa_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + // If the window is in or transitioning to/from fullscreen, this will be set on leave. + if (!(window->flags & SDL_WINDOW_FULLSCREEN) && ![data.listener isInFullscreenSpaceTransition]) { + if (SetWindowStyle(window, GetWindowStyle(window))) { + if (bordered) { + Cocoa_SetWindowTitle(_this, window); // this got blanked out. + } + } + } else { + data.border_toggled = true; + } + Cocoa_UpdateClipCursor(window); + } +} + +void Cocoa_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) +{ + @autoreleasepool { + /* Don't set this if we're in or transitioning to/from a space! + * The window will get permanently stuck if resizable is false. + * -flibit + */ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + SDL3Cocoa_WindowListener *listener = data.listener; + NSWindow *nswindow = data.nswindow; + SDL_CocoaVideoData *videodata = data.videodata; + if (![listener isInFullscreenSpace] && ![listener isInFullscreenSpaceTransition]) { + SetWindowStyle(window, GetWindowStyle(window)); + } + if (videodata.allow_spaces) { + if (resizable) { + // resizable windows are Spaces-friendly: they get the "go fullscreen" toggle button on their titlebar. + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary]; + } else { + [nswindow setCollectionBehavior:NSWindowCollectionBehaviorManaged]; + } + } + } +} + +void Cocoa_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = data.nswindow; + + // If the window is in or transitioning to/from fullscreen, this will be set on leave. + if (!(window->flags & SDL_WINDOW_FULLSCREEN) && ![data.listener isInFullscreenSpaceTransition]) { + if (on_top) { + [nswindow setLevel:NSFloatingWindowLevel]; + } else { + [nswindow setLevel:kCGNormalWindowLevel]; + } + } + } +} + +SDL_FullscreenResult Cocoa_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = data.nswindow; + NSRect rect; + + // This is a synchronous operation, so always clear the pending flags. + [data.listener clearPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN | PENDING_OPERATION_LEAVE_FULLSCREEN]; + + // The view responder chain gets messed with during setStyleMask + if ([data.sdlContentView nextResponder] == data.listener) { + [data.sdlContentView setNextResponder:nil]; + } + + if (fullscreen) { + SDL_Rect bounds; + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + data.was_zoomed = !!(window->flags & SDL_WINDOW_MAXIMIZED); + } + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); + Cocoa_GetDisplayBounds(_this, display, &bounds); + rect.origin.x = bounds.x; + rect.origin.y = bounds.y; + rect.size.width = bounds.w; + rect.size.height = bounds.h; + ConvertNSRect(&rect); + + /* Hack to fix origin on macOS 10.4 + This is no longer needed as of macOS 10.15, according to bug 4822. + */ + if (SDL_floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_14) { + NSRect screenRect = [[nswindow screen] frame]; + if (screenRect.size.height >= 1.0f) { + rect.origin.y += (screenRect.size.height - rect.size.height); + } + } + + [nswindow setStyleMask:NSWindowStyleMaskBorderless]; + } else { + NSRect frameRect; + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + + rect.origin.x = data.was_zoomed ? window->windowed.x : window->floating.x; + rect.origin.y = data.was_zoomed ? window->windowed.y : window->floating.y; + rect.size.width = data.was_zoomed ? window->windowed.w : window->floating.w; + rect.size.height = data.was_zoomed ? window->windowed.h : window->floating.h; + + ConvertNSRect(&rect); + + /* The window is not meant to be fullscreen, but its flags might have a + * fullscreen bit set if it's scheduled to go fullscreen immediately + * after. Always using the windowed mode style here works around bugs in + * macOS 10.15 where the window doesn't properly restore the windowed + * mode decorations after exiting fullscreen-desktop, when the window + * was created as fullscreen-desktop. */ + [nswindow setStyleMask:GetWindowWindowedStyle(window)]; + + // Hack to restore window decorations on macOS 10.10 + frameRect = [nswindow frame]; + [nswindow setFrame:NSMakeRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width + 1, frameRect.size.height) display:NO]; + [nswindow setFrame:frameRect display:NO]; + } + + // The view responder chain gets messed with during setStyleMask + if ([data.sdlContentView nextResponder] != data.listener) { + [data.sdlContentView setNextResponder:data.listener]; + } + + [nswindow setContentSize:rect.size]; + [nswindow setFrameOrigin:rect.origin]; + + // When the window style changes the title is cleared + if (!fullscreen) { + Cocoa_SetWindowTitle(_this, window); + data.was_zoomed = NO; + if ([data.listener windowOperationIsPending:PENDING_OPERATION_ZOOM]) { + [data.listener clearPendingWindowOperation:PENDING_OPERATION_ZOOM]; + [nswindow zoom:nil]; + } + } + + if (SDL_ShouldAllowTopmost() && fullscreen) { + // OpenGL is rendering to the window, so make it visible! + [nswindow setLevel:kCGMainMenuWindowLevel + 1]; + } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + [nswindow setLevel:NSFloatingWindowLevel]; + } else { + [nswindow setLevel:kCGNormalWindowLevel]; + } + + if ([nswindow isVisible] || fullscreen) { + [data.listener pauseVisibleObservation]; + [nswindow makeKeyAndOrderFront:nil]; + [data.listener resumeVisibleObservation]; + } + + // Update the safe area insets + // The view never seems to reflect the safe area, so we'll use the screen instead + if (@available(macOS 12.0, *)) { + if (fullscreen) { + NSScreen *screen = [nswindow screen]; + + SDL_SetWindowSafeAreaInsets(data.window, + (int)SDL_ceilf(screen.safeAreaInsets.left), + (int)SDL_ceilf(screen.safeAreaInsets.right), + (int)SDL_ceilf(screen.safeAreaInsets.top), + (int)SDL_ceilf(screen.safeAreaInsets.bottom)); + } else { + SDL_SetWindowSafeAreaInsets(data.window, 0, 0, 0, 0); + } + } + + /* When coming out of fullscreen to minimize, this needs to happen after the window + * is made key again, or it won't minimize on 15.0 (Sequoia). + */ + if (!fullscreen && [data.listener windowOperationIsPending:PENDING_OPERATION_MINIMIZE]) { + Cocoa_WaitForMiniaturizable(window); + [data.listener addPendingWindowOperation:PENDING_OPERATION_ENTER_FULLSCREEN]; + [data.listener clearPendingWindowOperation:PENDING_OPERATION_MINIMIZE]; + [nswindow miniaturize:nil]; + } + + ScheduleContextUpdates(data); + Cocoa_SyncWindow(_this, window); + Cocoa_UpdateClipCursor(window); + } + + return SDL_FULLSCREEN_SUCCEEDED; +} + +void *Cocoa_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + NSWindow *nswindow = data.nswindow; + NSScreen *screen = [nswindow screen]; + NSData *iccProfileData = nil; + void *retIccProfileData = NULL; + + if (screen == nil) { + SDL_SetError("Could not get screen of window."); + return NULL; + } + + if ([screen colorSpace] == nil) { + SDL_SetError("Could not get colorspace information of screen."); + return NULL; + } + + iccProfileData = [[screen colorSpace] ICCProfileData]; + if (iccProfileData == nil) { + SDL_SetError("Could not get ICC profile data."); + return NULL; + } + + retIccProfileData = SDL_malloc([iccProfileData length]); + if (!retIccProfileData) { + return NULL; + } + + [iccProfileData getBytes:retIccProfileData length:[iccProfileData length]]; + *size = [iccProfileData length]; + return retIccProfileData; + } +} + +SDL_DisplayID Cocoa_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + NSScreen *screen; + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + // Not recognized via CHECK_WINDOW_MAGIC + if (data == nil) { + // Don't set the error here, it hides other errors and is ignored anyway + // return SDL_SetError("Window data not set"); + return 0; + } + + // NSWindow.screen may be nil when the window is off-screen. + screen = data.nswindow.screen; + + if (screen != nil) { + // https://developer.apple.com/documentation/appkit/nsscreen/1388360-devicedescription?language=objc + CGDirectDisplayID displayid = [[screen.deviceDescription objectForKey:@"NSScreenNumber"] unsignedIntValue]; + SDL_VideoDisplay *display = Cocoa_FindSDLDisplayByCGDirectDisplayID(_this, displayid); + if (display) { + return display->id; + } + } + + // The higher level code will use other logic to find the display + return 0; + } +} + +bool Cocoa_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) +{ + Cocoa_UpdateClipCursor(window); + return true; +} + +bool Cocoa_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + Cocoa_UpdateClipCursor(window); + + if (data && (window->flags & SDL_WINDOW_FULLSCREEN) != 0) { + if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_INPUT_FOCUS) && ![data.listener isInFullscreenSpace]) { + // OpenGL is rendering to the window, so make it visible! + // Doing this in 10.11 while in a Space breaks things (bug #3152) + [data.nswindow setLevel:kCGMainMenuWindowLevel + 1]; + } else if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + [data.nswindow setLevel:NSFloatingWindowLevel]; + } else { + [data.nswindow setLevel:kCGNormalWindowLevel]; + } + } + } + + return true; +} + +void Cocoa_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (SDL_CocoaWindowData *)CFBridgingRelease(window->internal); + + if (data) { +#ifdef SDL_VIDEO_OPENGL + + NSArray *contexts; + +#endif // SDL_VIDEO_OPENGL + SDL_Window *topmost = GetParentToplevelWindow(window); + SDL_CocoaWindowData *topmost_data = (__bridge SDL_CocoaWindowData *)topmost->internal; + + /* Reset the input focus of the root window if this window is still set as keyboard focus. + * SDL_DestroyWindow will have already taken care of reassigning focus if this is the SDL + * keyboard focus, this ensures that an inactive window with this window set as input focus + * does not try to reference it the next time it gains focus. + */ + if (topmost_data.keyboard_focus == window) { + SDL_Window *new_focus = window; + while (SDL_WINDOW_IS_POPUP(new_focus) && (new_focus->is_hiding || new_focus->is_destroying)) { + new_focus = new_focus->parent; + } + + topmost_data.keyboard_focus = new_focus; + } + + if ([data.listener isInFullscreenSpace]) { + [NSMenu setMenuBarVisible:YES]; + } + [data.listener close]; + data.listener = nil; + + if (!(window->flags & SDL_WINDOW_EXTERNAL)) { + // Release the content view to avoid further updateLayer callbacks + [data.nswindow setContentView:nil]; + [data.nswindow close]; + } + +#ifdef SDL_VIDEO_OPENGL + + contexts = [data.nscontexts copy]; + for (SDL3OpenGLContext *context in contexts) { + // Calling setWindow:NULL causes the context to remove itself from the context list. + [context setWindow:NULL]; + } + +#endif // SDL_VIDEO_OPENGL + } + window->internal = NULL; + } +} + +bool Cocoa_SetWindowFullscreenSpace(SDL_Window *window, bool state, bool blocking) +{ + @autoreleasepool { + bool succeeded = false; + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + if (state) { + data.fullscreen_space_requested = YES; + } + data.in_blocking_transition = blocking; + if ([data.listener setFullscreenSpace:(state ? YES : NO)]) { + if (blocking) { + const int maxattempts = 3; + int attempt = 0; + while (++attempt <= maxattempts) { + /* Wait for the transition to complete, so application changes + take effect properly (e.g. setting the window size, etc.) + */ + const int limit = 10000; + int count = 0; + while ([data.listener isInFullscreenSpaceTransition]) { + if (++count == limit) { + // Uh oh, transition isn't completing. Should we assert? + break; + } + SDL_Delay(1); + SDL_PumpEvents(); + } + if ([data.listener isInFullscreenSpace] == (state ? YES : NO)) { + break; + } + // Try again, the last attempt was interrupted by user gestures + if (![data.listener setFullscreenSpace:(state ? YES : NO)]) { + break; // ??? + } + } + } + + // Return TRUE to prevent non-space fullscreen logic from running + succeeded = true; + } + + data.in_blocking_transition = NO; + return succeeded; + } +} + +bool Cocoa_SetWindowHitTest(SDL_Window *window, bool enabled) +{ + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + [data.listener updateHitTest]; + return true; +} + +void Cocoa_AcceptDragAndDrop(SDL_Window *window, bool accept) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + if (accept) { + [data.nswindow registerForDraggedTypes:@[ (NSString *)kUTTypeFileURL, + (NSString *)kUTTypeUTF8PlainText ]]; + } else { + [data.nswindow unregisterDraggedTypes]; + } + } +} + +bool Cocoa_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent) +{ + @autoreleasepool { + SDL_CocoaWindowData *child_data = (__bridge SDL_CocoaWindowData *)window->internal; + + // Remove an existing parent. + if (child_data.nswindow.parentWindow) { + NSWindow *nsparent = ((__bridge SDL_CocoaWindowData *)window->parent->internal).nswindow; + [nsparent removeChildWindow:child_data.nswindow]; + } + + if (parent) { + SDL_CocoaWindowData *parent_data = (__bridge SDL_CocoaWindowData *)parent->internal; + [parent_data.nswindow addChildWindow:child_data.nswindow ordered:NSWindowAbove]; + } + } + + return true; +} + +bool Cocoa_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + if (data.modal_session) { + [NSApp endModalSession:data.modal_session]; + data.modal_session = nil; + } + + if (modal) { + data.modal_session = [NSApp beginModalSessionForWindow:data.nswindow]; + } + } + + return true; +} + +bool Cocoa_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation) +{ + @autoreleasepool { + // Note that this is app-wide and not window-specific! + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + if (data.flash_request) { + [NSApp cancelUserAttentionRequest:data.flash_request]; + data.flash_request = 0; + } + + switch (operation) { + case SDL_FLASH_CANCEL: + // Canceled above + break; + case SDL_FLASH_BRIEFLY: + data.flash_request = [NSApp requestUserAttention:NSInformationalRequest]; + break; + case SDL_FLASH_UNTIL_FOCUSED: + data.flash_request = [NSApp requestUserAttention:NSCriticalRequest]; + break; + default: + return SDL_Unsupported(); + } + return true; + } +} + +bool Cocoa_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable) +{ + return true; // just succeed, the real work is done elsewhere. +} + +bool Cocoa_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity) +{ + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + [data.nswindow setAlphaValue:opacity]; + return true; + } +} + +bool Cocoa_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + bool result = true; + + @autoreleasepool { + SDL_CocoaWindowData *data = (__bridge SDL_CocoaWindowData *)window->internal; + + do { + SDL_PumpEvents(); + } while ([data.listener hasPendingWindowOperation]); + } + + return result; +} + +#endif // SDL_VIDEO_DRIVER_COCOA diff --git a/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h b/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h new file mode 100644 index 0000000..3173558 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12.h @@ -0,0 +1,103 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_D3D12_H +#define SDL_D3D12_H + +#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + +/* From the DirectX-Headers build system: + * "MinGW has RPC headers which define old versions, and complain if D3D + * headers are included before the RPC headers, since D3D headers were + * generated with new MIDL and "require" new RPC headers." + */ +#define __REQUIRED_RPCNDR_H_VERSION__ 475 + +// May not be defined in winapifamily.h, can safely be ignored +#ifndef WINAPI_PARTITION_GAMES +#define WINAPI_PARTITION_GAMES 0 +#endif // WINAPI_PARTITION_GAMES + +#define COBJMACROS +#include "d3d12.h" +#include +#include + +#define D3D_GUID(X) &(X) + +#define D3D_SAFE_RELEASE(X) \ + if (X) { \ + (X)->lpVtbl->Release(X); \ + X = NULL; \ + } + +/* Some D3D12 calls are mismatched between Windows/Xbox, so we need to wrap the + * C function ourselves :( + */ +#define D3D_CALL_RET(THIS, FUNC, ...) (THIS)->lpVtbl->FUNC((THIS), ##__VA_ARGS__) + +#else // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + +#if defined(SDL_PLATFORM_XBOXONE) +#include +#else // SDL_PLATFORM_XBOXSERIES +#include +#endif + +#define D3D_GUID(X) (X) + +#define D3D_SAFE_RELEASE(X) \ + if (X) { \ + (X)->Release(); \ + X = NULL; \ + } + +// Older versions of the Xbox GDK may not have this defined +#ifndef D3D12_TEXTURE_DATA_PITCH_ALIGNMENT +#define D3D12_TEXTURE_DATA_PITCH_ALIGNMENT 256 +#endif +#ifndef D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE +#define D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE ((D3D12_RESOURCE_STATES) (0x40 | 0x80)) +#endif +#ifndef D3D12_HEAP_TYPE_GPU_UPLOAD +#define D3D12_HEAP_TYPE_GPU_UPLOAD ((D3D12_HEAP_TYPE) 5) +#endif + +// DXGI_PRESENT flags are removed on Xbox +#define DXGI_PRESENT_ALLOW_TEARING 0 + +// Xbox D3D12 does not define the COBJMACROS, so we need to define them ourselves +#include "SDL_d3d12_xbox_cmacros.h" + +// They don't even define the CMACROS for ID3DBlob, come on man +#define ID3D10Blob_GetBufferPointer(blob) blob->GetBufferPointer() +#define ID3D10Blob_GetBufferSize(blob) blob->GetBufferSize() +#define ID3D10Blob_Release(blob) blob->Release() + +/* Xbox's D3D12 ABI actually varies from Windows, if a function does not exist + * in the above header then you need to use this instead :( + */ +#define D3D_CALL_RET(THIS, FUNC, RETVAL, ...) *(RETVAL) = (THIS)->FUNC(__VA_ARGS__) + +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + +#endif // SDL_D3D12_H diff --git a/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12_xbox_cmacros.h b/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12_xbox_cmacros.h new file mode 100644 index 0000000..fc6df35 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/directx/SDL_d3d12_xbox_cmacros.h @@ -0,0 +1,4761 @@ +/* This file is autogenerated, DO NOT MODIFY */ +#define ID3D12Object_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Object_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Object_Release(This) \ + ( (This)->Release() ) +#define ID3D12Object_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Object_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Object_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Object_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12DeviceChild_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceChild_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceChild_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceChild_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12DeviceChild_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12DeviceChild_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12DeviceChild_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12DeviceChild_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12RootSignature_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12RootSignature_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12RootSignature_Release(This) \ + ( (This)->Release() ) +#define ID3D12RootSignature_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12RootSignature_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12RootSignature_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12RootSignature_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12RootSignature_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12RootSignatureDeserializer_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12RootSignatureDeserializer_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12RootSignatureDeserializer_Release(This) \ + ( (This)->Release() ) +#define ID3D12RootSignatureDeserializer_GetRootSignatureDesc(This) \ + ( (This)->GetRootSignatureDesc() ) +#define ID3D12VersionedRootSignatureDeserializer_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12VersionedRootSignatureDeserializer_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12VersionedRootSignatureDeserializer_Release(This) \ + ( (This)->Release() ) +#define ID3D12VersionedRootSignatureDeserializer_GetRootSignatureDescAtVersion(This,convertToVersion,ppDesc) \ + ( (This)->GetRootSignatureDescAtVersion(convertToVersion,ppDesc) ) +#define ID3D12VersionedRootSignatureDeserializer_GetUnconvertedRootSignatureDesc(This) \ + ( (This)->GetUnconvertedRootSignatureDesc() ) +#define ID3D12Pageable_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Pageable_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Pageable_Release(This) \ + ( (This)->Release() ) +#define ID3D12Pageable_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Pageable_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Pageable_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Pageable_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Pageable_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Heap_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Heap_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Heap_Release(This) \ + ( (This)->Release() ) +#define ID3D12Heap_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Heap_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Heap_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Heap_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Heap_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Resource_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Resource_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Resource_Release(This) \ + ( (This)->Release() ) +#define ID3D12Resource_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Resource_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Resource_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Resource_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Resource_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Resource_Map(This,Subresource,pReadRange,ppData) \ + ( (This)->Map(Subresource,pReadRange,ppData) ) +#define ID3D12Resource_Unmap(This,Subresource,pWrittenRange) \ + ( (This)->Unmap(Subresource,pWrittenRange) ) +#define ID3D12Resource_GetGPUVirtualAddress(This) \ + ( (This)->GetGPUVirtualAddress() ) +#define ID3D12Resource_WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->WriteToSubresource(DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) +#define ID3D12Resource_ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) \ + ( (This)->ReadFromSubresource(pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) ) +#define ID3D12Resource_GetHeapProperties(This,pHeapProperties,pHeapFlags) \ + ( (This)->GetHeapProperties(pHeapProperties,pHeapFlags) ) +#define ID3D12CommandAllocator_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12CommandAllocator_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12CommandAllocator_Release(This) \ + ( (This)->Release() ) +#define ID3D12CommandAllocator_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12CommandAllocator_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12CommandAllocator_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12CommandAllocator_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12CommandAllocator_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12CommandAllocator_Reset(This) \ + ( (This)->Reset() ) +#define ID3D12Fence_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Fence_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Fence_Release(This) \ + ( (This)->Release() ) +#define ID3D12Fence_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Fence_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Fence_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Fence_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Fence_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Fence_GetCompletedValue(This) \ + ( (This)->GetCompletedValue() ) +#define ID3D12Fence_SetEventOnCompletion(This,Value,hEvent) \ + ( (This)->SetEventOnCompletion(Value,hEvent) ) +#define ID3D12Fence_Signal(This,Value) \ + ( (This)->Signal(Value) ) +#define ID3D12Fence1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Fence1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Fence1_Release(This) \ + ( (This)->Release() ) +#define ID3D12Fence1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Fence1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Fence1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Fence1_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Fence1_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Fence1_GetCompletedValue(This) \ + ( (This)->GetCompletedValue() ) +#define ID3D12Fence1_SetEventOnCompletion(This,Value,hEvent) \ + ( (This)->SetEventOnCompletion(Value,hEvent) ) +#define ID3D12Fence1_Signal(This,Value) \ + ( (This)->Signal(Value) ) +#define ID3D12Fence1_GetCreationFlags(This) \ + ( (This)->GetCreationFlags() ) +#define ID3D12PipelineState_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12PipelineState_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12PipelineState_Release(This) \ + ( (This)->Release() ) +#define ID3D12PipelineState_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12PipelineState_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12PipelineState_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12PipelineState_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12PipelineState_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12PipelineState_GetCachedBlob(This,ppBlob) \ + ( (This)->GetCachedBlob(ppBlob) ) +#define ID3D12DescriptorHeap_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DescriptorHeap_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DescriptorHeap_Release(This) \ + ( (This)->Release() ) +#define ID3D12DescriptorHeap_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12DescriptorHeap_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12DescriptorHeap_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12DescriptorHeap_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12DescriptorHeap_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12QueryHeap_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12QueryHeap_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12QueryHeap_Release(This) \ + ( (This)->Release() ) +#define ID3D12QueryHeap_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12QueryHeap_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12QueryHeap_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12QueryHeap_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12QueryHeap_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12CommandSignature_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12CommandSignature_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12CommandSignature_Release(This) \ + ( (This)->Release() ) +#define ID3D12CommandSignature_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12CommandSignature_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12CommandSignature_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12CommandSignature_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12CommandSignature_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12CommandList_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12CommandList_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12CommandList_Release(This) \ + ( (This)->Release() ) +#define ID3D12CommandList_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12CommandList_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12CommandList_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12CommandList_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12CommandList_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12CommandList_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList1_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList1_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList1_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList1_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList1_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList1_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList1_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList1_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList1_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList1_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList1_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList1_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList1_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList1_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList1_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList1_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList1_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList1_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList1_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList1_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList1_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList1_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList1_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList1_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList1_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList1_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList1_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList1_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList1_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList1_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList1_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList1_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList1_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList1_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList1_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList1_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList1_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList1_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList1_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList1_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList1_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList1_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList1_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList1_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList1_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList1_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList1_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList1_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList1_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList1_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList1_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList1_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList1_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList1_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList1_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList1_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList1_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList1_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList1_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList1_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList1_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList2_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList2_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList2_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList2_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList2_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList2_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList2_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList2_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList2_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList2_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList2_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList2_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList2_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList2_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList2_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList2_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList2_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList2_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList2_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList2_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList2_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList2_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList2_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList2_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList2_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList2_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList2_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList2_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList2_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList2_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList2_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList2_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList2_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList2_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList2_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList2_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList2_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList2_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList2_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList2_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList2_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList2_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList2_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList2_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList2_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList2_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList2_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList2_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList2_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList2_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList2_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList2_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList2_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList2_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList2_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList2_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList2_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList2_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList2_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList2_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList2_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList2_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList2_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList2_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList2_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12CommandQueue_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12CommandQueue_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12CommandQueue_Release(This) \ + ( (This)->Release() ) +#define ID3D12CommandQueue_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12CommandQueue_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12CommandQueue_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12CommandQueue_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12CommandQueue_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12CommandQueue_UpdateTileMappings(This,pResource,NumResourceRegions,pResourceRegionStartCoordinates,pResourceRegionSizes,pHeap,NumRanges,pRangeFlags,pHeapRangeStartOffsets,pRangeTileCounts,Flags) \ + ( (This)->UpdateTileMappings(pResource,NumResourceRegions,pResourceRegionStartCoordinates,pResourceRegionSizes,pHeap,NumRanges,pRangeFlags,pHeapRangeStartOffsets,pRangeTileCounts,Flags) ) +#define ID3D12CommandQueue_CopyTileMappings(This,pDstResource,pDstRegionStartCoordinate,pSrcResource,pSrcRegionStartCoordinate,pRegionSize,Flags) \ + ( (This)->CopyTileMappings(pDstResource,pDstRegionStartCoordinate,pSrcResource,pSrcRegionStartCoordinate,pRegionSize,Flags) ) +#define ID3D12CommandQueue_ExecuteCommandLists(This,NumCommandLists,ppCommandLists) \ + ( (This)->ExecuteCommandLists(NumCommandLists,ppCommandLists) ) +#define ID3D12CommandQueue_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12CommandQueue_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12CommandQueue_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12CommandQueue_Signal(This,pFence,Value) \ + ( (This)->Signal(pFence,Value) ) +#define ID3D12CommandQueue_Wait(This,pFence,Value) \ + ( (This)->Wait(pFence,Value) ) +#define ID3D12CommandQueue_GetTimestampFrequency(This,pFrequency) \ + ( (This)->GetTimestampFrequency(pFrequency) ) +#define ID3D12CommandQueue_GetClockCalibration(This,pGPUTimestamp,pCpuTimestamp) \ + ( (This)->GetClockCalibration(pGPUTimestamp,pCpuTimestamp) ) +#define ID3D12Device_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12PipelineLibrary_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12PipelineLibrary_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12PipelineLibrary_Release(This) \ + ( (This)->Release() ) +#define ID3D12PipelineLibrary_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12PipelineLibrary_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12PipelineLibrary_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12PipelineLibrary_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12PipelineLibrary_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12PipelineLibrary_StorePipeline(This,pName,pPipeline) \ + ( (This)->StorePipeline(pName,pPipeline) ) +#define ID3D12PipelineLibrary_LoadGraphicsPipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->LoadGraphicsPipeline(pName,pDesc,riid,ppPipelineState) ) +#define ID3D12PipelineLibrary_LoadComputePipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->LoadComputePipeline(pName,pDesc,riid,ppPipelineState) ) +#define ID3D12PipelineLibrary_GetSerializedSize(This) \ + ( (This)->GetSerializedSize() ) +#define ID3D12PipelineLibrary_Serialize(This,pData,DataSizeInBytes) \ + ( (This)->Serialize(pData,DataSizeInBytes) ) +#define ID3D12PipelineLibrary1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12PipelineLibrary1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12PipelineLibrary1_Release(This) \ + ( (This)->Release() ) +#define ID3D12PipelineLibrary1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12PipelineLibrary1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12PipelineLibrary1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12PipelineLibrary1_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12PipelineLibrary1_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12PipelineLibrary1_StorePipeline(This,pName,pPipeline) \ + ( (This)->StorePipeline(pName,pPipeline) ) +#define ID3D12PipelineLibrary1_LoadGraphicsPipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->LoadGraphicsPipeline(pName,pDesc,riid,ppPipelineState) ) +#define ID3D12PipelineLibrary1_LoadComputePipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->LoadComputePipeline(pName,pDesc,riid,ppPipelineState) ) +#define ID3D12PipelineLibrary1_GetSerializedSize(This) \ + ( (This)->GetSerializedSize() ) +#define ID3D12PipelineLibrary1_Serialize(This,pData,DataSizeInBytes) \ + ( (This)->Serialize(pData,DataSizeInBytes) ) +#define ID3D12PipelineLibrary1_LoadPipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->LoadPipeline(pName,pDesc,riid,ppPipelineState) ) +#define ID3D12Device1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device1_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device1_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device1_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device1_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device1_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device1_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device1_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device1_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device1_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device1_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device1_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device1_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device1_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device1_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device1_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device1_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device1_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device1_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device1_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device1_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device1_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device1_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device1_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device1_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device1_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device1_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device1_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device1_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device1_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device1_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device1_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device1_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device1_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device1_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device1_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device1_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device1_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device1_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device1_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device2_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device2_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device2_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device2_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device2_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device2_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device2_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device2_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device2_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device2_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device2_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device2_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device2_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device2_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device2_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device2_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device2_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device2_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device2_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device2_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device2_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device2_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device2_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device2_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device2_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device2_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device2_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device2_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device2_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device2_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device2_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device2_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device2_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device2_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device2_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device2_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device2_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device2_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device2_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device2_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device2_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device2_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device2_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device3_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device3_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device3_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device3_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device3_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device3_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device3_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device3_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device3_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device3_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device3_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device3_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device3_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device3_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device3_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device3_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device3_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device3_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device3_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device3_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device3_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device3_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device3_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device3_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device3_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device3_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device3_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device3_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device3_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device3_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device3_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device3_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device3_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device3_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device3_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device3_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device3_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device3_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device3_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device3_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device3_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device3_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device3_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device3_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device3_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device3_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device3_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device3_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12ProtectedSession_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12ProtectedSession_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12ProtectedSession_Release(This) \ + ( (This)->Release() ) +#define ID3D12ProtectedSession_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12ProtectedSession_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12ProtectedSession_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12ProtectedSession_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12ProtectedSession_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12ProtectedSession_GetStatusFence(This,riid,ppFence) \ + ( (This)->GetStatusFence(riid,ppFence) ) +#define ID3D12ProtectedSession_GetSessionStatus(This) \ + ( (This)->GetSessionStatus() ) +#define ID3D12ProtectedResourceSession_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12ProtectedResourceSession_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12ProtectedResourceSession_Release(This) \ + ( (This)->Release() ) +#define ID3D12ProtectedResourceSession_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12ProtectedResourceSession_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12ProtectedResourceSession_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12ProtectedResourceSession_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12ProtectedResourceSession_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12ProtectedResourceSession_GetStatusFence(This,riid,ppFence) \ + ( (This)->GetStatusFence(riid,ppFence) ) +#define ID3D12ProtectedResourceSession_GetSessionStatus(This) \ + ( (This)->GetSessionStatus() ) +#define ID3D12Device4_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device4_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device4_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device4_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device4_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device4_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device4_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device4_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device4_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device4_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device4_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device4_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device4_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device4_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device4_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device4_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device4_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device4_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device4_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device4_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device4_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device4_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device4_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device4_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device4_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device4_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device4_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device4_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device4_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device4_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device4_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device4_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device4_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device4_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device4_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device4_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device4_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device4_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device4_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device4_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device4_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device4_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device4_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device4_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device4_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device4_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device4_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device4_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device4_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device4_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device4_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device4_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device4_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12LifetimeOwner_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12LifetimeOwner_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12LifetimeOwner_Release(This) \ + ( (This)->Release() ) +#define ID3D12LifetimeOwner_LifetimeStateUpdated(This,NewState) \ + ( (This)->LifetimeStateUpdated(NewState) ) +#define ID3D12SwapChainAssistant_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12SwapChainAssistant_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12SwapChainAssistant_Release(This) \ + ( (This)->Release() ) +#define ID3D12SwapChainAssistant_GetSwapChainObject(This,riid,ppv) \ + ( (This)->GetSwapChainObject(riid,ppv) ) +#define ID3D12SwapChainAssistant_GetCurrentResourceAndCommandQueue(This,riidResource,ppvResource,riidQueue,ppvQueue) \ + ( (This)->GetCurrentResourceAndCommandQueue(riidResource,ppvResource,riidQueue,ppvQueue) ) +#define ID3D12SwapChainAssistant_InsertImplicitSync(This) \ + ( (This)->InsertImplicitSync() ) +#define ID3D12LifetimeTracker_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12LifetimeTracker_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12LifetimeTracker_Release(This) \ + ( (This)->Release() ) +#define ID3D12LifetimeTracker_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12LifetimeTracker_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12LifetimeTracker_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12LifetimeTracker_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12LifetimeTracker_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12LifetimeTracker_DestroyOwnedObject(This,pObject) \ + ( (This)->DestroyOwnedObject(pObject) ) +#define ID3D12StateObject_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12StateObject_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12StateObject_Release(This) \ + ( (This)->Release() ) +#define ID3D12StateObject_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12StateObject_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12StateObject_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12StateObject_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12StateObject_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12StateObjectProperties_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12StateObjectProperties_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12StateObjectProperties_Release(This) \ + ( (This)->Release() ) +#define ID3D12StateObjectProperties_GetShaderIdentifier(This,pExportName) \ + ( (This)->GetShaderIdentifier(pExportName) ) +#define ID3D12StateObjectProperties_GetShaderStackSize(This,pExportName) \ + ( (This)->GetShaderStackSize(pExportName) ) +#define ID3D12StateObjectProperties_GetPipelineStackSize(This) \ + ( (This)->GetPipelineStackSize() ) +#define ID3D12StateObjectProperties_SetPipelineStackSize(This,PipelineStackSizeInBytes) \ + ( (This)->SetPipelineStackSize(PipelineStackSizeInBytes) ) +#define ID3D12StateObjectProperties1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12StateObjectProperties1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12StateObjectProperties1_Release(This) \ + ( (This)->Release() ) +#define ID3D12StateObjectProperties1_GetShaderIdentifier(This,pExportName) \ + ( (This)->GetShaderIdentifier(pExportName) ) +#define ID3D12StateObjectProperties1_GetShaderStackSize(This,pExportName) \ + ( (This)->GetShaderStackSize(pExportName) ) +#define ID3D12StateObjectProperties1_GetPipelineStackSize(This) \ + ( (This)->GetPipelineStackSize() ) +#define ID3D12StateObjectProperties1_SetPipelineStackSize(This,PipelineStackSizeInBytes) \ + ( (This)->SetPipelineStackSize(PipelineStackSizeInBytes) ) +#define ID3D12WorkGraphProperties_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12WorkGraphProperties_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12WorkGraphProperties_Release(This) \ + ( (This)->Release() ) +#define ID3D12WorkGraphProperties_GetNumWorkGraphs(This) \ + ( (This)->GetNumWorkGraphs() ) +#define ID3D12WorkGraphProperties_GetProgramName(This,WorkGraphIndex) \ + ( (This)->GetProgramName(WorkGraphIndex) ) +#define ID3D12WorkGraphProperties_GetWorkGraphIndex(This,pProgramName) \ + ( (This)->GetWorkGraphIndex(pProgramName) ) +#define ID3D12WorkGraphProperties_GetNumNodes(This,WorkGraphIndex) \ + ( (This)->GetNumNodes(WorkGraphIndex) ) +#define ID3D12WorkGraphProperties_GetNodeIndex(This,WorkGraphIndex,NodeID) \ + ( (This)->GetNodeIndex(WorkGraphIndex,NodeID) ) +#define ID3D12WorkGraphProperties_GetNodeLocalRootArgumentsTableIndex(This,WorkGraphIndex,NodeIndex) \ + ( (This)->GetNodeLocalRootArgumentsTableIndex(WorkGraphIndex,NodeIndex) ) +#define ID3D12WorkGraphProperties_GetNumEntrypoints(This,WorkGraphIndex) \ + ( (This)->GetNumEntrypoints(WorkGraphIndex) ) +#define ID3D12WorkGraphProperties_GetEntrypointIndex(This,WorkGraphIndex,NodeID) \ + ( (This)->GetEntrypointIndex(WorkGraphIndex,NodeID) ) +#define ID3D12WorkGraphProperties_GetEntrypointRecordSizeInBytes(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->GetEntrypointRecordSizeInBytes(WorkGraphIndex,EntrypointIndex) ) +#define ID3D12WorkGraphProperties_GetWorkGraphMemoryRequirements(This,WorkGraphIndex,pWorkGraphMemoryRequirements) \ + ( (This)->GetWorkGraphMemoryRequirements(WorkGraphIndex,pWorkGraphMemoryRequirements) ) +#define ID3D12WorkGraphProperties_GetEntrypointRecordAlignmentInBytes(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->GetEntrypointRecordAlignmentInBytes(WorkGraphIndex,EntrypointIndex) ) +#define ID3D12Device5_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device5_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device5_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device5_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device5_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device5_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device5_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device5_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device5_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device5_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device5_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device5_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device5_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device5_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device5_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device5_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device5_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device5_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device5_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device5_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device5_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device5_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device5_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device5_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device5_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device5_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device5_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device5_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device5_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device5_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device5_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device5_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device5_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device5_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device5_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device5_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device5_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device5_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device5_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device5_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device5_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device5_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device5_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device5_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device5_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device5_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device5_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device5_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device5_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device5_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device5_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device5_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device5_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device5_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device5_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device5_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device5_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device5_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device5_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device5_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device5_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12DeviceRemovedExtendedDataSettings_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceRemovedExtendedDataSettings_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceRemovedExtendedDataSettings_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceRemovedExtendedDataSettings_SetAutoBreadcrumbsEnablement(This,Enablement) \ + ( (This)->SetAutoBreadcrumbsEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings_SetPageFaultEnablement(This,Enablement) \ + ( (This)->SetPageFaultEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings_SetWatsonDumpEnablement(This,Enablement) \ + ( (This)->SetWatsonDumpEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceRemovedExtendedDataSettings1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceRemovedExtendedDataSettings1_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceRemovedExtendedDataSettings1_SetAutoBreadcrumbsEnablement(This,Enablement) \ + ( (This)->SetAutoBreadcrumbsEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings1_SetPageFaultEnablement(This,Enablement) \ + ( (This)->SetPageFaultEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings1_SetWatsonDumpEnablement(This,Enablement) \ + ( (This)->SetWatsonDumpEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings1_SetBreadcrumbContextEnablement(This,Enablement) \ + ( (This)->SetBreadcrumbContextEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceRemovedExtendedDataSettings2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceRemovedExtendedDataSettings2_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceRemovedExtendedDataSettings2_SetAutoBreadcrumbsEnablement(This,Enablement) \ + ( (This)->SetAutoBreadcrumbsEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings2_SetPageFaultEnablement(This,Enablement) \ + ( (This)->SetPageFaultEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings2_SetWatsonDumpEnablement(This,Enablement) \ + ( (This)->SetWatsonDumpEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings2_SetBreadcrumbContextEnablement(This,Enablement) \ + ( (This)->SetBreadcrumbContextEnablement(Enablement) ) +#define ID3D12DeviceRemovedExtendedDataSettings2_UseMarkersOnlyAutoBreadcrumbs(This,MarkersOnly) \ + ( (This)->UseMarkersOnlyAutoBreadcrumbs(MarkersOnly) ) +#define ID3D12DeviceRemovedExtendedData_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceRemovedExtendedData_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceRemovedExtendedData_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceRemovedExtendedData_GetAutoBreadcrumbsOutput(This,pOutput) \ + ( (This)->GetAutoBreadcrumbsOutput(pOutput) ) +#define ID3D12DeviceRemovedExtendedData_GetPageFaultAllocationOutput(This,pOutput) \ + ( (This)->GetPageFaultAllocationOutput(pOutput) ) +#define ID3D12DeviceRemovedExtendedData1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceRemovedExtendedData1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceRemovedExtendedData1_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceRemovedExtendedData1_GetAutoBreadcrumbsOutput(This,pOutput) \ + ( (This)->GetAutoBreadcrumbsOutput(pOutput) ) +#define ID3D12DeviceRemovedExtendedData1_GetPageFaultAllocationOutput(This,pOutput) \ + ( (This)->GetPageFaultAllocationOutput(pOutput) ) +#define ID3D12DeviceRemovedExtendedData1_GetAutoBreadcrumbsOutput1(This,pOutput) \ + ( (This)->GetAutoBreadcrumbsOutput1(pOutput) ) +#define ID3D12DeviceRemovedExtendedData1_GetPageFaultAllocationOutput1(This,pOutput) \ + ( (This)->GetPageFaultAllocationOutput1(pOutput) ) +#define ID3D12DeviceRemovedExtendedData2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceRemovedExtendedData2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceRemovedExtendedData2_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceRemovedExtendedData2_GetAutoBreadcrumbsOutput(This,pOutput) \ + ( (This)->GetAutoBreadcrumbsOutput(pOutput) ) +#define ID3D12DeviceRemovedExtendedData2_GetPageFaultAllocationOutput(This,pOutput) \ + ( (This)->GetPageFaultAllocationOutput(pOutput) ) +#define ID3D12DeviceRemovedExtendedData2_GetAutoBreadcrumbsOutput1(This,pOutput) \ + ( (This)->GetAutoBreadcrumbsOutput1(pOutput) ) +#define ID3D12DeviceRemovedExtendedData2_GetPageFaultAllocationOutput1(This,pOutput) \ + ( (This)->GetPageFaultAllocationOutput1(pOutput) ) +#define ID3D12DeviceRemovedExtendedData2_GetPageFaultAllocationOutput2(This,pOutput) \ + ( (This)->GetPageFaultAllocationOutput2(pOutput) ) +#define ID3D12DeviceRemovedExtendedData2_GetDeviceState(This) \ + ( (This)->GetDeviceState() ) +#define ID3D12Device6_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device6_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device6_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device6_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device6_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device6_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device6_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device6_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device6_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device6_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device6_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device6_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device6_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device6_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device6_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device6_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device6_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device6_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device6_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device6_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device6_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device6_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device6_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device6_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device6_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device6_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device6_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device6_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device6_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device6_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device6_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device6_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device6_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device6_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device6_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device6_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device6_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device6_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device6_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device6_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device6_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device6_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device6_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device6_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device6_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device6_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device6_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device6_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device6_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device6_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device6_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device6_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device6_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device6_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device6_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device6_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device6_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device6_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device6_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device6_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device6_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device6_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12ProtectedResourceSession1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12ProtectedResourceSession1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12ProtectedResourceSession1_Release(This) \ + ( (This)->Release() ) +#define ID3D12ProtectedResourceSession1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12ProtectedResourceSession1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12ProtectedResourceSession1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12ProtectedResourceSession1_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12ProtectedResourceSession1_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12ProtectedResourceSession1_GetStatusFence(This,riid,ppFence) \ + ( (This)->GetStatusFence(riid,ppFence) ) +#define ID3D12ProtectedResourceSession1_GetSessionStatus(This) \ + ( (This)->GetSessionStatus() ) +#define ID3D12Device7_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device7_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device7_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device7_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device7_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device7_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device7_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device7_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device7_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device7_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device7_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device7_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device7_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device7_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device7_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device7_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device7_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device7_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device7_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device7_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device7_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device7_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device7_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device7_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device7_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device7_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device7_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device7_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device7_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device7_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device7_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device7_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device7_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device7_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device7_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device7_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device7_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device7_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device7_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device7_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device7_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device7_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device7_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device7_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device7_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device7_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device7_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device7_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device7_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device7_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device7_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device7_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device7_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device7_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device7_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device7_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device7_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device7_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device7_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device7_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device7_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device7_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device7_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device7_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device8_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device8_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device8_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device8_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device8_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device8_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device8_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device8_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device8_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device8_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device8_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device8_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device8_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device8_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device8_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device8_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device8_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device8_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device8_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device8_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device8_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device8_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device8_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device8_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device8_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device8_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device8_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device8_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device8_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device8_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device8_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device8_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device8_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device8_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device8_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device8_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device8_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device8_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device8_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device8_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device8_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device8_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device8_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device8_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device8_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device8_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device8_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device8_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device8_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device8_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device8_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device8_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device8_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device8_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device8_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device8_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device8_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device8_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device8_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device8_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device8_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device8_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device8_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device8_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device8_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource2(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device8_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource1(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device8_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource,pFeedbackResource,DestDescriptor) ) +#define ID3D12Device8_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints1(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Resource1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Resource1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Resource1_Release(This) \ + ( (This)->Release() ) +#define ID3D12Resource1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Resource1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Resource1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Resource1_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Resource1_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Resource1_Map(This,Subresource,pReadRange,ppData) \ + ( (This)->Map(Subresource,pReadRange,ppData) ) +#define ID3D12Resource1_Unmap(This,Subresource,pWrittenRange) \ + ( (This)->Unmap(Subresource,pWrittenRange) ) +#define ID3D12Resource1_GetGPUVirtualAddress(This) \ + ( (This)->GetGPUVirtualAddress() ) +#define ID3D12Resource1_WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->WriteToSubresource(DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) +#define ID3D12Resource1_ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) \ + ( (This)->ReadFromSubresource(pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) ) +#define ID3D12Resource1_GetHeapProperties(This,pHeapProperties,pHeapFlags) \ + ( (This)->GetHeapProperties(pHeapProperties,pHeapFlags) ) +#define ID3D12Resource1_GetProtectedResourceSession(This,riid,ppProtectedSession) \ + ( (This)->GetProtectedResourceSession(riid,ppProtectedSession) ) +#define ID3D12Resource2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Resource2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Resource2_Release(This) \ + ( (This)->Release() ) +#define ID3D12Resource2_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Resource2_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Resource2_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Resource2_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Resource2_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Resource2_Map(This,Subresource,pReadRange,ppData) \ + ( (This)->Map(Subresource,pReadRange,ppData) ) +#define ID3D12Resource2_Unmap(This,Subresource,pWrittenRange) \ + ( (This)->Unmap(Subresource,pWrittenRange) ) +#define ID3D12Resource2_GetGPUVirtualAddress(This) \ + ( (This)->GetGPUVirtualAddress() ) +#define ID3D12Resource2_WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->WriteToSubresource(DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) +#define ID3D12Resource2_ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) \ + ( (This)->ReadFromSubresource(pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) ) +#define ID3D12Resource2_GetHeapProperties(This,pHeapProperties,pHeapFlags) \ + ( (This)->GetHeapProperties(pHeapProperties,pHeapFlags) ) +#define ID3D12Resource2_GetProtectedResourceSession(This,riid,ppProtectedSession) \ + ( (This)->GetProtectedResourceSession(riid,ppProtectedSession) ) +#define ID3D12Heap1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Heap1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Heap1_Release(This) \ + ( (This)->Release() ) +#define ID3D12Heap1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Heap1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Heap1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Heap1_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Heap1_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12Heap1_GetProtectedResourceSession(This,riid,ppProtectedSession) \ + ( (This)->GetProtectedResourceSession(riid,ppProtectedSession) ) +#define ID3D12GraphicsCommandList3_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList3_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList3_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList3_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList3_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList3_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList3_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList3_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList3_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList3_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList3_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList3_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList3_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList3_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList3_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList3_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList3_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList3_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList3_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList3_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList3_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList3_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList3_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList3_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList3_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList3_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList3_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList3_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList3_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList3_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList3_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList3_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList3_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList3_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList3_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList3_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList3_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList3_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList3_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList3_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList3_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList3_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList3_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList3_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList3_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList3_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList3_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList3_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList3_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList3_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList3_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList3_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList3_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList3_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList3_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList3_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList3_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList3_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList3_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList3_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList3_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList3_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList3_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList3_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList3_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList3_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList3_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList3_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12MetaCommand_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12MetaCommand_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12MetaCommand_Release(This) \ + ( (This)->Release() ) +#define ID3D12MetaCommand_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12MetaCommand_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12MetaCommand_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12MetaCommand_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12MetaCommand_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12MetaCommand_GetRequiredParameterResourceSize(This,Stage,ParameterIndex) \ + ( (This)->GetRequiredParameterResourceSize(Stage,ParameterIndex) ) +#define ID3D12GraphicsCommandList4_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList4_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList4_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList4_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList4_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList4_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList4_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList4_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList4_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList4_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList4_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList4_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList4_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList4_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList4_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList4_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList4_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList4_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList4_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList4_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList4_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList4_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList4_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList4_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList4_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList4_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList4_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList4_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList4_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList4_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList4_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList4_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList4_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList4_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList4_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList4_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList4_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList4_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList4_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList4_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList4_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList4_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList4_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList4_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList4_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList4_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList4_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList4_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList4_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList4_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList4_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList4_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList4_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList4_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList4_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList4_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList4_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList4_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList4_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList4_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList4_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList4_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList4_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList4_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList4_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList4_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList4_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList4_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12GraphicsCommandList4_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->BeginRenderPass(NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) +#define ID3D12GraphicsCommandList4_EndRenderPass(This) \ + ( (This)->EndRenderPass() ) +#define ID3D12GraphicsCommandList4_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->InitializeMetaCommand(pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList4_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->ExecuteMetaCommand(pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList4_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->BuildRaytracingAccelerationStructure(pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) +#define ID3D12GraphicsCommandList4_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->EmitRaytracingAccelerationStructurePostbuildInfo(pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) +#define ID3D12GraphicsCommandList4_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->CopyRaytracingAccelerationStructure(DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) +#define ID3D12GraphicsCommandList4_SetPipelineState1(This,pStateObject) \ + ( (This)->SetPipelineState1(pStateObject) ) +#define ID3D12GraphicsCommandList4_DispatchRays(This,pDesc) \ + ( (This)->DispatchRays(pDesc) ) +#define ID3D12ShaderCacheSession_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12ShaderCacheSession_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12ShaderCacheSession_Release(This) \ + ( (This)->Release() ) +#define ID3D12ShaderCacheSession_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12ShaderCacheSession_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12ShaderCacheSession_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12ShaderCacheSession_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12ShaderCacheSession_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12ShaderCacheSession_FindValue(This,pKey,KeySize,pValue,pValueSize) \ + ( (This)->FindValue(pKey,KeySize,pValue,pValueSize) ) +#define ID3D12ShaderCacheSession_StoreValue(This,pKey,KeySize,pValue,ValueSize) \ + ( (This)->StoreValue(pKey,KeySize,pValue,ValueSize) ) +#define ID3D12ShaderCacheSession_SetDeleteOnDestroy(This) \ + ( (This)->SetDeleteOnDestroy() ) +#define ID3D12Device9_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device9_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device9_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device9_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device9_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device9_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device9_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device9_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device9_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device9_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device9_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device9_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device9_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device9_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device9_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device9_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device9_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device9_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device9_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device9_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device9_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device9_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device9_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device9_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device9_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device9_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device9_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device9_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device9_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device9_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device9_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device9_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device9_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device9_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device9_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device9_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device9_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device9_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device9_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device9_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device9_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device9_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device9_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device9_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device9_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device9_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device9_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device9_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device9_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device9_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device9_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device9_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device9_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device9_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device9_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device9_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device9_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device9_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device9_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device9_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device9_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device9_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device9_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device9_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device9_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource2(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device9_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource1(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device9_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource,pFeedbackResource,DestDescriptor) ) +#define ID3D12Device9_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints1(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device9_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->CreateShaderCacheSession(pDesc,riid,ppvSession) ) +#define ID3D12Device9_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->ShaderCacheControl(Kinds,Control) ) +#define ID3D12Device9_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue1(pDesc,CreatorID,riid,ppCommandQueue) ) +#define ID3D12Device10_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device10_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device10_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device10_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device10_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device10_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device10_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device10_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device10_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device10_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device10_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device10_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device10_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device10_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device10_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device10_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device10_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device10_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device10_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device10_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device10_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device10_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device10_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device10_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device10_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device10_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device10_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device10_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device10_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device10_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device10_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device10_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device10_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device10_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device10_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device10_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device10_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device10_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device10_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device10_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device10_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device10_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device10_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device10_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device10_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device10_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device10_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device10_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device10_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device10_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device10_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device10_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device10_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device10_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device10_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device10_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device10_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device10_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device10_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device10_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device10_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device10_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device10_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device10_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device10_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource2(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device10_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource1(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device10_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource,pFeedbackResource,DestDescriptor) ) +#define ID3D12Device10_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints1(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device10_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->CreateShaderCacheSession(pDesc,riid,ppvSession) ) +#define ID3D12Device10_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->ShaderCacheControl(Kinds,Control) ) +#define ID3D12Device10_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue1(pDesc,CreatorID,riid,ppCommandQueue) ) +#define ID3D12Device10_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource3(pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) +#define ID3D12Device10_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreatePlacedResource2(pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device10_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreateReservedResource2(pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device11_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device11_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device11_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device11_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device11_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device11_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device11_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device11_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device11_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device11_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device11_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device11_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device11_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device11_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device11_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device11_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device11_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device11_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device11_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device11_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device11_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device11_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device11_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device11_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device11_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device11_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device11_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device11_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device11_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device11_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device11_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device11_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device11_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device11_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device11_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device11_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device11_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device11_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device11_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device11_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device11_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device11_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device11_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device11_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device11_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device11_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device11_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device11_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device11_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device11_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device11_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device11_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device11_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device11_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device11_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device11_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device11_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device11_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device11_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device11_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device11_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device11_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device11_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device11_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device11_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource2(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device11_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource1(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device11_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource,pFeedbackResource,DestDescriptor) ) +#define ID3D12Device11_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints1(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device11_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->CreateShaderCacheSession(pDesc,riid,ppvSession) ) +#define ID3D12Device11_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->ShaderCacheControl(Kinds,Control) ) +#define ID3D12Device11_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue1(pDesc,CreatorID,riid,ppCommandQueue) ) +#define ID3D12Device11_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource3(pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) +#define ID3D12Device11_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreatePlacedResource2(pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device11_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreateReservedResource2(pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device11_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler2(pDesc,DestDescriptor) ) +#define ID3D12Device12_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device12_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device12_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device12_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device12_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device12_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device12_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device12_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device12_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device12_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device12_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device12_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device12_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device12_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device12_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device12_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device12_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device12_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device12_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device12_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device12_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device12_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device12_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device12_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device12_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device12_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device12_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device12_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device12_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device12_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device12_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device12_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device12_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device12_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device12_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device12_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device12_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device12_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device12_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device12_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device12_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device12_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device12_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device12_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device12_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device12_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device12_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device12_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device12_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device12_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device12_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device12_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device12_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device12_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device12_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device12_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device12_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device12_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device12_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device12_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device12_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device12_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device12_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device12_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device12_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource2(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device12_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource1(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device12_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource,pFeedbackResource,DestDescriptor) ) +#define ID3D12Device12_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints1(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device12_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->CreateShaderCacheSession(pDesc,riid,ppvSession) ) +#define ID3D12Device12_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->ShaderCacheControl(Kinds,Control) ) +#define ID3D12Device12_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue1(pDesc,CreatorID,riid,ppCommandQueue) ) +#define ID3D12Device12_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource3(pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) +#define ID3D12Device12_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreatePlacedResource2(pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device12_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreateReservedResource2(pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device12_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler2(pDesc,DestDescriptor) ) +#define ID3D12Device13_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device13_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device13_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device13_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device13_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device13_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device13_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device13_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device13_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device13_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device13_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device13_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device13_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device13_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device13_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device13_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device13_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device13_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device13_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device13_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device13_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device13_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device13_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device13_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device13_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device13_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device13_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device13_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device13_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device13_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device13_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device13_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device13_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device13_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device13_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device13_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device13_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device13_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device13_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device13_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device13_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device13_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device13_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device13_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device13_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device13_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device13_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device13_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device13_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device13_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device13_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device13_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device13_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device13_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device13_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device13_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device13_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device13_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device13_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device13_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device13_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device13_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device13_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device13_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device13_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource2(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device13_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource1(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device13_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource,pFeedbackResource,DestDescriptor) ) +#define ID3D12Device13_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints1(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device13_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->CreateShaderCacheSession(pDesc,riid,ppvSession) ) +#define ID3D12Device13_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->ShaderCacheControl(Kinds,Control) ) +#define ID3D12Device13_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue1(pDesc,CreatorID,riid,ppCommandQueue) ) +#define ID3D12Device13_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource3(pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) +#define ID3D12Device13_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreatePlacedResource2(pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device13_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreateReservedResource2(pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device13_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler2(pDesc,DestDescriptor) ) +#define ID3D12Device13_OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress1(pAddress,size,riid,ppvHeap) ) +#define ID3D12Device14_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Device14_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Device14_Release(This) \ + ( (This)->Release() ) +#define ID3D12Device14_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12Device14_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12Device14_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12Device14_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12Device14_GetNodeCount(This) \ + ( (This)->GetNodeCount() ) +#define ID3D12Device14_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue(pDesc,riid,ppCommandQueue) ) +#define ID3D12Device14_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->CreateCommandAllocator(type,riid,ppCommandAllocator) ) +#define ID3D12Device14_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateGraphicsPipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device14_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreateComputePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device14_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->CreateCommandList(nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) +#define ID3D12Device14_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->CheckFeatureSupport(Feature,pFeatureSupportData,FeatureSupportDataSize) ) +#define ID3D12Device14_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->CreateDescriptorHeap(pDescriptorHeapDesc,riid,ppvHeap) ) +#define ID3D12Device14_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->GetDescriptorHandleIncrementSize(DescriptorHeapType) ) +#define ID3D12Device14_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->CreateRootSignature(nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) +#define ID3D12Device14_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->CreateConstantBufferView(pDesc,DestDescriptor) ) +#define ID3D12Device14_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateShaderResourceView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device14_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->CreateUnorderedAccessView(pResource,pCounterResource,pDesc,DestDescriptor) ) +#define ID3D12Device14_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateRenderTargetView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device14_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->CreateDepthStencilView(pResource,pDesc,DestDescriptor) ) +#define ID3D12Device14_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler(pDesc,DestDescriptor) ) +#define ID3D12Device14_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->CopyDescriptors(NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) +#define ID3D12Device14_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->CopyDescriptorsSimple(NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#define ID3D12Device14_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) +#define ID3D12Device14_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device14_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device14_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreateReservedResource(pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device14_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->CreateSharedHandle(pObject,pAttributes,Access,Name,pHandle) ) +#define ID3D12Device14_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->OpenSharedHandle(NTHandle,riid,ppvObj) ) +#define ID3D12Device14_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->OpenSharedHandleByName(Name,Access,pNTHandle) ) +#define ID3D12Device14_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->MakeResident(NumObjects,ppObjects) ) +#define ID3D12Device14_Evict(This,NumObjects,ppObjects) \ + ( (This)->Evict(NumObjects,ppObjects) ) +#define ID3D12Device14_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->CreateFence(InitialValue,Flags,riid,ppFence) ) +#define ID3D12Device14_GetDeviceRemovedReason(This) \ + ( (This)->GetDeviceRemovedReason() ) +#define ID3D12Device14_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device14_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->CreateQueryHeap(pDesc,riid,ppvHeap) ) +#define ID3D12Device14_SetStablePowerState(This,Enable) \ + ( (This)->SetStablePowerState(Enable) ) +#define ID3D12Device14_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->CreateCommandSignature(pDesc,pRootSignature,riid,ppvCommandSignature) ) +#define ID3D12Device14_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->GetResourceTiling(pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#define ID3D12Device14_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->CreatePipelineLibrary(pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) +#define ID3D12Device14_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->SetEventOnMultipleFenceCompletion(ppFences,pFenceValues,NumFences,Flags,hEvent) ) +#define ID3D12Device14_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->SetResidencyPriority(NumObjects,ppObjects,pPriorities) ) +#define ID3D12Device14_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->CreatePipelineState(pDesc,riid,ppPipelineState) ) +#define ID3D12Device14_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress(pAddress,riid,ppvHeap) ) +#define ID3D12Device14_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromFileMapping(hFileMapping,riid,ppvHeap) ) +#define ID3D12Device14_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->EnqueueMakeResident(Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) +#define ID3D12Device14_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->CreateCommandList1(nodeMask,type,flags,riid,ppCommandList) ) +#define ID3D12Device14_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession(pDesc,riid,ppSession) ) +#define ID3D12Device14_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource1(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device14_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->CreateHeap1(pDesc,pProtectedSession,riid,ppvHeap) ) +#define ID3D12Device14_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->CreateReservedResource1(pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#define ID3D12Device14_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->CreateLifetimeTracker(pOwner,riid,ppvTracker) ) +#define ID3D12Device14_RemoveDevice(This) \ + ( (This)->RemoveDevice() ) +#define ID3D12Device14_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->EnumerateMetaCommands(pNumMetaCommands,pDescs) ) +#define ID3D12Device14_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->EnumerateMetaCommandParameters(CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) +#define ID3D12Device14_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->CreateMetaCommand(CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) +#define ID3D12Device14_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->CreateStateObject(pDesc,riid,ppStateObject) ) +#define ID3D12Device14_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->GetRaytracingAccelerationStructurePrebuildInfo(pDesc,pInfo) ) +#define ID3D12Device14_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->CheckDriverMatchingIdentifier(SerializedDataType,pIdentifierToCheck) ) +#define ID3D12Device14_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->SetBackgroundProcessingMode(Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) +#define ID3D12Device14_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->AddToStateObject(pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) +#define ID3D12Device14_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->CreateProtectedResourceSession1(pDesc,riid,ppSession) ) +#define ID3D12Device14_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource2(pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) +#define ID3D12Device14_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->CreatePlacedResource1(pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) +#define ID3D12Device14_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->CreateSamplerFeedbackUnorderedAccessView(pTargetedResource,pFeedbackResource,DestDescriptor) ) +#define ID3D12Device14_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->GetCopyableFootprints1(pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) +#define ID3D12Device14_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->CreateShaderCacheSession(pDesc,riid,ppvSession) ) +#define ID3D12Device14_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->ShaderCacheControl(Kinds,Control) ) +#define ID3D12Device14_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->CreateCommandQueue1(pDesc,CreatorID,riid,ppCommandQueue) ) +#define ID3D12Device14_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->CreateCommittedResource3(pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) +#define ID3D12Device14_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreatePlacedResource2(pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device14_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->CreateReservedResource2(pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) +#define ID3D12Device14_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->CreateSampler2(pDesc,DestDescriptor) ) +#define ID3D12Device14_OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) \ + ( (This)->OpenExistingHeapFromAddress1(pAddress,size,riid,ppvHeap) ) +#define ID3D12Device14_CreateRootSignatureFromSubobjectInLibrary(This,nodeMask,pLibraryBlob,blobLengthInBytes,subobjectName,riid,ppvRootSignature) \ + ( (This)->CreateRootSignatureFromSubobjectInLibrary(nodeMask,pLibraryBlob,blobLengthInBytes,subobjectName,riid,ppvRootSignature) ) +#define ID3D12VirtualizationGuestDevice_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12VirtualizationGuestDevice_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12VirtualizationGuestDevice_Release(This) \ + ( (This)->Release() ) +#define ID3D12VirtualizationGuestDevice_ShareWithHost(This,pObject,pHandle) \ + ( (This)->ShareWithHost(pObject,pHandle) ) +#define ID3D12VirtualizationGuestDevice_CreateFenceFd(This,pFence,FenceValue,pFenceFd) \ + ( (This)->CreateFenceFd(pFence,FenceValue,pFenceFd) ) +#define ID3D12Tools_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Tools_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Tools_Release(This) \ + ( (This)->Release() ) +#define ID3D12Tools_EnableShaderInstrumentation(This,bEnable) \ + ( (This)->EnableShaderInstrumentation(bEnable) ) +#define ID3D12Tools_ShaderInstrumentationEnabled(This) \ + ( (This)->ShaderInstrumentationEnabled() ) +#define ID3D12SDKConfiguration_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12SDKConfiguration_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12SDKConfiguration_Release(This) \ + ( (This)->Release() ) +#define ID3D12SDKConfiguration_SetSDKVersion(This,SDKVersion,SDKPath) \ + ( (This)->SetSDKVersion(SDKVersion,SDKPath) ) +#define ID3D12SDKConfiguration1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12SDKConfiguration1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12SDKConfiguration1_Release(This) \ + ( (This)->Release() ) +#define ID3D12SDKConfiguration1_SetSDKVersion(This,SDKVersion,SDKPath) \ + ( (This)->SetSDKVersion(SDKVersion,SDKPath) ) +#define ID3D12SDKConfiguration1_CreateDeviceFactory(This,SDKVersion,SDKPath,riid,ppvFactory) \ + ( (This)->CreateDeviceFactory(SDKVersion,SDKPath,riid,ppvFactory) ) +#define ID3D12SDKConfiguration1_FreeUnusedSDKs(This) \ + ( (This)->FreeUnusedSDKs() ) +#define ID3D12DeviceFactory_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceFactory_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceFactory_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceFactory_InitializeFromGlobalState(This) \ + ( (This)->InitializeFromGlobalState() ) +#define ID3D12DeviceFactory_ApplyToGlobalState(This) \ + ( (This)->ApplyToGlobalState() ) +#define ID3D12DeviceFactory_SetFlags(This,flags) \ + ( (This)->SetFlags(flags) ) +#define ID3D12DeviceFactory_GetFlags(This) \ + ( (This)->GetFlags() ) +#define ID3D12DeviceFactory_GetConfigurationInterface(This,clsid,iid,ppv) \ + ( (This)->GetConfigurationInterface(clsid,iid,ppv) ) +#define ID3D12DeviceFactory_EnableExperimentalFeatures(This,NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) \ + ( (This)->EnableExperimentalFeatures(NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) ) +#define ID3D12DeviceFactory_CreateDevice(This,adapter,FeatureLevel,riid,ppvDevice) \ + ( (This)->CreateDevice(adapter,FeatureLevel,riid,ppvDevice) ) +#define ID3D12DeviceConfiguration_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceConfiguration_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceConfiguration_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceConfiguration_GetEnabledExperimentalFeatures(This,pGuids,NumGuids) \ + ( (This)->GetEnabledExperimentalFeatures(pGuids,NumGuids) ) +#define ID3D12DeviceConfiguration_SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) \ + ( (This)->SerializeVersionedRootSignature(pDesc,ppResult,ppError) ) +#define ID3D12DeviceConfiguration_CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) \ + ( (This)->CreateVersionedRootSignatureDeserializer(pBlob,Size,riid,ppvDeserializer) ) +#define ID3D12DeviceConfiguration1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DeviceConfiguration1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DeviceConfiguration1_Release(This) \ + ( (This)->Release() ) +#define ID3D12DeviceConfiguration1_GetEnabledExperimentalFeatures(This,pGuids,NumGuids) \ + ( (This)->GetEnabledExperimentalFeatures(pGuids,NumGuids) ) +#define ID3D12DeviceConfiguration1_SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) \ + ( (This)->SerializeVersionedRootSignature(pDesc,ppResult,ppError) ) +#define ID3D12DeviceConfiguration1_CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) \ + ( (This)->CreateVersionedRootSignatureDeserializer(pBlob,Size,riid,ppvDeserializer) ) +#define ID3D12DeviceConfiguration1_CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary(This,pLibraryBlob,Size,RootSignatureSubobjectName,riid,ppvDeserializer) \ + ( (This)->CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary(pLibraryBlob,Size,RootSignatureSubobjectName,riid,ppvDeserializer) ) +#define ID3D12GraphicsCommandList5_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList5_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList5_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList5_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList5_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList5_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList5_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList5_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList5_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList5_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList5_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList5_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList5_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList5_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList5_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList5_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList5_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList5_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList5_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList5_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList5_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList5_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList5_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList5_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList5_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList5_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList5_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList5_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList5_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList5_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList5_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList5_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList5_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList5_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList5_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList5_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList5_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList5_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList5_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList5_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList5_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList5_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList5_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList5_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList5_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList5_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList5_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList5_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList5_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList5_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList5_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList5_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList5_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList5_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList5_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList5_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12GraphicsCommandList5_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->BeginRenderPass(NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) +#define ID3D12GraphicsCommandList5_EndRenderPass(This) \ + ( (This)->EndRenderPass() ) +#define ID3D12GraphicsCommandList5_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->InitializeMetaCommand(pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList5_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->ExecuteMetaCommand(pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList5_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->BuildRaytracingAccelerationStructure(pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) +#define ID3D12GraphicsCommandList5_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->EmitRaytracingAccelerationStructurePostbuildInfo(pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) +#define ID3D12GraphicsCommandList5_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->CopyRaytracingAccelerationStructure(DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) +#define ID3D12GraphicsCommandList5_SetPipelineState1(This,pStateObject) \ + ( (This)->SetPipelineState1(pStateObject) ) +#define ID3D12GraphicsCommandList5_DispatchRays(This,pDesc) \ + ( (This)->DispatchRays(pDesc) ) +#define ID3D12GraphicsCommandList5_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->RSSetShadingRate(baseShadingRate,combiners) ) +#define ID3D12GraphicsCommandList5_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->RSSetShadingRateImage(shadingRateImage) ) +#define ID3D12GraphicsCommandList6_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList6_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList6_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList6_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList6_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList6_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList6_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList6_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList6_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList6_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList6_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList6_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList6_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList6_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList6_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList6_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList6_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList6_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList6_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList6_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList6_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList6_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList6_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList6_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList6_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList6_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList6_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList6_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList6_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList6_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList6_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList6_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList6_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList6_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList6_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList6_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList6_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList6_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList6_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList6_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList6_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList6_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList6_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList6_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList6_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList6_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList6_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList6_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList6_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList6_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList6_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList6_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList6_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList6_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList6_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList6_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList6_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList6_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList6_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList6_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12GraphicsCommandList6_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->BeginRenderPass(NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) +#define ID3D12GraphicsCommandList6_EndRenderPass(This) \ + ( (This)->EndRenderPass() ) +#define ID3D12GraphicsCommandList6_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->InitializeMetaCommand(pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList6_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->ExecuteMetaCommand(pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList6_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->BuildRaytracingAccelerationStructure(pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) +#define ID3D12GraphicsCommandList6_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->EmitRaytracingAccelerationStructurePostbuildInfo(pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) +#define ID3D12GraphicsCommandList6_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->CopyRaytracingAccelerationStructure(DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) +#define ID3D12GraphicsCommandList6_SetPipelineState1(This,pStateObject) \ + ( (This)->SetPipelineState1(pStateObject) ) +#define ID3D12GraphicsCommandList6_DispatchRays(This,pDesc) \ + ( (This)->DispatchRays(pDesc) ) +#define ID3D12GraphicsCommandList6_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->RSSetShadingRate(baseShadingRate,combiners) ) +#define ID3D12GraphicsCommandList6_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->RSSetShadingRateImage(shadingRateImage) ) +#define ID3D12GraphicsCommandList6_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->DispatchMesh(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList7_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList7_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList7_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList7_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList7_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList7_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList7_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList7_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList7_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList7_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList7_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList7_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList7_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList7_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList7_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList7_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList7_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList7_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList7_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList7_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList7_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList7_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList7_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList7_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList7_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList7_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList7_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList7_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList7_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList7_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList7_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList7_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList7_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList7_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList7_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList7_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList7_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList7_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList7_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList7_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList7_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList7_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList7_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList7_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList7_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList7_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList7_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList7_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList7_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList7_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList7_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList7_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList7_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList7_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList7_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList7_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList7_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList7_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList7_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList7_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12GraphicsCommandList7_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->BeginRenderPass(NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) +#define ID3D12GraphicsCommandList7_EndRenderPass(This) \ + ( (This)->EndRenderPass() ) +#define ID3D12GraphicsCommandList7_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->InitializeMetaCommand(pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList7_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->ExecuteMetaCommand(pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList7_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->BuildRaytracingAccelerationStructure(pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) +#define ID3D12GraphicsCommandList7_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->EmitRaytracingAccelerationStructurePostbuildInfo(pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) +#define ID3D12GraphicsCommandList7_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->CopyRaytracingAccelerationStructure(DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) +#define ID3D12GraphicsCommandList7_SetPipelineState1(This,pStateObject) \ + ( (This)->SetPipelineState1(pStateObject) ) +#define ID3D12GraphicsCommandList7_DispatchRays(This,pDesc) \ + ( (This)->DispatchRays(pDesc) ) +#define ID3D12GraphicsCommandList7_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->RSSetShadingRate(baseShadingRate,combiners) ) +#define ID3D12GraphicsCommandList7_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->RSSetShadingRateImage(shadingRateImage) ) +#define ID3D12GraphicsCommandList7_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->DispatchMesh(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList7_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->Barrier(NumBarrierGroups,pBarrierGroups) ) +#define ID3D12GraphicsCommandList8_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList8_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList8_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList8_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList8_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList8_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList8_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList8_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList8_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList8_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList8_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList8_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList8_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList8_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList8_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList8_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList8_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList8_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList8_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList8_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList8_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList8_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList8_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList8_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList8_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList8_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList8_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList8_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList8_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList8_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList8_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList8_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList8_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList8_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList8_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList8_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList8_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList8_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList8_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList8_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList8_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList8_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList8_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList8_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList8_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList8_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList8_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList8_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList8_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList8_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList8_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList8_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList8_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList8_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList8_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList8_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList8_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList8_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList8_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList8_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12GraphicsCommandList8_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->BeginRenderPass(NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) +#define ID3D12GraphicsCommandList8_EndRenderPass(This) \ + ( (This)->EndRenderPass() ) +#define ID3D12GraphicsCommandList8_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->InitializeMetaCommand(pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList8_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->ExecuteMetaCommand(pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList8_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->BuildRaytracingAccelerationStructure(pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) +#define ID3D12GraphicsCommandList8_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->EmitRaytracingAccelerationStructurePostbuildInfo(pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) +#define ID3D12GraphicsCommandList8_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->CopyRaytracingAccelerationStructure(DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) +#define ID3D12GraphicsCommandList8_SetPipelineState1(This,pStateObject) \ + ( (This)->SetPipelineState1(pStateObject) ) +#define ID3D12GraphicsCommandList8_DispatchRays(This,pDesc) \ + ( (This)->DispatchRays(pDesc) ) +#define ID3D12GraphicsCommandList8_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->RSSetShadingRate(baseShadingRate,combiners) ) +#define ID3D12GraphicsCommandList8_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->RSSetShadingRateImage(shadingRateImage) ) +#define ID3D12GraphicsCommandList8_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->DispatchMesh(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList8_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->Barrier(NumBarrierGroups,pBarrierGroups) ) +#define ID3D12GraphicsCommandList8_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ + ( (This)->OMSetFrontAndBackStencilRef(FrontStencilRef,BackStencilRef) ) +#define ID3D12GraphicsCommandList9_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList9_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList9_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList9_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList9_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList9_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList9_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList9_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList9_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList9_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList9_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList9_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList9_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList9_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList9_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList9_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList9_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList9_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList9_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList9_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList9_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList9_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList9_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList9_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList9_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList9_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList9_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList9_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList9_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList9_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList9_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList9_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList9_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList9_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList9_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList9_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList9_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList9_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList9_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList9_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList9_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList9_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList9_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList9_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList9_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList9_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList9_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList9_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList9_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList9_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList9_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList9_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList9_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList9_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList9_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList9_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList9_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList9_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList9_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList9_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12GraphicsCommandList9_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->BeginRenderPass(NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) +#define ID3D12GraphicsCommandList9_EndRenderPass(This) \ + ( (This)->EndRenderPass() ) +#define ID3D12GraphicsCommandList9_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->InitializeMetaCommand(pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList9_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->ExecuteMetaCommand(pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList9_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->BuildRaytracingAccelerationStructure(pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) +#define ID3D12GraphicsCommandList9_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->EmitRaytracingAccelerationStructurePostbuildInfo(pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) +#define ID3D12GraphicsCommandList9_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->CopyRaytracingAccelerationStructure(DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) +#define ID3D12GraphicsCommandList9_SetPipelineState1(This,pStateObject) \ + ( (This)->SetPipelineState1(pStateObject) ) +#define ID3D12GraphicsCommandList9_DispatchRays(This,pDesc) \ + ( (This)->DispatchRays(pDesc) ) +#define ID3D12GraphicsCommandList9_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->RSSetShadingRate(baseShadingRate,combiners) ) +#define ID3D12GraphicsCommandList9_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->RSSetShadingRateImage(shadingRateImage) ) +#define ID3D12GraphicsCommandList9_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->DispatchMesh(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList9_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->Barrier(NumBarrierGroups,pBarrierGroups) ) +#define ID3D12GraphicsCommandList9_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ + ( (This)->OMSetFrontAndBackStencilRef(FrontStencilRef,BackStencilRef) ) +#define ID3D12GraphicsCommandList9_RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) \ + ( (This)->RSSetDepthBias(DepthBias,DepthBiasClamp,SlopeScaledDepthBias) ) +#define ID3D12GraphicsCommandList9_IASetIndexBufferStripCutValue(This,IBStripCutValue) \ + ( (This)->IASetIndexBufferStripCutValue(IBStripCutValue) ) +#define ID3D12GraphicsCommandList10_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GraphicsCommandList10_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GraphicsCommandList10_Release(This) \ + ( (This)->Release() ) +#define ID3D12GraphicsCommandList10_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->GetPrivateData(guid,pDataSize,pData) ) +#define ID3D12GraphicsCommandList10_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->SetPrivateData(guid,DataSize,pData) ) +#define ID3D12GraphicsCommandList10_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->SetPrivateDataInterface(guid,pData) ) +#define ID3D12GraphicsCommandList10_SetName(This,Name) \ + ( (This)->SetName(Name) ) +#define ID3D12GraphicsCommandList10_GetDevice(This,riid,ppvDevice) \ + ( (This)->GetDevice(riid,ppvDevice) ) +#define ID3D12GraphicsCommandList10_GetType(This) \ + ( (This)->GetType() ) +#define ID3D12GraphicsCommandList10_Close(This) \ + ( (This)->Close() ) +#define ID3D12GraphicsCommandList10_Reset(This,pAllocator,pInitialState) \ + ( (This)->Reset(pAllocator,pInitialState) ) +#define ID3D12GraphicsCommandList10_ClearState(This,pPipelineState) \ + ( (This)->ClearState(pPipelineState) ) +#define ID3D12GraphicsCommandList10_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->DrawInstanced(VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList10_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->DrawIndexedInstanced(IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) +#define ID3D12GraphicsCommandList10_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->Dispatch(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList10_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->CopyBufferRegion(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) +#define ID3D12GraphicsCommandList10_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->CopyTextureRegion(pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) +#define ID3D12GraphicsCommandList10_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->CopyResource(pDstResource,pSrcResource) ) +#define ID3D12GraphicsCommandList10_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->CopyTiles(pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) +#define ID3D12GraphicsCommandList10_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->ResolveSubresource(pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) +#define ID3D12GraphicsCommandList10_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->IASetPrimitiveTopology(PrimitiveTopology) ) +#define ID3D12GraphicsCommandList10_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->RSSetViewports(NumViewports,pViewports) ) +#define ID3D12GraphicsCommandList10_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->RSSetScissorRects(NumRects,pRects) ) +#define ID3D12GraphicsCommandList10_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->OMSetBlendFactor(BlendFactor) ) +#define ID3D12GraphicsCommandList10_OMSetStencilRef(This,StencilRef) \ + ( (This)->OMSetStencilRef(StencilRef) ) +#define ID3D12GraphicsCommandList10_SetPipelineState(This,pPipelineState) \ + ( (This)->SetPipelineState(pPipelineState) ) +#define ID3D12GraphicsCommandList10_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->ResourceBarrier(NumBarriers,pBarriers) ) +#define ID3D12GraphicsCommandList10_ExecuteBundle(This,pCommandList) \ + ( (This)->ExecuteBundle(pCommandList) ) +#define ID3D12GraphicsCommandList10_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->SetDescriptorHeaps(NumDescriptorHeaps,ppDescriptorHeaps) ) +#define ID3D12GraphicsCommandList10_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->SetComputeRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList10_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->SetGraphicsRootSignature(pRootSignature) ) +#define ID3D12GraphicsCommandList10_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetComputeRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList10_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->SetGraphicsRootDescriptorTable(RootParameterIndex,BaseDescriptor) ) +#define ID3D12GraphicsCommandList10_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList10_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstant(RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList10_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetComputeRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList10_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->SetGraphicsRoot32BitConstants(RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) +#define ID3D12GraphicsCommandList10_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList10_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootConstantBufferView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList10_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList10_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootShaderResourceView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList10_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetComputeRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList10_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->SetGraphicsRootUnorderedAccessView(RootParameterIndex,BufferLocation) ) +#define ID3D12GraphicsCommandList10_IASetIndexBuffer(This,pView) \ + ( (This)->IASetIndexBuffer(pView) ) +#define ID3D12GraphicsCommandList10_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->IASetVertexBuffers(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList10_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->SOSetTargets(StartSlot,NumViews,pViews) ) +#define ID3D12GraphicsCommandList10_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->OMSetRenderTargets(NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) +#define ID3D12GraphicsCommandList10_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->ClearDepthStencilView(DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) +#define ID3D12GraphicsCommandList10_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->ClearRenderTargetView(RenderTargetView,ColorRGBA,NumRects,pRects) ) +#define ID3D12GraphicsCommandList10_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewUint(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList10_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->ClearUnorderedAccessViewFloat(ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) +#define ID3D12GraphicsCommandList10_DiscardResource(This,pResource,pRegion) \ + ( (This)->DiscardResource(pResource,pRegion) ) +#define ID3D12GraphicsCommandList10_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->BeginQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList10_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->EndQuery(pQueryHeap,Type,Index) ) +#define ID3D12GraphicsCommandList10_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->ResolveQueryData(pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) +#define ID3D12GraphicsCommandList10_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->SetPredication(pBuffer,AlignedBufferOffset,Operation) ) +#define ID3D12GraphicsCommandList10_SetMarker(This,Metadata,pData,Size) \ + ( (This)->SetMarker(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList10_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->BeginEvent(Metadata,pData,Size) ) +#define ID3D12GraphicsCommandList10_EndEvent(This) \ + ( (This)->EndEvent() ) +#define ID3D12GraphicsCommandList10_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->ExecuteIndirect(pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) +#define ID3D12GraphicsCommandList10_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList10_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->AtomicCopyBufferUINT64(pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) +#define ID3D12GraphicsCommandList10_OMSetDepthBounds(This,Min,Max) \ + ( (This)->OMSetDepthBounds(Min,Max) ) +#define ID3D12GraphicsCommandList10_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->SetSamplePositions(NumSamplesPerPixel,NumPixels,pSamplePositions) ) +#define ID3D12GraphicsCommandList10_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->ResolveSubresourceRegion(pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) +#define ID3D12GraphicsCommandList10_SetViewInstanceMask(This,Mask) \ + ( (This)->SetViewInstanceMask(Mask) ) +#define ID3D12GraphicsCommandList10_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->WriteBufferImmediate(Count,pParams,pModes) ) +#define ID3D12GraphicsCommandList10_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->SetProtectedResourceSession(pProtectedResourceSession) ) +#define ID3D12GraphicsCommandList10_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->BeginRenderPass(NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) +#define ID3D12GraphicsCommandList10_EndRenderPass(This) \ + ( (This)->EndRenderPass() ) +#define ID3D12GraphicsCommandList10_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->InitializeMetaCommand(pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList10_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->ExecuteMetaCommand(pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) +#define ID3D12GraphicsCommandList10_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->BuildRaytracingAccelerationStructure(pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) +#define ID3D12GraphicsCommandList10_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->EmitRaytracingAccelerationStructurePostbuildInfo(pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) +#define ID3D12GraphicsCommandList10_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->CopyRaytracingAccelerationStructure(DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) +#define ID3D12GraphicsCommandList10_SetPipelineState1(This,pStateObject) \ + ( (This)->SetPipelineState1(pStateObject) ) +#define ID3D12GraphicsCommandList10_DispatchRays(This,pDesc) \ + ( (This)->DispatchRays(pDesc) ) +#define ID3D12GraphicsCommandList10_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->RSSetShadingRate(baseShadingRate,combiners) ) +#define ID3D12GraphicsCommandList10_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->RSSetShadingRateImage(shadingRateImage) ) +#define ID3D12GraphicsCommandList10_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->DispatchMesh(ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) +#define ID3D12GraphicsCommandList10_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->Barrier(NumBarrierGroups,pBarrierGroups) ) +#define ID3D12GraphicsCommandList10_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ + ( (This)->OMSetFrontAndBackStencilRef(FrontStencilRef,BackStencilRef) ) +#define ID3D12GraphicsCommandList10_RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) \ + ( (This)->RSSetDepthBias(DepthBias,DepthBiasClamp,SlopeScaledDepthBias) ) +#define ID3D12GraphicsCommandList10_IASetIndexBufferStripCutValue(This,IBStripCutValue) \ + ( (This)->IASetIndexBufferStripCutValue(IBStripCutValue) ) +#define ID3D12GraphicsCommandList10_SetProgram(This,pDesc) \ + ( (This)->SetProgram(pDesc) ) +#define ID3D12GraphicsCommandList10_DispatchGraph(This,pDesc) \ + ( (This)->DispatchGraph(pDesc) ) +#define ID3D12GBVDiagnostics_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12GBVDiagnostics_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12GBVDiagnostics_Release(This) \ + ( (This)->Release() ) +#define ID3D12GBVDiagnostics_GetGBVEntireSubresourceStatesData(This,pResource,pData,DataSize) \ + ( (This)->GetGBVEntireSubresourceStatesData(pResource,pData,DataSize) ) +#define ID3D12GBVDiagnostics_GetGBVSubresourceState(This,pResource,Subresource,pData) \ + ( (This)->GetGBVSubresourceState(pResource,Subresource,pData) ) +#define ID3D12GBVDiagnostics_GetGBVResourceUniformState(This,pResource,pData) \ + ( (This)->GetGBVResourceUniformState(pResource,pData) ) +#define ID3D12GBVDiagnostics_GetGBVResourceInfo(This,pResource,pResourceDesc,pResourceHash,pSubresourceStatesByteOffset) \ + ( (This)->GetGBVResourceInfo(pResource,pResourceDesc,pResourceHash,pSubresourceStatesByteOffset) ) +#define ID3D12GBVDiagnostics_GBVReserved0(This) \ + ( (This)->GBVReserved0() ) +#define ID3D12GBVDiagnostics_GBVReserved1(This) \ + ( (This)->GBVReserved1() ) +#define ID3D12Debug_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Debug_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Debug_Release(This) \ + ( (This)->Release() ) +#define ID3D12Debug_EnableDebugLayer(This) \ + ( (This)->EnableDebugLayer() ) +#define ID3D12Debug1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Debug1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Debug1_Release(This) \ + ( (This)->Release() ) +#define ID3D12Debug1_EnableDebugLayer(This) \ + ( (This)->EnableDebugLayer() ) +#define ID3D12Debug1_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->SetEnableGPUBasedValidation(Enable) ) +#define ID3D12Debug1_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->SetEnableSynchronizedCommandQueueValidation(Enable) ) +#define ID3D12Debug2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Debug2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Debug2_Release(This) \ + ( (This)->Release() ) +#define ID3D12Debug2_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->SetGPUBasedValidationFlags(Flags) ) +#define ID3D12Debug3_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Debug3_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Debug3_Release(This) \ + ( (This)->Release() ) +#define ID3D12Debug3_EnableDebugLayer(This) \ + ( (This)->EnableDebugLayer() ) +#define ID3D12Debug3_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->SetEnableGPUBasedValidation(Enable) ) +#define ID3D12Debug3_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->SetEnableSynchronizedCommandQueueValidation(Enable) ) +#define ID3D12Debug3_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->SetGPUBasedValidationFlags(Flags) ) +#define ID3D12Debug4_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Debug4_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Debug4_Release(This) \ + ( (This)->Release() ) +#define ID3D12Debug4_EnableDebugLayer(This) \ + ( (This)->EnableDebugLayer() ) +#define ID3D12Debug4_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->SetEnableGPUBasedValidation(Enable) ) +#define ID3D12Debug4_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->SetEnableSynchronizedCommandQueueValidation(Enable) ) +#define ID3D12Debug4_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->SetGPUBasedValidationFlags(Flags) ) +#define ID3D12Debug4_DisableDebugLayer(This) \ + ( (This)->DisableDebugLayer() ) +#define ID3D12Debug5_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Debug5_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Debug5_Release(This) \ + ( (This)->Release() ) +#define ID3D12Debug5_EnableDebugLayer(This) \ + ( (This)->EnableDebugLayer() ) +#define ID3D12Debug5_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->SetEnableGPUBasedValidation(Enable) ) +#define ID3D12Debug5_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->SetEnableSynchronizedCommandQueueValidation(Enable) ) +#define ID3D12Debug5_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->SetGPUBasedValidationFlags(Flags) ) +#define ID3D12Debug5_DisableDebugLayer(This) \ + ( (This)->DisableDebugLayer() ) +#define ID3D12Debug5_SetEnableAutoName(This,Enable) \ + ( (This)->SetEnableAutoName(Enable) ) +#define ID3D12Debug6_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12Debug6_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12Debug6_Release(This) \ + ( (This)->Release() ) +#define ID3D12Debug6_EnableDebugLayer(This) \ + ( (This)->EnableDebugLayer() ) +#define ID3D12Debug6_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->SetEnableGPUBasedValidation(Enable) ) +#define ID3D12Debug6_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->SetEnableSynchronizedCommandQueueValidation(Enable) ) +#define ID3D12Debug6_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->SetGPUBasedValidationFlags(Flags) ) +#define ID3D12Debug6_DisableDebugLayer(This) \ + ( (This)->DisableDebugLayer() ) +#define ID3D12Debug6_SetEnableAutoName(This,Enable) \ + ( (This)->SetEnableAutoName(Enable) ) +#define ID3D12Debug6_SetForceLegacyBarrierValidation(This,Enable) \ + ( (This)->SetForceLegacyBarrierValidation(Enable) ) +#define ID3D12DebugDevice1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugDevice1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugDevice1_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugDevice1_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->SetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugDevice1_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->GetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugDevice1_ReportLiveDeviceObjects(This,Flags) \ + ( (This)->ReportLiveDeviceObjects(Flags) ) +#define ID3D12DebugDevice_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugDevice_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugDevice_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugDevice_SetFeatureMask(This,Mask) \ + ( (This)->SetFeatureMask(Mask) ) +#define ID3D12DebugDevice_GetFeatureMask(This) \ + ( (This)->GetFeatureMask() ) +#define ID3D12DebugDevice_ReportLiveDeviceObjects(This,Flags) \ + ( (This)->ReportLiveDeviceObjects(Flags) ) +#define ID3D12DebugDevice2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugDevice2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugDevice2_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugDevice2_SetFeatureMask(This,Mask) \ + ( (This)->SetFeatureMask(Mask) ) +#define ID3D12DebugDevice2_GetFeatureMask(This) \ + ( (This)->GetFeatureMask() ) +#define ID3D12DebugDevice2_ReportLiveDeviceObjects(This,Flags) \ + ( (This)->ReportLiveDeviceObjects(Flags) ) +#define ID3D12DebugDevice2_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->SetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugDevice2_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->GetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugCommandQueue_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugCommandQueue_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugCommandQueue_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugCommandQueue_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->AssertResourceState(pResource,Subresource,State) ) +#define ID3D12DebugCommandQueue1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugCommandQueue1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugCommandQueue1_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugCommandQueue1_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->AssertResourceState(pResource,Subresource,State) ) +#define ID3D12DebugCommandQueue1_AssertResourceAccess(This,pResource,Subresource,Access) \ + ( (This)->AssertResourceAccess(pResource,Subresource,Access) ) +#define ID3D12DebugCommandQueue1_AssertTextureLayout(This,pResource,Subresource,Layout) \ + ( (This)->AssertTextureLayout(pResource,Subresource,Layout) ) +#define ID3D12DebugCommandList1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugCommandList1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugCommandList1_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugCommandList1_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->AssertResourceState(pResource,Subresource,State) ) +#define ID3D12DebugCommandList1_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->SetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugCommandList1_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->GetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugCommandList_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugCommandList_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugCommandList_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugCommandList_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->AssertResourceState(pResource,Subresource,State) ) +#define ID3D12DebugCommandList_SetFeatureMask(This,Mask) \ + ( (This)->SetFeatureMask(Mask) ) +#define ID3D12DebugCommandList_GetFeatureMask(This) \ + ( (This)->GetFeatureMask() ) +#define ID3D12DebugCommandList2_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugCommandList2_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugCommandList2_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugCommandList2_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->AssertResourceState(pResource,Subresource,State) ) +#define ID3D12DebugCommandList2_SetFeatureMask(This,Mask) \ + ( (This)->SetFeatureMask(Mask) ) +#define ID3D12DebugCommandList2_GetFeatureMask(This) \ + ( (This)->GetFeatureMask() ) +#define ID3D12DebugCommandList2_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->SetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugCommandList2_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->GetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugCommandList3_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12DebugCommandList3_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12DebugCommandList3_Release(This) \ + ( (This)->Release() ) +#define ID3D12DebugCommandList3_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->AssertResourceState(pResource,Subresource,State) ) +#define ID3D12DebugCommandList3_SetFeatureMask(This,Mask) \ + ( (This)->SetFeatureMask(Mask) ) +#define ID3D12DebugCommandList3_GetFeatureMask(This) \ + ( (This)->GetFeatureMask() ) +#define ID3D12DebugCommandList3_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->SetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugCommandList3_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->GetDebugParameter(Type,pData,DataSize) ) +#define ID3D12DebugCommandList3_AssertResourceAccess(This,pResource,Subresource,Access) \ + ( (This)->AssertResourceAccess(pResource,Subresource,Access) ) +#define ID3D12DebugCommandList3_AssertTextureLayout(This,pResource,Subresource,Layout) \ + ( (This)->AssertTextureLayout(pResource,Subresource,Layout) ) +#define ID3D12SharingContract_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12SharingContract_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12SharingContract_Release(This) \ + ( (This)->Release() ) +#define ID3D12SharingContract_Present(This,pResource,Subresource,window) \ + ( (This)->Present(pResource,Subresource,window) ) +#define ID3D12SharingContract_SharedFenceSignal(This,pFence,FenceValue) \ + ( (This)->SharedFenceSignal(pFence,FenceValue) ) +#define ID3D12SharingContract_BeginCapturableWork(This,guid) \ + ( (This)->BeginCapturableWork(guid) ) +#define ID3D12SharingContract_EndCapturableWork(This,guid) \ + ( (This)->EndCapturableWork(guid) ) +#define ID3D12ManualWriteTrackingResource_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12ManualWriteTrackingResource_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12ManualWriteTrackingResource_Release(This) \ + ( (This)->Release() ) +#define ID3D12ManualWriteTrackingResource_TrackWrite(This,Subresource,pWrittenRange) \ + ( (This)->TrackWrite(Subresource,pWrittenRange) ) +#define ID3D12InfoQueue_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12InfoQueue_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12InfoQueue_Release(This) \ + ( (This)->Release() ) +#define ID3D12InfoQueue_SetMessageCountLimit(This,MessageCountLimit) \ + ( (This)->SetMessageCountLimit(MessageCountLimit) ) +#define ID3D12InfoQueue_ClearStoredMessages(This) \ + ( (This)->ClearStoredMessages() ) +#define ID3D12InfoQueue_GetMessage(This,MessageIndex,pMessage,pMessageByteLength) \ + ( (This)->GetMessage(MessageIndex,pMessage,pMessageByteLength) ) +#define ID3D12InfoQueue_GetNumMessagesAllowedByStorageFilter(This) \ + ( (This)->GetNumMessagesAllowedByStorageFilter() ) +#define ID3D12InfoQueue_GetNumMessagesDeniedByStorageFilter(This) \ + ( (This)->GetNumMessagesDeniedByStorageFilter() ) +#define ID3D12InfoQueue_GetNumStoredMessages(This) \ + ( (This)->GetNumStoredMessages() ) +#define ID3D12InfoQueue_GetNumStoredMessagesAllowedByRetrievalFilter(This) \ + ( (This)->GetNumStoredMessagesAllowedByRetrievalFilter() ) +#define ID3D12InfoQueue_GetNumMessagesDiscardedByMessageCountLimit(This) \ + ( (This)->GetNumMessagesDiscardedByMessageCountLimit() ) +#define ID3D12InfoQueue_GetMessageCountLimit(This) \ + ( (This)->GetMessageCountLimit() ) +#define ID3D12InfoQueue_AddStorageFilterEntries(This,pFilter) \ + ( (This)->AddStorageFilterEntries(pFilter) ) +#define ID3D12InfoQueue_GetStorageFilter(This,pFilter,pFilterByteLength) \ + ( (This)->GetStorageFilter(pFilter,pFilterByteLength) ) +#define ID3D12InfoQueue_ClearStorageFilter(This) \ + ( (This)->ClearStorageFilter() ) +#define ID3D12InfoQueue_PushEmptyStorageFilter(This) \ + ( (This)->PushEmptyStorageFilter() ) +#define ID3D12InfoQueue_PushCopyOfStorageFilter(This) \ + ( (This)->PushCopyOfStorageFilter() ) +#define ID3D12InfoQueue_PushStorageFilter(This,pFilter) \ + ( (This)->PushStorageFilter(pFilter) ) +#define ID3D12InfoQueue_PopStorageFilter(This) \ + ( (This)->PopStorageFilter() ) +#define ID3D12InfoQueue_GetStorageFilterStackSize(This) \ + ( (This)->GetStorageFilterStackSize() ) +#define ID3D12InfoQueue_AddRetrievalFilterEntries(This,pFilter) \ + ( (This)->AddRetrievalFilterEntries(pFilter) ) +#define ID3D12InfoQueue_GetRetrievalFilter(This,pFilter,pFilterByteLength) \ + ( (This)->GetRetrievalFilter(pFilter,pFilterByteLength) ) +#define ID3D12InfoQueue_ClearRetrievalFilter(This) \ + ( (This)->ClearRetrievalFilter() ) +#define ID3D12InfoQueue_PushEmptyRetrievalFilter(This) \ + ( (This)->PushEmptyRetrievalFilter() ) +#define ID3D12InfoQueue_PushCopyOfRetrievalFilter(This) \ + ( (This)->PushCopyOfRetrievalFilter() ) +#define ID3D12InfoQueue_PushRetrievalFilter(This,pFilter) \ + ( (This)->PushRetrievalFilter(pFilter) ) +#define ID3D12InfoQueue_PopRetrievalFilter(This) \ + ( (This)->PopRetrievalFilter() ) +#define ID3D12InfoQueue_GetRetrievalFilterStackSize(This) \ + ( (This)->GetRetrievalFilterStackSize() ) +#define ID3D12InfoQueue_AddMessage(This,Category,Severity,ID,pDescription) \ + ( (This)->AddMessage(Category,Severity,ID,pDescription) ) +#define ID3D12InfoQueue_AddApplicationMessage(This,Severity,pDescription) \ + ( (This)->AddApplicationMessage(Severity,pDescription) ) +#define ID3D12InfoQueue_SetBreakOnCategory(This,Category,bEnable) \ + ( (This)->SetBreakOnCategory(Category,bEnable) ) +#define ID3D12InfoQueue_SetBreakOnSeverity(This,Severity,bEnable) \ + ( (This)->SetBreakOnSeverity(Severity,bEnable) ) +#define ID3D12InfoQueue_SetBreakOnID(This,ID,bEnable) \ + ( (This)->SetBreakOnID(ID,bEnable) ) +#define ID3D12InfoQueue_GetBreakOnCategory(This,Category) \ + ( (This)->GetBreakOnCategory(Category) ) +#define ID3D12InfoQueue_GetBreakOnSeverity(This,Severity) \ + ( (This)->GetBreakOnSeverity(Severity) ) +#define ID3D12InfoQueue_GetBreakOnID(This,ID) \ + ( (This)->GetBreakOnID(ID) ) +#define ID3D12InfoQueue_SetMuteDebugOutput(This,bMute) \ + ( (This)->SetMuteDebugOutput(bMute) ) +#define ID3D12InfoQueue_GetMuteDebugOutput(This) \ + ( (This)->GetMuteDebugOutput() ) +#define ID3D12InfoQueue1_QueryInterface(This,riid,ppvObject) \ + ( (This)->QueryInterface(riid,ppvObject) ) +#define ID3D12InfoQueue1_AddRef(This) \ + ( (This)->AddRef() ) +#define ID3D12InfoQueue1_Release(This) \ + ( (This)->Release() ) +#define ID3D12InfoQueue1_SetMessageCountLimit(This,MessageCountLimit) \ + ( (This)->SetMessageCountLimit(MessageCountLimit) ) +#define ID3D12InfoQueue1_ClearStoredMessages(This) \ + ( (This)->ClearStoredMessages() ) +#define ID3D12InfoQueue1_GetMessage(This,MessageIndex,pMessage,pMessageByteLength) \ + ( (This)->GetMessage(MessageIndex,pMessage,pMessageByteLength) ) +#define ID3D12InfoQueue1_GetNumMessagesAllowedByStorageFilter(This) \ + ( (This)->GetNumMessagesAllowedByStorageFilter() ) +#define ID3D12InfoQueue1_GetNumMessagesDeniedByStorageFilter(This) \ + ( (This)->GetNumMessagesDeniedByStorageFilter() ) +#define ID3D12InfoQueue1_GetNumStoredMessages(This) \ + ( (This)->GetNumStoredMessages() ) +#define ID3D12InfoQueue1_GetNumStoredMessagesAllowedByRetrievalFilter(This) \ + ( (This)->GetNumStoredMessagesAllowedByRetrievalFilter() ) +#define ID3D12InfoQueue1_GetNumMessagesDiscardedByMessageCountLimit(This) \ + ( (This)->GetNumMessagesDiscardedByMessageCountLimit() ) +#define ID3D12InfoQueue1_GetMessageCountLimit(This) \ + ( (This)->GetMessageCountLimit() ) +#define ID3D12InfoQueue1_AddStorageFilterEntries(This,pFilter) \ + ( (This)->AddStorageFilterEntries(pFilter) ) +#define ID3D12InfoQueue1_GetStorageFilter(This,pFilter,pFilterByteLength) \ + ( (This)->GetStorageFilter(pFilter,pFilterByteLength) ) +#define ID3D12InfoQueue1_ClearStorageFilter(This) \ + ( (This)->ClearStorageFilter() ) +#define ID3D12InfoQueue1_PushEmptyStorageFilter(This) \ + ( (This)->PushEmptyStorageFilter() ) +#define ID3D12InfoQueue1_PushCopyOfStorageFilter(This) \ + ( (This)->PushCopyOfStorageFilter() ) +#define ID3D12InfoQueue1_PushStorageFilter(This,pFilter) \ + ( (This)->PushStorageFilter(pFilter) ) +#define ID3D12InfoQueue1_PopStorageFilter(This) \ + ( (This)->PopStorageFilter() ) +#define ID3D12InfoQueue1_GetStorageFilterStackSize(This) \ + ( (This)->GetStorageFilterStackSize() ) +#define ID3D12InfoQueue1_AddRetrievalFilterEntries(This,pFilter) \ + ( (This)->AddRetrievalFilterEntries(pFilter) ) +#define ID3D12InfoQueue1_GetRetrievalFilter(This,pFilter,pFilterByteLength) \ + ( (This)->GetRetrievalFilter(pFilter,pFilterByteLength) ) +#define ID3D12InfoQueue1_ClearRetrievalFilter(This) \ + ( (This)->ClearRetrievalFilter() ) +#define ID3D12InfoQueue1_PushEmptyRetrievalFilter(This) \ + ( (This)->PushEmptyRetrievalFilter() ) +#define ID3D12InfoQueue1_PushCopyOfRetrievalFilter(This) \ + ( (This)->PushCopyOfRetrievalFilter() ) +#define ID3D12InfoQueue1_PushRetrievalFilter(This,pFilter) \ + ( (This)->PushRetrievalFilter(pFilter) ) +#define ID3D12InfoQueue1_PopRetrievalFilter(This) \ + ( (This)->PopRetrievalFilter() ) +#define ID3D12InfoQueue1_GetRetrievalFilterStackSize(This) \ + ( (This)->GetRetrievalFilterStackSize() ) +#define ID3D12InfoQueue1_AddMessage(This,Category,Severity,ID,pDescription) \ + ( (This)->AddMessage(Category,Severity,ID,pDescription) ) +#define ID3D12InfoQueue1_AddApplicationMessage(This,Severity,pDescription) \ + ( (This)->AddApplicationMessage(Severity,pDescription) ) +#define ID3D12InfoQueue1_SetBreakOnCategory(This,Category,bEnable) \ + ( (This)->SetBreakOnCategory(Category,bEnable) ) +#define ID3D12InfoQueue1_SetBreakOnSeverity(This,Severity,bEnable) \ + ( (This)->SetBreakOnSeverity(Severity,bEnable) ) +#define ID3D12InfoQueue1_SetBreakOnID(This,ID,bEnable) \ + ( (This)->SetBreakOnID(ID,bEnable) ) +#define ID3D12InfoQueue1_GetBreakOnCategory(This,Category) \ + ( (This)->GetBreakOnCategory(Category) ) +#define ID3D12InfoQueue1_GetBreakOnSeverity(This,Severity) \ + ( (This)->GetBreakOnSeverity(Severity) ) +#define ID3D12InfoQueue1_GetBreakOnID(This,ID) \ + ( (This)->GetBreakOnID(ID) ) +#define ID3D12InfoQueue1_SetMuteDebugOutput(This,bMute) \ + ( (This)->SetMuteDebugOutput(bMute) ) +#define ID3D12InfoQueue1_GetMuteDebugOutput(This) \ + ( (This)->GetMuteDebugOutput() ) +#define ID3D12InfoQueue1_RegisterMessageCallback(This,CallbackFunc,CallbackFilterFlags,pContext,pCallbackCookie) \ + ( (This)->RegisterMessageCallback(CallbackFunc,CallbackFilterFlags,pContext,pCallbackCookie) ) +#define ID3D12InfoQueue1_UnregisterMessageCallback(This,CallbackCookie) \ + ( (This)->UnregisterMessageCallback(CallbackCookie) ) diff --git a/contrib/SDL-3.2.8/src/video/directx/d3d12.h b/contrib/SDL-3.2.8/src/video/directx/d3d12.h new file mode 100644 index 0000000..eac7fbb --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/directx/d3d12.h @@ -0,0 +1,34949 @@ +/*------------------------------------------------------------------------------------- + * + * Copyright (c) Microsoft Corporation + * Licensed under the MIT license + * + *-------------------------------------------------------------------------------------*/ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 8.01.0628 */ + + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 500 +#endif + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif /* __RPCNDR_H_VERSION__ */ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __d3d12_h__ +#define __d3d12_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +#ifndef DECLSPEC_XFGVIRT +#if defined(_CONTROL_FLOW_GUARD_XFG) +#define DECLSPEC_XFGVIRT(base, func) __declspec(xfg_virtual(base, func)) +#else +#define DECLSPEC_XFGVIRT(base, func) +#endif +#endif + +#ifndef _In_opt_count_ +#define _In_opt_count_(x) +#endif +#ifndef _In_count_ +#define _In_count_(x) +#endif + +/* Forward Declarations */ + +#ifndef __ID3D12Object_FWD_DEFINED__ +#define __ID3D12Object_FWD_DEFINED__ +typedef interface ID3D12Object ID3D12Object; + +#endif /* __ID3D12Object_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceChild_FWD_DEFINED__ +#define __ID3D12DeviceChild_FWD_DEFINED__ +typedef interface ID3D12DeviceChild ID3D12DeviceChild; + +#endif /* __ID3D12DeviceChild_FWD_DEFINED__ */ + + +#ifndef __ID3D12RootSignature_FWD_DEFINED__ +#define __ID3D12RootSignature_FWD_DEFINED__ +typedef interface ID3D12RootSignature ID3D12RootSignature; + +#endif /* __ID3D12RootSignature_FWD_DEFINED__ */ + + +#ifndef __ID3D12RootSignatureDeserializer_FWD_DEFINED__ +#define __ID3D12RootSignatureDeserializer_FWD_DEFINED__ +typedef interface ID3D12RootSignatureDeserializer ID3D12RootSignatureDeserializer; + +#endif /* __ID3D12RootSignatureDeserializer_FWD_DEFINED__ */ + + +#ifndef __ID3D12VersionedRootSignatureDeserializer_FWD_DEFINED__ +#define __ID3D12VersionedRootSignatureDeserializer_FWD_DEFINED__ +typedef interface ID3D12VersionedRootSignatureDeserializer ID3D12VersionedRootSignatureDeserializer; + +#endif /* __ID3D12VersionedRootSignatureDeserializer_FWD_DEFINED__ */ + + +#ifndef __ID3D12Pageable_FWD_DEFINED__ +#define __ID3D12Pageable_FWD_DEFINED__ +typedef interface ID3D12Pageable ID3D12Pageable; + +#endif /* __ID3D12Pageable_FWD_DEFINED__ */ + + +#ifndef __ID3D12Heap_FWD_DEFINED__ +#define __ID3D12Heap_FWD_DEFINED__ +typedef interface ID3D12Heap ID3D12Heap; + +#endif /* __ID3D12Heap_FWD_DEFINED__ */ + + +#ifndef __ID3D12Resource_FWD_DEFINED__ +#define __ID3D12Resource_FWD_DEFINED__ +typedef interface ID3D12Resource ID3D12Resource; + +#endif /* __ID3D12Resource_FWD_DEFINED__ */ + + +#ifndef __ID3D12CommandAllocator_FWD_DEFINED__ +#define __ID3D12CommandAllocator_FWD_DEFINED__ +typedef interface ID3D12CommandAllocator ID3D12CommandAllocator; + +#endif /* __ID3D12CommandAllocator_FWD_DEFINED__ */ + + +#ifndef __ID3D12Fence_FWD_DEFINED__ +#define __ID3D12Fence_FWD_DEFINED__ +typedef interface ID3D12Fence ID3D12Fence; + +#endif /* __ID3D12Fence_FWD_DEFINED__ */ + + +#ifndef __ID3D12Fence1_FWD_DEFINED__ +#define __ID3D12Fence1_FWD_DEFINED__ +typedef interface ID3D12Fence1 ID3D12Fence1; + +#endif /* __ID3D12Fence1_FWD_DEFINED__ */ + + +#ifndef __ID3D12PipelineState_FWD_DEFINED__ +#define __ID3D12PipelineState_FWD_DEFINED__ +typedef interface ID3D12PipelineState ID3D12PipelineState; + +#endif /* __ID3D12PipelineState_FWD_DEFINED__ */ + + +#ifndef __ID3D12DescriptorHeap_FWD_DEFINED__ +#define __ID3D12DescriptorHeap_FWD_DEFINED__ +typedef interface ID3D12DescriptorHeap ID3D12DescriptorHeap; + +#endif /* __ID3D12DescriptorHeap_FWD_DEFINED__ */ + + +#ifndef __ID3D12QueryHeap_FWD_DEFINED__ +#define __ID3D12QueryHeap_FWD_DEFINED__ +typedef interface ID3D12QueryHeap ID3D12QueryHeap; + +#endif /* __ID3D12QueryHeap_FWD_DEFINED__ */ + + +#ifndef __ID3D12CommandSignature_FWD_DEFINED__ +#define __ID3D12CommandSignature_FWD_DEFINED__ +typedef interface ID3D12CommandSignature ID3D12CommandSignature; + +#endif /* __ID3D12CommandSignature_FWD_DEFINED__ */ + + +#ifndef __ID3D12CommandList_FWD_DEFINED__ +#define __ID3D12CommandList_FWD_DEFINED__ +typedef interface ID3D12CommandList ID3D12CommandList; + +#endif /* __ID3D12CommandList_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList ID3D12GraphicsCommandList; + +#endif /* __ID3D12GraphicsCommandList_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList1_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList1 ID3D12GraphicsCommandList1; + +#endif /* __ID3D12GraphicsCommandList1_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList2_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList2_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList2 ID3D12GraphicsCommandList2; + +#endif /* __ID3D12GraphicsCommandList2_FWD_DEFINED__ */ + + +#ifndef __ID3D12CommandQueue_FWD_DEFINED__ +#define __ID3D12CommandQueue_FWD_DEFINED__ +typedef interface ID3D12CommandQueue ID3D12CommandQueue; + +#endif /* __ID3D12CommandQueue_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device_FWD_DEFINED__ +#define __ID3D12Device_FWD_DEFINED__ +typedef interface ID3D12Device ID3D12Device; + +#endif /* __ID3D12Device_FWD_DEFINED__ */ + + +#ifndef __ID3D12PipelineLibrary_FWD_DEFINED__ +#define __ID3D12PipelineLibrary_FWD_DEFINED__ +typedef interface ID3D12PipelineLibrary ID3D12PipelineLibrary; + +#endif /* __ID3D12PipelineLibrary_FWD_DEFINED__ */ + + +#ifndef __ID3D12PipelineLibrary1_FWD_DEFINED__ +#define __ID3D12PipelineLibrary1_FWD_DEFINED__ +typedef interface ID3D12PipelineLibrary1 ID3D12PipelineLibrary1; + +#endif /* __ID3D12PipelineLibrary1_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device1_FWD_DEFINED__ +#define __ID3D12Device1_FWD_DEFINED__ +typedef interface ID3D12Device1 ID3D12Device1; + +#endif /* __ID3D12Device1_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device2_FWD_DEFINED__ +#define __ID3D12Device2_FWD_DEFINED__ +typedef interface ID3D12Device2 ID3D12Device2; + +#endif /* __ID3D12Device2_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device3_FWD_DEFINED__ +#define __ID3D12Device3_FWD_DEFINED__ +typedef interface ID3D12Device3 ID3D12Device3; + +#endif /* __ID3D12Device3_FWD_DEFINED__ */ + + +#ifndef __ID3D12ProtectedSession_FWD_DEFINED__ +#define __ID3D12ProtectedSession_FWD_DEFINED__ +typedef interface ID3D12ProtectedSession ID3D12ProtectedSession; + +#endif /* __ID3D12ProtectedSession_FWD_DEFINED__ */ + + +#ifndef __ID3D12ProtectedResourceSession_FWD_DEFINED__ +#define __ID3D12ProtectedResourceSession_FWD_DEFINED__ +typedef interface ID3D12ProtectedResourceSession ID3D12ProtectedResourceSession; + +#endif /* __ID3D12ProtectedResourceSession_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device4_FWD_DEFINED__ +#define __ID3D12Device4_FWD_DEFINED__ +typedef interface ID3D12Device4 ID3D12Device4; + +#endif /* __ID3D12Device4_FWD_DEFINED__ */ + + +#ifndef __ID3D12LifetimeOwner_FWD_DEFINED__ +#define __ID3D12LifetimeOwner_FWD_DEFINED__ +typedef interface ID3D12LifetimeOwner ID3D12LifetimeOwner; + +#endif /* __ID3D12LifetimeOwner_FWD_DEFINED__ */ + + +#ifndef __ID3D12SwapChainAssistant_FWD_DEFINED__ +#define __ID3D12SwapChainAssistant_FWD_DEFINED__ +typedef interface ID3D12SwapChainAssistant ID3D12SwapChainAssistant; + +#endif /* __ID3D12SwapChainAssistant_FWD_DEFINED__ */ + + +#ifndef __ID3D12LifetimeTracker_FWD_DEFINED__ +#define __ID3D12LifetimeTracker_FWD_DEFINED__ +typedef interface ID3D12LifetimeTracker ID3D12LifetimeTracker; + +#endif /* __ID3D12LifetimeTracker_FWD_DEFINED__ */ + + +#ifndef __ID3D12StateObject_FWD_DEFINED__ +#define __ID3D12StateObject_FWD_DEFINED__ +typedef interface ID3D12StateObject ID3D12StateObject; + +#endif /* __ID3D12StateObject_FWD_DEFINED__ */ + + +#ifndef __ID3D12StateObjectProperties_FWD_DEFINED__ +#define __ID3D12StateObjectProperties_FWD_DEFINED__ +typedef interface ID3D12StateObjectProperties ID3D12StateObjectProperties; + +#endif /* __ID3D12StateObjectProperties_FWD_DEFINED__ */ + + +#ifndef __ID3D12StateObjectProperties1_FWD_DEFINED__ +#define __ID3D12StateObjectProperties1_FWD_DEFINED__ +typedef interface ID3D12StateObjectProperties1 ID3D12StateObjectProperties1; + +#endif /* __ID3D12StateObjectProperties1_FWD_DEFINED__ */ + + +#ifndef __ID3D12WorkGraphProperties_FWD_DEFINED__ +#define __ID3D12WorkGraphProperties_FWD_DEFINED__ +typedef interface ID3D12WorkGraphProperties ID3D12WorkGraphProperties; + +#endif /* __ID3D12WorkGraphProperties_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device5_FWD_DEFINED__ +#define __ID3D12Device5_FWD_DEFINED__ +typedef interface ID3D12Device5 ID3D12Device5; + +#endif /* __ID3D12Device5_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedDataSettings_FWD_DEFINED__ +#define __ID3D12DeviceRemovedExtendedDataSettings_FWD_DEFINED__ +typedef interface ID3D12DeviceRemovedExtendedDataSettings ID3D12DeviceRemovedExtendedDataSettings; + +#endif /* __ID3D12DeviceRemovedExtendedDataSettings_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedDataSettings1_FWD_DEFINED__ +#define __ID3D12DeviceRemovedExtendedDataSettings1_FWD_DEFINED__ +typedef interface ID3D12DeviceRemovedExtendedDataSettings1 ID3D12DeviceRemovedExtendedDataSettings1; + +#endif /* __ID3D12DeviceRemovedExtendedDataSettings1_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedDataSettings2_FWD_DEFINED__ +#define __ID3D12DeviceRemovedExtendedDataSettings2_FWD_DEFINED__ +typedef interface ID3D12DeviceRemovedExtendedDataSettings2 ID3D12DeviceRemovedExtendedDataSettings2; + +#endif /* __ID3D12DeviceRemovedExtendedDataSettings2_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedData_FWD_DEFINED__ +#define __ID3D12DeviceRemovedExtendedData_FWD_DEFINED__ +typedef interface ID3D12DeviceRemovedExtendedData ID3D12DeviceRemovedExtendedData; + +#endif /* __ID3D12DeviceRemovedExtendedData_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedData1_FWD_DEFINED__ +#define __ID3D12DeviceRemovedExtendedData1_FWD_DEFINED__ +typedef interface ID3D12DeviceRemovedExtendedData1 ID3D12DeviceRemovedExtendedData1; + +#endif /* __ID3D12DeviceRemovedExtendedData1_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedData2_FWD_DEFINED__ +#define __ID3D12DeviceRemovedExtendedData2_FWD_DEFINED__ +typedef interface ID3D12DeviceRemovedExtendedData2 ID3D12DeviceRemovedExtendedData2; + +#endif /* __ID3D12DeviceRemovedExtendedData2_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device6_FWD_DEFINED__ +#define __ID3D12Device6_FWD_DEFINED__ +typedef interface ID3D12Device6 ID3D12Device6; + +#endif /* __ID3D12Device6_FWD_DEFINED__ */ + + +#ifndef __ID3D12ProtectedResourceSession1_FWD_DEFINED__ +#define __ID3D12ProtectedResourceSession1_FWD_DEFINED__ +typedef interface ID3D12ProtectedResourceSession1 ID3D12ProtectedResourceSession1; + +#endif /* __ID3D12ProtectedResourceSession1_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device7_FWD_DEFINED__ +#define __ID3D12Device7_FWD_DEFINED__ +typedef interface ID3D12Device7 ID3D12Device7; + +#endif /* __ID3D12Device7_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device8_FWD_DEFINED__ +#define __ID3D12Device8_FWD_DEFINED__ +typedef interface ID3D12Device8 ID3D12Device8; + +#endif /* __ID3D12Device8_FWD_DEFINED__ */ + + +#ifndef __ID3D12Resource1_FWD_DEFINED__ +#define __ID3D12Resource1_FWD_DEFINED__ +typedef interface ID3D12Resource1 ID3D12Resource1; + +#endif /* __ID3D12Resource1_FWD_DEFINED__ */ + + +#ifndef __ID3D12Resource2_FWD_DEFINED__ +#define __ID3D12Resource2_FWD_DEFINED__ +typedef interface ID3D12Resource2 ID3D12Resource2; + +#endif /* __ID3D12Resource2_FWD_DEFINED__ */ + + +#ifndef __ID3D12Heap1_FWD_DEFINED__ +#define __ID3D12Heap1_FWD_DEFINED__ +typedef interface ID3D12Heap1 ID3D12Heap1; + +#endif /* __ID3D12Heap1_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList3_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList3_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList3 ID3D12GraphicsCommandList3; + +#endif /* __ID3D12GraphicsCommandList3_FWD_DEFINED__ */ + + +#ifndef __ID3D12MetaCommand_FWD_DEFINED__ +#define __ID3D12MetaCommand_FWD_DEFINED__ +typedef interface ID3D12MetaCommand ID3D12MetaCommand; + +#endif /* __ID3D12MetaCommand_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList4_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList4_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList4 ID3D12GraphicsCommandList4; + +#endif /* __ID3D12GraphicsCommandList4_FWD_DEFINED__ */ + + +#ifndef __ID3D12ShaderCacheSession_FWD_DEFINED__ +#define __ID3D12ShaderCacheSession_FWD_DEFINED__ +typedef interface ID3D12ShaderCacheSession ID3D12ShaderCacheSession; + +#endif /* __ID3D12ShaderCacheSession_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device9_FWD_DEFINED__ +#define __ID3D12Device9_FWD_DEFINED__ +typedef interface ID3D12Device9 ID3D12Device9; + +#endif /* __ID3D12Device9_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device10_FWD_DEFINED__ +#define __ID3D12Device10_FWD_DEFINED__ +typedef interface ID3D12Device10 ID3D12Device10; + +#endif /* __ID3D12Device10_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device11_FWD_DEFINED__ +#define __ID3D12Device11_FWD_DEFINED__ +typedef interface ID3D12Device11 ID3D12Device11; + +#endif /* __ID3D12Device11_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device12_FWD_DEFINED__ +#define __ID3D12Device12_FWD_DEFINED__ +typedef interface ID3D12Device12 ID3D12Device12; + +#endif /* __ID3D12Device12_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device13_FWD_DEFINED__ +#define __ID3D12Device13_FWD_DEFINED__ +typedef interface ID3D12Device13 ID3D12Device13; + +#endif /* __ID3D12Device13_FWD_DEFINED__ */ + + +#ifndef __ID3D12Device14_FWD_DEFINED__ +#define __ID3D12Device14_FWD_DEFINED__ +typedef interface ID3D12Device14 ID3D12Device14; + +#endif /* __ID3D12Device14_FWD_DEFINED__ */ + + +#ifndef __ID3D12VirtualizationGuestDevice_FWD_DEFINED__ +#define __ID3D12VirtualizationGuestDevice_FWD_DEFINED__ +typedef interface ID3D12VirtualizationGuestDevice ID3D12VirtualizationGuestDevice; + +#endif /* __ID3D12VirtualizationGuestDevice_FWD_DEFINED__ */ + + +#ifndef __ID3D12Tools_FWD_DEFINED__ +#define __ID3D12Tools_FWD_DEFINED__ +typedef interface ID3D12Tools ID3D12Tools; + +#endif /* __ID3D12Tools_FWD_DEFINED__ */ + + +#ifndef __ID3D12SDKConfiguration_FWD_DEFINED__ +#define __ID3D12SDKConfiguration_FWD_DEFINED__ +typedef interface ID3D12SDKConfiguration ID3D12SDKConfiguration; + +#endif /* __ID3D12SDKConfiguration_FWD_DEFINED__ */ + + +#ifndef __ID3D12SDKConfiguration1_FWD_DEFINED__ +#define __ID3D12SDKConfiguration1_FWD_DEFINED__ +typedef interface ID3D12SDKConfiguration1 ID3D12SDKConfiguration1; + +#endif /* __ID3D12SDKConfiguration1_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceFactory_FWD_DEFINED__ +#define __ID3D12DeviceFactory_FWD_DEFINED__ +typedef interface ID3D12DeviceFactory ID3D12DeviceFactory; + +#endif /* __ID3D12DeviceFactory_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceConfiguration_FWD_DEFINED__ +#define __ID3D12DeviceConfiguration_FWD_DEFINED__ +typedef interface ID3D12DeviceConfiguration ID3D12DeviceConfiguration; + +#endif /* __ID3D12DeviceConfiguration_FWD_DEFINED__ */ + + +#ifndef __ID3D12DeviceConfiguration1_FWD_DEFINED__ +#define __ID3D12DeviceConfiguration1_FWD_DEFINED__ +typedef interface ID3D12DeviceConfiguration1 ID3D12DeviceConfiguration1; + +#endif /* __ID3D12DeviceConfiguration1_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList5_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList5_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList5 ID3D12GraphicsCommandList5; + +#endif /* __ID3D12GraphicsCommandList5_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList6_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList6_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList6 ID3D12GraphicsCommandList6; + +#endif /* __ID3D12GraphicsCommandList6_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList7_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList7_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList7 ID3D12GraphicsCommandList7; + +#endif /* __ID3D12GraphicsCommandList7_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList8_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList8_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList8 ID3D12GraphicsCommandList8; + +#endif /* __ID3D12GraphicsCommandList8_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList9_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList9_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList9 ID3D12GraphicsCommandList9; + +#endif /* __ID3D12GraphicsCommandList9_FWD_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList10_FWD_DEFINED__ +#define __ID3D12GraphicsCommandList10_FWD_DEFINED__ +typedef interface ID3D12GraphicsCommandList10 ID3D12GraphicsCommandList10; + +#endif /* __ID3D12GraphicsCommandList10_FWD_DEFINED__ */ + + +#ifndef __ID3D12GBVDiagnostics_FWD_DEFINED__ +#define __ID3D12GBVDiagnostics_FWD_DEFINED__ +typedef interface ID3D12GBVDiagnostics ID3D12GBVDiagnostics; + +#endif /* __ID3D12GBVDiagnostics_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" +#include "dxgicommon.h" +#include "dxgiformat.h" +#include "d3dcommon.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_d3d12_0000_0000 */ +/* [local] */ + +#include +#ifdef _MSC_VER +#pragma region App Family +#endif +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) +#ifndef _D3D12_CONSTANTS +#define _D3D12_CONSTANTS +#define D3D12_16BIT_INDEX_STRIP_CUT_VALUE ( 0xffff ) + +#define D3D12_32BIT_INDEX_STRIP_CUT_VALUE ( 0xffffffff ) + +#define D3D12_8BIT_INDEX_STRIP_CUT_VALUE ( 0xff ) + +#define D3D12_APPEND_ALIGNED_ELEMENT ( 0xffffffff ) + +#define D3D12_ARRAY_AXIS_ADDRESS_RANGE_BIT_COUNT ( 9 ) + +#define D3D12_CLIP_OR_CULL_DISTANCE_COUNT ( 8 ) + +#define D3D12_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT ( 2 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT ( 14 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_COMPONENTS ( 4 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT ( 15 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_PARTIAL_UPDATE_EXTENTS_BYTE_ALIGNMENT ( 16 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_COUNT ( 15 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READS_PER_INST ( 1 ) + +#define D3D12_COMMONSHADER_CONSTANT_BUFFER_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_COMMONSHADER_FLOWCONTROL_NESTING_LIMIT ( 64 ) + +#define D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_COUNT ( 1 ) + +#define D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READS_PER_INST ( 1 ) + +#define D3D12_COMMONSHADER_IMMEDIATE_CONSTANT_BUFFER_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_COMMONSHADER_IMMEDIATE_VALUE_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_COUNT ( 128 ) + +#define D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_READS_PER_INST ( 1 ) + +#define D3D12_COMMONSHADER_INPUT_RESOURCE_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT ( 128 ) + +#define D3D12_COMMONSHADER_SAMPLER_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_COMMONSHADER_SAMPLER_REGISTER_COUNT ( 16 ) + +#define D3D12_COMMONSHADER_SAMPLER_REGISTER_READS_PER_INST ( 1 ) + +#define D3D12_COMMONSHADER_SAMPLER_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_COMMONSHADER_SAMPLER_SLOT_COUNT ( 16 ) + +#define D3D12_COMMONSHADER_SUBROUTINE_NESTING_LIMIT ( 32 ) + +#define D3D12_COMMONSHADER_TEMP_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_COMMONSHADER_TEMP_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_COMMONSHADER_TEMP_REGISTER_COUNT ( 4096 ) + +#define D3D12_COMMONSHADER_TEMP_REGISTER_READS_PER_INST ( 3 ) + +#define D3D12_COMMONSHADER_TEMP_REGISTER_READ_PORTS ( 3 ) + +#define D3D12_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MAX ( 10 ) + +#define D3D12_COMMONSHADER_TEXCOORD_RANGE_REDUCTION_MIN ( -10 ) + +#define D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_NEGATIVE ( -8 ) + +#define D3D12_COMMONSHADER_TEXEL_OFFSET_MAX_POSITIVE ( 7 ) + +#define D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT ( 256 ) + +#define D3D12_CS_4_X_BUCKET00_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 256 ) + +#define D3D12_CS_4_X_BUCKET00_MAX_NUM_THREADS_PER_GROUP ( 64 ) + +#define D3D12_CS_4_X_BUCKET01_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 240 ) + +#define D3D12_CS_4_X_BUCKET01_MAX_NUM_THREADS_PER_GROUP ( 68 ) + +#define D3D12_CS_4_X_BUCKET02_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 224 ) + +#define D3D12_CS_4_X_BUCKET02_MAX_NUM_THREADS_PER_GROUP ( 72 ) + +#define D3D12_CS_4_X_BUCKET03_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 208 ) + +#define D3D12_CS_4_X_BUCKET03_MAX_NUM_THREADS_PER_GROUP ( 76 ) + +#define D3D12_CS_4_X_BUCKET04_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 192 ) + +#define D3D12_CS_4_X_BUCKET04_MAX_NUM_THREADS_PER_GROUP ( 84 ) + +#define D3D12_CS_4_X_BUCKET05_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 176 ) + +#define D3D12_CS_4_X_BUCKET05_MAX_NUM_THREADS_PER_GROUP ( 92 ) + +#define D3D12_CS_4_X_BUCKET06_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 160 ) + +#define D3D12_CS_4_X_BUCKET06_MAX_NUM_THREADS_PER_GROUP ( 100 ) + +#define D3D12_CS_4_X_BUCKET07_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 144 ) + +#define D3D12_CS_4_X_BUCKET07_MAX_NUM_THREADS_PER_GROUP ( 112 ) + +#define D3D12_CS_4_X_BUCKET08_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 128 ) + +#define D3D12_CS_4_X_BUCKET08_MAX_NUM_THREADS_PER_GROUP ( 128 ) + +#define D3D12_CS_4_X_BUCKET09_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 112 ) + +#define D3D12_CS_4_X_BUCKET09_MAX_NUM_THREADS_PER_GROUP ( 144 ) + +#define D3D12_CS_4_X_BUCKET10_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 96 ) + +#define D3D12_CS_4_X_BUCKET10_MAX_NUM_THREADS_PER_GROUP ( 168 ) + +#define D3D12_CS_4_X_BUCKET11_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 80 ) + +#define D3D12_CS_4_X_BUCKET11_MAX_NUM_THREADS_PER_GROUP ( 204 ) + +#define D3D12_CS_4_X_BUCKET12_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 64 ) + +#define D3D12_CS_4_X_BUCKET12_MAX_NUM_THREADS_PER_GROUP ( 256 ) + +#define D3D12_CS_4_X_BUCKET13_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 48 ) + +#define D3D12_CS_4_X_BUCKET13_MAX_NUM_THREADS_PER_GROUP ( 340 ) + +#define D3D12_CS_4_X_BUCKET14_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 32 ) + +#define D3D12_CS_4_X_BUCKET14_MAX_NUM_THREADS_PER_GROUP ( 512 ) + +#define D3D12_CS_4_X_BUCKET15_MAX_BYTES_TGSM_WRITABLE_PER_THREAD ( 16 ) + +#define D3D12_CS_4_X_BUCKET15_MAX_NUM_THREADS_PER_GROUP ( 768 ) + +#define D3D12_CS_4_X_DISPATCH_MAX_THREAD_GROUPS_IN_Z_DIMENSION ( 1 ) + +#define D3D12_CS_4_X_RAW_UAV_BYTE_ALIGNMENT ( 256 ) + +#define D3D12_CS_4_X_THREAD_GROUP_MAX_THREADS_PER_GROUP ( 768 ) + +#define D3D12_CS_4_X_THREAD_GROUP_MAX_X ( 768 ) + +#define D3D12_CS_4_X_THREAD_GROUP_MAX_Y ( 768 ) + +#define D3D12_CS_4_X_UAV_REGISTER_COUNT ( 1 ) + +#define D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION ( 65535 ) + +#define D3D12_CS_TGSM_REGISTER_COUNT ( 8192 ) + +#define D3D12_CS_TGSM_REGISTER_READS_PER_INST ( 1 ) + +#define D3D12_CS_TGSM_RESOURCE_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_CS_TGSM_RESOURCE_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_CS_THREADGROUPID_REGISTER_COMPONENTS ( 3 ) + +#define D3D12_CS_THREADGROUPID_REGISTER_COUNT ( 1 ) + +#define D3D12_CS_THREADIDINGROUPFLATTENED_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_CS_THREADIDINGROUPFLATTENED_REGISTER_COUNT ( 1 ) + +#define D3D12_CS_THREADIDINGROUP_REGISTER_COMPONENTS ( 3 ) + +#define D3D12_CS_THREADIDINGROUP_REGISTER_COUNT ( 1 ) + +#define D3D12_CS_THREADID_REGISTER_COMPONENTS ( 3 ) + +#define D3D12_CS_THREADID_REGISTER_COUNT ( 1 ) + +#define D3D12_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP ( 1024 ) + +#define D3D12_CS_THREAD_GROUP_MAX_X ( 1024 ) + +#define D3D12_CS_THREAD_GROUP_MAX_Y ( 1024 ) + +#define D3D12_CS_THREAD_GROUP_MAX_Z ( 64 ) + +#define D3D12_CS_THREAD_GROUP_MIN_X ( 1 ) + +#define D3D12_CS_THREAD_GROUP_MIN_Y ( 1 ) + +#define D3D12_CS_THREAD_GROUP_MIN_Z ( 1 ) + +#define D3D12_CS_THREAD_LOCAL_TEMP_REGISTER_POOL ( 16384 ) + +#define D3D12_DEFAULT_BLEND_FACTOR_ALPHA ( 1.0f ) +#define D3D12_DEFAULT_BLEND_FACTOR_BLUE ( 1.0f ) +#define D3D12_DEFAULT_BLEND_FACTOR_GREEN ( 1.0f ) +#define D3D12_DEFAULT_BLEND_FACTOR_RED ( 1.0f ) +#define D3D12_DEFAULT_BORDER_COLOR_COMPONENT ( 0.0f ) +#define D3D12_DEFAULT_DEPTH_BIAS ( 0 ) + +#define D3D12_DEFAULT_DEPTH_BIAS_CLAMP ( 0.0f ) +#define D3D12_DEFAULT_MAX_ANISOTROPY ( 16 ) + +#define D3D12_DEFAULT_MIP_LOD_BIAS ( 0.0f ) +#define D3D12_DEFAULT_MSAA_RESOURCE_PLACEMENT_ALIGNMENT ( 4194304 ) + +#define D3D12_DEFAULT_RENDER_TARGET_ARRAY_INDEX ( 0 ) + +#define D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT ( 65536 ) + +#define D3D12_DEFAULT_SAMPLE_MASK ( 0xffffffff ) + +#define D3D12_DEFAULT_SCISSOR_ENDX ( 0 ) + +#define D3D12_DEFAULT_SCISSOR_ENDY ( 0 ) + +#define D3D12_DEFAULT_SCISSOR_STARTX ( 0 ) + +#define D3D12_DEFAULT_SCISSOR_STARTY ( 0 ) + +#define D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS ( 0.0f ) +#define D3D12_DEFAULT_STENCIL_READ_MASK ( 0xff ) + +#define D3D12_DEFAULT_STENCIL_REFERENCE ( 0 ) + +#define D3D12_DEFAULT_STENCIL_WRITE_MASK ( 0xff ) + +#define D3D12_DEFAULT_VIEWPORT_AND_SCISSORRECT_INDEX ( 0 ) + +#define D3D12_DEFAULT_VIEWPORT_HEIGHT ( 0 ) + +#define D3D12_DEFAULT_VIEWPORT_MAX_DEPTH ( 0.0f ) +#define D3D12_DEFAULT_VIEWPORT_MIN_DEPTH ( 0.0f ) +#define D3D12_DEFAULT_VIEWPORT_TOPLEFTX ( 0 ) + +#define D3D12_DEFAULT_VIEWPORT_TOPLEFTY ( 0 ) + +#define D3D12_DEFAULT_VIEWPORT_WIDTH ( 0 ) + +#define D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND ( 0xffffffff ) + +#define D3D12_DRIVER_RESERVED_REGISTER_SPACE_VALUES_END ( 0xfffffff7 ) + +#define D3D12_DRIVER_RESERVED_REGISTER_SPACE_VALUES_START ( 0xfffffff0 ) + +#define D3D12_DS_INPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS ( 3968 ) + +#define D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_DS_INPUT_CONTROL_POINT_REGISTER_COUNT ( 32 ) + +#define D3D12_DS_INPUT_CONTROL_POINT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_DS_INPUT_CONTROL_POINT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENTS ( 3 ) + +#define D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_COUNT ( 1 ) + +#define D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_DS_INPUT_DOMAIN_POINT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_COUNT ( 32 ) + +#define D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_DS_INPUT_PATCH_CONSTANT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_COUNT ( 1 ) + +#define D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_DS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_DS_OUTPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_DS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_DS_OUTPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_FLOAT16_FUSED_TOLERANCE_IN_ULP ( 0.6 ) +#define D3D12_FLOAT32_MAX ( 3.402823466e+38f ) +#define D3D12_FLOAT32_TO_INTEGER_TOLERANCE_IN_ULP ( 0.6f ) +#define D3D12_FLOAT_TO_SRGB_EXPONENT_DENOMINATOR ( 2.4f ) +#define D3D12_FLOAT_TO_SRGB_EXPONENT_NUMERATOR ( 1.0f ) +#define D3D12_FLOAT_TO_SRGB_OFFSET ( 0.055f ) +#define D3D12_FLOAT_TO_SRGB_SCALE_1 ( 12.92f ) +#define D3D12_FLOAT_TO_SRGB_SCALE_2 ( 1.055f ) +#define D3D12_FLOAT_TO_SRGB_THRESHOLD ( 0.0031308f ) +#define D3D12_FTOI_INSTRUCTION_MAX_INPUT ( 2147483647.999f ) +#define D3D12_FTOI_INSTRUCTION_MIN_INPUT ( -2147483648.999f ) +#define D3D12_FTOU_INSTRUCTION_MAX_INPUT ( 4294967295.999f ) +#define D3D12_FTOU_INSTRUCTION_MIN_INPUT ( 0.0f ) +#define D3D12_GS_INPUT_INSTANCE_ID_READS_PER_INST ( 2 ) + +#define D3D12_GS_INPUT_INSTANCE_ID_READ_PORTS ( 1 ) + +#define D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_GS_INPUT_INSTANCE_ID_REGISTER_COUNT ( 1 ) + +#define D3D12_GS_INPUT_PRIM_CONST_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_GS_INPUT_PRIM_CONST_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_GS_INPUT_PRIM_CONST_REGISTER_COUNT ( 1 ) + +#define D3D12_GS_INPUT_PRIM_CONST_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_GS_INPUT_PRIM_CONST_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_GS_INPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_GS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_GS_INPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_GS_INPUT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_GS_INPUT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_GS_INPUT_REGISTER_VERTICES ( 32 ) + +#define D3D12_GS_MAX_INSTANCE_COUNT ( 32 ) + +#define D3D12_GS_MAX_OUTPUT_VERTEX_COUNT_ACROSS_INSTANCES ( 1024 ) + +#define D3D12_GS_OUTPUT_ELEMENTS ( 32 ) + +#define D3D12_GS_OUTPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_GS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_GS_OUTPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_HS_CONTROL_POINT_PHASE_INPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_HS_CONTROL_POINT_PHASE_OUTPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_HS_CONTROL_POINT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_HS_CONTROL_POINT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_HS_CONTROL_POINT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_HS_CONTROL_POINT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_HS_FORK_PHASE_INSTANCE_COUNT_UPPER_BOUND ( 0xffffffff ) + +#define D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_COUNT ( 1 ) + +#define D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_HS_INPUT_FORK_INSTANCE_ID_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_COUNT ( 1 ) + +#define D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_HS_INPUT_JOIN_INSTANCE_ID_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_COUNT ( 1 ) + +#define D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_HS_INPUT_PRIMITIVE_ID_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_HS_JOIN_PHASE_INSTANCE_COUNT_UPPER_BOUND ( 0xffffffff ) + +#define D3D12_HS_MAXTESSFACTOR_LOWER_BOUND ( 1.0f ) +#define D3D12_HS_MAXTESSFACTOR_UPPER_BOUND ( 64.0f ) +#define D3D12_HS_OUTPUT_CONTROL_POINTS_MAX_TOTAL_SCALARS ( 3968 ) + +#define D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_COUNT ( 1 ) + +#define D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_HS_OUTPUT_CONTROL_POINT_ID_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_COUNT ( 32 ) + +#define D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_HS_OUTPUT_PATCH_CONSTANT_REGISTER_SCALAR_COMPONENTS ( 128 ) + +#define D3D12_IA_DEFAULT_INDEX_BUFFER_OFFSET_IN_BYTES ( 0 ) + +#define D3D12_IA_DEFAULT_PRIMITIVE_TOPOLOGY ( 0 ) + +#define D3D12_IA_DEFAULT_VERTEX_BUFFER_OFFSET_IN_BYTES ( 0 ) + +#define D3D12_IA_INDEX_INPUT_RESOURCE_SLOT_COUNT ( 1 ) + +#define D3D12_IA_INSTANCE_ID_BIT_COUNT ( 32 ) + +#define D3D12_IA_INTEGER_ARITHMETIC_BIT_COUNT ( 32 ) + +#define D3D12_IA_PATCH_MAX_CONTROL_POINT_COUNT ( 32 ) + +#define D3D12_IA_PRIMITIVE_ID_BIT_COUNT ( 32 ) + +#define D3D12_IA_VERTEX_ID_BIT_COUNT ( 32 ) + +#define D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ( 32 ) + +#define D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENTS_COMPONENTS ( 128 ) + +#define D3D12_IA_VERTEX_INPUT_STRUCTURE_ELEMENT_COUNT ( 32 ) + +#define D3D12_INTEGER_DIVIDE_BY_ZERO_QUOTIENT ( 0xffffffff ) + +#define D3D12_INTEGER_DIVIDE_BY_ZERO_REMAINDER ( 0xffffffff ) + +#define D3D12_KEEP_RENDER_TARGETS_AND_DEPTH_STENCIL ( 0xffffffff ) + +#define D3D12_KEEP_UNORDERED_ACCESS_VIEWS ( 0xffffffff ) + +#define D3D12_LINEAR_GAMMA ( 1.0f ) +#define D3D12_MAJOR_VERSION ( 12 ) + +#define D3D12_MAX_BORDER_COLOR_COMPONENT ( 1.0f ) +#define D3D12_MAX_DEPTH ( 1.0f ) +#define D3D12_MAX_LIVE_STATIC_SAMPLERS ( 2032 ) + +#define D3D12_MAX_MAXANISOTROPY ( 16 ) + +#define D3D12_MAX_MULTISAMPLE_SAMPLE_COUNT ( 32 ) + +#define D3D12_MAX_POSITION_VALUE ( 3.402823466e+34f ) +#define D3D12_MAX_ROOT_COST ( 64 ) + +#define D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_1 ( 1000000 ) + +#define D3D12_MAX_SHADER_VISIBLE_DESCRIPTOR_HEAP_SIZE_TIER_2 ( 1000000 ) + +#define D3D12_MAX_SHADER_VISIBLE_SAMPLER_HEAP_SIZE ( 2048 ) + +#define D3D12_MAX_TEXTURE_DIMENSION_2_TO_EXP ( 17 ) + +#define D3D12_MAX_VIEW_INSTANCE_COUNT ( 4 ) + +#define D3D12_MINOR_VERSION ( 0 ) + +#define D3D12_MIN_BORDER_COLOR_COMPONENT ( 0.0f ) +#define D3D12_MIN_DEPTH ( 0.0f ) +#define D3D12_MIN_MAXANISOTROPY ( 0 ) + +#define D3D12_MIP_LOD_BIAS_MAX ( 15.99f ) +#define D3D12_MIP_LOD_BIAS_MIN ( -16.0f ) +#define D3D12_MIP_LOD_FRACTIONAL_BIT_COUNT ( 8 ) + +#define D3D12_MIP_LOD_RANGE_BIT_COUNT ( 8 ) + +#define D3D12_MULTISAMPLE_ANTIALIAS_LINE_WIDTH ( 1.4f ) +#define D3D12_NONSAMPLE_FETCH_OUT_OF_RANGE_ACCESS_RESULT ( 0 ) + +#define D3D12_OS_RESERVED_REGISTER_SPACE_VALUES_END ( 0xffffffff ) + +#define D3D12_OS_RESERVED_REGISTER_SPACE_VALUES_START ( 0xfffffff8 ) + +#define D3D12_PACKED_TILE ( 0xffffffff ) + +#define D3D12_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 15 ) + +#define D3D12_PREVIEW_SDK_VERSION ( 714 ) + +#define D3D12_PRE_SCISSOR_PIXEL_ADDRESS_RANGE_BIT_COUNT ( 16 ) + +#define D3D12_PS_CS_UAV_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_PS_CS_UAV_REGISTER_COUNT ( 8 ) + +#define D3D12_PS_CS_UAV_REGISTER_READS_PER_INST ( 1 ) + +#define D3D12_PS_CS_UAV_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_PS_FRONTFACING_DEFAULT_VALUE ( 0xffffffff ) + +#define D3D12_PS_FRONTFACING_FALSE_VALUE ( 0 ) + +#define D3D12_PS_FRONTFACING_TRUE_VALUE ( 0xffffffff ) + +#define D3D12_PS_INPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_PS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_PS_INPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_PS_INPUT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_PS_INPUT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_PS_LEGACY_PIXEL_CENTER_FRACTIONAL_COMPONENT ( 0.0f ) +#define D3D12_PS_OUTPUT_DEPTH_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_PS_OUTPUT_DEPTH_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_PS_OUTPUT_DEPTH_REGISTER_COUNT ( 1 ) + +#define D3D12_PS_OUTPUT_MASK_REGISTER_COMPONENTS ( 1 ) + +#define D3D12_PS_OUTPUT_MASK_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_PS_OUTPUT_MASK_REGISTER_COUNT ( 1 ) + +#define D3D12_PS_OUTPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_PS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_PS_OUTPUT_REGISTER_COUNT ( 8 ) + +#define D3D12_PS_PIXEL_CENTER_FRACTIONAL_COMPONENT ( 0.5f ) +#define D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT ( 16 ) + +#define D3D12_RAYTRACING_AABB_BYTE_ALIGNMENT ( 8 ) + +#define D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BYTE_ALIGNMENT ( 256 ) + +#define D3D12_RAYTRACING_INSTANCE_DESCS_BYTE_ALIGNMENT ( 16 ) + +#define D3D12_RAYTRACING_MAX_ATTRIBUTE_SIZE_IN_BYTES ( 32 ) + +#define D3D12_RAYTRACING_MAX_DECLARABLE_TRACE_RECURSION_DEPTH ( 31 ) + +#define D3D12_RAYTRACING_MAX_GEOMETRIES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE ( 16777216 ) + +#define D3D12_RAYTRACING_MAX_INSTANCES_PER_TOP_LEVEL_ACCELERATION_STRUCTURE ( 16777216 ) + +#define D3D12_RAYTRACING_MAX_PRIMITIVES_PER_BOTTOM_LEVEL_ACCELERATION_STRUCTURE ( 536870912 ) + +#define D3D12_RAYTRACING_MAX_RAY_GENERATION_SHADER_THREADS ( 1073741824 ) + +#define D3D12_RAYTRACING_MAX_SHADER_RECORD_STRIDE ( 4096 ) + +#define D3D12_RAYTRACING_SHADER_RECORD_BYTE_ALIGNMENT ( 32 ) + +#define D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT ( 64 ) + +#define D3D12_RAYTRACING_TRANSFORM3X4_BYTE_ALIGNMENT ( 16 ) + +#define D3D12_REQ_BLEND_OBJECT_COUNT_PER_DEVICE ( 4096 ) + +#define D3D12_REQ_BUFFER_RESOURCE_TEXEL_COUNT_2_TO_EXP ( 27 ) + +#define D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT ( 4096 ) + +#define D3D12_REQ_DEPTH_STENCIL_OBJECT_COUNT_PER_DEVICE ( 4096 ) + +#define D3D12_REQ_DRAWINDEXED_INDEX_COUNT_2_TO_EXP ( 32 ) + +#define D3D12_REQ_DRAW_VERTEX_COUNT_2_TO_EXP ( 32 ) + +#define D3D12_REQ_FILTERING_HW_ADDRESSABLE_RESOURCE_DIMENSION ( 16384 ) + +#define D3D12_REQ_GS_INVOCATION_32BIT_OUTPUT_COMPONENT_LIMIT ( 1024 ) + +#define D3D12_REQ_IMMEDIATE_CONSTANT_BUFFER_ELEMENT_COUNT ( 4096 ) + +#define D3D12_REQ_MAXANISOTROPY ( 16 ) + +#define D3D12_REQ_MIP_LEVELS ( 15 ) + +#define D3D12_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES ( 2048 ) + +#define D3D12_REQ_RASTERIZER_OBJECT_COUNT_PER_DEVICE ( 4096 ) + +#define D3D12_REQ_RENDER_TO_BUFFER_WINDOW_WIDTH ( 16384 ) + +#define D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_A_TERM ( 128 ) + +#define D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_B_TERM ( 0.25f ) +#define D3D12_REQ_RESOURCE_SIZE_IN_MEGABYTES_EXPRESSION_C_TERM ( 2048 ) + +#define D3D12_REQ_RESOURCE_VIEW_COUNT_PER_DEVICE_2_TO_EXP ( 20 ) + +#define D3D12_REQ_SAMPLER_OBJECT_COUNT_PER_DEVICE ( 4096 ) + +#define D3D12_REQ_SUBRESOURCES ( 30720 ) + +#define D3D12_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION ( 2048 ) + +#define D3D12_REQ_TEXTURE1D_U_DIMENSION ( 16384 ) + +#define D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION ( 2048 ) + +#define D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION ( 16384 ) + +#define D3D12_REQ_TEXTURE3D_U_V_OR_W_DIMENSION ( 2048 ) + +#define D3D12_REQ_TEXTURECUBE_DIMENSION ( 16384 ) + +#define D3D12_RESINFO_INSTRUCTION_MISSING_COMPONENT_RETVAL ( 0 ) + +#define D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES ( 0xffffffff ) + +#define D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT ( 2 ) + +#define D3D12_SDK_VERSION ( 614 ) + +#define D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES ( 32 ) + +#define D3D12_SHADER_MAJOR_VERSION ( 5 ) + +#define D3D12_SHADER_MAX_INSTANCES ( 65535 ) + +#define D3D12_SHADER_MAX_INTERFACES ( 253 ) + +#define D3D12_SHADER_MAX_INTERFACE_CALL_SITES ( 4096 ) + +#define D3D12_SHADER_MAX_TYPES ( 65535 ) + +#define D3D12_SHADER_MINOR_VERSION ( 1 ) + +#define D3D12_SHIFT_INSTRUCTION_PAD_VALUE ( 0 ) + +#define D3D12_SHIFT_INSTRUCTION_SHIFT_VALUE_BIT_COUNT ( 5 ) + +#define D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ( 8 ) + +#define D3D12_SMALL_MSAA_RESOURCE_PLACEMENT_ALIGNMENT ( 65536 ) + +#define D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT ( 4096 ) + +#define D3D12_SO_BUFFER_MAX_STRIDE_IN_BYTES ( 2048 ) + +#define D3D12_SO_BUFFER_MAX_WRITE_WINDOW_IN_BYTES ( 512 ) + +#define D3D12_SO_BUFFER_SLOT_COUNT ( 4 ) + +#define D3D12_SO_DDI_REGISTER_INDEX_DENOTING_GAP ( 0xffffffff ) + +#define D3D12_SO_NO_RASTERIZED_STREAM ( 0xffffffff ) + +#define D3D12_SO_OUTPUT_COMPONENT_COUNT ( 128 ) + +#define D3D12_SO_STREAM_COUNT ( 4 ) + +#define D3D12_SPEC_DATE_DAY ( 14 ) + +#define D3D12_SPEC_DATE_MONTH ( 11 ) + +#define D3D12_SPEC_DATE_YEAR ( 2014 ) + +#define D3D12_SPEC_VERSION ( 1.16 ) +#define D3D12_SRGB_GAMMA ( 2.2f ) +#define D3D12_SRGB_TO_FLOAT_DENOMINATOR_1 ( 12.92f ) +#define D3D12_SRGB_TO_FLOAT_DENOMINATOR_2 ( 1.055f ) +#define D3D12_SRGB_TO_FLOAT_EXPONENT ( 2.4f ) +#define D3D12_SRGB_TO_FLOAT_OFFSET ( 0.055f ) +#define D3D12_SRGB_TO_FLOAT_THRESHOLD ( 0.04045f ) +#define D3D12_SRGB_TO_FLOAT_TOLERANCE_IN_ULP ( 0.5f ) +#define D3D12_STANDARD_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_STANDARD_COMPONENT_BIT_COUNT_DOUBLED ( 64 ) + +#define D3D12_STANDARD_MAXIMUM_ELEMENT_ALIGNMENT_BYTE_MULTIPLE ( 4 ) + +#define D3D12_STANDARD_PIXEL_COMPONENT_COUNT ( 128 ) + +#define D3D12_STANDARD_PIXEL_ELEMENT_COUNT ( 32 ) + +#define D3D12_STANDARD_VECTOR_SIZE ( 4 ) + +#define D3D12_STANDARD_VERTEX_ELEMENT_COUNT ( 32 ) + +#define D3D12_STANDARD_VERTEX_TOTAL_COMPONENT_COUNT ( 64 ) + +#define D3D12_SUBPIXEL_FRACTIONAL_BIT_COUNT ( 8 ) + +#define D3D12_SUBTEXEL_FRACTIONAL_BIT_COUNT ( 8 ) + +#define D3D12_SYSTEM_RESERVED_REGISTER_SPACE_VALUES_END ( 0xffffffff ) + +#define D3D12_SYSTEM_RESERVED_REGISTER_SPACE_VALUES_START ( 0xfffffff0 ) + +#define D3D12_TESSELLATOR_MAX_EVEN_TESSELLATION_FACTOR ( 64 ) + +#define D3D12_TESSELLATOR_MAX_ISOLINE_DENSITY_TESSELLATION_FACTOR ( 64 ) + +#define D3D12_TESSELLATOR_MAX_ODD_TESSELLATION_FACTOR ( 63 ) + +#define D3D12_TESSELLATOR_MAX_TESSELLATION_FACTOR ( 64 ) + +#define D3D12_TESSELLATOR_MIN_EVEN_TESSELLATION_FACTOR ( 2 ) + +#define D3D12_TESSELLATOR_MIN_ISOLINE_DENSITY_TESSELLATION_FACTOR ( 1 ) + +#define D3D12_TESSELLATOR_MIN_ODD_TESSELLATION_FACTOR ( 1 ) + +#define D3D12_TEXEL_ADDRESS_RANGE_BIT_COUNT ( 16 ) + +#define D3D12_TEXTURE_DATA_PITCH_ALIGNMENT ( 256 ) + +#define D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT ( 512 ) + +#define D3D12_TILED_RESOURCE_TILE_SIZE_IN_BYTES ( 65536 ) + +#define D3D12_TRACKED_WORKLOAD_MAX_INSTANCES ( 32 ) + +#define D3D12_UAV_COUNTER_PLACEMENT_ALIGNMENT ( 4096 ) + +#define D3D12_UAV_SLOT_COUNT ( 64 ) + +#define D3D12_UNBOUND_MEMORY_ACCESS_RESULT ( 0 ) + +#define D3D12_VIDEO_DECODE_MAX_ARGUMENTS ( 10 ) + +#define D3D12_VIDEO_DECODE_MAX_HISTOGRAM_COMPONENTS ( 4 ) + +#define D3D12_VIDEO_DECODE_MIN_BITSTREAM_OFFSET_ALIGNMENT ( 256 ) + +#define D3D12_VIDEO_DECODE_MIN_HISTOGRAM_OFFSET_ALIGNMENT ( 256 ) + +#define D3D12_VIDEO_DECODE_STATUS_MACROBLOCKS_AFFECTED_UNKNOWN ( 0xffffffff ) + +#define D3D12_VIDEO_ENCODER_AV1_INVALID_DPB_RESOURCE_INDEX ( 0xff ) + +#define D3D12_VIDEO_ENCODER_AV1_MAX_TILE_COLS ( 64 ) + +#define D3D12_VIDEO_ENCODER_AV1_MAX_TILE_ROWS ( 64 ) + +#define D3D12_VIDEO_ENCODER_AV1_SUPERRES_DENOM_MIN ( 9 ) + +#define D3D12_VIDEO_ENCODER_AV1_SUPERRES_NUM ( 8 ) + +#define D3D12_VIDEO_PROCESS_MAX_FILTERS ( 32 ) + +#define D3D12_VIDEO_PROCESS_STEREO_VIEWS ( 2 ) + +#define D3D12_VIEWPORT_AND_SCISSORRECT_MAX_INDEX ( 15 ) + +#define D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE ( 16 ) + +#define D3D12_VIEWPORT_BOUNDS_MAX ( 32767 ) + +#define D3D12_VIEWPORT_BOUNDS_MIN ( -32768 ) + +#define D3D12_VS_INPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_VS_INPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_VS_INPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_VS_INPUT_REGISTER_READS_PER_INST ( 2 ) + +#define D3D12_VS_INPUT_REGISTER_READ_PORTS ( 1 ) + +#define D3D12_VS_OUTPUT_REGISTER_COMPONENTS ( 4 ) + +#define D3D12_VS_OUTPUT_REGISTER_COMPONENT_BIT_COUNT ( 32 ) + +#define D3D12_VS_OUTPUT_REGISTER_COUNT ( 32 ) + +#define D3D12_WHQL_CONTEXT_COUNT_FOR_RESOURCE_LIMIT ( 10 ) + +#define D3D12_WHQL_DRAWINDEXED_INDEX_COUNT_2_TO_EXP ( 25 ) + +#define D3D12_WHQL_DRAW_VERTEX_COUNT_2_TO_EXP ( 25 ) + +#define D3D12_WORK_GRAPHS_BACKING_MEMORY_ALIGNMENT_IN_BYTES ( 8 ) + +#define D3D12_WORK_GRAPHS_MAX_NODE_DEPTH ( 32 ) + +#endif + +typedef UINT64 D3D12_GPU_VIRTUAL_ADDRESS; + +typedef +enum D3D12_COMMAND_LIST_TYPE + { + D3D12_COMMAND_LIST_TYPE_DIRECT = 0, + D3D12_COMMAND_LIST_TYPE_BUNDLE = 1, + D3D12_COMMAND_LIST_TYPE_COMPUTE = 2, + D3D12_COMMAND_LIST_TYPE_COPY = 3, + D3D12_COMMAND_LIST_TYPE_VIDEO_DECODE = 4, + D3D12_COMMAND_LIST_TYPE_VIDEO_PROCESS = 5, + D3D12_COMMAND_LIST_TYPE_VIDEO_ENCODE = 6, + D3D12_COMMAND_LIST_TYPE_NONE = -1 + } D3D12_COMMAND_LIST_TYPE; + +typedef +enum D3D12_COMMAND_QUEUE_FLAGS + { + D3D12_COMMAND_QUEUE_FLAG_NONE = 0, + D3D12_COMMAND_QUEUE_FLAG_DISABLE_GPU_TIMEOUT = 0x1 + } D3D12_COMMAND_QUEUE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_QUEUE_FLAGS ) +typedef +enum D3D12_COMMAND_QUEUE_PRIORITY + { + D3D12_COMMAND_QUEUE_PRIORITY_NORMAL = 0, + D3D12_COMMAND_QUEUE_PRIORITY_HIGH = 100, + D3D12_COMMAND_QUEUE_PRIORITY_GLOBAL_REALTIME = 10000 + } D3D12_COMMAND_QUEUE_PRIORITY; + +typedef struct D3D12_COMMAND_QUEUE_DESC + { + D3D12_COMMAND_LIST_TYPE Type; + INT Priority; + D3D12_COMMAND_QUEUE_FLAGS Flags; + UINT NodeMask; + } D3D12_COMMAND_QUEUE_DESC; + +typedef +enum D3D12_PRIMITIVE_TOPOLOGY_TYPE + { + D3D12_PRIMITIVE_TOPOLOGY_TYPE_UNDEFINED = 0, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT = 1, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE = 2, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE = 3, + D3D12_PRIMITIVE_TOPOLOGY_TYPE_PATCH = 4 + } D3D12_PRIMITIVE_TOPOLOGY_TYPE; + +typedef +enum D3D12_INPUT_CLASSIFICATION + { + D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA = 0, + D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA = 1 + } D3D12_INPUT_CLASSIFICATION; + +typedef struct D3D12_INPUT_ELEMENT_DESC + { + LPCSTR SemanticName; + UINT SemanticIndex; + DXGI_FORMAT Format; + UINT InputSlot; + UINT AlignedByteOffset; + D3D12_INPUT_CLASSIFICATION InputSlotClass; + UINT InstanceDataStepRate; + } D3D12_INPUT_ELEMENT_DESC; + +typedef +enum D3D12_FILL_MODE + { + D3D12_FILL_MODE_WIREFRAME = 2, + D3D12_FILL_MODE_SOLID = 3 + } D3D12_FILL_MODE; + +typedef D3D_PRIMITIVE_TOPOLOGY D3D12_PRIMITIVE_TOPOLOGY; + +typedef D3D_PRIMITIVE D3D12_PRIMITIVE; + +typedef +enum D3D12_CULL_MODE + { + D3D12_CULL_MODE_NONE = 1, + D3D12_CULL_MODE_FRONT = 2, + D3D12_CULL_MODE_BACK = 3 + } D3D12_CULL_MODE; + +typedef struct D3D12_SO_DECLARATION_ENTRY + { + UINT Stream; + LPCSTR SemanticName; + UINT SemanticIndex; + BYTE StartComponent; + BYTE ComponentCount; + BYTE OutputSlot; + } D3D12_SO_DECLARATION_ENTRY; + +typedef struct D3D12_VIEWPORT + { + FLOAT TopLeftX; + FLOAT TopLeftY; + FLOAT Width; + FLOAT Height; + FLOAT MinDepth; + FLOAT MaxDepth; + } D3D12_VIEWPORT; + +typedef RECT D3D12_RECT; + +typedef struct D3D12_BOX + { + UINT left; + UINT top; + UINT front; + UINT right; + UINT bottom; + UINT back; + } D3D12_BOX; + +typedef +enum D3D12_COMPARISON_FUNC + { + D3D12_COMPARISON_FUNC_NONE = 0, + D3D12_COMPARISON_FUNC_NEVER = 1, + D3D12_COMPARISON_FUNC_LESS = 2, + D3D12_COMPARISON_FUNC_EQUAL = 3, + D3D12_COMPARISON_FUNC_LESS_EQUAL = 4, + D3D12_COMPARISON_FUNC_GREATER = 5, + D3D12_COMPARISON_FUNC_NOT_EQUAL = 6, + D3D12_COMPARISON_FUNC_GREATER_EQUAL = 7, + D3D12_COMPARISON_FUNC_ALWAYS = 8 + } D3D12_COMPARISON_FUNC; + +typedef +enum D3D12_DEPTH_WRITE_MASK + { + D3D12_DEPTH_WRITE_MASK_ZERO = 0, + D3D12_DEPTH_WRITE_MASK_ALL = 1 + } D3D12_DEPTH_WRITE_MASK; + +typedef +enum D3D12_STENCIL_OP + { + D3D12_STENCIL_OP_KEEP = 1, + D3D12_STENCIL_OP_ZERO = 2, + D3D12_STENCIL_OP_REPLACE = 3, + D3D12_STENCIL_OP_INCR_SAT = 4, + D3D12_STENCIL_OP_DECR_SAT = 5, + D3D12_STENCIL_OP_INVERT = 6, + D3D12_STENCIL_OP_INCR = 7, + D3D12_STENCIL_OP_DECR = 8 + } D3D12_STENCIL_OP; + +typedef struct D3D12_DEPTH_STENCILOP_DESC + { + D3D12_STENCIL_OP StencilFailOp; + D3D12_STENCIL_OP StencilDepthFailOp; + D3D12_STENCIL_OP StencilPassOp; + D3D12_COMPARISON_FUNC StencilFunc; + } D3D12_DEPTH_STENCILOP_DESC; + +typedef struct D3D12_DEPTH_STENCIL_DESC + { + BOOL DepthEnable; + D3D12_DEPTH_WRITE_MASK DepthWriteMask; + D3D12_COMPARISON_FUNC DepthFunc; + BOOL StencilEnable; + UINT8 StencilReadMask; + UINT8 StencilWriteMask; + D3D12_DEPTH_STENCILOP_DESC FrontFace; + D3D12_DEPTH_STENCILOP_DESC BackFace; + } D3D12_DEPTH_STENCIL_DESC; + +typedef struct D3D12_DEPTH_STENCIL_DESC1 + { + BOOL DepthEnable; + D3D12_DEPTH_WRITE_MASK DepthWriteMask; + D3D12_COMPARISON_FUNC DepthFunc; + BOOL StencilEnable; + UINT8 StencilReadMask; + UINT8 StencilWriteMask; + D3D12_DEPTH_STENCILOP_DESC FrontFace; + D3D12_DEPTH_STENCILOP_DESC BackFace; + BOOL DepthBoundsTestEnable; + } D3D12_DEPTH_STENCIL_DESC1; + +typedef struct D3D12_DEPTH_STENCILOP_DESC1 + { + D3D12_STENCIL_OP StencilFailOp; + D3D12_STENCIL_OP StencilDepthFailOp; + D3D12_STENCIL_OP StencilPassOp; + D3D12_COMPARISON_FUNC StencilFunc; + UINT8 StencilReadMask; + UINT8 StencilWriteMask; + } D3D12_DEPTH_STENCILOP_DESC1; + +typedef struct D3D12_DEPTH_STENCIL_DESC2 + { + BOOL DepthEnable; + D3D12_DEPTH_WRITE_MASK DepthWriteMask; + D3D12_COMPARISON_FUNC DepthFunc; + BOOL StencilEnable; + D3D12_DEPTH_STENCILOP_DESC1 FrontFace; + D3D12_DEPTH_STENCILOP_DESC1 BackFace; + BOOL DepthBoundsTestEnable; + } D3D12_DEPTH_STENCIL_DESC2; + +typedef +enum D3D12_BLEND + { + D3D12_BLEND_ZERO = 1, + D3D12_BLEND_ONE = 2, + D3D12_BLEND_SRC_COLOR = 3, + D3D12_BLEND_INV_SRC_COLOR = 4, + D3D12_BLEND_SRC_ALPHA = 5, + D3D12_BLEND_INV_SRC_ALPHA = 6, + D3D12_BLEND_DEST_ALPHA = 7, + D3D12_BLEND_INV_DEST_ALPHA = 8, + D3D12_BLEND_DEST_COLOR = 9, + D3D12_BLEND_INV_DEST_COLOR = 10, + D3D12_BLEND_SRC_ALPHA_SAT = 11, + D3D12_BLEND_BLEND_FACTOR = 14, + D3D12_BLEND_INV_BLEND_FACTOR = 15, + D3D12_BLEND_SRC1_COLOR = 16, + D3D12_BLEND_INV_SRC1_COLOR = 17, + D3D12_BLEND_SRC1_ALPHA = 18, + D3D12_BLEND_INV_SRC1_ALPHA = 19, + D3D12_BLEND_ALPHA_FACTOR = 20, + D3D12_BLEND_INV_ALPHA_FACTOR = 21 + } D3D12_BLEND; + +typedef +enum D3D12_BLEND_OP + { + D3D12_BLEND_OP_ADD = 1, + D3D12_BLEND_OP_SUBTRACT = 2, + D3D12_BLEND_OP_REV_SUBTRACT = 3, + D3D12_BLEND_OP_MIN = 4, + D3D12_BLEND_OP_MAX = 5 + } D3D12_BLEND_OP; + +typedef +enum D3D12_COLOR_WRITE_ENABLE + { + D3D12_COLOR_WRITE_ENABLE_RED = 1, + D3D12_COLOR_WRITE_ENABLE_GREEN = 2, + D3D12_COLOR_WRITE_ENABLE_BLUE = 4, + D3D12_COLOR_WRITE_ENABLE_ALPHA = 8, + D3D12_COLOR_WRITE_ENABLE_ALL = ( ( ( D3D12_COLOR_WRITE_ENABLE_RED | D3D12_COLOR_WRITE_ENABLE_GREEN ) | D3D12_COLOR_WRITE_ENABLE_BLUE ) | D3D12_COLOR_WRITE_ENABLE_ALPHA ) + } D3D12_COLOR_WRITE_ENABLE; + +typedef +enum D3D12_LOGIC_OP + { + D3D12_LOGIC_OP_CLEAR = 0, + D3D12_LOGIC_OP_SET = ( D3D12_LOGIC_OP_CLEAR + 1 ) , + D3D12_LOGIC_OP_COPY = ( D3D12_LOGIC_OP_SET + 1 ) , + D3D12_LOGIC_OP_COPY_INVERTED = ( D3D12_LOGIC_OP_COPY + 1 ) , + D3D12_LOGIC_OP_NOOP = ( D3D12_LOGIC_OP_COPY_INVERTED + 1 ) , + D3D12_LOGIC_OP_INVERT = ( D3D12_LOGIC_OP_NOOP + 1 ) , + D3D12_LOGIC_OP_AND = ( D3D12_LOGIC_OP_INVERT + 1 ) , + D3D12_LOGIC_OP_NAND = ( D3D12_LOGIC_OP_AND + 1 ) , + D3D12_LOGIC_OP_OR = ( D3D12_LOGIC_OP_NAND + 1 ) , + D3D12_LOGIC_OP_NOR = ( D3D12_LOGIC_OP_OR + 1 ) , + D3D12_LOGIC_OP_XOR = ( D3D12_LOGIC_OP_NOR + 1 ) , + D3D12_LOGIC_OP_EQUIV = ( D3D12_LOGIC_OP_XOR + 1 ) , + D3D12_LOGIC_OP_AND_REVERSE = ( D3D12_LOGIC_OP_EQUIV + 1 ) , + D3D12_LOGIC_OP_AND_INVERTED = ( D3D12_LOGIC_OP_AND_REVERSE + 1 ) , + D3D12_LOGIC_OP_OR_REVERSE = ( D3D12_LOGIC_OP_AND_INVERTED + 1 ) , + D3D12_LOGIC_OP_OR_INVERTED = ( D3D12_LOGIC_OP_OR_REVERSE + 1 ) + } D3D12_LOGIC_OP; + +typedef struct D3D12_RENDER_TARGET_BLEND_DESC + { + BOOL BlendEnable; + BOOL LogicOpEnable; + D3D12_BLEND SrcBlend; + D3D12_BLEND DestBlend; + D3D12_BLEND_OP BlendOp; + D3D12_BLEND SrcBlendAlpha; + D3D12_BLEND DestBlendAlpha; + D3D12_BLEND_OP BlendOpAlpha; + D3D12_LOGIC_OP LogicOp; + UINT8 RenderTargetWriteMask; + } D3D12_RENDER_TARGET_BLEND_DESC; + +typedef struct D3D12_BLEND_DESC + { + BOOL AlphaToCoverageEnable; + BOOL IndependentBlendEnable; + D3D12_RENDER_TARGET_BLEND_DESC RenderTarget[ 8 ]; + } D3D12_BLEND_DESC; + +/* Note, the array size for RenderTarget[] above is D3D12_SIMULTANEOUS_RENDERTARGET_COUNT. + IDL processing/generation of this header replaces the define; this comment is merely explaining what happened. */ +typedef +enum D3D12_CONSERVATIVE_RASTERIZATION_MODE + { + D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF = 0, + D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON = 1 + } D3D12_CONSERVATIVE_RASTERIZATION_MODE; + +typedef struct D3D12_RASTERIZER_DESC + { + D3D12_FILL_MODE FillMode; + D3D12_CULL_MODE CullMode; + BOOL FrontCounterClockwise; + INT DepthBias; + FLOAT DepthBiasClamp; + FLOAT SlopeScaledDepthBias; + BOOL DepthClipEnable; + BOOL MultisampleEnable; + BOOL AntialiasedLineEnable; + UINT ForcedSampleCount; + D3D12_CONSERVATIVE_RASTERIZATION_MODE ConservativeRaster; + } D3D12_RASTERIZER_DESC; + +typedef struct D3D12_RASTERIZER_DESC1 + { + D3D12_FILL_MODE FillMode; + D3D12_CULL_MODE CullMode; + BOOL FrontCounterClockwise; + FLOAT DepthBias; + FLOAT DepthBiasClamp; + FLOAT SlopeScaledDepthBias; + BOOL DepthClipEnable; + BOOL MultisampleEnable; + BOOL AntialiasedLineEnable; + UINT ForcedSampleCount; + D3D12_CONSERVATIVE_RASTERIZATION_MODE ConservativeRaster; + } D3D12_RASTERIZER_DESC1; + +typedef +enum D3D12_LINE_RASTERIZATION_MODE + { + D3D12_LINE_RASTERIZATION_MODE_ALIASED = 0, + D3D12_LINE_RASTERIZATION_MODE_ALPHA_ANTIALIASED = ( D3D12_LINE_RASTERIZATION_MODE_ALIASED + 1 ) , + D3D12_LINE_RASTERIZATION_MODE_QUADRILATERAL_WIDE = ( D3D12_LINE_RASTERIZATION_MODE_ALPHA_ANTIALIASED + 1 ) , + D3D12_LINE_RASTERIZATION_MODE_QUADRILATERAL_NARROW = ( D3D12_LINE_RASTERIZATION_MODE_QUADRILATERAL_WIDE + 1 ) + } D3D12_LINE_RASTERIZATION_MODE; + +typedef struct D3D12_RASTERIZER_DESC2 + { + D3D12_FILL_MODE FillMode; + D3D12_CULL_MODE CullMode; + BOOL FrontCounterClockwise; + FLOAT DepthBias; + FLOAT DepthBiasClamp; + FLOAT SlopeScaledDepthBias; + BOOL DepthClipEnable; + D3D12_LINE_RASTERIZATION_MODE LineRasterizationMode; + UINT ForcedSampleCount; + D3D12_CONSERVATIVE_RASTERIZATION_MODE ConservativeRaster; + } D3D12_RASTERIZER_DESC2; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0000_v0_0_s_ifspec; + +#ifndef __ID3D12Object_INTERFACE_DEFINED__ +#define __ID3D12Object_INTERFACE_DEFINED__ + +/* interface ID3D12Object */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Object; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("c4fec28f-7966-4e95-9f94-f431cb56c3b8") + ID3D12Object : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetPrivateData( + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateData( + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetPrivateDataInterface( + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetName( + _In_z_ LPCWSTR Name) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ObjectVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Object * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Object * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Object * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Object * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Object * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Object * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Object * This, + _In_z_ LPCWSTR Name); + + END_INTERFACE + } ID3D12ObjectVtbl; + + interface ID3D12Object + { + CONST_VTBL struct ID3D12ObjectVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Object_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Object_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Object_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Object_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Object_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Object_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Object_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Object_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceChild_INTERFACE_DEFINED__ +#define __ID3D12DeviceChild_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceChild */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceChild; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("905db94b-a00c-4140-9df5-2b64ca9ea357") + ID3D12DeviceChild : public ID3D12Object + { + public: + virtual HRESULT STDMETHODCALLTYPE GetDevice( + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceChildVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceChild * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceChild * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceChild * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12DeviceChild * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12DeviceChild * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12DeviceChild * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12DeviceChild * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12DeviceChild * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12DeviceChildVtbl; + + interface ID3D12DeviceChild + { + CONST_VTBL struct ID3D12DeviceChildVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceChild_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceChild_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceChild_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceChild_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12DeviceChild_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12DeviceChild_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12DeviceChild_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12DeviceChild_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceChild_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12RootSignature_INTERFACE_DEFINED__ +#define __ID3D12RootSignature_INTERFACE_DEFINED__ + +/* interface ID3D12RootSignature */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12RootSignature; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("c54a6b66-72df-4ee8-8be5-a946a1429214") + ID3D12RootSignature : public ID3D12DeviceChild + { + public: + }; + + +#else /* C style interface */ + + typedef struct ID3D12RootSignatureVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12RootSignature * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12RootSignature * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12RootSignature * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12RootSignature * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12RootSignature * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12RootSignature * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12RootSignature * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12RootSignature * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12RootSignatureVtbl; + + interface ID3D12RootSignature + { + CONST_VTBL struct ID3D12RootSignatureVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12RootSignature_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12RootSignature_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12RootSignature_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12RootSignature_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12RootSignature_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12RootSignature_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12RootSignature_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12RootSignature_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12RootSignature_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0001 */ +/* [local] */ + +typedef struct D3D12_SHADER_BYTECODE + { + _Field_size_bytes_full_(BytecodeLength) const void *pShaderBytecode; + SIZE_T BytecodeLength; + } D3D12_SHADER_BYTECODE; + +typedef struct D3D12_STREAM_OUTPUT_DESC + { + _Field_size_full_(NumEntries) const D3D12_SO_DECLARATION_ENTRY *pSODeclaration; + UINT NumEntries; + _Field_size_full_(NumStrides) const UINT *pBufferStrides; + UINT NumStrides; + UINT RasterizedStream; + } D3D12_STREAM_OUTPUT_DESC; + +typedef struct D3D12_INPUT_LAYOUT_DESC + { + _Field_size_full_(NumElements) const D3D12_INPUT_ELEMENT_DESC *pInputElementDescs; + UINT NumElements; + } D3D12_INPUT_LAYOUT_DESC; + +typedef +enum D3D12_INDEX_BUFFER_STRIP_CUT_VALUE + { + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_DISABLED = 0, + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFF = 1, + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE_0xFFFFFFFF = 2 + } D3D12_INDEX_BUFFER_STRIP_CUT_VALUE; + +typedef +enum D3D12_STANDARD_MULTISAMPLE_QUALITY_LEVELS + { + D3D12_STANDARD_MULTISAMPLE_PATTERN = 0xffffffff, + D3D12_CENTER_MULTISAMPLE_PATTERN = 0xfffffffe + } D3D12_STANDARD_MULTISAMPLE_QUALITY_LEVELS; + +typedef struct D3D12_CACHED_PIPELINE_STATE + { + _Field_size_bytes_full_(CachedBlobSizeInBytes) const void *pCachedBlob; + SIZE_T CachedBlobSizeInBytes; + } D3D12_CACHED_PIPELINE_STATE; + +typedef +enum D3D12_PIPELINE_STATE_FLAGS + { + D3D12_PIPELINE_STATE_FLAG_NONE = 0, + D3D12_PIPELINE_STATE_FLAG_TOOL_DEBUG = 0x1, + D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS = 0x4, + D3D12_PIPELINE_STATE_FLAG_DYNAMIC_INDEX_BUFFER_STRIP_CUT = 0x8 + } D3D12_PIPELINE_STATE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_PIPELINE_STATE_FLAGS ) +typedef struct D3D12_GRAPHICS_PIPELINE_STATE_DESC + { + ID3D12RootSignature *pRootSignature; + D3D12_SHADER_BYTECODE VS; + D3D12_SHADER_BYTECODE PS; + D3D12_SHADER_BYTECODE DS; + D3D12_SHADER_BYTECODE HS; + D3D12_SHADER_BYTECODE GS; + D3D12_STREAM_OUTPUT_DESC StreamOutput; + D3D12_BLEND_DESC BlendState; + UINT SampleMask; + D3D12_RASTERIZER_DESC RasterizerState; + D3D12_DEPTH_STENCIL_DESC DepthStencilState; + D3D12_INPUT_LAYOUT_DESC InputLayout; + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue; + D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType; + UINT NumRenderTargets; + DXGI_FORMAT RTVFormats[ 8 ]; + DXGI_FORMAT DSVFormat; + DXGI_SAMPLE_DESC SampleDesc; + UINT NodeMask; + D3D12_CACHED_PIPELINE_STATE CachedPSO; + D3D12_PIPELINE_STATE_FLAGS Flags; + } D3D12_GRAPHICS_PIPELINE_STATE_DESC; + +typedef struct D3D12_COMPUTE_PIPELINE_STATE_DESC + { + ID3D12RootSignature *pRootSignature; + D3D12_SHADER_BYTECODE CS; + UINT NodeMask; + D3D12_CACHED_PIPELINE_STATE CachedPSO; + D3D12_PIPELINE_STATE_FLAGS Flags; + } D3D12_COMPUTE_PIPELINE_STATE_DESC; + +struct D3D12_RT_FORMAT_ARRAY + { + DXGI_FORMAT RTFormats[ 8 ]; + UINT NumRenderTargets; + } ; +typedef struct D3D12_PIPELINE_STATE_STREAM_DESC + { + _In_ SIZE_T SizeInBytes; + _In_reads_(_Inexpressible_("Dependent on size of subobjects")) void *pPipelineStateSubobjectStream; + } D3D12_PIPELINE_STATE_STREAM_DESC; + +typedef +enum D3D12_PIPELINE_STATE_SUBOBJECT_TYPE + { + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE = 0, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 + 1 ) , + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS = 24, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS = 25, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 = 26, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER1 = 27, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER2 = 28, + D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MAX_VALID = ( D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER2 + 1 ) + } D3D12_PIPELINE_STATE_SUBOBJECT_TYPE; + +typedef +enum D3D12_FEATURE + { + D3D12_FEATURE_D3D12_OPTIONS = 0, + D3D12_FEATURE_ARCHITECTURE = 1, + D3D12_FEATURE_FEATURE_LEVELS = 2, + D3D12_FEATURE_FORMAT_SUPPORT = 3, + D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS = 4, + D3D12_FEATURE_FORMAT_INFO = 5, + D3D12_FEATURE_GPU_VIRTUAL_ADDRESS_SUPPORT = 6, + D3D12_FEATURE_SHADER_MODEL = 7, + D3D12_FEATURE_D3D12_OPTIONS1 = 8, + D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_SUPPORT = 10, + D3D12_FEATURE_ROOT_SIGNATURE = 12, + D3D12_FEATURE_ARCHITECTURE1 = 16, + D3D12_FEATURE_D3D12_OPTIONS2 = 18, + D3D12_FEATURE_SHADER_CACHE = 19, + D3D12_FEATURE_COMMAND_QUEUE_PRIORITY = 20, + D3D12_FEATURE_D3D12_OPTIONS3 = 21, + D3D12_FEATURE_EXISTING_HEAPS = 22, + D3D12_FEATURE_D3D12_OPTIONS4 = 23, + D3D12_FEATURE_SERIALIZATION = 24, + D3D12_FEATURE_CROSS_NODE = 25, + D3D12_FEATURE_D3D12_OPTIONS5 = 27, + D3D12_FEATURE_DISPLAYABLE = 28, + D3D12_FEATURE_D3D12_OPTIONS6 = 30, + D3D12_FEATURE_QUERY_META_COMMAND = 31, + D3D12_FEATURE_D3D12_OPTIONS7 = 32, + D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPE_COUNT = 33, + D3D12_FEATURE_PROTECTED_RESOURCE_SESSION_TYPES = 34, + D3D12_FEATURE_D3D12_OPTIONS8 = 36, + D3D12_FEATURE_D3D12_OPTIONS9 = 37, + D3D12_FEATURE_D3D12_OPTIONS10 = 39, + D3D12_FEATURE_D3D12_OPTIONS11 = 40, + D3D12_FEATURE_D3D12_OPTIONS12 = 41, + D3D12_FEATURE_D3D12_OPTIONS13 = 42, + D3D12_FEATURE_D3D12_OPTIONS14 = 43, + D3D12_FEATURE_D3D12_OPTIONS15 = 44, + D3D12_FEATURE_D3D12_OPTIONS16 = 45, + D3D12_FEATURE_D3D12_OPTIONS17 = 46, + D3D12_FEATURE_D3D12_OPTIONS18 = 47, + D3D12_FEATURE_D3D12_OPTIONS19 = 48, + D3D12_FEATURE_D3D12_OPTIONS20 = 49, + D3D12_FEATURE_PREDICATION = 50, + D3D12_FEATURE_PLACED_RESOURCE_SUPPORT_INFO = 51, + D3D12_FEATURE_HARDWARE_COPY = 52, + D3D12_FEATURE_D3D12_OPTIONS21 = 53 + } D3D12_FEATURE; + +typedef +enum D3D12_SHADER_MIN_PRECISION_SUPPORT + { + D3D12_SHADER_MIN_PRECISION_SUPPORT_NONE = 0, + D3D12_SHADER_MIN_PRECISION_SUPPORT_10_BIT = 0x1, + D3D12_SHADER_MIN_PRECISION_SUPPORT_16_BIT = 0x2 + } D3D12_SHADER_MIN_PRECISION_SUPPORT; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_MIN_PRECISION_SUPPORT ) +typedef +enum D3D12_TILED_RESOURCES_TIER + { + D3D12_TILED_RESOURCES_TIER_NOT_SUPPORTED = 0, + D3D12_TILED_RESOURCES_TIER_1 = 1, + D3D12_TILED_RESOURCES_TIER_2 = 2, + D3D12_TILED_RESOURCES_TIER_3 = 3, + D3D12_TILED_RESOURCES_TIER_4 = 4 + } D3D12_TILED_RESOURCES_TIER; + +typedef +enum D3D12_RESOURCE_BINDING_TIER + { + D3D12_RESOURCE_BINDING_TIER_1 = 1, + D3D12_RESOURCE_BINDING_TIER_2 = 2, + D3D12_RESOURCE_BINDING_TIER_3 = 3 + } D3D12_RESOURCE_BINDING_TIER; + +typedef +enum D3D12_CONSERVATIVE_RASTERIZATION_TIER + { + D3D12_CONSERVATIVE_RASTERIZATION_TIER_NOT_SUPPORTED = 0, + D3D12_CONSERVATIVE_RASTERIZATION_TIER_1 = 1, + D3D12_CONSERVATIVE_RASTERIZATION_TIER_2 = 2, + D3D12_CONSERVATIVE_RASTERIZATION_TIER_3 = 3 + } D3D12_CONSERVATIVE_RASTERIZATION_TIER; + +typedef +enum D3D12_FORMAT_SUPPORT1 + { + D3D12_FORMAT_SUPPORT1_NONE = 0, + D3D12_FORMAT_SUPPORT1_BUFFER = 0x1, + D3D12_FORMAT_SUPPORT1_IA_VERTEX_BUFFER = 0x2, + D3D12_FORMAT_SUPPORT1_IA_INDEX_BUFFER = 0x4, + D3D12_FORMAT_SUPPORT1_SO_BUFFER = 0x8, + D3D12_FORMAT_SUPPORT1_TEXTURE1D = 0x10, + D3D12_FORMAT_SUPPORT1_TEXTURE2D = 0x20, + D3D12_FORMAT_SUPPORT1_TEXTURE3D = 0x40, + D3D12_FORMAT_SUPPORT1_TEXTURECUBE = 0x80, + D3D12_FORMAT_SUPPORT1_SHADER_LOAD = 0x100, + D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE = 0x200, + D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_COMPARISON = 0x400, + D3D12_FORMAT_SUPPORT1_SHADER_SAMPLE_MONO_TEXT = 0x800, + D3D12_FORMAT_SUPPORT1_MIP = 0x1000, + D3D12_FORMAT_SUPPORT1_RENDER_TARGET = 0x4000, + D3D12_FORMAT_SUPPORT1_BLENDABLE = 0x8000, + D3D12_FORMAT_SUPPORT1_DEPTH_STENCIL = 0x10000, + D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RESOLVE = 0x40000, + D3D12_FORMAT_SUPPORT1_DISPLAY = 0x80000, + D3D12_FORMAT_SUPPORT1_CAST_WITHIN_BIT_LAYOUT = 0x100000, + D3D12_FORMAT_SUPPORT1_MULTISAMPLE_RENDERTARGET = 0x200000, + D3D12_FORMAT_SUPPORT1_MULTISAMPLE_LOAD = 0x400000, + D3D12_FORMAT_SUPPORT1_SHADER_GATHER = 0x800000, + D3D12_FORMAT_SUPPORT1_BACK_BUFFER_CAST = 0x1000000, + D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW = 0x2000000, + D3D12_FORMAT_SUPPORT1_SHADER_GATHER_COMPARISON = 0x4000000, + D3D12_FORMAT_SUPPORT1_DECODER_OUTPUT = 0x8000000, + D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_OUTPUT = 0x10000000, + D3D12_FORMAT_SUPPORT1_VIDEO_PROCESSOR_INPUT = 0x20000000, + D3D12_FORMAT_SUPPORT1_VIDEO_ENCODER = 0x40000000 + } D3D12_FORMAT_SUPPORT1; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT1 ) +typedef +enum D3D12_FORMAT_SUPPORT2 + { + D3D12_FORMAT_SUPPORT2_NONE = 0, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_ADD = 0x1, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_BITWISE_OPS = 0x2, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_COMPARE_STORE_OR_COMPARE_EXCHANGE = 0x4, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_EXCHANGE = 0x8, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_SIGNED_MIN_OR_MAX = 0x10, + D3D12_FORMAT_SUPPORT2_UAV_ATOMIC_UNSIGNED_MIN_OR_MAX = 0x20, + D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD = 0x40, + D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE = 0x80, + D3D12_FORMAT_SUPPORT2_OUTPUT_MERGER_LOGIC_OP = 0x100, + D3D12_FORMAT_SUPPORT2_TILED = 0x200, + D3D12_FORMAT_SUPPORT2_MULTIPLANE_OVERLAY = 0x4000, + D3D12_FORMAT_SUPPORT2_SAMPLER_FEEDBACK = 0x8000 + } D3D12_FORMAT_SUPPORT2; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_FORMAT_SUPPORT2 ) +typedef +enum D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS + { + D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE = 0, + D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_TILED_RESOURCE = 0x1 + } D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS ) +typedef +enum D3D12_CROSS_NODE_SHARING_TIER + { + D3D12_CROSS_NODE_SHARING_TIER_NOT_SUPPORTED = 0, + D3D12_CROSS_NODE_SHARING_TIER_1_EMULATED = 1, + D3D12_CROSS_NODE_SHARING_TIER_1 = 2, + D3D12_CROSS_NODE_SHARING_TIER_2 = 3, + D3D12_CROSS_NODE_SHARING_TIER_3 = 4 + } D3D12_CROSS_NODE_SHARING_TIER; + +typedef +enum D3D12_RESOURCE_HEAP_TIER + { + D3D12_RESOURCE_HEAP_TIER_1 = 1, + D3D12_RESOURCE_HEAP_TIER_2 = 2 + } D3D12_RESOURCE_HEAP_TIER; + +typedef +enum D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER + { + D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_NOT_SUPPORTED = 0, + D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_1 = 1, + D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_2 = 2 + } D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER; + +typedef +enum D3D12_VIEW_INSTANCING_TIER + { + D3D12_VIEW_INSTANCING_TIER_NOT_SUPPORTED = 0, + D3D12_VIEW_INSTANCING_TIER_1 = 1, + D3D12_VIEW_INSTANCING_TIER_2 = 2, + D3D12_VIEW_INSTANCING_TIER_3 = 3 + } D3D12_VIEW_INSTANCING_TIER; + +typedef +enum D3D12_WORK_GRAPHS_TIER + { + D3D12_WORK_GRAPHS_TIER_NOT_SUPPORTED = 0, + D3D12_WORK_GRAPHS_TIER_1_0 = 10 + } D3D12_WORK_GRAPHS_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS + { + _Out_ BOOL DoublePrecisionFloatShaderOps; + _Out_ BOOL OutputMergerLogicOp; + _Out_ D3D12_SHADER_MIN_PRECISION_SUPPORT MinPrecisionSupport; + _Out_ D3D12_TILED_RESOURCES_TIER TiledResourcesTier; + _Out_ D3D12_RESOURCE_BINDING_TIER ResourceBindingTier; + _Out_ BOOL PSSpecifiedStencilRefSupported; + _Out_ BOOL TypedUAVLoadAdditionalFormats; + _Out_ BOOL ROVsSupported; + _Out_ D3D12_CONSERVATIVE_RASTERIZATION_TIER ConservativeRasterizationTier; + _Out_ UINT MaxGPUVirtualAddressBitsPerResource; + _Out_ BOOL StandardSwizzle64KBSupported; + _Out_ D3D12_CROSS_NODE_SHARING_TIER CrossNodeSharingTier; + _Out_ BOOL CrossAdapterRowMajorTextureSupported; + _Out_ BOOL VPAndRTArrayIndexFromAnyShaderFeedingRasterizerSupportedWithoutGSEmulation; + _Out_ D3D12_RESOURCE_HEAP_TIER ResourceHeapTier; + } D3D12_FEATURE_DATA_D3D12_OPTIONS; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS1 + { + _Out_ BOOL WaveOps; + _Out_ UINT WaveLaneCountMin; + _Out_ UINT WaveLaneCountMax; + _Out_ UINT TotalLaneCount; + _Out_ BOOL ExpandedComputeResourceStates; + _Out_ BOOL Int64ShaderOps; + } D3D12_FEATURE_DATA_D3D12_OPTIONS1; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS2 + { + _Out_ BOOL DepthBoundsTestSupported; + _Out_ D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER ProgrammableSamplePositionsTier; + } D3D12_FEATURE_DATA_D3D12_OPTIONS2; + +typedef +enum D3D_ROOT_SIGNATURE_VERSION + { + D3D_ROOT_SIGNATURE_VERSION_1 = 0x1, + D3D_ROOT_SIGNATURE_VERSION_1_0 = 0x1, + D3D_ROOT_SIGNATURE_VERSION_1_1 = 0x2, + D3D_ROOT_SIGNATURE_VERSION_1_2 = 0x3 + } D3D_ROOT_SIGNATURE_VERSION; + +typedef struct D3D12_FEATURE_DATA_ROOT_SIGNATURE + { + _Inout_ D3D_ROOT_SIGNATURE_VERSION HighestVersion; + } D3D12_FEATURE_DATA_ROOT_SIGNATURE; + +typedef struct D3D12_FEATURE_DATA_ARCHITECTURE + { + _In_ UINT NodeIndex; + _Out_ BOOL TileBasedRenderer; + _Out_ BOOL UMA; + _Out_ BOOL CacheCoherentUMA; + } D3D12_FEATURE_DATA_ARCHITECTURE; + +typedef struct D3D12_FEATURE_DATA_ARCHITECTURE1 + { + _In_ UINT NodeIndex; + _Out_ BOOL TileBasedRenderer; + _Out_ BOOL UMA; + _Out_ BOOL CacheCoherentUMA; + _Out_ BOOL IsolatedMMU; + } D3D12_FEATURE_DATA_ARCHITECTURE1; + +typedef struct D3D12_FEATURE_DATA_FEATURE_LEVELS + { + _In_ UINT NumFeatureLevels; + _In_reads_(NumFeatureLevels) const D3D_FEATURE_LEVEL *pFeatureLevelsRequested; + _Out_ D3D_FEATURE_LEVEL MaxSupportedFeatureLevel; + } D3D12_FEATURE_DATA_FEATURE_LEVELS; + +typedef +enum D3D_SHADER_MODEL + { + D3D_SHADER_MODEL_NONE = 0, + D3D_SHADER_MODEL_5_1 = 0x51, + D3D_SHADER_MODEL_6_0 = 0x60, + D3D_SHADER_MODEL_6_1 = 0x61, + D3D_SHADER_MODEL_6_2 = 0x62, + D3D_SHADER_MODEL_6_3 = 0x63, + D3D_SHADER_MODEL_6_4 = 0x64, + D3D_SHADER_MODEL_6_5 = 0x65, + D3D_SHADER_MODEL_6_6 = 0x66, + D3D_SHADER_MODEL_6_7 = 0x67, + D3D_SHADER_MODEL_6_8 = 0x68, + D3D_SHADER_MODEL_6_9 = 0x69, + D3D_HIGHEST_SHADER_MODEL = D3D_SHADER_MODEL_6_9 + } D3D_SHADER_MODEL; + +typedef struct D3D12_FEATURE_DATA_SHADER_MODEL + { + _Inout_ D3D_SHADER_MODEL HighestShaderModel; + } D3D12_FEATURE_DATA_SHADER_MODEL; + +typedef struct D3D12_FEATURE_DATA_FORMAT_SUPPORT + { + _In_ DXGI_FORMAT Format; + _Out_ D3D12_FORMAT_SUPPORT1 Support1; + _Out_ D3D12_FORMAT_SUPPORT2 Support2; + } D3D12_FEATURE_DATA_FORMAT_SUPPORT; + +typedef struct D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS + { + _In_ DXGI_FORMAT Format; + _In_ UINT SampleCount; + _In_ D3D12_MULTISAMPLE_QUALITY_LEVEL_FLAGS Flags; + _Out_ UINT NumQualityLevels; + } D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS; + +typedef struct D3D12_FEATURE_DATA_FORMAT_INFO + { + DXGI_FORMAT Format; + UINT8 PlaneCount; + } D3D12_FEATURE_DATA_FORMAT_INFO; + +typedef struct D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT + { + UINT MaxGPUVirtualAddressBitsPerResource; + UINT MaxGPUVirtualAddressBitsPerProcess; + } D3D12_FEATURE_DATA_GPU_VIRTUAL_ADDRESS_SUPPORT; + +typedef +enum D3D12_SHADER_CACHE_SUPPORT_FLAGS + { + D3D12_SHADER_CACHE_SUPPORT_NONE = 0, + D3D12_SHADER_CACHE_SUPPORT_SINGLE_PSO = 0x1, + D3D12_SHADER_CACHE_SUPPORT_LIBRARY = 0x2, + D3D12_SHADER_CACHE_SUPPORT_AUTOMATIC_INPROC_CACHE = 0x4, + D3D12_SHADER_CACHE_SUPPORT_AUTOMATIC_DISK_CACHE = 0x8, + D3D12_SHADER_CACHE_SUPPORT_DRIVER_MANAGED_CACHE = 0x10, + D3D12_SHADER_CACHE_SUPPORT_SHADER_CONTROL_CLEAR = 0x20, + D3D12_SHADER_CACHE_SUPPORT_SHADER_SESSION_DELETE = 0x40 + } D3D12_SHADER_CACHE_SUPPORT_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_CACHE_SUPPORT_FLAGS ) +typedef struct D3D12_FEATURE_DATA_SHADER_CACHE + { + _Out_ D3D12_SHADER_CACHE_SUPPORT_FLAGS SupportFlags; + } D3D12_FEATURE_DATA_SHADER_CACHE; + +typedef struct D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY + { + _In_ D3D12_COMMAND_LIST_TYPE CommandListType; + _In_ UINT Priority; + _Out_ BOOL PriorityForTypeIsSupported; + } D3D12_FEATURE_DATA_COMMAND_QUEUE_PRIORITY; + +typedef +enum D3D12_COMMAND_LIST_SUPPORT_FLAGS + { + D3D12_COMMAND_LIST_SUPPORT_FLAG_NONE = 0, + D3D12_COMMAND_LIST_SUPPORT_FLAG_DIRECT = ( 1 << D3D12_COMMAND_LIST_TYPE_DIRECT ) , + D3D12_COMMAND_LIST_SUPPORT_FLAG_BUNDLE = ( 1 << D3D12_COMMAND_LIST_TYPE_BUNDLE ) , + D3D12_COMMAND_LIST_SUPPORT_FLAG_COMPUTE = ( 1 << D3D12_COMMAND_LIST_TYPE_COMPUTE ) , + D3D12_COMMAND_LIST_SUPPORT_FLAG_COPY = ( 1 << D3D12_COMMAND_LIST_TYPE_COPY ) , + D3D12_COMMAND_LIST_SUPPORT_FLAG_VIDEO_DECODE = ( 1 << D3D12_COMMAND_LIST_TYPE_VIDEO_DECODE ) , + D3D12_COMMAND_LIST_SUPPORT_FLAG_VIDEO_PROCESS = ( 1 << D3D12_COMMAND_LIST_TYPE_VIDEO_PROCESS ) , + D3D12_COMMAND_LIST_SUPPORT_FLAG_VIDEO_ENCODE = ( 1 << D3D12_COMMAND_LIST_TYPE_VIDEO_ENCODE ) + } D3D12_COMMAND_LIST_SUPPORT_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_LIST_SUPPORT_FLAGS ) +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS3 + { + _Out_ BOOL CopyQueueTimestampQueriesSupported; + _Out_ BOOL CastingFullyTypedFormatSupported; + _Out_ D3D12_COMMAND_LIST_SUPPORT_FLAGS WriteBufferImmediateSupportFlags; + _Out_ D3D12_VIEW_INSTANCING_TIER ViewInstancingTier; + _Out_ BOOL BarycentricsSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS3; + +typedef struct D3D12_FEATURE_DATA_EXISTING_HEAPS + { + _Out_ BOOL Supported; + } D3D12_FEATURE_DATA_EXISTING_HEAPS; + +typedef +enum D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER + { + D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_0 = 0, + D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_1 = ( D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_0 + 1 ) , + D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_2 = ( D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER_1 + 1 ) + } D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER; + +typedef struct D3D12_FEATURE_DATA_DISPLAYABLE + { + _Out_ BOOL DisplayableTexture; + _Out_ D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; + } D3D12_FEATURE_DATA_DISPLAYABLE; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS4 + { + _Out_ BOOL MSAA64KBAlignedTextureSupported; + _Out_ D3D12_SHARED_RESOURCE_COMPATIBILITY_TIER SharedResourceCompatibilityTier; + _Out_ BOOL Native16BitShaderOpsSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS4; + +typedef +enum D3D12_HEAP_SERIALIZATION_TIER + { + D3D12_HEAP_SERIALIZATION_TIER_0 = 0, + D3D12_HEAP_SERIALIZATION_TIER_10 = 10 + } D3D12_HEAP_SERIALIZATION_TIER; + +typedef struct D3D12_FEATURE_DATA_SERIALIZATION + { + _In_ UINT NodeIndex; + _Out_ D3D12_HEAP_SERIALIZATION_TIER HeapSerializationTier; + } D3D12_FEATURE_DATA_SERIALIZATION; + +typedef struct D3D12_FEATURE_DATA_CROSS_NODE + { + D3D12_CROSS_NODE_SHARING_TIER SharingTier; + BOOL AtomicShaderInstructions; + } D3D12_FEATURE_DATA_CROSS_NODE; + +typedef +enum D3D12_RENDER_PASS_TIER + { + D3D12_RENDER_PASS_TIER_0 = 0, + D3D12_RENDER_PASS_TIER_1 = 1, + D3D12_RENDER_PASS_TIER_2 = 2 + } D3D12_RENDER_PASS_TIER; + +typedef +enum D3D12_RAYTRACING_TIER + { + D3D12_RAYTRACING_TIER_NOT_SUPPORTED = 0, + D3D12_RAYTRACING_TIER_1_0 = 10, + D3D12_RAYTRACING_TIER_1_1 = 11 + } D3D12_RAYTRACING_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS5 + { + _Out_ BOOL SRVOnlyTiledResourceTier3; + _Out_ D3D12_RENDER_PASS_TIER RenderPassesTier; + _Out_ D3D12_RAYTRACING_TIER RaytracingTier; + } D3D12_FEATURE_DATA_D3D12_OPTIONS5; + +typedef +enum D3D12_VARIABLE_SHADING_RATE_TIER + { + D3D12_VARIABLE_SHADING_RATE_TIER_NOT_SUPPORTED = 0, + D3D12_VARIABLE_SHADING_RATE_TIER_1 = 1, + D3D12_VARIABLE_SHADING_RATE_TIER_2 = 2 + } D3D12_VARIABLE_SHADING_RATE_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS6 + { + _Out_ BOOL AdditionalShadingRatesSupported; + _Out_ BOOL PerPrimitiveShadingRateSupportedWithViewportIndexing; + _Out_ D3D12_VARIABLE_SHADING_RATE_TIER VariableShadingRateTier; + _Out_ UINT ShadingRateImageTileSize; + _Out_ BOOL BackgroundProcessingSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS6; + +typedef +enum D3D12_MESH_SHADER_TIER + { + D3D12_MESH_SHADER_TIER_NOT_SUPPORTED = 0, + D3D12_MESH_SHADER_TIER_1 = 10 + } D3D12_MESH_SHADER_TIER; + +typedef +enum D3D12_SAMPLER_FEEDBACK_TIER + { + D3D12_SAMPLER_FEEDBACK_TIER_NOT_SUPPORTED = 0, + D3D12_SAMPLER_FEEDBACK_TIER_0_9 = 90, + D3D12_SAMPLER_FEEDBACK_TIER_1_0 = 100 + } D3D12_SAMPLER_FEEDBACK_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS7 + { + _Out_ D3D12_MESH_SHADER_TIER MeshShaderTier; + _Out_ D3D12_SAMPLER_FEEDBACK_TIER SamplerFeedbackTier; + } D3D12_FEATURE_DATA_D3D12_OPTIONS7; + +typedef struct D3D12_FEATURE_DATA_QUERY_META_COMMAND + { + _In_ GUID CommandId; + _In_ UINT NodeMask; + _Field_size_bytes_full_opt_( QueryInputDataSizeInBytes ) const void *pQueryInputData; + _In_ SIZE_T QueryInputDataSizeInBytes; + _Field_size_bytes_full_( QueryOutputDataSizeInBytes ) void *pQueryOutputData; + _In_ SIZE_T QueryOutputDataSizeInBytes; + } D3D12_FEATURE_DATA_QUERY_META_COMMAND; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS8 + { + _Out_ BOOL UnalignedBlockTexturesSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS8; + +typedef +enum D3D12_WAVE_MMA_TIER + { + D3D12_WAVE_MMA_TIER_NOT_SUPPORTED = 0, + D3D12_WAVE_MMA_TIER_1_0 = 10 + } D3D12_WAVE_MMA_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS9 + { + _Out_ BOOL MeshShaderPipelineStatsSupported; + _Out_ BOOL MeshShaderSupportsFullRangeRenderTargetArrayIndex; + _Out_ BOOL AtomicInt64OnTypedResourceSupported; + _Out_ BOOL AtomicInt64OnGroupSharedSupported; + _Out_ BOOL DerivativesInMeshAndAmplificationShadersSupported; + _Out_ D3D12_WAVE_MMA_TIER WaveMMATier; + } D3D12_FEATURE_DATA_D3D12_OPTIONS9; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS10 + { + _Out_ BOOL VariableRateShadingSumCombinerSupported; + _Out_ BOOL MeshShaderPerPrimitiveShadingRateSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS10; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS11 + { + _Out_ BOOL AtomicInt64OnDescriptorHeapResourceSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS11; + +typedef +enum D3D12_TRI_STATE + { + D3D12_TRI_STATE_UNKNOWN = -1, + D3D12_TRI_STATE_FALSE = 0, + D3D12_TRI_STATE_TRUE = 1 + } D3D12_TRI_STATE; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS12 + { + _Out_ D3D12_TRI_STATE MSPrimitivesPipelineStatisticIncludesCulledPrimitives; + _Out_ BOOL EnhancedBarriersSupported; + _Out_ BOOL RelaxedFormatCastingSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS12; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS13 + { + _Out_ BOOL UnrestrictedBufferTextureCopyPitchSupported; + _Out_ BOOL UnrestrictedVertexElementAlignmentSupported; + _Out_ BOOL InvertedViewportHeightFlipsYSupported; + _Out_ BOOL InvertedViewportDepthFlipsZSupported; + _Out_ BOOL TextureCopyBetweenDimensionsSupported; + _Out_ BOOL AlphaBlendFactorSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS13; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS14 + { + _Out_ BOOL AdvancedTextureOpsSupported; + _Out_ BOOL WriteableMSAATexturesSupported; + _Out_ BOOL IndependentFrontAndBackStencilRefMaskSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS14; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS15 + { + _Out_ BOOL TriangleFanSupported; + _Out_ BOOL DynamicIndexBufferStripCutSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS15; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS16 + { + _Out_ BOOL DynamicDepthBiasSupported; + _Out_ BOOL GPUUploadHeapSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS16; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS17 + { + _Out_ BOOL NonNormalizedCoordinateSamplersSupported; + _Out_ BOOL ManualWriteTrackingResourceSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS17; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS18 + { + _Out_ BOOL RenderPassesValid; + } D3D12_FEATURE_DATA_D3D12_OPTIONS18; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS19 + { + BOOL MismatchingOutputDimensionsSupported; + UINT SupportedSampleCountsWithNoOutputs; + BOOL PointSamplingAddressesNeverRoundUp; + BOOL RasterizerDesc2Supported; + BOOL NarrowQuadrilateralLinesSupported; + BOOL AnisoFilterWithPointMipSupported; + UINT MaxSamplerDescriptorHeapSize; + UINT MaxSamplerDescriptorHeapSizeWithStaticSamplers; + UINT MaxViewDescriptorHeapSize; + _Out_ BOOL ComputeOnlyCustomHeapSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS19; + +typedef +enum D3D12_RECREATE_AT_TIER + { + D3D12_RECREATE_AT_TIER_NOT_SUPPORTED = 0, + D3D12_RECREATE_AT_TIER_1 = 1 + } D3D12_RECREATE_AT_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS20 + { + _Out_ BOOL ComputeOnlyWriteWatchSupported; + D3D12_RECREATE_AT_TIER RecreateAtTier; + } D3D12_FEATURE_DATA_D3D12_OPTIONS20; + +typedef +enum D3D12_EXECUTE_INDIRECT_TIER + { + D3D12_EXECUTE_INDIRECT_TIER_1_0 = 10, + D3D12_EXECUTE_INDIRECT_TIER_1_1 = 11 + } D3D12_EXECUTE_INDIRECT_TIER; + +typedef struct D3D12_FEATURE_DATA_D3D12_OPTIONS21 + { + _Out_ D3D12_WORK_GRAPHS_TIER WorkGraphsTier; + _Out_ D3D12_EXECUTE_INDIRECT_TIER ExecuteIndirectTier; + _Out_ BOOL SampleCmpGradientAndBiasSupported; + _Out_ BOOL ExtendedCommandInfoSupported; + } D3D12_FEATURE_DATA_D3D12_OPTIONS21; + +typedef struct D3D12_FEATURE_DATA_PREDICATION + { + _Out_ BOOL Supported; + } D3D12_FEATURE_DATA_PREDICATION; + +typedef struct D3D12_FEATURE_DATA_HARDWARE_COPY + { + _Out_ BOOL Supported; + } D3D12_FEATURE_DATA_HARDWARE_COPY; + +typedef struct D3D12_RESOURCE_ALLOCATION_INFO + { + UINT64 SizeInBytes; + UINT64 Alignment; + } D3D12_RESOURCE_ALLOCATION_INFO; + +typedef struct D3D12_RESOURCE_ALLOCATION_INFO1 + { + UINT64 Offset; + UINT64 Alignment; + UINT64 SizeInBytes; + } D3D12_RESOURCE_ALLOCATION_INFO1; + +typedef +enum D3D12_HEAP_TYPE + { + D3D12_HEAP_TYPE_DEFAULT = 1, + D3D12_HEAP_TYPE_UPLOAD = 2, + D3D12_HEAP_TYPE_READBACK = 3, + D3D12_HEAP_TYPE_CUSTOM = 4, + D3D12_HEAP_TYPE_GPU_UPLOAD = 5 + } D3D12_HEAP_TYPE; + +typedef +enum D3D12_CPU_PAGE_PROPERTY + { + D3D12_CPU_PAGE_PROPERTY_UNKNOWN = 0, + D3D12_CPU_PAGE_PROPERTY_NOT_AVAILABLE = 1, + D3D12_CPU_PAGE_PROPERTY_WRITE_COMBINE = 2, + D3D12_CPU_PAGE_PROPERTY_WRITE_BACK = 3 + } D3D12_CPU_PAGE_PROPERTY; + +typedef +enum D3D12_MEMORY_POOL + { + D3D12_MEMORY_POOL_UNKNOWN = 0, + D3D12_MEMORY_POOL_L0 = 1, + D3D12_MEMORY_POOL_L1 = 2 + } D3D12_MEMORY_POOL; + +typedef struct D3D12_HEAP_PROPERTIES + { + D3D12_HEAP_TYPE Type; + D3D12_CPU_PAGE_PROPERTY CPUPageProperty; + D3D12_MEMORY_POOL MemoryPoolPreference; + UINT CreationNodeMask; + UINT VisibleNodeMask; + } D3D12_HEAP_PROPERTIES; + +typedef +enum D3D12_HEAP_FLAGS + { + D3D12_HEAP_FLAG_NONE = 0, + D3D12_HEAP_FLAG_SHARED = 0x1, + D3D12_HEAP_FLAG_DENY_BUFFERS = 0x4, + D3D12_HEAP_FLAG_ALLOW_DISPLAY = 0x8, + D3D12_HEAP_FLAG_SHARED_CROSS_ADAPTER = 0x20, + D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES = 0x40, + D3D12_HEAP_FLAG_DENY_NON_RT_DS_TEXTURES = 0x80, + D3D12_HEAP_FLAG_HARDWARE_PROTECTED = 0x100, + D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH = 0x200, + D3D12_HEAP_FLAG_ALLOW_SHADER_ATOMICS = 0x400, + D3D12_HEAP_FLAG_CREATE_NOT_RESIDENT = 0x800, + D3D12_HEAP_FLAG_CREATE_NOT_ZEROED = 0x1000, + D3D12_HEAP_FLAG_TOOLS_USE_MANUAL_WRITE_TRACKING = 0x2000, + D3D12_HEAP_FLAG_ALLOW_ALL_BUFFERS_AND_TEXTURES = 0, + D3D12_HEAP_FLAG_ALLOW_ONLY_BUFFERS = 0xc0, + D3D12_HEAP_FLAG_ALLOW_ONLY_NON_RT_DS_TEXTURES = 0x44, + D3D12_HEAP_FLAG_ALLOW_ONLY_RT_DS_TEXTURES = 0x84 + } D3D12_HEAP_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_HEAP_FLAGS ) +typedef struct D3D12_HEAP_DESC + { + UINT64 SizeInBytes; + D3D12_HEAP_PROPERTIES Properties; + UINT64 Alignment; + D3D12_HEAP_FLAGS Flags; + } D3D12_HEAP_DESC; + +typedef +enum D3D12_RESOURCE_DIMENSION + { + D3D12_RESOURCE_DIMENSION_UNKNOWN = 0, + D3D12_RESOURCE_DIMENSION_BUFFER = 1, + D3D12_RESOURCE_DIMENSION_TEXTURE1D = 2, + D3D12_RESOURCE_DIMENSION_TEXTURE2D = 3, + D3D12_RESOURCE_DIMENSION_TEXTURE3D = 4 + } D3D12_RESOURCE_DIMENSION; + +typedef struct D3D12_FEATURE_DATA_PLACED_RESOURCE_SUPPORT_INFO + { + _In_ DXGI_FORMAT Format; + _In_ D3D12_RESOURCE_DIMENSION Dimension; + _In_ D3D12_HEAP_PROPERTIES DestHeapProperties; + _Out_ BOOL Supported; + } D3D12_FEATURE_DATA_PLACED_RESOURCE_SUPPORT_INFO; + +typedef +enum D3D12_TEXTURE_LAYOUT + { + D3D12_TEXTURE_LAYOUT_UNKNOWN = 0, + D3D12_TEXTURE_LAYOUT_ROW_MAJOR = 1, + D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE = 2, + D3D12_TEXTURE_LAYOUT_64KB_STANDARD_SWIZZLE = 3 + } D3D12_TEXTURE_LAYOUT; + +typedef +enum D3D12_RESOURCE_FLAGS + { + D3D12_RESOURCE_FLAG_NONE = 0, + D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET = 0x1, + D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL = 0x2, + D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS = 0x4, + D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE = 0x8, + D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER = 0x10, + D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS = 0x20, + D3D12_RESOURCE_FLAG_VIDEO_DECODE_REFERENCE_ONLY = 0x40, + D3D12_RESOURCE_FLAG_VIDEO_ENCODE_REFERENCE_ONLY = 0x80, + D3D12_RESOURCE_FLAG_RAYTRACING_ACCELERATION_STRUCTURE = 0x100 + } D3D12_RESOURCE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_FLAGS ) +typedef struct D3D12_MIP_REGION + { + UINT Width; + UINT Height; + UINT Depth; + } D3D12_MIP_REGION; + +typedef struct D3D12_RESOURCE_DESC + { + D3D12_RESOURCE_DIMENSION Dimension; + UINT64 Alignment; + UINT64 Width; + UINT Height; + UINT16 DepthOrArraySize; + UINT16 MipLevels; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D12_TEXTURE_LAYOUT Layout; + D3D12_RESOURCE_FLAGS Flags; + } D3D12_RESOURCE_DESC; + +typedef struct D3D12_RESOURCE_DESC1 + { + D3D12_RESOURCE_DIMENSION Dimension; + UINT64 Alignment; + UINT64 Width; + UINT Height; + UINT16 DepthOrArraySize; + UINT16 MipLevels; + DXGI_FORMAT Format; + DXGI_SAMPLE_DESC SampleDesc; + D3D12_TEXTURE_LAYOUT Layout; + D3D12_RESOURCE_FLAGS Flags; + D3D12_MIP_REGION SamplerFeedbackMipRegion; + } D3D12_RESOURCE_DESC1; + +typedef struct D3D12_DEPTH_STENCIL_VALUE + { + FLOAT Depth; + UINT8 Stencil; + } D3D12_DEPTH_STENCIL_VALUE; + +typedef struct D3D12_CLEAR_VALUE + { + DXGI_FORMAT Format; + union + { + FLOAT Color[ 4 ]; + D3D12_DEPTH_STENCIL_VALUE DepthStencil; + } ; + } D3D12_CLEAR_VALUE; + +typedef struct D3D12_RANGE + { + SIZE_T Begin; + SIZE_T End; + } D3D12_RANGE; + +typedef struct D3D12_RANGE_UINT64 + { + UINT64 Begin; + UINT64 End; + } D3D12_RANGE_UINT64; + +typedef struct D3D12_SUBRESOURCE_RANGE_UINT64 + { + UINT Subresource; + D3D12_RANGE_UINT64 Range; + } D3D12_SUBRESOURCE_RANGE_UINT64; + +typedef struct D3D12_SUBRESOURCE_INFO + { + UINT64 Offset; + UINT RowPitch; + UINT DepthPitch; + } D3D12_SUBRESOURCE_INFO; + +typedef struct D3D12_TILED_RESOURCE_COORDINATE + { + UINT X; + UINT Y; + UINT Z; + UINT Subresource; + } D3D12_TILED_RESOURCE_COORDINATE; + +typedef struct D3D12_TILE_REGION_SIZE + { + UINT NumTiles; + BOOL UseBox; + UINT Width; + UINT16 Height; + UINT16 Depth; + } D3D12_TILE_REGION_SIZE; + +typedef +enum D3D12_TILE_RANGE_FLAGS + { + D3D12_TILE_RANGE_FLAG_NONE = 0, + D3D12_TILE_RANGE_FLAG_NULL = 1, + D3D12_TILE_RANGE_FLAG_SKIP = 2, + D3D12_TILE_RANGE_FLAG_REUSE_SINGLE_TILE = 4 + } D3D12_TILE_RANGE_FLAGS; + +typedef struct D3D12_SUBRESOURCE_TILING + { + UINT WidthInTiles; + UINT16 HeightInTiles; + UINT16 DepthInTiles; + UINT StartTileIndexInOverallResource; + } D3D12_SUBRESOURCE_TILING; + +typedef struct D3D12_TILE_SHAPE + { + UINT WidthInTexels; + UINT HeightInTexels; + UINT DepthInTexels; + } D3D12_TILE_SHAPE; + +typedef struct D3D12_PACKED_MIP_INFO + { + UINT8 NumStandardMips; + UINT8 NumPackedMips; + UINT NumTilesForPackedMips; + UINT StartTileIndexInOverallResource; + } D3D12_PACKED_MIP_INFO; + +typedef +enum D3D12_TILE_MAPPING_FLAGS + { + D3D12_TILE_MAPPING_FLAG_NONE = 0, + D3D12_TILE_MAPPING_FLAG_NO_HAZARD = 0x1 + } D3D12_TILE_MAPPING_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_MAPPING_FLAGS ) +typedef +enum D3D12_TILE_COPY_FLAGS + { + D3D12_TILE_COPY_FLAG_NONE = 0, + D3D12_TILE_COPY_FLAG_NO_HAZARD = 0x1, + D3D12_TILE_COPY_FLAG_LINEAR_BUFFER_TO_SWIZZLED_TILED_RESOURCE = 0x2, + D3D12_TILE_COPY_FLAG_SWIZZLED_TILED_RESOURCE_TO_LINEAR_BUFFER = 0x4 + } D3D12_TILE_COPY_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_TILE_COPY_FLAGS ) +typedef +enum D3D12_RESOURCE_STATES + { + D3D12_RESOURCE_STATE_COMMON = 0, + D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER = 0x1, + D3D12_RESOURCE_STATE_INDEX_BUFFER = 0x2, + D3D12_RESOURCE_STATE_RENDER_TARGET = 0x4, + D3D12_RESOURCE_STATE_UNORDERED_ACCESS = 0x8, + D3D12_RESOURCE_STATE_DEPTH_WRITE = 0x10, + D3D12_RESOURCE_STATE_DEPTH_READ = 0x20, + D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE = 0x40, + D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE = 0x80, + D3D12_RESOURCE_STATE_STREAM_OUT = 0x100, + D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT = 0x200, + D3D12_RESOURCE_STATE_COPY_DEST = 0x400, + D3D12_RESOURCE_STATE_COPY_SOURCE = 0x800, + D3D12_RESOURCE_STATE_RESOLVE_DEST = 0x1000, + D3D12_RESOURCE_STATE_RESOLVE_SOURCE = 0x2000, + D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE = 0x400000, + D3D12_RESOURCE_STATE_SHADING_RATE_SOURCE = 0x1000000, + D3D12_RESOURCE_STATE_RESERVED_INTERNAL_8000 = 0x8000, + D3D12_RESOURCE_STATE_RESERVED_INTERNAL_4000 = 0x4000, + D3D12_RESOURCE_STATE_RESERVED_INTERNAL_100000 = 0x100000, + D3D12_RESOURCE_STATE_RESERVED_INTERNAL_40000000 = 0x40000000, + D3D12_RESOURCE_STATE_RESERVED_INTERNAL_80000000 = 0x80000000, + D3D12_RESOURCE_STATE_GENERIC_READ = ( ( ( ( ( 0x1 | 0x2 ) | 0x40 ) | 0x80 ) | 0x200 ) | 0x800 ) , + D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE = ( 0x40 | 0x80 ) , + D3D12_RESOURCE_STATE_PRESENT = 0, + D3D12_RESOURCE_STATE_PREDICATION = 0x200, + D3D12_RESOURCE_STATE_VIDEO_DECODE_READ = 0x10000, + D3D12_RESOURCE_STATE_VIDEO_DECODE_WRITE = 0x20000, + D3D12_RESOURCE_STATE_VIDEO_PROCESS_READ = 0x40000, + D3D12_RESOURCE_STATE_VIDEO_PROCESS_WRITE = 0x80000, + D3D12_RESOURCE_STATE_VIDEO_ENCODE_READ = 0x200000, + D3D12_RESOURCE_STATE_VIDEO_ENCODE_WRITE = 0x800000 + } D3D12_RESOURCE_STATES; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_STATES ) +typedef +enum D3D12_RESOURCE_BARRIER_TYPE + { + D3D12_RESOURCE_BARRIER_TYPE_TRANSITION = 0, + D3D12_RESOURCE_BARRIER_TYPE_ALIASING = ( D3D12_RESOURCE_BARRIER_TYPE_TRANSITION + 1 ) , + D3D12_RESOURCE_BARRIER_TYPE_UAV = ( D3D12_RESOURCE_BARRIER_TYPE_ALIASING + 1 ) + } D3D12_RESOURCE_BARRIER_TYPE; + + +typedef struct D3D12_RESOURCE_TRANSITION_BARRIER + { + ID3D12Resource *pResource; + UINT Subresource; + D3D12_RESOURCE_STATES StateBefore; + D3D12_RESOURCE_STATES StateAfter; + } D3D12_RESOURCE_TRANSITION_BARRIER; + +typedef struct D3D12_RESOURCE_ALIASING_BARRIER + { + ID3D12Resource *pResourceBefore; + ID3D12Resource *pResourceAfter; + } D3D12_RESOURCE_ALIASING_BARRIER; + +typedef struct D3D12_RESOURCE_UAV_BARRIER + { + ID3D12Resource *pResource; + } D3D12_RESOURCE_UAV_BARRIER; + +typedef +enum D3D12_RESOURCE_BARRIER_FLAGS + { + D3D12_RESOURCE_BARRIER_FLAG_NONE = 0, + D3D12_RESOURCE_BARRIER_FLAG_BEGIN_ONLY = 0x1, + D3D12_RESOURCE_BARRIER_FLAG_END_ONLY = 0x2 + } D3D12_RESOURCE_BARRIER_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESOURCE_BARRIER_FLAGS ) +typedef struct D3D12_RESOURCE_BARRIER + { + D3D12_RESOURCE_BARRIER_TYPE Type; + D3D12_RESOURCE_BARRIER_FLAGS Flags; + union + { + D3D12_RESOURCE_TRANSITION_BARRIER Transition; + D3D12_RESOURCE_ALIASING_BARRIER Aliasing; + D3D12_RESOURCE_UAV_BARRIER UAV; + } ; + } D3D12_RESOURCE_BARRIER; + +typedef struct D3D12_SUBRESOURCE_FOOTPRINT + { + DXGI_FORMAT Format; + UINT Width; + UINT Height; + UINT Depth; + UINT RowPitch; + } D3D12_SUBRESOURCE_FOOTPRINT; + +typedef struct D3D12_PLACED_SUBRESOURCE_FOOTPRINT + { + UINT64 Offset; + D3D12_SUBRESOURCE_FOOTPRINT Footprint; + } D3D12_PLACED_SUBRESOURCE_FOOTPRINT; + +typedef +enum D3D12_TEXTURE_COPY_TYPE + { + D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX = 0, + D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT = 1 + } D3D12_TEXTURE_COPY_TYPE; + +typedef struct D3D12_TEXTURE_COPY_LOCATION + { + ID3D12Resource *pResource; + D3D12_TEXTURE_COPY_TYPE Type; + union + { + D3D12_PLACED_SUBRESOURCE_FOOTPRINT PlacedFootprint; + UINT SubresourceIndex; + } ; + } D3D12_TEXTURE_COPY_LOCATION; + +typedef +enum D3D12_RESOLVE_MODE + { + D3D12_RESOLVE_MODE_DECOMPRESS = 0, + D3D12_RESOLVE_MODE_MIN = 1, + D3D12_RESOLVE_MODE_MAX = 2, + D3D12_RESOLVE_MODE_AVERAGE = 3, + D3D12_RESOLVE_MODE_ENCODE_SAMPLER_FEEDBACK = 4, + D3D12_RESOLVE_MODE_DECODE_SAMPLER_FEEDBACK = 5 + } D3D12_RESOLVE_MODE; + +typedef struct D3D12_SAMPLE_POSITION + { + INT8 X; + INT8 Y; + } D3D12_SAMPLE_POSITION; + +typedef struct D3D12_VIEW_INSTANCE_LOCATION + { + UINT ViewportArrayIndex; + UINT RenderTargetArrayIndex; + } D3D12_VIEW_INSTANCE_LOCATION; + +typedef +enum D3D12_VIEW_INSTANCING_FLAGS + { + D3D12_VIEW_INSTANCING_FLAG_NONE = 0, + D3D12_VIEW_INSTANCING_FLAG_ENABLE_VIEW_INSTANCE_MASKING = 0x1 + } D3D12_VIEW_INSTANCING_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_VIEW_INSTANCING_FLAGS ) +typedef struct D3D12_VIEW_INSTANCING_DESC + { + UINT ViewInstanceCount; + _Field_size_full_(ViewInstanceCount) const D3D12_VIEW_INSTANCE_LOCATION *pViewInstanceLocations; + D3D12_VIEW_INSTANCING_FLAGS Flags; + } D3D12_VIEW_INSTANCING_DESC; + +typedef +enum D3D12_SHADER_COMPONENT_MAPPING + { + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0 = 0, + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1 = 1, + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2 = 2, + D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3 = 3, + D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0 = 4, + D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 = 5 + } D3D12_SHADER_COMPONENT_MAPPING; + +#define D3D12_SHADER_COMPONENT_MAPPING_MASK 0x7 +#define D3D12_SHADER_COMPONENT_MAPPING_SHIFT 3 +#define D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES (1<<(D3D12_SHADER_COMPONENT_MAPPING_SHIFT*4)) +#define D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(Src0,Src1,Src2,Src3) ((((Src0)&D3D12_SHADER_COMPONENT_MAPPING_MASK)| \ + (((Src1)&D3D12_SHADER_COMPONENT_MAPPING_MASK)<> (D3D12_SHADER_COMPONENT_MAPPING_SHIFT*ComponentToExtract) & D3D12_SHADER_COMPONENT_MAPPING_MASK)) +#define D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(0,1,2,3) +typedef +enum D3D12_BUFFER_SRV_FLAGS + { + D3D12_BUFFER_SRV_FLAG_NONE = 0, + D3D12_BUFFER_SRV_FLAG_RAW = 0x1 + } D3D12_BUFFER_SRV_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_SRV_FLAGS ) +typedef struct D3D12_BUFFER_SRV + { + UINT64 FirstElement; + UINT NumElements; + UINT StructureByteStride; + D3D12_BUFFER_SRV_FLAGS Flags; + } D3D12_BUFFER_SRV; + +typedef struct D3D12_TEX1D_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + FLOAT ResourceMinLODClamp; + } D3D12_TEX1D_SRV; + +typedef struct D3D12_TEX1D_ARRAY_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; + FLOAT ResourceMinLODClamp; + } D3D12_TEX1D_ARRAY_SRV; + +typedef struct D3D12_TEX2D_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + UINT PlaneSlice; + FLOAT ResourceMinLODClamp; + } D3D12_TEX2D_SRV; + +typedef struct D3D12_TEX2D_ARRAY_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + UINT FirstArraySlice; + UINT ArraySize; + UINT PlaneSlice; + FLOAT ResourceMinLODClamp; + } D3D12_TEX2D_ARRAY_SRV; + +typedef struct D3D12_TEX3D_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + FLOAT ResourceMinLODClamp; + } D3D12_TEX3D_SRV; + +typedef struct D3D12_TEXCUBE_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + FLOAT ResourceMinLODClamp; + } D3D12_TEXCUBE_SRV; + +typedef struct D3D12_TEXCUBE_ARRAY_SRV + { + UINT MostDetailedMip; + UINT MipLevels; + UINT First2DArrayFace; + UINT NumCubes; + FLOAT ResourceMinLODClamp; + } D3D12_TEXCUBE_ARRAY_SRV; + +typedef struct D3D12_TEX2DMS_SRV + { + UINT UnusedField_NothingToDefine; + } D3D12_TEX2DMS_SRV; + +typedef struct D3D12_TEX2DMS_ARRAY_SRV + { + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX2DMS_ARRAY_SRV; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_SRV + { + D3D12_GPU_VIRTUAL_ADDRESS Location; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_SRV; + +typedef +enum D3D12_SRV_DIMENSION + { + D3D12_SRV_DIMENSION_UNKNOWN = 0, + D3D12_SRV_DIMENSION_BUFFER = 1, + D3D12_SRV_DIMENSION_TEXTURE1D = 2, + D3D12_SRV_DIMENSION_TEXTURE1DARRAY = 3, + D3D12_SRV_DIMENSION_TEXTURE2D = 4, + D3D12_SRV_DIMENSION_TEXTURE2DARRAY = 5, + D3D12_SRV_DIMENSION_TEXTURE2DMS = 6, + D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D12_SRV_DIMENSION_TEXTURE3D = 8, + D3D12_SRV_DIMENSION_TEXTURECUBE = 9, + D3D12_SRV_DIMENSION_TEXTURECUBEARRAY = 10, + D3D12_SRV_DIMENSION_RAYTRACING_ACCELERATION_STRUCTURE = 11 + } D3D12_SRV_DIMENSION; + +typedef struct D3D12_SHADER_RESOURCE_VIEW_DESC + { + DXGI_FORMAT Format; + D3D12_SRV_DIMENSION ViewDimension; + UINT Shader4ComponentMapping; + union + { + D3D12_BUFFER_SRV Buffer; + D3D12_TEX1D_SRV Texture1D; + D3D12_TEX1D_ARRAY_SRV Texture1DArray; + D3D12_TEX2D_SRV Texture2D; + D3D12_TEX2D_ARRAY_SRV Texture2DArray; + D3D12_TEX2DMS_SRV Texture2DMS; + D3D12_TEX2DMS_ARRAY_SRV Texture2DMSArray; + D3D12_TEX3D_SRV Texture3D; + D3D12_TEXCUBE_SRV TextureCube; + D3D12_TEXCUBE_ARRAY_SRV TextureCubeArray; + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_SRV RaytracingAccelerationStructure; + } ; + } D3D12_SHADER_RESOURCE_VIEW_DESC; + +typedef struct D3D12_CONSTANT_BUFFER_VIEW_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS BufferLocation; + UINT SizeInBytes; + } D3D12_CONSTANT_BUFFER_VIEW_DESC; + +typedef +enum D3D12_FILTER + { + D3D12_FILTER_MIN_MAG_MIP_POINT = 0, + D3D12_FILTER_MIN_MAG_POINT_MIP_LINEAR = 0x1, + D3D12_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x4, + D3D12_FILTER_MIN_POINT_MAG_MIP_LINEAR = 0x5, + D3D12_FILTER_MIN_LINEAR_MAG_MIP_POINT = 0x10, + D3D12_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x11, + D3D12_FILTER_MIN_MAG_LINEAR_MIP_POINT = 0x14, + D3D12_FILTER_MIN_MAG_MIP_LINEAR = 0x15, + D3D12_FILTER_MIN_MAG_ANISOTROPIC_MIP_POINT = 0x54, + D3D12_FILTER_ANISOTROPIC = 0x55, + D3D12_FILTER_COMPARISON_MIN_MAG_MIP_POINT = 0x80, + D3D12_FILTER_COMPARISON_MIN_MAG_POINT_MIP_LINEAR = 0x81, + D3D12_FILTER_COMPARISON_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x84, + D3D12_FILTER_COMPARISON_MIN_POINT_MAG_MIP_LINEAR = 0x85, + D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_MIP_POINT = 0x90, + D3D12_FILTER_COMPARISON_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x91, + D3D12_FILTER_COMPARISON_MIN_MAG_LINEAR_MIP_POINT = 0x94, + D3D12_FILTER_COMPARISON_MIN_MAG_MIP_LINEAR = 0x95, + D3D12_FILTER_COMPARISON_MIN_MAG_ANISOTROPIC_MIP_POINT = 0xd4, + D3D12_FILTER_COMPARISON_ANISOTROPIC = 0xd5, + D3D12_FILTER_MINIMUM_MIN_MAG_MIP_POINT = 0x100, + D3D12_FILTER_MINIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x101, + D3D12_FILTER_MINIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x104, + D3D12_FILTER_MINIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x105, + D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x110, + D3D12_FILTER_MINIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x111, + D3D12_FILTER_MINIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x114, + D3D12_FILTER_MINIMUM_MIN_MAG_MIP_LINEAR = 0x115, + D3D12_FILTER_MINIMUM_MIN_MAG_ANISOTROPIC_MIP_POINT = 0x154, + D3D12_FILTER_MINIMUM_ANISOTROPIC = 0x155, + D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_POINT = 0x180, + D3D12_FILTER_MAXIMUM_MIN_MAG_POINT_MIP_LINEAR = 0x181, + D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_LINEAR_MIP_POINT = 0x184, + D3D12_FILTER_MAXIMUM_MIN_POINT_MAG_MIP_LINEAR = 0x185, + D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_MIP_POINT = 0x190, + D3D12_FILTER_MAXIMUM_MIN_LINEAR_MAG_POINT_MIP_LINEAR = 0x191, + D3D12_FILTER_MAXIMUM_MIN_MAG_LINEAR_MIP_POINT = 0x194, + D3D12_FILTER_MAXIMUM_MIN_MAG_MIP_LINEAR = 0x195, + D3D12_FILTER_MAXIMUM_MIN_MAG_ANISOTROPIC_MIP_POINT = 0x1d4, + D3D12_FILTER_MAXIMUM_ANISOTROPIC = 0x1d5 + } D3D12_FILTER; + +typedef +enum D3D12_FILTER_TYPE + { + D3D12_FILTER_TYPE_POINT = 0, + D3D12_FILTER_TYPE_LINEAR = 1 + } D3D12_FILTER_TYPE; + +typedef +enum D3D12_FILTER_REDUCTION_TYPE + { + D3D12_FILTER_REDUCTION_TYPE_STANDARD = 0, + D3D12_FILTER_REDUCTION_TYPE_COMPARISON = 1, + D3D12_FILTER_REDUCTION_TYPE_MINIMUM = 2, + D3D12_FILTER_REDUCTION_TYPE_MAXIMUM = 3 + } D3D12_FILTER_REDUCTION_TYPE; + +#define D3D12_FILTER_REDUCTION_TYPE_MASK ( 0x3 ) + +#define D3D12_FILTER_REDUCTION_TYPE_SHIFT ( 7 ) + +#define D3D12_FILTER_TYPE_MASK ( 0x3 ) + +#define D3D12_MIN_FILTER_SHIFT ( 4 ) + +#define D3D12_MAG_FILTER_SHIFT ( 2 ) + +#define D3D12_MIP_FILTER_SHIFT ( 0 ) + +#define D3D12_ANISOTROPIC_FILTERING_BIT ( 0x40 ) + +#define D3D12_ENCODE_BASIC_FILTER( min, mag, mip, reduction ) \ + ( ( D3D12_FILTER ) ( \ + ( ( ( min ) & D3D12_FILTER_TYPE_MASK ) << D3D12_MIN_FILTER_SHIFT ) | \ + ( ( ( mag ) & D3D12_FILTER_TYPE_MASK ) << D3D12_MAG_FILTER_SHIFT ) | \ + ( ( ( mip ) & D3D12_FILTER_TYPE_MASK ) << D3D12_MIP_FILTER_SHIFT ) | \ + ( ( ( reduction ) & D3D12_FILTER_REDUCTION_TYPE_MASK ) << D3D12_FILTER_REDUCTION_TYPE_SHIFT ) ) ) +#define D3D12_ENCODE_ANISOTROPIC_FILTER( reduction ) \ + ( ( D3D12_FILTER ) ( \ + D3D12_ANISOTROPIC_FILTERING_BIT | \ + D3D12_ENCODE_BASIC_FILTER( D3D12_FILTER_TYPE_LINEAR, \ + D3D12_FILTER_TYPE_LINEAR, \ + D3D12_FILTER_TYPE_LINEAR, \ + reduction ) ) ) +#define D3D12_ENCODE_MIN_MAG_ANISOTROPIC_MIP_POINT_FILTER( reduction ) \ + ( ( D3D12_FILTER ) ( \ + D3D12_ANISOTROPIC_FILTERING_BIT | \ + D3D12_ENCODE_BASIC_FILTER( D3D12_FILTER_TYPE_LINEAR, \ + D3D12_FILTER_TYPE_LINEAR, \ + D3D12_FILTER_TYPE_POINT, \ + reduction ) ) ) +#define D3D12_DECODE_MIN_FILTER( D3D12Filter ) \ + ( ( D3D12_FILTER_TYPE ) \ + ( ( ( D3D12Filter ) >> D3D12_MIN_FILTER_SHIFT ) & D3D12_FILTER_TYPE_MASK ) ) +#define D3D12_DECODE_MAG_FILTER( D3D12Filter ) \ + ( ( D3D12_FILTER_TYPE ) \ + ( ( ( D3D12Filter ) >> D3D12_MAG_FILTER_SHIFT ) & D3D12_FILTER_TYPE_MASK ) ) +#define D3D12_DECODE_MIP_FILTER( D3D12Filter ) \ + ( ( D3D12_FILTER_TYPE ) \ + ( ( ( D3D12Filter ) >> D3D12_MIP_FILTER_SHIFT ) & D3D12_FILTER_TYPE_MASK ) ) +#define D3D12_DECODE_FILTER_REDUCTION( D3D12Filter ) \ + ( ( D3D12_FILTER_REDUCTION_TYPE ) \ + ( ( ( D3D12Filter ) >> D3D12_FILTER_REDUCTION_TYPE_SHIFT ) & D3D12_FILTER_REDUCTION_TYPE_MASK ) ) +#define D3D12_DECODE_IS_COMPARISON_FILTER( D3D12Filter ) \ + ( D3D12_DECODE_FILTER_REDUCTION( D3D12Filter ) == D3D12_FILTER_REDUCTION_TYPE_COMPARISON ) +#define D3D12_DECODE_IS_ANISOTROPIC_FILTER( D3D12Filter ) \ + ( ( ( D3D12Filter ) & D3D12_ANISOTROPIC_FILTERING_BIT ) && \ + ( D3D12_FILTER_TYPE_LINEAR == D3D12_DECODE_MIN_FILTER( D3D12Filter ) ) && \ + ( D3D12_FILTER_TYPE_LINEAR == D3D12_DECODE_MAG_FILTER( D3D12Filter ) ) ) +typedef +enum D3D12_TEXTURE_ADDRESS_MODE + { + D3D12_TEXTURE_ADDRESS_MODE_WRAP = 1, + D3D12_TEXTURE_ADDRESS_MODE_MIRROR = 2, + D3D12_TEXTURE_ADDRESS_MODE_CLAMP = 3, + D3D12_TEXTURE_ADDRESS_MODE_BORDER = 4, + D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE = 5 + } D3D12_TEXTURE_ADDRESS_MODE; + +typedef struct D3D12_SAMPLER_DESC + { + D3D12_FILTER Filter; + D3D12_TEXTURE_ADDRESS_MODE AddressU; + D3D12_TEXTURE_ADDRESS_MODE AddressV; + D3D12_TEXTURE_ADDRESS_MODE AddressW; + FLOAT MipLODBias; + UINT MaxAnisotropy; + D3D12_COMPARISON_FUNC ComparisonFunc; + FLOAT BorderColor[ 4 ]; + FLOAT MinLOD; + FLOAT MaxLOD; + } D3D12_SAMPLER_DESC; + +typedef +enum D3D12_SAMPLER_FLAGS + { + D3D12_SAMPLER_FLAG_NONE = 0, + D3D12_SAMPLER_FLAG_UINT_BORDER_COLOR = 0x1, + D3D12_SAMPLER_FLAG_NON_NORMALIZED_COORDINATES = 0x2 + } D3D12_SAMPLER_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SAMPLER_FLAGS ) +typedef struct D3D12_SAMPLER_DESC2 + { + D3D12_FILTER Filter; + D3D12_TEXTURE_ADDRESS_MODE AddressU; + D3D12_TEXTURE_ADDRESS_MODE AddressV; + D3D12_TEXTURE_ADDRESS_MODE AddressW; + FLOAT MipLODBias; + UINT MaxAnisotropy; + D3D12_COMPARISON_FUNC ComparisonFunc; + union + { + FLOAT FloatBorderColor[ 4 ]; + UINT UintBorderColor[ 4 ]; + } ; + FLOAT MinLOD; + FLOAT MaxLOD; + D3D12_SAMPLER_FLAGS Flags; + } D3D12_SAMPLER_DESC2; + +typedef +enum D3D12_BUFFER_UAV_FLAGS + { + D3D12_BUFFER_UAV_FLAG_NONE = 0, + D3D12_BUFFER_UAV_FLAG_RAW = 0x1 + } D3D12_BUFFER_UAV_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_BUFFER_UAV_FLAGS ) +typedef struct D3D12_BUFFER_UAV + { + UINT64 FirstElement; + UINT NumElements; + UINT StructureByteStride; + UINT64 CounterOffsetInBytes; + D3D12_BUFFER_UAV_FLAGS Flags; + } D3D12_BUFFER_UAV; + +typedef struct D3D12_TEX1D_UAV + { + UINT MipSlice; + } D3D12_TEX1D_UAV; + +typedef struct D3D12_TEX1D_ARRAY_UAV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX1D_ARRAY_UAV; + +typedef struct D3D12_TEX2D_UAV + { + UINT MipSlice; + UINT PlaneSlice; + } D3D12_TEX2D_UAV; + +typedef struct D3D12_TEX2D_ARRAY_UAV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + UINT PlaneSlice; + } D3D12_TEX2D_ARRAY_UAV; + +typedef struct D3D12_TEX2DMS_UAV + { + UINT UnusedField_NothingToDefine; + } D3D12_TEX2DMS_UAV; + +typedef struct D3D12_TEX2DMS_ARRAY_UAV + { + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX2DMS_ARRAY_UAV; + +typedef struct D3D12_TEX3D_UAV + { + UINT MipSlice; + UINT FirstWSlice; + UINT WSize; + } D3D12_TEX3D_UAV; + +typedef +enum D3D12_UAV_DIMENSION + { + D3D12_UAV_DIMENSION_UNKNOWN = 0, + D3D12_UAV_DIMENSION_BUFFER = 1, + D3D12_UAV_DIMENSION_TEXTURE1D = 2, + D3D12_UAV_DIMENSION_TEXTURE1DARRAY = 3, + D3D12_UAV_DIMENSION_TEXTURE2D = 4, + D3D12_UAV_DIMENSION_TEXTURE2DARRAY = 5, + D3D12_UAV_DIMENSION_TEXTURE2DMS = 6, + D3D12_UAV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D12_UAV_DIMENSION_TEXTURE3D = 8 + } D3D12_UAV_DIMENSION; + +typedef struct D3D12_UNORDERED_ACCESS_VIEW_DESC + { + DXGI_FORMAT Format; + D3D12_UAV_DIMENSION ViewDimension; + union + { + D3D12_BUFFER_UAV Buffer; + D3D12_TEX1D_UAV Texture1D; + D3D12_TEX1D_ARRAY_UAV Texture1DArray; + D3D12_TEX2D_UAV Texture2D; + D3D12_TEX2D_ARRAY_UAV Texture2DArray; + D3D12_TEX2DMS_UAV Texture2DMS; + D3D12_TEX2DMS_ARRAY_UAV Texture2DMSArray; + D3D12_TEX3D_UAV Texture3D; + } ; + } D3D12_UNORDERED_ACCESS_VIEW_DESC; + +typedef struct D3D12_BUFFER_RTV + { + UINT64 FirstElement; + UINT NumElements; + } D3D12_BUFFER_RTV; + +typedef struct D3D12_TEX1D_RTV + { + UINT MipSlice; + } D3D12_TEX1D_RTV; + +typedef struct D3D12_TEX1D_ARRAY_RTV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX1D_ARRAY_RTV; + +typedef struct D3D12_TEX2D_RTV + { + UINT MipSlice; + UINT PlaneSlice; + } D3D12_TEX2D_RTV; + +typedef struct D3D12_TEX2DMS_RTV + { + UINT UnusedField_NothingToDefine; + } D3D12_TEX2DMS_RTV; + +typedef struct D3D12_TEX2D_ARRAY_RTV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + UINT PlaneSlice; + } D3D12_TEX2D_ARRAY_RTV; + +typedef struct D3D12_TEX2DMS_ARRAY_RTV + { + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX2DMS_ARRAY_RTV; + +typedef struct D3D12_TEX3D_RTV + { + UINT MipSlice; + UINT FirstWSlice; + UINT WSize; + } D3D12_TEX3D_RTV; + +typedef +enum D3D12_RTV_DIMENSION + { + D3D12_RTV_DIMENSION_UNKNOWN = 0, + D3D12_RTV_DIMENSION_BUFFER = 1, + D3D12_RTV_DIMENSION_TEXTURE1D = 2, + D3D12_RTV_DIMENSION_TEXTURE1DARRAY = 3, + D3D12_RTV_DIMENSION_TEXTURE2D = 4, + D3D12_RTV_DIMENSION_TEXTURE2DARRAY = 5, + D3D12_RTV_DIMENSION_TEXTURE2DMS = 6, + D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY = 7, + D3D12_RTV_DIMENSION_TEXTURE3D = 8 + } D3D12_RTV_DIMENSION; + +typedef struct D3D12_RENDER_TARGET_VIEW_DESC + { + DXGI_FORMAT Format; + D3D12_RTV_DIMENSION ViewDimension; + union + { + D3D12_BUFFER_RTV Buffer; + D3D12_TEX1D_RTV Texture1D; + D3D12_TEX1D_ARRAY_RTV Texture1DArray; + D3D12_TEX2D_RTV Texture2D; + D3D12_TEX2D_ARRAY_RTV Texture2DArray; + D3D12_TEX2DMS_RTV Texture2DMS; + D3D12_TEX2DMS_ARRAY_RTV Texture2DMSArray; + D3D12_TEX3D_RTV Texture3D; + } ; + } D3D12_RENDER_TARGET_VIEW_DESC; + +typedef struct D3D12_TEX1D_DSV + { + UINT MipSlice; + } D3D12_TEX1D_DSV; + +typedef struct D3D12_TEX1D_ARRAY_DSV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX1D_ARRAY_DSV; + +typedef struct D3D12_TEX2D_DSV + { + UINT MipSlice; + } D3D12_TEX2D_DSV; + +typedef struct D3D12_TEX2D_ARRAY_DSV + { + UINT MipSlice; + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX2D_ARRAY_DSV; + +typedef struct D3D12_TEX2DMS_DSV + { + UINT UnusedField_NothingToDefine; + } D3D12_TEX2DMS_DSV; + +typedef struct D3D12_TEX2DMS_ARRAY_DSV + { + UINT FirstArraySlice; + UINT ArraySize; + } D3D12_TEX2DMS_ARRAY_DSV; + +typedef +enum D3D12_DSV_FLAGS + { + D3D12_DSV_FLAG_NONE = 0, + D3D12_DSV_FLAG_READ_ONLY_DEPTH = 0x1, + D3D12_DSV_FLAG_READ_ONLY_STENCIL = 0x2 + } D3D12_DSV_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DSV_FLAGS ) +typedef +enum D3D12_DSV_DIMENSION + { + D3D12_DSV_DIMENSION_UNKNOWN = 0, + D3D12_DSV_DIMENSION_TEXTURE1D = 1, + D3D12_DSV_DIMENSION_TEXTURE1DARRAY = 2, + D3D12_DSV_DIMENSION_TEXTURE2D = 3, + D3D12_DSV_DIMENSION_TEXTURE2DARRAY = 4, + D3D12_DSV_DIMENSION_TEXTURE2DMS = 5, + D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY = 6 + } D3D12_DSV_DIMENSION; + +typedef struct D3D12_DEPTH_STENCIL_VIEW_DESC + { + DXGI_FORMAT Format; + D3D12_DSV_DIMENSION ViewDimension; + D3D12_DSV_FLAGS Flags; + union + { + D3D12_TEX1D_DSV Texture1D; + D3D12_TEX1D_ARRAY_DSV Texture1DArray; + D3D12_TEX2D_DSV Texture2D; + D3D12_TEX2D_ARRAY_DSV Texture2DArray; + D3D12_TEX2DMS_DSV Texture2DMS; + D3D12_TEX2DMS_ARRAY_DSV Texture2DMSArray; + } ; + } D3D12_DEPTH_STENCIL_VIEW_DESC; + +typedef +enum D3D12_CLEAR_FLAGS + { + D3D12_CLEAR_FLAG_DEPTH = 0x1, + D3D12_CLEAR_FLAG_STENCIL = 0x2 + } D3D12_CLEAR_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_CLEAR_FLAGS ) +typedef +enum D3D12_FENCE_FLAGS + { + D3D12_FENCE_FLAG_NONE = 0, + D3D12_FENCE_FLAG_SHARED = 0x1, + D3D12_FENCE_FLAG_SHARED_CROSS_ADAPTER = 0x2, + D3D12_FENCE_FLAG_NON_MONITORED = 0x4 + } D3D12_FENCE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_FENCE_FLAGS ) +typedef +enum D3D12_DESCRIPTOR_HEAP_TYPE + { + D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV = 0, + D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER = ( D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV + 1 ) , + D3D12_DESCRIPTOR_HEAP_TYPE_RTV = ( D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER + 1 ) , + D3D12_DESCRIPTOR_HEAP_TYPE_DSV = ( D3D12_DESCRIPTOR_HEAP_TYPE_RTV + 1 ) , + D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES = ( D3D12_DESCRIPTOR_HEAP_TYPE_DSV + 1 ) + } D3D12_DESCRIPTOR_HEAP_TYPE; + +typedef +enum D3D12_DESCRIPTOR_HEAP_FLAGS + { + D3D12_DESCRIPTOR_HEAP_FLAG_NONE = 0, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE = 0x1 + } D3D12_DESCRIPTOR_HEAP_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DESCRIPTOR_HEAP_FLAGS ) +typedef struct D3D12_DESCRIPTOR_HEAP_DESC + { + D3D12_DESCRIPTOR_HEAP_TYPE Type; + UINT NumDescriptors; + D3D12_DESCRIPTOR_HEAP_FLAGS Flags; + UINT NodeMask; + } D3D12_DESCRIPTOR_HEAP_DESC; + +typedef +enum D3D12_DESCRIPTOR_RANGE_TYPE + { + D3D12_DESCRIPTOR_RANGE_TYPE_SRV = 0, + D3D12_DESCRIPTOR_RANGE_TYPE_UAV = ( D3D12_DESCRIPTOR_RANGE_TYPE_SRV + 1 ) , + D3D12_DESCRIPTOR_RANGE_TYPE_CBV = ( D3D12_DESCRIPTOR_RANGE_TYPE_UAV + 1 ) , + D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER = ( D3D12_DESCRIPTOR_RANGE_TYPE_CBV + 1 ) + } D3D12_DESCRIPTOR_RANGE_TYPE; + +typedef struct D3D12_DESCRIPTOR_RANGE + { + D3D12_DESCRIPTOR_RANGE_TYPE RangeType; + UINT NumDescriptors; + UINT BaseShaderRegister; + UINT RegisterSpace; + UINT OffsetInDescriptorsFromTableStart; + } D3D12_DESCRIPTOR_RANGE; + +typedef struct D3D12_ROOT_DESCRIPTOR_TABLE + { + UINT NumDescriptorRanges; + _Field_size_full_(NumDescriptorRanges) const D3D12_DESCRIPTOR_RANGE *pDescriptorRanges; + } D3D12_ROOT_DESCRIPTOR_TABLE; + +typedef struct D3D12_ROOT_CONSTANTS + { + UINT ShaderRegister; + UINT RegisterSpace; + UINT Num32BitValues; + } D3D12_ROOT_CONSTANTS; + +typedef struct D3D12_ROOT_DESCRIPTOR + { + UINT ShaderRegister; + UINT RegisterSpace; + } D3D12_ROOT_DESCRIPTOR; + +typedef +enum D3D12_SHADER_VISIBILITY + { + D3D12_SHADER_VISIBILITY_ALL = 0, + D3D12_SHADER_VISIBILITY_VERTEX = 1, + D3D12_SHADER_VISIBILITY_HULL = 2, + D3D12_SHADER_VISIBILITY_DOMAIN = 3, + D3D12_SHADER_VISIBILITY_GEOMETRY = 4, + D3D12_SHADER_VISIBILITY_PIXEL = 5, + D3D12_SHADER_VISIBILITY_AMPLIFICATION = 6, + D3D12_SHADER_VISIBILITY_MESH = 7 + } D3D12_SHADER_VISIBILITY; + +typedef +enum D3D12_ROOT_PARAMETER_TYPE + { + D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE = 0, + D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS = ( D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE + 1 ) , + D3D12_ROOT_PARAMETER_TYPE_CBV = ( D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS + 1 ) , + D3D12_ROOT_PARAMETER_TYPE_SRV = ( D3D12_ROOT_PARAMETER_TYPE_CBV + 1 ) , + D3D12_ROOT_PARAMETER_TYPE_UAV = ( D3D12_ROOT_PARAMETER_TYPE_SRV + 1 ) + } D3D12_ROOT_PARAMETER_TYPE; + +typedef struct D3D12_ROOT_PARAMETER + { + D3D12_ROOT_PARAMETER_TYPE ParameterType; + union + { + D3D12_ROOT_DESCRIPTOR_TABLE DescriptorTable; + D3D12_ROOT_CONSTANTS Constants; + D3D12_ROOT_DESCRIPTOR Descriptor; + } ; + D3D12_SHADER_VISIBILITY ShaderVisibility; + } D3D12_ROOT_PARAMETER; + +typedef +enum D3D12_ROOT_SIGNATURE_FLAGS + { + D3D12_ROOT_SIGNATURE_FLAG_NONE = 0, + D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT = 0x1, + D3D12_ROOT_SIGNATURE_FLAG_DENY_VERTEX_SHADER_ROOT_ACCESS = 0x2, + D3D12_ROOT_SIGNATURE_FLAG_DENY_HULL_SHADER_ROOT_ACCESS = 0x4, + D3D12_ROOT_SIGNATURE_FLAG_DENY_DOMAIN_SHADER_ROOT_ACCESS = 0x8, + D3D12_ROOT_SIGNATURE_FLAG_DENY_GEOMETRY_SHADER_ROOT_ACCESS = 0x10, + D3D12_ROOT_SIGNATURE_FLAG_DENY_PIXEL_SHADER_ROOT_ACCESS = 0x20, + D3D12_ROOT_SIGNATURE_FLAG_ALLOW_STREAM_OUTPUT = 0x40, + D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE = 0x80, + D3D12_ROOT_SIGNATURE_FLAG_DENY_AMPLIFICATION_SHADER_ROOT_ACCESS = 0x100, + D3D12_ROOT_SIGNATURE_FLAG_DENY_MESH_SHADER_ROOT_ACCESS = 0x200, + D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED = 0x400, + D3D12_ROOT_SIGNATURE_FLAG_SAMPLER_HEAP_DIRECTLY_INDEXED = 0x800 + } D3D12_ROOT_SIGNATURE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_ROOT_SIGNATURE_FLAGS ) +typedef +enum D3D12_STATIC_BORDER_COLOR + { + D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK = 0, + D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK = ( D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK + 1 ) , + D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE = ( D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK + 1 ) , + D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK_UINT = ( D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE + 1 ) , + D3D12_STATIC_BORDER_COLOR_OPAQUE_WHITE_UINT = ( D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK_UINT + 1 ) + } D3D12_STATIC_BORDER_COLOR; + +typedef struct D3D12_STATIC_SAMPLER_DESC + { + D3D12_FILTER Filter; + D3D12_TEXTURE_ADDRESS_MODE AddressU; + D3D12_TEXTURE_ADDRESS_MODE AddressV; + D3D12_TEXTURE_ADDRESS_MODE AddressW; + FLOAT MipLODBias; + UINT MaxAnisotropy; + D3D12_COMPARISON_FUNC ComparisonFunc; + D3D12_STATIC_BORDER_COLOR BorderColor; + FLOAT MinLOD; + FLOAT MaxLOD; + UINT ShaderRegister; + UINT RegisterSpace; + D3D12_SHADER_VISIBILITY ShaderVisibility; + } D3D12_STATIC_SAMPLER_DESC; + +typedef struct D3D12_STATIC_SAMPLER_DESC1 + { + D3D12_FILTER Filter; + D3D12_TEXTURE_ADDRESS_MODE AddressU; + D3D12_TEXTURE_ADDRESS_MODE AddressV; + D3D12_TEXTURE_ADDRESS_MODE AddressW; + FLOAT MipLODBias; + UINT MaxAnisotropy; + D3D12_COMPARISON_FUNC ComparisonFunc; + D3D12_STATIC_BORDER_COLOR BorderColor; + FLOAT MinLOD; + FLOAT MaxLOD; + UINT ShaderRegister; + UINT RegisterSpace; + D3D12_SHADER_VISIBILITY ShaderVisibility; + D3D12_SAMPLER_FLAGS Flags; + } D3D12_STATIC_SAMPLER_DESC1; + +typedef struct D3D12_ROOT_SIGNATURE_DESC + { + UINT NumParameters; + _Field_size_full_(NumParameters) const D3D12_ROOT_PARAMETER *pParameters; + UINT NumStaticSamplers; + _Field_size_full_(NumStaticSamplers) const D3D12_STATIC_SAMPLER_DESC *pStaticSamplers; + D3D12_ROOT_SIGNATURE_FLAGS Flags; + } D3D12_ROOT_SIGNATURE_DESC; + +typedef +enum D3D12_DESCRIPTOR_RANGE_FLAGS + { + D3D12_DESCRIPTOR_RANGE_FLAG_NONE = 0, + D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE = 0x1, + D3D12_DESCRIPTOR_RANGE_FLAG_DATA_VOLATILE = 0x2, + D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4, + D3D12_DESCRIPTOR_RANGE_FLAG_DATA_STATIC = 0x8, + D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS = 0x10000 + } D3D12_DESCRIPTOR_RANGE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DESCRIPTOR_RANGE_FLAGS ) +typedef struct D3D12_DESCRIPTOR_RANGE1 + { + D3D12_DESCRIPTOR_RANGE_TYPE RangeType; + UINT NumDescriptors; + UINT BaseShaderRegister; + UINT RegisterSpace; + D3D12_DESCRIPTOR_RANGE_FLAGS Flags; + UINT OffsetInDescriptorsFromTableStart; + } D3D12_DESCRIPTOR_RANGE1; + +typedef struct D3D12_ROOT_DESCRIPTOR_TABLE1 + { + UINT NumDescriptorRanges; + _Field_size_full_(NumDescriptorRanges) const D3D12_DESCRIPTOR_RANGE1 *pDescriptorRanges; + } D3D12_ROOT_DESCRIPTOR_TABLE1; + +typedef +enum D3D12_ROOT_DESCRIPTOR_FLAGS + { + D3D12_ROOT_DESCRIPTOR_FLAG_NONE = 0, + D3D12_ROOT_DESCRIPTOR_FLAG_DATA_VOLATILE = 0x2, + D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC_WHILE_SET_AT_EXECUTE = 0x4, + D3D12_ROOT_DESCRIPTOR_FLAG_DATA_STATIC = 0x8 + } D3D12_ROOT_DESCRIPTOR_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_ROOT_DESCRIPTOR_FLAGS ) +typedef struct D3D12_ROOT_DESCRIPTOR1 + { + UINT ShaderRegister; + UINT RegisterSpace; + D3D12_ROOT_DESCRIPTOR_FLAGS Flags; + } D3D12_ROOT_DESCRIPTOR1; + +typedef struct D3D12_ROOT_PARAMETER1 + { + D3D12_ROOT_PARAMETER_TYPE ParameterType; + union + { + D3D12_ROOT_DESCRIPTOR_TABLE1 DescriptorTable; + D3D12_ROOT_CONSTANTS Constants; + D3D12_ROOT_DESCRIPTOR1 Descriptor; + } ; + D3D12_SHADER_VISIBILITY ShaderVisibility; + } D3D12_ROOT_PARAMETER1; + +typedef struct D3D12_ROOT_SIGNATURE_DESC1 + { + UINT NumParameters; + _Field_size_full_(NumParameters) const D3D12_ROOT_PARAMETER1 *pParameters; + UINT NumStaticSamplers; + _Field_size_full_(NumStaticSamplers) const D3D12_STATIC_SAMPLER_DESC *pStaticSamplers; + D3D12_ROOT_SIGNATURE_FLAGS Flags; + } D3D12_ROOT_SIGNATURE_DESC1; + +typedef struct D3D12_ROOT_SIGNATURE_DESC2 + { + UINT NumParameters; + _Field_size_full_(NumParameters) const D3D12_ROOT_PARAMETER1 *pParameters; + UINT NumStaticSamplers; + _Field_size_full_(NumStaticSamplers) const D3D12_STATIC_SAMPLER_DESC1 *pStaticSamplers; + D3D12_ROOT_SIGNATURE_FLAGS Flags; + } D3D12_ROOT_SIGNATURE_DESC2; + +typedef struct D3D12_VERSIONED_ROOT_SIGNATURE_DESC + { + D3D_ROOT_SIGNATURE_VERSION Version; + union + { + D3D12_ROOT_SIGNATURE_DESC Desc_1_0; + D3D12_ROOT_SIGNATURE_DESC1 Desc_1_1; + D3D12_ROOT_SIGNATURE_DESC2 Desc_1_2; + } ; + } D3D12_VERSIONED_ROOT_SIGNATURE_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0001_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0001_v0_0_s_ifspec; + +#ifndef __ID3D12RootSignatureDeserializer_INTERFACE_DEFINED__ +#define __ID3D12RootSignatureDeserializer_INTERFACE_DEFINED__ + +/* interface ID3D12RootSignatureDeserializer */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12RootSignatureDeserializer; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("34AB647B-3CC8-46AC-841B-C0965645C046") + ID3D12RootSignatureDeserializer : public IUnknown + { + public: + virtual const D3D12_ROOT_SIGNATURE_DESC *STDMETHODCALLTYPE GetRootSignatureDesc( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12RootSignatureDeserializerVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12RootSignatureDeserializer * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12RootSignatureDeserializer * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12RootSignatureDeserializer * This); + + DECLSPEC_XFGVIRT(ID3D12RootSignatureDeserializer, GetRootSignatureDesc) + const D3D12_ROOT_SIGNATURE_DESC *( STDMETHODCALLTYPE *GetRootSignatureDesc )( + ID3D12RootSignatureDeserializer * This); + + END_INTERFACE + } ID3D12RootSignatureDeserializerVtbl; + + interface ID3D12RootSignatureDeserializer + { + CONST_VTBL struct ID3D12RootSignatureDeserializerVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12RootSignatureDeserializer_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12RootSignatureDeserializer_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12RootSignatureDeserializer_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12RootSignatureDeserializer_GetRootSignatureDesc(This) \ + ( (This)->lpVtbl -> GetRootSignatureDesc(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12RootSignatureDeserializer_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12VersionedRootSignatureDeserializer_INTERFACE_DEFINED__ +#define __ID3D12VersionedRootSignatureDeserializer_INTERFACE_DEFINED__ + +/* interface ID3D12VersionedRootSignatureDeserializer */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12VersionedRootSignatureDeserializer; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("7F91CE67-090C-4BB7-B78E-ED8FF2E31DA0") + ID3D12VersionedRootSignatureDeserializer : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetRootSignatureDescAtVersion( + D3D_ROOT_SIGNATURE_VERSION convertToVersion, + _Out_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC **ppDesc) = 0; + + virtual const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *STDMETHODCALLTYPE GetUnconvertedRootSignatureDesc( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12VersionedRootSignatureDeserializerVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12VersionedRootSignatureDeserializer * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12VersionedRootSignatureDeserializer * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12VersionedRootSignatureDeserializer * This); + + DECLSPEC_XFGVIRT(ID3D12VersionedRootSignatureDeserializer, GetRootSignatureDescAtVersion) + HRESULT ( STDMETHODCALLTYPE *GetRootSignatureDescAtVersion )( + ID3D12VersionedRootSignatureDeserializer * This, + D3D_ROOT_SIGNATURE_VERSION convertToVersion, + _Out_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC **ppDesc); + + DECLSPEC_XFGVIRT(ID3D12VersionedRootSignatureDeserializer, GetUnconvertedRootSignatureDesc) + const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *( STDMETHODCALLTYPE *GetUnconvertedRootSignatureDesc )( + ID3D12VersionedRootSignatureDeserializer * This); + + END_INTERFACE + } ID3D12VersionedRootSignatureDeserializerVtbl; + + interface ID3D12VersionedRootSignatureDeserializer + { + CONST_VTBL struct ID3D12VersionedRootSignatureDeserializerVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12VersionedRootSignatureDeserializer_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12VersionedRootSignatureDeserializer_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12VersionedRootSignatureDeserializer_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12VersionedRootSignatureDeserializer_GetRootSignatureDescAtVersion(This,convertToVersion,ppDesc) \ + ( (This)->lpVtbl -> GetRootSignatureDescAtVersion(This,convertToVersion,ppDesc) ) + +#define ID3D12VersionedRootSignatureDeserializer_GetUnconvertedRootSignatureDesc(This) \ + ( (This)->lpVtbl -> GetUnconvertedRootSignatureDesc(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12VersionedRootSignatureDeserializer_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0003 */ +/* [local] */ + +typedef HRESULT (WINAPI* PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)( + _In_ const D3D12_ROOT_SIGNATURE_DESC* pRootSignature, + _In_ D3D_ROOT_SIGNATURE_VERSION Version, + _Out_ ID3DBlob** ppBlob, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob); + +HRESULT WINAPI D3D12SerializeRootSignature( + _In_ const D3D12_ROOT_SIGNATURE_DESC* pRootSignature, + _In_ D3D_ROOT_SIGNATURE_VERSION Version, + _Out_ ID3DBlob** ppBlob, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob); + +typedef HRESULT (WINAPI* PFN_D3D12_CREATE_ROOT_SIGNATURE_DESERIALIZER)( + _In_reads_bytes_(SrcDataSizeInBytes) LPCVOID pSrcData, + _In_ SIZE_T SrcDataSizeInBytes, + _In_ REFIID pRootSignatureDeserializerInterface, + _Out_ void** ppRootSignatureDeserializer); + +HRESULT WINAPI D3D12CreateRootSignatureDeserializer( + _In_reads_bytes_(SrcDataSizeInBytes) LPCVOID pSrcData, + _In_ SIZE_T SrcDataSizeInBytes, + _In_ REFIID pRootSignatureDeserializerInterface, + _Out_ void** ppRootSignatureDeserializer); + +typedef HRESULT (WINAPI* PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)( + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* pRootSignature, + _Out_ ID3DBlob** ppBlob, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob); + +HRESULT WINAPI D3D12SerializeVersionedRootSignature( + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC* pRootSignature, + _Out_ ID3DBlob** ppBlob, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob** ppErrorBlob); + +typedef HRESULT (WINAPI* PFN_D3D12_CREATE_VERSIONED_ROOT_SIGNATURE_DESERIALIZER)( + _In_reads_bytes_(SrcDataSizeInBytes) LPCVOID pSrcData, + _In_ SIZE_T SrcDataSizeInBytes, + _In_ REFIID pRootSignatureDeserializerInterface, + _Out_ void** ppRootSignatureDeserializer); + +HRESULT WINAPI D3D12CreateVersionedRootSignatureDeserializer( + _In_reads_bytes_(SrcDataSizeInBytes) LPCVOID pSrcData, + _In_ SIZE_T SrcDataSizeInBytes, + _In_ REFIID pRootSignatureDeserializerInterface, + _Out_ void** ppRootSignatureDeserializer); + +typedef struct D3D12_CPU_DESCRIPTOR_HANDLE + { + SIZE_T ptr; + } D3D12_CPU_DESCRIPTOR_HANDLE; + +typedef struct D3D12_GPU_DESCRIPTOR_HANDLE + { + UINT64 ptr; + } D3D12_GPU_DESCRIPTOR_HANDLE; + +// If rects are supplied in D3D12_DISCARD_REGION, below, the resource +// must have 2D subresources with all specified subresources the same dimension. +typedef struct D3D12_DISCARD_REGION + { + UINT NumRects; + _In_reads_(NumRects) const D3D12_RECT *pRects; + UINT FirstSubresource; + UINT NumSubresources; + } D3D12_DISCARD_REGION; + +typedef +enum D3D12_QUERY_HEAP_TYPE + { + D3D12_QUERY_HEAP_TYPE_OCCLUSION = 0, + D3D12_QUERY_HEAP_TYPE_TIMESTAMP = 1, + D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS = 2, + D3D12_QUERY_HEAP_TYPE_SO_STATISTICS = 3, + D3D12_QUERY_HEAP_TYPE_VIDEO_DECODE_STATISTICS = 4, + D3D12_QUERY_HEAP_TYPE_COPY_QUEUE_TIMESTAMP = 5, + D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS1 = 7 + } D3D12_QUERY_HEAP_TYPE; + +typedef struct D3D12_QUERY_HEAP_DESC + { + D3D12_QUERY_HEAP_TYPE Type; + UINT Count; + UINT NodeMask; + } D3D12_QUERY_HEAP_DESC; + +typedef +enum D3D12_QUERY_TYPE + { + D3D12_QUERY_TYPE_OCCLUSION = 0, + D3D12_QUERY_TYPE_BINARY_OCCLUSION = 1, + D3D12_QUERY_TYPE_TIMESTAMP = 2, + D3D12_QUERY_TYPE_PIPELINE_STATISTICS = 3, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM0 = 4, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM1 = 5, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM2 = 6, + D3D12_QUERY_TYPE_SO_STATISTICS_STREAM3 = 7, + D3D12_QUERY_TYPE_VIDEO_DECODE_STATISTICS = 8, + D3D12_QUERY_TYPE_PIPELINE_STATISTICS1 = 10 + } D3D12_QUERY_TYPE; + +typedef +enum D3D12_PREDICATION_OP + { + D3D12_PREDICATION_OP_EQUAL_ZERO = 0, + D3D12_PREDICATION_OP_NOT_EQUAL_ZERO = 1 + } D3D12_PREDICATION_OP; + +typedef struct D3D12_QUERY_DATA_PIPELINE_STATISTICS + { + UINT64 IAVertices; + UINT64 IAPrimitives; + UINT64 VSInvocations; + UINT64 GSInvocations; + UINT64 GSPrimitives; + UINT64 CInvocations; + UINT64 CPrimitives; + UINT64 PSInvocations; + UINT64 HSInvocations; + UINT64 DSInvocations; + UINT64 CSInvocations; + } D3D12_QUERY_DATA_PIPELINE_STATISTICS; + +typedef struct D3D12_QUERY_DATA_PIPELINE_STATISTICS1 + { + UINT64 IAVertices; + UINT64 IAPrimitives; + UINT64 VSInvocations; + UINT64 GSInvocations; + UINT64 GSPrimitives; + UINT64 CInvocations; + UINT64 CPrimitives; + UINT64 PSInvocations; + UINT64 HSInvocations; + UINT64 DSInvocations; + UINT64 CSInvocations; + UINT64 ASInvocations; + UINT64 MSInvocations; + UINT64 MSPrimitives; + } D3D12_QUERY_DATA_PIPELINE_STATISTICS1; + +typedef struct D3D12_QUERY_DATA_SO_STATISTICS + { + UINT64 NumPrimitivesWritten; + UINT64 PrimitivesStorageNeeded; + } D3D12_QUERY_DATA_SO_STATISTICS; + +typedef struct D3D12_STREAM_OUTPUT_BUFFER_VIEW + { + D3D12_GPU_VIRTUAL_ADDRESS BufferLocation; + UINT64 SizeInBytes; + D3D12_GPU_VIRTUAL_ADDRESS BufferFilledSizeLocation; + } D3D12_STREAM_OUTPUT_BUFFER_VIEW; + +typedef struct D3D12_DRAW_ARGUMENTS + { + UINT VertexCountPerInstance; + UINT InstanceCount; + UINT StartVertexLocation; + UINT StartInstanceLocation; + } D3D12_DRAW_ARGUMENTS; + +typedef struct D3D12_DRAW_INDEXED_ARGUMENTS + { + UINT IndexCountPerInstance; + UINT InstanceCount; + UINT StartIndexLocation; + INT BaseVertexLocation; + UINT StartInstanceLocation; + } D3D12_DRAW_INDEXED_ARGUMENTS; + +typedef struct D3D12_DISPATCH_ARGUMENTS + { + UINT ThreadGroupCountX; + UINT ThreadGroupCountY; + UINT ThreadGroupCountZ; + } D3D12_DISPATCH_ARGUMENTS; + +typedef struct D3D12_VERTEX_BUFFER_VIEW + { + D3D12_GPU_VIRTUAL_ADDRESS BufferLocation; + UINT SizeInBytes; + UINT StrideInBytes; + } D3D12_VERTEX_BUFFER_VIEW; + +typedef struct D3D12_INDEX_BUFFER_VIEW + { + D3D12_GPU_VIRTUAL_ADDRESS BufferLocation; + UINT SizeInBytes; + DXGI_FORMAT Format; + } D3D12_INDEX_BUFFER_VIEW; + +typedef +enum D3D12_INDIRECT_ARGUMENT_TYPE + { + D3D12_INDIRECT_ARGUMENT_TYPE_DRAW = 0, + D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED = ( D3D12_INDIRECT_ARGUMENT_TYPE_DRAW + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH = ( D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW = ( D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW = ( D3D12_INDIRECT_ARGUMENT_TYPE_VERTEX_BUFFER_VIEW + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT = ( D3D12_INDIRECT_ARGUMENT_TYPE_INDEX_BUFFER_VIEW + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW = ( D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW = ( D3D12_INDIRECT_ARGUMENT_TYPE_CONSTANT_BUFFER_VIEW + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW = ( D3D12_INDIRECT_ARGUMENT_TYPE_SHADER_RESOURCE_VIEW + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS = ( D3D12_INDIRECT_ARGUMENT_TYPE_UNORDERED_ACCESS_VIEW + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH = ( D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_RAYS + 1 ) , + D3D12_INDIRECT_ARGUMENT_TYPE_INCREMENTING_CONSTANT = ( D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH + 1 ) + } D3D12_INDIRECT_ARGUMENT_TYPE; + +typedef struct D3D12_INDIRECT_ARGUMENT_DESC + { + D3D12_INDIRECT_ARGUMENT_TYPE Type; + union + { + struct + { + UINT Slot; + } VertexBuffer; + struct + { + UINT RootParameterIndex; + UINT DestOffsetIn32BitValues; + UINT Num32BitValuesToSet; + } Constant; + struct + { + UINT RootParameterIndex; + } ConstantBufferView; + struct + { + UINT RootParameterIndex; + } ShaderResourceView; + struct + { + UINT RootParameterIndex; + } UnorderedAccessView; + struct + { + UINT RootParameterIndex; + UINT DestOffsetIn32BitValues; + } IncrementingConstant; + } ; + } D3D12_INDIRECT_ARGUMENT_DESC; + +typedef struct D3D12_COMMAND_SIGNATURE_DESC + { + UINT ByteStride; + UINT NumArgumentDescs; + _Field_size_full_(NumArgumentDescs) const D3D12_INDIRECT_ARGUMENT_DESC *pArgumentDescs; + UINT NodeMask; + } D3D12_COMMAND_SIGNATURE_DESC; + + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0003_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0003_v0_0_s_ifspec; + +#ifndef __ID3D12Pageable_INTERFACE_DEFINED__ +#define __ID3D12Pageable_INTERFACE_DEFINED__ + +/* interface ID3D12Pageable */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Pageable; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("63ee58fb-1268-4835-86da-f008ce62f0d6") + ID3D12Pageable : public ID3D12DeviceChild + { + public: + }; + + +#else /* C style interface */ + + typedef struct ID3D12PageableVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Pageable * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Pageable * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Pageable * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Pageable * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Pageable * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Pageable * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Pageable * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Pageable * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12PageableVtbl; + + interface ID3D12Pageable + { + CONST_VTBL struct ID3D12PageableVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Pageable_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Pageable_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Pageable_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Pageable_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Pageable_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Pageable_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Pageable_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Pageable_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Pageable_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Heap_INTERFACE_DEFINED__ +#define __ID3D12Heap_INTERFACE_DEFINED__ + +/* interface ID3D12Heap */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Heap; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("6b3b2502-6e51-45b3-90ee-9884265e8df3") + ID3D12Heap : public ID3D12Pageable + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_HEAP_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_HEAP_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_HEAP_DESC * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12HeapVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Heap * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Heap * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Heap * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Heap * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Heap * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Heap * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Heap * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Heap * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12Heap, GetDesc) +#if !defined(_WIN32) + D3D12_HEAP_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12Heap * This); + +#else + D3D12_HEAP_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12Heap * This, + D3D12_HEAP_DESC * RetVal); + +#endif + + END_INTERFACE + } ID3D12HeapVtbl; + + interface ID3D12Heap + { + CONST_VTBL struct ID3D12HeapVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Heap_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Heap_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Heap_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Heap_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Heap_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Heap_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Heap_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Heap_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#if !defined(_WIN32) + +#define ID3D12Heap_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12Heap_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Heap_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Resource_INTERFACE_DEFINED__ +#define __ID3D12Resource_INTERFACE_DEFINED__ + +/* interface ID3D12Resource */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Resource; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("696442be-a72e-4059-bc79-5b5c98040fad") + ID3D12Resource : public ID3D12Pageable + { + public: + virtual HRESULT STDMETHODCALLTYPE Map( + UINT Subresource, + _In_opt_ const D3D12_RANGE *pReadRange, + _Outptr_opt_result_bytebuffer_(_Inexpressible_("Dependent on resource")) void **ppData) = 0; + + virtual void STDMETHODCALLTYPE Unmap( + UINT Subresource, + _In_opt_ const D3D12_RANGE *pWrittenRange) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_RESOURCE_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_RESOURCE_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_RESOURCE_DESC * RetVal) = 0; +#endif + + virtual D3D12_GPU_VIRTUAL_ADDRESS STDMETHODCALLTYPE GetGPUVirtualAddress( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE WriteToSubresource( + UINT DstSubresource, + _In_opt_ const D3D12_BOX *pDstBox, + _In_ const void *pSrcData, + UINT SrcRowPitch, + UINT SrcDepthPitch) = 0; + + virtual HRESULT STDMETHODCALLTYPE ReadFromSubresource( + _Out_ void *pDstData, + UINT DstRowPitch, + UINT DstDepthPitch, + UINT SrcSubresource, + _In_opt_ const D3D12_BOX *pSrcBox) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetHeapProperties( + _Out_opt_ D3D12_HEAP_PROPERTIES *pHeapProperties, + _Out_opt_ D3D12_HEAP_FLAGS *pHeapFlags) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ResourceVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Resource * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Resource * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Resource * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Resource * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Resource * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Resource * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Resource * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Resource * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12Resource, Map) + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D12Resource * This, + UINT Subresource, + _In_opt_ const D3D12_RANGE *pReadRange, + _Outptr_opt_result_bytebuffer_(_Inexpressible_("Dependent on resource")) void **ppData); + + DECLSPEC_XFGVIRT(ID3D12Resource, Unmap) + void ( STDMETHODCALLTYPE *Unmap )( + ID3D12Resource * This, + UINT Subresource, + _In_opt_ const D3D12_RANGE *pWrittenRange); + + DECLSPEC_XFGVIRT(ID3D12Resource, GetDesc) +#if !defined(_WIN32) + D3D12_RESOURCE_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12Resource * This); + +#else + D3D12_RESOURCE_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12Resource * This, + D3D12_RESOURCE_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Resource, GetGPUVirtualAddress) + D3D12_GPU_VIRTUAL_ADDRESS ( STDMETHODCALLTYPE *GetGPUVirtualAddress )( + ID3D12Resource * This); + + DECLSPEC_XFGVIRT(ID3D12Resource, WriteToSubresource) + HRESULT ( STDMETHODCALLTYPE *WriteToSubresource )( + ID3D12Resource * This, + UINT DstSubresource, + _In_opt_ const D3D12_BOX *pDstBox, + _In_ const void *pSrcData, + UINT SrcRowPitch, + UINT SrcDepthPitch); + + DECLSPEC_XFGVIRT(ID3D12Resource, ReadFromSubresource) + HRESULT ( STDMETHODCALLTYPE *ReadFromSubresource )( + ID3D12Resource * This, + _Out_ void *pDstData, + UINT DstRowPitch, + UINT DstDepthPitch, + UINT SrcSubresource, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12Resource, GetHeapProperties) + HRESULT ( STDMETHODCALLTYPE *GetHeapProperties )( + ID3D12Resource * This, + _Out_opt_ D3D12_HEAP_PROPERTIES *pHeapProperties, + _Out_opt_ D3D12_HEAP_FLAGS *pHeapFlags); + + END_INTERFACE + } ID3D12ResourceVtbl; + + interface ID3D12Resource + { + CONST_VTBL struct ID3D12ResourceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Resource_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Resource_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Resource_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Resource_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Resource_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Resource_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Resource_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Resource_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12Resource_Map(This,Subresource,pReadRange,ppData) \ + ( (This)->lpVtbl -> Map(This,Subresource,pReadRange,ppData) ) + +#define ID3D12Resource_Unmap(This,Subresource,pWrittenRange) \ + ( (This)->lpVtbl -> Unmap(This,Subresource,pWrittenRange) ) +#if !defined(_WIN32) + +#define ID3D12Resource_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12Resource_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#define ID3D12Resource_GetGPUVirtualAddress(This) \ + ( (This)->lpVtbl -> GetGPUVirtualAddress(This) ) + +#define ID3D12Resource_WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D12Resource_ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) ) + +#define ID3D12Resource_GetHeapProperties(This,pHeapProperties,pHeapFlags) \ + ( (This)->lpVtbl -> GetHeapProperties(This,pHeapProperties,pHeapFlags) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Resource_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12CommandAllocator_INTERFACE_DEFINED__ +#define __ID3D12CommandAllocator_INTERFACE_DEFINED__ + +/* interface ID3D12CommandAllocator */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12CommandAllocator; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("6102dee4-af59-4b09-b999-b44d73f09b24") + ID3D12CommandAllocator : public ID3D12Pageable + { + public: + virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12CommandAllocatorVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12CommandAllocator * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12CommandAllocator * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12CommandAllocator * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12CommandAllocator * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12CommandAllocator * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12CommandAllocator * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12CommandAllocator * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12CommandAllocator * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandAllocator, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12CommandAllocator * This); + + END_INTERFACE + } ID3D12CommandAllocatorVtbl; + + interface ID3D12CommandAllocator + { + CONST_VTBL struct ID3D12CommandAllocatorVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12CommandAllocator_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12CommandAllocator_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12CommandAllocator_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12CommandAllocator_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12CommandAllocator_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12CommandAllocator_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12CommandAllocator_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12CommandAllocator_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12CommandAllocator_Reset(This) \ + ( (This)->lpVtbl -> Reset(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12CommandAllocator_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Fence_INTERFACE_DEFINED__ +#define __ID3D12Fence_INTERFACE_DEFINED__ + +/* interface ID3D12Fence */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Fence; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("0a753dcf-c4d8-4b91-adf6-be5a60d95a76") + ID3D12Fence : public ID3D12Pageable + { + public: + virtual UINT64 STDMETHODCALLTYPE GetCompletedValue( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetEventOnCompletion( + UINT64 Value, + HANDLE hEvent) = 0; + + virtual HRESULT STDMETHODCALLTYPE Signal( + UINT64 Value) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12FenceVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Fence * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Fence * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Fence * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Fence * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Fence * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Fence * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Fence * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Fence * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12Fence, GetCompletedValue) + UINT64 ( STDMETHODCALLTYPE *GetCompletedValue )( + ID3D12Fence * This); + + DECLSPEC_XFGVIRT(ID3D12Fence, SetEventOnCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnCompletion )( + ID3D12Fence * This, + UINT64 Value, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Fence, Signal) + HRESULT ( STDMETHODCALLTYPE *Signal )( + ID3D12Fence * This, + UINT64 Value); + + END_INTERFACE + } ID3D12FenceVtbl; + + interface ID3D12Fence + { + CONST_VTBL struct ID3D12FenceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Fence_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Fence_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Fence_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Fence_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Fence_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Fence_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Fence_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Fence_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12Fence_GetCompletedValue(This) \ + ( (This)->lpVtbl -> GetCompletedValue(This) ) + +#define ID3D12Fence_SetEventOnCompletion(This,Value,hEvent) \ + ( (This)->lpVtbl -> SetEventOnCompletion(This,Value,hEvent) ) + +#define ID3D12Fence_Signal(This,Value) \ + ( (This)->lpVtbl -> Signal(This,Value) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Fence_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Fence1_INTERFACE_DEFINED__ +#define __ID3D12Fence1_INTERFACE_DEFINED__ + +/* interface ID3D12Fence1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Fence1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("433685fe-e22b-4ca0-a8db-b5b4f4dd0e4a") + ID3D12Fence1 : public ID3D12Fence + { + public: + virtual D3D12_FENCE_FLAGS STDMETHODCALLTYPE GetCreationFlags( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Fence1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Fence1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Fence1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Fence1 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Fence1 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Fence1 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Fence1 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Fence1 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Fence1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12Fence, GetCompletedValue) + UINT64 ( STDMETHODCALLTYPE *GetCompletedValue )( + ID3D12Fence1 * This); + + DECLSPEC_XFGVIRT(ID3D12Fence, SetEventOnCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnCompletion )( + ID3D12Fence1 * This, + UINT64 Value, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Fence, Signal) + HRESULT ( STDMETHODCALLTYPE *Signal )( + ID3D12Fence1 * This, + UINT64 Value); + + DECLSPEC_XFGVIRT(ID3D12Fence1, GetCreationFlags) + D3D12_FENCE_FLAGS ( STDMETHODCALLTYPE *GetCreationFlags )( + ID3D12Fence1 * This); + + END_INTERFACE + } ID3D12Fence1Vtbl; + + interface ID3D12Fence1 + { + CONST_VTBL struct ID3D12Fence1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Fence1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Fence1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Fence1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Fence1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Fence1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Fence1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Fence1_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Fence1_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12Fence1_GetCompletedValue(This) \ + ( (This)->lpVtbl -> GetCompletedValue(This) ) + +#define ID3D12Fence1_SetEventOnCompletion(This,Value,hEvent) \ + ( (This)->lpVtbl -> SetEventOnCompletion(This,Value,hEvent) ) + +#define ID3D12Fence1_Signal(This,Value) \ + ( (This)->lpVtbl -> Signal(This,Value) ) + + +#define ID3D12Fence1_GetCreationFlags(This) \ + ( (This)->lpVtbl -> GetCreationFlags(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Fence1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12PipelineState_INTERFACE_DEFINED__ +#define __ID3D12PipelineState_INTERFACE_DEFINED__ + +/* interface ID3D12PipelineState */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12PipelineState; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("765a30f3-f624-4c6f-a828-ace948622445") + ID3D12PipelineState : public ID3D12Pageable + { + public: + virtual HRESULT STDMETHODCALLTYPE GetCachedBlob( + _COM_Outptr_ ID3DBlob **ppBlob) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12PipelineStateVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12PipelineState * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12PipelineState * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12PipelineState * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12PipelineState * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12PipelineState * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12PipelineState * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12PipelineState * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12PipelineState * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12PipelineState, GetCachedBlob) + HRESULT ( STDMETHODCALLTYPE *GetCachedBlob )( + ID3D12PipelineState * This, + _COM_Outptr_ ID3DBlob **ppBlob); + + END_INTERFACE + } ID3D12PipelineStateVtbl; + + interface ID3D12PipelineState + { + CONST_VTBL struct ID3D12PipelineStateVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12PipelineState_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12PipelineState_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12PipelineState_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12PipelineState_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12PipelineState_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12PipelineState_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12PipelineState_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12PipelineState_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12PipelineState_GetCachedBlob(This,ppBlob) \ + ( (This)->lpVtbl -> GetCachedBlob(This,ppBlob) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12PipelineState_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DescriptorHeap_INTERFACE_DEFINED__ +#define __ID3D12DescriptorHeap_INTERFACE_DEFINED__ + +/* interface ID3D12DescriptorHeap */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DescriptorHeap; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("8efb471d-616c-4f49-90f7-127bb763fa51") + ID3D12DescriptorHeap : public ID3D12Pageable + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_DESCRIPTOR_HEAP_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_DESCRIPTOR_HEAP_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_DESCRIPTOR_HEAP_DESC * RetVal) = 0; +#endif + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_CPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE GetCPUDescriptorHandleForHeapStart( void) = 0; +#else + virtual D3D12_CPU_DESCRIPTOR_HANDLE *STDMETHODCALLTYPE GetCPUDescriptorHandleForHeapStart( + D3D12_CPU_DESCRIPTOR_HANDLE * RetVal) = 0; +#endif + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_GPU_DESCRIPTOR_HANDLE STDMETHODCALLTYPE GetGPUDescriptorHandleForHeapStart( void) = 0; +#else + virtual D3D12_GPU_DESCRIPTOR_HANDLE *STDMETHODCALLTYPE GetGPUDescriptorHandleForHeapStart( + D3D12_GPU_DESCRIPTOR_HANDLE * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DescriptorHeapVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DescriptorHeap * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DescriptorHeap * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DescriptorHeap * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12DescriptorHeap * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12DescriptorHeap * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12DescriptorHeap * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12DescriptorHeap * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12DescriptorHeap * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12DescriptorHeap, GetDesc) +#if !defined(_WIN32) + D3D12_DESCRIPTOR_HEAP_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12DescriptorHeap * This); + +#else + D3D12_DESCRIPTOR_HEAP_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12DescriptorHeap * This, + D3D12_DESCRIPTOR_HEAP_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12DescriptorHeap, GetCPUDescriptorHandleForHeapStart) +#if !defined(_WIN32) + D3D12_CPU_DESCRIPTOR_HANDLE ( STDMETHODCALLTYPE *GetCPUDescriptorHandleForHeapStart )( + ID3D12DescriptorHeap * This); + +#else + D3D12_CPU_DESCRIPTOR_HANDLE *( STDMETHODCALLTYPE *GetCPUDescriptorHandleForHeapStart )( + ID3D12DescriptorHeap * This, + D3D12_CPU_DESCRIPTOR_HANDLE * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12DescriptorHeap, GetGPUDescriptorHandleForHeapStart) +#if !defined(_WIN32) + D3D12_GPU_DESCRIPTOR_HANDLE ( STDMETHODCALLTYPE *GetGPUDescriptorHandleForHeapStart )( + ID3D12DescriptorHeap * This); + +#else + D3D12_GPU_DESCRIPTOR_HANDLE *( STDMETHODCALLTYPE *GetGPUDescriptorHandleForHeapStart )( + ID3D12DescriptorHeap * This, + D3D12_GPU_DESCRIPTOR_HANDLE * RetVal); + +#endif + + END_INTERFACE + } ID3D12DescriptorHeapVtbl; + + interface ID3D12DescriptorHeap + { + CONST_VTBL struct ID3D12DescriptorHeapVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DescriptorHeap_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DescriptorHeap_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DescriptorHeap_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DescriptorHeap_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12DescriptorHeap_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12DescriptorHeap_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12DescriptorHeap_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12DescriptorHeap_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#if !defined(_WIN32) + +#define ID3D12DescriptorHeap_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12DescriptorHeap_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif +#if !defined(_WIN32) + +#define ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(This) \ + ( (This)->lpVtbl -> GetCPUDescriptorHandleForHeapStart(This) ) +#else +#define ID3D12DescriptorHeap_GetCPUDescriptorHandleForHeapStart(This,RetVal) \ + ( (This)->lpVtbl -> GetCPUDescriptorHandleForHeapStart(This,RetVal) ) +#endif +#if !defined(_WIN32) + +#define ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(This) \ + ( (This)->lpVtbl -> GetGPUDescriptorHandleForHeapStart(This) ) +#else +#define ID3D12DescriptorHeap_GetGPUDescriptorHandleForHeapStart(This,RetVal) \ + ( (This)->lpVtbl -> GetGPUDescriptorHandleForHeapStart(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DescriptorHeap_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12QueryHeap_INTERFACE_DEFINED__ +#define __ID3D12QueryHeap_INTERFACE_DEFINED__ + +/* interface ID3D12QueryHeap */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12QueryHeap; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("0d9658ae-ed45-469e-a61d-970ec583cab4") + ID3D12QueryHeap : public ID3D12Pageable + { + public: + }; + + +#else /* C style interface */ + + typedef struct ID3D12QueryHeapVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12QueryHeap * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12QueryHeap * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12QueryHeap * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12QueryHeap * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12QueryHeap * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12QueryHeap * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12QueryHeap * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12QueryHeap * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12QueryHeapVtbl; + + interface ID3D12QueryHeap + { + CONST_VTBL struct ID3D12QueryHeapVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12QueryHeap_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12QueryHeap_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12QueryHeap_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12QueryHeap_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12QueryHeap_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12QueryHeap_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12QueryHeap_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12QueryHeap_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12QueryHeap_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12CommandSignature_INTERFACE_DEFINED__ +#define __ID3D12CommandSignature_INTERFACE_DEFINED__ + +/* interface ID3D12CommandSignature */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12CommandSignature; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("c36a797c-ec80-4f0a-8985-a7b2475082d1") + ID3D12CommandSignature : public ID3D12Pageable + { + public: + }; + + +#else /* C style interface */ + + typedef struct ID3D12CommandSignatureVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12CommandSignature * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12CommandSignature * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12CommandSignature * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12CommandSignature * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12CommandSignature * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12CommandSignature * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12CommandSignature * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12CommandSignature * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12CommandSignatureVtbl; + + interface ID3D12CommandSignature + { + CONST_VTBL struct ID3D12CommandSignatureVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12CommandSignature_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12CommandSignature_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12CommandSignature_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12CommandSignature_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12CommandSignature_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12CommandSignature_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12CommandSignature_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12CommandSignature_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12CommandSignature_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12CommandList_INTERFACE_DEFINED__ +#define __ID3D12CommandList_INTERFACE_DEFINED__ + +/* interface ID3D12CommandList */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12CommandList; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("7116d91c-e7e4-47ce-b8c6-ec8168f437e5") + ID3D12CommandList : public ID3D12DeviceChild + { + public: + virtual D3D12_COMMAND_LIST_TYPE STDMETHODCALLTYPE GetType( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12CommandListVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12CommandList * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12CommandList * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12CommandList * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12CommandList * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12CommandList * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12CommandList * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12CommandList * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12CommandList * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12CommandList * This); + + END_INTERFACE + } ID3D12CommandListVtbl; + + interface ID3D12CommandList + { + CONST_VTBL struct ID3D12CommandListVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12CommandList_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12CommandList_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12CommandList_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12CommandList_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12CommandList_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12CommandList_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12CommandList_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12CommandList_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12CommandList_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12CommandList_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5b160d0f-ac1b-4185-8ba8-b3ae42a5a455") + ID3D12GraphicsCommandList : public ID3D12CommandList + { + public: + virtual HRESULT STDMETHODCALLTYPE Close( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE Reset( + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState) = 0; + + virtual void STDMETHODCALLTYPE ClearState( + _In_opt_ ID3D12PipelineState *pPipelineState) = 0; + + virtual void STDMETHODCALLTYPE DrawInstanced( + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation) = 0; + + virtual void STDMETHODCALLTYPE DrawIndexedInstanced( + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation) = 0; + + virtual void STDMETHODCALLTYPE Dispatch( + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ) = 0; + + virtual void STDMETHODCALLTYPE CopyBufferRegion( + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes) = 0; + + virtual void STDMETHODCALLTYPE CopyTextureRegion( + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox) = 0; + + virtual void STDMETHODCALLTYPE CopyResource( + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource) = 0; + + virtual void STDMETHODCALLTYPE CopyTiles( + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags) = 0; + + virtual void STDMETHODCALLTYPE ResolveSubresource( + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format) = 0; + + virtual void STDMETHODCALLTYPE IASetPrimitiveTopology( + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology) = 0; + + virtual void STDMETHODCALLTYPE RSSetViewports( + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports) = 0; + + virtual void STDMETHODCALLTYPE RSSetScissorRects( + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects) = 0; + + virtual void STDMETHODCALLTYPE OMSetBlendFactor( + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]) = 0; + + virtual void STDMETHODCALLTYPE OMSetStencilRef( + _In_ UINT StencilRef) = 0; + + virtual void STDMETHODCALLTYPE SetPipelineState( + _In_ ID3D12PipelineState *pPipelineState) = 0; + + virtual void STDMETHODCALLTYPE ResourceBarrier( + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers) = 0; + + virtual void STDMETHODCALLTYPE ExecuteBundle( + _In_ ID3D12GraphicsCommandList *pCommandList) = 0; + + virtual void STDMETHODCALLTYPE SetDescriptorHeaps( + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps) = 0; + + virtual void STDMETHODCALLTYPE SetComputeRootSignature( + _In_opt_ ID3D12RootSignature *pRootSignature) = 0; + + virtual void STDMETHODCALLTYPE SetGraphicsRootSignature( + _In_opt_ ID3D12RootSignature *pRootSignature) = 0; + + virtual void STDMETHODCALLTYPE SetComputeRootDescriptorTable( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor) = 0; + + virtual void STDMETHODCALLTYPE SetGraphicsRootDescriptorTable( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor) = 0; + + virtual void STDMETHODCALLTYPE SetComputeRoot32BitConstant( + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues) = 0; + + virtual void STDMETHODCALLTYPE SetGraphicsRoot32BitConstant( + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues) = 0; + + virtual void STDMETHODCALLTYPE SetComputeRoot32BitConstants( + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues) = 0; + + virtual void STDMETHODCALLTYPE SetGraphicsRoot32BitConstants( + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues) = 0; + + virtual void STDMETHODCALLTYPE SetComputeRootConstantBufferView( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation) = 0; + + virtual void STDMETHODCALLTYPE SetGraphicsRootConstantBufferView( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation) = 0; + + virtual void STDMETHODCALLTYPE SetComputeRootShaderResourceView( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation) = 0; + + virtual void STDMETHODCALLTYPE SetGraphicsRootShaderResourceView( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation) = 0; + + virtual void STDMETHODCALLTYPE SetComputeRootUnorderedAccessView( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation) = 0; + + virtual void STDMETHODCALLTYPE SetGraphicsRootUnorderedAccessView( + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation) = 0; + + virtual void STDMETHODCALLTYPE IASetIndexBuffer( + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView) = 0; + + virtual void STDMETHODCALLTYPE IASetVertexBuffers( + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews) = 0; + + virtual void STDMETHODCALLTYPE SOSetTargets( + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews) = 0; + + virtual void STDMETHODCALLTYPE OMSetRenderTargets( + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor) = 0; + + virtual void STDMETHODCALLTYPE ClearDepthStencilView( + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects) = 0; + + virtual void STDMETHODCALLTYPE ClearRenderTargetView( + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects) = 0; + + virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewUint( + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects) = 0; + + virtual void STDMETHODCALLTYPE ClearUnorderedAccessViewFloat( + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects) = 0; + + virtual void STDMETHODCALLTYPE DiscardResource( + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion) = 0; + + virtual void STDMETHODCALLTYPE BeginQuery( + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index) = 0; + + virtual void STDMETHODCALLTYPE EndQuery( + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index) = 0; + + virtual void STDMETHODCALLTYPE ResolveQueryData( + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset) = 0; + + virtual void STDMETHODCALLTYPE SetPredication( + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation) = 0; + + virtual void STDMETHODCALLTYPE SetMarker( + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size) = 0; + + virtual void STDMETHODCALLTYPE BeginEvent( + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size) = 0; + + virtual void STDMETHODCALLTYPE EndEvent( void) = 0; + + virtual void STDMETHODCALLTYPE ExecuteIndirect( + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandListVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + END_INTERFACE + } ID3D12GraphicsCommandListVtbl; + + interface ID3D12GraphicsCommandList + { + CONST_VTBL struct ID3D12GraphicsCommandListVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList1_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList1_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("553103fb-1fe7-4557-bb38-946d7d0e7ca7") + ID3D12GraphicsCommandList1 : public ID3D12GraphicsCommandList + { + public: + virtual void STDMETHODCALLTYPE AtomicCopyBufferUINT( + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges) = 0; + + virtual void STDMETHODCALLTYPE AtomicCopyBufferUINT64( + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges) = 0; + + virtual void STDMETHODCALLTYPE OMSetDepthBounds( + _In_ FLOAT Min, + _In_ FLOAT Max) = 0; + + virtual void STDMETHODCALLTYPE SetSamplePositions( + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions) = 0; + + virtual void STDMETHODCALLTYPE ResolveSubresourceRegion( + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode) = 0; + + virtual void STDMETHODCALLTYPE SetViewInstanceMask( + _In_ UINT Mask) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList1 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList1 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList1 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList1 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList1 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList1 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList1 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList1 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList1 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList1 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList1 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList1 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList1 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList1 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList1 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList1 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList1 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList1 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList1 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList1 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList1 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList1 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList1 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList1 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList1 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList1 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList1 * This, + _In_ UINT Mask); + + END_INTERFACE + } ID3D12GraphicsCommandList1Vtbl; + + interface ID3D12GraphicsCommandList1 + { + CONST_VTBL struct ID3D12GraphicsCommandList1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList1_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList1_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList1_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList1_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList1_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList1_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList1_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList1_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList1_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList1_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList1_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList1_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList1_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList1_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList1_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList1_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList1_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList1_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList1_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList1_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList1_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList1_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList1_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList1_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList1_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList1_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList1_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList1_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList1_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList1_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList1_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList1_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList1_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList1_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList1_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList1_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList1_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList1_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList1_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList1_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList1_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList1_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList1_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList1_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList1_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList1_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList1_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList1_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList1_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList1_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList1_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList1_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList1_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList1_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList1_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList1_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList1_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList1_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList1_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList1_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0018 */ +/* [local] */ + +typedef struct D3D12_WRITEBUFFERIMMEDIATE_PARAMETER + { + D3D12_GPU_VIRTUAL_ADDRESS Dest; + UINT32 Value; + } D3D12_WRITEBUFFERIMMEDIATE_PARAMETER; + +typedef +enum D3D12_WRITEBUFFERIMMEDIATE_MODE + { + D3D12_WRITEBUFFERIMMEDIATE_MODE_DEFAULT = 0, + D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_IN = 0x1, + D3D12_WRITEBUFFERIMMEDIATE_MODE_MARKER_OUT = 0x2 + } D3D12_WRITEBUFFERIMMEDIATE_MODE; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0018_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0018_v0_0_s_ifspec; + +#ifndef __ID3D12GraphicsCommandList2_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList2_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("38C3E585-FF17-412C-9150-4FC6F9D72A28") + ID3D12GraphicsCommandList2 : public ID3D12GraphicsCommandList1 + { + public: + virtual void STDMETHODCALLTYPE WriteBufferImmediate( + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList2 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList2 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList2 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList2 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList2 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList2 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList2 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList2 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList2 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList2 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList2 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList2 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList2 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList2 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList2 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList2 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList2 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList2 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList2 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList2 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList2 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList2 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList2 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList2 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList2 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList2 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList2 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList2 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList2 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + END_INTERFACE + } ID3D12GraphicsCommandList2Vtbl; + + interface ID3D12GraphicsCommandList2 + { + CONST_VTBL struct ID3D12GraphicsCommandList2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList2_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList2_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList2_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList2_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList2_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList2_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList2_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList2_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList2_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList2_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList2_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList2_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList2_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList2_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList2_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList2_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList2_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList2_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList2_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList2_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList2_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList2_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList2_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList2_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList2_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList2_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList2_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList2_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList2_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList2_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList2_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList2_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList2_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList2_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList2_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList2_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList2_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList2_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList2_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList2_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList2_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList2_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList2_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList2_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList2_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList2_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList2_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList2_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList2_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList2_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList2_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList2_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList2_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList2_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList2_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList2_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList2_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList2_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList2_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList2_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList2_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList2_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList2_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList2_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList2_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12CommandQueue_INTERFACE_DEFINED__ +#define __ID3D12CommandQueue_INTERFACE_DEFINED__ + +/* interface ID3D12CommandQueue */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12CommandQueue; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("0ec870a6-5d7e-4c22-8cfc-5baae07616ed") + ID3D12CommandQueue : public ID3D12Pageable + { + public: + virtual void STDMETHODCALLTYPE UpdateTileMappings( + _In_ ID3D12Resource *pResource, + UINT NumResourceRegions, + _In_reads_opt_(NumResourceRegions) const D3D12_TILED_RESOURCE_COORDINATE *pResourceRegionStartCoordinates, + _In_reads_opt_(NumResourceRegions) const D3D12_TILE_REGION_SIZE *pResourceRegionSizes, + _In_opt_ ID3D12Heap *pHeap, + UINT NumRanges, + _In_reads_opt_(NumRanges) const D3D12_TILE_RANGE_FLAGS *pRangeFlags, + _In_reads_opt_(NumRanges) const UINT *pHeapRangeStartOffsets, + _In_reads_opt_(NumRanges) const UINT *pRangeTileCounts, + D3D12_TILE_MAPPING_FLAGS Flags) = 0; + + virtual void STDMETHODCALLTYPE CopyTileMappings( + _In_ ID3D12Resource *pDstResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pDstRegionStartCoordinate, + _In_ ID3D12Resource *pSrcResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pSrcRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pRegionSize, + D3D12_TILE_MAPPING_FLAGS Flags) = 0; + + virtual void STDMETHODCALLTYPE ExecuteCommandLists( + _In_ UINT NumCommandLists, + _In_reads_(NumCommandLists) ID3D12CommandList *const *ppCommandLists) = 0; + + virtual void STDMETHODCALLTYPE SetMarker( + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size) = 0; + + virtual void STDMETHODCALLTYPE BeginEvent( + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size) = 0; + + virtual void STDMETHODCALLTYPE EndEvent( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE Signal( + ID3D12Fence *pFence, + UINT64 Value) = 0; + + virtual HRESULT STDMETHODCALLTYPE Wait( + ID3D12Fence *pFence, + UINT64 Value) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetTimestampFrequency( + _Out_ UINT64 *pFrequency) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetClockCalibration( + _Out_ UINT64 *pGPUTimestamp, + _Out_ UINT64 *pCpuTimestamp) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_COMMAND_QUEUE_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_COMMAND_QUEUE_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_COMMAND_QUEUE_DESC * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12CommandQueueVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12CommandQueue * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12CommandQueue * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12CommandQueue * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12CommandQueue * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12CommandQueue * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12CommandQueue * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12CommandQueue * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12CommandQueue * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, UpdateTileMappings) + void ( STDMETHODCALLTYPE *UpdateTileMappings )( + ID3D12CommandQueue * This, + _In_ ID3D12Resource *pResource, + UINT NumResourceRegions, + _In_reads_opt_(NumResourceRegions) const D3D12_TILED_RESOURCE_COORDINATE *pResourceRegionStartCoordinates, + _In_reads_opt_(NumResourceRegions) const D3D12_TILE_REGION_SIZE *pResourceRegionSizes, + _In_opt_ ID3D12Heap *pHeap, + UINT NumRanges, + _In_reads_opt_(NumRanges) const D3D12_TILE_RANGE_FLAGS *pRangeFlags, + _In_reads_opt_(NumRanges) const UINT *pHeapRangeStartOffsets, + _In_reads_opt_(NumRanges) const UINT *pRangeTileCounts, + D3D12_TILE_MAPPING_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, CopyTileMappings) + void ( STDMETHODCALLTYPE *CopyTileMappings )( + ID3D12CommandQueue * This, + _In_ ID3D12Resource *pDstResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pDstRegionStartCoordinate, + _In_ ID3D12Resource *pSrcResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pSrcRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pRegionSize, + D3D12_TILE_MAPPING_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, ExecuteCommandLists) + void ( STDMETHODCALLTYPE *ExecuteCommandLists )( + ID3D12CommandQueue * This, + _In_ UINT NumCommandLists, + _In_reads_(NumCommandLists) ID3D12CommandList *const *ppCommandLists); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12CommandQueue * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12CommandQueue * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12CommandQueue * This); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, Signal) + HRESULT ( STDMETHODCALLTYPE *Signal )( + ID3D12CommandQueue * This, + ID3D12Fence *pFence, + UINT64 Value); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, Wait) + HRESULT ( STDMETHODCALLTYPE *Wait )( + ID3D12CommandQueue * This, + ID3D12Fence *pFence, + UINT64 Value); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, GetTimestampFrequency) + HRESULT ( STDMETHODCALLTYPE *GetTimestampFrequency )( + ID3D12CommandQueue * This, + _Out_ UINT64 *pFrequency); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, GetClockCalibration) + HRESULT ( STDMETHODCALLTYPE *GetClockCalibration )( + ID3D12CommandQueue * This, + _Out_ UINT64 *pGPUTimestamp, + _Out_ UINT64 *pCpuTimestamp); + + DECLSPEC_XFGVIRT(ID3D12CommandQueue, GetDesc) +#if !defined(_WIN32) + D3D12_COMMAND_QUEUE_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12CommandQueue * This); + +#else + D3D12_COMMAND_QUEUE_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12CommandQueue * This, + D3D12_COMMAND_QUEUE_DESC * RetVal); + +#endif + + END_INTERFACE + } ID3D12CommandQueueVtbl; + + interface ID3D12CommandQueue + { + CONST_VTBL struct ID3D12CommandQueueVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12CommandQueue_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12CommandQueue_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12CommandQueue_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12CommandQueue_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12CommandQueue_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12CommandQueue_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12CommandQueue_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12CommandQueue_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12CommandQueue_UpdateTileMappings(This,pResource,NumResourceRegions,pResourceRegionStartCoordinates,pResourceRegionSizes,pHeap,NumRanges,pRangeFlags,pHeapRangeStartOffsets,pRangeTileCounts,Flags) \ + ( (This)->lpVtbl -> UpdateTileMappings(This,pResource,NumResourceRegions,pResourceRegionStartCoordinates,pResourceRegionSizes,pHeap,NumRanges,pRangeFlags,pHeapRangeStartOffsets,pRangeTileCounts,Flags) ) + +#define ID3D12CommandQueue_CopyTileMappings(This,pDstResource,pDstRegionStartCoordinate,pSrcResource,pSrcRegionStartCoordinate,pRegionSize,Flags) \ + ( (This)->lpVtbl -> CopyTileMappings(This,pDstResource,pDstRegionStartCoordinate,pSrcResource,pSrcRegionStartCoordinate,pRegionSize,Flags) ) + +#define ID3D12CommandQueue_ExecuteCommandLists(This,NumCommandLists,ppCommandLists) \ + ( (This)->lpVtbl -> ExecuteCommandLists(This,NumCommandLists,ppCommandLists) ) + +#define ID3D12CommandQueue_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12CommandQueue_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12CommandQueue_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12CommandQueue_Signal(This,pFence,Value) \ + ( (This)->lpVtbl -> Signal(This,pFence,Value) ) + +#define ID3D12CommandQueue_Wait(This,pFence,Value) \ + ( (This)->lpVtbl -> Wait(This,pFence,Value) ) + +#define ID3D12CommandQueue_GetTimestampFrequency(This,pFrequency) \ + ( (This)->lpVtbl -> GetTimestampFrequency(This,pFrequency) ) + +#define ID3D12CommandQueue_GetClockCalibration(This,pGPUTimestamp,pCpuTimestamp) \ + ( (This)->lpVtbl -> GetClockCalibration(This,pGPUTimestamp,pCpuTimestamp) ) +#if !defined(_WIN32) + +#define ID3D12CommandQueue_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12CommandQueue_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12CommandQueue_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0020 */ +/* [local] */ + +#ifdef __midl +#ifndef LUID_DEFINED +#define LUID_DEFINED 1 +typedef struct __LUID + { + DWORD LowPart; + LONG HighPart; + } LUID; + +typedef struct __LUID *PLUID; + +#endif +#endif + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0020_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0020_v0_0_s_ifspec; + +#ifndef __ID3D12Device_INTERFACE_DEFINED__ +#define __ID3D12Device_INTERFACE_DEFINED__ + +/* interface ID3D12Device */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("189819f1-1db6-4b57-be54-1821339b85f7") + ID3D12Device : public ID3D12Object + { + public: + virtual UINT STDMETHODCALLTYPE GetNodeCount( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateCommandQueue( + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateCommandAllocator( + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateGraphicsPipelineState( + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateComputePipelineState( + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateCommandList( + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList) = 0; + + virtual HRESULT STDMETHODCALLTYPE CheckFeatureSupport( + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateDescriptorHeap( + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap) = 0; + + virtual UINT STDMETHODCALLTYPE GetDescriptorHandleIncrementSize( + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateRootSignature( + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature) = 0; + + virtual void STDMETHODCALLTYPE CreateConstantBufferView( + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + virtual void STDMETHODCALLTYPE CreateShaderResourceView( + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + virtual void STDMETHODCALLTYPE CreateUnorderedAccessView( + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + virtual void STDMETHODCALLTYPE CreateRenderTargetView( + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + virtual void STDMETHODCALLTYPE CreateDepthStencilView( + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + virtual void STDMETHODCALLTYPE CreateSampler( + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + virtual void STDMETHODCALLTYPE CopyDescriptors( + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType) = 0; + + virtual void STDMETHODCALLTYPE CopyDescriptorsSimple( + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_RESOURCE_ALLOCATION_INFO STDMETHODCALLTYPE GetResourceAllocationInfo( + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs) = 0; +#else + virtual D3D12_RESOURCE_ALLOCATION_INFO *STDMETHODCALLTYPE GetResourceAllocationInfo( + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs) = 0; +#endif + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_HEAP_PROPERTIES STDMETHODCALLTYPE GetCustomHeapProperties( + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType) = 0; +#else + virtual D3D12_HEAP_PROPERTIES *STDMETHODCALLTYPE GetCustomHeapProperties( + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType) = 0; +#endif + + virtual HRESULT STDMETHODCALLTYPE CreateCommittedResource( + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateHeap( + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreatePlacedResource( + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateReservedResource( + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateSharedHandle( + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle) = 0; + + virtual HRESULT STDMETHODCALLTYPE OpenSharedHandle( + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj) = 0; + + virtual HRESULT STDMETHODCALLTYPE OpenSharedHandleByName( + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle) = 0; + + virtual HRESULT STDMETHODCALLTYPE MakeResident( + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects) = 0; + + virtual HRESULT STDMETHODCALLTYPE Evict( + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateFence( + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDeviceRemovedReason( void) = 0; + + virtual void STDMETHODCALLTYPE GetCopyableFootprints( + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateQueryHeap( + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetStablePowerState( + BOOL Enable) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateCommandSignature( + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature) = 0; + + virtual void STDMETHODCALLTYPE GetResourceTiling( + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual LUID STDMETHODCALLTYPE GetAdapterLuid( void) = 0; +#else + virtual LUID *STDMETHODCALLTYPE GetAdapterLuid( + LUID * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device * This, + LUID * RetVal); + +#endif + + END_INTERFACE + } ID3D12DeviceVtbl; + + interface ID3D12Device + { + CONST_VTBL struct ID3D12DeviceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12PipelineLibrary_INTERFACE_DEFINED__ +#define __ID3D12PipelineLibrary_INTERFACE_DEFINED__ + +/* interface ID3D12PipelineLibrary */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12PipelineLibrary; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("c64226a8-9201-46af-b4cc-53fb9ff7414f") + ID3D12PipelineLibrary : public ID3D12DeviceChild + { + public: + virtual HRESULT STDMETHODCALLTYPE StorePipeline( + _In_opt_ LPCWSTR pName, + _In_ ID3D12PipelineState *pPipeline) = 0; + + virtual HRESULT STDMETHODCALLTYPE LoadGraphicsPipeline( + _In_ LPCWSTR pName, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState) = 0; + + virtual HRESULT STDMETHODCALLTYPE LoadComputePipeline( + _In_ LPCWSTR pName, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState) = 0; + + virtual SIZE_T STDMETHODCALLTYPE GetSerializedSize( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE Serialize( + _Out_writes_(DataSizeInBytes) void *pData, + SIZE_T DataSizeInBytes) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12PipelineLibraryVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12PipelineLibrary * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12PipelineLibrary * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12PipelineLibrary * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12PipelineLibrary * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12PipelineLibrary * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12PipelineLibrary * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12PipelineLibrary * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12PipelineLibrary * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, StorePipeline) + HRESULT ( STDMETHODCALLTYPE *StorePipeline )( + ID3D12PipelineLibrary * This, + _In_opt_ LPCWSTR pName, + _In_ ID3D12PipelineState *pPipeline); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, LoadGraphicsPipeline) + HRESULT ( STDMETHODCALLTYPE *LoadGraphicsPipeline )( + ID3D12PipelineLibrary * This, + _In_ LPCWSTR pName, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, LoadComputePipeline) + HRESULT ( STDMETHODCALLTYPE *LoadComputePipeline )( + ID3D12PipelineLibrary * This, + _In_ LPCWSTR pName, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, GetSerializedSize) + SIZE_T ( STDMETHODCALLTYPE *GetSerializedSize )( + ID3D12PipelineLibrary * This); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, Serialize) + HRESULT ( STDMETHODCALLTYPE *Serialize )( + ID3D12PipelineLibrary * This, + _Out_writes_(DataSizeInBytes) void *pData, + SIZE_T DataSizeInBytes); + + END_INTERFACE + } ID3D12PipelineLibraryVtbl; + + interface ID3D12PipelineLibrary + { + CONST_VTBL struct ID3D12PipelineLibraryVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12PipelineLibrary_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12PipelineLibrary_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12PipelineLibrary_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12PipelineLibrary_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12PipelineLibrary_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12PipelineLibrary_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12PipelineLibrary_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12PipelineLibrary_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12PipelineLibrary_StorePipeline(This,pName,pPipeline) \ + ( (This)->lpVtbl -> StorePipeline(This,pName,pPipeline) ) + +#define ID3D12PipelineLibrary_LoadGraphicsPipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> LoadGraphicsPipeline(This,pName,pDesc,riid,ppPipelineState) ) + +#define ID3D12PipelineLibrary_LoadComputePipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> LoadComputePipeline(This,pName,pDesc,riid,ppPipelineState) ) + +#define ID3D12PipelineLibrary_GetSerializedSize(This) \ + ( (This)->lpVtbl -> GetSerializedSize(This) ) + +#define ID3D12PipelineLibrary_Serialize(This,pData,DataSizeInBytes) \ + ( (This)->lpVtbl -> Serialize(This,pData,DataSizeInBytes) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12PipelineLibrary_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12PipelineLibrary1_INTERFACE_DEFINED__ +#define __ID3D12PipelineLibrary1_INTERFACE_DEFINED__ + +/* interface ID3D12PipelineLibrary1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12PipelineLibrary1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("80eabf42-2568-4e5e-bd82-c37f86961dc3") + ID3D12PipelineLibrary1 : public ID3D12PipelineLibrary + { + public: + virtual HRESULT STDMETHODCALLTYPE LoadPipeline( + _In_ LPCWSTR pName, + _In_ const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12PipelineLibrary1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12PipelineLibrary1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12PipelineLibrary1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12PipelineLibrary1 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12PipelineLibrary1 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12PipelineLibrary1 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12PipelineLibrary1 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12PipelineLibrary1 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12PipelineLibrary1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, StorePipeline) + HRESULT ( STDMETHODCALLTYPE *StorePipeline )( + ID3D12PipelineLibrary1 * This, + _In_opt_ LPCWSTR pName, + _In_ ID3D12PipelineState *pPipeline); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, LoadGraphicsPipeline) + HRESULT ( STDMETHODCALLTYPE *LoadGraphicsPipeline )( + ID3D12PipelineLibrary1 * This, + _In_ LPCWSTR pName, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, LoadComputePipeline) + HRESULT ( STDMETHODCALLTYPE *LoadComputePipeline )( + ID3D12PipelineLibrary1 * This, + _In_ LPCWSTR pName, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, GetSerializedSize) + SIZE_T ( STDMETHODCALLTYPE *GetSerializedSize )( + ID3D12PipelineLibrary1 * This); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary, Serialize) + HRESULT ( STDMETHODCALLTYPE *Serialize )( + ID3D12PipelineLibrary1 * This, + _Out_writes_(DataSizeInBytes) void *pData, + SIZE_T DataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12PipelineLibrary1, LoadPipeline) + HRESULT ( STDMETHODCALLTYPE *LoadPipeline )( + ID3D12PipelineLibrary1 * This, + _In_ LPCWSTR pName, + _In_ const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + END_INTERFACE + } ID3D12PipelineLibrary1Vtbl; + + interface ID3D12PipelineLibrary1 + { + CONST_VTBL struct ID3D12PipelineLibrary1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12PipelineLibrary1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12PipelineLibrary1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12PipelineLibrary1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12PipelineLibrary1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12PipelineLibrary1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12PipelineLibrary1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12PipelineLibrary1_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12PipelineLibrary1_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12PipelineLibrary1_StorePipeline(This,pName,pPipeline) \ + ( (This)->lpVtbl -> StorePipeline(This,pName,pPipeline) ) + +#define ID3D12PipelineLibrary1_LoadGraphicsPipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> LoadGraphicsPipeline(This,pName,pDesc,riid,ppPipelineState) ) + +#define ID3D12PipelineLibrary1_LoadComputePipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> LoadComputePipeline(This,pName,pDesc,riid,ppPipelineState) ) + +#define ID3D12PipelineLibrary1_GetSerializedSize(This) \ + ( (This)->lpVtbl -> GetSerializedSize(This) ) + +#define ID3D12PipelineLibrary1_Serialize(This,pData,DataSizeInBytes) \ + ( (This)->lpVtbl -> Serialize(This,pData,DataSizeInBytes) ) + + +#define ID3D12PipelineLibrary1_LoadPipeline(This,pName,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> LoadPipeline(This,pName,pDesc,riid,ppPipelineState) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12PipelineLibrary1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0023 */ +/* [local] */ + +typedef +enum D3D12_MULTIPLE_FENCE_WAIT_FLAGS + { + D3D12_MULTIPLE_FENCE_WAIT_FLAG_NONE = 0, + D3D12_MULTIPLE_FENCE_WAIT_FLAG_ANY = 0x1, + D3D12_MULTIPLE_FENCE_WAIT_FLAG_ALL = 0 + } D3D12_MULTIPLE_FENCE_WAIT_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_MULTIPLE_FENCE_WAIT_FLAGS ) +typedef +enum D3D12_RESIDENCY_PRIORITY + { + D3D12_RESIDENCY_PRIORITY_MINIMUM = 0x28000000, + D3D12_RESIDENCY_PRIORITY_LOW = 0x50000000, + D3D12_RESIDENCY_PRIORITY_NORMAL = 0x78000000, + D3D12_RESIDENCY_PRIORITY_HIGH = 0xa0010000, + D3D12_RESIDENCY_PRIORITY_MAXIMUM = 0xc8000000 + } D3D12_RESIDENCY_PRIORITY; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0023_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0023_v0_0_s_ifspec; + +#ifndef __ID3D12Device1_INTERFACE_DEFINED__ +#define __ID3D12Device1_INTERFACE_DEFINED__ + +/* interface ID3D12Device1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("77acce80-638e-4e65-8895-c1f23386863e") + ID3D12Device1 : public ID3D12Device + { + public: + virtual HRESULT STDMETHODCALLTYPE CreatePipelineLibrary( + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetEventOnMultipleFenceCompletion( + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetResidencyPriority( + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device1 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device1 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device1 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device1 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device1 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device1 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device1 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device1 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device1 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device1 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device1 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device1 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device1 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device1 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device1 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device1 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device1 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device1 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device1 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device1 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device1 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device1 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device1 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device1 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device1 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device1 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device1 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device1 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device1 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device1 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device1 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device1 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device1 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device1 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device1 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device1 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device1 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device1 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device1 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device1 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device1 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device1 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device1 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device1 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device1 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device1 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device1 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device1 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + END_INTERFACE + } ID3D12Device1Vtbl; + + interface ID3D12Device1 + { + CONST_VTBL struct ID3D12Device1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device1_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device1_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device1_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device1_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device1_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device1_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device1_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device1_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device1_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device1_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device1_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device1_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device1_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device1_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device1_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device1_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device1_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device1_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device1_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device1_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device1_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device1_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device1_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device1_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device1_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device1_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device1_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device1_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device1_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device1_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device1_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device1_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device1_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device1_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device1_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device1_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device1_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device1_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device1_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device1_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device1_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device1_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device1_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device1_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device2_INTERFACE_DEFINED__ +#define __ID3D12Device2_INTERFACE_DEFINED__ + +/* interface ID3D12Device2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("30baa41e-b15b-475c-a0bb-1af5c5b64328") + ID3D12Device2 : public ID3D12Device1 + { + public: + virtual HRESULT STDMETHODCALLTYPE CreatePipelineState( + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device2 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device2 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device2 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device2 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device2 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device2 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device2 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device2 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device2 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device2 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device2 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device2 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device2 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device2 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device2 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device2 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device2 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device2 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device2 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device2 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device2 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device2 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device2 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device2 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device2 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device2 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device2 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device2 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device2 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device2 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device2 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device2 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device2 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device2 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device2 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device2 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device2 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device2 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device2 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device2 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device2 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device2 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device2 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device2 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device2 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device2 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device2 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device2 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device2 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + END_INTERFACE + } ID3D12Device2Vtbl; + + interface ID3D12Device2 + { + CONST_VTBL struct ID3D12Device2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device2_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device2_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device2_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device2_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device2_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device2_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device2_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device2_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device2_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device2_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device2_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device2_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device2_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device2_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device2_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device2_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device2_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device2_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device2_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device2_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device2_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device2_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device2_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device2_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device2_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device2_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device2_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device2_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device2_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device2_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device2_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device2_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device2_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device2_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device2_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device2_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device2_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device2_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device2_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device2_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device2_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device2_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device2_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device2_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device2_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device2_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device2_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device2_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device2_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0025 */ +/* [local] */ + +typedef +enum D3D12_RESIDENCY_FLAGS + { + D3D12_RESIDENCY_FLAG_NONE = 0, + D3D12_RESIDENCY_FLAG_DENY_OVERBUDGET = 0x1 + } D3D12_RESIDENCY_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RESIDENCY_FLAGS ) + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0025_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0025_v0_0_s_ifspec; + +#ifndef __ID3D12Device3_INTERFACE_DEFINED__ +#define __ID3D12Device3_INTERFACE_DEFINED__ + +/* interface ID3D12Device3 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device3; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("81dadc15-2bad-4392-93c5-101345c4aa98") + ID3D12Device3 : public ID3D12Device2 + { + public: + virtual HRESULT STDMETHODCALLTYPE OpenExistingHeapFromAddress( + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap) = 0; + + virtual HRESULT STDMETHODCALLTYPE OpenExistingHeapFromFileMapping( + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnqueueMakeResident( + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device3Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device3 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device3 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device3 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device3 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device3 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device3 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device3 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device3 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device3 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device3 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device3 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device3 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device3 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device3 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device3 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device3 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device3 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device3 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device3 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device3 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device3 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device3 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device3 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device3 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device3 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device3 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device3 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device3 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device3 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device3 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device3 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device3 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device3 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device3 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device3 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device3 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device3 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device3 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device3 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device3 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device3 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device3 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device3 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device3 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device3 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device3 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device3 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device3 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device3 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device3 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device3 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device3 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device3 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device3 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + END_INTERFACE + } ID3D12Device3Vtbl; + + interface ID3D12Device3 + { + CONST_VTBL struct ID3D12Device3Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device3_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device3_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device3_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device3_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device3_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device3_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device3_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device3_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device3_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device3_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device3_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device3_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device3_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device3_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device3_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device3_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device3_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device3_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device3_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device3_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device3_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device3_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device3_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device3_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device3_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device3_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device3_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device3_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device3_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device3_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device3_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device3_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device3_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device3_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device3_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device3_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device3_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device3_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device3_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device3_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device3_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device3_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device3_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device3_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device3_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device3_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device3_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device3_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device3_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device3_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device3_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device3_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device3_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device3_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device3_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0026 */ +/* [local] */ + +typedef +enum D3D12_COMMAND_LIST_FLAGS + { + D3D12_COMMAND_LIST_FLAG_NONE = 0 + } D3D12_COMMAND_LIST_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_LIST_FLAGS ) +typedef +enum D3D12_COMMAND_POOL_FLAGS + { + D3D12_COMMAND_POOL_FLAG_NONE = 0 + } D3D12_COMMAND_POOL_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_POOL_FLAGS ) +typedef +enum D3D12_COMMAND_RECORDER_FLAGS + { + D3D12_COMMAND_RECORDER_FLAG_NONE = 0 + } D3D12_COMMAND_RECORDER_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_COMMAND_RECORDER_FLAGS ) +typedef +enum D3D12_PROTECTED_SESSION_STATUS + { + D3D12_PROTECTED_SESSION_STATUS_OK = 0, + D3D12_PROTECTED_SESSION_STATUS_INVALID = 1 + } D3D12_PROTECTED_SESSION_STATUS; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0026_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0026_v0_0_s_ifspec; + +#ifndef __ID3D12ProtectedSession_INTERFACE_DEFINED__ +#define __ID3D12ProtectedSession_INTERFACE_DEFINED__ + +/* interface ID3D12ProtectedSession */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12ProtectedSession; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("A1533D18-0AC1-4084-85B9-89A96116806B") + ID3D12ProtectedSession : public ID3D12DeviceChild + { + public: + virtual HRESULT STDMETHODCALLTYPE GetStatusFence( + REFIID riid, + _COM_Outptr_opt_ void **ppFence) = 0; + + virtual D3D12_PROTECTED_SESSION_STATUS STDMETHODCALLTYPE GetSessionStatus( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ProtectedSessionVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12ProtectedSession * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12ProtectedSession * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12ProtectedSession * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12ProtectedSession * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12ProtectedSession * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12ProtectedSession * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12ProtectedSession * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12ProtectedSession * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12ProtectedSession, GetStatusFence) + HRESULT ( STDMETHODCALLTYPE *GetStatusFence )( + ID3D12ProtectedSession * This, + REFIID riid, + _COM_Outptr_opt_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12ProtectedSession, GetSessionStatus) + D3D12_PROTECTED_SESSION_STATUS ( STDMETHODCALLTYPE *GetSessionStatus )( + ID3D12ProtectedSession * This); + + END_INTERFACE + } ID3D12ProtectedSessionVtbl; + + interface ID3D12ProtectedSession + { + CONST_VTBL struct ID3D12ProtectedSessionVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12ProtectedSession_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12ProtectedSession_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12ProtectedSession_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12ProtectedSession_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12ProtectedSession_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12ProtectedSession_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12ProtectedSession_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12ProtectedSession_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12ProtectedSession_GetStatusFence(This,riid,ppFence) \ + ( (This)->lpVtbl -> GetStatusFence(This,riid,ppFence) ) + +#define ID3D12ProtectedSession_GetSessionStatus(This) \ + ( (This)->lpVtbl -> GetSessionStatus(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12ProtectedSession_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0027 */ +/* [local] */ + +typedef +enum D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS + { + D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG_NONE = 0, + D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAG_SUPPORTED = 0x1 + } D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS ) +typedef struct D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_SUPPORT + { + UINT NodeIndex; + D3D12_PROTECTED_RESOURCE_SESSION_SUPPORT_FLAGS Support; + } D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_SUPPORT; + +typedef +enum D3D12_PROTECTED_RESOURCE_SESSION_FLAGS + { + D3D12_PROTECTED_RESOURCE_SESSION_FLAG_NONE = 0 + } D3D12_PROTECTED_RESOURCE_SESSION_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_PROTECTED_RESOURCE_SESSION_FLAGS ) +typedef struct D3D12_PROTECTED_RESOURCE_SESSION_DESC + { + UINT NodeMask; + D3D12_PROTECTED_RESOURCE_SESSION_FLAGS Flags; + } D3D12_PROTECTED_RESOURCE_SESSION_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0027_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0027_v0_0_s_ifspec; + +#ifndef __ID3D12ProtectedResourceSession_INTERFACE_DEFINED__ +#define __ID3D12ProtectedResourceSession_INTERFACE_DEFINED__ + +/* interface ID3D12ProtectedResourceSession */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12ProtectedResourceSession; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("6CD696F4-F289-40CC-8091-5A6C0A099C3D") + ID3D12ProtectedResourceSession : public ID3D12ProtectedSession + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_PROTECTED_RESOURCE_SESSION_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_PROTECTED_RESOURCE_SESSION_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_PROTECTED_RESOURCE_SESSION_DESC * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ProtectedResourceSessionVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12ProtectedResourceSession * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12ProtectedResourceSession * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12ProtectedResourceSession * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12ProtectedResourceSession * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12ProtectedResourceSession * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12ProtectedResourceSession * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12ProtectedResourceSession * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12ProtectedResourceSession * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12ProtectedSession, GetStatusFence) + HRESULT ( STDMETHODCALLTYPE *GetStatusFence )( + ID3D12ProtectedResourceSession * This, + REFIID riid, + _COM_Outptr_opt_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12ProtectedSession, GetSessionStatus) + D3D12_PROTECTED_SESSION_STATUS ( STDMETHODCALLTYPE *GetSessionStatus )( + ID3D12ProtectedResourceSession * This); + + DECLSPEC_XFGVIRT(ID3D12ProtectedResourceSession, GetDesc) +#if !defined(_WIN32) + D3D12_PROTECTED_RESOURCE_SESSION_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12ProtectedResourceSession * This); + +#else + D3D12_PROTECTED_RESOURCE_SESSION_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12ProtectedResourceSession * This, + D3D12_PROTECTED_RESOURCE_SESSION_DESC * RetVal); + +#endif + + END_INTERFACE + } ID3D12ProtectedResourceSessionVtbl; + + interface ID3D12ProtectedResourceSession + { + CONST_VTBL struct ID3D12ProtectedResourceSessionVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12ProtectedResourceSession_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12ProtectedResourceSession_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12ProtectedResourceSession_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12ProtectedResourceSession_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12ProtectedResourceSession_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12ProtectedResourceSession_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12ProtectedResourceSession_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12ProtectedResourceSession_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12ProtectedResourceSession_GetStatusFence(This,riid,ppFence) \ + ( (This)->lpVtbl -> GetStatusFence(This,riid,ppFence) ) + +#define ID3D12ProtectedResourceSession_GetSessionStatus(This) \ + ( (This)->lpVtbl -> GetSessionStatus(This) ) + +#if !defined(_WIN32) + +#define ID3D12ProtectedResourceSession_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12ProtectedResourceSession_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12ProtectedResourceSession_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device4_INTERFACE_DEFINED__ +#define __ID3D12Device4_INTERFACE_DEFINED__ + +/* interface ID3D12Device4 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device4; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("e865df17-a9ee-46f9-a463-3098315aa2e5") + ID3D12Device4 : public ID3D12Device3 + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateCommandList1( + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateProtectedResourceSession( + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateCommittedResource1( + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateHeap1( + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateReservedResource1( + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_RESOURCE_ALLOCATION_INFO STDMETHODCALLTYPE GetResourceAllocationInfo1( + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1) = 0; +#else + virtual D3D12_RESOURCE_ALLOCATION_INFO *STDMETHODCALLTYPE GetResourceAllocationInfo1( + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device4Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device4 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device4 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device4 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device4 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device4 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device4 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device4 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device4 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device4 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device4 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device4 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device4 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device4 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device4 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device4 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device4 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device4 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device4 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device4 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device4 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device4 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device4 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device4 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device4 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device4 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device4 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device4 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device4 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device4 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device4 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device4 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device4 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device4 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device4 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device4 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device4 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device4 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device4 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device4 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device4 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device4 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device4 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device4 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device4 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device4 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device4 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device4 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device4 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device4 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device4 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device4 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device4 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device4 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device4 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device4 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device4 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device4 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device4 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device4 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device4 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device4 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + END_INTERFACE + } ID3D12Device4Vtbl; + + interface ID3D12Device4 + { + CONST_VTBL struct ID3D12Device4Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device4_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device4_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device4_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device4_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device4_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device4_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device4_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device4_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device4_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device4_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device4_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device4_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device4_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device4_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device4_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device4_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device4_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device4_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device4_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device4_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device4_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device4_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device4_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device4_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device4_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device4_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device4_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device4_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device4_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device4_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device4_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device4_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device4_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device4_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device4_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device4_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device4_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device4_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device4_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device4_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device4_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device4_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device4_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device4_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device4_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device4_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device4_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device4_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device4_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device4_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device4_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device4_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device4_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device4_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device4_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device4_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device4_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device4_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device4_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device4_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device4_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device4_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0029 */ +/* [local] */ + +typedef +enum D3D12_LIFETIME_STATE + { + D3D12_LIFETIME_STATE_IN_USE = 0, + D3D12_LIFETIME_STATE_NOT_IN_USE = ( D3D12_LIFETIME_STATE_IN_USE + 1 ) + } D3D12_LIFETIME_STATE; + + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0029_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0029_v0_0_s_ifspec; + +#ifndef __ID3D12LifetimeOwner_INTERFACE_DEFINED__ +#define __ID3D12LifetimeOwner_INTERFACE_DEFINED__ + +/* interface ID3D12LifetimeOwner */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12LifetimeOwner; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("e667af9f-cd56-4f46-83ce-032e595d70a8") + ID3D12LifetimeOwner : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE LifetimeStateUpdated( + D3D12_LIFETIME_STATE NewState) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12LifetimeOwnerVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12LifetimeOwner * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12LifetimeOwner * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12LifetimeOwner * This); + + DECLSPEC_XFGVIRT(ID3D12LifetimeOwner, LifetimeStateUpdated) + void ( STDMETHODCALLTYPE *LifetimeStateUpdated )( + ID3D12LifetimeOwner * This, + D3D12_LIFETIME_STATE NewState); + + END_INTERFACE + } ID3D12LifetimeOwnerVtbl; + + interface ID3D12LifetimeOwner + { + CONST_VTBL struct ID3D12LifetimeOwnerVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12LifetimeOwner_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12LifetimeOwner_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12LifetimeOwner_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12LifetimeOwner_LifetimeStateUpdated(This,NewState) \ + ( (This)->lpVtbl -> LifetimeStateUpdated(This,NewState) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12LifetimeOwner_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12SwapChainAssistant_INTERFACE_DEFINED__ +#define __ID3D12SwapChainAssistant_INTERFACE_DEFINED__ + +/* interface ID3D12SwapChainAssistant */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12SwapChainAssistant; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("f1df64b6-57fd-49cd-8807-c0eb88b45c8f") + ID3D12SwapChainAssistant : public IUnknown + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual LUID STDMETHODCALLTYPE GetLUID( void) = 0; +#else + virtual LUID *STDMETHODCALLTYPE GetLUID( + LUID * RetVal) = 0; +#endif + + virtual HRESULT STDMETHODCALLTYPE GetSwapChainObject( + REFIID riid, + _COM_Outptr_ void **ppv) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetCurrentResourceAndCommandQueue( + REFIID riidResource, + _COM_Outptr_ void **ppvResource, + REFIID riidQueue, + _COM_Outptr_ void **ppvQueue) = 0; + + virtual HRESULT STDMETHODCALLTYPE InsertImplicitSync( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12SwapChainAssistantVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12SwapChainAssistant * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12SwapChainAssistant * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12SwapChainAssistant * This); + + DECLSPEC_XFGVIRT(ID3D12SwapChainAssistant, GetLUID) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetLUID )( + ID3D12SwapChainAssistant * This); + +#else + LUID *( STDMETHODCALLTYPE *GetLUID )( + ID3D12SwapChainAssistant * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12SwapChainAssistant, GetSwapChainObject) + HRESULT ( STDMETHODCALLTYPE *GetSwapChainObject )( + ID3D12SwapChainAssistant * This, + REFIID riid, + _COM_Outptr_ void **ppv); + + DECLSPEC_XFGVIRT(ID3D12SwapChainAssistant, GetCurrentResourceAndCommandQueue) + HRESULT ( STDMETHODCALLTYPE *GetCurrentResourceAndCommandQueue )( + ID3D12SwapChainAssistant * This, + REFIID riidResource, + _COM_Outptr_ void **ppvResource, + REFIID riidQueue, + _COM_Outptr_ void **ppvQueue); + + DECLSPEC_XFGVIRT(ID3D12SwapChainAssistant, InsertImplicitSync) + HRESULT ( STDMETHODCALLTYPE *InsertImplicitSync )( + ID3D12SwapChainAssistant * This); + + END_INTERFACE + } ID3D12SwapChainAssistantVtbl; + + interface ID3D12SwapChainAssistant + { + CONST_VTBL struct ID3D12SwapChainAssistantVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12SwapChainAssistant_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12SwapChainAssistant_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12SwapChainAssistant_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + +#if !defined(_WIN32) + +#define ID3D12SwapChainAssistant_GetLUID(This) \ + ( (This)->lpVtbl -> GetLUID(This) ) +#else +#define ID3D12SwapChainAssistant_GetLUID(This,RetVal) \ + ( (This)->lpVtbl -> GetLUID(This,RetVal) ) +#endif + +#define ID3D12SwapChainAssistant_GetSwapChainObject(This,riid,ppv) \ + ( (This)->lpVtbl -> GetSwapChainObject(This,riid,ppv) ) + +#define ID3D12SwapChainAssistant_GetCurrentResourceAndCommandQueue(This,riidResource,ppvResource,riidQueue,ppvQueue) \ + ( (This)->lpVtbl -> GetCurrentResourceAndCommandQueue(This,riidResource,ppvResource,riidQueue,ppvQueue) ) + +#define ID3D12SwapChainAssistant_InsertImplicitSync(This) \ + ( (This)->lpVtbl -> InsertImplicitSync(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12SwapChainAssistant_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12LifetimeTracker_INTERFACE_DEFINED__ +#define __ID3D12LifetimeTracker_INTERFACE_DEFINED__ + +/* interface ID3D12LifetimeTracker */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12LifetimeTracker; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("3fd03d36-4eb1-424a-a582-494ecb8ba813") + ID3D12LifetimeTracker : public ID3D12DeviceChild + { + public: + virtual HRESULT STDMETHODCALLTYPE DestroyOwnedObject( + _In_ ID3D12DeviceChild *pObject) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12LifetimeTrackerVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12LifetimeTracker * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12LifetimeTracker * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12LifetimeTracker * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12LifetimeTracker * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12LifetimeTracker * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12LifetimeTracker * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12LifetimeTracker * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12LifetimeTracker * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12LifetimeTracker, DestroyOwnedObject) + HRESULT ( STDMETHODCALLTYPE *DestroyOwnedObject )( + ID3D12LifetimeTracker * This, + _In_ ID3D12DeviceChild *pObject); + + END_INTERFACE + } ID3D12LifetimeTrackerVtbl; + + interface ID3D12LifetimeTracker + { + CONST_VTBL struct ID3D12LifetimeTrackerVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12LifetimeTracker_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12LifetimeTracker_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12LifetimeTracker_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12LifetimeTracker_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12LifetimeTracker_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12LifetimeTracker_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12LifetimeTracker_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12LifetimeTracker_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12LifetimeTracker_DestroyOwnedObject(This,pObject) \ + ( (This)->lpVtbl -> DestroyOwnedObject(This,pObject) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12LifetimeTracker_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0032 */ +/* [local] */ + +typedef +enum D3D12_META_COMMAND_PARAMETER_TYPE + { + D3D12_META_COMMAND_PARAMETER_TYPE_FLOAT = 0, + D3D12_META_COMMAND_PARAMETER_TYPE_UINT64 = 1, + D3D12_META_COMMAND_PARAMETER_TYPE_GPU_VIRTUAL_ADDRESS = 2, + D3D12_META_COMMAND_PARAMETER_TYPE_CPU_DESCRIPTOR_HANDLE_HEAP_TYPE_CBV_SRV_UAV = 3, + D3D12_META_COMMAND_PARAMETER_TYPE_GPU_DESCRIPTOR_HANDLE_HEAP_TYPE_CBV_SRV_UAV = 4 + } D3D12_META_COMMAND_PARAMETER_TYPE; + +typedef +enum D3D12_META_COMMAND_PARAMETER_FLAGS + { + D3D12_META_COMMAND_PARAMETER_FLAG_INPUT = 0x1, + D3D12_META_COMMAND_PARAMETER_FLAG_OUTPUT = 0x2 + } D3D12_META_COMMAND_PARAMETER_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_META_COMMAND_PARAMETER_FLAGS ) +typedef +enum D3D12_META_COMMAND_PARAMETER_STAGE + { + D3D12_META_COMMAND_PARAMETER_STAGE_CREATION = 0, + D3D12_META_COMMAND_PARAMETER_STAGE_INITIALIZATION = 1, + D3D12_META_COMMAND_PARAMETER_STAGE_EXECUTION = 2 + } D3D12_META_COMMAND_PARAMETER_STAGE; + +typedef struct D3D12_META_COMMAND_PARAMETER_DESC + { + LPCWSTR Name; + D3D12_META_COMMAND_PARAMETER_TYPE Type; + D3D12_META_COMMAND_PARAMETER_FLAGS Flags; + D3D12_RESOURCE_STATES RequiredResourceState; + UINT StructureOffset; + } D3D12_META_COMMAND_PARAMETER_DESC; + +typedef +enum D3D12_GRAPHICS_STATES + { + D3D12_GRAPHICS_STATE_NONE = 0, + D3D12_GRAPHICS_STATE_IA_VERTEX_BUFFERS = ( 1 << 0 ) , + D3D12_GRAPHICS_STATE_IA_INDEX_BUFFER = ( 1 << 1 ) , + D3D12_GRAPHICS_STATE_IA_PRIMITIVE_TOPOLOGY = ( 1 << 2 ) , + D3D12_GRAPHICS_STATE_DESCRIPTOR_HEAP = ( 1 << 3 ) , + D3D12_GRAPHICS_STATE_GRAPHICS_ROOT_SIGNATURE = ( 1 << 4 ) , + D3D12_GRAPHICS_STATE_COMPUTE_ROOT_SIGNATURE = ( 1 << 5 ) , + D3D12_GRAPHICS_STATE_RS_VIEWPORTS = ( 1 << 6 ) , + D3D12_GRAPHICS_STATE_RS_SCISSOR_RECTS = ( 1 << 7 ) , + D3D12_GRAPHICS_STATE_PREDICATION = ( 1 << 8 ) , + D3D12_GRAPHICS_STATE_OM_RENDER_TARGETS = ( 1 << 9 ) , + D3D12_GRAPHICS_STATE_OM_STENCIL_REF = ( 1 << 10 ) , + D3D12_GRAPHICS_STATE_OM_BLEND_FACTOR = ( 1 << 11 ) , + D3D12_GRAPHICS_STATE_PIPELINE_STATE = ( 1 << 12 ) , + D3D12_GRAPHICS_STATE_SO_TARGETS = ( 1 << 13 ) , + D3D12_GRAPHICS_STATE_OM_DEPTH_BOUNDS = ( 1 << 14 ) , + D3D12_GRAPHICS_STATE_SAMPLE_POSITIONS = ( 1 << 15 ) , + D3D12_GRAPHICS_STATE_VIEW_INSTANCE_MASK = ( 1 << 16 ) + } D3D12_GRAPHICS_STATES; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_GRAPHICS_STATES ) +typedef struct D3D12_META_COMMAND_DESC + { + GUID Id; + LPCWSTR Name; + D3D12_GRAPHICS_STATES InitializationDirtyState; + D3D12_GRAPHICS_STATES ExecutionDirtyState; + } D3D12_META_COMMAND_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0032_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0032_v0_0_s_ifspec; + +#ifndef __ID3D12StateObject_INTERFACE_DEFINED__ +#define __ID3D12StateObject_INTERFACE_DEFINED__ + +/* interface ID3D12StateObject */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12StateObject; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("47016943-fca8-4594-93ea-af258b55346d") + ID3D12StateObject : public ID3D12Pageable + { + public: + }; + + +#else /* C style interface */ + + typedef struct ID3D12StateObjectVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12StateObject * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12StateObject * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12StateObject * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12StateObject * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12StateObject * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12StateObject * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12StateObject * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12StateObject * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12StateObjectVtbl; + + interface ID3D12StateObject + { + CONST_VTBL struct ID3D12StateObjectVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12StateObject_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12StateObject_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12StateObject_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12StateObject_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12StateObject_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12StateObject_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12StateObject_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12StateObject_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12StateObject_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12StateObjectProperties_INTERFACE_DEFINED__ +#define __ID3D12StateObjectProperties_INTERFACE_DEFINED__ + +/* interface ID3D12StateObjectProperties */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12StateObjectProperties; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("de5fa827-9bf9-4f26-89ff-d7f56fde3860") + ID3D12StateObjectProperties : public IUnknown + { + public: + virtual void *STDMETHODCALLTYPE GetShaderIdentifier( + _In_ LPCWSTR pExportName) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetShaderStackSize( + _In_ LPCWSTR pExportName) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetPipelineStackSize( void) = 0; + + virtual void STDMETHODCALLTYPE SetPipelineStackSize( + UINT64 PipelineStackSizeInBytes) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12StateObjectPropertiesVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12StateObjectProperties * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12StateObjectProperties * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12StateObjectProperties * This); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetShaderIdentifier) + void *( STDMETHODCALLTYPE *GetShaderIdentifier )( + ID3D12StateObjectProperties * This, + _In_ LPCWSTR pExportName); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetShaderStackSize) + UINT64 ( STDMETHODCALLTYPE *GetShaderStackSize )( + ID3D12StateObjectProperties * This, + _In_ LPCWSTR pExportName); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetPipelineStackSize) + UINT64 ( STDMETHODCALLTYPE *GetPipelineStackSize )( + ID3D12StateObjectProperties * This); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, SetPipelineStackSize) + void ( STDMETHODCALLTYPE *SetPipelineStackSize )( + ID3D12StateObjectProperties * This, + UINT64 PipelineStackSizeInBytes); + + END_INTERFACE + } ID3D12StateObjectPropertiesVtbl; + + interface ID3D12StateObjectProperties + { + CONST_VTBL struct ID3D12StateObjectPropertiesVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12StateObjectProperties_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12StateObjectProperties_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12StateObjectProperties_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12StateObjectProperties_GetShaderIdentifier(This,pExportName) \ + ( (This)->lpVtbl -> GetShaderIdentifier(This,pExportName) ) + +#define ID3D12StateObjectProperties_GetShaderStackSize(This,pExportName) \ + ( (This)->lpVtbl -> GetShaderStackSize(This,pExportName) ) + +#define ID3D12StateObjectProperties_GetPipelineStackSize(This) \ + ( (This)->lpVtbl -> GetPipelineStackSize(This) ) + +#define ID3D12StateObjectProperties_SetPipelineStackSize(This,PipelineStackSizeInBytes) \ + ( (This)->lpVtbl -> SetPipelineStackSize(This,PipelineStackSizeInBytes) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12StateObjectProperties_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0034 */ +/* [local] */ + +typedef struct D3D12_PROGRAM_IDENTIFIER + { + UINT64 OpaqueData[ 4 ]; + } D3D12_PROGRAM_IDENTIFIER; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0034_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0034_v0_0_s_ifspec; + +#ifndef __ID3D12StateObjectProperties1_INTERFACE_DEFINED__ +#define __ID3D12StateObjectProperties1_INTERFACE_DEFINED__ + +/* interface ID3D12StateObjectProperties1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12StateObjectProperties1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("460caac7-1d24-446a-a184-ca67db494138") + ID3D12StateObjectProperties1 : public ID3D12StateObjectProperties + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_PROGRAM_IDENTIFIER STDMETHODCALLTYPE GetProgramIdentifier( + LPCWSTR pProgramName) = 0; +#else + virtual D3D12_PROGRAM_IDENTIFIER *STDMETHODCALLTYPE GetProgramIdentifier( + D3D12_PROGRAM_IDENTIFIER * RetVal, + LPCWSTR pProgramName) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12StateObjectProperties1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12StateObjectProperties1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12StateObjectProperties1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12StateObjectProperties1 * This); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetShaderIdentifier) + void *( STDMETHODCALLTYPE *GetShaderIdentifier )( + ID3D12StateObjectProperties1 * This, + _In_ LPCWSTR pExportName); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetShaderStackSize) + UINT64 ( STDMETHODCALLTYPE *GetShaderStackSize )( + ID3D12StateObjectProperties1 * This, + _In_ LPCWSTR pExportName); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, GetPipelineStackSize) + UINT64 ( STDMETHODCALLTYPE *GetPipelineStackSize )( + ID3D12StateObjectProperties1 * This); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties, SetPipelineStackSize) + void ( STDMETHODCALLTYPE *SetPipelineStackSize )( + ID3D12StateObjectProperties1 * This, + UINT64 PipelineStackSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12StateObjectProperties1, GetProgramIdentifier) +#if !defined(_WIN32) + D3D12_PROGRAM_IDENTIFIER ( STDMETHODCALLTYPE *GetProgramIdentifier )( + ID3D12StateObjectProperties1 * This, + LPCWSTR pProgramName); + +#else + D3D12_PROGRAM_IDENTIFIER *( STDMETHODCALLTYPE *GetProgramIdentifier )( + ID3D12StateObjectProperties1 * This, + D3D12_PROGRAM_IDENTIFIER * RetVal, + LPCWSTR pProgramName); + +#endif + + END_INTERFACE + } ID3D12StateObjectProperties1Vtbl; + + interface ID3D12StateObjectProperties1 + { + CONST_VTBL struct ID3D12StateObjectProperties1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12StateObjectProperties1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12StateObjectProperties1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12StateObjectProperties1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12StateObjectProperties1_GetShaderIdentifier(This,pExportName) \ + ( (This)->lpVtbl -> GetShaderIdentifier(This,pExportName) ) + +#define ID3D12StateObjectProperties1_GetShaderStackSize(This,pExportName) \ + ( (This)->lpVtbl -> GetShaderStackSize(This,pExportName) ) + +#define ID3D12StateObjectProperties1_GetPipelineStackSize(This) \ + ( (This)->lpVtbl -> GetPipelineStackSize(This) ) + +#define ID3D12StateObjectProperties1_SetPipelineStackSize(This,PipelineStackSizeInBytes) \ + ( (This)->lpVtbl -> SetPipelineStackSize(This,PipelineStackSizeInBytes) ) + +#if !defined(_WIN32) + +#define ID3D12StateObjectProperties1_GetProgramIdentifier(This,pProgramName) \ + ( (This)->lpVtbl -> GetProgramIdentifier(This,pProgramName) ) +#else +#define ID3D12StateObjectProperties1_GetProgramIdentifier(This,RetVal,pProgramName) \ + ( (This)->lpVtbl -> GetProgramIdentifier(This,RetVal,pProgramName) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12StateObjectProperties1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0035 */ +/* [local] */ + +typedef struct D3D12_NODE_ID + { + LPCWSTR Name; + UINT ArrayIndex; + } D3D12_NODE_ID; + +typedef struct D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS + { + UINT64 MinSizeInBytes; + UINT64 MaxSizeInBytes; + UINT SizeGranularityInBytes; + } D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0035_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0035_v0_0_s_ifspec; + +#ifndef __ID3D12WorkGraphProperties_INTERFACE_DEFINED__ +#define __ID3D12WorkGraphProperties_INTERFACE_DEFINED__ + +/* interface ID3D12WorkGraphProperties */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12WorkGraphProperties; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("065acf71-f863-4b89-82f4-02e4d5886757") + ID3D12WorkGraphProperties : public IUnknown + { + public: + virtual UINT STDMETHODCALLTYPE GetNumWorkGraphs( void) = 0; + + virtual LPCWSTR STDMETHODCALLTYPE GetProgramName( + UINT WorkGraphIndex) = 0; + + virtual UINT STDMETHODCALLTYPE GetWorkGraphIndex( + LPCWSTR pProgramName) = 0; + + virtual UINT STDMETHODCALLTYPE GetNumNodes( + UINT WorkGraphIndex) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_NODE_ID STDMETHODCALLTYPE GetNodeID( + UINT WorkGraphIndex, + UINT NodeIndex) = 0; +#else + virtual D3D12_NODE_ID *STDMETHODCALLTYPE GetNodeID( + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT NodeIndex) = 0; +#endif + + virtual UINT STDMETHODCALLTYPE GetNodeIndex( + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID) = 0; + + virtual UINT STDMETHODCALLTYPE GetNodeLocalRootArgumentsTableIndex( + UINT WorkGraphIndex, + UINT NodeIndex) = 0; + + virtual UINT STDMETHODCALLTYPE GetNumEntrypoints( + UINT WorkGraphIndex) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_NODE_ID STDMETHODCALLTYPE GetEntrypointID( + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; +#else + virtual D3D12_NODE_ID *STDMETHODCALLTYPE GetEntrypointID( + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; +#endif + + virtual UINT STDMETHODCALLTYPE GetEntrypointIndex( + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID) = 0; + + virtual UINT STDMETHODCALLTYPE GetEntrypointRecordSizeInBytes( + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; + + virtual void STDMETHODCALLTYPE GetWorkGraphMemoryRequirements( + UINT WorkGraphIndex, + _Out_ D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS *pWorkGraphMemoryRequirements) = 0; + + virtual UINT STDMETHODCALLTYPE GetEntrypointRecordAlignmentInBytes( + UINT WorkGraphIndex, + UINT EntrypointIndex) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12WorkGraphPropertiesVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12WorkGraphProperties * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12WorkGraphProperties * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12WorkGraphProperties * This); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNumWorkGraphs) + UINT ( STDMETHODCALLTYPE *GetNumWorkGraphs )( + ID3D12WorkGraphProperties * This); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetProgramName) + LPCWSTR ( STDMETHODCALLTYPE *GetProgramName )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetWorkGraphIndex) + UINT ( STDMETHODCALLTYPE *GetWorkGraphIndex )( + ID3D12WorkGraphProperties * This, + LPCWSTR pProgramName); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNumNodes) + UINT ( STDMETHODCALLTYPE *GetNumNodes )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNodeID) +#if !defined(_WIN32) + D3D12_NODE_ID ( STDMETHODCALLTYPE *GetNodeID )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT NodeIndex); + +#else + D3D12_NODE_ID *( STDMETHODCALLTYPE *GetNodeID )( + ID3D12WorkGraphProperties * This, + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT NodeIndex); + +#endif + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNodeIndex) + UINT ( STDMETHODCALLTYPE *GetNodeIndex )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNodeLocalRootArgumentsTableIndex) + UINT ( STDMETHODCALLTYPE *GetNodeLocalRootArgumentsTableIndex )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT NodeIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetNumEntrypoints) + UINT ( STDMETHODCALLTYPE *GetNumEntrypoints )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointID) +#if !defined(_WIN32) + D3D12_NODE_ID ( STDMETHODCALLTYPE *GetEntrypointID )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT EntrypointIndex); + +#else + D3D12_NODE_ID *( STDMETHODCALLTYPE *GetEntrypointID )( + ID3D12WorkGraphProperties * This, + D3D12_NODE_ID * RetVal, + UINT WorkGraphIndex, + UINT EntrypointIndex); + +#endif + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointIndex) + UINT ( STDMETHODCALLTYPE *GetEntrypointIndex )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + D3D12_NODE_ID NodeID); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointRecordSizeInBytes) + UINT ( STDMETHODCALLTYPE *GetEntrypointRecordSizeInBytes )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT EntrypointIndex); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetWorkGraphMemoryRequirements) + void ( STDMETHODCALLTYPE *GetWorkGraphMemoryRequirements )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + _Out_ D3D12_WORK_GRAPH_MEMORY_REQUIREMENTS *pWorkGraphMemoryRequirements); + + DECLSPEC_XFGVIRT(ID3D12WorkGraphProperties, GetEntrypointRecordAlignmentInBytes) + UINT ( STDMETHODCALLTYPE *GetEntrypointRecordAlignmentInBytes )( + ID3D12WorkGraphProperties * This, + UINT WorkGraphIndex, + UINT EntrypointIndex); + + END_INTERFACE + } ID3D12WorkGraphPropertiesVtbl; + + interface ID3D12WorkGraphProperties + { + CONST_VTBL struct ID3D12WorkGraphPropertiesVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12WorkGraphProperties_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12WorkGraphProperties_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12WorkGraphProperties_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12WorkGraphProperties_GetNumWorkGraphs(This) \ + ( (This)->lpVtbl -> GetNumWorkGraphs(This) ) + +#define ID3D12WorkGraphProperties_GetProgramName(This,WorkGraphIndex) \ + ( (This)->lpVtbl -> GetProgramName(This,WorkGraphIndex) ) + +#define ID3D12WorkGraphProperties_GetWorkGraphIndex(This,pProgramName) \ + ( (This)->lpVtbl -> GetWorkGraphIndex(This,pProgramName) ) + +#define ID3D12WorkGraphProperties_GetNumNodes(This,WorkGraphIndex) \ + ( (This)->lpVtbl -> GetNumNodes(This,WorkGraphIndex) ) +#if !defined(_WIN32) + +#define ID3D12WorkGraphProperties_GetNodeID(This,WorkGraphIndex,NodeIndex) \ + ( (This)->lpVtbl -> GetNodeID(This,WorkGraphIndex,NodeIndex) ) +#else +#define ID3D12WorkGraphProperties_GetNodeID(This,RetVal,WorkGraphIndex,NodeIndex) \ + ( (This)->lpVtbl -> GetNodeID(This,RetVal,WorkGraphIndex,NodeIndex) ) +#endif + +#define ID3D12WorkGraphProperties_GetNodeIndex(This,WorkGraphIndex,NodeID) \ + ( (This)->lpVtbl -> GetNodeIndex(This,WorkGraphIndex,NodeID) ) + +#define ID3D12WorkGraphProperties_GetNodeLocalRootArgumentsTableIndex(This,WorkGraphIndex,NodeIndex) \ + ( (This)->lpVtbl -> GetNodeLocalRootArgumentsTableIndex(This,WorkGraphIndex,NodeIndex) ) + +#define ID3D12WorkGraphProperties_GetNumEntrypoints(This,WorkGraphIndex) \ + ( (This)->lpVtbl -> GetNumEntrypoints(This,WorkGraphIndex) ) +#if !defined(_WIN32) + +#define ID3D12WorkGraphProperties_GetEntrypointID(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointID(This,WorkGraphIndex,EntrypointIndex) ) +#else +#define ID3D12WorkGraphProperties_GetEntrypointID(This,RetVal,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointID(This,RetVal,WorkGraphIndex,EntrypointIndex) ) +#endif + +#define ID3D12WorkGraphProperties_GetEntrypointIndex(This,WorkGraphIndex,NodeID) \ + ( (This)->lpVtbl -> GetEntrypointIndex(This,WorkGraphIndex,NodeID) ) + +#define ID3D12WorkGraphProperties_GetEntrypointRecordSizeInBytes(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointRecordSizeInBytes(This,WorkGraphIndex,EntrypointIndex) ) + +#define ID3D12WorkGraphProperties_GetWorkGraphMemoryRequirements(This,WorkGraphIndex,pWorkGraphMemoryRequirements) \ + ( (This)->lpVtbl -> GetWorkGraphMemoryRequirements(This,WorkGraphIndex,pWorkGraphMemoryRequirements) ) + +#define ID3D12WorkGraphProperties_GetEntrypointRecordAlignmentInBytes(This,WorkGraphIndex,EntrypointIndex) \ + ( (This)->lpVtbl -> GetEntrypointRecordAlignmentInBytes(This,WorkGraphIndex,EntrypointIndex) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12WorkGraphProperties_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0036 */ +/* [local] */ + +typedef +enum D3D12_STATE_SUBOBJECT_TYPE + { + D3D12_STATE_SUBOBJECT_TYPE_STATE_OBJECT_CONFIG = 0, + D3D12_STATE_SUBOBJECT_TYPE_GLOBAL_ROOT_SIGNATURE = 1, + D3D12_STATE_SUBOBJECT_TYPE_LOCAL_ROOT_SIGNATURE = 2, + D3D12_STATE_SUBOBJECT_TYPE_NODE_MASK = 3, + D3D12_STATE_SUBOBJECT_TYPE_DXIL_LIBRARY = 5, + D3D12_STATE_SUBOBJECT_TYPE_EXISTING_COLLECTION = 6, + D3D12_STATE_SUBOBJECT_TYPE_SUBOBJECT_TO_EXPORTS_ASSOCIATION = 7, + D3D12_STATE_SUBOBJECT_TYPE_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION = 8, + D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_SHADER_CONFIG = 9, + D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG = 10, + D3D12_STATE_SUBOBJECT_TYPE_HIT_GROUP = 11, + D3D12_STATE_SUBOBJECT_TYPE_RAYTRACING_PIPELINE_CONFIG1 = 12, + D3D12_STATE_SUBOBJECT_TYPE_WORK_GRAPH = 13, + D3D12_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT = 14, + D3D12_STATE_SUBOBJECT_TYPE_BLEND = 15, + D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_MASK = 16, + D3D12_STATE_SUBOBJECT_TYPE_RASTERIZER = 17, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL = 18, + D3D12_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT = 19, + D3D12_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE = 20, + D3D12_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY = 21, + D3D12_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS = 22, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT = 23, + D3D12_STATE_SUBOBJECT_TYPE_SAMPLE_DESC = 24, + D3D12_STATE_SUBOBJECT_TYPE_FLAGS = 26, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1 = 27, + D3D12_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING = 28, + D3D12_STATE_SUBOBJECT_TYPE_GENERIC_PROGRAM = 29, + D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 = 30, + D3D12_STATE_SUBOBJECT_TYPE_MAX_VALID = ( D3D12_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL2 + 1 ) + } D3D12_STATE_SUBOBJECT_TYPE; + +typedef struct D3D12_STATE_SUBOBJECT + { + D3D12_STATE_SUBOBJECT_TYPE Type; + const void *pDesc; + } D3D12_STATE_SUBOBJECT; + +typedef +enum D3D12_STATE_OBJECT_FLAGS + { + D3D12_STATE_OBJECT_FLAG_NONE = 0, + D3D12_STATE_OBJECT_FLAG_ALLOW_LOCAL_DEPENDENCIES_ON_EXTERNAL_DEFINITIONS = 0x1, + D3D12_STATE_OBJECT_FLAG_ALLOW_EXTERNAL_DEPENDENCIES_ON_LOCAL_DEFINITIONS = 0x2, + D3D12_STATE_OBJECT_FLAG_ALLOW_STATE_OBJECT_ADDITIONS = 0x4 + } D3D12_STATE_OBJECT_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_STATE_OBJECT_FLAGS ) +typedef struct D3D12_STATE_OBJECT_CONFIG + { + D3D12_STATE_OBJECT_FLAGS Flags; + } D3D12_STATE_OBJECT_CONFIG; + +typedef struct D3D12_GLOBAL_ROOT_SIGNATURE + { + ID3D12RootSignature *pGlobalRootSignature; + } D3D12_GLOBAL_ROOT_SIGNATURE; + +typedef struct D3D12_LOCAL_ROOT_SIGNATURE + { + ID3D12RootSignature *pLocalRootSignature; + } D3D12_LOCAL_ROOT_SIGNATURE; + +typedef struct D3D12_NODE_MASK + { + UINT NodeMask; + } D3D12_NODE_MASK; + +typedef struct D3D12_SAMPLE_MASK + { + UINT SampleMask; + } D3D12_SAMPLE_MASK; + +typedef struct D3D12_IB_STRIP_CUT_VALUE + { + D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IndexBufferStripCutValue; + } D3D12_IB_STRIP_CUT_VALUE; + +typedef struct D3D12_PRIMITIVE_TOPOLOGY_DESC + { + D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopology; + } D3D12_PRIMITIVE_TOPOLOGY_DESC; + +typedef struct D3D12_DEPTH_STENCIL_FORMAT + { + DXGI_FORMAT DepthStencilFormat; + } D3D12_DEPTH_STENCIL_FORMAT; + +typedef +enum D3D12_EXPORT_FLAGS + { + D3D12_EXPORT_FLAG_NONE = 0 + } D3D12_EXPORT_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_EXPORT_FLAGS ) +typedef struct D3D12_EXPORT_DESC + { + LPCWSTR Name; + _In_opt_ LPCWSTR ExportToRename; + D3D12_EXPORT_FLAGS Flags; + } D3D12_EXPORT_DESC; + +typedef struct D3D12_DXIL_LIBRARY_DESC + { + D3D12_SHADER_BYTECODE DXILLibrary; + UINT NumExports; + _In_reads_(NumExports) const D3D12_EXPORT_DESC *pExports; + } D3D12_DXIL_LIBRARY_DESC; + +typedef struct D3D12_EXISTING_COLLECTION_DESC + { + ID3D12StateObject *pExistingCollection; + UINT NumExports; + _In_reads_(NumExports) const D3D12_EXPORT_DESC *pExports; + } D3D12_EXISTING_COLLECTION_DESC; + +typedef struct D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION + { + const D3D12_STATE_SUBOBJECT *pSubobjectToAssociate; + UINT NumExports; + _In_reads_(NumExports) LPCWSTR *pExports; + } D3D12_SUBOBJECT_TO_EXPORTS_ASSOCIATION; + +typedef struct D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION + { + LPCWSTR SubobjectToAssociate; + UINT NumExports; + _In_reads_(NumExports) LPCWSTR *pExports; + } D3D12_DXIL_SUBOBJECT_TO_EXPORTS_ASSOCIATION; + +typedef +enum D3D12_HIT_GROUP_TYPE + { + D3D12_HIT_GROUP_TYPE_TRIANGLES = 0, + D3D12_HIT_GROUP_TYPE_PROCEDURAL_PRIMITIVE = 0x1 + } D3D12_HIT_GROUP_TYPE; + +typedef struct D3D12_HIT_GROUP_DESC + { + LPCWSTR HitGroupExport; + D3D12_HIT_GROUP_TYPE Type; + _In_opt_ LPCWSTR AnyHitShaderImport; + _In_opt_ LPCWSTR ClosestHitShaderImport; + _In_opt_ LPCWSTR IntersectionShaderImport; + } D3D12_HIT_GROUP_DESC; + +typedef struct D3D12_RAYTRACING_SHADER_CONFIG + { + UINT MaxPayloadSizeInBytes; + UINT MaxAttributeSizeInBytes; + } D3D12_RAYTRACING_SHADER_CONFIG; + +typedef struct D3D12_RAYTRACING_PIPELINE_CONFIG + { + UINT MaxTraceRecursionDepth; + } D3D12_RAYTRACING_PIPELINE_CONFIG; + +typedef +enum D3D12_RAYTRACING_PIPELINE_FLAGS + { + D3D12_RAYTRACING_PIPELINE_FLAG_NONE = 0, + D3D12_RAYTRACING_PIPELINE_FLAG_SKIP_TRIANGLES = 0x100, + D3D12_RAYTRACING_PIPELINE_FLAG_SKIP_PROCEDURAL_PRIMITIVES = 0x200 + } D3D12_RAYTRACING_PIPELINE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_PIPELINE_FLAGS ) +typedef struct D3D12_RAYTRACING_PIPELINE_CONFIG1 + { + UINT MaxTraceRecursionDepth; + D3D12_RAYTRACING_PIPELINE_FLAGS Flags; + } D3D12_RAYTRACING_PIPELINE_CONFIG1; + +typedef struct D3D12_NODE_OUTPUT_OVERRIDES + { + UINT OutputIndex; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const BOOL *pAllowSparseNodes; + _In_opt_ const UINT *pMaxRecords; + _In_opt_ const UINT *pMaxRecordsSharedWithOutputIndex; + } D3D12_NODE_OUTPUT_OVERRIDES; + +typedef struct D3D12_BROADCASTING_LAUNCH_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + _In_reads_opt_(3) const UINT *pDispatchGrid; + _In_reads_opt_(3) const UINT *pMaxDispatchGrid; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_BROADCASTING_LAUNCH_OVERRIDES; + +typedef struct D3D12_COALESCING_LAUNCH_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_COALESCING_LAUNCH_OVERRIDES; + +typedef struct D3D12_THREAD_LAUNCH_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_THREAD_LAUNCH_OVERRIDES; + +typedef struct D3D12_COMMON_COMPUTE_NODE_OVERRIDES + { + _In_opt_ const UINT *pLocalRootArgumentsTableIndex; + _In_opt_ const BOOL *pProgramEntry; + _In_opt_ const D3D12_NODE_ID *pNewName; + _In_opt_ const D3D12_NODE_ID *pShareInputOf; + UINT NumOutputOverrides; + _In_reads_opt_(NumOutputOverrides) const D3D12_NODE_OUTPUT_OVERRIDES *pOutputOverrides; + } D3D12_COMMON_COMPUTE_NODE_OVERRIDES; + +typedef +enum D3D12_NODE_OVERRIDES_TYPE + { + D3D12_NODE_OVERRIDES_TYPE_NONE = 0, + D3D12_NODE_OVERRIDES_TYPE_BROADCASTING_LAUNCH = 1, + D3D12_NODE_OVERRIDES_TYPE_COALESCING_LAUNCH = 2, + D3D12_NODE_OVERRIDES_TYPE_THREAD_LAUNCH = 3, + D3D12_NODE_OVERRIDES_TYPE_COMMON_COMPUTE = 4 + } D3D12_NODE_OVERRIDES_TYPE; + +typedef struct D3D12_SHADER_NODE + { + LPCWSTR Shader; + D3D12_NODE_OVERRIDES_TYPE OverridesType; + union + { + const D3D12_BROADCASTING_LAUNCH_OVERRIDES *pBroadcastingLaunchOverrides; + const D3D12_COALESCING_LAUNCH_OVERRIDES *pCoalescingLaunchOverrides; + const D3D12_THREAD_LAUNCH_OVERRIDES *pThreadLaunchOverrides; + const D3D12_COMMON_COMPUTE_NODE_OVERRIDES *pCommonComputeNodeOverrides; + } ; + } D3D12_SHADER_NODE; + +typedef +enum D3D12_NODE_TYPE + { + D3D12_NODE_TYPE_SHADER = 0 + } D3D12_NODE_TYPE; + +typedef struct D3D12_NODE + { + D3D12_NODE_TYPE NodeType; + union + { + D3D12_SHADER_NODE Shader; + } ; + } D3D12_NODE; + +typedef +enum D3D12_WORK_GRAPH_FLAGS + { + D3D12_WORK_GRAPH_FLAG_NONE = 0, + D3D12_WORK_GRAPH_FLAG_INCLUDE_ALL_AVAILABLE_NODES = 0x1 + } D3D12_WORK_GRAPH_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_WORK_GRAPH_FLAGS ) +typedef struct D3D12_WORK_GRAPH_DESC + { + LPCWSTR ProgramName; + D3D12_WORK_GRAPH_FLAGS Flags; + UINT NumEntrypoints; + _In_reads_opt_(NumEntrypoints) const D3D12_NODE_ID *pEntrypoints; + UINT NumExplicitlyDefinedNodes; + _In_reads_opt_(NumExplicitlyDefinedNodes) const D3D12_NODE *pExplicitlyDefinedNodes; + } D3D12_WORK_GRAPH_DESC; + +typedef struct D3D12_GENERIC_PROGRAM_DESC + { + LPCWSTR ProgramName; + UINT NumExports; + _In_reads_(NumExports) LPCWSTR *pExports; + UINT NumSubobjects; + _In_reads_opt_(NumSubobjects) const D3D12_STATE_SUBOBJECT *const *ppSubobjects; + } D3D12_GENERIC_PROGRAM_DESC; + +typedef +enum D3D12_STATE_OBJECT_TYPE + { + D3D12_STATE_OBJECT_TYPE_COLLECTION = 0, + D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE = 3, + D3D12_STATE_OBJECT_TYPE_EXECUTABLE = 4 + } D3D12_STATE_OBJECT_TYPE; + +typedef struct D3D12_STATE_OBJECT_DESC + { + D3D12_STATE_OBJECT_TYPE Type; + UINT NumSubobjects; + _In_reads_(NumSubobjects) const D3D12_STATE_SUBOBJECT *pSubobjects; + } D3D12_STATE_OBJECT_DESC; + +typedef +enum D3D12_RAYTRACING_GEOMETRY_FLAGS + { + D3D12_RAYTRACING_GEOMETRY_FLAG_NONE = 0, + D3D12_RAYTRACING_GEOMETRY_FLAG_OPAQUE = 0x1, + D3D12_RAYTRACING_GEOMETRY_FLAG_NO_DUPLICATE_ANYHIT_INVOCATION = 0x2 + } D3D12_RAYTRACING_GEOMETRY_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_GEOMETRY_FLAGS ) +typedef +enum D3D12_RAYTRACING_GEOMETRY_TYPE + { + D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES = 0, + D3D12_RAYTRACING_GEOMETRY_TYPE_PROCEDURAL_PRIMITIVE_AABBS = ( D3D12_RAYTRACING_GEOMETRY_TYPE_TRIANGLES + 1 ) + } D3D12_RAYTRACING_GEOMETRY_TYPE; + +typedef +enum D3D12_RAYTRACING_INSTANCE_FLAGS + { + D3D12_RAYTRACING_INSTANCE_FLAG_NONE = 0, + D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_CULL_DISABLE = 0x1, + D3D12_RAYTRACING_INSTANCE_FLAG_TRIANGLE_FRONT_COUNTERCLOCKWISE = 0x2, + D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_OPAQUE = 0x4, + D3D12_RAYTRACING_INSTANCE_FLAG_FORCE_NON_OPAQUE = 0x8 + } D3D12_RAYTRACING_INSTANCE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_INSTANCE_FLAGS ) +typedef struct D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE + { + D3D12_GPU_VIRTUAL_ADDRESS StartAddress; + UINT64 StrideInBytes; + } D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE; + +typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE + { + D3D12_GPU_VIRTUAL_ADDRESS StartAddress; + UINT64 SizeInBytes; + } D3D12_GPU_VIRTUAL_ADDRESS_RANGE; + +typedef struct D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE + { + D3D12_GPU_VIRTUAL_ADDRESS StartAddress; + UINT64 SizeInBytes; + UINT64 StrideInBytes; + } D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE; + +typedef struct D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS Transform3x4; + DXGI_FORMAT IndexFormat; + DXGI_FORMAT VertexFormat; + UINT IndexCount; + UINT VertexCount; + D3D12_GPU_VIRTUAL_ADDRESS IndexBuffer; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE VertexBuffer; + } D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC; + +typedef struct D3D12_RAYTRACING_AABB + { + FLOAT MinX; + FLOAT MinY; + FLOAT MinZ; + FLOAT MaxX; + FLOAT MaxY; + FLOAT MaxZ; + } D3D12_RAYTRACING_AABB; + +typedef struct D3D12_RAYTRACING_GEOMETRY_AABBS_DESC + { + UINT64 AABBCount; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE AABBs; + } D3D12_RAYTRACING_GEOMETRY_AABBS_DESC; + +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_NONE = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_UPDATE = 0x1, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_ALLOW_COMPACTION = 0x2, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_TRACE = 0x4, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PREFER_FAST_BUILD = 0x8, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_MINIMIZE_MEMORY = 0x10, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAG_PERFORM_UPDATE = 0x20 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS ) +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_CLONE = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_COMPACT = 0x1, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_VISUALIZATION_DECODE_FOR_TOOLS = 0x2, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_SERIALIZE = 0x3, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE_DESERIALIZE = 0x4 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE; + +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL = 0x1 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE; + +typedef +enum D3D12_ELEMENTS_LAYOUT + { + D3D12_ELEMENTS_LAYOUT_ARRAY = 0, + D3D12_ELEMENTS_LAYOUT_ARRAY_OF_POINTERS = 0x1 + } D3D12_ELEMENTS_LAYOUT; + +typedef +enum D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE = 0, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION = 0x1, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION = 0x2, + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE = 0x3 + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS DestBuffer; + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TYPE InfoType; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC + { + UINT64 CompactedSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION_DESC + { + UINT64 DecodedSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_TOOLS_VISUALIZATION_DESC; + +typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE Type; + UINT NumDescs; + } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER; + +// Regarding D3D12_BUILD_RAY_TRACING_ACCELERATION_STRUCTURE_TOOLS_VISUALIZATION_HEADER above, +// depending on Type field, NumDescs above is followed by either: +// D3D12_RAY_TRACING_INSTANCE_DESC InstanceDescs[NumDescs] +// or D3D12_RAY_TRACING_GEOMETRY_DESC GeometryDescs[NumDescs]. +// There is 4 bytes of padding between GeometryDesc structs in the array so alignment is natural when viewed by CPU. + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC + { + UINT64 SerializedSizeInBytes; + UINT64 NumBottomLevelAccelerationStructurePointers; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC; + +typedef struct D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER + { + GUID DriverOpaqueGUID; + BYTE DriverOpaqueVersioningData[ 16 ]; + } D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER; + +typedef +enum D3D12_SERIALIZED_DATA_TYPE + { + D3D12_SERIALIZED_DATA_RAYTRACING_ACCELERATION_STRUCTURE = 0 + } D3D12_SERIALIZED_DATA_TYPE; + +typedef +enum D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS + { + D3D12_DRIVER_MATCHING_IDENTIFIER_COMPATIBLE_WITH_DEVICE = 0, + D3D12_DRIVER_MATCHING_IDENTIFIER_UNSUPPORTED_TYPE = 0x1, + D3D12_DRIVER_MATCHING_IDENTIFIER_UNRECOGNIZED = 0x2, + D3D12_DRIVER_MATCHING_IDENTIFIER_INCOMPATIBLE_VERSION = 0x3, + D3D12_DRIVER_MATCHING_IDENTIFIER_INCOMPATIBLE_TYPE = 0x4 + } D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS; + +typedef struct D3D12_SERIALIZED_RAYTRACING_ACCELERATION_STRUCTURE_HEADER + { + D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER DriverMatchingIdentifier; + UINT64 SerializedSizeInBytesIncludingHeader; + UINT64 DeserializedSizeInBytes; + UINT64 NumBottomLevelAccelerationStructurePointersAfterHeader; + } D3D12_SERIALIZED_RAYTRACING_ACCELERATION_STRUCTURE_HEADER; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE_DESC + { + UINT64 CurrentSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE_DESC; + +typedef struct D3D12_RAYTRACING_INSTANCE_DESC + { + FLOAT Transform[ 3 ][ 4 ]; + UINT InstanceID : 24; + UINT InstanceMask : 8; + UINT InstanceContributionToHitGroupIndex : 24; + UINT Flags : 8; + D3D12_GPU_VIRTUAL_ADDRESS AccelerationStructure; + } D3D12_RAYTRACING_INSTANCE_DESC; + +typedef struct D3D12_RAYTRACING_GEOMETRY_DESC + { + D3D12_RAYTRACING_GEOMETRY_TYPE Type; + D3D12_RAYTRACING_GEOMETRY_FLAGS Flags; + union + { + D3D12_RAYTRACING_GEOMETRY_TRIANGLES_DESC Triangles; + D3D12_RAYTRACING_GEOMETRY_AABBS_DESC AABBs; + } ; + } D3D12_RAYTRACING_GEOMETRY_DESC; + +typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS + { + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_TYPE Type; + D3D12_RAYTRACING_ACCELERATION_STRUCTURE_BUILD_FLAGS Flags; + UINT NumDescs; + D3D12_ELEMENTS_LAYOUT DescsLayout; + union + { + D3D12_GPU_VIRTUAL_ADDRESS InstanceDescs; + const D3D12_RAYTRACING_GEOMETRY_DESC *pGeometryDescs; + const D3D12_RAYTRACING_GEOMETRY_DESC *const *ppGeometryDescs; + } ; + } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS; + +typedef struct D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData; + D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS Inputs; + _In_opt_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData; + D3D12_GPU_VIRTUAL_ADDRESS ScratchAccelerationStructureData; + } D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC; + +typedef struct D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO + { + UINT64 ResultDataMaxSizeInBytes; + UINT64 ScratchDataSizeInBytes; + UINT64 UpdateScratchDataSizeInBytes; + } D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO; + +typedef +enum D3D12_RAY_FLAGS + { + D3D12_RAY_FLAG_NONE = 0, + D3D12_RAY_FLAG_FORCE_OPAQUE = 0x1, + D3D12_RAY_FLAG_FORCE_NON_OPAQUE = 0x2, + D3D12_RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH = 0x4, + D3D12_RAY_FLAG_SKIP_CLOSEST_HIT_SHADER = 0x8, + D3D12_RAY_FLAG_CULL_BACK_FACING_TRIANGLES = 0x10, + D3D12_RAY_FLAG_CULL_FRONT_FACING_TRIANGLES = 0x20, + D3D12_RAY_FLAG_CULL_OPAQUE = 0x40, + D3D12_RAY_FLAG_CULL_NON_OPAQUE = 0x80, + D3D12_RAY_FLAG_SKIP_TRIANGLES = 0x100, + D3D12_RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES = 0x200 + } D3D12_RAY_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RAY_FLAGS ) +typedef +enum D3D12_HIT_KIND + { + D3D12_HIT_KIND_TRIANGLE_FRONT_FACE = 0xfe, + D3D12_HIT_KIND_TRIANGLE_BACK_FACE = 0xff + } D3D12_HIT_KIND; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0036_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0036_v0_0_s_ifspec; + +#ifndef __ID3D12Device5_INTERFACE_DEFINED__ +#define __ID3D12Device5_INTERFACE_DEFINED__ + +/* interface ID3D12Device5 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device5; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("8b4f173b-2fea-4b80-8f58-4307191ab95d") + ID3D12Device5 : public ID3D12Device4 + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateLifetimeTracker( + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker) = 0; + + virtual void STDMETHODCALLTYPE RemoveDevice( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnumerateMetaCommands( + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnumerateMetaCommandParameters( + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateMetaCommand( + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateStateObject( + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject) = 0; + + virtual void STDMETHODCALLTYPE GetRaytracingAccelerationStructurePrebuildInfo( + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo) = 0; + + virtual D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS STDMETHODCALLTYPE CheckDriverMatchingIdentifier( + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device5Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device5 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device5 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device5 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device5 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device5 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device5 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device5 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device5 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device5 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device5 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device5 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device5 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device5 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device5 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device5 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device5 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device5 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device5 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device5 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device5 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device5 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device5 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device5 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device5 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device5 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device5 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device5 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device5 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device5 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device5 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device5 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device5 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device5 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device5 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device5 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device5 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device5 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device5 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device5 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device5 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device5 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device5 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device5 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device5 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device5 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device5 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device5 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device5 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device5 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device5 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device5 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device5 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device5 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device5 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device5 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device5 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device5 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device5 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device5 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device5 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device5 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device5 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device5 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device5 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device5 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device5 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device5 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device5 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device5 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + END_INTERFACE + } ID3D12Device5Vtbl; + + interface ID3D12Device5 + { + CONST_VTBL struct ID3D12Device5Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device5_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device5_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device5_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device5_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device5_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device5_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device5_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device5_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device5_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device5_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device5_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device5_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device5_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device5_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device5_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device5_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device5_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device5_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device5_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device5_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device5_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device5_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device5_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device5_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device5_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device5_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device5_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device5_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device5_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device5_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device5_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device5_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device5_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device5_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device5_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device5_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device5_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device5_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device5_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device5_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device5_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device5_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device5_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device5_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device5_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device5_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device5_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device5_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device5_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device5_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device5_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device5_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device5_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device5_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device5_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device5_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device5_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device5_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device5_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device5_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device5_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device5_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device5_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device5_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device5_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device5_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device5_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device5_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device5_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device5_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0037 */ +/* [local] */ + +typedef +enum D3D12_AUTO_BREADCRUMB_OP + { + D3D12_AUTO_BREADCRUMB_OP_SETMARKER = 0, + D3D12_AUTO_BREADCRUMB_OP_BEGINEVENT = 1, + D3D12_AUTO_BREADCRUMB_OP_ENDEVENT = 2, + D3D12_AUTO_BREADCRUMB_OP_DRAWINSTANCED = 3, + D3D12_AUTO_BREADCRUMB_OP_DRAWINDEXEDINSTANCED = 4, + D3D12_AUTO_BREADCRUMB_OP_EXECUTEINDIRECT = 5, + D3D12_AUTO_BREADCRUMB_OP_DISPATCH = 6, + D3D12_AUTO_BREADCRUMB_OP_COPYBUFFERREGION = 7, + D3D12_AUTO_BREADCRUMB_OP_COPYTEXTUREREGION = 8, + D3D12_AUTO_BREADCRUMB_OP_COPYRESOURCE = 9, + D3D12_AUTO_BREADCRUMB_OP_COPYTILES = 10, + D3D12_AUTO_BREADCRUMB_OP_RESOLVESUBRESOURCE = 11, + D3D12_AUTO_BREADCRUMB_OP_CLEARRENDERTARGETVIEW = 12, + D3D12_AUTO_BREADCRUMB_OP_CLEARUNORDEREDACCESSVIEW = 13, + D3D12_AUTO_BREADCRUMB_OP_CLEARDEPTHSTENCILVIEW = 14, + D3D12_AUTO_BREADCRUMB_OP_RESOURCEBARRIER = 15, + D3D12_AUTO_BREADCRUMB_OP_EXECUTEBUNDLE = 16, + D3D12_AUTO_BREADCRUMB_OP_PRESENT = 17, + D3D12_AUTO_BREADCRUMB_OP_RESOLVEQUERYDATA = 18, + D3D12_AUTO_BREADCRUMB_OP_BEGINSUBMISSION = 19, + D3D12_AUTO_BREADCRUMB_OP_ENDSUBMISSION = 20, + D3D12_AUTO_BREADCRUMB_OP_DECODEFRAME = 21, + D3D12_AUTO_BREADCRUMB_OP_PROCESSFRAMES = 22, + D3D12_AUTO_BREADCRUMB_OP_ATOMICCOPYBUFFERUINT = 23, + D3D12_AUTO_BREADCRUMB_OP_ATOMICCOPYBUFFERUINT64 = 24, + D3D12_AUTO_BREADCRUMB_OP_RESOLVESUBRESOURCEREGION = 25, + D3D12_AUTO_BREADCRUMB_OP_WRITEBUFFERIMMEDIATE = 26, + D3D12_AUTO_BREADCRUMB_OP_DECODEFRAME1 = 27, + D3D12_AUTO_BREADCRUMB_OP_SETPROTECTEDRESOURCESESSION = 28, + D3D12_AUTO_BREADCRUMB_OP_DECODEFRAME2 = 29, + D3D12_AUTO_BREADCRUMB_OP_PROCESSFRAMES1 = 30, + D3D12_AUTO_BREADCRUMB_OP_BUILDRAYTRACINGACCELERATIONSTRUCTURE = 31, + D3D12_AUTO_BREADCRUMB_OP_EMITRAYTRACINGACCELERATIONSTRUCTUREPOSTBUILDINFO = 32, + D3D12_AUTO_BREADCRUMB_OP_COPYRAYTRACINGACCELERATIONSTRUCTURE = 33, + D3D12_AUTO_BREADCRUMB_OP_DISPATCHRAYS = 34, + D3D12_AUTO_BREADCRUMB_OP_INITIALIZEMETACOMMAND = 35, + D3D12_AUTO_BREADCRUMB_OP_EXECUTEMETACOMMAND = 36, + D3D12_AUTO_BREADCRUMB_OP_ESTIMATEMOTION = 37, + D3D12_AUTO_BREADCRUMB_OP_RESOLVEMOTIONVECTORHEAP = 38, + D3D12_AUTO_BREADCRUMB_OP_SETPIPELINESTATE1 = 39, + D3D12_AUTO_BREADCRUMB_OP_INITIALIZEEXTENSIONCOMMAND = 40, + D3D12_AUTO_BREADCRUMB_OP_EXECUTEEXTENSIONCOMMAND = 41, + D3D12_AUTO_BREADCRUMB_OP_DISPATCHMESH = 42, + D3D12_AUTO_BREADCRUMB_OP_ENCODEFRAME = 43, + D3D12_AUTO_BREADCRUMB_OP_RESOLVEENCODEROUTPUTMETADATA = 44, + D3D12_AUTO_BREADCRUMB_OP_BARRIER = 45, + D3D12_AUTO_BREADCRUMB_OP_BEGIN_COMMAND_LIST = 46, + D3D12_AUTO_BREADCRUMB_OP_DISPATCHGRAPH = 47, + D3D12_AUTO_BREADCRUMB_OP_SETPROGRAM = 48 + } D3D12_AUTO_BREADCRUMB_OP; + +typedef struct D3D12_AUTO_BREADCRUMB_NODE + { + const char *pCommandListDebugNameA; + const wchar_t *pCommandListDebugNameW; + const char *pCommandQueueDebugNameA; + const wchar_t *pCommandQueueDebugNameW; + ID3D12GraphicsCommandList *pCommandList; + ID3D12CommandQueue *pCommandQueue; + UINT32 BreadcrumbCount; + const UINT32 *pLastBreadcrumbValue; + const D3D12_AUTO_BREADCRUMB_OP *pCommandHistory; + const struct D3D12_AUTO_BREADCRUMB_NODE *pNext; + } D3D12_AUTO_BREADCRUMB_NODE; + +typedef struct D3D12_DRED_BREADCRUMB_CONTEXT + { + UINT BreadcrumbIndex; + const wchar_t *pContextString; + } D3D12_DRED_BREADCRUMB_CONTEXT; + +typedef struct D3D12_AUTO_BREADCRUMB_NODE1 + { + const char *pCommandListDebugNameA; + const wchar_t *pCommandListDebugNameW; + const char *pCommandQueueDebugNameA; + const wchar_t *pCommandQueueDebugNameW; + ID3D12GraphicsCommandList *pCommandList; + ID3D12CommandQueue *pCommandQueue; + UINT BreadcrumbCount; + const UINT *pLastBreadcrumbValue; + const D3D12_AUTO_BREADCRUMB_OP *pCommandHistory; + const struct D3D12_AUTO_BREADCRUMB_NODE1 *pNext; + UINT BreadcrumbContextsCount; + D3D12_DRED_BREADCRUMB_CONTEXT *pBreadcrumbContexts; + } D3D12_AUTO_BREADCRUMB_NODE1; + +typedef +enum D3D12_DRED_VERSION + { + D3D12_DRED_VERSION_1_0 = 0x1, + D3D12_DRED_VERSION_1_1 = 0x2, + D3D12_DRED_VERSION_1_2 = 0x3, + D3D12_DRED_VERSION_1_3 = 0x4 + } D3D12_DRED_VERSION; + +typedef +enum D3D12_DRED_FLAGS + { + D3D12_DRED_FLAG_NONE = 0, + D3D12_DRED_FLAG_FORCE_ENABLE = 1, + D3D12_DRED_FLAG_DISABLE_AUTOBREADCRUMBS = 2 + } D3D12_DRED_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DRED_FLAGS ) +typedef +enum D3D12_DRED_ENABLEMENT + { + D3D12_DRED_ENABLEMENT_SYSTEM_CONTROLLED = 0, + D3D12_DRED_ENABLEMENT_FORCED_OFF = 1, + D3D12_DRED_ENABLEMENT_FORCED_ON = 2 + } D3D12_DRED_ENABLEMENT; + +typedef struct D3D12_DEVICE_REMOVED_EXTENDED_DATA + { + _In_ D3D12_DRED_FLAGS Flags; + _Out_ D3D12_AUTO_BREADCRUMB_NODE *pHeadAutoBreadcrumbNode; + } D3D12_DEVICE_REMOVED_EXTENDED_DATA; + +typedef +enum D3D12_DRED_ALLOCATION_TYPE + { + D3D12_DRED_ALLOCATION_TYPE_COMMAND_QUEUE = 19, + D3D12_DRED_ALLOCATION_TYPE_COMMAND_ALLOCATOR = 20, + D3D12_DRED_ALLOCATION_TYPE_PIPELINE_STATE = 21, + D3D12_DRED_ALLOCATION_TYPE_COMMAND_LIST = 22, + D3D12_DRED_ALLOCATION_TYPE_FENCE = 23, + D3D12_DRED_ALLOCATION_TYPE_DESCRIPTOR_HEAP = 24, + D3D12_DRED_ALLOCATION_TYPE_HEAP = 25, + D3D12_DRED_ALLOCATION_TYPE_QUERY_HEAP = 27, + D3D12_DRED_ALLOCATION_TYPE_COMMAND_SIGNATURE = 28, + D3D12_DRED_ALLOCATION_TYPE_PIPELINE_LIBRARY = 29, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_DECODER = 30, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_PROCESSOR = 32, + D3D12_DRED_ALLOCATION_TYPE_RESOURCE = 34, + D3D12_DRED_ALLOCATION_TYPE_PASS = 35, + D3D12_DRED_ALLOCATION_TYPE_CRYPTOSESSION = 36, + D3D12_DRED_ALLOCATION_TYPE_CRYPTOSESSIONPOLICY = 37, + D3D12_DRED_ALLOCATION_TYPE_PROTECTEDRESOURCESESSION = 38, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_DECODER_HEAP = 39, + D3D12_DRED_ALLOCATION_TYPE_COMMAND_POOL = 40, + D3D12_DRED_ALLOCATION_TYPE_COMMAND_RECORDER = 41, + D3D12_DRED_ALLOCATION_TYPE_STATE_OBJECT = 42, + D3D12_DRED_ALLOCATION_TYPE_METACOMMAND = 43, + D3D12_DRED_ALLOCATION_TYPE_SCHEDULINGGROUP = 44, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_MOTION_ESTIMATOR = 45, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_MOTION_VECTOR_HEAP = 46, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_EXTENSION_COMMAND = 47, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_ENCODER = 48, + D3D12_DRED_ALLOCATION_TYPE_VIDEO_ENCODER_HEAP = 49, + D3D12_DRED_ALLOCATION_TYPE_INVALID = 0xffffffff + } D3D12_DRED_ALLOCATION_TYPE; + +typedef struct D3D12_DRED_ALLOCATION_NODE + { + const char *ObjectNameA; + const wchar_t *ObjectNameW; + D3D12_DRED_ALLOCATION_TYPE AllocationType; + const struct D3D12_DRED_ALLOCATION_NODE *pNext; + } D3D12_DRED_ALLOCATION_NODE; + +typedef struct D3D12_DRED_ALLOCATION_NODE1 + { + const char *ObjectNameA; + const wchar_t *ObjectNameW; + D3D12_DRED_ALLOCATION_TYPE AllocationType; + const struct D3D12_DRED_ALLOCATION_NODE1 *pNext; + const IUnknown *pObject; + } D3D12_DRED_ALLOCATION_NODE1; + +typedef struct D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT + { + _Out_ const D3D12_AUTO_BREADCRUMB_NODE *pHeadAutoBreadcrumbNode; + } D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT; + +typedef struct D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 + { + _Out_ const D3D12_AUTO_BREADCRUMB_NODE1 *pHeadAutoBreadcrumbNode; + } D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1; + +typedef struct D3D12_DRED_PAGE_FAULT_OUTPUT + { + D3D12_GPU_VIRTUAL_ADDRESS PageFaultVA; + _Out_ const D3D12_DRED_ALLOCATION_NODE *pHeadExistingAllocationNode; + _Out_ const D3D12_DRED_ALLOCATION_NODE *pHeadRecentFreedAllocationNode; + } D3D12_DRED_PAGE_FAULT_OUTPUT; + +typedef struct D3D12_DRED_PAGE_FAULT_OUTPUT1 + { + D3D12_GPU_VIRTUAL_ADDRESS PageFaultVA; + _Out_ const D3D12_DRED_ALLOCATION_NODE1 *pHeadExistingAllocationNode; + _Out_ const D3D12_DRED_ALLOCATION_NODE1 *pHeadRecentFreedAllocationNode; + } D3D12_DRED_PAGE_FAULT_OUTPUT1; + +typedef +enum D3D12_DRED_PAGE_FAULT_FLAGS + { + D3D12_DRED_PAGE_FAULT_FLAGS_NONE = 0 + } D3D12_DRED_PAGE_FAULT_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DRED_PAGE_FAULT_FLAGS ) +typedef +enum D3D12_DRED_DEVICE_STATE + { + D3D12_DRED_DEVICE_STATE_UNKNOWN = 0, + D3D12_DRED_DEVICE_STATE_HUNG = 3, + D3D12_DRED_DEVICE_STATE_FAULT = 6, + D3D12_DRED_DEVICE_STATE_PAGEFAULT = 7 + } D3D12_DRED_DEVICE_STATE; + +typedef struct D3D12_DRED_PAGE_FAULT_OUTPUT2 + { + D3D12_GPU_VIRTUAL_ADDRESS PageFaultVA; + _Out_ const D3D12_DRED_ALLOCATION_NODE1 *pHeadExistingAllocationNode; + _Out_ const D3D12_DRED_ALLOCATION_NODE1 *pHeadRecentFreedAllocationNode; + D3D12_DRED_PAGE_FAULT_FLAGS PageFaultFlags; + } D3D12_DRED_PAGE_FAULT_OUTPUT2; + +typedef struct D3D12_DEVICE_REMOVED_EXTENDED_DATA1 + { + HRESULT DeviceRemovedReason; + D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT AutoBreadcrumbsOutput; + D3D12_DRED_PAGE_FAULT_OUTPUT PageFaultOutput; + } D3D12_DEVICE_REMOVED_EXTENDED_DATA1; + +typedef struct D3D12_DEVICE_REMOVED_EXTENDED_DATA2 + { + HRESULT DeviceRemovedReason; + D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 AutoBreadcrumbsOutput; + D3D12_DRED_PAGE_FAULT_OUTPUT1 PageFaultOutput; + } D3D12_DEVICE_REMOVED_EXTENDED_DATA2; + +typedef struct D3D12_DEVICE_REMOVED_EXTENDED_DATA3 + { + HRESULT DeviceRemovedReason; + D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 AutoBreadcrumbsOutput; + D3D12_DRED_PAGE_FAULT_OUTPUT2 PageFaultOutput; + D3D12_DRED_DEVICE_STATE DeviceState; + } D3D12_DEVICE_REMOVED_EXTENDED_DATA3; + +typedef struct D3D12_VERSIONED_DEVICE_REMOVED_EXTENDED_DATA + { + D3D12_DRED_VERSION Version; + union + { + D3D12_DEVICE_REMOVED_EXTENDED_DATA Dred_1_0; + D3D12_DEVICE_REMOVED_EXTENDED_DATA1 Dred_1_1; + D3D12_DEVICE_REMOVED_EXTENDED_DATA2 Dred_1_2; + D3D12_DEVICE_REMOVED_EXTENDED_DATA3 Dred_1_3; + } ; + } D3D12_VERSIONED_DEVICE_REMOVED_EXTENDED_DATA; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0037_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0037_v0_0_s_ifspec; + +#ifndef __ID3D12DeviceRemovedExtendedDataSettings_INTERFACE_DEFINED__ +#define __ID3D12DeviceRemovedExtendedDataSettings_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceRemovedExtendedDataSettings */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceRemovedExtendedDataSettings; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("82BC481C-6B9B-4030-AEDB-7EE3D1DF1E63") + ID3D12DeviceRemovedExtendedDataSettings : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE SetAutoBreadcrumbsEnablement( + D3D12_DRED_ENABLEMENT Enablement) = 0; + + virtual void STDMETHODCALLTYPE SetPageFaultEnablement( + D3D12_DRED_ENABLEMENT Enablement) = 0; + + virtual void STDMETHODCALLTYPE SetWatsonDumpEnablement( + D3D12_DRED_ENABLEMENT Enablement) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceRemovedExtendedDataSettingsVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceRemovedExtendedDataSettings * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceRemovedExtendedDataSettings * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceRemovedExtendedDataSettings * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetAutoBreadcrumbsEnablement) + void ( STDMETHODCALLTYPE *SetAutoBreadcrumbsEnablement )( + ID3D12DeviceRemovedExtendedDataSettings * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetPageFaultEnablement) + void ( STDMETHODCALLTYPE *SetPageFaultEnablement )( + ID3D12DeviceRemovedExtendedDataSettings * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetWatsonDumpEnablement) + void ( STDMETHODCALLTYPE *SetWatsonDumpEnablement )( + ID3D12DeviceRemovedExtendedDataSettings * This, + D3D12_DRED_ENABLEMENT Enablement); + + END_INTERFACE + } ID3D12DeviceRemovedExtendedDataSettingsVtbl; + + interface ID3D12DeviceRemovedExtendedDataSettings + { + CONST_VTBL struct ID3D12DeviceRemovedExtendedDataSettingsVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceRemovedExtendedDataSettings_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceRemovedExtendedDataSettings_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceRemovedExtendedDataSettings_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceRemovedExtendedDataSettings_SetAutoBreadcrumbsEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetAutoBreadcrumbsEnablement(This,Enablement) ) + +#define ID3D12DeviceRemovedExtendedDataSettings_SetPageFaultEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetPageFaultEnablement(This,Enablement) ) + +#define ID3D12DeviceRemovedExtendedDataSettings_SetWatsonDumpEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetWatsonDumpEnablement(This,Enablement) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceRemovedExtendedDataSettings_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedDataSettings1_INTERFACE_DEFINED__ +#define __ID3D12DeviceRemovedExtendedDataSettings1_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceRemovedExtendedDataSettings1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceRemovedExtendedDataSettings1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("DBD5AE51-3317-4F0A-ADF9-1D7CEDCAAE0B") + ID3D12DeviceRemovedExtendedDataSettings1 : public ID3D12DeviceRemovedExtendedDataSettings + { + public: + virtual void STDMETHODCALLTYPE SetBreadcrumbContextEnablement( + D3D12_DRED_ENABLEMENT Enablement) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceRemovedExtendedDataSettings1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceRemovedExtendedDataSettings1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceRemovedExtendedDataSettings1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceRemovedExtendedDataSettings1 * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetAutoBreadcrumbsEnablement) + void ( STDMETHODCALLTYPE *SetAutoBreadcrumbsEnablement )( + ID3D12DeviceRemovedExtendedDataSettings1 * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetPageFaultEnablement) + void ( STDMETHODCALLTYPE *SetPageFaultEnablement )( + ID3D12DeviceRemovedExtendedDataSettings1 * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetWatsonDumpEnablement) + void ( STDMETHODCALLTYPE *SetWatsonDumpEnablement )( + ID3D12DeviceRemovedExtendedDataSettings1 * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings1, SetBreadcrumbContextEnablement) + void ( STDMETHODCALLTYPE *SetBreadcrumbContextEnablement )( + ID3D12DeviceRemovedExtendedDataSettings1 * This, + D3D12_DRED_ENABLEMENT Enablement); + + END_INTERFACE + } ID3D12DeviceRemovedExtendedDataSettings1Vtbl; + + interface ID3D12DeviceRemovedExtendedDataSettings1 + { + CONST_VTBL struct ID3D12DeviceRemovedExtendedDataSettings1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceRemovedExtendedDataSettings1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceRemovedExtendedDataSettings1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceRemovedExtendedDataSettings1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceRemovedExtendedDataSettings1_SetAutoBreadcrumbsEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetAutoBreadcrumbsEnablement(This,Enablement) ) + +#define ID3D12DeviceRemovedExtendedDataSettings1_SetPageFaultEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetPageFaultEnablement(This,Enablement) ) + +#define ID3D12DeviceRemovedExtendedDataSettings1_SetWatsonDumpEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetWatsonDumpEnablement(This,Enablement) ) + + +#define ID3D12DeviceRemovedExtendedDataSettings1_SetBreadcrumbContextEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetBreadcrumbContextEnablement(This,Enablement) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceRemovedExtendedDataSettings1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedDataSettings2_INTERFACE_DEFINED__ +#define __ID3D12DeviceRemovedExtendedDataSettings2_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceRemovedExtendedDataSettings2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceRemovedExtendedDataSettings2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("61552388-01ab-4008-a436-83db189566ea") + ID3D12DeviceRemovedExtendedDataSettings2 : public ID3D12DeviceRemovedExtendedDataSettings1 + { + public: + virtual void STDMETHODCALLTYPE UseMarkersOnlyAutoBreadcrumbs( + BOOL MarkersOnly) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceRemovedExtendedDataSettings2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceRemovedExtendedDataSettings2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceRemovedExtendedDataSettings2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceRemovedExtendedDataSettings2 * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetAutoBreadcrumbsEnablement) + void ( STDMETHODCALLTYPE *SetAutoBreadcrumbsEnablement )( + ID3D12DeviceRemovedExtendedDataSettings2 * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetPageFaultEnablement) + void ( STDMETHODCALLTYPE *SetPageFaultEnablement )( + ID3D12DeviceRemovedExtendedDataSettings2 * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings, SetWatsonDumpEnablement) + void ( STDMETHODCALLTYPE *SetWatsonDumpEnablement )( + ID3D12DeviceRemovedExtendedDataSettings2 * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings1, SetBreadcrumbContextEnablement) + void ( STDMETHODCALLTYPE *SetBreadcrumbContextEnablement )( + ID3D12DeviceRemovedExtendedDataSettings2 * This, + D3D12_DRED_ENABLEMENT Enablement); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedDataSettings2, UseMarkersOnlyAutoBreadcrumbs) + void ( STDMETHODCALLTYPE *UseMarkersOnlyAutoBreadcrumbs )( + ID3D12DeviceRemovedExtendedDataSettings2 * This, + BOOL MarkersOnly); + + END_INTERFACE + } ID3D12DeviceRemovedExtendedDataSettings2Vtbl; + + interface ID3D12DeviceRemovedExtendedDataSettings2 + { + CONST_VTBL struct ID3D12DeviceRemovedExtendedDataSettings2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceRemovedExtendedDataSettings2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceRemovedExtendedDataSettings2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceRemovedExtendedDataSettings2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceRemovedExtendedDataSettings2_SetAutoBreadcrumbsEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetAutoBreadcrumbsEnablement(This,Enablement) ) + +#define ID3D12DeviceRemovedExtendedDataSettings2_SetPageFaultEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetPageFaultEnablement(This,Enablement) ) + +#define ID3D12DeviceRemovedExtendedDataSettings2_SetWatsonDumpEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetWatsonDumpEnablement(This,Enablement) ) + + +#define ID3D12DeviceRemovedExtendedDataSettings2_SetBreadcrumbContextEnablement(This,Enablement) \ + ( (This)->lpVtbl -> SetBreadcrumbContextEnablement(This,Enablement) ) + + +#define ID3D12DeviceRemovedExtendedDataSettings2_UseMarkersOnlyAutoBreadcrumbs(This,MarkersOnly) \ + ( (This)->lpVtbl -> UseMarkersOnlyAutoBreadcrumbs(This,MarkersOnly) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceRemovedExtendedDataSettings2_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedData_INTERFACE_DEFINED__ +#define __ID3D12DeviceRemovedExtendedData_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceRemovedExtendedData */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceRemovedExtendedData; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("98931D33-5AE8-4791-AA3C-1A73A2934E71") + ID3D12DeviceRemovedExtendedData : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetAutoBreadcrumbsOutput( + _Out_ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT *pOutput) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetPageFaultAllocationOutput( + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT *pOutput) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceRemovedExtendedDataVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceRemovedExtendedData * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceRemovedExtendedData * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceRemovedExtendedData * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData, GetAutoBreadcrumbsOutput) + HRESULT ( STDMETHODCALLTYPE *GetAutoBreadcrumbsOutput )( + ID3D12DeviceRemovedExtendedData * This, + _Out_ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData, GetPageFaultAllocationOutput) + HRESULT ( STDMETHODCALLTYPE *GetPageFaultAllocationOutput )( + ID3D12DeviceRemovedExtendedData * This, + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT *pOutput); + + END_INTERFACE + } ID3D12DeviceRemovedExtendedDataVtbl; + + interface ID3D12DeviceRemovedExtendedData + { + CONST_VTBL struct ID3D12DeviceRemovedExtendedDataVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceRemovedExtendedData_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceRemovedExtendedData_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceRemovedExtendedData_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceRemovedExtendedData_GetAutoBreadcrumbsOutput(This,pOutput) \ + ( (This)->lpVtbl -> GetAutoBreadcrumbsOutput(This,pOutput) ) + +#define ID3D12DeviceRemovedExtendedData_GetPageFaultAllocationOutput(This,pOutput) \ + ( (This)->lpVtbl -> GetPageFaultAllocationOutput(This,pOutput) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceRemovedExtendedData_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedData1_INTERFACE_DEFINED__ +#define __ID3D12DeviceRemovedExtendedData1_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceRemovedExtendedData1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceRemovedExtendedData1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9727A022-CF1D-4DDA-9EBA-EFFA653FC506") + ID3D12DeviceRemovedExtendedData1 : public ID3D12DeviceRemovedExtendedData + { + public: + virtual HRESULT STDMETHODCALLTYPE GetAutoBreadcrumbsOutput1( + _Out_ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 *pOutput) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetPageFaultAllocationOutput1( + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT1 *pOutput) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceRemovedExtendedData1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceRemovedExtendedData1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceRemovedExtendedData1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceRemovedExtendedData1 * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData, GetAutoBreadcrumbsOutput) + HRESULT ( STDMETHODCALLTYPE *GetAutoBreadcrumbsOutput )( + ID3D12DeviceRemovedExtendedData1 * This, + _Out_ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData, GetPageFaultAllocationOutput) + HRESULT ( STDMETHODCALLTYPE *GetPageFaultAllocationOutput )( + ID3D12DeviceRemovedExtendedData1 * This, + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData1, GetAutoBreadcrumbsOutput1) + HRESULT ( STDMETHODCALLTYPE *GetAutoBreadcrumbsOutput1 )( + ID3D12DeviceRemovedExtendedData1 * This, + _Out_ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData1, GetPageFaultAllocationOutput1) + HRESULT ( STDMETHODCALLTYPE *GetPageFaultAllocationOutput1 )( + ID3D12DeviceRemovedExtendedData1 * This, + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT1 *pOutput); + + END_INTERFACE + } ID3D12DeviceRemovedExtendedData1Vtbl; + + interface ID3D12DeviceRemovedExtendedData1 + { + CONST_VTBL struct ID3D12DeviceRemovedExtendedData1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceRemovedExtendedData1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceRemovedExtendedData1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceRemovedExtendedData1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceRemovedExtendedData1_GetAutoBreadcrumbsOutput(This,pOutput) \ + ( (This)->lpVtbl -> GetAutoBreadcrumbsOutput(This,pOutput) ) + +#define ID3D12DeviceRemovedExtendedData1_GetPageFaultAllocationOutput(This,pOutput) \ + ( (This)->lpVtbl -> GetPageFaultAllocationOutput(This,pOutput) ) + + +#define ID3D12DeviceRemovedExtendedData1_GetAutoBreadcrumbsOutput1(This,pOutput) \ + ( (This)->lpVtbl -> GetAutoBreadcrumbsOutput1(This,pOutput) ) + +#define ID3D12DeviceRemovedExtendedData1_GetPageFaultAllocationOutput1(This,pOutput) \ + ( (This)->lpVtbl -> GetPageFaultAllocationOutput1(This,pOutput) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceRemovedExtendedData1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceRemovedExtendedData2_INTERFACE_DEFINED__ +#define __ID3D12DeviceRemovedExtendedData2_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceRemovedExtendedData2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceRemovedExtendedData2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("67FC5816-E4CA-4915-BF18-42541272DA54") + ID3D12DeviceRemovedExtendedData2 : public ID3D12DeviceRemovedExtendedData1 + { + public: + virtual HRESULT STDMETHODCALLTYPE GetPageFaultAllocationOutput2( + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT2 *pOutput) = 0; + + virtual D3D12_DRED_DEVICE_STATE STDMETHODCALLTYPE GetDeviceState( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceRemovedExtendedData2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceRemovedExtendedData2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceRemovedExtendedData2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceRemovedExtendedData2 * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData, GetAutoBreadcrumbsOutput) + HRESULT ( STDMETHODCALLTYPE *GetAutoBreadcrumbsOutput )( + ID3D12DeviceRemovedExtendedData2 * This, + _Out_ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData, GetPageFaultAllocationOutput) + HRESULT ( STDMETHODCALLTYPE *GetPageFaultAllocationOutput )( + ID3D12DeviceRemovedExtendedData2 * This, + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData1, GetAutoBreadcrumbsOutput1) + HRESULT ( STDMETHODCALLTYPE *GetAutoBreadcrumbsOutput1 )( + ID3D12DeviceRemovedExtendedData2 * This, + _Out_ D3D12_DRED_AUTO_BREADCRUMBS_OUTPUT1 *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData1, GetPageFaultAllocationOutput1) + HRESULT ( STDMETHODCALLTYPE *GetPageFaultAllocationOutput1 )( + ID3D12DeviceRemovedExtendedData2 * This, + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT1 *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData2, GetPageFaultAllocationOutput2) + HRESULT ( STDMETHODCALLTYPE *GetPageFaultAllocationOutput2 )( + ID3D12DeviceRemovedExtendedData2 * This, + _Out_ D3D12_DRED_PAGE_FAULT_OUTPUT2 *pOutput); + + DECLSPEC_XFGVIRT(ID3D12DeviceRemovedExtendedData2, GetDeviceState) + D3D12_DRED_DEVICE_STATE ( STDMETHODCALLTYPE *GetDeviceState )( + ID3D12DeviceRemovedExtendedData2 * This); + + END_INTERFACE + } ID3D12DeviceRemovedExtendedData2Vtbl; + + interface ID3D12DeviceRemovedExtendedData2 + { + CONST_VTBL struct ID3D12DeviceRemovedExtendedData2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceRemovedExtendedData2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceRemovedExtendedData2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceRemovedExtendedData2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceRemovedExtendedData2_GetAutoBreadcrumbsOutput(This,pOutput) \ + ( (This)->lpVtbl -> GetAutoBreadcrumbsOutput(This,pOutput) ) + +#define ID3D12DeviceRemovedExtendedData2_GetPageFaultAllocationOutput(This,pOutput) \ + ( (This)->lpVtbl -> GetPageFaultAllocationOutput(This,pOutput) ) + + +#define ID3D12DeviceRemovedExtendedData2_GetAutoBreadcrumbsOutput1(This,pOutput) \ + ( (This)->lpVtbl -> GetAutoBreadcrumbsOutput1(This,pOutput) ) + +#define ID3D12DeviceRemovedExtendedData2_GetPageFaultAllocationOutput1(This,pOutput) \ + ( (This)->lpVtbl -> GetPageFaultAllocationOutput1(This,pOutput) ) + + +#define ID3D12DeviceRemovedExtendedData2_GetPageFaultAllocationOutput2(This,pOutput) \ + ( (This)->lpVtbl -> GetPageFaultAllocationOutput2(This,pOutput) ) + +#define ID3D12DeviceRemovedExtendedData2_GetDeviceState(This) \ + ( (This)->lpVtbl -> GetDeviceState(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceRemovedExtendedData2_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0043 */ +/* [local] */ + +typedef +enum D3D12_BACKGROUND_PROCESSING_MODE + { + D3D12_BACKGROUND_PROCESSING_MODE_ALLOWED = 0, + D3D12_BACKGROUND_PROCESSING_MODE_ALLOW_INTRUSIVE_MEASUREMENTS = ( D3D12_BACKGROUND_PROCESSING_MODE_ALLOWED + 1 ) , + D3D12_BACKGROUND_PROCESSING_MODE_DISABLE_BACKGROUND_WORK = ( D3D12_BACKGROUND_PROCESSING_MODE_ALLOW_INTRUSIVE_MEASUREMENTS + 1 ) , + D3D12_BACKGROUND_PROCESSING_MODE_DISABLE_PROFILING_BY_SYSTEM = ( D3D12_BACKGROUND_PROCESSING_MODE_DISABLE_BACKGROUND_WORK + 1 ) + } D3D12_BACKGROUND_PROCESSING_MODE; + +typedef +enum D3D12_MEASUREMENTS_ACTION + { + D3D12_MEASUREMENTS_ACTION_KEEP_ALL = 0, + D3D12_MEASUREMENTS_ACTION_COMMIT_RESULTS = ( D3D12_MEASUREMENTS_ACTION_KEEP_ALL + 1 ) , + D3D12_MEASUREMENTS_ACTION_COMMIT_RESULTS_HIGH_PRIORITY = ( D3D12_MEASUREMENTS_ACTION_COMMIT_RESULTS + 1 ) , + D3D12_MEASUREMENTS_ACTION_DISCARD_PREVIOUS = ( D3D12_MEASUREMENTS_ACTION_COMMIT_RESULTS_HIGH_PRIORITY + 1 ) + } D3D12_MEASUREMENTS_ACTION; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0043_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0043_v0_0_s_ifspec; + +#ifndef __ID3D12Device6_INTERFACE_DEFINED__ +#define __ID3D12Device6_INTERFACE_DEFINED__ + +/* interface ID3D12Device6 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device6; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("c70b221b-40e4-4a17-89af-025a0727a6dc") + ID3D12Device6 : public ID3D12Device5 + { + public: + virtual HRESULT STDMETHODCALLTYPE SetBackgroundProcessingMode( + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device6Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device6 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device6 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device6 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device6 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device6 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device6 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device6 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device6 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device6 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device6 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device6 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device6 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device6 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device6 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device6 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device6 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device6 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device6 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device6 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device6 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device6 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device6 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device6 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device6 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device6 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device6 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device6 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device6 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device6 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device6 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device6 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device6 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device6 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device6 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device6 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device6 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device6 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device6 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device6 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device6 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device6 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device6 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device6 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device6 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device6 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device6 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device6 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device6 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device6 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device6 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device6 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device6 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device6 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device6 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device6 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device6 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device6 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device6 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device6 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device6 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device6 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device6 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device6 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device6 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device6 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device6 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device6 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device6 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device6 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device6 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + END_INTERFACE + } ID3D12Device6Vtbl; + + interface ID3D12Device6 + { + CONST_VTBL struct ID3D12Device6Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device6_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device6_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device6_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device6_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device6_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device6_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device6_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device6_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device6_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device6_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device6_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device6_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device6_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device6_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device6_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device6_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device6_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device6_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device6_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device6_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device6_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device6_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device6_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device6_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device6_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device6_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device6_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device6_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device6_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device6_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device6_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device6_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device6_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device6_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device6_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device6_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device6_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device6_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device6_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device6_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device6_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device6_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device6_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device6_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device6_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device6_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device6_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device6_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device6_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device6_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device6_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device6_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device6_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device6_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device6_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device6_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device6_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device6_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device6_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device6_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device6_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device6_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device6_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device6_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device6_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device6_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device6_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device6_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device6_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device6_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device6_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0044 */ +/* [local] */ + +DEFINE_GUID(D3D12_PROTECTED_RESOURCES_SESSION_HARDWARE_PROTECTED, 0x62B0084E, 0xC70E, 0x4DAA, 0xA1, 0x09, 0x30, 0xFF, 0x8D, 0x5A, 0x04, 0x82); +typedef struct D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPE_COUNT + { + UINT NodeIndex; + UINT Count; + } D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPE_COUNT; + +typedef struct D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES + { + UINT NodeIndex; + UINT Count; + GUID *pTypes; + } D3D12_FEATURE_DATA_PROTECTED_RESOURCE_SESSION_TYPES; + +typedef struct D3D12_PROTECTED_RESOURCE_SESSION_DESC1 + { + UINT NodeMask; + D3D12_PROTECTED_RESOURCE_SESSION_FLAGS Flags; + GUID ProtectionType; + } D3D12_PROTECTED_RESOURCE_SESSION_DESC1; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0044_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0044_v0_0_s_ifspec; + +#ifndef __ID3D12ProtectedResourceSession1_INTERFACE_DEFINED__ +#define __ID3D12ProtectedResourceSession1_INTERFACE_DEFINED__ + +/* interface ID3D12ProtectedResourceSession1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12ProtectedResourceSession1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("D6F12DD6-76FB-406E-8961-4296EEFC0409") + ID3D12ProtectedResourceSession1 : public ID3D12ProtectedResourceSession + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_PROTECTED_RESOURCE_SESSION_DESC1 STDMETHODCALLTYPE GetDesc1( void) = 0; +#else + virtual D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *STDMETHODCALLTYPE GetDesc1( + D3D12_PROTECTED_RESOURCE_SESSION_DESC1 * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ProtectedResourceSession1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12ProtectedResourceSession1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12ProtectedResourceSession1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12ProtectedResourceSession1 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12ProtectedResourceSession1 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12ProtectedResourceSession1 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12ProtectedResourceSession1 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12ProtectedResourceSession1 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12ProtectedResourceSession1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12ProtectedSession, GetStatusFence) + HRESULT ( STDMETHODCALLTYPE *GetStatusFence )( + ID3D12ProtectedResourceSession1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12ProtectedSession, GetSessionStatus) + D3D12_PROTECTED_SESSION_STATUS ( STDMETHODCALLTYPE *GetSessionStatus )( + ID3D12ProtectedResourceSession1 * This); + + DECLSPEC_XFGVIRT(ID3D12ProtectedResourceSession, GetDesc) +#if !defined(_WIN32) + D3D12_PROTECTED_RESOURCE_SESSION_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12ProtectedResourceSession1 * This); + +#else + D3D12_PROTECTED_RESOURCE_SESSION_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12ProtectedResourceSession1 * This, + D3D12_PROTECTED_RESOURCE_SESSION_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12ProtectedResourceSession1, GetDesc1) +#if !defined(_WIN32) + D3D12_PROTECTED_RESOURCE_SESSION_DESC1 ( STDMETHODCALLTYPE *GetDesc1 )( + ID3D12ProtectedResourceSession1 * This); + +#else + D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *( STDMETHODCALLTYPE *GetDesc1 )( + ID3D12ProtectedResourceSession1 * This, + D3D12_PROTECTED_RESOURCE_SESSION_DESC1 * RetVal); + +#endif + + END_INTERFACE + } ID3D12ProtectedResourceSession1Vtbl; + + interface ID3D12ProtectedResourceSession1 + { + CONST_VTBL struct ID3D12ProtectedResourceSession1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12ProtectedResourceSession1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12ProtectedResourceSession1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12ProtectedResourceSession1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12ProtectedResourceSession1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12ProtectedResourceSession1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12ProtectedResourceSession1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12ProtectedResourceSession1_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12ProtectedResourceSession1_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12ProtectedResourceSession1_GetStatusFence(This,riid,ppFence) \ + ( (This)->lpVtbl -> GetStatusFence(This,riid,ppFence) ) + +#define ID3D12ProtectedResourceSession1_GetSessionStatus(This) \ + ( (This)->lpVtbl -> GetSessionStatus(This) ) + +#if !defined(_WIN32) + +#define ID3D12ProtectedResourceSession1_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12ProtectedResourceSession1_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#if !defined(_WIN32) + +#define ID3D12ProtectedResourceSession1_GetDesc1(This) \ + ( (This)->lpVtbl -> GetDesc1(This) ) +#else +#define ID3D12ProtectedResourceSession1_GetDesc1(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc1(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12ProtectedResourceSession1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device7_INTERFACE_DEFINED__ +#define __ID3D12Device7_INTERFACE_DEFINED__ + +/* interface ID3D12Device7 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device7; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5c014b53-68a1-4b9b-8bd1-dd6046b9358b") + ID3D12Device7 : public ID3D12Device6 + { + public: + virtual HRESULT STDMETHODCALLTYPE AddToStateObject( + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateProtectedResourceSession1( + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device7Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device7 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device7 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device7 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device7 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device7 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device7 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device7 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device7 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device7 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device7 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device7 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device7 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device7 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device7 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device7 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device7 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device7 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device7 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device7 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device7 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device7 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device7 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device7 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device7 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device7 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device7 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device7 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device7 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device7 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device7 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device7 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device7 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device7 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device7 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device7 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device7 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device7 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device7 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device7 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device7 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device7 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device7 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device7 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device7 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device7 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device7 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device7 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device7 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device7 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device7 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device7 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device7 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device7 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device7 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device7 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device7 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device7 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device7 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device7 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device7 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device7 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device7 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device7 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device7 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device7 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device7 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device7 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device7 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device7 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device7 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device7 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device7 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + END_INTERFACE + } ID3D12Device7Vtbl; + + interface ID3D12Device7 + { + CONST_VTBL struct ID3D12Device7Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device7_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device7_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device7_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device7_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device7_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device7_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device7_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device7_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device7_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device7_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device7_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device7_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device7_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device7_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device7_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device7_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device7_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device7_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device7_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device7_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device7_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device7_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device7_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device7_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device7_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device7_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device7_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device7_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device7_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device7_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device7_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device7_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device7_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device7_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device7_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device7_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device7_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device7_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device7_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device7_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device7_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device7_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device7_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device7_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device7_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device7_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device7_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device7_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device7_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device7_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device7_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device7_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device7_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device7_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device7_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device7_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device7_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device7_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device7_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device7_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device7_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device7_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device7_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device7_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device7_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device7_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device7_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device7_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device7_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device7_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device7_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device7_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device7_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device8_INTERFACE_DEFINED__ +#define __ID3D12Device8_INTERFACE_DEFINED__ + +/* interface ID3D12Device8 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device8; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9218E6BB-F944-4F7E-A75C-B1B2C7B701F3") + ID3D12Device8 : public ID3D12Device7 + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_RESOURCE_ALLOCATION_INFO STDMETHODCALLTYPE GetResourceAllocationInfo2( + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1) = 0; +#else + virtual D3D12_RESOURCE_ALLOCATION_INFO *STDMETHODCALLTYPE GetResourceAllocationInfo2( + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1) = 0; +#endif + + virtual HRESULT STDMETHODCALLTYPE CreateCommittedResource2( + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreatePlacedResource1( + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual void STDMETHODCALLTYPE CreateSamplerFeedbackUnorderedAccessView( + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + virtual void STDMETHODCALLTYPE GetCopyableFootprints1( + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device8Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device8 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device8 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device8 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device8 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device8 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device8 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device8 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device8 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device8 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device8 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device8 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device8 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device8 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device8 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device8 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device8 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device8 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device8 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device8 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device8 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device8 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device8 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device8 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device8 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device8 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device8 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device8 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device8 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device8 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device8 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device8 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device8 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device8 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device8 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device8 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device8 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device8 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device8 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device8 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device8 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device8 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device8 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device8 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device8 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device8 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device8 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device8 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device8 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device8 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device8 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device8 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device8 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device8 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device8 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device8 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device8 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device8 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device8 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device8 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device8 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device8 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device8 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device8 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device8 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device8 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device8 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device8 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device8 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device8 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device8 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device8 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device8 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device8 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device8 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device8 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device8 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device8 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device8 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + END_INTERFACE + } ID3D12Device8Vtbl; + + interface ID3D12Device8 + { + CONST_VTBL struct ID3D12Device8Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device8_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device8_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device8_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device8_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device8_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device8_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device8_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device8_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device8_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device8_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device8_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device8_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device8_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device8_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device8_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device8_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device8_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device8_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device8_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device8_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device8_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device8_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device8_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device8_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device8_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device8_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device8_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device8_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device8_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device8_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device8_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device8_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device8_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device8_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device8_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device8_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device8_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device8_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device8_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device8_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device8_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device8_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device8_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device8_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device8_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device8_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device8_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device8_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device8_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device8_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device8_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device8_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device8_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device8_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device8_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device8_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device8_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device8_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device8_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device8_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device8_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device8_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device8_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device8_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device8_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device8_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device8_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device8_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device8_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device8_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device8_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device8_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device8_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device8_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device8_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device8_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device8_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device8_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device8_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Resource1_INTERFACE_DEFINED__ +#define __ID3D12Resource1_INTERFACE_DEFINED__ + +/* interface ID3D12Resource1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Resource1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("9D5E227A-4430-4161-88B3-3ECA6BB16E19") + ID3D12Resource1 : public ID3D12Resource + { + public: + virtual HRESULT STDMETHODCALLTYPE GetProtectedResourceSession( + REFIID riid, + _COM_Outptr_opt_ void **ppProtectedSession) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Resource1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Resource1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Resource1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Resource1 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Resource1 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Resource1 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Resource1 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Resource1 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Resource1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12Resource, Map) + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D12Resource1 * This, + UINT Subresource, + _In_opt_ const D3D12_RANGE *pReadRange, + _Outptr_opt_result_bytebuffer_(_Inexpressible_("Dependent on resource")) void **ppData); + + DECLSPEC_XFGVIRT(ID3D12Resource, Unmap) + void ( STDMETHODCALLTYPE *Unmap )( + ID3D12Resource1 * This, + UINT Subresource, + _In_opt_ const D3D12_RANGE *pWrittenRange); + + DECLSPEC_XFGVIRT(ID3D12Resource, GetDesc) +#if !defined(_WIN32) + D3D12_RESOURCE_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12Resource1 * This); + +#else + D3D12_RESOURCE_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12Resource1 * This, + D3D12_RESOURCE_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Resource, GetGPUVirtualAddress) + D3D12_GPU_VIRTUAL_ADDRESS ( STDMETHODCALLTYPE *GetGPUVirtualAddress )( + ID3D12Resource1 * This); + + DECLSPEC_XFGVIRT(ID3D12Resource, WriteToSubresource) + HRESULT ( STDMETHODCALLTYPE *WriteToSubresource )( + ID3D12Resource1 * This, + UINT DstSubresource, + _In_opt_ const D3D12_BOX *pDstBox, + _In_ const void *pSrcData, + UINT SrcRowPitch, + UINT SrcDepthPitch); + + DECLSPEC_XFGVIRT(ID3D12Resource, ReadFromSubresource) + HRESULT ( STDMETHODCALLTYPE *ReadFromSubresource )( + ID3D12Resource1 * This, + _Out_ void *pDstData, + UINT DstRowPitch, + UINT DstDepthPitch, + UINT SrcSubresource, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12Resource, GetHeapProperties) + HRESULT ( STDMETHODCALLTYPE *GetHeapProperties )( + ID3D12Resource1 * This, + _Out_opt_ D3D12_HEAP_PROPERTIES *pHeapProperties, + _Out_opt_ D3D12_HEAP_FLAGS *pHeapFlags); + + DECLSPEC_XFGVIRT(ID3D12Resource1, GetProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *GetProtectedResourceSession )( + ID3D12Resource1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppProtectedSession); + + END_INTERFACE + } ID3D12Resource1Vtbl; + + interface ID3D12Resource1 + { + CONST_VTBL struct ID3D12Resource1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Resource1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Resource1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Resource1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Resource1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Resource1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Resource1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Resource1_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Resource1_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12Resource1_Map(This,Subresource,pReadRange,ppData) \ + ( (This)->lpVtbl -> Map(This,Subresource,pReadRange,ppData) ) + +#define ID3D12Resource1_Unmap(This,Subresource,pWrittenRange) \ + ( (This)->lpVtbl -> Unmap(This,Subresource,pWrittenRange) ) +#if !defined(_WIN32) + +#define ID3D12Resource1_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12Resource1_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#define ID3D12Resource1_GetGPUVirtualAddress(This) \ + ( (This)->lpVtbl -> GetGPUVirtualAddress(This) ) + +#define ID3D12Resource1_WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D12Resource1_ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) ) + +#define ID3D12Resource1_GetHeapProperties(This,pHeapProperties,pHeapFlags) \ + ( (This)->lpVtbl -> GetHeapProperties(This,pHeapProperties,pHeapFlags) ) + + +#define ID3D12Resource1_GetProtectedResourceSession(This,riid,ppProtectedSession) \ + ( (This)->lpVtbl -> GetProtectedResourceSession(This,riid,ppProtectedSession) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Resource1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Resource2_INTERFACE_DEFINED__ +#define __ID3D12Resource2_INTERFACE_DEFINED__ + +/* interface ID3D12Resource2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Resource2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("BE36EC3B-EA85-4AEB-A45A-E9D76404A495") + ID3D12Resource2 : public ID3D12Resource1 + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_RESOURCE_DESC1 STDMETHODCALLTYPE GetDesc1( void) = 0; +#else + virtual D3D12_RESOURCE_DESC1 *STDMETHODCALLTYPE GetDesc1( + D3D12_RESOURCE_DESC1 * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Resource2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Resource2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Resource2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Resource2 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Resource2 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Resource2 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Resource2 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Resource2 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Resource2 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12Resource, Map) + HRESULT ( STDMETHODCALLTYPE *Map )( + ID3D12Resource2 * This, + UINT Subresource, + _In_opt_ const D3D12_RANGE *pReadRange, + _Outptr_opt_result_bytebuffer_(_Inexpressible_("Dependent on resource")) void **ppData); + + DECLSPEC_XFGVIRT(ID3D12Resource, Unmap) + void ( STDMETHODCALLTYPE *Unmap )( + ID3D12Resource2 * This, + UINT Subresource, + _In_opt_ const D3D12_RANGE *pWrittenRange); + + DECLSPEC_XFGVIRT(ID3D12Resource, GetDesc) +#if !defined(_WIN32) + D3D12_RESOURCE_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12Resource2 * This); + +#else + D3D12_RESOURCE_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12Resource2 * This, + D3D12_RESOURCE_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Resource, GetGPUVirtualAddress) + D3D12_GPU_VIRTUAL_ADDRESS ( STDMETHODCALLTYPE *GetGPUVirtualAddress )( + ID3D12Resource2 * This); + + DECLSPEC_XFGVIRT(ID3D12Resource, WriteToSubresource) + HRESULT ( STDMETHODCALLTYPE *WriteToSubresource )( + ID3D12Resource2 * This, + UINT DstSubresource, + _In_opt_ const D3D12_BOX *pDstBox, + _In_ const void *pSrcData, + UINT SrcRowPitch, + UINT SrcDepthPitch); + + DECLSPEC_XFGVIRT(ID3D12Resource, ReadFromSubresource) + HRESULT ( STDMETHODCALLTYPE *ReadFromSubresource )( + ID3D12Resource2 * This, + _Out_ void *pDstData, + UINT DstRowPitch, + UINT DstDepthPitch, + UINT SrcSubresource, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12Resource, GetHeapProperties) + HRESULT ( STDMETHODCALLTYPE *GetHeapProperties )( + ID3D12Resource2 * This, + _Out_opt_ D3D12_HEAP_PROPERTIES *pHeapProperties, + _Out_opt_ D3D12_HEAP_FLAGS *pHeapFlags); + + DECLSPEC_XFGVIRT(ID3D12Resource1, GetProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *GetProtectedResourceSession )( + ID3D12Resource2 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppProtectedSession); + + DECLSPEC_XFGVIRT(ID3D12Resource2, GetDesc1) +#if !defined(_WIN32) + D3D12_RESOURCE_DESC1 ( STDMETHODCALLTYPE *GetDesc1 )( + ID3D12Resource2 * This); + +#else + D3D12_RESOURCE_DESC1 *( STDMETHODCALLTYPE *GetDesc1 )( + ID3D12Resource2 * This, + D3D12_RESOURCE_DESC1 * RetVal); + +#endif + + END_INTERFACE + } ID3D12Resource2Vtbl; + + interface ID3D12Resource2 + { + CONST_VTBL struct ID3D12Resource2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Resource2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Resource2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Resource2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Resource2_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Resource2_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Resource2_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Resource2_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Resource2_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12Resource2_Map(This,Subresource,pReadRange,ppData) \ + ( (This)->lpVtbl -> Map(This,Subresource,pReadRange,ppData) ) + +#define ID3D12Resource2_Unmap(This,Subresource,pWrittenRange) \ + ( (This)->lpVtbl -> Unmap(This,Subresource,pWrittenRange) ) +#if !defined(_WIN32) + +#define ID3D12Resource2_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12Resource2_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#define ID3D12Resource2_GetGPUVirtualAddress(This) \ + ( (This)->lpVtbl -> GetGPUVirtualAddress(This) ) + +#define ID3D12Resource2_WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) \ + ( (This)->lpVtbl -> WriteToSubresource(This,DstSubresource,pDstBox,pSrcData,SrcRowPitch,SrcDepthPitch) ) + +#define ID3D12Resource2_ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) \ + ( (This)->lpVtbl -> ReadFromSubresource(This,pDstData,DstRowPitch,DstDepthPitch,SrcSubresource,pSrcBox) ) + +#define ID3D12Resource2_GetHeapProperties(This,pHeapProperties,pHeapFlags) \ + ( (This)->lpVtbl -> GetHeapProperties(This,pHeapProperties,pHeapFlags) ) + + +#define ID3D12Resource2_GetProtectedResourceSession(This,riid,ppProtectedSession) \ + ( (This)->lpVtbl -> GetProtectedResourceSession(This,riid,ppProtectedSession) ) + +#if !defined(_WIN32) + +#define ID3D12Resource2_GetDesc1(This) \ + ( (This)->lpVtbl -> GetDesc1(This) ) +#else +#define ID3D12Resource2_GetDesc1(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc1(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Resource2_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Heap1_INTERFACE_DEFINED__ +#define __ID3D12Heap1_INTERFACE_DEFINED__ + +/* interface ID3D12Heap1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Heap1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("572F7389-2168-49E3-9693-D6DF5871BF6D") + ID3D12Heap1 : public ID3D12Heap + { + public: + virtual HRESULT STDMETHODCALLTYPE GetProtectedResourceSession( + REFIID riid, + _COM_Outptr_opt_ void **ppProtectedSession) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Heap1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Heap1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Heap1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Heap1 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Heap1 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Heap1 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Heap1 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Heap1 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12Heap1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12Heap, GetDesc) +#if !defined(_WIN32) + D3D12_HEAP_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12Heap1 * This); + +#else + D3D12_HEAP_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12Heap1 * This, + D3D12_HEAP_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Heap1, GetProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *GetProtectedResourceSession )( + ID3D12Heap1 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppProtectedSession); + + END_INTERFACE + } ID3D12Heap1Vtbl; + + interface ID3D12Heap1 + { + CONST_VTBL struct ID3D12Heap1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Heap1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Heap1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Heap1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Heap1_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Heap1_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Heap1_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Heap1_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Heap1_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#if !defined(_WIN32) + +#define ID3D12Heap1_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12Heap1_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + + +#define ID3D12Heap1_GetProtectedResourceSession(This,riid,ppProtectedSession) \ + ( (This)->lpVtbl -> GetProtectedResourceSession(This,riid,ppProtectedSession) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Heap1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList3_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList3_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList3 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList3; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("6FDA83A7-B84C-4E38-9AC8-C7BD22016B3D") + ID3D12GraphicsCommandList3 : public ID3D12GraphicsCommandList2 + { + public: + virtual void STDMETHODCALLTYPE SetProtectedResourceSession( + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList3Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList3 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList3 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList3 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList3 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList3 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList3 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList3 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList3 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList3 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList3 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList3 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList3 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList3 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList3 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList3 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList3 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList3 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList3 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList3 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList3 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList3 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList3 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList3 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList3 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList3 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList3 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList3 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList3 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList3 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList3 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList3 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList3 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + END_INTERFACE + } ID3D12GraphicsCommandList3Vtbl; + + interface ID3D12GraphicsCommandList3 + { + CONST_VTBL struct ID3D12GraphicsCommandList3Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList3_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList3_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList3_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList3_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList3_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList3_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList3_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList3_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList3_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList3_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList3_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList3_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList3_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList3_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList3_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList3_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList3_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList3_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList3_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList3_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList3_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList3_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList3_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList3_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList3_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList3_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList3_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList3_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList3_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList3_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList3_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList3_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList3_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList3_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList3_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList3_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList3_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList3_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList3_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList3_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList3_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList3_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList3_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList3_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList3_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList3_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList3_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList3_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList3_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList3_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList3_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList3_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList3_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList3_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList3_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList3_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList3_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList3_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList3_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList3_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList3_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList3_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList3_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList3_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList3_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList3_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList3_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList3_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList3_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0051 */ +/* [local] */ + +typedef +enum D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE + { + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD = 0, + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE = ( D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_DISCARD + 1 ) , + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR = ( D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE + 1 ) , + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS = ( D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_CLEAR + 1 ) , + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER = ( D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_NO_ACCESS + 1 ) , + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_SRV = ( D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER + 1 ) , + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_UAV = ( D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE_PRESERVE_LOCAL_SRV + 1 ) + } D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE; + +typedef struct D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS + { + D3D12_CLEAR_VALUE ClearValue; + } D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS; + +typedef struct D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS + { + UINT AdditionalWidth; + UINT AdditionalHeight; + } D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS; + +typedef struct D3D12_RENDER_PASS_BEGINNING_ACCESS + { + D3D12_RENDER_PASS_BEGINNING_ACCESS_TYPE Type; + union + { + D3D12_RENDER_PASS_BEGINNING_ACCESS_CLEAR_PARAMETERS Clear; + D3D12_RENDER_PASS_BEGINNING_ACCESS_PRESERVE_LOCAL_PARAMETERS PreserveLocal; + } ; + } D3D12_RENDER_PASS_BEGINNING_ACCESS; + +typedef +enum D3D12_RENDER_PASS_ENDING_ACCESS_TYPE + { + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD = 0, + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE = ( D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD + 1 ) , + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE = ( D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE + 1 ) , + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS = ( D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_RESOLVE + 1 ) , + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER = ( D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_NO_ACCESS + 1 ) , + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_SRV = ( D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_RENDER + 1 ) , + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_UAV = ( D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE_LOCAL_SRV + 1 ) + } D3D12_RENDER_PASS_ENDING_ACCESS_TYPE; + +typedef struct D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS + { + UINT SrcSubresource; + UINT DstSubresource; + UINT DstX; + UINT DstY; + D3D12_RECT SrcRect; + } D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS; + +typedef struct D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS + { + ID3D12Resource *pSrcResource; + ID3D12Resource *pDstResource; + UINT SubresourceCount; + _Field_size_full_(SubresourceCount) const D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_SUBRESOURCE_PARAMETERS *pSubresourceParameters; + DXGI_FORMAT Format; + D3D12_RESOLVE_MODE ResolveMode; + BOOL PreserveResolveSource; + } D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS; + +typedef struct D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS + { + UINT AdditionalWidth; + UINT AdditionalHeight; + } D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS; + +typedef struct D3D12_RENDER_PASS_ENDING_ACCESS + { + D3D12_RENDER_PASS_ENDING_ACCESS_TYPE Type; + union + { + D3D12_RENDER_PASS_ENDING_ACCESS_RESOLVE_PARAMETERS Resolve; + D3D12_RENDER_PASS_ENDING_ACCESS_PRESERVE_LOCAL_PARAMETERS PreserveLocal; + } ; + } D3D12_RENDER_PASS_ENDING_ACCESS; + +typedef struct D3D12_RENDER_PASS_RENDER_TARGET_DESC + { + D3D12_CPU_DESCRIPTOR_HANDLE cpuDescriptor; + D3D12_RENDER_PASS_BEGINNING_ACCESS BeginningAccess; + D3D12_RENDER_PASS_ENDING_ACCESS EndingAccess; + } D3D12_RENDER_PASS_RENDER_TARGET_DESC; + +typedef struct D3D12_RENDER_PASS_DEPTH_STENCIL_DESC + { + D3D12_CPU_DESCRIPTOR_HANDLE cpuDescriptor; + D3D12_RENDER_PASS_BEGINNING_ACCESS DepthBeginningAccess; + D3D12_RENDER_PASS_BEGINNING_ACCESS StencilBeginningAccess; + D3D12_RENDER_PASS_ENDING_ACCESS DepthEndingAccess; + D3D12_RENDER_PASS_ENDING_ACCESS StencilEndingAccess; + } D3D12_RENDER_PASS_DEPTH_STENCIL_DESC; + +typedef +enum D3D12_RENDER_PASS_FLAGS + { + D3D12_RENDER_PASS_FLAG_NONE = 0, + D3D12_RENDER_PASS_FLAG_ALLOW_UAV_WRITES = 0x1, + D3D12_RENDER_PASS_FLAG_SUSPENDING_PASS = 0x2, + D3D12_RENDER_PASS_FLAG_RESUMING_PASS = 0x4, + D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_DEPTH = 0x8, + D3D12_RENDER_PASS_FLAG_BIND_READ_ONLY_STENCIL = 0x10 + } D3D12_RENDER_PASS_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_RENDER_PASS_FLAGS ) + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0051_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0051_v0_0_s_ifspec; + +#ifndef __ID3D12MetaCommand_INTERFACE_DEFINED__ +#define __ID3D12MetaCommand_INTERFACE_DEFINED__ + +/* interface ID3D12MetaCommand */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12MetaCommand; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("DBB84C27-36CE-4FC9-B801-F048C46AC570") + ID3D12MetaCommand : public ID3D12Pageable + { + public: + virtual UINT64 STDMETHODCALLTYPE GetRequiredParameterResourceSize( + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _In_ UINT ParameterIndex) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12MetaCommandVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12MetaCommand * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12MetaCommand * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12MetaCommand * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12MetaCommand * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12MetaCommand * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12MetaCommand * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12MetaCommand * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12MetaCommand * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12MetaCommand, GetRequiredParameterResourceSize) + UINT64 ( STDMETHODCALLTYPE *GetRequiredParameterResourceSize )( + ID3D12MetaCommand * This, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _In_ UINT ParameterIndex); + + END_INTERFACE + } ID3D12MetaCommandVtbl; + + interface ID3D12MetaCommand + { + CONST_VTBL struct ID3D12MetaCommandVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12MetaCommand_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12MetaCommand_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12MetaCommand_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12MetaCommand_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12MetaCommand_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12MetaCommand_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12MetaCommand_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12MetaCommand_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + + +#define ID3D12MetaCommand_GetRequiredParameterResourceSize(This,Stage,ParameterIndex) \ + ( (This)->lpVtbl -> GetRequiredParameterResourceSize(This,Stage,ParameterIndex) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12MetaCommand_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0052 */ +/* [local] */ + +typedef struct D3D12_DISPATCH_RAYS_DESC + { + D3D12_GPU_VIRTUAL_ADDRESS_RANGE RayGenerationShaderRecord; + D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE MissShaderTable; + D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE HitGroupTable; + D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE CallableShaderTable; + UINT Width; + UINT Height; + UINT Depth; + } D3D12_DISPATCH_RAYS_DESC; + +typedef +enum D3D12_SET_WORK_GRAPH_FLAGS + { + D3D12_SET_WORK_GRAPH_FLAG_NONE = 0, + D3D12_SET_WORK_GRAPH_FLAG_INITIALIZE = 0x1 + } D3D12_SET_WORK_GRAPH_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SET_WORK_GRAPH_FLAGS ) +typedef struct D3D12_SET_WORK_GRAPH_DESC + { + D3D12_PROGRAM_IDENTIFIER ProgramIdentifier; + D3D12_SET_WORK_GRAPH_FLAGS Flags; + D3D12_GPU_VIRTUAL_ADDRESS_RANGE BackingMemory; + D3D12_GPU_VIRTUAL_ADDRESS_RANGE_AND_STRIDE NodeLocalRootArgumentsTable; + } D3D12_SET_WORK_GRAPH_DESC; + +typedef struct D3D12_SET_RAYTRACING_PIPELINE_DESC + { + D3D12_PROGRAM_IDENTIFIER ProgramIdentifier; + } D3D12_SET_RAYTRACING_PIPELINE_DESC; + +typedef struct D3D12_SET_GENERIC_PIPELINE_DESC + { + D3D12_PROGRAM_IDENTIFIER ProgramIdentifier; + } D3D12_SET_GENERIC_PIPELINE_DESC; + +typedef +enum D3D12_PROGRAM_TYPE + { + D3D12_PROGRAM_TYPE_GENERIC_PIPELINE = 1, + D3D12_PROGRAM_TYPE_RAYTRACING_PIPELINE = 4, + D3D12_PROGRAM_TYPE_WORK_GRAPH = 5 + } D3D12_PROGRAM_TYPE; + +typedef struct D3D12_SET_PROGRAM_DESC + { + D3D12_PROGRAM_TYPE Type; + union + { + D3D12_SET_GENERIC_PIPELINE_DESC GenericPipeline; + D3D12_SET_RAYTRACING_PIPELINE_DESC RaytracingPipeline; + D3D12_SET_WORK_GRAPH_DESC WorkGraph; + } ; + } D3D12_SET_PROGRAM_DESC; + +typedef +enum D3D12_DISPATCH_MODE + { + D3D12_DISPATCH_MODE_NODE_CPU_INPUT = 0, + D3D12_DISPATCH_MODE_NODE_GPU_INPUT = 1, + D3D12_DISPATCH_MODE_MULTI_NODE_CPU_INPUT = 2, + D3D12_DISPATCH_MODE_MULTI_NODE_GPU_INPUT = 3 + } D3D12_DISPATCH_MODE; + +typedef struct D3D12_NODE_CPU_INPUT + { + UINT EntrypointIndex; + UINT NumRecords; + const void *pRecords; + UINT64 RecordStrideInBytes; + } D3D12_NODE_CPU_INPUT; + +typedef struct D3D12_NODE_GPU_INPUT + { + UINT EntrypointIndex; + UINT NumRecords; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE Records; + } D3D12_NODE_GPU_INPUT; + +typedef struct D3D12_MULTI_NODE_CPU_INPUT + { + UINT NumNodeInputs; + const D3D12_NODE_CPU_INPUT *pNodeInputs; + UINT64 NodeInputStrideInBytes; + } D3D12_MULTI_NODE_CPU_INPUT; + +typedef struct D3D12_MULTI_NODE_GPU_INPUT + { + UINT NumNodeInputs; + D3D12_GPU_VIRTUAL_ADDRESS_AND_STRIDE NodeInputs; + } D3D12_MULTI_NODE_GPU_INPUT; + +typedef struct D3D12_DISPATCH_GRAPH_DESC + { + D3D12_DISPATCH_MODE Mode; + union + { + D3D12_NODE_CPU_INPUT NodeCPUInput; + D3D12_GPU_VIRTUAL_ADDRESS NodeGPUInput; + D3D12_MULTI_NODE_CPU_INPUT MultiNodeCPUInput; + D3D12_GPU_VIRTUAL_ADDRESS MultiNodeGPUInput; + } ; + } D3D12_DISPATCH_GRAPH_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0052_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0052_v0_0_s_ifspec; + +#ifndef __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList4 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList4; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("8754318e-d3a9-4541-98cf-645b50dc4874") + ID3D12GraphicsCommandList4 : public ID3D12GraphicsCommandList3 + { + public: + virtual void STDMETHODCALLTYPE BeginRenderPass( + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags) = 0; + + virtual void STDMETHODCALLTYPE EndRenderPass( void) = 0; + + virtual void STDMETHODCALLTYPE InitializeMetaCommand( + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes) = 0; + + virtual void STDMETHODCALLTYPE ExecuteMetaCommand( + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes) = 0; + + virtual void STDMETHODCALLTYPE BuildRaytracingAccelerationStructure( + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs) = 0; + + virtual void STDMETHODCALLTYPE EmitRaytracingAccelerationStructurePostbuildInfo( + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData) = 0; + + virtual void STDMETHODCALLTYPE CopyRaytracingAccelerationStructure( + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode) = 0; + + virtual void STDMETHODCALLTYPE SetPipelineState1( + _In_ ID3D12StateObject *pStateObject) = 0; + + virtual void STDMETHODCALLTYPE DispatchRays( + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList4Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList4 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList4 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList4 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList4 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList4 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList4 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList4 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList4 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList4 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList4 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList4 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList4 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList4 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList4 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList4 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList4 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList4 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList4 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList4 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList4 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList4 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList4 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList4 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList4 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList4 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList4 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList4 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList4 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList4 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList4 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList4 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList4 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList4 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList4 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList4 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList4 * This, + _In_ ID3D12StateObject *pStateObject); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList4 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); + + END_INTERFACE + } ID3D12GraphicsCommandList4Vtbl; + + interface ID3D12GraphicsCommandList4 + { + CONST_VTBL struct ID3D12GraphicsCommandList4Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList4_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList4_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList4_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList4_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList4_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList4_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList4_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList4_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList4_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList4_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList4_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList4_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList4_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList4_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList4_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList4_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList4_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList4_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList4_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList4_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList4_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList4_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList4_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList4_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList4_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList4_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList4_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList4_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList4_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList4_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList4_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList4_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList4_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList4_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList4_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList4_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList4_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList4_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList4_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList4_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList4_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList4_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList4_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList4_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList4_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList4_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList4_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList4_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList4_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList4_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList4_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList4_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList4_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList4_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList4_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList4_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList4_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList4_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList4_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList4_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList4_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList4_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList4_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList4_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList4_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList4_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList4_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList4_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + + +#define ID3D12GraphicsCommandList4_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) + +#define ID3D12GraphicsCommandList4_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) + +#define ID3D12GraphicsCommandList4_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList4_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList4_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) + +#define ID3D12GraphicsCommandList4_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) + +#define ID3D12GraphicsCommandList4_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) + +#define ID3D12GraphicsCommandList4_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) + +#define ID3D12GraphicsCommandList4_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList4_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0053 */ +/* [local] */ + +typedef +enum D3D12_SHADER_CACHE_MODE + { + D3D12_SHADER_CACHE_MODE_MEMORY = 0, + D3D12_SHADER_CACHE_MODE_DISK = ( D3D12_SHADER_CACHE_MODE_MEMORY + 1 ) + } D3D12_SHADER_CACHE_MODE; + +typedef +enum D3D12_SHADER_CACHE_FLAGS + { + D3D12_SHADER_CACHE_FLAG_NONE = 0, + D3D12_SHADER_CACHE_FLAG_DRIVER_VERSIONED = 0x1, + D3D12_SHADER_CACHE_FLAG_USE_WORKING_DIR = 0x2 + } D3D12_SHADER_CACHE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_CACHE_FLAGS ) +typedef struct D3D12_SHADER_CACHE_SESSION_DESC + { + GUID Identifier; + D3D12_SHADER_CACHE_MODE Mode; + D3D12_SHADER_CACHE_FLAGS Flags; + UINT MaximumInMemoryCacheSizeBytes; + UINT MaximumInMemoryCacheEntries; + UINT MaximumValueFileSizeBytes; + UINT64 Version; + } D3D12_SHADER_CACHE_SESSION_DESC; + +typedef +enum D3D12_BARRIER_LAYOUT + { + D3D12_BARRIER_LAYOUT_UNDEFINED = 0xffffffff, + D3D12_BARRIER_LAYOUT_COMMON = 0, + D3D12_BARRIER_LAYOUT_PRESENT = 0, + D3D12_BARRIER_LAYOUT_GENERIC_READ = ( D3D12_BARRIER_LAYOUT_PRESENT + 1 ) , + D3D12_BARRIER_LAYOUT_RENDER_TARGET = ( D3D12_BARRIER_LAYOUT_GENERIC_READ + 1 ) , + D3D12_BARRIER_LAYOUT_UNORDERED_ACCESS = ( D3D12_BARRIER_LAYOUT_RENDER_TARGET + 1 ) , + D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_WRITE = ( D3D12_BARRIER_LAYOUT_UNORDERED_ACCESS + 1 ) , + D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_READ = ( D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_WRITE + 1 ) , + D3D12_BARRIER_LAYOUT_SHADER_RESOURCE = ( D3D12_BARRIER_LAYOUT_DEPTH_STENCIL_READ + 1 ) , + D3D12_BARRIER_LAYOUT_COPY_SOURCE = ( D3D12_BARRIER_LAYOUT_SHADER_RESOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_COPY_DEST = ( D3D12_BARRIER_LAYOUT_COPY_SOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_RESOLVE_SOURCE = ( D3D12_BARRIER_LAYOUT_COPY_DEST + 1 ) , + D3D12_BARRIER_LAYOUT_RESOLVE_DEST = ( D3D12_BARRIER_LAYOUT_RESOLVE_SOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_SHADING_RATE_SOURCE = ( D3D12_BARRIER_LAYOUT_RESOLVE_DEST + 1 ) , + D3D12_BARRIER_LAYOUT_VIDEO_DECODE_READ = ( D3D12_BARRIER_LAYOUT_SHADING_RATE_SOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_VIDEO_DECODE_WRITE = ( D3D12_BARRIER_LAYOUT_VIDEO_DECODE_READ + 1 ) , + D3D12_BARRIER_LAYOUT_VIDEO_PROCESS_READ = ( D3D12_BARRIER_LAYOUT_VIDEO_DECODE_WRITE + 1 ) , + D3D12_BARRIER_LAYOUT_VIDEO_PROCESS_WRITE = ( D3D12_BARRIER_LAYOUT_VIDEO_PROCESS_READ + 1 ) , + D3D12_BARRIER_LAYOUT_VIDEO_ENCODE_READ = ( D3D12_BARRIER_LAYOUT_VIDEO_PROCESS_WRITE + 1 ) , + D3D12_BARRIER_LAYOUT_VIDEO_ENCODE_WRITE = ( D3D12_BARRIER_LAYOUT_VIDEO_ENCODE_READ + 1 ) , + D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_COMMON = ( D3D12_BARRIER_LAYOUT_VIDEO_ENCODE_WRITE + 1 ) , + D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_GENERIC_READ = ( D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_COMMON + 1 ) , + D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_UNORDERED_ACCESS = ( D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_GENERIC_READ + 1 ) , + D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_SHADER_RESOURCE = ( D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_UNORDERED_ACCESS + 1 ) , + D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_COPY_SOURCE = ( D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_SHADER_RESOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_COPY_DEST = ( D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_COPY_SOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_COMMON = ( D3D12_BARRIER_LAYOUT_DIRECT_QUEUE_COPY_DEST + 1 ) , + D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_GENERIC_READ = ( D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_COMMON + 1 ) , + D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_UNORDERED_ACCESS = ( D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_GENERIC_READ + 1 ) , + D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_SHADER_RESOURCE = ( D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_UNORDERED_ACCESS + 1 ) , + D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_COPY_SOURCE = ( D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_SHADER_RESOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_COPY_DEST = ( D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_COPY_SOURCE + 1 ) , + D3D12_BARRIER_LAYOUT_VIDEO_QUEUE_COMMON = ( D3D12_BARRIER_LAYOUT_COMPUTE_QUEUE_COPY_DEST + 1 ) + } D3D12_BARRIER_LAYOUT; + +typedef +enum D3D12_BARRIER_SYNC + { + D3D12_BARRIER_SYNC_NONE = 0, + D3D12_BARRIER_SYNC_ALL = 0x1, + D3D12_BARRIER_SYNC_DRAW = 0x2, + D3D12_BARRIER_SYNC_INDEX_INPUT = 0x4, + D3D12_BARRIER_SYNC_VERTEX_SHADING = 0x8, + D3D12_BARRIER_SYNC_PIXEL_SHADING = 0x10, + D3D12_BARRIER_SYNC_DEPTH_STENCIL = 0x20, + D3D12_BARRIER_SYNC_RENDER_TARGET = 0x40, + D3D12_BARRIER_SYNC_COMPUTE_SHADING = 0x80, + D3D12_BARRIER_SYNC_RAYTRACING = 0x100, + D3D12_BARRIER_SYNC_COPY = 0x200, + D3D12_BARRIER_SYNC_RESOLVE = 0x400, + D3D12_BARRIER_SYNC_EXECUTE_INDIRECT = 0x800, + D3D12_BARRIER_SYNC_PREDICATION = 0x800, + D3D12_BARRIER_SYNC_ALL_SHADING = 0x1000, + D3D12_BARRIER_SYNC_NON_PIXEL_SHADING = 0x2000, + D3D12_BARRIER_SYNC_EMIT_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO = 0x4000, + D3D12_BARRIER_SYNC_CLEAR_UNORDERED_ACCESS_VIEW = 0x8000, + D3D12_BARRIER_SYNC_VIDEO_DECODE = 0x100000, + D3D12_BARRIER_SYNC_VIDEO_PROCESS = 0x200000, + D3D12_BARRIER_SYNC_VIDEO_ENCODE = 0x400000, + D3D12_BARRIER_SYNC_BUILD_RAYTRACING_ACCELERATION_STRUCTURE = 0x800000, + D3D12_BARRIER_SYNC_COPY_RAYTRACING_ACCELERATION_STRUCTURE = 0x1000000, + D3D12_BARRIER_SYNC_SPLIT = 0x80000000 + } D3D12_BARRIER_SYNC; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_BARRIER_SYNC ) +typedef +enum D3D12_BARRIER_ACCESS + { + D3D12_BARRIER_ACCESS_COMMON = 0, + D3D12_BARRIER_ACCESS_VERTEX_BUFFER = 0x1, + D3D12_BARRIER_ACCESS_CONSTANT_BUFFER = 0x2, + D3D12_BARRIER_ACCESS_INDEX_BUFFER = 0x4, + D3D12_BARRIER_ACCESS_RENDER_TARGET = 0x8, + D3D12_BARRIER_ACCESS_UNORDERED_ACCESS = 0x10, + D3D12_BARRIER_ACCESS_DEPTH_STENCIL_WRITE = 0x20, + D3D12_BARRIER_ACCESS_DEPTH_STENCIL_READ = 0x40, + D3D12_BARRIER_ACCESS_SHADER_RESOURCE = 0x80, + D3D12_BARRIER_ACCESS_STREAM_OUTPUT = 0x100, + D3D12_BARRIER_ACCESS_INDIRECT_ARGUMENT = 0x200, + D3D12_BARRIER_ACCESS_PREDICATION = 0x200, + D3D12_BARRIER_ACCESS_COPY_DEST = 0x400, + D3D12_BARRIER_ACCESS_COPY_SOURCE = 0x800, + D3D12_BARRIER_ACCESS_RESOLVE_DEST = 0x1000, + D3D12_BARRIER_ACCESS_RESOLVE_SOURCE = 0x2000, + D3D12_BARRIER_ACCESS_RAYTRACING_ACCELERATION_STRUCTURE_READ = 0x4000, + D3D12_BARRIER_ACCESS_RAYTRACING_ACCELERATION_STRUCTURE_WRITE = 0x8000, + D3D12_BARRIER_ACCESS_SHADING_RATE_SOURCE = 0x10000, + D3D12_BARRIER_ACCESS_VIDEO_DECODE_READ = 0x20000, + D3D12_BARRIER_ACCESS_VIDEO_DECODE_WRITE = 0x40000, + D3D12_BARRIER_ACCESS_VIDEO_PROCESS_READ = 0x80000, + D3D12_BARRIER_ACCESS_VIDEO_PROCESS_WRITE = 0x100000, + D3D12_BARRIER_ACCESS_VIDEO_ENCODE_READ = 0x200000, + D3D12_BARRIER_ACCESS_VIDEO_ENCODE_WRITE = 0x400000, + D3D12_BARRIER_ACCESS_NO_ACCESS = 0x80000000 + } D3D12_BARRIER_ACCESS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_BARRIER_ACCESS ) +typedef +enum D3D12_BARRIER_TYPE + { + D3D12_BARRIER_TYPE_GLOBAL = 0, + D3D12_BARRIER_TYPE_TEXTURE = ( D3D12_BARRIER_TYPE_GLOBAL + 1 ) , + D3D12_BARRIER_TYPE_BUFFER = ( D3D12_BARRIER_TYPE_TEXTURE + 1 ) + } D3D12_BARRIER_TYPE; + +typedef +enum D3D12_TEXTURE_BARRIER_FLAGS + { + D3D12_TEXTURE_BARRIER_FLAG_NONE = 0, + D3D12_TEXTURE_BARRIER_FLAG_DISCARD = 0x1 + } D3D12_TEXTURE_BARRIER_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_TEXTURE_BARRIER_FLAGS ) +typedef struct D3D12_BARRIER_SUBRESOURCE_RANGE + { + UINT IndexOrFirstMipLevel; + UINT NumMipLevels; + UINT FirstArraySlice; + UINT NumArraySlices; + UINT FirstPlane; + UINT NumPlanes; + } D3D12_BARRIER_SUBRESOURCE_RANGE; + +typedef struct D3D12_GLOBAL_BARRIER + { + D3D12_BARRIER_SYNC SyncBefore; + D3D12_BARRIER_SYNC SyncAfter; + D3D12_BARRIER_ACCESS AccessBefore; + D3D12_BARRIER_ACCESS AccessAfter; + } D3D12_GLOBAL_BARRIER; + +typedef struct D3D12_TEXTURE_BARRIER + { + D3D12_BARRIER_SYNC SyncBefore; + D3D12_BARRIER_SYNC SyncAfter; + D3D12_BARRIER_ACCESS AccessBefore; + D3D12_BARRIER_ACCESS AccessAfter; + D3D12_BARRIER_LAYOUT LayoutBefore; + D3D12_BARRIER_LAYOUT LayoutAfter; + _In_ ID3D12Resource *pResource; + D3D12_BARRIER_SUBRESOURCE_RANGE Subresources; + D3D12_TEXTURE_BARRIER_FLAGS Flags; + } D3D12_TEXTURE_BARRIER; + +typedef struct D3D12_BUFFER_BARRIER + { + D3D12_BARRIER_SYNC SyncBefore; + D3D12_BARRIER_SYNC SyncAfter; + D3D12_BARRIER_ACCESS AccessBefore; + D3D12_BARRIER_ACCESS AccessAfter; + _In_ ID3D12Resource *pResource; + UINT64 Offset; + UINT64 Size; + } D3D12_BUFFER_BARRIER; + +typedef struct D3D12_BARRIER_GROUP + { + D3D12_BARRIER_TYPE Type; + UINT32 NumBarriers; + union + { + _In_reads_(NumBarriers) const D3D12_GLOBAL_BARRIER *pGlobalBarriers; + _In_reads_(NumBarriers) const D3D12_TEXTURE_BARRIER *pTextureBarriers; + _In_reads_(NumBarriers) const D3D12_BUFFER_BARRIER *pBufferBarriers; + } ; + } D3D12_BARRIER_GROUP; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0053_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0053_v0_0_s_ifspec; + +#ifndef __ID3D12ShaderCacheSession_INTERFACE_DEFINED__ +#define __ID3D12ShaderCacheSession_INTERFACE_DEFINED__ + +/* interface ID3D12ShaderCacheSession */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12ShaderCacheSession; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("28e2495d-0f64-4ae4-a6ec-129255dc49a8") + ID3D12ShaderCacheSession : public ID3D12DeviceChild + { + public: + virtual HRESULT STDMETHODCALLTYPE FindValue( + /* [annotation][in] */ + _In_reads_bytes_(KeySize) const void *pKey, + UINT KeySize, + /* [annotation][out] */ + _Out_writes_bytes_(*pValueSize) void *pValue, + _Inout_ UINT *pValueSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE StoreValue( + /* [annotation][in] */ + _In_reads_bytes_(KeySize) const void *pKey, + UINT KeySize, + /* [annotation][in] */ + _In_reads_bytes_(ValueSize) const void *pValue, + UINT ValueSize) = 0; + + virtual void STDMETHODCALLTYPE SetDeleteOnDestroy( void) = 0; + +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_SHADER_CACHE_SESSION_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_SHADER_CACHE_SESSION_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_SHADER_CACHE_SESSION_DESC * RetVal) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ShaderCacheSessionVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12ShaderCacheSession * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12ShaderCacheSession * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12ShaderCacheSession * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12ShaderCacheSession * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12ShaderCacheSession * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12ShaderCacheSession * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12ShaderCacheSession * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12ShaderCacheSession * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12ShaderCacheSession, FindValue) + HRESULT ( STDMETHODCALLTYPE *FindValue )( + ID3D12ShaderCacheSession * This, + /* [annotation][in] */ + _In_reads_bytes_(KeySize) const void *pKey, + UINT KeySize, + /* [annotation][out] */ + _Out_writes_bytes_(*pValueSize) void *pValue, + _Inout_ UINT *pValueSize); + + DECLSPEC_XFGVIRT(ID3D12ShaderCacheSession, StoreValue) + HRESULT ( STDMETHODCALLTYPE *StoreValue )( + ID3D12ShaderCacheSession * This, + /* [annotation][in] */ + _In_reads_bytes_(KeySize) const void *pKey, + UINT KeySize, + /* [annotation][in] */ + _In_reads_bytes_(ValueSize) const void *pValue, + UINT ValueSize); + + DECLSPEC_XFGVIRT(ID3D12ShaderCacheSession, SetDeleteOnDestroy) + void ( STDMETHODCALLTYPE *SetDeleteOnDestroy )( + ID3D12ShaderCacheSession * This); + + DECLSPEC_XFGVIRT(ID3D12ShaderCacheSession, GetDesc) +#if !defined(_WIN32) + D3D12_SHADER_CACHE_SESSION_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12ShaderCacheSession * This); + +#else + D3D12_SHADER_CACHE_SESSION_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12ShaderCacheSession * This, + D3D12_SHADER_CACHE_SESSION_DESC * RetVal); + +#endif + + END_INTERFACE + } ID3D12ShaderCacheSessionVtbl; + + interface ID3D12ShaderCacheSession + { + CONST_VTBL struct ID3D12ShaderCacheSessionVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12ShaderCacheSession_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12ShaderCacheSession_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12ShaderCacheSession_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12ShaderCacheSession_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12ShaderCacheSession_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12ShaderCacheSession_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12ShaderCacheSession_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12ShaderCacheSession_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12ShaderCacheSession_FindValue(This,pKey,KeySize,pValue,pValueSize) \ + ( (This)->lpVtbl -> FindValue(This,pKey,KeySize,pValue,pValueSize) ) + +#define ID3D12ShaderCacheSession_StoreValue(This,pKey,KeySize,pValue,ValueSize) \ + ( (This)->lpVtbl -> StoreValue(This,pKey,KeySize,pValue,ValueSize) ) + +#define ID3D12ShaderCacheSession_SetDeleteOnDestroy(This) \ + ( (This)->lpVtbl -> SetDeleteOnDestroy(This) ) +#if !defined(_WIN32) + +#define ID3D12ShaderCacheSession_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12ShaderCacheSession_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12ShaderCacheSession_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0054 */ +/* [local] */ + +typedef +enum D3D12_SHADER_CACHE_KIND_FLAGS + { + D3D12_SHADER_CACHE_KIND_FLAG_IMPLICIT_D3D_CACHE_FOR_DRIVER = 0x1, + D3D12_SHADER_CACHE_KIND_FLAG_IMPLICIT_D3D_CONVERSIONS = 0x2, + D3D12_SHADER_CACHE_KIND_FLAG_IMPLICIT_DRIVER_MANAGED = 0x4, + D3D12_SHADER_CACHE_KIND_FLAG_APPLICATION_MANAGED = 0x8 + } D3D12_SHADER_CACHE_KIND_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_CACHE_KIND_FLAGS ) +typedef +enum D3D12_SHADER_CACHE_CONTROL_FLAGS + { + D3D12_SHADER_CACHE_CONTROL_FLAG_DISABLE = 0x1, + D3D12_SHADER_CACHE_CONTROL_FLAG_ENABLE = 0x2, + D3D12_SHADER_CACHE_CONTROL_FLAG_CLEAR = 0x4 + } D3D12_SHADER_CACHE_CONTROL_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_SHADER_CACHE_CONTROL_FLAGS ) + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0054_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0054_v0_0_s_ifspec; + +#ifndef __ID3D12Device9_INTERFACE_DEFINED__ +#define __ID3D12Device9_INTERFACE_DEFINED__ + +/* interface ID3D12Device9 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device9; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("4c80e962-f032-4f60-bc9e-ebc2cfa1d83c") + ID3D12Device9 : public ID3D12Device8 + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateShaderCacheSession( + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession) = 0; + + virtual HRESULT STDMETHODCALLTYPE ShaderCacheControl( + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateCommandQueue1( + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device9Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device9 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device9 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device9 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device9 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device9 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device9 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device9 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device9 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device9 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device9 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device9 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device9 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device9 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device9 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device9 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device9 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device9 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device9 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device9 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device9 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device9 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device9 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device9 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device9 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device9 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device9 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device9 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device9 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device9 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device9 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device9 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device9 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device9 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device9 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device9 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device9 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device9 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device9 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device9 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device9 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device9 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device9 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device9 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device9 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device9 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device9 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device9 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device9 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device9 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device9 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device9 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device9 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device9 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device9 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device9 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device9 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device9 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device9 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device9 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device9 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device9 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device9 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device9 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device9 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device9 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device9 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device9 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device9 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device9 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device9 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device9 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device9 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device9 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device9 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device9 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device9 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device9 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device9 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateShaderCacheSession) + HRESULT ( STDMETHODCALLTYPE *CreateShaderCacheSession )( + ID3D12Device9 * This, + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession); + + DECLSPEC_XFGVIRT(ID3D12Device9, ShaderCacheControl) + HRESULT ( STDMETHODCALLTYPE *ShaderCacheControl )( + ID3D12Device9 * This, + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateCommandQueue1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue1 )( + ID3D12Device9 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + END_INTERFACE + } ID3D12Device9Vtbl; + + interface ID3D12Device9 + { + CONST_VTBL struct ID3D12Device9Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device9_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device9_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device9_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device9_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device9_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device9_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device9_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device9_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device9_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device9_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device9_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device9_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device9_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device9_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device9_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device9_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device9_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device9_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device9_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device9_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device9_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device9_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device9_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device9_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device9_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device9_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device9_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device9_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device9_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device9_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device9_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device9_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device9_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device9_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device9_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device9_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device9_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device9_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device9_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device9_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device9_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device9_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device9_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device9_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device9_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device9_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device9_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device9_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device9_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device9_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device9_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device9_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device9_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device9_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device9_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device9_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device9_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device9_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device9_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device9_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device9_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device9_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device9_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device9_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device9_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device9_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device9_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device9_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device9_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device9_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device9_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device9_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device9_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device9_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device9_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device9_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device9_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device9_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + + +#define ID3D12Device9_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->lpVtbl -> CreateShaderCacheSession(This,pDesc,riid,ppvSession) ) + +#define ID3D12Device9_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->lpVtbl -> ShaderCacheControl(This,Kinds,Control) ) + +#define ID3D12Device9_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device9_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device10_INTERFACE_DEFINED__ +#define __ID3D12Device10_INTERFACE_DEFINED__ + +/* interface ID3D12Device10 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device10; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("517f8718-aa66-49f9-b02b-a7ab89c06031") + ID3D12Device10 : public ID3D12Device9 + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateCommittedResource3( + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreatePlacedResource2( + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateReservedResource2( + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device10Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device10 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device10 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device10 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device10 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device10 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device10 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device10 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device10 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device10 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device10 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device10 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device10 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device10 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device10 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device10 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device10 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device10 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device10 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device10 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device10 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device10 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device10 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device10 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device10 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device10 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device10 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device10 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device10 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device10 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device10 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device10 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device10 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device10 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device10 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device10 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device10 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device10 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device10 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device10 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device10 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device10 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device10 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device10 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device10 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device10 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device10 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device10 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device10 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device10 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device10 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device10 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device10 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device10 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device10 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device10 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device10 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device10 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device10 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device10 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device10 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device10 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device10 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device10 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device10 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device10 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device10 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device10 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device10 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device10 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device10 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device10 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device10 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device10 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device10 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device10 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device10 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device10 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device10 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateShaderCacheSession) + HRESULT ( STDMETHODCALLTYPE *CreateShaderCacheSession )( + ID3D12Device10 * This, + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession); + + DECLSPEC_XFGVIRT(ID3D12Device9, ShaderCacheControl) + HRESULT ( STDMETHODCALLTYPE *ShaderCacheControl )( + ID3D12Device10 * This, + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateCommandQueue1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue1 )( + ID3D12Device10 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateCommittedResource3) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource3 )( + ID3D12Device10 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreatePlacedResource2) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource2 )( + ID3D12Device10 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateReservedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource2 )( + ID3D12Device10 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + END_INTERFACE + } ID3D12Device10Vtbl; + + interface ID3D12Device10 + { + CONST_VTBL struct ID3D12Device10Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device10_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device10_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device10_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device10_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device10_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device10_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device10_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device10_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device10_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device10_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device10_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device10_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device10_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device10_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device10_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device10_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device10_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device10_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device10_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device10_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device10_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device10_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device10_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device10_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device10_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device10_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device10_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device10_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device10_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device10_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device10_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device10_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device10_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device10_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device10_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device10_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device10_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device10_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device10_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device10_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device10_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device10_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device10_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device10_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device10_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device10_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device10_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device10_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device10_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device10_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device10_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device10_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device10_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device10_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device10_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device10_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device10_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device10_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device10_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device10_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device10_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device10_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device10_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device10_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device10_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device10_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device10_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device10_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device10_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device10_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device10_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device10_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device10_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device10_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device10_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device10_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device10_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device10_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + + +#define ID3D12Device10_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->lpVtbl -> CreateShaderCacheSession(This,pDesc,riid,ppvSession) ) + +#define ID3D12Device10_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->lpVtbl -> ShaderCacheControl(This,Kinds,Control) ) + +#define ID3D12Device10_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) ) + + +#define ID3D12Device10_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) + +#define ID3D12Device10_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + +#define ID3D12Device10_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device10_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device11_INTERFACE_DEFINED__ +#define __ID3D12Device11_INTERFACE_DEFINED__ + +/* interface ID3D12Device11 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device11; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5405c344-d457-444e-b4dd-2366e45aee39") + ID3D12Device11 : public ID3D12Device10 + { + public: + virtual void STDMETHODCALLTYPE CreateSampler2( + _In_ const D3D12_SAMPLER_DESC2 *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device11Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device11 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device11 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device11 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device11 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device11 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device11 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device11 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device11 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device11 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device11 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device11 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device11 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device11 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device11 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device11 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device11 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device11 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device11 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device11 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device11 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device11 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device11 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device11 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device11 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device11 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device11 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device11 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device11 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device11 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device11 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device11 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device11 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device11 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device11 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device11 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device11 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device11 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device11 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device11 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device11 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device11 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device11 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device11 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device11 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device11 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device11 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device11 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device11 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device11 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device11 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device11 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device11 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device11 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device11 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device11 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device11 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device11 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device11 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device11 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device11 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device11 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device11 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device11 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device11 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device11 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device11 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device11 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device11 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device11 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device11 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device11 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device11 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device11 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device11 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device11 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device11 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device11 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device11 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateShaderCacheSession) + HRESULT ( STDMETHODCALLTYPE *CreateShaderCacheSession )( + ID3D12Device11 * This, + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession); + + DECLSPEC_XFGVIRT(ID3D12Device9, ShaderCacheControl) + HRESULT ( STDMETHODCALLTYPE *ShaderCacheControl )( + ID3D12Device11 * This, + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateCommandQueue1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue1 )( + ID3D12Device11 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateCommittedResource3) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource3 )( + ID3D12Device11 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreatePlacedResource2) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource2 )( + ID3D12Device11 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateReservedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource2 )( + ID3D12Device11 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device11, CreateSampler2) + void ( STDMETHODCALLTYPE *CreateSampler2 )( + ID3D12Device11 * This, + _In_ const D3D12_SAMPLER_DESC2 *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + END_INTERFACE + } ID3D12Device11Vtbl; + + interface ID3D12Device11 + { + CONST_VTBL struct ID3D12Device11Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device11_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device11_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device11_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device11_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device11_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device11_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device11_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device11_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device11_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device11_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device11_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device11_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device11_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device11_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device11_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device11_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device11_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device11_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device11_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device11_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device11_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device11_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device11_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device11_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device11_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device11_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device11_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device11_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device11_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device11_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device11_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device11_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device11_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device11_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device11_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device11_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device11_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device11_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device11_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device11_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device11_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device11_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device11_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device11_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device11_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device11_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device11_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device11_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device11_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device11_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device11_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device11_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device11_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device11_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device11_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device11_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device11_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device11_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device11_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device11_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device11_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device11_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device11_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device11_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device11_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device11_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device11_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device11_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device11_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device11_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device11_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device11_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device11_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device11_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device11_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device11_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device11_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device11_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + + +#define ID3D12Device11_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->lpVtbl -> CreateShaderCacheSession(This,pDesc,riid,ppvSession) ) + +#define ID3D12Device11_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->lpVtbl -> ShaderCacheControl(This,Kinds,Control) ) + +#define ID3D12Device11_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) ) + + +#define ID3D12Device11_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) + +#define ID3D12Device11_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + +#define ID3D12Device11_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + + +#define ID3D12Device11_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler2(This,pDesc,DestDescriptor) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device11_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device12_INTERFACE_DEFINED__ +#define __ID3D12Device12_INTERFACE_DEFINED__ + +/* interface ID3D12Device12 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device12; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5af5c532-4c91-4cd0-b541-15a405395fc5") + ID3D12Device12 : public ID3D12Device11 + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_RESOURCE_ALLOCATION_INFO STDMETHODCALLTYPE GetResourceAllocationInfo3( + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1) = 0; +#else + virtual D3D12_RESOURCE_ALLOCATION_INFO *STDMETHODCALLTYPE GetResourceAllocationInfo3( + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1) = 0; +#endif + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device12Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device12 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device12 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device12 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device12 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device12 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device12 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device12 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device12 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device12 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device12 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device12 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device12 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device12 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device12 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device12 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device12 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device12 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device12 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device12 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device12 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device12 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device12 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device12 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device12 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device12 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device12 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device12 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device12 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device12 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device12 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device12 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device12 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device12 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device12 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device12 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device12 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device12 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device12 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device12 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device12 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device12 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device12 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device12 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device12 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device12 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device12 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device12 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device12 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device12 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device12 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device12 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device12 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device12 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device12 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device12 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device12 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device12 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device12 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device12 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device12 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device12 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device12 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device12 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device12 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device12 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device12 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device12 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device12 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device12 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device12 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device12 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device12 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device12 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device12 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device12 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device12 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device12 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device12 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateShaderCacheSession) + HRESULT ( STDMETHODCALLTYPE *CreateShaderCacheSession )( + ID3D12Device12 * This, + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession); + + DECLSPEC_XFGVIRT(ID3D12Device9, ShaderCacheControl) + HRESULT ( STDMETHODCALLTYPE *ShaderCacheControl )( + ID3D12Device12 * This, + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateCommandQueue1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue1 )( + ID3D12Device12 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateCommittedResource3) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource3 )( + ID3D12Device12 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreatePlacedResource2) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource2 )( + ID3D12Device12 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateReservedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource2 )( + ID3D12Device12 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device11, CreateSampler2) + void ( STDMETHODCALLTYPE *CreateSampler2 )( + ID3D12Device12 * This, + _In_ const D3D12_SAMPLER_DESC2 *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device12, GetResourceAllocationInfo3) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device12 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device12 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + END_INTERFACE + } ID3D12Device12Vtbl; + + interface ID3D12Device12 + { + CONST_VTBL struct ID3D12Device12Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device12_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device12_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device12_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device12_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device12_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device12_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device12_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device12_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device12_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device12_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device12_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device12_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device12_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device12_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device12_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device12_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device12_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device12_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device12_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device12_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device12_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device12_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device12_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device12_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device12_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device12_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device12_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device12_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device12_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device12_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device12_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device12_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device12_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device12_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device12_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device12_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device12_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device12_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device12_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device12_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device12_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device12_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device12_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device12_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device12_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device12_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device12_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device12_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device12_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device12_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device12_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device12_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device12_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device12_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device12_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device12_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device12_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device12_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device12_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device12_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device12_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device12_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device12_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device12_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device12_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device12_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device12_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device12_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device12_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device12_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device12_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device12_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device12_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device12_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device12_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device12_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device12_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device12_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + + +#define ID3D12Device12_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->lpVtbl -> CreateShaderCacheSession(This,pDesc,riid,ppvSession) ) + +#define ID3D12Device12_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->lpVtbl -> ShaderCacheControl(This,Kinds,Control) ) + +#define ID3D12Device12_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) ) + + +#define ID3D12Device12_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) + +#define ID3D12Device12_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + +#define ID3D12Device12_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + + +#define ID3D12Device12_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler2(This,pDesc,DestDescriptor) ) + +#if !defined(_WIN32) + +#define ID3D12Device12_GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#else +#define ID3D12Device12_GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#endif + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device12_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device13_INTERFACE_DEFINED__ +#define __ID3D12Device13_INTERFACE_DEFINED__ + +/* interface ID3D12Device13 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device13; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("14eecffc-4df8-40f7-a118-5c816f45695e") + ID3D12Device13 : public ID3D12Device12 + { + public: + virtual HRESULT STDMETHODCALLTYPE OpenExistingHeapFromAddress1( + _In_ const void *pAddress, + SIZE_T size, + REFIID riid, + _COM_Outptr_ void **ppvHeap) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device13Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device13 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device13 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device13 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device13 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device13 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device13 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device13 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device13 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device13 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device13 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device13 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device13 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device13 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device13 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device13 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device13 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device13 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device13 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device13 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device13 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device13 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device13 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device13 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device13 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device13 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device13 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device13 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device13 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device13 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device13 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device13 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device13 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device13 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device13 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device13 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device13 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device13 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device13 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device13 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device13 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device13 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device13 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device13 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device13 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device13 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device13 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device13 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device13 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device13 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device13 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device13 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device13 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device13 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device13 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device13 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device13 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device13 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device13 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device13 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device13 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device13 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device13 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device13 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device13 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device13 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device13 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device13 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device13 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device13 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device13 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device13 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device13 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device13 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device13 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device13 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device13 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device13 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device13 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateShaderCacheSession) + HRESULT ( STDMETHODCALLTYPE *CreateShaderCacheSession )( + ID3D12Device13 * This, + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession); + + DECLSPEC_XFGVIRT(ID3D12Device9, ShaderCacheControl) + HRESULT ( STDMETHODCALLTYPE *ShaderCacheControl )( + ID3D12Device13 * This, + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateCommandQueue1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue1 )( + ID3D12Device13 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateCommittedResource3) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource3 )( + ID3D12Device13 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreatePlacedResource2) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource2 )( + ID3D12Device13 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateReservedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource2 )( + ID3D12Device13 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device11, CreateSampler2) + void ( STDMETHODCALLTYPE *CreateSampler2 )( + ID3D12Device13 * This, + _In_ const D3D12_SAMPLER_DESC2 *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device12, GetResourceAllocationInfo3) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device13 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device13 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device13, OpenExistingHeapFromAddress1) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress1 )( + ID3D12Device13 * This, + _In_ const void *pAddress, + SIZE_T size, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + END_INTERFACE + } ID3D12Device13Vtbl; + + interface ID3D12Device13 + { + CONST_VTBL struct ID3D12Device13Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device13_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device13_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device13_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device13_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device13_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device13_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device13_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device13_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device13_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device13_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device13_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device13_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device13_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device13_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device13_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device13_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device13_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device13_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device13_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device13_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device13_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device13_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device13_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device13_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device13_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device13_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device13_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device13_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device13_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device13_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device13_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device13_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device13_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device13_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device13_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device13_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device13_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device13_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device13_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device13_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device13_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device13_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device13_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device13_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device13_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device13_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device13_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device13_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device13_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device13_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device13_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device13_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device13_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device13_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device13_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device13_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device13_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device13_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device13_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device13_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device13_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device13_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device13_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device13_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device13_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device13_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device13_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device13_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device13_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device13_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device13_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device13_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device13_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device13_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device13_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device13_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device13_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device13_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + + +#define ID3D12Device13_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->lpVtbl -> CreateShaderCacheSession(This,pDesc,riid,ppvSession) ) + +#define ID3D12Device13_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->lpVtbl -> ShaderCacheControl(This,Kinds,Control) ) + +#define ID3D12Device13_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) ) + + +#define ID3D12Device13_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) + +#define ID3D12Device13_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + +#define ID3D12Device13_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + + +#define ID3D12Device13_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler2(This,pDesc,DestDescriptor) ) + +#if !defined(_WIN32) + +#define ID3D12Device13_GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#else +#define ID3D12Device13_GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device13_OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device13_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Device14_INTERFACE_DEFINED__ +#define __ID3D12Device14_INTERFACE_DEFINED__ + +/* interface ID3D12Device14 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Device14; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5f6e592d-d895-44c2-8e4a-88ad4926d323") + ID3D12Device14 : public ID3D12Device13 + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateRootSignatureFromSubobjectInLibrary( + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pLibraryBlob, + _In_ SIZE_T blobLengthInBytes, + _In_opt_ LPCWSTR subobjectName, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Device14Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Device14 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Device14 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Device14 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12Device14 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12Device14 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12Device14 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12Device14 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12Device, GetNodeCount) + UINT ( STDMETHODCALLTYPE *GetNodeCount )( + ID3D12Device14 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandQueue) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue )( + ID3D12Device14 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandAllocator) + HRESULT ( STDMETHODCALLTYPE *CreateCommandAllocator )( + ID3D12Device14 * This, + _In_ D3D12_COMMAND_LIST_TYPE type, + REFIID riid, + _COM_Outptr_ void **ppCommandAllocator); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateGraphicsPipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateGraphicsPipelineState )( + ID3D12Device14 * This, + _In_ const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateComputePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreateComputePipelineState )( + ID3D12Device14 * This, + _In_ const D3D12_COMPUTE_PIPELINE_STATE_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandList) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ ID3D12CommandAllocator *pCommandAllocator, + _In_opt_ ID3D12PipelineState *pInitialState, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device, CheckFeatureSupport) + HRESULT ( STDMETHODCALLTYPE *CheckFeatureSupport )( + ID3D12Device14 * This, + D3D12_FEATURE Feature, + _Inout_updates_bytes_(FeatureSupportDataSize) void *pFeatureSupportData, + UINT FeatureSupportDataSize); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDescriptorHeap) + HRESULT ( STDMETHODCALLTYPE *CreateDescriptorHeap )( + ID3D12Device14 * This, + _In_ const D3D12_DESCRIPTOR_HEAP_DESC *pDescriptorHeapDesc, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDescriptorHandleIncrementSize) + UINT ( STDMETHODCALLTYPE *GetDescriptorHandleIncrementSize )( + ID3D12Device14 * This, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapType); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRootSignature) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignature )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pBlobWithRootSignature, + _In_ SIZE_T blobLengthInBytes, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateConstantBufferView) + void ( STDMETHODCALLTYPE *CreateConstantBufferView )( + ID3D12Device14 * This, + _In_opt_ const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateShaderResourceView) + void ( STDMETHODCALLTYPE *CreateShaderResourceView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateUnorderedAccessView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ ID3D12Resource *pCounterResource, + _In_opt_ const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateRenderTargetView) + void ( STDMETHODCALLTYPE *CreateRenderTargetView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_RENDER_TARGET_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateDepthStencilView) + void ( STDMETHODCALLTYPE *CreateDepthStencilView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSampler) + void ( STDMETHODCALLTYPE *CreateSampler )( + ID3D12Device14 * This, + _In_ const D3D12_SAMPLER_DESC *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptors) + void ( STDMETHODCALLTYPE *CopyDescriptors )( + ID3D12Device14 * This, + _In_ UINT NumDestDescriptorRanges, + _In_reads_(NumDestDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pDestDescriptorRangeStarts, + _In_reads_opt_(NumDestDescriptorRanges) const UINT *pDestDescriptorRangeSizes, + _In_ UINT NumSrcDescriptorRanges, + _In_reads_(NumSrcDescriptorRanges) const D3D12_CPU_DESCRIPTOR_HANDLE *pSrcDescriptorRangeStarts, + _In_reads_opt_(NumSrcDescriptorRanges) const UINT *pSrcDescriptorRangeSizes, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, CopyDescriptorsSimple) + void ( STDMETHODCALLTYPE *CopyDescriptorsSimple )( + ID3D12Device14 * This, + _In_ UINT NumDescriptors, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptorRangeStart, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE SrcDescriptorRangeStart, + _In_ D3D12_DESCRIPTOR_HEAP_TYPE DescriptorHeapsType); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceAllocationInfo) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device14 * This, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + _In_ UINT visibleMask, + _In_ UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, GetCustomHeapProperties) +#if !defined(_WIN32) + D3D12_HEAP_PROPERTIES ( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#else + D3D12_HEAP_PROPERTIES *( STDMETHODCALLTYPE *GetCustomHeapProperties )( + ID3D12Device14 * This, + D3D12_HEAP_PROPERTIES * RetVal, + _In_ UINT nodeMask, + D3D12_HEAP_TYPE heapType); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommittedResource) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateHeap) + HRESULT ( STDMETHODCALLTYPE *CreateHeap )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, CreatePlacedResource) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource )( + ID3D12Device14 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateReservedResource) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateSharedHandle) + HRESULT ( STDMETHODCALLTYPE *CreateSharedHandle )( + ID3D12Device14 * This, + _In_ ID3D12DeviceChild *pObject, + _In_opt_ const SECURITY_ATTRIBUTES *pAttributes, + DWORD Access, + _In_opt_ LPCWSTR Name, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandle) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandle )( + ID3D12Device14 * This, + _In_ HANDLE NTHandle, + REFIID riid, + _COM_Outptr_opt_ void **ppvObj); + + DECLSPEC_XFGVIRT(ID3D12Device, OpenSharedHandleByName) + HRESULT ( STDMETHODCALLTYPE *OpenSharedHandleByName )( + ID3D12Device14 * This, + _In_ LPCWSTR Name, + DWORD Access, + /* [annotation][out] */ + _Out_ HANDLE *pNTHandle); + + DECLSPEC_XFGVIRT(ID3D12Device, MakeResident) + HRESULT ( STDMETHODCALLTYPE *MakeResident )( + ID3D12Device14 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, Evict) + HRESULT ( STDMETHODCALLTYPE *Evict )( + ID3D12Device14 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateFence) + HRESULT ( STDMETHODCALLTYPE *CreateFence )( + ID3D12Device14 * This, + UINT64 InitialValue, + D3D12_FENCE_FLAGS Flags, + REFIID riid, + _COM_Outptr_ void **ppFence); + + DECLSPEC_XFGVIRT(ID3D12Device, GetDeviceRemovedReason) + HRESULT ( STDMETHODCALLTYPE *GetDeviceRemovedReason )( + ID3D12Device14 * This); + + DECLSPEC_XFGVIRT(ID3D12Device, GetCopyableFootprints) + void ( STDMETHODCALLTYPE *GetCopyableFootprints )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateQueryHeap) + HRESULT ( STDMETHODCALLTYPE *CreateQueryHeap )( + ID3D12Device14 * This, + _In_ const D3D12_QUERY_HEAP_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device, SetStablePowerState) + HRESULT ( STDMETHODCALLTYPE *SetStablePowerState )( + ID3D12Device14 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Device, CreateCommandSignature) + HRESULT ( STDMETHODCALLTYPE *CreateCommandSignature )( + ID3D12Device14 * This, + _In_ const D3D12_COMMAND_SIGNATURE_DESC *pDesc, + _In_opt_ ID3D12RootSignature *pRootSignature, + REFIID riid, + _COM_Outptr_opt_ void **ppvCommandSignature); + + DECLSPEC_XFGVIRT(ID3D12Device, GetResourceTiling) + void ( STDMETHODCALLTYPE *GetResourceTiling )( + ID3D12Device14 * This, + _In_ ID3D12Resource *pTiledResource, + _Out_opt_ UINT *pNumTilesForEntireResource, + _Out_opt_ D3D12_PACKED_MIP_INFO *pPackedMipDesc, + _Out_opt_ D3D12_TILE_SHAPE *pStandardTileShapeForNonPackedMips, + _Inout_opt_ UINT *pNumSubresourceTilings, + _In_ UINT FirstSubresourceTilingToGet, + _Out_writes_(*pNumSubresourceTilings) D3D12_SUBRESOURCE_TILING *pSubresourceTilingsForNonPackedMips); + + DECLSPEC_XFGVIRT(ID3D12Device, GetAdapterLuid) +#if !defined(_WIN32) + LUID ( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device14 * This); + +#else + LUID *( STDMETHODCALLTYPE *GetAdapterLuid )( + ID3D12Device14 * This, + LUID * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device1, CreatePipelineLibrary) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineLibrary )( + ID3D12Device14 * This, + _In_reads_(BlobLength) const void *pLibraryBlob, + SIZE_T BlobLength, + REFIID riid, + _COM_Outptr_ void **ppPipelineLibrary); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetEventOnMultipleFenceCompletion) + HRESULT ( STDMETHODCALLTYPE *SetEventOnMultipleFenceCompletion )( + ID3D12Device14 * This, + _In_reads_(NumFences) ID3D12Fence *const *ppFences, + _In_reads_(NumFences) const UINT64 *pFenceValues, + UINT NumFences, + D3D12_MULTIPLE_FENCE_WAIT_FLAGS Flags, + HANDLE hEvent); + + DECLSPEC_XFGVIRT(ID3D12Device1, SetResidencyPriority) + HRESULT ( STDMETHODCALLTYPE *SetResidencyPriority )( + ID3D12Device14 * This, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_reads_(NumObjects) const D3D12_RESIDENCY_PRIORITY *pPriorities); + + DECLSPEC_XFGVIRT(ID3D12Device2, CreatePipelineState) + HRESULT ( STDMETHODCALLTYPE *CreatePipelineState )( + ID3D12Device14 * This, + const D3D12_PIPELINE_STATE_STREAM_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppPipelineState); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromAddress) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress )( + ID3D12Device14 * This, + _In_ const void *pAddress, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, OpenExistingHeapFromFileMapping) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromFileMapping )( + ID3D12Device14 * This, + _In_ HANDLE hFileMapping, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device3, EnqueueMakeResident) + HRESULT ( STDMETHODCALLTYPE *EnqueueMakeResident )( + ID3D12Device14 * This, + D3D12_RESIDENCY_FLAGS Flags, + UINT NumObjects, + _In_reads_(NumObjects) ID3D12Pageable *const *ppObjects, + _In_ ID3D12Fence *pFenceToSignal, + UINT64 FenceValueToSignal); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommandList1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandList1 )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_ D3D12_COMMAND_LIST_TYPE type, + _In_ D3D12_COMMAND_LIST_FLAGS flags, + REFIID riid, + _COM_Outptr_ void **ppCommandList); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateProtectedResourceSession) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession )( + ID3D12Device14 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateCommittedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource1 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateHeap1) + HRESULT ( STDMETHODCALLTYPE *CreateHeap1 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_DESC *pDesc, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device4, CreateReservedResource1) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource1 )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device4, GetResourceAllocationInfo1) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device14 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo1 )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateLifetimeTracker) + HRESULT ( STDMETHODCALLTYPE *CreateLifetimeTracker )( + ID3D12Device14 * This, + _In_ ID3D12LifetimeOwner *pOwner, + REFIID riid, + _COM_Outptr_ void **ppvTracker); + + DECLSPEC_XFGVIRT(ID3D12Device5, RemoveDevice) + void ( STDMETHODCALLTYPE *RemoveDevice )( + ID3D12Device14 * This); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommands) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommands )( + ID3D12Device14 * This, + _Inout_ UINT *pNumMetaCommands, + _Out_writes_opt_(*pNumMetaCommands) D3D12_META_COMMAND_DESC *pDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, EnumerateMetaCommandParameters) + HRESULT ( STDMETHODCALLTYPE *EnumerateMetaCommandParameters )( + ID3D12Device14 * This, + _In_ REFGUID CommandId, + _In_ D3D12_META_COMMAND_PARAMETER_STAGE Stage, + _Out_opt_ UINT *pTotalStructureSizeInBytes, + _Inout_ UINT *pParameterCount, + _Out_writes_opt_(*pParameterCount) D3D12_META_COMMAND_PARAMETER_DESC *pParameterDescs); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateMetaCommand) + HRESULT ( STDMETHODCALLTYPE *CreateMetaCommand )( + ID3D12Device14 * This, + _In_ REFGUID CommandId, + _In_ UINT NodeMask, + _In_reads_bytes_opt_(CreationParametersDataSizeInBytes) const void *pCreationParametersData, + _In_ SIZE_T CreationParametersDataSizeInBytes, + REFIID riid, + _COM_Outptr_ void **ppMetaCommand); + + DECLSPEC_XFGVIRT(ID3D12Device5, CreateStateObject) + HRESULT ( STDMETHODCALLTYPE *CreateStateObject )( + ID3D12Device14 * This, + const D3D12_STATE_OBJECT_DESC *pDesc, + REFIID riid, + _COM_Outptr_ void **ppStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device5, GetRaytracingAccelerationStructurePrebuildInfo) + void ( STDMETHODCALLTYPE *GetRaytracingAccelerationStructurePrebuildInfo )( + ID3D12Device14 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INPUTS *pDesc, + _Out_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO *pInfo); + + DECLSPEC_XFGVIRT(ID3D12Device5, CheckDriverMatchingIdentifier) + D3D12_DRIVER_MATCHING_IDENTIFIER_STATUS ( STDMETHODCALLTYPE *CheckDriverMatchingIdentifier )( + ID3D12Device14 * This, + _In_ D3D12_SERIALIZED_DATA_TYPE SerializedDataType, + _In_ const D3D12_SERIALIZED_DATA_DRIVER_MATCHING_IDENTIFIER *pIdentifierToCheck); + + DECLSPEC_XFGVIRT(ID3D12Device6, SetBackgroundProcessingMode) + HRESULT ( STDMETHODCALLTYPE *SetBackgroundProcessingMode )( + ID3D12Device14 * This, + D3D12_BACKGROUND_PROCESSING_MODE Mode, + D3D12_MEASUREMENTS_ACTION MeasurementsAction, + _In_opt_ HANDLE hEventToSignalUponCompletion, + _Out_opt_ BOOL *pbFurtherMeasurementsDesired); + + DECLSPEC_XFGVIRT(ID3D12Device7, AddToStateObject) + HRESULT ( STDMETHODCALLTYPE *AddToStateObject )( + ID3D12Device14 * This, + const D3D12_STATE_OBJECT_DESC *pAddition, + ID3D12StateObject *pStateObjectToGrowFrom, + REFIID riid, + _COM_Outptr_ void **ppNewStateObject); + + DECLSPEC_XFGVIRT(ID3D12Device7, CreateProtectedResourceSession1) + HRESULT ( STDMETHODCALLTYPE *CreateProtectedResourceSession1 )( + ID3D12Device14 * This, + _In_ const D3D12_PROTECTED_RESOURCE_SESSION_DESC1 *pDesc, + _In_ REFIID riid, + _COM_Outptr_ void **ppSession); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetResourceAllocationInfo2) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device14 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo2 )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateCommittedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource2 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialResourceState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreatePlacedResource1) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource1 )( + ID3D12Device14 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_RESOURCE_STATES InitialState, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device8, CreateSamplerFeedbackUnorderedAccessView) + void ( STDMETHODCALLTYPE *CreateSamplerFeedbackUnorderedAccessView )( + ID3D12Device14 * This, + _In_opt_ ID3D12Resource *pTargetedResource, + _In_opt_ ID3D12Resource *pFeedbackResource, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device8, GetCopyableFootprints1) + void ( STDMETHODCALLTYPE *GetCopyableFootprints1 )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC1 *pResourceDesc, + _In_range_(0,D3D12_REQ_SUBRESOURCES) UINT FirstSubresource, + _In_range_(0,D3D12_REQ_SUBRESOURCES-FirstSubresource) UINT NumSubresources, + UINT64 BaseOffset, + _Out_writes_opt_(NumSubresources) D3D12_PLACED_SUBRESOURCE_FOOTPRINT *pLayouts, + _Out_writes_opt_(NumSubresources) UINT *pNumRows, + _Out_writes_opt_(NumSubresources) UINT64 *pRowSizeInBytes, + _Out_opt_ UINT64 *pTotalBytes); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateShaderCacheSession) + HRESULT ( STDMETHODCALLTYPE *CreateShaderCacheSession )( + ID3D12Device14 * This, + _In_ const D3D12_SHADER_CACHE_SESSION_DESC *pDesc, + REFIID riid, + _COM_Outptr_opt_ void **ppvSession); + + DECLSPEC_XFGVIRT(ID3D12Device9, ShaderCacheControl) + HRESULT ( STDMETHODCALLTYPE *ShaderCacheControl )( + ID3D12Device14 * This, + D3D12_SHADER_CACHE_KIND_FLAGS Kinds, + D3D12_SHADER_CACHE_CONTROL_FLAGS Control); + + DECLSPEC_XFGVIRT(ID3D12Device9, CreateCommandQueue1) + HRESULT ( STDMETHODCALLTYPE *CreateCommandQueue1 )( + ID3D12Device14 * This, + _In_ const D3D12_COMMAND_QUEUE_DESC *pDesc, + REFIID CreatorID, + REFIID riid, + _COM_Outptr_ void **ppCommandQueue); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateCommittedResource3) + HRESULT ( STDMETHODCALLTYPE *CreateCommittedResource3 )( + ID3D12Device14 * This, + _In_ const D3D12_HEAP_PROPERTIES *pHeapProperties, + D3D12_HEAP_FLAGS HeapFlags, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riidResource, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreatePlacedResource2) + HRESULT ( STDMETHODCALLTYPE *CreatePlacedResource2 )( + ID3D12Device14 * This, + _In_ ID3D12Heap *pHeap, + UINT64 HeapOffset, + _In_ const D3D12_RESOURCE_DESC1 *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device10, CreateReservedResource2) + HRESULT ( STDMETHODCALLTYPE *CreateReservedResource2 )( + ID3D12Device14 * This, + _In_ const D3D12_RESOURCE_DESC *pDesc, + D3D12_BARRIER_LAYOUT InitialLayout, + _In_opt_ const D3D12_CLEAR_VALUE *pOptimizedClearValue, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedSession, + UINT32 NumCastableFormats, + _In_opt_count_(NumCastableFormats) const DXGI_FORMAT *pCastableFormats, + REFIID riid, + _COM_Outptr_opt_ void **ppvResource); + + DECLSPEC_XFGVIRT(ID3D12Device11, CreateSampler2) + void ( STDMETHODCALLTYPE *CreateSampler2 )( + ID3D12Device14 * This, + _In_ const D3D12_SAMPLER_DESC2 *pDesc, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DestDescriptor); + + DECLSPEC_XFGVIRT(ID3D12Device12, GetResourceAllocationInfo3) +#if !defined(_WIN32) + D3D12_RESOURCE_ALLOCATION_INFO ( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device14 * This, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#else + D3D12_RESOURCE_ALLOCATION_INFO *( STDMETHODCALLTYPE *GetResourceAllocationInfo3 )( + ID3D12Device14 * This, + D3D12_RESOURCE_ALLOCATION_INFO * RetVal, + UINT visibleMask, + UINT numResourceDescs, + _In_reads_(numResourceDescs) const D3D12_RESOURCE_DESC1 *pResourceDescs, + _In_opt_count_(numResourceDescs) const UINT32 *pNumCastableFormats, + _In_opt_count_(numResourceDescs) const DXGI_FORMAT *const *ppCastableFormats, + _Out_writes_opt_(numResourceDescs) D3D12_RESOURCE_ALLOCATION_INFO1 *pResourceAllocationInfo1); + +#endif + + DECLSPEC_XFGVIRT(ID3D12Device13, OpenExistingHeapFromAddress1) + HRESULT ( STDMETHODCALLTYPE *OpenExistingHeapFromAddress1 )( + ID3D12Device14 * This, + _In_ const void *pAddress, + SIZE_T size, + REFIID riid, + _COM_Outptr_ void **ppvHeap); + + DECLSPEC_XFGVIRT(ID3D12Device14, CreateRootSignatureFromSubobjectInLibrary) + HRESULT ( STDMETHODCALLTYPE *CreateRootSignatureFromSubobjectInLibrary )( + ID3D12Device14 * This, + _In_ UINT nodeMask, + _In_reads_(blobLengthInBytes) const void *pLibraryBlob, + _In_ SIZE_T blobLengthInBytes, + _In_opt_ LPCWSTR subobjectName, + REFIID riid, + _COM_Outptr_ void **ppvRootSignature); + + END_INTERFACE + } ID3D12Device14Vtbl; + + interface ID3D12Device14 + { + CONST_VTBL struct ID3D12Device14Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Device14_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Device14_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Device14_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Device14_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12Device14_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12Device14_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12Device14_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12Device14_GetNodeCount(This) \ + ( (This)->lpVtbl -> GetNodeCount(This) ) + +#define ID3D12Device14_CreateCommandQueue(This,pDesc,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue(This,pDesc,riid,ppCommandQueue) ) + +#define ID3D12Device14_CreateCommandAllocator(This,type,riid,ppCommandAllocator) \ + ( (This)->lpVtbl -> CreateCommandAllocator(This,type,riid,ppCommandAllocator) ) + +#define ID3D12Device14_CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateGraphicsPipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device14_CreateComputePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreateComputePipelineState(This,pDesc,riid,ppPipelineState) ) + +#define ID3D12Device14_CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList(This,nodeMask,type,pCommandAllocator,pInitialState,riid,ppCommandList) ) + +#define ID3D12Device14_CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) \ + ( (This)->lpVtbl -> CheckFeatureSupport(This,Feature,pFeatureSupportData,FeatureSupportDataSize) ) + +#define ID3D12Device14_CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateDescriptorHeap(This,pDescriptorHeapDesc,riid,ppvHeap) ) + +#define ID3D12Device14_GetDescriptorHandleIncrementSize(This,DescriptorHeapType) \ + ( (This)->lpVtbl -> GetDescriptorHandleIncrementSize(This,DescriptorHeapType) ) + +#define ID3D12Device14_CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignature(This,nodeMask,pBlobWithRootSignature,blobLengthInBytes,riid,ppvRootSignature) ) + +#define ID3D12Device14_CreateConstantBufferView(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateConstantBufferView(This,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateShaderResourceView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateUnorderedAccessView(This,pResource,pCounterResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateRenderTargetView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateDepthStencilView(This,pResource,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CreateSampler(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler(This,pDesc,DestDescriptor) ) + +#define ID3D12Device14_CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptors(This,NumDestDescriptorRanges,pDestDescriptorRangeStarts,pDestDescriptorRangeSizes,NumSrcDescriptorRanges,pSrcDescriptorRangeStarts,pSrcDescriptorRangeSizes,DescriptorHeapsType) ) + +#define ID3D12Device14_CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) \ + ( (This)->lpVtbl -> CopyDescriptorsSimple(This,NumDescriptors,DestDescriptorRangeStart,SrcDescriptorRangeStart,DescriptorHeapsType) ) +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,visibleMask,numResourceDescs,pResourceDescs) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo(This,RetVal,visibleMask,numResourceDescs,pResourceDescs) ) +#endif +#if !defined(_WIN32) + +#define ID3D12Device14_GetCustomHeapProperties(This,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,nodeMask,heapType) ) +#else +#define ID3D12Device14_GetCustomHeapProperties(This,RetVal,nodeMask,heapType) \ + ( (This)->lpVtbl -> GetCustomHeapProperties(This,RetVal,nodeMask,heapType) ) +#endif + +#define ID3D12Device14_CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,riidResource,ppvResource) ) + +#define ID3D12Device14_CreateHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device14_CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device14_CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource(This,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device14_CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) \ + ( (This)->lpVtbl -> CreateSharedHandle(This,pObject,pAttributes,Access,Name,pHandle) ) + +#define ID3D12Device14_OpenSharedHandle(This,NTHandle,riid,ppvObj) \ + ( (This)->lpVtbl -> OpenSharedHandle(This,NTHandle,riid,ppvObj) ) + +#define ID3D12Device14_OpenSharedHandleByName(This,Name,Access,pNTHandle) \ + ( (This)->lpVtbl -> OpenSharedHandleByName(This,Name,Access,pNTHandle) ) + +#define ID3D12Device14_MakeResident(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> MakeResident(This,NumObjects,ppObjects) ) + +#define ID3D12Device14_Evict(This,NumObjects,ppObjects) \ + ( (This)->lpVtbl -> Evict(This,NumObjects,ppObjects) ) + +#define ID3D12Device14_CreateFence(This,InitialValue,Flags,riid,ppFence) \ + ( (This)->lpVtbl -> CreateFence(This,InitialValue,Flags,riid,ppFence) ) + +#define ID3D12Device14_GetDeviceRemovedReason(This) \ + ( (This)->lpVtbl -> GetDeviceRemovedReason(This) ) + +#define ID3D12Device14_GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + +#define ID3D12Device14_CreateQueryHeap(This,pDesc,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateQueryHeap(This,pDesc,riid,ppvHeap) ) + +#define ID3D12Device14_SetStablePowerState(This,Enable) \ + ( (This)->lpVtbl -> SetStablePowerState(This,Enable) ) + +#define ID3D12Device14_CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) \ + ( (This)->lpVtbl -> CreateCommandSignature(This,pDesc,pRootSignature,riid,ppvCommandSignature) ) + +#define ID3D12Device14_GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) \ + ( (This)->lpVtbl -> GetResourceTiling(This,pTiledResource,pNumTilesForEntireResource,pPackedMipDesc,pStandardTileShapeForNonPackedMips,pNumSubresourceTilings,FirstSubresourceTilingToGet,pSubresourceTilingsForNonPackedMips) ) +#if !defined(_WIN32) + +#define ID3D12Device14_GetAdapterLuid(This) \ + ( (This)->lpVtbl -> GetAdapterLuid(This) ) +#else +#define ID3D12Device14_GetAdapterLuid(This,RetVal) \ + ( (This)->lpVtbl -> GetAdapterLuid(This,RetVal) ) +#endif + + +#define ID3D12Device14_CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) \ + ( (This)->lpVtbl -> CreatePipelineLibrary(This,pLibraryBlob,BlobLength,riid,ppPipelineLibrary) ) + +#define ID3D12Device14_SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) \ + ( (This)->lpVtbl -> SetEventOnMultipleFenceCompletion(This,ppFences,pFenceValues,NumFences,Flags,hEvent) ) + +#define ID3D12Device14_SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) \ + ( (This)->lpVtbl -> SetResidencyPriority(This,NumObjects,ppObjects,pPriorities) ) + + +#define ID3D12Device14_CreatePipelineState(This,pDesc,riid,ppPipelineState) \ + ( (This)->lpVtbl -> CreatePipelineState(This,pDesc,riid,ppPipelineState) ) + + +#define ID3D12Device14_OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress(This,pAddress,riid,ppvHeap) ) + +#define ID3D12Device14_OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromFileMapping(This,hFileMapping,riid,ppvHeap) ) + +#define ID3D12Device14_EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) \ + ( (This)->lpVtbl -> EnqueueMakeResident(This,Flags,NumObjects,ppObjects,pFenceToSignal,FenceValueToSignal) ) + + +#define ID3D12Device14_CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) \ + ( (This)->lpVtbl -> CreateCommandList1(This,nodeMask,type,flags,riid,ppCommandList) ) + +#define ID3D12Device14_CreateProtectedResourceSession(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession(This,pDesc,riid,ppSession) ) + +#define ID3D12Device14_CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource1(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device14_CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) \ + ( (This)->lpVtbl -> CreateHeap1(This,pDesc,pProtectedSession,riid,ppvHeap) ) + +#define ID3D12Device14_CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource1(This,pDesc,InitialState,pOptimizedClearValue,pProtectedSession,riid,ppvResource) ) +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo1(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device14_CreateLifetimeTracker(This,pOwner,riid,ppvTracker) \ + ( (This)->lpVtbl -> CreateLifetimeTracker(This,pOwner,riid,ppvTracker) ) + +#define ID3D12Device14_RemoveDevice(This) \ + ( (This)->lpVtbl -> RemoveDevice(This) ) + +#define ID3D12Device14_EnumerateMetaCommands(This,pNumMetaCommands,pDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommands(This,pNumMetaCommands,pDescs) ) + +#define ID3D12Device14_EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) \ + ( (This)->lpVtbl -> EnumerateMetaCommandParameters(This,CommandId,Stage,pTotalStructureSizeInBytes,pParameterCount,pParameterDescs) ) + +#define ID3D12Device14_CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) \ + ( (This)->lpVtbl -> CreateMetaCommand(This,CommandId,NodeMask,pCreationParametersData,CreationParametersDataSizeInBytes,riid,ppMetaCommand) ) + +#define ID3D12Device14_CreateStateObject(This,pDesc,riid,ppStateObject) \ + ( (This)->lpVtbl -> CreateStateObject(This,pDesc,riid,ppStateObject) ) + +#define ID3D12Device14_GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) \ + ( (This)->lpVtbl -> GetRaytracingAccelerationStructurePrebuildInfo(This,pDesc,pInfo) ) + +#define ID3D12Device14_CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) \ + ( (This)->lpVtbl -> CheckDriverMatchingIdentifier(This,SerializedDataType,pIdentifierToCheck) ) + + +#define ID3D12Device14_SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) \ + ( (This)->lpVtbl -> SetBackgroundProcessingMode(This,Mode,MeasurementsAction,hEventToSignalUponCompletion,pbFurtherMeasurementsDesired) ) + + +#define ID3D12Device14_AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) \ + ( (This)->lpVtbl -> AddToStateObject(This,pAddition,pStateObjectToGrowFrom,riid,ppNewStateObject) ) + +#define ID3D12Device14_CreateProtectedResourceSession1(This,pDesc,riid,ppSession) \ + ( (This)->lpVtbl -> CreateProtectedResourceSession1(This,pDesc,riid,ppSession) ) + +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo2(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pResourceAllocationInfo1) ) +#endif + +#define ID3D12Device14_CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource2(This,pHeapProperties,HeapFlags,pDesc,InitialResourceState,pOptimizedClearValue,pProtectedSession,riidResource,ppvResource) ) + +#define ID3D12Device14_CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource1(This,pHeap,HeapOffset,pDesc,InitialState,pOptimizedClearValue,riid,ppvResource) ) + +#define ID3D12Device14_CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSamplerFeedbackUnorderedAccessView(This,pTargetedResource,pFeedbackResource,DestDescriptor) ) + +#define ID3D12Device14_GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) \ + ( (This)->lpVtbl -> GetCopyableFootprints1(This,pResourceDesc,FirstSubresource,NumSubresources,BaseOffset,pLayouts,pNumRows,pRowSizeInBytes,pTotalBytes) ) + + +#define ID3D12Device14_CreateShaderCacheSession(This,pDesc,riid,ppvSession) \ + ( (This)->lpVtbl -> CreateShaderCacheSession(This,pDesc,riid,ppvSession) ) + +#define ID3D12Device14_ShaderCacheControl(This,Kinds,Control) \ + ( (This)->lpVtbl -> ShaderCacheControl(This,Kinds,Control) ) + +#define ID3D12Device14_CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) \ + ( (This)->lpVtbl -> CreateCommandQueue1(This,pDesc,CreatorID,riid,ppCommandQueue) ) + + +#define ID3D12Device14_CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) \ + ( (This)->lpVtbl -> CreateCommittedResource3(This,pHeapProperties,HeapFlags,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riidResource,ppvResource) ) + +#define ID3D12Device14_CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreatePlacedResource2(This,pHeap,HeapOffset,pDesc,InitialLayout,pOptimizedClearValue,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + +#define ID3D12Device14_CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) \ + ( (This)->lpVtbl -> CreateReservedResource2(This,pDesc,InitialLayout,pOptimizedClearValue,pProtectedSession,NumCastableFormats,pCastableFormats,riid,ppvResource) ) + + +#define ID3D12Device14_CreateSampler2(This,pDesc,DestDescriptor) \ + ( (This)->lpVtbl -> CreateSampler2(This,pDesc,DestDescriptor) ) + +#if !defined(_WIN32) + +#define ID3D12Device14_GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#else +#define ID3D12Device14_GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) \ + ( (This)->lpVtbl -> GetResourceAllocationInfo3(This,RetVal,visibleMask,numResourceDescs,pResourceDescs,pNumCastableFormats,ppCastableFormats,pResourceAllocationInfo1) ) +#endif + + +#define ID3D12Device14_OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) \ + ( (This)->lpVtbl -> OpenExistingHeapFromAddress1(This,pAddress,size,riid,ppvHeap) ) + + +#define ID3D12Device14_CreateRootSignatureFromSubobjectInLibrary(This,nodeMask,pLibraryBlob,blobLengthInBytes,subobjectName,riid,ppvRootSignature) \ + ( (This)->lpVtbl -> CreateRootSignatureFromSubobjectInLibrary(This,nodeMask,pLibraryBlob,blobLengthInBytes,subobjectName,riid,ppvRootSignature) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Device14_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ +#define __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ + +/* interface ID3D12VirtualizationGuestDevice */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12VirtualizationGuestDevice; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("bc66d368-7373-4943-8757-fc87dc79e476") + ID3D12VirtualizationGuestDevice : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE ShareWithHost( + _In_ ID3D12DeviceChild *pObject, + _Out_ HANDLE *pHandle) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateFenceFd( + _In_ ID3D12Fence *pFence, + UINT64 FenceValue, + _Out_ int *pFenceFd) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12VirtualizationGuestDeviceVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12VirtualizationGuestDevice * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12VirtualizationGuestDevice * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12VirtualizationGuestDevice * This); + + DECLSPEC_XFGVIRT(ID3D12VirtualizationGuestDevice, ShareWithHost) + HRESULT ( STDMETHODCALLTYPE *ShareWithHost )( + ID3D12VirtualizationGuestDevice * This, + _In_ ID3D12DeviceChild *pObject, + _Out_ HANDLE *pHandle); + + DECLSPEC_XFGVIRT(ID3D12VirtualizationGuestDevice, CreateFenceFd) + HRESULT ( STDMETHODCALLTYPE *CreateFenceFd )( + ID3D12VirtualizationGuestDevice * This, + _In_ ID3D12Fence *pFence, + UINT64 FenceValue, + _Out_ int *pFenceFd); + + END_INTERFACE + } ID3D12VirtualizationGuestDeviceVtbl; + + interface ID3D12VirtualizationGuestDevice + { + CONST_VTBL struct ID3D12VirtualizationGuestDeviceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12VirtualizationGuestDevice_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12VirtualizationGuestDevice_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12VirtualizationGuestDevice_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12VirtualizationGuestDevice_ShareWithHost(This,pObject,pHandle) \ + ( (This)->lpVtbl -> ShareWithHost(This,pObject,pHandle) ) + +#define ID3D12VirtualizationGuestDevice_CreateFenceFd(This,pFence,FenceValue,pFenceFd) \ + ( (This)->lpVtbl -> CreateFenceFd(This,pFence,FenceValue,pFenceFd) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12VirtualizationGuestDevice_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Tools_INTERFACE_DEFINED__ +#define __ID3D12Tools_INTERFACE_DEFINED__ + +/* interface ID3D12Tools */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Tools; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("7071e1f0-e84b-4b33-974f-12fa49de65c5") + ID3D12Tools : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE EnableShaderInstrumentation( + BOOL bEnable) = 0; + + virtual BOOL STDMETHODCALLTYPE ShaderInstrumentationEnabled( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ToolsVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Tools * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Tools * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Tools * This); + + DECLSPEC_XFGVIRT(ID3D12Tools, EnableShaderInstrumentation) + void ( STDMETHODCALLTYPE *EnableShaderInstrumentation )( + ID3D12Tools * This, + BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12Tools, ShaderInstrumentationEnabled) + BOOL ( STDMETHODCALLTYPE *ShaderInstrumentationEnabled )( + ID3D12Tools * This); + + END_INTERFACE + } ID3D12ToolsVtbl; + + interface ID3D12Tools + { + CONST_VTBL struct ID3D12ToolsVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Tools_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Tools_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Tools_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Tools_EnableShaderInstrumentation(This,bEnable) \ + ( (This)->lpVtbl -> EnableShaderInstrumentation(This,bEnable) ) + +#define ID3D12Tools_ShaderInstrumentationEnabled(This) \ + ( (This)->lpVtbl -> ShaderInstrumentationEnabled(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Tools_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0062 */ +/* [local] */ + +typedef struct D3D12_SUBRESOURCE_DATA + { + const void *pData; + LONG_PTR RowPitch; + LONG_PTR SlicePitch; + } D3D12_SUBRESOURCE_DATA; + +typedef struct D3D12_MEMCPY_DEST + { + void *pData; + SIZE_T RowPitch; + SIZE_T SlicePitch; + } D3D12_MEMCPY_DEST; + +#if !defined( D3D12_IGNORE_SDK_LAYERS ) +#include "d3d12sdklayers.h" +#endif + +/////////////////////////////////////////////////////////////////////////// +// D3D12CreateDevice +// ------------------ +// +// pAdapter +// If NULL, D3D12CreateDevice will choose the primary adapter. +// If non-NULL, D3D12CreateDevice will use the provided adapter. +// MinimumFeatureLevel +// The minimum feature level required for successful device creation. +// riid +// The interface IID of the device to be returned. Expected: ID3D12Device. +// ppDevice +// Pointer to returned interface. May be NULL. +// +// Return Values +// Any of those documented for +// CreateDXGIFactory1 +// IDXGIFactory::EnumAdapters +// D3D12CreateDevice +// +/////////////////////////////////////////////////////////////////////////// +typedef HRESULT (WINAPI* PFN_D3D12_CREATE_DEVICE)( _In_opt_ IUnknown*, + D3D_FEATURE_LEVEL, + _In_ REFIID, _COM_Outptr_opt_ void** ); + +HRESULT WINAPI D3D12CreateDevice( + _In_opt_ IUnknown* pAdapter, + D3D_FEATURE_LEVEL MinimumFeatureLevel, + _In_ REFIID riid, // Expected: ID3D12Device + _COM_Outptr_opt_ void** ppDevice ); + + +typedef HRESULT (WINAPI* PFN_D3D12_GET_DEBUG_INTERFACE)( _In_ REFIID, _COM_Outptr_opt_ void** ); + +HRESULT WINAPI D3D12GetDebugInterface( _In_ REFIID riid, _COM_Outptr_opt_ void** ppvDebug ); + +// -------------------------------------------------------------------------------------------------------------------------------- +// D3D12EnableExperimentalFeatures +// +// Pass in a list of feature GUIDs to be enabled together. +// +// If a particular feature requires some configuration information on enablement, it will have +// a configuration struct that can be passed alongside the GUID. +// +// Some features might use an interface IID as the GUID. For these, once the feature is enabled via +// D3D12EnableExperimentalFeatures, D3D12GetDebugInterface can then be called with the IID to retrieve the interface +// for manipulating the feature. This allows for control that might not cleanly be expressed by just +// the configuration struct that D3D12EnableExperimentalFeatures provides. +// +// If this method is called and a change to existing feature enablement is made, +// all current D3D12 devices are set to DEVICE_REMOVED state, since under the covers there is really only one +// singleton device for a process. Removing the devices when configuration changes prevents +// mismatched expectations of how a device is supposed to work after it has been created from the app's point of view. +// +// The call returns E_NOINTERFACE if an unrecognized feature is passed in or Windows Developer mode is not on. +// The call returns E_INVALIDARG if the configuration of a feature is incorrect, the set of features passed +// in are known to be incompatible with each other, or other errors. +// Returns S_OK otherwise. +// +// -------------------------------------------------------------------------------------------------------------------------------- +HRESULT WINAPI D3D12EnableExperimentalFeatures( + UINT NumFeatures, + _In_count_(NumFeatures) const IID* pIIDs, + _In_opt_count_(NumFeatures) void* pConfigurationStructs, + _In_opt_count_(NumFeatures) UINT* pConfigurationStructSizes); + +// -------------------------------------------------------------------------------------------------------------------------------- +// Experimental Feature: D3D12ExperimentalShaderModels +// +// Use with D3D12EnableExperimentalFeatures to enable experimental shader model support, +// meaning shader models that haven't been finalized for use in retail. +// +// Enabling D3D12ExperimentalShaderModels needs no configuration struct, pass NULL in the pConfigurationStructs array. +// +// -------------------------------------------------------------------------------------------------------------------------------- +static const UUID D3D12ExperimentalShaderModels = { /* 76f5573e-f13a-40f5-b297-81ce9e18933f */ + 0x76f5573e, + 0xf13a, + 0x40f5, + { 0xb2, 0x97, 0x81, 0xce, 0x9e, 0x18, 0x93, 0x3f } +}; +// -------------------------------------------------------------------------------------------------------------------------------- +// Experimental Feature: D3D12TiledResourceTier4 +// +// Use with D3D12EnableExperimentalFeatures to enable tiled resource tier 4 support, +// meaning texture tile data-inheritance is allowed. +// +// Enabling D3D12TiledResourceTier4 needs no configuration struct, pass NULL in the pConfigurationStructs array. +// +// -------------------------------------------------------------------------------------------------------------------------------- +static const UUID D3D12TiledResourceTier4 = { /* c9c4725f-a81a-4f56-8c5b-c51039d694fb */ + 0xc9c4725f, + 0xa81a, + 0x4f56, + { 0x8c, 0x5b, 0xc5, 0x10, 0x39, 0xd6, 0x94, 0xfb } +}; +// -------------------------------------------------------------------------------------------------------------------------------- +// D3D12GetInterface +// +// Retrieve Global D3D12 Interface. +// + +DEFINE_GUID(CLSID_D3D12Debug, 0xf2352aeb, 0xdd84, 0x49fe, 0xb9, 0x7b, 0xa9, 0xdc, 0xfd, 0xcc, 0x1b, 0x4f); +DEFINE_GUID(CLSID_D3D12Tools, 0xe38216b1, 0x3c8c, 0x4833, 0xaa, 0x09, 0x0a, 0x06, 0xb6, 0x5d, 0x96, 0xc8); +DEFINE_GUID(CLSID_D3D12DeviceRemovedExtendedData, 0x4a75bbc4, 0x9ff4, 0x4ad8, 0x9f, 0x18, 0xab, 0xae, 0x84, 0xdc, 0x5f, 0xf2); +DEFINE_GUID(CLSID_D3D12SDKConfiguration, 0x7cda6aca, 0xa03e, 0x49c8, 0x94, 0x58, 0x03, 0x34, 0xd2, 0x0e, 0x07, 0xce); +DEFINE_GUID(CLSID_D3D12DeviceFactory, 0x114863bf, 0xc386, 0x4aee, 0xb3, 0x9d, 0x8f, 0x0b, 0xbb, 0x06, 0x29, 0x55); + +typedef HRESULT (WINAPI* PFN_D3D12_GET_INTERFACE)( _In_ REFCLSID, _In_ REFIID, _COM_Outptr_opt_ void** ); + +HRESULT WINAPI D3D12GetInterface( _In_ REFCLSID rclsid, _In_ REFIID riid, _COM_Outptr_opt_ void** ppvDebug ); + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0062_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0062_v0_0_s_ifspec; + +#ifndef __ID3D12SDKConfiguration_INTERFACE_DEFINED__ +#define __ID3D12SDKConfiguration_INTERFACE_DEFINED__ + +/* interface ID3D12SDKConfiguration */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12SDKConfiguration; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("e9eb5314-33aa-42b2-a718-d77f58b1f1c7") + ID3D12SDKConfiguration : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetSDKVersion( + UINT SDKVersion, + _In_z_ LPCSTR SDKPath) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12SDKConfigurationVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12SDKConfiguration * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12SDKConfiguration * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12SDKConfiguration * This); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration, SetSDKVersion) + HRESULT ( STDMETHODCALLTYPE *SetSDKVersion )( + ID3D12SDKConfiguration * This, + UINT SDKVersion, + _In_z_ LPCSTR SDKPath); + + END_INTERFACE + } ID3D12SDKConfigurationVtbl; + + interface ID3D12SDKConfiguration + { + CONST_VTBL struct ID3D12SDKConfigurationVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12SDKConfiguration_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12SDKConfiguration_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12SDKConfiguration_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12SDKConfiguration_SetSDKVersion(This,SDKVersion,SDKPath) \ + ( (This)->lpVtbl -> SetSDKVersion(This,SDKVersion,SDKPath) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12SDKConfiguration_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ +#define __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ + +/* interface ID3D12SDKConfiguration1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12SDKConfiguration1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("8aaf9303-ad25-48b9-9a57-d9c37e009d9f") + ID3D12SDKConfiguration1 : public ID3D12SDKConfiguration + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateDeviceFactory( + UINT SDKVersion, + _In_ LPCSTR SDKPath, + REFIID riid, + _COM_Outptr_ void **ppvFactory) = 0; + + virtual void STDMETHODCALLTYPE FreeUnusedSDKs( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12SDKConfiguration1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12SDKConfiguration1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12SDKConfiguration1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12SDKConfiguration1 * This); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration, SetSDKVersion) + HRESULT ( STDMETHODCALLTYPE *SetSDKVersion )( + ID3D12SDKConfiguration1 * This, + UINT SDKVersion, + _In_z_ LPCSTR SDKPath); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration1, CreateDeviceFactory) + HRESULT ( STDMETHODCALLTYPE *CreateDeviceFactory )( + ID3D12SDKConfiguration1 * This, + UINT SDKVersion, + _In_ LPCSTR SDKPath, + REFIID riid, + _COM_Outptr_ void **ppvFactory); + + DECLSPEC_XFGVIRT(ID3D12SDKConfiguration1, FreeUnusedSDKs) + void ( STDMETHODCALLTYPE *FreeUnusedSDKs )( + ID3D12SDKConfiguration1 * This); + + END_INTERFACE + } ID3D12SDKConfiguration1Vtbl; + + interface ID3D12SDKConfiguration1 + { + CONST_VTBL struct ID3D12SDKConfiguration1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12SDKConfiguration1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12SDKConfiguration1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12SDKConfiguration1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12SDKConfiguration1_SetSDKVersion(This,SDKVersion,SDKPath) \ + ( (This)->lpVtbl -> SetSDKVersion(This,SDKVersion,SDKPath) ) + + +#define ID3D12SDKConfiguration1_CreateDeviceFactory(This,SDKVersion,SDKPath,riid,ppvFactory) \ + ( (This)->lpVtbl -> CreateDeviceFactory(This,SDKVersion,SDKPath,riid,ppvFactory) ) + +#define ID3D12SDKConfiguration1_FreeUnusedSDKs(This) \ + ( (This)->lpVtbl -> FreeUnusedSDKs(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12SDKConfiguration1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0064 */ +/* [local] */ + +typedef +enum D3D12_DEVICE_FACTORY_FLAGS + { + D3D12_DEVICE_FACTORY_FLAG_NONE = 0, + D3D12_DEVICE_FACTORY_FLAG_ALLOW_RETURNING_EXISTING_DEVICE = 0x1, + D3D12_DEVICE_FACTORY_FLAG_ALLOW_RETURNING_INCOMPATIBLE_EXISTING_DEVICE = 0x2, + D3D12_DEVICE_FACTORY_FLAG_DISALLOW_STORING_NEW_DEVICE_AS_SINGLETON = 0x4 + } D3D12_DEVICE_FACTORY_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEVICE_FACTORY_FLAGS ) + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0064_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0064_v0_0_s_ifspec; + +#ifndef __ID3D12DeviceFactory_INTERFACE_DEFINED__ +#define __ID3D12DeviceFactory_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceFactory */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceFactory; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("61f307d3-d34e-4e7c-8374-3ba4de23cccb") + ID3D12DeviceFactory : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE InitializeFromGlobalState( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE ApplyToGlobalState( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetFlags( + D3D12_DEVICE_FACTORY_FLAGS flags) = 0; + + virtual D3D12_DEVICE_FACTORY_FLAGS STDMETHODCALLTYPE GetFlags( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetConfigurationInterface( + REFCLSID clsid, + REFIID iid, + _COM_Outptr_ void **ppv) = 0; + + virtual HRESULT STDMETHODCALLTYPE EnableExperimentalFeatures( + UINT NumFeatures, + _In_reads_(NumFeatures) const IID *pIIDs, + _In_reads_opt_(NumFeatures) void *pConfigurationStructs, + _In_reads_opt_(NumFeatures) UINT *pConfigurationStructSizes) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateDevice( + _In_opt_ IUnknown *adapter, + D3D_FEATURE_LEVEL FeatureLevel, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceFactoryVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceFactory * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, InitializeFromGlobalState) + HRESULT ( STDMETHODCALLTYPE *InitializeFromGlobalState )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, ApplyToGlobalState) + HRESULT ( STDMETHODCALLTYPE *ApplyToGlobalState )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, SetFlags) + HRESULT ( STDMETHODCALLTYPE *SetFlags )( + ID3D12DeviceFactory * This, + D3D12_DEVICE_FACTORY_FLAGS flags); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, GetFlags) + D3D12_DEVICE_FACTORY_FLAGS ( STDMETHODCALLTYPE *GetFlags )( + ID3D12DeviceFactory * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, GetConfigurationInterface) + HRESULT ( STDMETHODCALLTYPE *GetConfigurationInterface )( + ID3D12DeviceFactory * This, + REFCLSID clsid, + REFIID iid, + _COM_Outptr_ void **ppv); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, EnableExperimentalFeatures) + HRESULT ( STDMETHODCALLTYPE *EnableExperimentalFeatures )( + ID3D12DeviceFactory * This, + UINT NumFeatures, + _In_reads_(NumFeatures) const IID *pIIDs, + _In_reads_opt_(NumFeatures) void *pConfigurationStructs, + _In_reads_opt_(NumFeatures) UINT *pConfigurationStructSizes); + + DECLSPEC_XFGVIRT(ID3D12DeviceFactory, CreateDevice) + HRESULT ( STDMETHODCALLTYPE *CreateDevice )( + ID3D12DeviceFactory * This, + _In_opt_ IUnknown *adapter, + D3D_FEATURE_LEVEL FeatureLevel, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + END_INTERFACE + } ID3D12DeviceFactoryVtbl; + + interface ID3D12DeviceFactory + { + CONST_VTBL struct ID3D12DeviceFactoryVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceFactory_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceFactory_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceFactory_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DeviceFactory_InitializeFromGlobalState(This) \ + ( (This)->lpVtbl -> InitializeFromGlobalState(This) ) + +#define ID3D12DeviceFactory_ApplyToGlobalState(This) \ + ( (This)->lpVtbl -> ApplyToGlobalState(This) ) + +#define ID3D12DeviceFactory_SetFlags(This,flags) \ + ( (This)->lpVtbl -> SetFlags(This,flags) ) + +#define ID3D12DeviceFactory_GetFlags(This) \ + ( (This)->lpVtbl -> GetFlags(This) ) + +#define ID3D12DeviceFactory_GetConfigurationInterface(This,clsid,iid,ppv) \ + ( (This)->lpVtbl -> GetConfigurationInterface(This,clsid,iid,ppv) ) + +#define ID3D12DeviceFactory_EnableExperimentalFeatures(This,NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) \ + ( (This)->lpVtbl -> EnableExperimentalFeatures(This,NumFeatures,pIIDs,pConfigurationStructs,pConfigurationStructSizes) ) + +#define ID3D12DeviceFactory_CreateDevice(This,adapter,FeatureLevel,riid,ppvDevice) \ + ( (This)->lpVtbl -> CreateDevice(This,adapter,FeatureLevel,riid,ppvDevice) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceFactory_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0065 */ +/* [local] */ + +typedef +enum D3D12_DEVICE_FLAGS + { + D3D12_DEVICE_FLAG_NONE = 0, + D3D12_DEVICE_FLAG_DEBUG_LAYER_ENABLED = 0x1, + D3D12_DEVICE_FLAG_GPU_BASED_VALIDATION_ENABLED = 0x2, + D3D12_DEVICE_FLAG_SYNCHRONIZED_COMMAND_QUEUE_VALIDATION_DISABLED = 0x4, + D3D12_DEVICE_FLAG_DRED_AUTO_BREADCRUMBS_ENABLED = 0x8, + D3D12_DEVICE_FLAG_DRED_PAGE_FAULT_REPORTING_ENABLED = 0x10, + D3D12_DEVICE_FLAG_DRED_WATSON_REPORTING_ENABLED = 0x20, + D3D12_DEVICE_FLAG_DRED_BREADCRUMB_CONTEXT_ENABLED = 0x40, + D3D12_DEVICE_FLAG_DRED_USE_MARKERS_ONLY_BREADCRUMBS = 0x80, + D3D12_DEVICE_FLAG_SHADER_INSTRUMENTATION_ENABLED = 0x100, + D3D12_DEVICE_FLAG_AUTO_DEBUG_NAME_ENABLED = 0x200, + D3D12_DEVICE_FLAG_FORCE_LEGACY_STATE_VALIDATION = 0x400 + } D3D12_DEVICE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS( D3D12_DEVICE_FLAGS ) +typedef struct D3D12_DEVICE_CONFIGURATION_DESC + { + D3D12_DEVICE_FLAGS Flags; + UINT GPUBasedValidationFlags; + UINT SDKVersion; + UINT NumEnabledExperimentalFeatures; + } D3D12_DEVICE_CONFIGURATION_DESC; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0065_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0065_v0_0_s_ifspec; + +#ifndef __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ +#define __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceConfiguration */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceConfiguration; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("78dbf87b-f766-422b-a61c-c8c446bdb9ad") + ID3D12DeviceConfiguration : public IUnknown + { + public: +#if defined(_MSC_VER) || !defined(_WIN32) + virtual D3D12_DEVICE_CONFIGURATION_DESC STDMETHODCALLTYPE GetDesc( void) = 0; +#else + virtual D3D12_DEVICE_CONFIGURATION_DESC *STDMETHODCALLTYPE GetDesc( + D3D12_DEVICE_CONFIGURATION_DESC * RetVal) = 0; +#endif + + virtual HRESULT STDMETHODCALLTYPE GetEnabledExperimentalFeatures( + _Out_writes_(NumGuids) GUID *pGuids, + UINT NumGuids) = 0; + + virtual HRESULT STDMETHODCALLTYPE SerializeVersionedRootSignature( + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, + _COM_Outptr_ ID3DBlob **ppResult, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError) = 0; + + virtual HRESULT STDMETHODCALLTYPE CreateVersionedRootSignatureDeserializer( + _In_reads_bytes_(Size) const void *pBlob, + SIZE_T Size, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceConfigurationVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceConfiguration * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceConfiguration * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceConfiguration * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetDesc) +#if !defined(_WIN32) + D3D12_DEVICE_CONFIGURATION_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration * This); + +#else + D3D12_DEVICE_CONFIGURATION_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration * This, + D3D12_DEVICE_CONFIGURATION_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetEnabledExperimentalFeatures) + HRESULT ( STDMETHODCALLTYPE *GetEnabledExperimentalFeatures )( + ID3D12DeviceConfiguration * This, + _Out_writes_(NumGuids) GUID *pGuids, + UINT NumGuids); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, SerializeVersionedRootSignature) + HRESULT ( STDMETHODCALLTYPE *SerializeVersionedRootSignature )( + ID3D12DeviceConfiguration * This, + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, + _COM_Outptr_ ID3DBlob **ppResult, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, CreateVersionedRootSignatureDeserializer) + HRESULT ( STDMETHODCALLTYPE *CreateVersionedRootSignatureDeserializer )( + ID3D12DeviceConfiguration * This, + _In_reads_bytes_(Size) const void *pBlob, + SIZE_T Size, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer); + + END_INTERFACE + } ID3D12DeviceConfigurationVtbl; + + interface ID3D12DeviceConfiguration + { + CONST_VTBL struct ID3D12DeviceConfigurationVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceConfiguration_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceConfiguration_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceConfiguration_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + +#if !defined(_WIN32) + +#define ID3D12DeviceConfiguration_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12DeviceConfiguration_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#define ID3D12DeviceConfiguration_GetEnabledExperimentalFeatures(This,pGuids,NumGuids) \ + ( (This)->lpVtbl -> GetEnabledExperimentalFeatures(This,pGuids,NumGuids) ) + +#define ID3D12DeviceConfiguration_SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) \ + ( (This)->lpVtbl -> SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) ) + +#define ID3D12DeviceConfiguration_CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) \ + ( (This)->lpVtbl -> CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceConfiguration_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DeviceConfiguration1_INTERFACE_DEFINED__ +#define __ID3D12DeviceConfiguration1_INTERFACE_DEFINED__ + +/* interface ID3D12DeviceConfiguration1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DeviceConfiguration1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("ed342442-6343-4e16-bb82-a3a577874e56") + ID3D12DeviceConfiguration1 : public ID3D12DeviceConfiguration + { + public: + virtual HRESULT STDMETHODCALLTYPE CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary( + _In_reads_bytes_(Size) const void *pLibraryBlob, + SIZE_T Size, + LPCWSTR RootSignatureSubobjectName, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DeviceConfiguration1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DeviceConfiguration1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DeviceConfiguration1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DeviceConfiguration1 * This); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetDesc) +#if !defined(_WIN32) + D3D12_DEVICE_CONFIGURATION_DESC ( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration1 * This); + +#else + D3D12_DEVICE_CONFIGURATION_DESC *( STDMETHODCALLTYPE *GetDesc )( + ID3D12DeviceConfiguration1 * This, + D3D12_DEVICE_CONFIGURATION_DESC * RetVal); + +#endif + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, GetEnabledExperimentalFeatures) + HRESULT ( STDMETHODCALLTYPE *GetEnabledExperimentalFeatures )( + ID3D12DeviceConfiguration1 * This, + _Out_writes_(NumGuids) GUID *pGuids, + UINT NumGuids); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, SerializeVersionedRootSignature) + HRESULT ( STDMETHODCALLTYPE *SerializeVersionedRootSignature )( + ID3D12DeviceConfiguration1 * This, + _In_ const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *pDesc, + _COM_Outptr_ ID3DBlob **ppResult, + _Always_(_Outptr_opt_result_maybenull_) ID3DBlob **ppError); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration, CreateVersionedRootSignatureDeserializer) + HRESULT ( STDMETHODCALLTYPE *CreateVersionedRootSignatureDeserializer )( + ID3D12DeviceConfiguration1 * This, + _In_reads_bytes_(Size) const void *pBlob, + SIZE_T Size, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer); + + DECLSPEC_XFGVIRT(ID3D12DeviceConfiguration1, CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary) + HRESULT ( STDMETHODCALLTYPE *CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary )( + ID3D12DeviceConfiguration1 * This, + _In_reads_bytes_(Size) const void *pLibraryBlob, + SIZE_T Size, + LPCWSTR RootSignatureSubobjectName, + REFIID riid, + _COM_Outptr_ void **ppvDeserializer); + + END_INTERFACE + } ID3D12DeviceConfiguration1Vtbl; + + interface ID3D12DeviceConfiguration1 + { + CONST_VTBL struct ID3D12DeviceConfiguration1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DeviceConfiguration1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DeviceConfiguration1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DeviceConfiguration1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + +#if !defined(_WIN32) + +#define ID3D12DeviceConfiguration1_GetDesc(This) \ + ( (This)->lpVtbl -> GetDesc(This) ) +#else +#define ID3D12DeviceConfiguration1_GetDesc(This,RetVal) \ + ( (This)->lpVtbl -> GetDesc(This,RetVal) ) +#endif + +#define ID3D12DeviceConfiguration1_GetEnabledExperimentalFeatures(This,pGuids,NumGuids) \ + ( (This)->lpVtbl -> GetEnabledExperimentalFeatures(This,pGuids,NumGuids) ) + +#define ID3D12DeviceConfiguration1_SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) \ + ( (This)->lpVtbl -> SerializeVersionedRootSignature(This,pDesc,ppResult,ppError) ) + +#define ID3D12DeviceConfiguration1_CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) \ + ( (This)->lpVtbl -> CreateVersionedRootSignatureDeserializer(This,pBlob,Size,riid,ppvDeserializer) ) + + +#define ID3D12DeviceConfiguration1_CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary(This,pLibraryBlob,Size,RootSignatureSubobjectName,riid,ppvDeserializer) \ + ( (This)->lpVtbl -> CreateVersionedRootSignatureDeserializerFromSubobjectInLibrary(This,pLibraryBlob,Size,RootSignatureSubobjectName,riid,ppvDeserializer) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DeviceConfiguration1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0067 */ +/* [local] */ + +typedef +enum D3D12_AXIS_SHADING_RATE + { + D3D12_AXIS_SHADING_RATE_1X = 0, + D3D12_AXIS_SHADING_RATE_2X = 0x1, + D3D12_AXIS_SHADING_RATE_4X = 0x2 + } D3D12_AXIS_SHADING_RATE; + +#define D3D12_SHADING_RATE_X_AXIS_SHIFT 2 +#define D3D12_SHADING_RATE_VALID_MASK 3 +#define D3D12_MAKE_COARSE_SHADING_RATE(x,y) ((x) << D3D12_SHADING_RATE_X_AXIS_SHIFT | (y)) +#define D3D12_GET_COARSE_SHADING_RATE_X_AXIS(x) (((x) >> D3D12_SHADING_RATE_X_AXIS_SHIFT) & D3D12_SHADING_RATE_VALID_MASK) +#define D3D12_GET_COARSE_SHADING_RATE_Y_AXIS(y) ((y) & D3D12_SHADING_RATE_VALID_MASK) +typedef +enum D3D12_SHADING_RATE + { + D3D12_SHADING_RATE_1X1 = 0, + D3D12_SHADING_RATE_1X2 = 0x1, + D3D12_SHADING_RATE_2X1 = 0x4, + D3D12_SHADING_RATE_2X2 = 0x5, + D3D12_SHADING_RATE_2X4 = 0x6, + D3D12_SHADING_RATE_4X2 = 0x9, + D3D12_SHADING_RATE_4X4 = 0xa + } D3D12_SHADING_RATE; + +typedef +enum D3D12_SHADING_RATE_COMBINER + { + D3D12_SHADING_RATE_COMBINER_PASSTHROUGH = 0, + D3D12_SHADING_RATE_COMBINER_OVERRIDE = 1, + D3D12_SHADING_RATE_COMBINER_MIN = 2, + D3D12_SHADING_RATE_COMBINER_MAX = 3, + D3D12_SHADING_RATE_COMBINER_SUM = 4 + } D3D12_SHADING_RATE_COMBINER; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0067_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0067_v0_0_s_ifspec; + +#ifndef __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList5 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList5; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("55050859-4024-474c-87f5-6472eaee44ea") + ID3D12GraphicsCommandList5 : public ID3D12GraphicsCommandList4 + { + public: + virtual void STDMETHODCALLTYPE RSSetShadingRate( + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners) = 0; + + virtual void STDMETHODCALLTYPE RSSetShadingRateImage( + _In_opt_ ID3D12Resource *shadingRateImage) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList5Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList5 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList5 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList5 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList5 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList5 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList5 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList5 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList5 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList5 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList5 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList5 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList5 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList5 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList5 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList5 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList5 * This, + _In_ ID3D12StateObject *pStateObject); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList5 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) + void ( STDMETHODCALLTYPE *RSSetShadingRate )( + ID3D12GraphicsCommandList5 * This, + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) + void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( + ID3D12GraphicsCommandList5 * This, + _In_opt_ ID3D12Resource *shadingRateImage); + + END_INTERFACE + } ID3D12GraphicsCommandList5Vtbl; + + interface ID3D12GraphicsCommandList5 + { + CONST_VTBL struct ID3D12GraphicsCommandList5Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList5_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList5_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList5_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList5_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList5_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList5_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList5_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList5_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList5_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList5_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList5_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList5_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList5_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList5_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList5_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList5_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList5_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList5_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList5_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList5_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList5_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList5_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList5_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList5_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList5_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList5_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList5_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList5_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList5_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList5_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList5_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList5_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList5_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList5_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList5_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList5_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList5_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList5_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList5_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList5_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList5_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList5_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList5_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList5_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList5_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList5_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList5_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList5_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList5_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList5_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList5_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList5_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList5_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList5_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + + +#define ID3D12GraphicsCommandList5_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) + +#define ID3D12GraphicsCommandList5_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) + +#define ID3D12GraphicsCommandList5_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList5_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList5_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) + +#define ID3D12GraphicsCommandList5_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) + +#define ID3D12GraphicsCommandList5_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) + +#define ID3D12GraphicsCommandList5_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) + +#define ID3D12GraphicsCommandList5_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) + + +#define ID3D12GraphicsCommandList5_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) + +#define ID3D12GraphicsCommandList5_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList5_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0068 */ +/* [local] */ + +typedef struct D3D12_DISPATCH_MESH_ARGUMENTS + { + UINT ThreadGroupCountX; + UINT ThreadGroupCountY; + UINT ThreadGroupCountZ; + } D3D12_DISPATCH_MESH_ARGUMENTS; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0068_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0068_v0_0_s_ifspec; + +#ifndef __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList6 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList6; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("c3827890-e548-4cfa-96cf-5689a9370f80") + ID3D12GraphicsCommandList6 : public ID3D12GraphicsCommandList5 + { + public: + virtual void STDMETHODCALLTYPE DispatchMesh( + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList6Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList6 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList6 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList6 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList6 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList6 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList6 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList6 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList6 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList6 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList6 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList6 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList6 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList6 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList6 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList6 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList6 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList6 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList6 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList6 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList6 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList6 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList6 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList6 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList6 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList6 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList6 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList6 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList6 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList6 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList6 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList6 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList6 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList6 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList6 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList6 * This, + _In_ ID3D12StateObject *pStateObject); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList6 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) + void ( STDMETHODCALLTYPE *RSSetShadingRate )( + ID3D12GraphicsCommandList6 * This, + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) + void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( + ID3D12GraphicsCommandList6 * This, + _In_opt_ ID3D12Resource *shadingRateImage); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) + void ( STDMETHODCALLTYPE *DispatchMesh )( + ID3D12GraphicsCommandList6 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + END_INTERFACE + } ID3D12GraphicsCommandList6Vtbl; + + interface ID3D12GraphicsCommandList6 + { + CONST_VTBL struct ID3D12GraphicsCommandList6Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList6_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList6_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList6_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList6_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList6_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList6_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList6_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList6_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList6_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList6_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList6_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList6_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList6_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList6_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList6_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList6_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList6_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList6_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList6_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList6_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList6_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList6_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList6_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList6_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList6_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList6_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList6_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList6_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList6_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList6_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList6_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList6_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList6_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList6_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList6_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList6_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList6_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList6_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList6_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList6_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList6_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList6_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList6_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList6_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList6_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList6_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList6_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList6_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList6_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList6_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList6_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList6_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList6_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList6_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList6_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList6_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList6_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList6_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList6_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList6_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList6_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList6_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList6_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList6_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + + +#define ID3D12GraphicsCommandList6_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) + +#define ID3D12GraphicsCommandList6_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) + +#define ID3D12GraphicsCommandList6_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList6_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList6_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) + +#define ID3D12GraphicsCommandList6_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) + +#define ID3D12GraphicsCommandList6_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) + +#define ID3D12GraphicsCommandList6_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) + +#define ID3D12GraphicsCommandList6_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) + + +#define ID3D12GraphicsCommandList6_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) + +#define ID3D12GraphicsCommandList6_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) + + +#define ID3D12GraphicsCommandList6_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList6_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList7 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList7; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("dd171223-8b61-4769-90e3-160ccde4e2c1") + ID3D12GraphicsCommandList7 : public ID3D12GraphicsCommandList6 + { + public: + virtual void STDMETHODCALLTYPE Barrier( + UINT32 NumBarrierGroups, + _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList7Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList7 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList7 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList7 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList7 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList7 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList7 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList7 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList7 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList7 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList7 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList7 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList7 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList7 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList7 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList7 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList7 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList7 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList7 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList7 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList7 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList7 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList7 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList7 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList7 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList7 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList7 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList7 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList7 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList7 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList7 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList7 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList7 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList7 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList7 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList7 * This, + _In_ ID3D12StateObject *pStateObject); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList7 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) + void ( STDMETHODCALLTYPE *RSSetShadingRate )( + ID3D12GraphicsCommandList7 * This, + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) + void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( + ID3D12GraphicsCommandList7 * This, + _In_opt_ ID3D12Resource *shadingRateImage); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) + void ( STDMETHODCALLTYPE *DispatchMesh )( + ID3D12GraphicsCommandList7 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) + void ( STDMETHODCALLTYPE *Barrier )( + ID3D12GraphicsCommandList7 * This, + UINT32 NumBarrierGroups, + _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); + + END_INTERFACE + } ID3D12GraphicsCommandList7Vtbl; + + interface ID3D12GraphicsCommandList7 + { + CONST_VTBL struct ID3D12GraphicsCommandList7Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList7_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList7_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList7_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList7_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList7_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList7_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList7_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList7_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList7_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList7_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList7_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList7_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList7_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList7_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList7_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList7_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList7_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList7_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList7_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList7_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList7_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList7_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList7_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList7_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList7_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList7_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList7_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList7_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList7_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList7_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList7_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList7_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList7_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList7_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList7_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList7_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList7_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList7_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList7_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList7_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList7_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList7_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList7_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList7_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList7_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList7_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList7_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList7_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList7_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList7_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList7_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList7_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList7_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList7_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList7_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList7_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList7_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList7_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList7_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList7_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList7_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList7_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList7_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList7_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + + +#define ID3D12GraphicsCommandList7_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) + +#define ID3D12GraphicsCommandList7_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) + +#define ID3D12GraphicsCommandList7_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList7_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList7_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) + +#define ID3D12GraphicsCommandList7_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) + +#define ID3D12GraphicsCommandList7_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) + +#define ID3D12GraphicsCommandList7_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) + +#define ID3D12GraphicsCommandList7_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) + + +#define ID3D12GraphicsCommandList7_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) + +#define ID3D12GraphicsCommandList7_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) + + +#define ID3D12GraphicsCommandList7_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + + +#define ID3D12GraphicsCommandList7_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList7_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList8 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList8; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("ee936ef9-599d-4d28-938e-23c4ad05ce51") + ID3D12GraphicsCommandList8 : public ID3D12GraphicsCommandList7 + { + public: + virtual void STDMETHODCALLTYPE OMSetFrontAndBackStencilRef( + _In_ UINT FrontStencilRef, + _In_ UINT BackStencilRef) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList8Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList8 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList8 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList8 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList8 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList8 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList8 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList8 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList8 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList8 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList8 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList8 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList8 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList8 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList8 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList8 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList8 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList8 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList8 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList8 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList8 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList8 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList8 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList8 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList8 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList8 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList8 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList8 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList8 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList8 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList8 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList8 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList8 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList8 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList8 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList8 * This, + _In_ ID3D12StateObject *pStateObject); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList8 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) + void ( STDMETHODCALLTYPE *RSSetShadingRate )( + ID3D12GraphicsCommandList8 * This, + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) + void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( + ID3D12GraphicsCommandList8 * This, + _In_opt_ ID3D12Resource *shadingRateImage); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) + void ( STDMETHODCALLTYPE *DispatchMesh )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) + void ( STDMETHODCALLTYPE *Barrier )( + ID3D12GraphicsCommandList8 * This, + UINT32 NumBarrierGroups, + _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList8, OMSetFrontAndBackStencilRef) + void ( STDMETHODCALLTYPE *OMSetFrontAndBackStencilRef )( + ID3D12GraphicsCommandList8 * This, + _In_ UINT FrontStencilRef, + _In_ UINT BackStencilRef); + + END_INTERFACE + } ID3D12GraphicsCommandList8Vtbl; + + interface ID3D12GraphicsCommandList8 + { + CONST_VTBL struct ID3D12GraphicsCommandList8Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList8_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList8_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList8_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList8_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList8_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList8_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList8_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList8_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList8_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList8_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList8_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList8_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList8_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList8_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList8_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList8_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList8_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList8_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList8_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList8_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList8_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList8_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList8_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList8_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList8_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList8_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList8_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList8_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList8_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList8_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList8_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList8_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList8_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList8_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList8_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList8_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList8_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList8_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList8_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList8_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList8_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList8_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList8_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList8_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList8_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList8_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList8_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList8_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList8_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList8_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList8_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList8_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList8_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList8_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList8_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList8_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList8_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList8_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList8_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList8_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList8_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList8_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList8_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList8_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + + +#define ID3D12GraphicsCommandList8_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) + +#define ID3D12GraphicsCommandList8_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) + +#define ID3D12GraphicsCommandList8_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList8_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList8_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) + +#define ID3D12GraphicsCommandList8_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) + +#define ID3D12GraphicsCommandList8_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) + +#define ID3D12GraphicsCommandList8_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) + +#define ID3D12GraphicsCommandList8_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) + + +#define ID3D12GraphicsCommandList8_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) + +#define ID3D12GraphicsCommandList8_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) + + +#define ID3D12GraphicsCommandList8_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + + +#define ID3D12GraphicsCommandList8_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) + + +#define ID3D12GraphicsCommandList8_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ + ( (This)->lpVtbl -> OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList8_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList9 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList9; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("34ed2808-ffe6-4c2b-b11a-cabd2b0c59e1") + ID3D12GraphicsCommandList9 : public ID3D12GraphicsCommandList8 + { + public: + virtual void STDMETHODCALLTYPE RSSetDepthBias( + _In_ FLOAT DepthBias, + _In_ FLOAT DepthBiasClamp, + _In_ FLOAT SlopeScaledDepthBias) = 0; + + virtual void STDMETHODCALLTYPE IASetIndexBufferStripCutValue( + _In_ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList9Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList9 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList9 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList9 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList9 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList9 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList9 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList9 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList9 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList9 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList9 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList9 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList9 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList9 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList9 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList9 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList9 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList9 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList9 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList9 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList9 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList9 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList9 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList9 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList9 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList9 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList9 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList9 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList9 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList9 * This, + _In_ ID3D12StateObject *pStateObject); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList9 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) + void ( STDMETHODCALLTYPE *RSSetShadingRate )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) + void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( + ID3D12GraphicsCommandList9 * This, + _In_opt_ ID3D12Resource *shadingRateImage); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) + void ( STDMETHODCALLTYPE *DispatchMesh )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) + void ( STDMETHODCALLTYPE *Barrier )( + ID3D12GraphicsCommandList9 * This, + UINT32 NumBarrierGroups, + _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList8, OMSetFrontAndBackStencilRef) + void ( STDMETHODCALLTYPE *OMSetFrontAndBackStencilRef )( + ID3D12GraphicsCommandList9 * This, + _In_ UINT FrontStencilRef, + _In_ UINT BackStencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, RSSetDepthBias) + void ( STDMETHODCALLTYPE *RSSetDepthBias )( + ID3D12GraphicsCommandList9 * This, + _In_ FLOAT DepthBias, + _In_ FLOAT DepthBiasClamp, + _In_ FLOAT SlopeScaledDepthBias); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, IASetIndexBufferStripCutValue) + void ( STDMETHODCALLTYPE *IASetIndexBufferStripCutValue )( + ID3D12GraphicsCommandList9 * This, + _In_ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue); + + END_INTERFACE + } ID3D12GraphicsCommandList9Vtbl; + + interface ID3D12GraphicsCommandList9 + { + CONST_VTBL struct ID3D12GraphicsCommandList9Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList9_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList9_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList9_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList9_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList9_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList9_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList9_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList9_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList9_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList9_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList9_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList9_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList9_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList9_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList9_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList9_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList9_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList9_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList9_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList9_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList9_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList9_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList9_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList9_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList9_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList9_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList9_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList9_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList9_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList9_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList9_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList9_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList9_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList9_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList9_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList9_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList9_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList9_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList9_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList9_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList9_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList9_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList9_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList9_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList9_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList9_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList9_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList9_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList9_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList9_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList9_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList9_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList9_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList9_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList9_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList9_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList9_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList9_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList9_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList9_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList9_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList9_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList9_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList9_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + + +#define ID3D12GraphicsCommandList9_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) + +#define ID3D12GraphicsCommandList9_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) + +#define ID3D12GraphicsCommandList9_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList9_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList9_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) + +#define ID3D12GraphicsCommandList9_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) + +#define ID3D12GraphicsCommandList9_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) + +#define ID3D12GraphicsCommandList9_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) + +#define ID3D12GraphicsCommandList9_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) + + +#define ID3D12GraphicsCommandList9_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) + +#define ID3D12GraphicsCommandList9_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) + + +#define ID3D12GraphicsCommandList9_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + + +#define ID3D12GraphicsCommandList9_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) + + +#define ID3D12GraphicsCommandList9_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ + ( (This)->lpVtbl -> OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) ) + + +#define ID3D12GraphicsCommandList9_RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) \ + ( (This)->lpVtbl -> RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) ) + +#define ID3D12GraphicsCommandList9_IASetIndexBufferStripCutValue(This,IBStripCutValue) \ + ( (This)->lpVtbl -> IASetIndexBufferStripCutValue(This,IBStripCutValue) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList9_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__ +#define __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__ + +/* interface ID3D12GraphicsCommandList10 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GraphicsCommandList10; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("7013c015-d161-4b63-a08c-238552dd8acc") + ID3D12GraphicsCommandList10 : public ID3D12GraphicsCommandList9 + { + public: + virtual void STDMETHODCALLTYPE SetProgram( + _In_ const D3D12_SET_PROGRAM_DESC *pDesc) = 0; + + virtual void STDMETHODCALLTYPE DispatchGraph( + _In_ const D3D12_DISPATCH_GRAPH_DESC *pDesc) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GraphicsCommandList10Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GraphicsCommandList10 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GraphicsCommandList10 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GraphicsCommandList10 * This); + + DECLSPEC_XFGVIRT(ID3D12Object, GetPrivateData) + HRESULT ( STDMETHODCALLTYPE *GetPrivateData )( + ID3D12GraphicsCommandList10 * This, + _In_ REFGUID guid, + _Inout_ UINT *pDataSize, + _Out_writes_bytes_opt_( *pDataSize ) void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateData) + HRESULT ( STDMETHODCALLTYPE *SetPrivateData )( + ID3D12GraphicsCommandList10 * This, + _In_ REFGUID guid, + _In_ UINT DataSize, + _In_reads_bytes_opt_( DataSize ) const void *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetPrivateDataInterface) + HRESULT ( STDMETHODCALLTYPE *SetPrivateDataInterface )( + ID3D12GraphicsCommandList10 * This, + _In_ REFGUID guid, + _In_opt_ const IUnknown *pData); + + DECLSPEC_XFGVIRT(ID3D12Object, SetName) + HRESULT ( STDMETHODCALLTYPE *SetName )( + ID3D12GraphicsCommandList10 * This, + _In_z_ LPCWSTR Name); + + DECLSPEC_XFGVIRT(ID3D12DeviceChild, GetDevice) + HRESULT ( STDMETHODCALLTYPE *GetDevice )( + ID3D12GraphicsCommandList10 * This, + REFIID riid, + _COM_Outptr_opt_ void **ppvDevice); + + DECLSPEC_XFGVIRT(ID3D12CommandList, GetType) + D3D12_COMMAND_LIST_TYPE ( STDMETHODCALLTYPE *GetType )( + ID3D12GraphicsCommandList10 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Close) + HRESULT ( STDMETHODCALLTYPE *Close )( + ID3D12GraphicsCommandList10 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Reset) + HRESULT ( STDMETHODCALLTYPE *Reset )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12CommandAllocator *pAllocator, + _In_opt_ ID3D12PipelineState *pInitialState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearState) + void ( STDMETHODCALLTYPE *ClearState )( + ID3D12GraphicsCommandList10 * This, + _In_opt_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawInstanced) + void ( STDMETHODCALLTYPE *DrawInstanced )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT VertexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DrawIndexedInstanced) + void ( STDMETHODCALLTYPE *DrawIndexedInstanced )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT IndexCountPerInstance, + _In_ UINT InstanceCount, + _In_ UINT StartIndexLocation, + _In_ INT BaseVertexLocation, + _In_ UINT StartInstanceLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, Dispatch) + void ( STDMETHODCALLTYPE *Dispatch )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyBufferRegion) + void ( STDMETHODCALLTYPE *CopyBufferRegion )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT64 NumBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTextureRegion) + void ( STDMETHODCALLTYPE *CopyTextureRegion )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pDst, + UINT DstX, + UINT DstY, + UINT DstZ, + _In_ const D3D12_TEXTURE_COPY_LOCATION *pSrc, + _In_opt_ const D3D12_BOX *pSrcBox); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyResource) + void ( STDMETHODCALLTYPE *CopyResource )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pDstResource, + _In_ ID3D12Resource *pSrcResource); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, CopyTiles) + void ( STDMETHODCALLTYPE *CopyTiles )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pTiledResource, + _In_ const D3D12_TILED_RESOURCE_COORDINATE *pTileRegionStartCoordinate, + _In_ const D3D12_TILE_REGION_SIZE *pTileRegionSize, + _In_ ID3D12Resource *pBuffer, + UINT64 BufferStartOffsetInBytes, + D3D12_TILE_COPY_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveSubresource) + void ( STDMETHODCALLTYPE *ResolveSubresource )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_ DXGI_FORMAT Format); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetPrimitiveTopology) + void ( STDMETHODCALLTYPE *IASetPrimitiveTopology )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_PRIMITIVE_TOPOLOGY PrimitiveTopology); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetViewports) + void ( STDMETHODCALLTYPE *RSSetViewports )( + ID3D12GraphicsCommandList10 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumViewports, + _In_reads_( NumViewports) const D3D12_VIEWPORT *pViewports); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, RSSetScissorRects) + void ( STDMETHODCALLTYPE *RSSetScissorRects )( + ID3D12GraphicsCommandList10 * This, + _In_range_(0, D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE) UINT NumRects, + _In_reads_( NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetBlendFactor) + void ( STDMETHODCALLTYPE *OMSetBlendFactor )( + ID3D12GraphicsCommandList10 * This, + _In_reads_opt_(4) const FLOAT BlendFactor[ 4 ]); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetStencilRef) + void ( STDMETHODCALLTYPE *OMSetStencilRef )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT StencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPipelineState) + void ( STDMETHODCALLTYPE *SetPipelineState )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12PipelineState *pPipelineState); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResourceBarrier) + void ( STDMETHODCALLTYPE *ResourceBarrier )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT NumBarriers, + _In_reads_(NumBarriers) const D3D12_RESOURCE_BARRIER *pBarriers); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteBundle) + void ( STDMETHODCALLTYPE *ExecuteBundle )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12GraphicsCommandList *pCommandList); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetDescriptorHeaps) + void ( STDMETHODCALLTYPE *SetDescriptorHeaps )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT NumDescriptorHeaps, + _In_reads_(NumDescriptorHeaps) ID3D12DescriptorHeap *const *ppDescriptorHeaps); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootSignature) + void ( STDMETHODCALLTYPE *SetComputeRootSignature )( + ID3D12GraphicsCommandList10 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootSignature) + void ( STDMETHODCALLTYPE *SetGraphicsRootSignature )( + ID3D12GraphicsCommandList10 * This, + _In_opt_ ID3D12RootSignature *pRootSignature); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetComputeRootDescriptorTable )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootDescriptorTable) + void ( STDMETHODCALLTYPE *SetGraphicsRootDescriptorTable )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstant )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstant) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstant )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ UINT SrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetComputeRoot32BitConstants )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRoot32BitConstants) + void ( STDMETHODCALLTYPE *SetGraphicsRoot32BitConstants )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ UINT Num32BitValuesToSet, + _In_reads_(Num32BitValuesToSet*sizeof(UINT)) const void *pSrcData, + _In_ UINT DestOffsetIn32BitValues); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetComputeRootConstantBufferView )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootConstantBufferView) + void ( STDMETHODCALLTYPE *SetGraphicsRootConstantBufferView )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetComputeRootShaderResourceView )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootShaderResourceView) + void ( STDMETHODCALLTYPE *SetGraphicsRootShaderResourceView )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetComputeRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetComputeRootUnorderedAccessView )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetGraphicsRootUnorderedAccessView) + void ( STDMETHODCALLTYPE *SetGraphicsRootUnorderedAccessView )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT RootParameterIndex, + _In_ D3D12_GPU_VIRTUAL_ADDRESS BufferLocation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetIndexBuffer) + void ( STDMETHODCALLTYPE *IASetIndexBuffer )( + ID3D12GraphicsCommandList10 * This, + _In_opt_ const D3D12_INDEX_BUFFER_VIEW *pView); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, IASetVertexBuffers) + void ( STDMETHODCALLTYPE *IASetVertexBuffers )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_VERTEX_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SOSetTargets) + void ( STDMETHODCALLTYPE *SOSetTargets )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT StartSlot, + _In_ UINT NumViews, + _In_reads_opt_(NumViews) const D3D12_STREAM_OUTPUT_BUFFER_VIEW *pViews); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, OMSetRenderTargets) + void ( STDMETHODCALLTYPE *OMSetRenderTargets )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT NumRenderTargetDescriptors, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pRenderTargetDescriptors, + _In_ BOOL RTsSingleHandleToDescriptorRange, + _In_opt_ const D3D12_CPU_DESCRIPTOR_HANDLE *pDepthStencilDescriptor); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearDepthStencilView) + void ( STDMETHODCALLTYPE *ClearDepthStencilView )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE DepthStencilView, + _In_ D3D12_CLEAR_FLAGS ClearFlags, + _In_ FLOAT Depth, + _In_ UINT8 Stencil, + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearRenderTargetView) + void ( STDMETHODCALLTYPE *ClearRenderTargetView )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE RenderTargetView, + _In_ const FLOAT ColorRGBA[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewUint) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewUint )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const UINT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ClearUnorderedAccessViewFloat) + void ( STDMETHODCALLTYPE *ClearUnorderedAccessViewFloat )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_GPU_DESCRIPTOR_HANDLE ViewGPUHandleInCurrentHeap, + _In_ D3D12_CPU_DESCRIPTOR_HANDLE ViewCPUHandle, + _In_ ID3D12Resource *pResource, + _In_ const FLOAT Values[ 4 ], + _In_ UINT NumRects, + _In_reads_(NumRects) const D3D12_RECT *pRects); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, DiscardResource) + void ( STDMETHODCALLTYPE *DiscardResource )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pResource, + _In_opt_ const D3D12_DISCARD_REGION *pRegion); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginQuery) + void ( STDMETHODCALLTYPE *BeginQuery )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndQuery) + void ( STDMETHODCALLTYPE *EndQuery )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT Index); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ResolveQueryData) + void ( STDMETHODCALLTYPE *ResolveQueryData )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12QueryHeap *pQueryHeap, + _In_ D3D12_QUERY_TYPE Type, + _In_ UINT StartIndex, + _In_ UINT NumQueries, + _In_ ID3D12Resource *pDestinationBuffer, + _In_ UINT64 AlignedDestinationBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetPredication) + void ( STDMETHODCALLTYPE *SetPredication )( + ID3D12GraphicsCommandList10 * This, + _In_opt_ ID3D12Resource *pBuffer, + _In_ UINT64 AlignedBufferOffset, + _In_ D3D12_PREDICATION_OP Operation); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, SetMarker) + void ( STDMETHODCALLTYPE *SetMarker )( + ID3D12GraphicsCommandList10 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, BeginEvent) + void ( STDMETHODCALLTYPE *BeginEvent )( + ID3D12GraphicsCommandList10 * This, + UINT Metadata, + _In_reads_bytes_opt_(Size) const void *pData, + UINT Size); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, EndEvent) + void ( STDMETHODCALLTYPE *EndEvent )( + ID3D12GraphicsCommandList10 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList, ExecuteIndirect) + void ( STDMETHODCALLTYPE *ExecuteIndirect )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12CommandSignature *pCommandSignature, + _In_ UINT MaxCommandCount, + _In_ ID3D12Resource *pArgumentBuffer, + _In_ UINT64 ArgumentBufferOffset, + _In_opt_ ID3D12Resource *pCountBuffer, + _In_ UINT64 CountBufferOffset); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, AtomicCopyBufferUINT64) + void ( STDMETHODCALLTYPE *AtomicCopyBufferUINT64 )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pDstBuffer, + UINT64 DstOffset, + _In_ ID3D12Resource *pSrcBuffer, + UINT64 SrcOffset, + UINT Dependencies, + _In_reads_(Dependencies) ID3D12Resource *const *ppDependentResources, + _In_reads_(Dependencies) const D3D12_SUBRESOURCE_RANGE_UINT64 *pDependentSubresourceRanges); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, OMSetDepthBounds) + void ( STDMETHODCALLTYPE *OMSetDepthBounds )( + ID3D12GraphicsCommandList10 * This, + _In_ FLOAT Min, + _In_ FLOAT Max); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetSamplePositions) + void ( STDMETHODCALLTYPE *SetSamplePositions )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT NumSamplesPerPixel, + _In_ UINT NumPixels, + _In_reads_(NumSamplesPerPixel*NumPixels) D3D12_SAMPLE_POSITION *pSamplePositions); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, ResolveSubresourceRegion) + void ( STDMETHODCALLTYPE *ResolveSubresourceRegion )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12Resource *pDstResource, + _In_ UINT DstSubresource, + _In_ UINT DstX, + _In_ UINT DstY, + _In_ ID3D12Resource *pSrcResource, + _In_ UINT SrcSubresource, + _In_opt_ D3D12_RECT *pSrcRect, + _In_ DXGI_FORMAT Format, + _In_ D3D12_RESOLVE_MODE ResolveMode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList1, SetViewInstanceMask) + void ( STDMETHODCALLTYPE *SetViewInstanceMask )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT Mask); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList2, WriteBufferImmediate) + void ( STDMETHODCALLTYPE *WriteBufferImmediate )( + ID3D12GraphicsCommandList10 * This, + UINT Count, + _In_reads_(Count) const D3D12_WRITEBUFFERIMMEDIATE_PARAMETER *pParams, + _In_reads_opt_(Count) const D3D12_WRITEBUFFERIMMEDIATE_MODE *pModes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList3, SetProtectedResourceSession) + void ( STDMETHODCALLTYPE *SetProtectedResourceSession )( + ID3D12GraphicsCommandList10 * This, + _In_opt_ ID3D12ProtectedResourceSession *pProtectedResourceSession); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BeginRenderPass) + void ( STDMETHODCALLTYPE *BeginRenderPass )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT NumRenderTargets, + _In_reads_opt_(NumRenderTargets) const D3D12_RENDER_PASS_RENDER_TARGET_DESC *pRenderTargets, + _In_opt_ const D3D12_RENDER_PASS_DEPTH_STENCIL_DESC *pDepthStencil, + D3D12_RENDER_PASS_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EndRenderPass) + void ( STDMETHODCALLTYPE *EndRenderPass )( + ID3D12GraphicsCommandList10 * This); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, InitializeMetaCommand) + void ( STDMETHODCALLTYPE *InitializeMetaCommand )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(InitializationParametersDataSizeInBytes) const void *pInitializationParametersData, + _In_ SIZE_T InitializationParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, ExecuteMetaCommand) + void ( STDMETHODCALLTYPE *ExecuteMetaCommand )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12MetaCommand *pMetaCommand, + _In_reads_bytes_opt_(ExecutionParametersDataSizeInBytes) const void *pExecutionParametersData, + _In_ SIZE_T ExecutionParametersDataSizeInBytes); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, BuildRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *BuildRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_DESC *pDesc, + _In_ UINT NumPostbuildInfoDescs, + _In_reads_opt_(NumPostbuildInfoDescs) const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pPostbuildInfoDescs); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, EmitRaytracingAccelerationStructurePostbuildInfo) + void ( STDMETHODCALLTYPE *EmitRaytracingAccelerationStructurePostbuildInfo )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC *pDesc, + _In_ UINT NumSourceAccelerationStructures, + _In_reads_( NumSourceAccelerationStructures ) const D3D12_GPU_VIRTUAL_ADDRESS *pSourceAccelerationStructureData); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, CopyRaytracingAccelerationStructure) + void ( STDMETHODCALLTYPE *CopyRaytracingAccelerationStructure )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_GPU_VIRTUAL_ADDRESS DestAccelerationStructureData, + _In_ D3D12_GPU_VIRTUAL_ADDRESS SourceAccelerationStructureData, + _In_ D3D12_RAYTRACING_ACCELERATION_STRUCTURE_COPY_MODE Mode); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, SetPipelineState1) + void ( STDMETHODCALLTYPE *SetPipelineState1 )( + ID3D12GraphicsCommandList10 * This, + _In_ ID3D12StateObject *pStateObject); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList4, DispatchRays) + void ( STDMETHODCALLTYPE *DispatchRays )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_DISPATCH_RAYS_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRate) + void ( STDMETHODCALLTYPE *RSSetShadingRate )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_SHADING_RATE baseShadingRate, + _In_reads_opt_(D3D12_RS_SET_SHADING_RATE_COMBINER_COUNT) const D3D12_SHADING_RATE_COMBINER *combiners); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList5, RSSetShadingRateImage) + void ( STDMETHODCALLTYPE *RSSetShadingRateImage )( + ID3D12GraphicsCommandList10 * This, + _In_opt_ ID3D12Resource *shadingRateImage); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList6, DispatchMesh) + void ( STDMETHODCALLTYPE *DispatchMesh )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT ThreadGroupCountX, + _In_ UINT ThreadGroupCountY, + _In_ UINT ThreadGroupCountZ); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList7, Barrier) + void ( STDMETHODCALLTYPE *Barrier )( + ID3D12GraphicsCommandList10 * This, + UINT32 NumBarrierGroups, + _In_reads_(NumBarrierGroups) const D3D12_BARRIER_GROUP *pBarrierGroups); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList8, OMSetFrontAndBackStencilRef) + void ( STDMETHODCALLTYPE *OMSetFrontAndBackStencilRef )( + ID3D12GraphicsCommandList10 * This, + _In_ UINT FrontStencilRef, + _In_ UINT BackStencilRef); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, RSSetDepthBias) + void ( STDMETHODCALLTYPE *RSSetDepthBias )( + ID3D12GraphicsCommandList10 * This, + _In_ FLOAT DepthBias, + _In_ FLOAT DepthBiasClamp, + _In_ FLOAT SlopeScaledDepthBias); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList9, IASetIndexBufferStripCutValue) + void ( STDMETHODCALLTYPE *IASetIndexBufferStripCutValue )( + ID3D12GraphicsCommandList10 * This, + _In_ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE IBStripCutValue); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList10, SetProgram) + void ( STDMETHODCALLTYPE *SetProgram )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_SET_PROGRAM_DESC *pDesc); + + DECLSPEC_XFGVIRT(ID3D12GraphicsCommandList10, DispatchGraph) + void ( STDMETHODCALLTYPE *DispatchGraph )( + ID3D12GraphicsCommandList10 * This, + _In_ const D3D12_DISPATCH_GRAPH_DESC *pDesc); + + END_INTERFACE + } ID3D12GraphicsCommandList10Vtbl; + + interface ID3D12GraphicsCommandList10 + { + CONST_VTBL struct ID3D12GraphicsCommandList10Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GraphicsCommandList10_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GraphicsCommandList10_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GraphicsCommandList10_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GraphicsCommandList10_GetPrivateData(This,guid,pDataSize,pData) \ + ( (This)->lpVtbl -> GetPrivateData(This,guid,pDataSize,pData) ) + +#define ID3D12GraphicsCommandList10_SetPrivateData(This,guid,DataSize,pData) \ + ( (This)->lpVtbl -> SetPrivateData(This,guid,DataSize,pData) ) + +#define ID3D12GraphicsCommandList10_SetPrivateDataInterface(This,guid,pData) \ + ( (This)->lpVtbl -> SetPrivateDataInterface(This,guid,pData) ) + +#define ID3D12GraphicsCommandList10_SetName(This,Name) \ + ( (This)->lpVtbl -> SetName(This,Name) ) + + +#define ID3D12GraphicsCommandList10_GetDevice(This,riid,ppvDevice) \ + ( (This)->lpVtbl -> GetDevice(This,riid,ppvDevice) ) + + +#define ID3D12GraphicsCommandList10_GetType(This) \ + ( (This)->lpVtbl -> GetType(This) ) + + +#define ID3D12GraphicsCommandList10_Close(This) \ + ( (This)->lpVtbl -> Close(This) ) + +#define ID3D12GraphicsCommandList10_Reset(This,pAllocator,pInitialState) \ + ( (This)->lpVtbl -> Reset(This,pAllocator,pInitialState) ) + +#define ID3D12GraphicsCommandList10_ClearState(This,pPipelineState) \ + ( (This)->lpVtbl -> ClearState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList10_DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawInstanced(This,VertexCountPerInstance,InstanceCount,StartVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList10_DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) \ + ( (This)->lpVtbl -> DrawIndexedInstanced(This,IndexCountPerInstance,InstanceCount,StartIndexLocation,BaseVertexLocation,StartInstanceLocation) ) + +#define ID3D12GraphicsCommandList10_Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> Dispatch(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + +#define ID3D12GraphicsCommandList10_CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) \ + ( (This)->lpVtbl -> CopyBufferRegion(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,NumBytes) ) + +#define ID3D12GraphicsCommandList10_CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) \ + ( (This)->lpVtbl -> CopyTextureRegion(This,pDst,DstX,DstY,DstZ,pSrc,pSrcBox) ) + +#define ID3D12GraphicsCommandList10_CopyResource(This,pDstResource,pSrcResource) \ + ( (This)->lpVtbl -> CopyResource(This,pDstResource,pSrcResource) ) + +#define ID3D12GraphicsCommandList10_CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) \ + ( (This)->lpVtbl -> CopyTiles(This,pTiledResource,pTileRegionStartCoordinate,pTileRegionSize,pBuffer,BufferStartOffsetInBytes,Flags) ) + +#define ID3D12GraphicsCommandList10_ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) \ + ( (This)->lpVtbl -> ResolveSubresource(This,pDstResource,DstSubresource,pSrcResource,SrcSubresource,Format) ) + +#define ID3D12GraphicsCommandList10_IASetPrimitiveTopology(This,PrimitiveTopology) \ + ( (This)->lpVtbl -> IASetPrimitiveTopology(This,PrimitiveTopology) ) + +#define ID3D12GraphicsCommandList10_RSSetViewports(This,NumViewports,pViewports) \ + ( (This)->lpVtbl -> RSSetViewports(This,NumViewports,pViewports) ) + +#define ID3D12GraphicsCommandList10_RSSetScissorRects(This,NumRects,pRects) \ + ( (This)->lpVtbl -> RSSetScissorRects(This,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList10_OMSetBlendFactor(This,BlendFactor) \ + ( (This)->lpVtbl -> OMSetBlendFactor(This,BlendFactor) ) + +#define ID3D12GraphicsCommandList10_OMSetStencilRef(This,StencilRef) \ + ( (This)->lpVtbl -> OMSetStencilRef(This,StencilRef) ) + +#define ID3D12GraphicsCommandList10_SetPipelineState(This,pPipelineState) \ + ( (This)->lpVtbl -> SetPipelineState(This,pPipelineState) ) + +#define ID3D12GraphicsCommandList10_ResourceBarrier(This,NumBarriers,pBarriers) \ + ( (This)->lpVtbl -> ResourceBarrier(This,NumBarriers,pBarriers) ) + +#define ID3D12GraphicsCommandList10_ExecuteBundle(This,pCommandList) \ + ( (This)->lpVtbl -> ExecuteBundle(This,pCommandList) ) + +#define ID3D12GraphicsCommandList10_SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) \ + ( (This)->lpVtbl -> SetDescriptorHeaps(This,NumDescriptorHeaps,ppDescriptorHeaps) ) + +#define ID3D12GraphicsCommandList10_SetComputeRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetComputeRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList10_SetGraphicsRootSignature(This,pRootSignature) \ + ( (This)->lpVtbl -> SetGraphicsRootSignature(This,pRootSignature) ) + +#define ID3D12GraphicsCommandList10_SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetComputeRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList10_SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) \ + ( (This)->lpVtbl -> SetGraphicsRootDescriptorTable(This,RootParameterIndex,BaseDescriptor) ) + +#define ID3D12GraphicsCommandList10_SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList10_SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstant(This,RootParameterIndex,SrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList10_SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetComputeRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList10_SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) \ + ( (This)->lpVtbl -> SetGraphicsRoot32BitConstants(This,RootParameterIndex,Num32BitValuesToSet,pSrcData,DestOffsetIn32BitValues) ) + +#define ID3D12GraphicsCommandList10_SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList10_SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootConstantBufferView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList10_SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList10_SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootShaderResourceView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList10_SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetComputeRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList10_SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) \ + ( (This)->lpVtbl -> SetGraphicsRootUnorderedAccessView(This,RootParameterIndex,BufferLocation) ) + +#define ID3D12GraphicsCommandList10_IASetIndexBuffer(This,pView) \ + ( (This)->lpVtbl -> IASetIndexBuffer(This,pView) ) + +#define ID3D12GraphicsCommandList10_IASetVertexBuffers(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> IASetVertexBuffers(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList10_SOSetTargets(This,StartSlot,NumViews,pViews) \ + ( (This)->lpVtbl -> SOSetTargets(This,StartSlot,NumViews,pViews) ) + +#define ID3D12GraphicsCommandList10_OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) \ + ( (This)->lpVtbl -> OMSetRenderTargets(This,NumRenderTargetDescriptors,pRenderTargetDescriptors,RTsSingleHandleToDescriptorRange,pDepthStencilDescriptor) ) + +#define ID3D12GraphicsCommandList10_ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearDepthStencilView(This,DepthStencilView,ClearFlags,Depth,Stencil,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList10_ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearRenderTargetView(This,RenderTargetView,ColorRGBA,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList10_ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewUint(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList10_ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) \ + ( (This)->lpVtbl -> ClearUnorderedAccessViewFloat(This,ViewGPUHandleInCurrentHeap,ViewCPUHandle,pResource,Values,NumRects,pRects) ) + +#define ID3D12GraphicsCommandList10_DiscardResource(This,pResource,pRegion) \ + ( (This)->lpVtbl -> DiscardResource(This,pResource,pRegion) ) + +#define ID3D12GraphicsCommandList10_BeginQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> BeginQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList10_EndQuery(This,pQueryHeap,Type,Index) \ + ( (This)->lpVtbl -> EndQuery(This,pQueryHeap,Type,Index) ) + +#define ID3D12GraphicsCommandList10_ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) \ + ( (This)->lpVtbl -> ResolveQueryData(This,pQueryHeap,Type,StartIndex,NumQueries,pDestinationBuffer,AlignedDestinationBufferOffset) ) + +#define ID3D12GraphicsCommandList10_SetPredication(This,pBuffer,AlignedBufferOffset,Operation) \ + ( (This)->lpVtbl -> SetPredication(This,pBuffer,AlignedBufferOffset,Operation) ) + +#define ID3D12GraphicsCommandList10_SetMarker(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> SetMarker(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList10_BeginEvent(This,Metadata,pData,Size) \ + ( (This)->lpVtbl -> BeginEvent(This,Metadata,pData,Size) ) + +#define ID3D12GraphicsCommandList10_EndEvent(This) \ + ( (This)->lpVtbl -> EndEvent(This) ) + +#define ID3D12GraphicsCommandList10_ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) \ + ( (This)->lpVtbl -> ExecuteIndirect(This,pCommandSignature,MaxCommandCount,pArgumentBuffer,ArgumentBufferOffset,pCountBuffer,CountBufferOffset) ) + + +#define ID3D12GraphicsCommandList10_AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList10_AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) \ + ( (This)->lpVtbl -> AtomicCopyBufferUINT64(This,pDstBuffer,DstOffset,pSrcBuffer,SrcOffset,Dependencies,ppDependentResources,pDependentSubresourceRanges) ) + +#define ID3D12GraphicsCommandList10_OMSetDepthBounds(This,Min,Max) \ + ( (This)->lpVtbl -> OMSetDepthBounds(This,Min,Max) ) + +#define ID3D12GraphicsCommandList10_SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) \ + ( (This)->lpVtbl -> SetSamplePositions(This,NumSamplesPerPixel,NumPixels,pSamplePositions) ) + +#define ID3D12GraphicsCommandList10_ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) \ + ( (This)->lpVtbl -> ResolveSubresourceRegion(This,pDstResource,DstSubresource,DstX,DstY,pSrcResource,SrcSubresource,pSrcRect,Format,ResolveMode) ) + +#define ID3D12GraphicsCommandList10_SetViewInstanceMask(This,Mask) \ + ( (This)->lpVtbl -> SetViewInstanceMask(This,Mask) ) + + +#define ID3D12GraphicsCommandList10_WriteBufferImmediate(This,Count,pParams,pModes) \ + ( (This)->lpVtbl -> WriteBufferImmediate(This,Count,pParams,pModes) ) + + +#define ID3D12GraphicsCommandList10_SetProtectedResourceSession(This,pProtectedResourceSession) \ + ( (This)->lpVtbl -> SetProtectedResourceSession(This,pProtectedResourceSession) ) + + +#define ID3D12GraphicsCommandList10_BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) \ + ( (This)->lpVtbl -> BeginRenderPass(This,NumRenderTargets,pRenderTargets,pDepthStencil,Flags) ) + +#define ID3D12GraphicsCommandList10_EndRenderPass(This) \ + ( (This)->lpVtbl -> EndRenderPass(This) ) + +#define ID3D12GraphicsCommandList10_InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> InitializeMetaCommand(This,pMetaCommand,pInitializationParametersData,InitializationParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList10_ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) \ + ( (This)->lpVtbl -> ExecuteMetaCommand(This,pMetaCommand,pExecutionParametersData,ExecutionParametersDataSizeInBytes) ) + +#define ID3D12GraphicsCommandList10_BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) \ + ( (This)->lpVtbl -> BuildRaytracingAccelerationStructure(This,pDesc,NumPostbuildInfoDescs,pPostbuildInfoDescs) ) + +#define ID3D12GraphicsCommandList10_EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) \ + ( (This)->lpVtbl -> EmitRaytracingAccelerationStructurePostbuildInfo(This,pDesc,NumSourceAccelerationStructures,pSourceAccelerationStructureData) ) + +#define ID3D12GraphicsCommandList10_CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) \ + ( (This)->lpVtbl -> CopyRaytracingAccelerationStructure(This,DestAccelerationStructureData,SourceAccelerationStructureData,Mode) ) + +#define ID3D12GraphicsCommandList10_SetPipelineState1(This,pStateObject) \ + ( (This)->lpVtbl -> SetPipelineState1(This,pStateObject) ) + +#define ID3D12GraphicsCommandList10_DispatchRays(This,pDesc) \ + ( (This)->lpVtbl -> DispatchRays(This,pDesc) ) + + +#define ID3D12GraphicsCommandList10_RSSetShadingRate(This,baseShadingRate,combiners) \ + ( (This)->lpVtbl -> RSSetShadingRate(This,baseShadingRate,combiners) ) + +#define ID3D12GraphicsCommandList10_RSSetShadingRateImage(This,shadingRateImage) \ + ( (This)->lpVtbl -> RSSetShadingRateImage(This,shadingRateImage) ) + + +#define ID3D12GraphicsCommandList10_DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) \ + ( (This)->lpVtbl -> DispatchMesh(This,ThreadGroupCountX,ThreadGroupCountY,ThreadGroupCountZ) ) + + +#define ID3D12GraphicsCommandList10_Barrier(This,NumBarrierGroups,pBarrierGroups) \ + ( (This)->lpVtbl -> Barrier(This,NumBarrierGroups,pBarrierGroups) ) + + +#define ID3D12GraphicsCommandList10_OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) \ + ( (This)->lpVtbl -> OMSetFrontAndBackStencilRef(This,FrontStencilRef,BackStencilRef) ) + + +#define ID3D12GraphicsCommandList10_RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) \ + ( (This)->lpVtbl -> RSSetDepthBias(This,DepthBias,DepthBiasClamp,SlopeScaledDepthBias) ) + +#define ID3D12GraphicsCommandList10_IASetIndexBufferStripCutValue(This,IBStripCutValue) \ + ( (This)->lpVtbl -> IASetIndexBufferStripCutValue(This,IBStripCutValue) ) + + +#define ID3D12GraphicsCommandList10_SetProgram(This,pDesc) \ + ( (This)->lpVtbl -> SetProgram(This,pDesc) ) + +#define ID3D12GraphicsCommandList10_DispatchGraph(This,pDesc) \ + ( (This)->lpVtbl -> DispatchGraph(This,pDesc) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GraphicsCommandList10_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12GBVDiagnostics_INTERFACE_DEFINED__ +#define __ID3D12GBVDiagnostics_INTERFACE_DEFINED__ + +/* interface ID3D12GBVDiagnostics */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12GBVDiagnostics; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("597985ab-9b75-4dbb-be23-0761195bebee") + ID3D12GBVDiagnostics : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE GetGBVEntireSubresourceStatesData( + _In_ ID3D12Resource *pResource, + _Out_writes_bytes_(DataSize) int *pData, + UINT DataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGBVSubresourceState( + _In_ ID3D12Resource *pResource, + UINT Subresource, + _Out_ int *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGBVResourceUniformState( + _In_ ID3D12Resource *pResource, + _Out_ int *pData) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetGBVResourceInfo( + _In_ ID3D12Resource *pResource, + _In_opt_ D3D12_RESOURCE_DESC *pResourceDesc, + _In_opt_ UINT32 *pResourceHash, + _In_opt_ UINT32 *pSubresourceStatesByteOffset) = 0; + + virtual void STDMETHODCALLTYPE GBVReserved0( void) = 0; + + virtual void STDMETHODCALLTYPE GBVReserved1( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12GBVDiagnosticsVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12GBVDiagnostics * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12GBVDiagnostics * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12GBVDiagnostics * This); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVEntireSubresourceStatesData) + HRESULT ( STDMETHODCALLTYPE *GetGBVEntireSubresourceStatesData )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + _Out_writes_bytes_(DataSize) int *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVSubresourceState) + HRESULT ( STDMETHODCALLTYPE *GetGBVSubresourceState )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + _Out_ int *pData); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVResourceUniformState) + HRESULT ( STDMETHODCALLTYPE *GetGBVResourceUniformState )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + _Out_ int *pData); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GetGBVResourceInfo) + HRESULT ( STDMETHODCALLTYPE *GetGBVResourceInfo )( + ID3D12GBVDiagnostics * This, + _In_ ID3D12Resource *pResource, + _In_opt_ D3D12_RESOURCE_DESC *pResourceDesc, + _In_opt_ UINT32 *pResourceHash, + _In_opt_ UINT32 *pSubresourceStatesByteOffset); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GBVReserved0) + void ( STDMETHODCALLTYPE *GBVReserved0 )( + ID3D12GBVDiagnostics * This); + + DECLSPEC_XFGVIRT(ID3D12GBVDiagnostics, GBVReserved1) + void ( STDMETHODCALLTYPE *GBVReserved1 )( + ID3D12GBVDiagnostics * This); + + END_INTERFACE + } ID3D12GBVDiagnosticsVtbl; + + interface ID3D12GBVDiagnostics + { + CONST_VTBL struct ID3D12GBVDiagnosticsVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12GBVDiagnostics_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12GBVDiagnostics_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12GBVDiagnostics_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12GBVDiagnostics_GetGBVEntireSubresourceStatesData(This,pResource,pData,DataSize) \ + ( (This)->lpVtbl -> GetGBVEntireSubresourceStatesData(This,pResource,pData,DataSize) ) + +#define ID3D12GBVDiagnostics_GetGBVSubresourceState(This,pResource,Subresource,pData) \ + ( (This)->lpVtbl -> GetGBVSubresourceState(This,pResource,Subresource,pData) ) + +#define ID3D12GBVDiagnostics_GetGBVResourceUniformState(This,pResource,pData) \ + ( (This)->lpVtbl -> GetGBVResourceUniformState(This,pResource,pData) ) + +#define ID3D12GBVDiagnostics_GetGBVResourceInfo(This,pResource,pResourceDesc,pResourceHash,pSubresourceStatesByteOffset) \ + ( (This)->lpVtbl -> GetGBVResourceInfo(This,pResource,pResourceDesc,pResourceHash,pSubresourceStatesByteOffset) ) + +#define ID3D12GBVDiagnostics_GBVReserved0(This) \ + ( (This)->lpVtbl -> GBVReserved0(This) ) + +#define ID3D12GBVDiagnostics_GBVReserved1(This) \ + ( (This)->lpVtbl -> GBVReserved1(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12GBVDiagnostics_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12_0000_0074 */ +/* [local] */ + +#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */ +#ifdef _MSC_VER +#pragma endregion +#endif +DEFINE_GUID(IID_ID3D12Object,0xc4fec28f,0x7966,0x4e95,0x9f,0x94,0xf4,0x31,0xcb,0x56,0xc3,0xb8); +DEFINE_GUID(IID_ID3D12DeviceChild,0x905db94b,0xa00c,0x4140,0x9d,0xf5,0x2b,0x64,0xca,0x9e,0xa3,0x57); +DEFINE_GUID(IID_ID3D12RootSignature,0xc54a6b66,0x72df,0x4ee8,0x8b,0xe5,0xa9,0x46,0xa1,0x42,0x92,0x14); +DEFINE_GUID(IID_ID3D12RootSignatureDeserializer,0x34AB647B,0x3CC8,0x46AC,0x84,0x1B,0xC0,0x96,0x56,0x45,0xC0,0x46); +DEFINE_GUID(IID_ID3D12VersionedRootSignatureDeserializer,0x7F91CE67,0x090C,0x4BB7,0xB7,0x8E,0xED,0x8F,0xF2,0xE3,0x1D,0xA0); +DEFINE_GUID(IID_ID3D12Pageable,0x63ee58fb,0x1268,0x4835,0x86,0xda,0xf0,0x08,0xce,0x62,0xf0,0xd6); +DEFINE_GUID(IID_ID3D12Heap,0x6b3b2502,0x6e51,0x45b3,0x90,0xee,0x98,0x84,0x26,0x5e,0x8d,0xf3); +DEFINE_GUID(IID_ID3D12Resource,0x696442be,0xa72e,0x4059,0xbc,0x79,0x5b,0x5c,0x98,0x04,0x0f,0xad); +DEFINE_GUID(IID_ID3D12CommandAllocator,0x6102dee4,0xaf59,0x4b09,0xb9,0x99,0xb4,0x4d,0x73,0xf0,0x9b,0x24); +DEFINE_GUID(IID_ID3D12Fence,0x0a753dcf,0xc4d8,0x4b91,0xad,0xf6,0xbe,0x5a,0x60,0xd9,0x5a,0x76); +DEFINE_GUID(IID_ID3D12Fence1,0x433685fe,0xe22b,0x4ca0,0xa8,0xdb,0xb5,0xb4,0xf4,0xdd,0x0e,0x4a); +DEFINE_GUID(IID_ID3D12PipelineState,0x765a30f3,0xf624,0x4c6f,0xa8,0x28,0xac,0xe9,0x48,0x62,0x24,0x45); +DEFINE_GUID(IID_ID3D12DescriptorHeap,0x8efb471d,0x616c,0x4f49,0x90,0xf7,0x12,0x7b,0xb7,0x63,0xfa,0x51); +DEFINE_GUID(IID_ID3D12QueryHeap,0x0d9658ae,0xed45,0x469e,0xa6,0x1d,0x97,0x0e,0xc5,0x83,0xca,0xb4); +DEFINE_GUID(IID_ID3D12CommandSignature,0xc36a797c,0xec80,0x4f0a,0x89,0x85,0xa7,0xb2,0x47,0x50,0x82,0xd1); +DEFINE_GUID(IID_ID3D12CommandList,0x7116d91c,0xe7e4,0x47ce,0xb8,0xc6,0xec,0x81,0x68,0xf4,0x37,0xe5); +DEFINE_GUID(IID_ID3D12GraphicsCommandList,0x5b160d0f,0xac1b,0x4185,0x8b,0xa8,0xb3,0xae,0x42,0xa5,0xa4,0x55); +DEFINE_GUID(IID_ID3D12GraphicsCommandList1,0x553103fb,0x1fe7,0x4557,0xbb,0x38,0x94,0x6d,0x7d,0x0e,0x7c,0xa7); +DEFINE_GUID(IID_ID3D12GraphicsCommandList2,0x38C3E585,0xFF17,0x412C,0x91,0x50,0x4F,0xC6,0xF9,0xD7,0x2A,0x28); +DEFINE_GUID(IID_ID3D12CommandQueue,0x0ec870a6,0x5d7e,0x4c22,0x8c,0xfc,0x5b,0xaa,0xe0,0x76,0x16,0xed); +DEFINE_GUID(IID_ID3D12Device,0x189819f1,0x1db6,0x4b57,0xbe,0x54,0x18,0x21,0x33,0x9b,0x85,0xf7); +DEFINE_GUID(IID_ID3D12PipelineLibrary,0xc64226a8,0x9201,0x46af,0xb4,0xcc,0x53,0xfb,0x9f,0xf7,0x41,0x4f); +DEFINE_GUID(IID_ID3D12PipelineLibrary1,0x80eabf42,0x2568,0x4e5e,0xbd,0x82,0xc3,0x7f,0x86,0x96,0x1d,0xc3); +DEFINE_GUID(IID_ID3D12Device1,0x77acce80,0x638e,0x4e65,0x88,0x95,0xc1,0xf2,0x33,0x86,0x86,0x3e); +DEFINE_GUID(IID_ID3D12Device2,0x30baa41e,0xb15b,0x475c,0xa0,0xbb,0x1a,0xf5,0xc5,0xb6,0x43,0x28); +DEFINE_GUID(IID_ID3D12Device3,0x81dadc15,0x2bad,0x4392,0x93,0xc5,0x10,0x13,0x45,0xc4,0xaa,0x98); +DEFINE_GUID(IID_ID3D12ProtectedSession,0xA1533D18,0x0AC1,0x4084,0x85,0xB9,0x89,0xA9,0x61,0x16,0x80,0x6B); +DEFINE_GUID(IID_ID3D12ProtectedResourceSession,0x6CD696F4,0xF289,0x40CC,0x80,0x91,0x5A,0x6C,0x0A,0x09,0x9C,0x3D); +DEFINE_GUID(IID_ID3D12Device4,0xe865df17,0xa9ee,0x46f9,0xa4,0x63,0x30,0x98,0x31,0x5a,0xa2,0xe5); +DEFINE_GUID(IID_ID3D12LifetimeOwner,0xe667af9f,0xcd56,0x4f46,0x83,0xce,0x03,0x2e,0x59,0x5d,0x70,0xa8); +DEFINE_GUID(IID_ID3D12SwapChainAssistant,0xf1df64b6,0x57fd,0x49cd,0x88,0x07,0xc0,0xeb,0x88,0xb4,0x5c,0x8f); +DEFINE_GUID(IID_ID3D12LifetimeTracker,0x3fd03d36,0x4eb1,0x424a,0xa5,0x82,0x49,0x4e,0xcb,0x8b,0xa8,0x13); +DEFINE_GUID(IID_ID3D12StateObject,0x47016943,0xfca8,0x4594,0x93,0xea,0xaf,0x25,0x8b,0x55,0x34,0x6d); +DEFINE_GUID(IID_ID3D12StateObjectProperties,0xde5fa827,0x9bf9,0x4f26,0x89,0xff,0xd7,0xf5,0x6f,0xde,0x38,0x60); +DEFINE_GUID(IID_ID3D12StateObjectProperties1,0x460caac7,0x1d24,0x446a,0xa1,0x84,0xca,0x67,0xdb,0x49,0x41,0x38); +DEFINE_GUID(IID_ID3D12WorkGraphProperties,0x065acf71,0xf863,0x4b89,0x82,0xf4,0x02,0xe4,0xd5,0x88,0x67,0x57); +DEFINE_GUID(IID_ID3D12Device5,0x8b4f173b,0x2fea,0x4b80,0x8f,0x58,0x43,0x07,0x19,0x1a,0xb9,0x5d); +DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedDataSettings,0x82BC481C,0x6B9B,0x4030,0xAE,0xDB,0x7E,0xE3,0xD1,0xDF,0x1E,0x63); +DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedDataSettings1,0xDBD5AE51,0x3317,0x4F0A,0xAD,0xF9,0x1D,0x7C,0xED,0xCA,0xAE,0x0B); +DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedDataSettings2,0x61552388,0x01ab,0x4008,0xa4,0x36,0x83,0xdb,0x18,0x95,0x66,0xea); +DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedData,0x98931D33,0x5AE8,0x4791,0xAA,0x3C,0x1A,0x73,0xA2,0x93,0x4E,0x71); +DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedData1,0x9727A022,0xCF1D,0x4DDA,0x9E,0xBA,0xEF,0xFA,0x65,0x3F,0xC5,0x06); +DEFINE_GUID(IID_ID3D12DeviceRemovedExtendedData2,0x67FC5816,0xE4CA,0x4915,0xBF,0x18,0x42,0x54,0x12,0x72,0xDA,0x54); +DEFINE_GUID(IID_ID3D12Device6,0xc70b221b,0x40e4,0x4a17,0x89,0xaf,0x02,0x5a,0x07,0x27,0xa6,0xdc); +DEFINE_GUID(IID_ID3D12ProtectedResourceSession1,0xD6F12DD6,0x76FB,0x406E,0x89,0x61,0x42,0x96,0xEE,0xFC,0x04,0x09); +DEFINE_GUID(IID_ID3D12Device7,0x5c014b53,0x68a1,0x4b9b,0x8b,0xd1,0xdd,0x60,0x46,0xb9,0x35,0x8b); +DEFINE_GUID(IID_ID3D12Device8,0x9218E6BB,0xF944,0x4F7E,0xA7,0x5C,0xB1,0xB2,0xC7,0xB7,0x01,0xF3); +DEFINE_GUID(IID_ID3D12Resource1,0x9D5E227A,0x4430,0x4161,0x88,0xB3,0x3E,0xCA,0x6B,0xB1,0x6E,0x19); +DEFINE_GUID(IID_ID3D12Resource2,0xBE36EC3B,0xEA85,0x4AEB,0xA4,0x5A,0xE9,0xD7,0x64,0x04,0xA4,0x95); +DEFINE_GUID(IID_ID3D12Heap1,0x572F7389,0x2168,0x49E3,0x96,0x93,0xD6,0xDF,0x58,0x71,0xBF,0x6D); +DEFINE_GUID(IID_ID3D12GraphicsCommandList3,0x6FDA83A7,0xB84C,0x4E38,0x9A,0xC8,0xC7,0xBD,0x22,0x01,0x6B,0x3D); +DEFINE_GUID(IID_ID3D12MetaCommand,0xDBB84C27,0x36CE,0x4FC9,0xB8,0x01,0xF0,0x48,0xC4,0x6A,0xC5,0x70); +DEFINE_GUID(IID_ID3D12GraphicsCommandList4,0x8754318e,0xd3a9,0x4541,0x98,0xcf,0x64,0x5b,0x50,0xdc,0x48,0x74); +DEFINE_GUID(IID_ID3D12ShaderCacheSession,0x28e2495d,0x0f64,0x4ae4,0xa6,0xec,0x12,0x92,0x55,0xdc,0x49,0xa8); +DEFINE_GUID(IID_ID3D12Device9,0x4c80e962,0xf032,0x4f60,0xbc,0x9e,0xeb,0xc2,0xcf,0xa1,0xd8,0x3c); +DEFINE_GUID(IID_ID3D12Device10,0x517f8718,0xaa66,0x49f9,0xb0,0x2b,0xa7,0xab,0x89,0xc0,0x60,0x31); +DEFINE_GUID(IID_ID3D12Device11,0x5405c344,0xd457,0x444e,0xb4,0xdd,0x23,0x66,0xe4,0x5a,0xee,0x39); +DEFINE_GUID(IID_ID3D12Device12,0x5af5c532,0x4c91,0x4cd0,0xb5,0x41,0x15,0xa4,0x05,0x39,0x5f,0xc5); +DEFINE_GUID(IID_ID3D12Device13,0x14eecffc,0x4df8,0x40f7,0xa1,0x18,0x5c,0x81,0x6f,0x45,0x69,0x5e); +DEFINE_GUID(IID_ID3D12Device14,0x5f6e592d,0xd895,0x44c2,0x8e,0x4a,0x88,0xad,0x49,0x26,0xd3,0x23); +DEFINE_GUID(IID_ID3D12VirtualizationGuestDevice,0xbc66d368,0x7373,0x4943,0x87,0x57,0xfc,0x87,0xdc,0x79,0xe4,0x76); +DEFINE_GUID(IID_ID3D12Tools,0x7071e1f0,0xe84b,0x4b33,0x97,0x4f,0x12,0xfa,0x49,0xde,0x65,0xc5); +DEFINE_GUID(IID_ID3D12SDKConfiguration,0xe9eb5314,0x33aa,0x42b2,0xa7,0x18,0xd7,0x7f,0x58,0xb1,0xf1,0xc7); +DEFINE_GUID(IID_ID3D12SDKConfiguration1,0x8aaf9303,0xad25,0x48b9,0x9a,0x57,0xd9,0xc3,0x7e,0x00,0x9d,0x9f); +DEFINE_GUID(IID_ID3D12DeviceFactory,0x61f307d3,0xd34e,0x4e7c,0x83,0x74,0x3b,0xa4,0xde,0x23,0xcc,0xcb); +DEFINE_GUID(IID_ID3D12DeviceConfiguration,0x78dbf87b,0xf766,0x422b,0xa6,0x1c,0xc8,0xc4,0x46,0xbd,0xb9,0xad); +DEFINE_GUID(IID_ID3D12DeviceConfiguration1,0xed342442,0x6343,0x4e16,0xbb,0x82,0xa3,0xa5,0x77,0x87,0x4e,0x56); +DEFINE_GUID(IID_ID3D12GraphicsCommandList5,0x55050859,0x4024,0x474c,0x87,0xf5,0x64,0x72,0xea,0xee,0x44,0xea); +DEFINE_GUID(IID_ID3D12GraphicsCommandList6,0xc3827890,0xe548,0x4cfa,0x96,0xcf,0x56,0x89,0xa9,0x37,0x0f,0x80); +DEFINE_GUID(IID_ID3D12GraphicsCommandList7,0xdd171223,0x8b61,0x4769,0x90,0xe3,0x16,0x0c,0xcd,0xe4,0xe2,0xc1); +DEFINE_GUID(IID_ID3D12GraphicsCommandList8,0xee936ef9,0x599d,0x4d28,0x93,0x8e,0x23,0xc4,0xad,0x05,0xce,0x51); +DEFINE_GUID(IID_ID3D12GraphicsCommandList9,0x34ed2808,0xffe6,0x4c2b,0xb1,0x1a,0xca,0xbd,0x2b,0x0c,0x59,0xe1); +DEFINE_GUID(IID_ID3D12GraphicsCommandList10,0x7013c015,0xd161,0x4b63,0xa0,0x8c,0x23,0x85,0x52,0xdd,0x8a,0xcc); +DEFINE_GUID(IID_ID3D12GBVDiagnostics,0x597985ab,0x9b75,0x4dbb,0xbe,0x23,0x07,0x61,0x19,0x5b,0xeb,0xee); + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0074_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12_0000_0074_v0_0_s_ifspec; + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/contrib/SDL-3.2.8/src/video/directx/d3d12sdklayers.h b/contrib/SDL-3.2.8/src/video/directx/d3d12sdklayers.h new file mode 100644 index 0000000..2628d62 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/directx/d3d12sdklayers.h @@ -0,0 +1,4267 @@ +/*------------------------------------------------------------------------------------- + * + * Copyright (c) Microsoft Corporation + * Licensed under the MIT license + * + *-------------------------------------------------------------------------------------*/ + + +/* this ALWAYS GENERATED file contains the definitions for the interfaces */ + + + /* File created by MIDL compiler version 8.01.0628 */ + + + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCNDR_H_VERSION__ +#define __REQUIRED_RPCNDR_H_VERSION__ 500 +#endif + +/* verify that the version is high enough to compile this file*/ +#ifndef __REQUIRED_RPCSAL_H_VERSION__ +#define __REQUIRED_RPCSAL_H_VERSION__ 100 +#endif + +#include "rpc.h" +#include "rpcndr.h" + +#ifndef __RPCNDR_H_VERSION__ +#error this stub requires an updated version of +#endif /* __RPCNDR_H_VERSION__ */ + +#ifndef COM_NO_WINDOWS_H +#include "windows.h" +#include "ole2.h" +#endif /*COM_NO_WINDOWS_H*/ + +#ifndef __d3d12sdklayers_h__ +#define __d3d12sdklayers_h__ + +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#pragma once +#endif + +#ifndef DECLSPEC_XFGVIRT +#if defined(_CONTROL_FLOW_GUARD_XFG) +#define DECLSPEC_XFGVIRT(base, func) __declspec(xfg_virtual(base, func)) +#else +#define DECLSPEC_XFGVIRT(base, func) +#endif +#endif + +/* Forward Declarations */ + +#ifndef __ID3D12Debug_FWD_DEFINED__ +#define __ID3D12Debug_FWD_DEFINED__ +typedef interface ID3D12Debug ID3D12Debug; + +#endif /* __ID3D12Debug_FWD_DEFINED__ */ + + +#ifndef __ID3D12Debug1_FWD_DEFINED__ +#define __ID3D12Debug1_FWD_DEFINED__ +typedef interface ID3D12Debug1 ID3D12Debug1; + +#endif /* __ID3D12Debug1_FWD_DEFINED__ */ + + +#ifndef __ID3D12Debug2_FWD_DEFINED__ +#define __ID3D12Debug2_FWD_DEFINED__ +typedef interface ID3D12Debug2 ID3D12Debug2; + +#endif /* __ID3D12Debug2_FWD_DEFINED__ */ + + +#ifndef __ID3D12Debug3_FWD_DEFINED__ +#define __ID3D12Debug3_FWD_DEFINED__ +typedef interface ID3D12Debug3 ID3D12Debug3; + +#endif /* __ID3D12Debug3_FWD_DEFINED__ */ + + +#ifndef __ID3D12Debug4_FWD_DEFINED__ +#define __ID3D12Debug4_FWD_DEFINED__ +typedef interface ID3D12Debug4 ID3D12Debug4; + +#endif /* __ID3D12Debug4_FWD_DEFINED__ */ + + +#ifndef __ID3D12Debug5_FWD_DEFINED__ +#define __ID3D12Debug5_FWD_DEFINED__ +typedef interface ID3D12Debug5 ID3D12Debug5; + +#endif /* __ID3D12Debug5_FWD_DEFINED__ */ + + +#ifndef __ID3D12Debug6_FWD_DEFINED__ +#define __ID3D12Debug6_FWD_DEFINED__ +typedef interface ID3D12Debug6 ID3D12Debug6; + +#endif /* __ID3D12Debug6_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugDevice1_FWD_DEFINED__ +#define __ID3D12DebugDevice1_FWD_DEFINED__ +typedef interface ID3D12DebugDevice1 ID3D12DebugDevice1; + +#endif /* __ID3D12DebugDevice1_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugDevice_FWD_DEFINED__ +#define __ID3D12DebugDevice_FWD_DEFINED__ +typedef interface ID3D12DebugDevice ID3D12DebugDevice; + +#endif /* __ID3D12DebugDevice_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugDevice2_FWD_DEFINED__ +#define __ID3D12DebugDevice2_FWD_DEFINED__ +typedef interface ID3D12DebugDevice2 ID3D12DebugDevice2; + +#endif /* __ID3D12DebugDevice2_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandQueue_FWD_DEFINED__ +#define __ID3D12DebugCommandQueue_FWD_DEFINED__ +typedef interface ID3D12DebugCommandQueue ID3D12DebugCommandQueue; + +#endif /* __ID3D12DebugCommandQueue_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandQueue1_FWD_DEFINED__ +#define __ID3D12DebugCommandQueue1_FWD_DEFINED__ +typedef interface ID3D12DebugCommandQueue1 ID3D12DebugCommandQueue1; + +#endif /* __ID3D12DebugCommandQueue1_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandList1_FWD_DEFINED__ +#define __ID3D12DebugCommandList1_FWD_DEFINED__ +typedef interface ID3D12DebugCommandList1 ID3D12DebugCommandList1; + +#endif /* __ID3D12DebugCommandList1_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandList_FWD_DEFINED__ +#define __ID3D12DebugCommandList_FWD_DEFINED__ +typedef interface ID3D12DebugCommandList ID3D12DebugCommandList; + +#endif /* __ID3D12DebugCommandList_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandList2_FWD_DEFINED__ +#define __ID3D12DebugCommandList2_FWD_DEFINED__ +typedef interface ID3D12DebugCommandList2 ID3D12DebugCommandList2; + +#endif /* __ID3D12DebugCommandList2_FWD_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandList3_FWD_DEFINED__ +#define __ID3D12DebugCommandList3_FWD_DEFINED__ +typedef interface ID3D12DebugCommandList3 ID3D12DebugCommandList3; + +#endif /* __ID3D12DebugCommandList3_FWD_DEFINED__ */ + + +#ifndef __ID3D12SharingContract_FWD_DEFINED__ +#define __ID3D12SharingContract_FWD_DEFINED__ +typedef interface ID3D12SharingContract ID3D12SharingContract; + +#endif /* __ID3D12SharingContract_FWD_DEFINED__ */ + + +#ifndef __ID3D12ManualWriteTrackingResource_FWD_DEFINED__ +#define __ID3D12ManualWriteTrackingResource_FWD_DEFINED__ +typedef interface ID3D12ManualWriteTrackingResource ID3D12ManualWriteTrackingResource; + +#endif /* __ID3D12ManualWriteTrackingResource_FWD_DEFINED__ */ + + +#ifndef __ID3D12InfoQueue_FWD_DEFINED__ +#define __ID3D12InfoQueue_FWD_DEFINED__ +typedef interface ID3D12InfoQueue ID3D12InfoQueue; + +#endif /* __ID3D12InfoQueue_FWD_DEFINED__ */ + + +#ifndef __ID3D12InfoQueue1_FWD_DEFINED__ +#define __ID3D12InfoQueue1_FWD_DEFINED__ +typedef interface ID3D12InfoQueue1 ID3D12InfoQueue1; + +#endif /* __ID3D12InfoQueue1_FWD_DEFINED__ */ + + +/* header files for imported files */ +#include "oaidl.h" +#include "ocidl.h" +#include "d3d12.h" + +#ifdef __cplusplus +extern "C"{ +#endif + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0000 */ +/* [local] */ + +#include +#ifdef _MSC_VER +#pragma region App Family +#endif +#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0000_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0000_v0_0_s_ifspec; + +#ifndef __ID3D12Debug_INTERFACE_DEFINED__ +#define __ID3D12Debug_INTERFACE_DEFINED__ + +/* interface ID3D12Debug */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Debug; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("344488b7-6846-474b-b989-f027448245e0") + ID3D12Debug : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE EnableDebugLayer( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Debug * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Debug * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Debug * This); + + DECLSPEC_XFGVIRT(ID3D12Debug, EnableDebugLayer) + void ( STDMETHODCALLTYPE *EnableDebugLayer )( + ID3D12Debug * This); + + END_INTERFACE + } ID3D12DebugVtbl; + + interface ID3D12Debug + { + CONST_VTBL struct ID3D12DebugVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Debug_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Debug_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Debug_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Debug_EnableDebugLayer(This) \ + ( (This)->lpVtbl -> EnableDebugLayer(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Debug_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0001 */ +/* [local] */ + +typedef +enum D3D12_GPU_BASED_VALIDATION_FLAGS + { + D3D12_GPU_BASED_VALIDATION_FLAGS_NONE = 0, + D3D12_GPU_BASED_VALIDATION_FLAGS_DISABLE_STATE_TRACKING = 0x1 + } D3D12_GPU_BASED_VALIDATION_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS(D3D12_GPU_BASED_VALIDATION_FLAGS) + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0001_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0001_v0_0_s_ifspec; + +#ifndef __ID3D12Debug1_INTERFACE_DEFINED__ +#define __ID3D12Debug1_INTERFACE_DEFINED__ + +/* interface ID3D12Debug1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Debug1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("affaa4ca-63fe-4d8e-b8ad-159000af4304") + ID3D12Debug1 : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE EnableDebugLayer( void) = 0; + + virtual void STDMETHODCALLTYPE SetEnableGPUBasedValidation( + BOOL Enable) = 0; + + virtual void STDMETHODCALLTYPE SetEnableSynchronizedCommandQueueValidation( + BOOL Enable) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Debug1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Debug1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Debug1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Debug1 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug1, EnableDebugLayer) + void ( STDMETHODCALLTYPE *EnableDebugLayer )( + ID3D12Debug1 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug1, SetEnableGPUBasedValidation) + void ( STDMETHODCALLTYPE *SetEnableGPUBasedValidation )( + ID3D12Debug1 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug1, SetEnableSynchronizedCommandQueueValidation) + void ( STDMETHODCALLTYPE *SetEnableSynchronizedCommandQueueValidation )( + ID3D12Debug1 * This, + BOOL Enable); + + END_INTERFACE + } ID3D12Debug1Vtbl; + + interface ID3D12Debug1 + { + CONST_VTBL struct ID3D12Debug1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Debug1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Debug1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Debug1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Debug1_EnableDebugLayer(This) \ + ( (This)->lpVtbl -> EnableDebugLayer(This) ) + +#define ID3D12Debug1_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableGPUBasedValidation(This,Enable) ) + +#define ID3D12Debug1_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableSynchronizedCommandQueueValidation(This,Enable) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Debug1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Debug2_INTERFACE_DEFINED__ +#define __ID3D12Debug2_INTERFACE_DEFINED__ + +/* interface ID3D12Debug2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Debug2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("93a665c4-a3b2-4e5d-b692-a26ae14e3374") + ID3D12Debug2 : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE SetGPUBasedValidationFlags( + D3D12_GPU_BASED_VALIDATION_FLAGS Flags) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Debug2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Debug2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Debug2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Debug2 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug2, SetGPUBasedValidationFlags) + void ( STDMETHODCALLTYPE *SetGPUBasedValidationFlags )( + ID3D12Debug2 * This, + D3D12_GPU_BASED_VALIDATION_FLAGS Flags); + + END_INTERFACE + } ID3D12Debug2Vtbl; + + interface ID3D12Debug2 + { + CONST_VTBL struct ID3D12Debug2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Debug2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Debug2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Debug2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Debug2_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->lpVtbl -> SetGPUBasedValidationFlags(This,Flags) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Debug2_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Debug3_INTERFACE_DEFINED__ +#define __ID3D12Debug3_INTERFACE_DEFINED__ + +/* interface ID3D12Debug3 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Debug3; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("5cf4e58f-f671-4ff1-a542-3686e3d153d1") + ID3D12Debug3 : public ID3D12Debug + { + public: + virtual void STDMETHODCALLTYPE SetEnableGPUBasedValidation( + BOOL Enable) = 0; + + virtual void STDMETHODCALLTYPE SetEnableSynchronizedCommandQueueValidation( + BOOL Enable) = 0; + + virtual void STDMETHODCALLTYPE SetGPUBasedValidationFlags( + D3D12_GPU_BASED_VALIDATION_FLAGS Flags) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Debug3Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Debug3 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Debug3 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Debug3 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug, EnableDebugLayer) + void ( STDMETHODCALLTYPE *EnableDebugLayer )( + ID3D12Debug3 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableGPUBasedValidation) + void ( STDMETHODCALLTYPE *SetEnableGPUBasedValidation )( + ID3D12Debug3 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableSynchronizedCommandQueueValidation) + void ( STDMETHODCALLTYPE *SetEnableSynchronizedCommandQueueValidation )( + ID3D12Debug3 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetGPUBasedValidationFlags) + void ( STDMETHODCALLTYPE *SetGPUBasedValidationFlags )( + ID3D12Debug3 * This, + D3D12_GPU_BASED_VALIDATION_FLAGS Flags); + + END_INTERFACE + } ID3D12Debug3Vtbl; + + interface ID3D12Debug3 + { + CONST_VTBL struct ID3D12Debug3Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Debug3_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Debug3_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Debug3_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Debug3_EnableDebugLayer(This) \ + ( (This)->lpVtbl -> EnableDebugLayer(This) ) + + +#define ID3D12Debug3_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableGPUBasedValidation(This,Enable) ) + +#define ID3D12Debug3_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableSynchronizedCommandQueueValidation(This,Enable) ) + +#define ID3D12Debug3_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->lpVtbl -> SetGPUBasedValidationFlags(This,Flags) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Debug3_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Debug4_INTERFACE_DEFINED__ +#define __ID3D12Debug4_INTERFACE_DEFINED__ + +/* interface ID3D12Debug4 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Debug4; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("014b816e-9ec5-4a2f-a845-ffbe441ce13a") + ID3D12Debug4 : public ID3D12Debug3 + { + public: + virtual void STDMETHODCALLTYPE DisableDebugLayer( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Debug4Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Debug4 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Debug4 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Debug4 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug, EnableDebugLayer) + void ( STDMETHODCALLTYPE *EnableDebugLayer )( + ID3D12Debug4 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableGPUBasedValidation) + void ( STDMETHODCALLTYPE *SetEnableGPUBasedValidation )( + ID3D12Debug4 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableSynchronizedCommandQueueValidation) + void ( STDMETHODCALLTYPE *SetEnableSynchronizedCommandQueueValidation )( + ID3D12Debug4 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetGPUBasedValidationFlags) + void ( STDMETHODCALLTYPE *SetGPUBasedValidationFlags )( + ID3D12Debug4 * This, + D3D12_GPU_BASED_VALIDATION_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12Debug4, DisableDebugLayer) + void ( STDMETHODCALLTYPE *DisableDebugLayer )( + ID3D12Debug4 * This); + + END_INTERFACE + } ID3D12Debug4Vtbl; + + interface ID3D12Debug4 + { + CONST_VTBL struct ID3D12Debug4Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Debug4_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Debug4_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Debug4_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Debug4_EnableDebugLayer(This) \ + ( (This)->lpVtbl -> EnableDebugLayer(This) ) + + +#define ID3D12Debug4_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableGPUBasedValidation(This,Enable) ) + +#define ID3D12Debug4_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableSynchronizedCommandQueueValidation(This,Enable) ) + +#define ID3D12Debug4_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->lpVtbl -> SetGPUBasedValidationFlags(This,Flags) ) + + +#define ID3D12Debug4_DisableDebugLayer(This) \ + ( (This)->lpVtbl -> DisableDebugLayer(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Debug4_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Debug5_INTERFACE_DEFINED__ +#define __ID3D12Debug5_INTERFACE_DEFINED__ + +/* interface ID3D12Debug5 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Debug5; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("548d6b12-09fa-40e0-9069-5dcd589a52c9") + ID3D12Debug5 : public ID3D12Debug4 + { + public: + virtual void STDMETHODCALLTYPE SetEnableAutoName( + BOOL Enable) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Debug5Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Debug5 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Debug5 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Debug5 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug, EnableDebugLayer) + void ( STDMETHODCALLTYPE *EnableDebugLayer )( + ID3D12Debug5 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableGPUBasedValidation) + void ( STDMETHODCALLTYPE *SetEnableGPUBasedValidation )( + ID3D12Debug5 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableSynchronizedCommandQueueValidation) + void ( STDMETHODCALLTYPE *SetEnableSynchronizedCommandQueueValidation )( + ID3D12Debug5 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetGPUBasedValidationFlags) + void ( STDMETHODCALLTYPE *SetGPUBasedValidationFlags )( + ID3D12Debug5 * This, + D3D12_GPU_BASED_VALIDATION_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12Debug4, DisableDebugLayer) + void ( STDMETHODCALLTYPE *DisableDebugLayer )( + ID3D12Debug5 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug5, SetEnableAutoName) + void ( STDMETHODCALLTYPE *SetEnableAutoName )( + ID3D12Debug5 * This, + BOOL Enable); + + END_INTERFACE + } ID3D12Debug5Vtbl; + + interface ID3D12Debug5 + { + CONST_VTBL struct ID3D12Debug5Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Debug5_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Debug5_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Debug5_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Debug5_EnableDebugLayer(This) \ + ( (This)->lpVtbl -> EnableDebugLayer(This) ) + + +#define ID3D12Debug5_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableGPUBasedValidation(This,Enable) ) + +#define ID3D12Debug5_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableSynchronizedCommandQueueValidation(This,Enable) ) + +#define ID3D12Debug5_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->lpVtbl -> SetGPUBasedValidationFlags(This,Flags) ) + + +#define ID3D12Debug5_DisableDebugLayer(This) \ + ( (This)->lpVtbl -> DisableDebugLayer(This) ) + + +#define ID3D12Debug5_SetEnableAutoName(This,Enable) \ + ( (This)->lpVtbl -> SetEnableAutoName(This,Enable) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Debug5_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12Debug6_INTERFACE_DEFINED__ +#define __ID3D12Debug6_INTERFACE_DEFINED__ + +/* interface ID3D12Debug6 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12Debug6; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("82a816d6-5d01-4157-97d0-4975463fd1ed") + ID3D12Debug6 : public ID3D12Debug5 + { + public: + virtual void STDMETHODCALLTYPE SetForceLegacyBarrierValidation( + BOOL Enable) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12Debug6Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12Debug6 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12Debug6 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12Debug6 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug, EnableDebugLayer) + void ( STDMETHODCALLTYPE *EnableDebugLayer )( + ID3D12Debug6 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableGPUBasedValidation) + void ( STDMETHODCALLTYPE *SetEnableGPUBasedValidation )( + ID3D12Debug6 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetEnableSynchronizedCommandQueueValidation) + void ( STDMETHODCALLTYPE *SetEnableSynchronizedCommandQueueValidation )( + ID3D12Debug6 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug3, SetGPUBasedValidationFlags) + void ( STDMETHODCALLTYPE *SetGPUBasedValidationFlags )( + ID3D12Debug6 * This, + D3D12_GPU_BASED_VALIDATION_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12Debug4, DisableDebugLayer) + void ( STDMETHODCALLTYPE *DisableDebugLayer )( + ID3D12Debug6 * This); + + DECLSPEC_XFGVIRT(ID3D12Debug5, SetEnableAutoName) + void ( STDMETHODCALLTYPE *SetEnableAutoName )( + ID3D12Debug6 * This, + BOOL Enable); + + DECLSPEC_XFGVIRT(ID3D12Debug6, SetForceLegacyBarrierValidation) + void ( STDMETHODCALLTYPE *SetForceLegacyBarrierValidation )( + ID3D12Debug6 * This, + BOOL Enable); + + END_INTERFACE + } ID3D12Debug6Vtbl; + + interface ID3D12Debug6 + { + CONST_VTBL struct ID3D12Debug6Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12Debug6_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12Debug6_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12Debug6_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12Debug6_EnableDebugLayer(This) \ + ( (This)->lpVtbl -> EnableDebugLayer(This) ) + + +#define ID3D12Debug6_SetEnableGPUBasedValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableGPUBasedValidation(This,Enable) ) + +#define ID3D12Debug6_SetEnableSynchronizedCommandQueueValidation(This,Enable) \ + ( (This)->lpVtbl -> SetEnableSynchronizedCommandQueueValidation(This,Enable) ) + +#define ID3D12Debug6_SetGPUBasedValidationFlags(This,Flags) \ + ( (This)->lpVtbl -> SetGPUBasedValidationFlags(This,Flags) ) + + +#define ID3D12Debug6_DisableDebugLayer(This) \ + ( (This)->lpVtbl -> DisableDebugLayer(This) ) + + +#define ID3D12Debug6_SetEnableAutoName(This,Enable) \ + ( (This)->lpVtbl -> SetEnableAutoName(This,Enable) ) + + +#define ID3D12Debug6_SetForceLegacyBarrierValidation(This,Enable) \ + ( (This)->lpVtbl -> SetForceLegacyBarrierValidation(This,Enable) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12Debug6_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0007 */ +/* [local] */ + +DEFINE_GUID(WKPDID_D3DAutoDebugObjectNameW, 0xd4902e36, 0x757a, 0x4942, 0x95, 0x94, 0xb6, 0x76, 0x9a, 0xfa, 0x43, 0xcd); +typedef +enum D3D12_RLDO_FLAGS + { + D3D12_RLDO_NONE = 0, + D3D12_RLDO_SUMMARY = 0x1, + D3D12_RLDO_DETAIL = 0x2, + D3D12_RLDO_IGNORE_INTERNAL = 0x4 + } D3D12_RLDO_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS(D3D12_RLDO_FLAGS) +typedef +enum D3D12_DEBUG_DEVICE_PARAMETER_TYPE + { + D3D12_DEBUG_DEVICE_PARAMETER_FEATURE_FLAGS = 0, + D3D12_DEBUG_DEVICE_PARAMETER_GPU_BASED_VALIDATION_SETTINGS = ( D3D12_DEBUG_DEVICE_PARAMETER_FEATURE_FLAGS + 1 ) , + D3D12_DEBUG_DEVICE_PARAMETER_GPU_SLOWDOWN_PERFORMANCE_FACTOR = ( D3D12_DEBUG_DEVICE_PARAMETER_GPU_BASED_VALIDATION_SETTINGS + 1 ) + } D3D12_DEBUG_DEVICE_PARAMETER_TYPE; + +typedef +enum D3D12_DEBUG_FEATURE + { + D3D12_DEBUG_FEATURE_NONE = 0, + D3D12_DEBUG_FEATURE_ALLOW_BEHAVIOR_CHANGING_DEBUG_AIDS = 0x1, + D3D12_DEBUG_FEATURE_CONSERVATIVE_RESOURCE_STATE_TRACKING = 0x2, + D3D12_DEBUG_FEATURE_DISABLE_VIRTUALIZED_BUNDLES_VALIDATION = 0x4, + D3D12_DEBUG_FEATURE_EMULATE_WINDOWS7 = 0x8 + } D3D12_DEBUG_FEATURE; + +DEFINE_ENUM_FLAG_OPERATORS(D3D12_DEBUG_FEATURE) +typedef +enum D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE + { + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_NONE = 0, + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_STATE_TRACKING_ONLY = ( D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_NONE + 1 ) , + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_UNGUARDED_VALIDATION = ( D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_STATE_TRACKING_ONLY + 1 ) , + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_GUARDED_VALIDATION = ( D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_UNGUARDED_VALIDATION + 1 ) , + NUM_D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODES = ( D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE_GUARDED_VALIDATION + 1 ) + } D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE; + +typedef +enum D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS + { + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_NONE = 0, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_TRACKING_ONLY_SHADERS = 0x1, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_UNGUARDED_VALIDATION_SHADERS = 0x2, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAG_FRONT_LOAD_CREATE_GUARDED_VALIDATION_SHADERS = 0x4, + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS_VALID_MASK = 0x7 + } D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS(D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS) +typedef struct D3D12_DEBUG_DEVICE_GPU_BASED_VALIDATION_SETTINGS + { + UINT MaxMessagesPerCommandList; + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE DefaultShaderPatchMode; + D3D12_GPU_BASED_VALIDATION_PIPELINE_STATE_CREATE_FLAGS PipelineStateCreateFlags; + } D3D12_DEBUG_DEVICE_GPU_BASED_VALIDATION_SETTINGS; + +typedef struct D3D12_DEBUG_DEVICE_GPU_SLOWDOWN_PERFORMANCE_FACTOR + { + FLOAT SlowdownFactor; + } D3D12_DEBUG_DEVICE_GPU_SLOWDOWN_PERFORMANCE_FACTOR; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0007_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0007_v0_0_s_ifspec; + +#ifndef __ID3D12DebugDevice1_INTERFACE_DEFINED__ +#define __ID3D12DebugDevice1_INTERFACE_DEFINED__ + +/* interface ID3D12DebugDevice1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugDevice1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("a9b71770-d099-4a65-a698-3dee10020f88") + ID3D12DebugDevice1 : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetDebugParameter( + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDebugParameter( + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE ReportLiveDeviceObjects( + D3D12_RLDO_FLAGS Flags) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugDevice1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugDevice1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugDevice1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugDevice1 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice1, SetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *SetDebugParameter )( + ID3D12DebugDevice1 * This, + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice1, GetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *GetDebugParameter )( + ID3D12DebugDevice1 * This, + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice1, ReportLiveDeviceObjects) + HRESULT ( STDMETHODCALLTYPE *ReportLiveDeviceObjects )( + ID3D12DebugDevice1 * This, + D3D12_RLDO_FLAGS Flags); + + END_INTERFACE + } ID3D12DebugDevice1Vtbl; + + interface ID3D12DebugDevice1 + { + CONST_VTBL struct ID3D12DebugDevice1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugDevice1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugDevice1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugDevice1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugDevice1_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> SetDebugParameter(This,Type,pData,DataSize) ) + +#define ID3D12DebugDevice1_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> GetDebugParameter(This,Type,pData,DataSize) ) + +#define ID3D12DebugDevice1_ReportLiveDeviceObjects(This,Flags) \ + ( (This)->lpVtbl -> ReportLiveDeviceObjects(This,Flags) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugDevice1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DebugDevice_INTERFACE_DEFINED__ +#define __ID3D12DebugDevice_INTERFACE_DEFINED__ + +/* interface ID3D12DebugDevice */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugDevice; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("3febd6dd-4973-4787-8194-e45f9e28923e") + ID3D12DebugDevice : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetFeatureMask( + D3D12_DEBUG_FEATURE Mask) = 0; + + virtual D3D12_DEBUG_FEATURE STDMETHODCALLTYPE GetFeatureMask( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE ReportLiveDeviceObjects( + D3D12_RLDO_FLAGS Flags) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugDeviceVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugDevice * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugDevice * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugDevice * This); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice, SetFeatureMask) + HRESULT ( STDMETHODCALLTYPE *SetFeatureMask )( + ID3D12DebugDevice * This, + D3D12_DEBUG_FEATURE Mask); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice, GetFeatureMask) + D3D12_DEBUG_FEATURE ( STDMETHODCALLTYPE *GetFeatureMask )( + ID3D12DebugDevice * This); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice, ReportLiveDeviceObjects) + HRESULT ( STDMETHODCALLTYPE *ReportLiveDeviceObjects )( + ID3D12DebugDevice * This, + D3D12_RLDO_FLAGS Flags); + + END_INTERFACE + } ID3D12DebugDeviceVtbl; + + interface ID3D12DebugDevice + { + CONST_VTBL struct ID3D12DebugDeviceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugDevice_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugDevice_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugDevice_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugDevice_SetFeatureMask(This,Mask) \ + ( (This)->lpVtbl -> SetFeatureMask(This,Mask) ) + +#define ID3D12DebugDevice_GetFeatureMask(This) \ + ( (This)->lpVtbl -> GetFeatureMask(This) ) + +#define ID3D12DebugDevice_ReportLiveDeviceObjects(This,Flags) \ + ( (This)->lpVtbl -> ReportLiveDeviceObjects(This,Flags) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugDevice_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DebugDevice2_INTERFACE_DEFINED__ +#define __ID3D12DebugDevice2_INTERFACE_DEFINED__ + +/* interface ID3D12DebugDevice2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugDevice2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("60eccbc1-378d-4df1-894c-f8ac5ce4d7dd") + ID3D12DebugDevice2 : public ID3D12DebugDevice + { + public: + virtual HRESULT STDMETHODCALLTYPE SetDebugParameter( + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDebugParameter( + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugDevice2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugDevice2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugDevice2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugDevice2 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice, SetFeatureMask) + HRESULT ( STDMETHODCALLTYPE *SetFeatureMask )( + ID3D12DebugDevice2 * This, + D3D12_DEBUG_FEATURE Mask); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice, GetFeatureMask) + D3D12_DEBUG_FEATURE ( STDMETHODCALLTYPE *GetFeatureMask )( + ID3D12DebugDevice2 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice, ReportLiveDeviceObjects) + HRESULT ( STDMETHODCALLTYPE *ReportLiveDeviceObjects )( + ID3D12DebugDevice2 * This, + D3D12_RLDO_FLAGS Flags); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice2, SetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *SetDebugParameter )( + ID3D12DebugDevice2 * This, + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12DebugDevice2, GetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *GetDebugParameter )( + ID3D12DebugDevice2 * This, + D3D12_DEBUG_DEVICE_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize); + + END_INTERFACE + } ID3D12DebugDevice2Vtbl; + + interface ID3D12DebugDevice2 + { + CONST_VTBL struct ID3D12DebugDevice2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugDevice2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugDevice2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugDevice2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugDevice2_SetFeatureMask(This,Mask) \ + ( (This)->lpVtbl -> SetFeatureMask(This,Mask) ) + +#define ID3D12DebugDevice2_GetFeatureMask(This) \ + ( (This)->lpVtbl -> GetFeatureMask(This) ) + +#define ID3D12DebugDevice2_ReportLiveDeviceObjects(This,Flags) \ + ( (This)->lpVtbl -> ReportLiveDeviceObjects(This,Flags) ) + + +#define ID3D12DebugDevice2_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> SetDebugParameter(This,Type,pData,DataSize) ) + +#define ID3D12DebugDevice2_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> GetDebugParameter(This,Type,pData,DataSize) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugDevice2_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0010 */ +/* [local] */ + +DEFINE_GUID(DXGI_DEBUG_D3D12, 0xcf59a98c, 0xa950, 0x4326, 0x91, 0xef, 0x9b, 0xba, 0xa1, 0x7b, 0xfd, 0x95); + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0010_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0010_v0_0_s_ifspec; + +#ifndef __ID3D12DebugCommandQueue_INTERFACE_DEFINED__ +#define __ID3D12DebugCommandQueue_INTERFACE_DEFINED__ + +/* interface ID3D12DebugCommandQueue */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugCommandQueue; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("09e0bf36-54ac-484f-8847-4baeeab6053a") + ID3D12DebugCommandQueue : public IUnknown + { + public: + virtual BOOL STDMETHODCALLTYPE AssertResourceState( + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugCommandQueueVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugCommandQueue * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugCommandQueue * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugCommandQueue * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandQueue, AssertResourceState) + BOOL ( STDMETHODCALLTYPE *AssertResourceState )( + ID3D12DebugCommandQueue * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State); + + END_INTERFACE + } ID3D12DebugCommandQueueVtbl; + + interface ID3D12DebugCommandQueue + { + CONST_VTBL struct ID3D12DebugCommandQueueVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugCommandQueue_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugCommandQueue_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugCommandQueue_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugCommandQueue_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->lpVtbl -> AssertResourceState(This,pResource,Subresource,State) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugCommandQueue_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandQueue1_INTERFACE_DEFINED__ +#define __ID3D12DebugCommandQueue1_INTERFACE_DEFINED__ + +/* interface ID3D12DebugCommandQueue1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugCommandQueue1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("16be35a2-bfd6-49f2-bcae-eaae4aff862d") + ID3D12DebugCommandQueue1 : public ID3D12DebugCommandQueue + { + public: + virtual void STDMETHODCALLTYPE AssertResourceAccess( + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_ACCESS Access) = 0; + + virtual void STDMETHODCALLTYPE AssertTextureLayout( + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_LAYOUT Layout) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugCommandQueue1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugCommandQueue1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugCommandQueue1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugCommandQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandQueue, AssertResourceState) + BOOL ( STDMETHODCALLTYPE *AssertResourceState )( + ID3D12DebugCommandQueue1 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandQueue1, AssertResourceAccess) + void ( STDMETHODCALLTYPE *AssertResourceAccess )( + ID3D12DebugCommandQueue1 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_ACCESS Access); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandQueue1, AssertTextureLayout) + void ( STDMETHODCALLTYPE *AssertTextureLayout )( + ID3D12DebugCommandQueue1 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_LAYOUT Layout); + + END_INTERFACE + } ID3D12DebugCommandQueue1Vtbl; + + interface ID3D12DebugCommandQueue1 + { + CONST_VTBL struct ID3D12DebugCommandQueue1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugCommandQueue1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugCommandQueue1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugCommandQueue1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugCommandQueue1_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->lpVtbl -> AssertResourceState(This,pResource,Subresource,State) ) + + +#define ID3D12DebugCommandQueue1_AssertResourceAccess(This,pResource,Subresource,Access) \ + ( (This)->lpVtbl -> AssertResourceAccess(This,pResource,Subresource,Access) ) + +#define ID3D12DebugCommandQueue1_AssertTextureLayout(This,pResource,Subresource,Layout) \ + ( (This)->lpVtbl -> AssertTextureLayout(This,pResource,Subresource,Layout) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugCommandQueue1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0012 */ +/* [local] */ + +typedef +enum D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE + { + D3D12_DEBUG_COMMAND_LIST_PARAMETER_GPU_BASED_VALIDATION_SETTINGS = 0 + } D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE; + +typedef struct D3D12_DEBUG_COMMAND_LIST_GPU_BASED_VALIDATION_SETTINGS + { + D3D12_GPU_BASED_VALIDATION_SHADER_PATCH_MODE ShaderPatchMode; + } D3D12_DEBUG_COMMAND_LIST_GPU_BASED_VALIDATION_SETTINGS; + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0012_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0012_v0_0_s_ifspec; + +#ifndef __ID3D12DebugCommandList1_INTERFACE_DEFINED__ +#define __ID3D12DebugCommandList1_INTERFACE_DEFINED__ + +/* interface ID3D12DebugCommandList1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugCommandList1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("102ca951-311b-4b01-b11f-ecb83e061b37") + ID3D12DebugCommandList1 : public IUnknown + { + public: + virtual BOOL STDMETHODCALLTYPE AssertResourceState( + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetDebugParameter( + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDebugParameter( + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugCommandList1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugCommandList1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugCommandList1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugCommandList1 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList1, AssertResourceState) + BOOL ( STDMETHODCALLTYPE *AssertResourceState )( + ID3D12DebugCommandList1 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList1, SetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *SetDebugParameter )( + ID3D12DebugCommandList1 * This, + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList1, GetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *GetDebugParameter )( + ID3D12DebugCommandList1 * This, + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize); + + END_INTERFACE + } ID3D12DebugCommandList1Vtbl; + + interface ID3D12DebugCommandList1 + { + CONST_VTBL struct ID3D12DebugCommandList1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugCommandList1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugCommandList1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugCommandList1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugCommandList1_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->lpVtbl -> AssertResourceState(This,pResource,Subresource,State) ) + +#define ID3D12DebugCommandList1_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> SetDebugParameter(This,Type,pData,DataSize) ) + +#define ID3D12DebugCommandList1_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> GetDebugParameter(This,Type,pData,DataSize) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugCommandList1_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandList_INTERFACE_DEFINED__ +#define __ID3D12DebugCommandList_INTERFACE_DEFINED__ + +/* interface ID3D12DebugCommandList */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugCommandList; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("09e0bf36-54ac-484f-8847-4baeeab6053f") + ID3D12DebugCommandList : public IUnknown + { + public: + virtual BOOL STDMETHODCALLTYPE AssertResourceState( + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetFeatureMask( + D3D12_DEBUG_FEATURE Mask) = 0; + + virtual D3D12_DEBUG_FEATURE STDMETHODCALLTYPE GetFeatureMask( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugCommandListVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugCommandList * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugCommandList * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugCommandList * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, AssertResourceState) + BOOL ( STDMETHODCALLTYPE *AssertResourceState )( + ID3D12DebugCommandList * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, SetFeatureMask) + HRESULT ( STDMETHODCALLTYPE *SetFeatureMask )( + ID3D12DebugCommandList * This, + D3D12_DEBUG_FEATURE Mask); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, GetFeatureMask) + D3D12_DEBUG_FEATURE ( STDMETHODCALLTYPE *GetFeatureMask )( + ID3D12DebugCommandList * This); + + END_INTERFACE + } ID3D12DebugCommandListVtbl; + + interface ID3D12DebugCommandList + { + CONST_VTBL struct ID3D12DebugCommandListVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugCommandList_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugCommandList_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugCommandList_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugCommandList_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->lpVtbl -> AssertResourceState(This,pResource,Subresource,State) ) + +#define ID3D12DebugCommandList_SetFeatureMask(This,Mask) \ + ( (This)->lpVtbl -> SetFeatureMask(This,Mask) ) + +#define ID3D12DebugCommandList_GetFeatureMask(This) \ + ( (This)->lpVtbl -> GetFeatureMask(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugCommandList_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandList2_INTERFACE_DEFINED__ +#define __ID3D12DebugCommandList2_INTERFACE_DEFINED__ + +/* interface ID3D12DebugCommandList2 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugCommandList2; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("aeb575cf-4e06-48be-ba3b-c450fc96652e") + ID3D12DebugCommandList2 : public ID3D12DebugCommandList + { + public: + virtual HRESULT STDMETHODCALLTYPE SetDebugParameter( + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetDebugParameter( + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugCommandList2Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugCommandList2 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugCommandList2 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugCommandList2 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, AssertResourceState) + BOOL ( STDMETHODCALLTYPE *AssertResourceState )( + ID3D12DebugCommandList2 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, SetFeatureMask) + HRESULT ( STDMETHODCALLTYPE *SetFeatureMask )( + ID3D12DebugCommandList2 * This, + D3D12_DEBUG_FEATURE Mask); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, GetFeatureMask) + D3D12_DEBUG_FEATURE ( STDMETHODCALLTYPE *GetFeatureMask )( + ID3D12DebugCommandList2 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList2, SetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *SetDebugParameter )( + ID3D12DebugCommandList2 * This, + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList2, GetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *GetDebugParameter )( + ID3D12DebugCommandList2 * This, + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize); + + END_INTERFACE + } ID3D12DebugCommandList2Vtbl; + + interface ID3D12DebugCommandList2 + { + CONST_VTBL struct ID3D12DebugCommandList2Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugCommandList2_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugCommandList2_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugCommandList2_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugCommandList2_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->lpVtbl -> AssertResourceState(This,pResource,Subresource,State) ) + +#define ID3D12DebugCommandList2_SetFeatureMask(This,Mask) \ + ( (This)->lpVtbl -> SetFeatureMask(This,Mask) ) + +#define ID3D12DebugCommandList2_GetFeatureMask(This) \ + ( (This)->lpVtbl -> GetFeatureMask(This) ) + + +#define ID3D12DebugCommandList2_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> SetDebugParameter(This,Type,pData,DataSize) ) + +#define ID3D12DebugCommandList2_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> GetDebugParameter(This,Type,pData,DataSize) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugCommandList2_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12DebugCommandList3_INTERFACE_DEFINED__ +#define __ID3D12DebugCommandList3_INTERFACE_DEFINED__ + +/* interface ID3D12DebugCommandList3 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12DebugCommandList3; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("197d5e15-4d37-4d34-af78-724cd70fdb1f") + ID3D12DebugCommandList3 : public ID3D12DebugCommandList2 + { + public: + virtual void STDMETHODCALLTYPE AssertResourceAccess( + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_ACCESS Access) = 0; + + virtual void STDMETHODCALLTYPE AssertTextureLayout( + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_LAYOUT Layout) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12DebugCommandList3Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12DebugCommandList3 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12DebugCommandList3 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12DebugCommandList3 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, AssertResourceState) + BOOL ( STDMETHODCALLTYPE *AssertResourceState )( + ID3D12DebugCommandList3 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + UINT State); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, SetFeatureMask) + HRESULT ( STDMETHODCALLTYPE *SetFeatureMask )( + ID3D12DebugCommandList3 * This, + D3D12_DEBUG_FEATURE Mask); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList, GetFeatureMask) + D3D12_DEBUG_FEATURE ( STDMETHODCALLTYPE *GetFeatureMask )( + ID3D12DebugCommandList3 * This); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList2, SetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *SetDebugParameter )( + ID3D12DebugCommandList3 * This, + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _In_reads_bytes_(DataSize) const void *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList2, GetDebugParameter) + HRESULT ( STDMETHODCALLTYPE *GetDebugParameter )( + ID3D12DebugCommandList3 * This, + D3D12_DEBUG_COMMAND_LIST_PARAMETER_TYPE Type, + _Out_writes_bytes_(DataSize) void *pData, + UINT DataSize); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList3, AssertResourceAccess) + void ( STDMETHODCALLTYPE *AssertResourceAccess )( + ID3D12DebugCommandList3 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_ACCESS Access); + + DECLSPEC_XFGVIRT(ID3D12DebugCommandList3, AssertTextureLayout) + void ( STDMETHODCALLTYPE *AssertTextureLayout )( + ID3D12DebugCommandList3 * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + D3D12_BARRIER_LAYOUT Layout); + + END_INTERFACE + } ID3D12DebugCommandList3Vtbl; + + interface ID3D12DebugCommandList3 + { + CONST_VTBL struct ID3D12DebugCommandList3Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12DebugCommandList3_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12DebugCommandList3_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12DebugCommandList3_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12DebugCommandList3_AssertResourceState(This,pResource,Subresource,State) \ + ( (This)->lpVtbl -> AssertResourceState(This,pResource,Subresource,State) ) + +#define ID3D12DebugCommandList3_SetFeatureMask(This,Mask) \ + ( (This)->lpVtbl -> SetFeatureMask(This,Mask) ) + +#define ID3D12DebugCommandList3_GetFeatureMask(This) \ + ( (This)->lpVtbl -> GetFeatureMask(This) ) + + +#define ID3D12DebugCommandList3_SetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> SetDebugParameter(This,Type,pData,DataSize) ) + +#define ID3D12DebugCommandList3_GetDebugParameter(This,Type,pData,DataSize) \ + ( (This)->lpVtbl -> GetDebugParameter(This,Type,pData,DataSize) ) + + +#define ID3D12DebugCommandList3_AssertResourceAccess(This,pResource,Subresource,Access) \ + ( (This)->lpVtbl -> AssertResourceAccess(This,pResource,Subresource,Access) ) + +#define ID3D12DebugCommandList3_AssertTextureLayout(This,pResource,Subresource,Layout) \ + ( (This)->lpVtbl -> AssertTextureLayout(This,pResource,Subresource,Layout) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12DebugCommandList3_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12SharingContract_INTERFACE_DEFINED__ +#define __ID3D12SharingContract_INTERFACE_DEFINED__ + +/* interface ID3D12SharingContract */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12SharingContract; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("0adf7d52-929c-4e61-addb-ffed30de66ef") + ID3D12SharingContract : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE Present( + _In_ ID3D12Resource *pResource, + UINT Subresource, + _In_ HWND window) = 0; + + virtual void STDMETHODCALLTYPE SharedFenceSignal( + _In_ ID3D12Fence *pFence, + UINT64 FenceValue) = 0; + + virtual void STDMETHODCALLTYPE BeginCapturableWork( + _In_ REFGUID guid) = 0; + + virtual void STDMETHODCALLTYPE EndCapturableWork( + _In_ REFGUID guid) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12SharingContractVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12SharingContract * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12SharingContract * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12SharingContract * This); + + DECLSPEC_XFGVIRT(ID3D12SharingContract, Present) + void ( STDMETHODCALLTYPE *Present )( + ID3D12SharingContract * This, + _In_ ID3D12Resource *pResource, + UINT Subresource, + _In_ HWND window); + + DECLSPEC_XFGVIRT(ID3D12SharingContract, SharedFenceSignal) + void ( STDMETHODCALLTYPE *SharedFenceSignal )( + ID3D12SharingContract * This, + _In_ ID3D12Fence *pFence, + UINT64 FenceValue); + + DECLSPEC_XFGVIRT(ID3D12SharingContract, BeginCapturableWork) + void ( STDMETHODCALLTYPE *BeginCapturableWork )( + ID3D12SharingContract * This, + _In_ REFGUID guid); + + DECLSPEC_XFGVIRT(ID3D12SharingContract, EndCapturableWork) + void ( STDMETHODCALLTYPE *EndCapturableWork )( + ID3D12SharingContract * This, + _In_ REFGUID guid); + + END_INTERFACE + } ID3D12SharingContractVtbl; + + interface ID3D12SharingContract + { + CONST_VTBL struct ID3D12SharingContractVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12SharingContract_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12SharingContract_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12SharingContract_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12SharingContract_Present(This,pResource,Subresource,window) \ + ( (This)->lpVtbl -> Present(This,pResource,Subresource,window) ) + +#define ID3D12SharingContract_SharedFenceSignal(This,pFence,FenceValue) \ + ( (This)->lpVtbl -> SharedFenceSignal(This,pFence,FenceValue) ) + +#define ID3D12SharingContract_BeginCapturableWork(This,guid) \ + ( (This)->lpVtbl -> BeginCapturableWork(This,guid) ) + +#define ID3D12SharingContract_EndCapturableWork(This,guid) \ + ( (This)->lpVtbl -> EndCapturableWork(This,guid) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12SharingContract_INTERFACE_DEFINED__ */ + + +#ifndef __ID3D12ManualWriteTrackingResource_INTERFACE_DEFINED__ +#define __ID3D12ManualWriteTrackingResource_INTERFACE_DEFINED__ + +/* interface ID3D12ManualWriteTrackingResource */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12ManualWriteTrackingResource; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("86ca3b85-49ad-4b6e-aed5-eddb18540f41") + ID3D12ManualWriteTrackingResource : public IUnknown + { + public: + virtual void STDMETHODCALLTYPE TrackWrite( + UINT Subresource, + _In_opt_ const D3D12_RANGE *pWrittenRange) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12ManualWriteTrackingResourceVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12ManualWriteTrackingResource * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12ManualWriteTrackingResource * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12ManualWriteTrackingResource * This); + + DECLSPEC_XFGVIRT(ID3D12ManualWriteTrackingResource, TrackWrite) + void ( STDMETHODCALLTYPE *TrackWrite )( + ID3D12ManualWriteTrackingResource * This, + UINT Subresource, + _In_opt_ const D3D12_RANGE *pWrittenRange); + + END_INTERFACE + } ID3D12ManualWriteTrackingResourceVtbl; + + interface ID3D12ManualWriteTrackingResource + { + CONST_VTBL struct ID3D12ManualWriteTrackingResourceVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12ManualWriteTrackingResource_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12ManualWriteTrackingResource_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12ManualWriteTrackingResource_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12ManualWriteTrackingResource_TrackWrite(This,Subresource,pWrittenRange) \ + ( (This)->lpVtbl -> TrackWrite(This,Subresource,pWrittenRange) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12ManualWriteTrackingResource_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0018 */ +/* [local] */ + +typedef +enum D3D12_MESSAGE_CATEGORY + { + D3D12_MESSAGE_CATEGORY_APPLICATION_DEFINED = 0, + D3D12_MESSAGE_CATEGORY_MISCELLANEOUS = ( D3D12_MESSAGE_CATEGORY_APPLICATION_DEFINED + 1 ) , + D3D12_MESSAGE_CATEGORY_INITIALIZATION = ( D3D12_MESSAGE_CATEGORY_MISCELLANEOUS + 1 ) , + D3D12_MESSAGE_CATEGORY_CLEANUP = ( D3D12_MESSAGE_CATEGORY_INITIALIZATION + 1 ) , + D3D12_MESSAGE_CATEGORY_COMPILATION = ( D3D12_MESSAGE_CATEGORY_CLEANUP + 1 ) , + D3D12_MESSAGE_CATEGORY_STATE_CREATION = ( D3D12_MESSAGE_CATEGORY_COMPILATION + 1 ) , + D3D12_MESSAGE_CATEGORY_STATE_SETTING = ( D3D12_MESSAGE_CATEGORY_STATE_CREATION + 1 ) , + D3D12_MESSAGE_CATEGORY_STATE_GETTING = ( D3D12_MESSAGE_CATEGORY_STATE_SETTING + 1 ) , + D3D12_MESSAGE_CATEGORY_RESOURCE_MANIPULATION = ( D3D12_MESSAGE_CATEGORY_STATE_GETTING + 1 ) , + D3D12_MESSAGE_CATEGORY_EXECUTION = ( D3D12_MESSAGE_CATEGORY_RESOURCE_MANIPULATION + 1 ) , + D3D12_MESSAGE_CATEGORY_SHADER = ( D3D12_MESSAGE_CATEGORY_EXECUTION + 1 ) + } D3D12_MESSAGE_CATEGORY; + +typedef +enum D3D12_MESSAGE_SEVERITY + { + D3D12_MESSAGE_SEVERITY_CORRUPTION = 0, + D3D12_MESSAGE_SEVERITY_ERROR = ( D3D12_MESSAGE_SEVERITY_CORRUPTION + 1 ) , + D3D12_MESSAGE_SEVERITY_WARNING = ( D3D12_MESSAGE_SEVERITY_ERROR + 1 ) , + D3D12_MESSAGE_SEVERITY_INFO = ( D3D12_MESSAGE_SEVERITY_WARNING + 1 ) , + D3D12_MESSAGE_SEVERITY_MESSAGE = ( D3D12_MESSAGE_SEVERITY_INFO + 1 ) + } D3D12_MESSAGE_SEVERITY; + +typedef +enum D3D12_MESSAGE_ID + { + D3D12_MESSAGE_ID_UNKNOWN = 0, + D3D12_MESSAGE_ID_STRING_FROM_APPLICATION = 1, + D3D12_MESSAGE_ID_CORRUPTED_THIS = 2, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER1 = 3, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER2 = 4, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER3 = 5, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER4 = 6, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER5 = 7, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER6 = 8, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER7 = 9, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER8 = 10, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER9 = 11, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER10 = 12, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER11 = 13, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER12 = 14, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER13 = 15, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER14 = 16, + D3D12_MESSAGE_ID_CORRUPTED_PARAMETER15 = 17, + D3D12_MESSAGE_ID_CORRUPTED_MULTITHREADING = 18, + D3D12_MESSAGE_ID_MESSAGE_REPORTING_OUTOFMEMORY = 19, + D3D12_MESSAGE_ID_GETPRIVATEDATA_MOREDATA = 20, + D3D12_MESSAGE_ID_SETPRIVATEDATA_INVALIDFREEDATA = 21, + D3D12_MESSAGE_ID_SETPRIVATEDATA_CHANGINGPARAMS = 24, + D3D12_MESSAGE_ID_SETPRIVATEDATA_OUTOFMEMORY = 25, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_UNRECOGNIZEDFORMAT = 26, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDESC = 27, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDFORMAT = 28, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDVIDEOPLANESLICE = 29, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDPLANESLICE = 30, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDDIMENSIONS = 31, + D3D12_MESSAGE_ID_CREATESHADERRESOURCEVIEW_INVALIDRESOURCE = 32, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_UNRECOGNIZEDFORMAT = 35, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_UNSUPPORTEDFORMAT = 36, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDESC = 37, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDFORMAT = 38, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDVIDEOPLANESLICE = 39, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDPLANESLICE = 40, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDDIMENSIONS = 41, + D3D12_MESSAGE_ID_CREATERENDERTARGETVIEW_INVALIDRESOURCE = 42, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_UNRECOGNIZEDFORMAT = 45, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDESC = 46, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFORMAT = 47, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDDIMENSIONS = 48, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDRESOURCE = 49, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_OUTOFMEMORY = 52, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TOOMANYELEMENTS = 53, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDFORMAT = 54, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INCOMPATIBLEFORMAT = 55, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOT = 56, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDINPUTSLOTCLASS = 57, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_STEPRATESLOTCLASSMISMATCH = 58, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSLOTCLASSCHANGE = 59, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDSTEPRATECHANGE = 60, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_INVALIDALIGNMENT = 61, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_DUPLICATESEMANTIC = 62, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_UNPARSEABLEINPUTSIGNATURE = 63, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_NULLSEMANTIC = 64, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_MISSINGELEMENT = 65, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_OUTOFMEMORY = 66, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERBYTECODE = 67, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDSHADERTYPE = 68, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_OUTOFMEMORY = 69, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERBYTECODE = 70, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDSHADERTYPE = 71, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTOFMEMORY = 72, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERBYTECODE = 73, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE = 74, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMENTRIES = 75, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSTREAMSTRIDEUNUSED = 76, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_OUTPUTSLOT0EXPECTED = 79, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSLOT = 80, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_ONLYONEELEMENTPERSLOT = 81, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDCOMPONENTCOUNT = 82, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTARTCOMPONENTANDCOMPONENTCOUNT = 83, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDGAPDEFINITION = 84, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_REPEATEDOUTPUT = 85, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDOUTPUTSTREAMSTRIDE = 86, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGSEMANTIC = 87, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MASKMISMATCH = 88, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_CANTHAVEONLYGAPS = 89, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DECLTOOCOMPLEX = 90, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_MISSINGOUTPUTSIGNATURE = 91, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_OUTOFMEMORY = 92, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERBYTECODE = 93, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDSHADERTYPE = 94, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFILLMODE = 95, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDCULLMODE = 96, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDDEPTHBIASCLAMP = 97, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDSLOPESCALEDDEPTHBIAS = 98, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHWRITEMASK = 100, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDDEPTHFUNC = 101, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFAILOP = 102, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILZFAILOP = 103, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILPASSOP = 104, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDFRONTFACESTENCILFUNC = 105, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFAILOP = 106, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILZFAILOP = 107, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILPASSOP = 108, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INVALIDBACKFACESTENCILFUNC = 109, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLEND = 111, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLEND = 112, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOP = 113, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDSRCBLENDALPHA = 114, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDDESTBLENDALPHA = 115, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDBLENDOPALPHA = 116, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDRENDERTARGETWRITEMASK = 117, + D3D12_MESSAGE_ID_GET_PROGRAM_IDENTIFIER_ERROR = 118, + D3D12_MESSAGE_ID_GET_WORK_GRAPH_PROPERTIES_ERROR = 119, + D3D12_MESSAGE_ID_SET_PROGRAM_ERROR = 120, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_INVALID = 135, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_ROOT_SIGNATURE_NOT_SET = 200, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_ROOT_SIGNATURE_MISMATCH = 201, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_NOT_SET = 202, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_STRIDE_TOO_SMALL = 209, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_BUFFER_TOO_SMALL = 210, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_NOT_SET = 211, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_FORMAT_INVALID = 212, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_BUFFER_TOO_SMALL = 213, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INVALID_PRIMITIVETOPOLOGY = 219, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_VERTEX_STRIDE_UNALIGNED = 221, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INDEX_OFFSET_UNALIGNED = 222, + D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_AT_FAULT = 232, + D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_POSSIBLY_AT_FAULT = 233, + D3D12_MESSAGE_ID_DEVICE_REMOVAL_PROCESS_NOT_AT_FAULT = 234, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TRAILING_DIGIT_IN_SEMANTIC = 239, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_TRAILING_DIGIT_IN_SEMANTIC = 240, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_TYPE_MISMATCH = 245, + D3D12_MESSAGE_ID_CREATEINPUTLAYOUT_EMPTY_LAYOUT = 253, + D3D12_MESSAGE_ID_LIVE_OBJECT_SUMMARY = 255, + D3D12_MESSAGE_ID_LIVE_DEVICE = 274, + D3D12_MESSAGE_ID_LIVE_SWAPCHAIN = 275, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILVIEW_INVALIDFLAGS = 276, + D3D12_MESSAGE_ID_CREATEVERTEXSHADER_INVALIDCLASSLINKAGE = 277, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADER_INVALIDCLASSLINKAGE = 278, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAMTORASTERIZER = 280, + D3D12_MESSAGE_ID_CREATEPIXELSHADER_INVALIDCLASSLINKAGE = 283, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDSTREAM = 284, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDENTRIES = 285, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UNEXPECTEDSTRIDES = 286, + D3D12_MESSAGE_ID_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_INVALIDNUMSTRIDES = 287, + D3D12_MESSAGE_ID_CREATEHULLSHADER_OUTOFMEMORY = 289, + D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERBYTECODE = 290, + D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDSHADERTYPE = 291, + D3D12_MESSAGE_ID_CREATEHULLSHADER_INVALIDCLASSLINKAGE = 292, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_OUTOFMEMORY = 294, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERBYTECODE = 295, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDSHADERTYPE = 296, + D3D12_MESSAGE_ID_CREATEDOMAINSHADER_INVALIDCLASSLINKAGE = 297, + D3D12_MESSAGE_ID_RESOURCE_UNMAP_NOTMAPPED = 310, + D3D12_MESSAGE_ID_DEVICE_CHECKFEATURESUPPORT_MISMATCHED_DATA_SIZE = 318, + D3D12_MESSAGE_ID_CREATECOMPUTESHADER_OUTOFMEMORY = 321, + D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDSHADERBYTECODE = 322, + D3D12_MESSAGE_ID_CREATECOMPUTESHADER_INVALIDCLASSLINKAGE = 323, + D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 331, + D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 332, + D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 333, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 334, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEFLOATOPSNOTSUPPORTED = 335, + D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEFLOATOPSNOTSUPPORTED = 336, + D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEFLOATOPSNOTSUPPORTED = 337, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDRESOURCE = 340, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDESC = 341, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFORMAT = 342, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDVIDEOPLANESLICE = 343, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDPLANESLICE = 344, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDDIMENSIONS = 345, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_UNRECOGNIZEDFORMAT = 346, + D3D12_MESSAGE_ID_CREATEUNORDEREDACCESSVIEW_INVALIDFLAGS = 354, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALIDFORCEDSAMPLECOUNT = 401, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_INVALIDLOGICOPS = 403, + D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 410, + D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 412, + D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 414, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 416, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_DOUBLEEXTENSIONSNOTSUPPORTED = 418, + D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 420, + D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_DOUBLEEXTENSIONSNOTSUPPORTED = 422, + D3D12_MESSAGE_ID_DEVICE_CREATEVERTEXSHADER_UAVSNOTSUPPORTED = 425, + D3D12_MESSAGE_ID_DEVICE_CREATEHULLSHADER_UAVSNOTSUPPORTED = 426, + D3D12_MESSAGE_ID_DEVICE_CREATEDOMAINSHADER_UAVSNOTSUPPORTED = 427, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADER_UAVSNOTSUPPORTED = 428, + D3D12_MESSAGE_ID_DEVICE_CREATEGEOMETRYSHADERWITHSTREAMOUTPUT_UAVSNOTSUPPORTED = 429, + D3D12_MESSAGE_ID_DEVICE_CREATEPIXELSHADER_UAVSNOTSUPPORTED = 430, + D3D12_MESSAGE_ID_DEVICE_CREATECOMPUTESHADER_UAVSNOTSUPPORTED = 431, + D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_INVALIDSOURCERECT = 447, + D3D12_MESSAGE_ID_DEVICE_CLEARVIEW_EMPTYRECT = 448, + D3D12_MESSAGE_ID_UPDATETILEMAPPINGS_INVALID_PARAMETER = 493, + D3D12_MESSAGE_ID_COPYTILEMAPPINGS_INVALID_PARAMETER = 494, + D3D12_MESSAGE_ID_CREATEDEVICE_INVALIDARGS = 506, + D3D12_MESSAGE_ID_CREATEDEVICE_WARNING = 507, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_TYPE = 519, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_NULL_POINTER = 520, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_SUBRESOURCE = 521, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_RESERVED_BITS = 522, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISSING_BIND_FLAGS = 523, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_MISC_FLAGS = 524, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MATCHING_STATES = 525, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMBINATION = 526, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_BEFORE_AFTER_MISMATCH = 527, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_RESOURCE = 528, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_SAMPLE_COUNT = 529, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAGS = 530, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMBINED_FLAGS = 531, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAGS_FOR_FORMAT = 532, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_SPLIT_BARRIER = 533, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_UNMATCHED_END = 534, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_UNMATCHED_BEGIN = 535, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_FLAG = 536, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_COMMAND_LIST_TYPE = 537, + D3D12_MESSAGE_ID_INVALID_SUBRESOURCE_STATE = 538, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_CONTENTION = 540, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_RESET = 541, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_RESET_BUNDLE = 542, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_CANNOT_RESET = 543, + D3D12_MESSAGE_ID_COMMAND_LIST_OPEN = 544, + D3D12_MESSAGE_ID_INVALID_BUNDLE_API = 546, + D3D12_MESSAGE_ID_COMMAND_LIST_CLOSED = 547, + D3D12_MESSAGE_ID_WRONG_COMMAND_ALLOCATOR_TYPE = 549, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_SYNC = 552, + D3D12_MESSAGE_ID_COMMAND_LIST_SYNC = 553, + D3D12_MESSAGE_ID_SET_DESCRIPTOR_HEAP_INVALID = 554, + D3D12_MESSAGE_ID_CREATE_COMMANDQUEUE = 557, + D3D12_MESSAGE_ID_CREATE_COMMANDALLOCATOR = 558, + D3D12_MESSAGE_ID_CREATE_PIPELINESTATE = 559, + D3D12_MESSAGE_ID_CREATE_COMMANDLIST12 = 560, + D3D12_MESSAGE_ID_CREATE_RESOURCE = 562, + D3D12_MESSAGE_ID_CREATE_DESCRIPTORHEAP = 563, + D3D12_MESSAGE_ID_CREATE_ROOTSIGNATURE = 564, + D3D12_MESSAGE_ID_CREATE_LIBRARY = 565, + D3D12_MESSAGE_ID_CREATE_HEAP = 566, + D3D12_MESSAGE_ID_CREATE_MONITOREDFENCE = 567, + D3D12_MESSAGE_ID_CREATE_QUERYHEAP = 568, + D3D12_MESSAGE_ID_CREATE_COMMANDSIGNATURE = 569, + D3D12_MESSAGE_ID_LIVE_COMMANDQUEUE = 570, + D3D12_MESSAGE_ID_LIVE_COMMANDALLOCATOR = 571, + D3D12_MESSAGE_ID_LIVE_PIPELINESTATE = 572, + D3D12_MESSAGE_ID_LIVE_COMMANDLIST12 = 573, + D3D12_MESSAGE_ID_LIVE_RESOURCE = 575, + D3D12_MESSAGE_ID_LIVE_DESCRIPTORHEAP = 576, + D3D12_MESSAGE_ID_LIVE_ROOTSIGNATURE = 577, + D3D12_MESSAGE_ID_LIVE_LIBRARY = 578, + D3D12_MESSAGE_ID_LIVE_HEAP = 579, + D3D12_MESSAGE_ID_LIVE_MONITOREDFENCE = 580, + D3D12_MESSAGE_ID_LIVE_QUERYHEAP = 581, + D3D12_MESSAGE_ID_LIVE_COMMANDSIGNATURE = 582, + D3D12_MESSAGE_ID_DESTROY_COMMANDQUEUE = 583, + D3D12_MESSAGE_ID_DESTROY_COMMANDALLOCATOR = 584, + D3D12_MESSAGE_ID_DESTROY_PIPELINESTATE = 585, + D3D12_MESSAGE_ID_DESTROY_COMMANDLIST12 = 586, + D3D12_MESSAGE_ID_DESTROY_RESOURCE = 588, + D3D12_MESSAGE_ID_DESTROY_DESCRIPTORHEAP = 589, + D3D12_MESSAGE_ID_DESTROY_ROOTSIGNATURE = 590, + D3D12_MESSAGE_ID_DESTROY_LIBRARY = 591, + D3D12_MESSAGE_ID_DESTROY_HEAP = 592, + D3D12_MESSAGE_ID_DESTROY_MONITOREDFENCE = 593, + D3D12_MESSAGE_ID_DESTROY_QUERYHEAP = 594, + D3D12_MESSAGE_ID_DESTROY_COMMANDSIGNATURE = 595, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDIMENSIONS = 597, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMISCFLAGS = 599, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDARG_RETURN = 602, + D3D12_MESSAGE_ID_CREATERESOURCE_OUTOFMEMORY_RETURN = 603, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDESC = 604, + D3D12_MESSAGE_ID_POSSIBLY_INVALID_SUBRESOURCE_STATE = 607, + D3D12_MESSAGE_ID_INVALID_USE_OF_NON_RESIDENT_RESOURCE = 608, + D3D12_MESSAGE_ID_POSSIBLE_INVALID_USE_OF_NON_RESIDENT_RESOURCE = 609, + D3D12_MESSAGE_ID_BUNDLE_PIPELINE_STATE_MISMATCH = 610, + D3D12_MESSAGE_ID_PRIMITIVE_TOPOLOGY_MISMATCH_PIPELINE_STATE = 611, + D3D12_MESSAGE_ID_RENDER_TARGET_FORMAT_MISMATCH_PIPELINE_STATE = 613, + D3D12_MESSAGE_ID_RENDER_TARGET_SAMPLE_DESC_MISMATCH_PIPELINE_STATE = 614, + D3D12_MESSAGE_ID_DEPTH_STENCIL_FORMAT_MISMATCH_PIPELINE_STATE = 615, + D3D12_MESSAGE_ID_DEPTH_STENCIL_SAMPLE_DESC_MISMATCH_PIPELINE_STATE = 616, + D3D12_MESSAGE_ID_CREATESHADER_INVALIDBYTECODE = 622, + D3D12_MESSAGE_ID_CREATEHEAP_NULLDESC = 623, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDSIZE = 624, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDHEAPTYPE = 625, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDCPUPAGEPROPERTIES = 626, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDMEMORYPOOL = 627, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDPROPERTIES = 628, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDALIGNMENT = 629, + D3D12_MESSAGE_ID_CREATEHEAP_UNRECOGNIZEDMISCFLAGS = 630, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDMISCFLAGS = 631, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDARG_RETURN = 632, + D3D12_MESSAGE_ID_CREATEHEAP_OUTOFMEMORY_RETURN = 633, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLHEAPPROPERTIES = 634, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDHEAPTYPE = 635, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDCPUPAGEPROPERTIES = 636, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDMEMORYPOOL = 637, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDHEAPPROPERTIES = 638, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_UNRECOGNIZEDHEAPMISCFLAGS = 639, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDHEAPMISCFLAGS = 640, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDARG_RETURN = 641, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_OUTOFMEMORY_RETURN = 642, + D3D12_MESSAGE_ID_GETCUSTOMHEAPPROPERTIES_UNRECOGNIZEDHEAPTYPE = 643, + D3D12_MESSAGE_ID_GETCUSTOMHEAPPROPERTIES_INVALIDHEAPTYPE = 644, + D3D12_MESSAGE_ID_CREATE_DESCRIPTOR_HEAP_INVALID_DESC = 645, + D3D12_MESSAGE_ID_INVALID_DESCRIPTOR_HANDLE = 646, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALID_CONSERVATIVERASTERMODE = 647, + D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_INVALID_RESOURCE = 649, + D3D12_MESSAGE_ID_CREATE_CONSTANT_BUFFER_VIEW_INVALID_DESC = 650, + D3D12_MESSAGE_ID_CREATE_UNORDEREDACCESS_VIEW_INVALID_COUNTER_USAGE = 652, + D3D12_MESSAGE_ID_COPY_DESCRIPTORS_INVALID_RANGES = 653, + D3D12_MESSAGE_ID_COPY_DESCRIPTORS_WRITE_ONLY_DESCRIPTOR = 654, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RTV_FORMAT_NOT_UNKNOWN = 655, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_RENDER_TARGET_COUNT = 656, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_VERTEX_SHADER_NOT_SET = 657, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INPUTLAYOUT_NOT_SET = 658, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_HS_DS_SIGNATURE_MISMATCH = 659, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGISTERINDEX = 660, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_COMPONENTTYPE = 661, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_REGISTERMASK = 662, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_SYSTEMVALUE = 663, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_NEVERWRITTEN_ALWAYSREADS = 664, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_MINPRECISION = 665, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND = 666, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_XOR_DS_MISMATCH = 667, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HULL_SHADER_INPUT_TOPOLOGY_MISMATCH = 668, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_DS_CONTROL_POINT_COUNT_MISMATCH = 669, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_DS_TESSELLATOR_DOMAIN_MISMATCH = 670, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_USE_OF_CENTER_MULTISAMPLE_PATTERN = 671, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_USE_OF_FORCED_SAMPLE_COUNT = 672, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_PRIMITIVETOPOLOGY = 673, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_SYSTEMVALUE = 674, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_DUAL_SOURCE_BLENDING_CAN_ONLY_HAVE_RENDER_TARGET_0 = 675, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_RENDER_TARGET_DOES_NOT_SUPPORT_BLENDING = 676, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_OUTPUT_TYPE_MISMATCH = 677, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_OM_RENDER_TARGET_DOES_NOT_SUPPORT_LOGIC_OPS = 678, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDERTARGETVIEW_NOT_SET = 679, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DEPTHSTENCILVIEW_NOT_SET = 680, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_GS_INPUT_PRIMITIVE_MISMATCH = 681, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_POSITION_NOT_PRESENT = 682, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MISSING_ROOT_SIGNATURE_FLAGS = 683, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_INDEX_BUFFER_PROPERTIES = 684, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INVALID_SAMPLE_DESC = 685, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_HS_ROOT_SIGNATURE_MISMATCH = 686, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_DS_ROOT_SIGNATURE_MISMATCH = 687, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_VS_ROOT_SIGNATURE_MISMATCH = 688, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_GS_ROOT_SIGNATURE_MISMATCH = 689, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_ROOT_SIGNATURE_MISMATCH = 690, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MISSING_ROOT_SIGNATURE = 691, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_OPEN_BUNDLE = 692, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_DESCRIPTOR_HEAP_MISMATCH = 693, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_TYPE = 694, + D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE = 695, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_BLOB_NOT_FOUND = 696, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_DESERIALIZE_FAILED = 697, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_INVALID_CONFIGURATION = 698, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_NOT_SUPPORTED_ON_DEVICE = 699, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLRESOURCEPROPERTIES = 700, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_NULLHEAP = 701, + D3D12_MESSAGE_ID_GETRESOURCEALLOCATIONINFO_INVALIDRDESCS = 702, + D3D12_MESSAGE_ID_MAKERESIDENT_NULLOBJECTARRAY = 703, + D3D12_MESSAGE_ID_EVICT_NULLOBJECTARRAY = 705, + D3D12_MESSAGE_ID_SET_DESCRIPTOR_TABLE_INVALID = 708, + D3D12_MESSAGE_ID_SET_ROOT_CONSTANT_INVALID = 709, + D3D12_MESSAGE_ID_SET_ROOT_CONSTANT_BUFFER_VIEW_INVALID = 710, + D3D12_MESSAGE_ID_SET_ROOT_SHADER_RESOURCE_VIEW_INVALID = 711, + D3D12_MESSAGE_ID_SET_ROOT_UNORDERED_ACCESS_VIEW_INVALID = 712, + D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_INVALID_DESC = 713, + D3D12_MESSAGE_ID_SET_INDEX_BUFFER_INVALID_DESC = 715, + D3D12_MESSAGE_ID_SET_STREAM_OUTPUT_BUFFERS_INVALID_DESC = 717, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDDIMENSIONALITY = 718, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDLAYOUT = 719, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDDIMENSIONALITY = 720, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDALIGNMENT = 721, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDMIPLEVELS = 722, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDSAMPLEDESC = 723, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDLAYOUT = 724, + D3D12_MESSAGE_ID_SET_INDEX_BUFFER_INVALID = 725, + D3D12_MESSAGE_ID_SET_VERTEX_BUFFERS_INVALID = 726, + D3D12_MESSAGE_ID_SET_STREAM_OUTPUT_BUFFERS_INVALID = 727, + D3D12_MESSAGE_ID_SET_RENDER_TARGETS_INVALID = 728, + D3D12_MESSAGE_ID_CREATEQUERY_HEAP_INVALID_PARAMETERS = 729, + D3D12_MESSAGE_ID_BEGIN_END_QUERY_INVALID_PARAMETERS = 731, + D3D12_MESSAGE_ID_CLOSE_COMMAND_LIST_OPEN_QUERY = 732, + D3D12_MESSAGE_ID_RESOLVE_QUERY_DATA_INVALID_PARAMETERS = 733, + D3D12_MESSAGE_ID_SET_PREDICATION_INVALID_PARAMETERS = 734, + D3D12_MESSAGE_ID_TIMESTAMPS_NOT_SUPPORTED = 735, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDFORMAT = 737, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDFORMAT = 738, + D3D12_MESSAGE_ID_GETCOPYABLEFOOTPRINTS_INVALIDSUBRESOURCERANGE = 739, + D3D12_MESSAGE_ID_GETCOPYABLEFOOTPRINTS_INVALIDBASEOFFSET = 740, + D3D12_MESSAGE_ID_GETCOPYABLELAYOUT_INVALIDSUBRESOURCERANGE = 739, + D3D12_MESSAGE_ID_GETCOPYABLELAYOUT_INVALIDBASEOFFSET = 740, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_INVALID_HEAP = 741, + D3D12_MESSAGE_ID_CREATE_SAMPLER_INVALID = 742, + D3D12_MESSAGE_ID_CREATECOMMANDSIGNATURE_INVALID = 743, + D3D12_MESSAGE_ID_EXECUTE_INDIRECT_INVALID_PARAMETERS = 744, + D3D12_MESSAGE_ID_GETGPUVIRTUALADDRESS_INVALID_RESOURCE_DIMENSION = 745, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUE = 815, + D3D12_MESSAGE_ID_CREATERESOURCE_UNRECOGNIZEDCLEARVALUEFORMAT = 816, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDCLEARVALUEFORMAT = 817, + D3D12_MESSAGE_ID_CREATERESOURCE_CLEARVALUEDENORMFLUSH = 818, + D3D12_MESSAGE_ID_CLEARRENDERTARGETVIEW_MISMATCHINGCLEARVALUE = 820, + D3D12_MESSAGE_ID_CLEARDEPTHSTENCILVIEW_MISMATCHINGCLEARVALUE = 821, + D3D12_MESSAGE_ID_MAP_INVALIDHEAP = 822, + D3D12_MESSAGE_ID_UNMAP_INVALIDHEAP = 823, + D3D12_MESSAGE_ID_MAP_INVALIDRESOURCE = 824, + D3D12_MESSAGE_ID_UNMAP_INVALIDRESOURCE = 825, + D3D12_MESSAGE_ID_MAP_INVALIDSUBRESOURCE = 826, + D3D12_MESSAGE_ID_UNMAP_INVALIDSUBRESOURCE = 827, + D3D12_MESSAGE_ID_MAP_INVALIDRANGE = 828, + D3D12_MESSAGE_ID_UNMAP_INVALIDRANGE = 829, + D3D12_MESSAGE_ID_MAP_INVALIDDATAPOINTER = 832, + D3D12_MESSAGE_ID_MAP_INVALIDARG_RETURN = 833, + D3D12_MESSAGE_ID_MAP_OUTOFMEMORY_RETURN = 834, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_BUNDLENOTSUPPORTED = 835, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_COMMANDLISTMISMATCH = 836, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_OPENCOMMANDLIST = 837, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_FAILEDCOMMANDLIST = 838, + D3D12_MESSAGE_ID_COPYBUFFERREGION_NULLDST = 839, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDDSTRESOURCEDIMENSION = 840, + D3D12_MESSAGE_ID_COPYBUFFERREGION_DSTRANGEOUTOFBOUNDS = 841, + D3D12_MESSAGE_ID_COPYBUFFERREGION_NULLSRC = 842, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDSRCRESOURCEDIMENSION = 843, + D3D12_MESSAGE_ID_COPYBUFFERREGION_SRCRANGEOUTOFBOUNDS = 844, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALIDCOPYFLAGS = 845, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_NULLDST = 846, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDDSTTYPE = 847, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTRESOURCEDIMENSION = 848, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTRESOURCE = 849, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTSUBRESOURCE = 850, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTOFFSET = 851, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDDSTFORMAT = 852, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTFORMAT = 853, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTDIMENSIONS = 854, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTROWPITCH = 855, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTPLACEMENT = 856, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTDSPLACEDFOOTPRINTFORMAT = 857, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_DSTREGIONOUTOFBOUNDS = 858, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_NULLSRC = 859, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDSRCTYPE = 860, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCRESOURCEDIMENSION = 861, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCRESOURCE = 862, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCSUBRESOURCE = 863, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCOFFSET = 864, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_UNRECOGNIZEDSRCFORMAT = 865, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCFORMAT = 866, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCDIMENSIONS = 867, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCROWPITCH = 868, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCPLACEMENT = 869, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCDSPLACEDFOOTPRINTFORMAT = 870, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_SRCREGIONOUTOFBOUNDS = 871, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDDSTCOORDINATES = 872, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDSRCBOX = 873, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_FORMATMISMATCH = 874, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_EMPTYBOX = 875, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_INVALIDCOPYFLAGS = 876, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_SUBRESOURCE_INDEX = 877, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_FORMAT = 878, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_RESOURCE_MISMATCH = 879, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALID_SAMPLE_COUNT = 880, + D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_INVALID_SHADER = 881, + D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_CS_ROOT_SIGNATURE_MISMATCH = 882, + D3D12_MESSAGE_ID_CREATECOMPUTEPIPELINESTATE_MISSING_ROOT_SIGNATURE = 883, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALIDCACHEDBLOB = 884, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBADAPTERMISMATCH = 885, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBDRIVERVERSIONMISMATCH = 886, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBDESCMISMATCH = 887, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CACHEDBLOBIGNORED = 888, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDHEAP = 889, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDRESOURCE = 890, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDBOX = 891, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_INVALIDSUBRESOURCE = 892, + D3D12_MESSAGE_ID_WRITETOSUBRESOURCE_EMPTYBOX = 893, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDHEAP = 894, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDRESOURCE = 895, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDBOX = 896, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_INVALIDSUBRESOURCE = 897, + D3D12_MESSAGE_ID_READFROMSUBRESOURCE_EMPTYBOX = 898, + D3D12_MESSAGE_ID_TOO_MANY_NODES_SPECIFIED = 899, + D3D12_MESSAGE_ID_INVALID_NODE_INDEX = 900, + D3D12_MESSAGE_ID_GETHEAPPROPERTIES_INVALIDRESOURCE = 901, + D3D12_MESSAGE_ID_NODE_MASK_MISMATCH = 902, + D3D12_MESSAGE_ID_COMMAND_LIST_OUTOFMEMORY = 903, + D3D12_MESSAGE_ID_COMMAND_LIST_MULTIPLE_SWAPCHAIN_BUFFER_REFERENCES = 904, + D3D12_MESSAGE_ID_COMMAND_LIST_TOO_MANY_SWAPCHAIN_REFERENCES = 905, + D3D12_MESSAGE_ID_COMMAND_QUEUE_TOO_MANY_SWAPCHAIN_REFERENCES = 906, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_WRONGSWAPCHAINBUFFERREFERENCE = 907, + D3D12_MESSAGE_ID_COMMAND_LIST_SETRENDERTARGETS_INVALIDNUMRENDERTARGETS = 908, + D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_TYPE = 909, + D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_FLAGS = 910, + D3D12_MESSAGE_ID_CREATESHAREDRESOURCE_INVALIDFLAGS = 911, + D3D12_MESSAGE_ID_CREATESHAREDRESOURCE_INVALIDFORMAT = 912, + D3D12_MESSAGE_ID_CREATESHAREDHEAP_INVALIDFLAGS = 913, + D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_UNRECOGNIZEDPROPERTIES = 914, + D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_INVALIDSIZE = 915, + D3D12_MESSAGE_ID_REFLECTSHAREDPROPERTIES_INVALIDOBJECT = 916, + D3D12_MESSAGE_ID_KEYEDMUTEX_INVALIDOBJECT = 917, + D3D12_MESSAGE_ID_KEYEDMUTEX_INVALIDKEY = 918, + D3D12_MESSAGE_ID_KEYEDMUTEX_WRONGSTATE = 919, + D3D12_MESSAGE_ID_CREATE_QUEUE_INVALID_PRIORITY = 920, + D3D12_MESSAGE_ID_OBJECT_DELETED_WHILE_STILL_IN_USE = 921, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALID_FLAGS = 922, + D3D12_MESSAGE_ID_HEAP_ADDRESS_RANGE_HAS_NO_RESOURCE = 923, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_RENDER_TARGET_DELETED = 924, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_ALL_RENDER_TARGETS_HAVE_UNKNOWN_FORMAT = 925, + D3D12_MESSAGE_ID_HEAP_ADDRESS_RANGE_INTERSECTS_MULTIPLE_BUFFERS = 926, + D3D12_MESSAGE_ID_EXECUTECOMMANDLISTS_GPU_WRITTEN_READBACK_RESOURCE_MAPPED = 927, + D3D12_MESSAGE_ID_UNMAP_RANGE_NOT_EMPTY = 929, + D3D12_MESSAGE_ID_MAP_INVALID_NULLRANGE = 930, + D3D12_MESSAGE_ID_UNMAP_INVALID_NULLRANGE = 931, + D3D12_MESSAGE_ID_NO_GRAPHICS_API_SUPPORT = 932, + D3D12_MESSAGE_ID_NO_COMPUTE_API_SUPPORT = 933, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_RESOURCE_FLAGS_NOT_SUPPORTED = 934, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_ROOT_ARGUMENT_UNINITIALIZED = 935, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_HEAP_INDEX_OUT_OF_BOUNDS = 936, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_TABLE_REGISTER_INDEX_OUT_OF_BOUNDS = 937, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_UNINITIALIZED = 938, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_DESCRIPTOR_TYPE_MISMATCH = 939, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_SRV_RESOURCE_DIMENSION_MISMATCH = 940, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_UAV_RESOURCE_DIMENSION_MISMATCH = 941, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_INCOMPATIBLE_RESOURCE_STATE = 942, + D3D12_MESSAGE_ID_COPYRESOURCE_NULLDST = 943, + D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDDSTRESOURCE = 944, + D3D12_MESSAGE_ID_COPYRESOURCE_NULLSRC = 945, + D3D12_MESSAGE_ID_COPYRESOURCE_INVALIDSRCRESOURCE = 946, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_NULLDST = 947, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALIDDSTRESOURCE = 948, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_NULLSRC = 949, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_INVALIDSRCRESOURCE = 950, + D3D12_MESSAGE_ID_PIPELINE_STATE_TYPE_MISMATCH = 951, + D3D12_MESSAGE_ID_COMMAND_LIST_DISPATCH_ROOT_SIGNATURE_NOT_SET = 952, + D3D12_MESSAGE_ID_COMMAND_LIST_DISPATCH_ROOT_SIGNATURE_MISMATCH = 953, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_ZERO_BARRIERS = 954, + D3D12_MESSAGE_ID_BEGIN_END_EVENT_MISMATCH = 955, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_POSSIBLE_BEFORE_AFTER_MISMATCH = 956, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_BEGIN_END = 957, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_INVALID_RESOURCE = 958, + D3D12_MESSAGE_ID_USE_OF_ZERO_REFCOUNT_OBJECT = 959, + D3D12_MESSAGE_ID_OBJECT_EVICTED_WHILE_STILL_IN_USE = 960, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_ROOT_DESCRIPTOR_ACCESS_OUT_OF_BOUNDS = 961, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_INVALIDLIBRARYBLOB = 962, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_DRIVERVERSIONMISMATCH = 963, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_ADAPTERVERSIONMISMATCH = 964, + D3D12_MESSAGE_ID_CREATEPIPELINELIBRARY_UNSUPPORTED = 965, + D3D12_MESSAGE_ID_CREATE_PIPELINELIBRARY = 966, + D3D12_MESSAGE_ID_LIVE_PIPELINELIBRARY = 967, + D3D12_MESSAGE_ID_DESTROY_PIPELINELIBRARY = 968, + D3D12_MESSAGE_ID_STOREPIPELINE_NONAME = 969, + D3D12_MESSAGE_ID_STOREPIPELINE_DUPLICATENAME = 970, + D3D12_MESSAGE_ID_LOADPIPELINE_NAMENOTFOUND = 971, + D3D12_MESSAGE_ID_LOADPIPELINE_INVALIDDESC = 972, + D3D12_MESSAGE_ID_PIPELINELIBRARY_SERIALIZE_NOTENOUGHMEMORY = 973, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_PS_OUTPUT_RT_OUTPUT_MISMATCH = 974, + D3D12_MESSAGE_ID_SETEVENTONMULTIPLEFENCECOMPLETION_INVALIDFLAGS = 975, + D3D12_MESSAGE_ID_CREATE_QUEUE_VIDEO_NOT_SUPPORTED = 976, + D3D12_MESSAGE_ID_CREATE_COMMAND_ALLOCATOR_VIDEO_NOT_SUPPORTED = 977, + D3D12_MESSAGE_ID_CREATEQUERY_HEAP_VIDEO_DECODE_STATISTICS_NOT_SUPPORTED = 978, + D3D12_MESSAGE_ID_CREATE_VIDEODECODECOMMANDLIST = 979, + D3D12_MESSAGE_ID_CREATE_VIDEODECODER = 980, + D3D12_MESSAGE_ID_CREATE_VIDEODECODESTREAM = 981, + D3D12_MESSAGE_ID_LIVE_VIDEODECODECOMMANDLIST = 982, + D3D12_MESSAGE_ID_LIVE_VIDEODECODER = 983, + D3D12_MESSAGE_ID_LIVE_VIDEODECODESTREAM = 984, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODECOMMANDLIST = 985, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODER = 986, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODESTREAM = 987, + D3D12_MESSAGE_ID_DECODE_FRAME_INVALID_PARAMETERS = 988, + D3D12_MESSAGE_ID_DEPRECATED_API = 989, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_MISMATCHING_COMMAND_LIST_TYPE = 990, + D3D12_MESSAGE_ID_COMMAND_LIST_DESCRIPTOR_TABLE_NOT_SET = 991, + D3D12_MESSAGE_ID_COMMAND_LIST_ROOT_CONSTANT_BUFFER_VIEW_NOT_SET = 992, + D3D12_MESSAGE_ID_COMMAND_LIST_ROOT_SHADER_RESOURCE_VIEW_NOT_SET = 993, + D3D12_MESSAGE_ID_COMMAND_LIST_ROOT_UNORDERED_ACCESS_VIEW_NOT_SET = 994, + D3D12_MESSAGE_ID_DISCARD_INVALID_SUBRESOURCE_RANGE = 995, + D3D12_MESSAGE_ID_DISCARD_ONE_SUBRESOURCE_FOR_MIPS_WITH_RECTS = 996, + D3D12_MESSAGE_ID_DISCARD_NO_RECTS_FOR_NON_TEXTURE2D = 997, + D3D12_MESSAGE_ID_COPY_ON_SAME_SUBRESOURCE = 998, + D3D12_MESSAGE_ID_SETRESIDENCYPRIORITY_INVALID_PAGEABLE = 999, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_UNSUPPORTED = 1000, + D3D12_MESSAGE_ID_STATIC_DESCRIPTOR_INVALID_DESCRIPTOR_CHANGE = 1001, + D3D12_MESSAGE_ID_DATA_STATIC_DESCRIPTOR_INVALID_DATA_CHANGE = 1002, + D3D12_MESSAGE_ID_DATA_STATIC_WHILE_SET_AT_EXECUTE_DESCRIPTOR_INVALID_DATA_CHANGE = 1003, + D3D12_MESSAGE_ID_EXECUTE_BUNDLE_STATIC_DESCRIPTOR_DATA_STATIC_NOT_SET = 1004, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_RESOURCE_ACCESS_OUT_OF_BOUNDS = 1005, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_SAMPLER_MODE_MISMATCH = 1006, + D3D12_MESSAGE_ID_CREATE_FENCE_INVALID_FLAGS = 1007, + D3D12_MESSAGE_ID_RESOURCE_BARRIER_DUPLICATE_SUBRESOURCE_TRANSITIONS = 1008, + D3D12_MESSAGE_ID_SETRESIDENCYPRIORITY_INVALID_PRIORITY = 1009, + D3D12_MESSAGE_ID_CREATE_DESCRIPTOR_HEAP_LARGE_NUM_DESCRIPTORS = 1013, + D3D12_MESSAGE_ID_BEGIN_EVENT = 1014, + D3D12_MESSAGE_ID_END_EVENT = 1015, + D3D12_MESSAGE_ID_CREATEDEVICE_DEBUG_LAYER_STARTUP_OPTIONS = 1016, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_DEPTHBOUNDSTEST_UNSUPPORTED = 1017, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_DUPLICATE_SUBOBJECT = 1018, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_UNKNOWN_SUBOBJECT = 1019, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_ZERO_SIZE_STREAM = 1020, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_INVALID_STREAM = 1021, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_CANNOT_DEDUCE_TYPE = 1022, + D3D12_MESSAGE_ID_COMMAND_LIST_STATIC_DESCRIPTOR_RESOURCE_DIMENSION_MISMATCH = 1023, + D3D12_MESSAGE_ID_CREATE_COMMAND_QUEUE_INSUFFICIENT_PRIVILEGE_FOR_GLOBAL_REALTIME = 1024, + D3D12_MESSAGE_ID_CREATE_COMMAND_QUEUE_INSUFFICIENT_HARDWARE_SUPPORT_FOR_GLOBAL_REALTIME = 1025, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_ARCHITECTURE = 1026, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_DST = 1027, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_DST_RESOURCE_DIMENSION = 1028, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_DST_RANGE_OUT_OF_BOUNDS = 1029, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_SRC = 1030, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_SRC_RESOURCE_DIMENSION = 1031, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_SRC_RANGE_OUT_OF_BOUNDS = 1032, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_OFFSET_ALIGNMENT = 1033, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_DEPENDENT_RESOURCES = 1034, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_NULL_DEPENDENT_SUBRESOURCE_RANGES = 1035, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_DEPENDENT_RESOURCE = 1036, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_DEPENDENT_SUBRESOURCE_RANGE = 1037, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_DEPENDENT_SUBRESOURCE_OUT_OF_BOUNDS = 1038, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_DEPENDENT_RANGE_OUT_OF_BOUNDS = 1039, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_ZERO_DEPENDENCIES = 1040, + D3D12_MESSAGE_ID_DEVICE_CREATE_SHARED_HANDLE_INVALIDARG = 1041, + D3D12_MESSAGE_ID_DESCRIPTOR_HANDLE_WITH_INVALID_RESOURCE = 1042, + D3D12_MESSAGE_ID_SETDEPTHBOUNDS_INVALIDARGS = 1043, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_RESOURCE_STATE_IMPRECISE = 1044, + D3D12_MESSAGE_ID_COMMAND_LIST_PIPELINE_STATE_NOT_SET = 1045, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_SHADER_MODEL_MISMATCH = 1046, + D3D12_MESSAGE_ID_OBJECT_ACCESSED_WHILE_STILL_IN_USE = 1047, + D3D12_MESSAGE_ID_PROGRAMMABLE_MSAA_UNSUPPORTED = 1048, + D3D12_MESSAGE_ID_SETSAMPLEPOSITIONS_INVALIDARGS = 1049, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCEREGION_INVALID_RECT = 1050, + D3D12_MESSAGE_ID_CREATE_VIDEODECODECOMMANDQUEUE = 1051, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSCOMMANDLIST = 1052, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSCOMMANDQUEUE = 1053, + D3D12_MESSAGE_ID_LIVE_VIDEODECODECOMMANDQUEUE = 1054, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSCOMMANDLIST = 1055, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSCOMMANDQUEUE = 1056, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODECOMMANDQUEUE = 1057, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSCOMMANDLIST = 1058, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSCOMMANDQUEUE = 1059, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSOR = 1060, + D3D12_MESSAGE_ID_CREATE_VIDEOPROCESSSTREAM = 1061, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSOR = 1062, + D3D12_MESSAGE_ID_LIVE_VIDEOPROCESSSTREAM = 1063, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSOR = 1064, + D3D12_MESSAGE_ID_DESTROY_VIDEOPROCESSSTREAM = 1065, + D3D12_MESSAGE_ID_PROCESS_FRAME_INVALID_PARAMETERS = 1066, + D3D12_MESSAGE_ID_COPY_INVALIDLAYOUT = 1067, + D3D12_MESSAGE_ID_CREATE_CRYPTO_SESSION = 1068, + D3D12_MESSAGE_ID_CREATE_CRYPTO_SESSION_POLICY = 1069, + D3D12_MESSAGE_ID_CREATE_PROTECTED_RESOURCE_SESSION = 1070, + D3D12_MESSAGE_ID_LIVE_CRYPTO_SESSION = 1071, + D3D12_MESSAGE_ID_LIVE_CRYPTO_SESSION_POLICY = 1072, + D3D12_MESSAGE_ID_LIVE_PROTECTED_RESOURCE_SESSION = 1073, + D3D12_MESSAGE_ID_DESTROY_CRYPTO_SESSION = 1074, + D3D12_MESSAGE_ID_DESTROY_CRYPTO_SESSION_POLICY = 1075, + D3D12_MESSAGE_ID_DESTROY_PROTECTED_RESOURCE_SESSION = 1076, + D3D12_MESSAGE_ID_PROTECTED_RESOURCE_SESSION_UNSUPPORTED = 1077, + D3D12_MESSAGE_ID_FENCE_INVALIDOPERATION = 1078, + D3D12_MESSAGE_ID_CREATEQUERY_HEAP_COPY_QUEUE_TIMESTAMPS_NOT_SUPPORTED = 1079, + D3D12_MESSAGE_ID_SAMPLEPOSITIONS_MISMATCH_DEFERRED = 1080, + D3D12_MESSAGE_ID_SAMPLEPOSITIONS_MISMATCH_RECORDTIME_ASSUMEDFROMFIRSTUSE = 1081, + D3D12_MESSAGE_ID_SAMPLEPOSITIONS_MISMATCH_RECORDTIME_ASSUMEDFROMCLEAR = 1082, + D3D12_MESSAGE_ID_CREATE_VIDEODECODERHEAP = 1083, + D3D12_MESSAGE_ID_LIVE_VIDEODECODERHEAP = 1084, + D3D12_MESSAGE_ID_DESTROY_VIDEODECODERHEAP = 1085, + D3D12_MESSAGE_ID_OPENEXISTINGHEAP_INVALIDARG_RETURN = 1086, + D3D12_MESSAGE_ID_OPENEXISTINGHEAP_OUTOFMEMORY_RETURN = 1087, + D3D12_MESSAGE_ID_OPENEXISTINGHEAP_INVALIDADDRESS = 1088, + D3D12_MESSAGE_ID_OPENEXISTINGHEAP_INVALIDHANDLE = 1089, + D3D12_MESSAGE_ID_WRITEBUFFERIMMEDIATE_INVALID_DEST = 1090, + D3D12_MESSAGE_ID_WRITEBUFFERIMMEDIATE_INVALID_MODE = 1091, + D3D12_MESSAGE_ID_WRITEBUFFERIMMEDIATE_INVALID_ALIGNMENT = 1092, + D3D12_MESSAGE_ID_WRITEBUFFERIMMEDIATE_NOT_SUPPORTED = 1093, + D3D12_MESSAGE_ID_SETVIEWINSTANCEMASK_INVALIDARGS = 1094, + D3D12_MESSAGE_ID_VIEW_INSTANCING_UNSUPPORTED = 1095, + D3D12_MESSAGE_ID_VIEW_INSTANCING_INVALIDARGS = 1096, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_MISMATCH_DECODE_REFERENCE_ONLY_FLAG = 1097, + D3D12_MESSAGE_ID_COPYRESOURCE_MISMATCH_DECODE_REFERENCE_ONLY_FLAG = 1098, + D3D12_MESSAGE_ID_CREATE_VIDEO_DECODE_HEAP_CAPS_FAILURE = 1099, + D3D12_MESSAGE_ID_CREATE_VIDEO_DECODE_HEAP_CAPS_UNSUPPORTED = 1100, + D3D12_MESSAGE_ID_VIDEO_DECODE_SUPPORT_INVALID_INPUT = 1101, + D3D12_MESSAGE_ID_CREATE_VIDEO_DECODER_UNSUPPORTED = 1102, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_METADATA_ERROR = 1103, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_VIEW_INSTANCING_VERTEX_SIZE_EXCEEDED = 1104, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RUNTIME_INTERNAL_ERROR = 1105, + D3D12_MESSAGE_ID_NO_VIDEO_API_SUPPORT = 1106, + D3D12_MESSAGE_ID_VIDEO_PROCESS_SUPPORT_INVALID_INPUT = 1107, + D3D12_MESSAGE_ID_CREATE_VIDEO_PROCESSOR_CAPS_FAILURE = 1108, + D3D12_MESSAGE_ID_VIDEO_PROCESS_SUPPORT_UNSUPPORTED_FORMAT = 1109, + D3D12_MESSAGE_ID_VIDEO_DECODE_FRAME_INVALID_ARGUMENT = 1110, + D3D12_MESSAGE_ID_ENQUEUE_MAKE_RESIDENT_INVALID_FLAGS = 1111, + D3D12_MESSAGE_ID_OPENEXISTINGHEAP_UNSUPPORTED = 1112, + D3D12_MESSAGE_ID_VIDEO_PROCESS_FRAMES_INVALID_ARGUMENT = 1113, + D3D12_MESSAGE_ID_VIDEO_DECODE_SUPPORT_UNSUPPORTED = 1114, + D3D12_MESSAGE_ID_CREATE_COMMANDRECORDER = 1115, + D3D12_MESSAGE_ID_LIVE_COMMANDRECORDER = 1116, + D3D12_MESSAGE_ID_DESTROY_COMMANDRECORDER = 1117, + D3D12_MESSAGE_ID_CREATE_COMMAND_RECORDER_VIDEO_NOT_SUPPORTED = 1118, + D3D12_MESSAGE_ID_CREATE_COMMAND_RECORDER_INVALID_SUPPORT_FLAGS = 1119, + D3D12_MESSAGE_ID_CREATE_COMMAND_RECORDER_INVALID_FLAGS = 1120, + D3D12_MESSAGE_ID_CREATE_COMMAND_RECORDER_MORE_RECORDERS_THAN_LOGICAL_PROCESSORS = 1121, + D3D12_MESSAGE_ID_CREATE_COMMANDPOOL = 1122, + D3D12_MESSAGE_ID_LIVE_COMMANDPOOL = 1123, + D3D12_MESSAGE_ID_DESTROY_COMMANDPOOL = 1124, + D3D12_MESSAGE_ID_CREATE_COMMAND_POOL_INVALID_FLAGS = 1125, + D3D12_MESSAGE_ID_CREATE_COMMAND_LIST_VIDEO_NOT_SUPPORTED = 1126, + D3D12_MESSAGE_ID_COMMAND_RECORDER_SUPPORT_FLAGS_MISMATCH = 1127, + D3D12_MESSAGE_ID_COMMAND_RECORDER_CONTENTION = 1128, + D3D12_MESSAGE_ID_COMMAND_RECORDER_USAGE_WITH_CREATECOMMANDLIST_COMMAND_LIST = 1129, + D3D12_MESSAGE_ID_COMMAND_ALLOCATOR_USAGE_WITH_CREATECOMMANDLIST1_COMMAND_LIST = 1130, + D3D12_MESSAGE_ID_CANNOT_EXECUTE_EMPTY_COMMAND_LIST = 1131, + D3D12_MESSAGE_ID_CANNOT_RESET_COMMAND_POOL_WITH_OPEN_COMMAND_LISTS = 1132, + D3D12_MESSAGE_ID_CANNOT_USE_COMMAND_RECORDER_WITHOUT_CURRENT_TARGET = 1133, + D3D12_MESSAGE_ID_CANNOT_CHANGE_COMMAND_RECORDER_TARGET_WHILE_RECORDING = 1134, + D3D12_MESSAGE_ID_COMMAND_POOL_SYNC = 1135, + D3D12_MESSAGE_ID_EVICT_UNDERFLOW = 1136, + D3D12_MESSAGE_ID_CREATE_META_COMMAND = 1137, + D3D12_MESSAGE_ID_LIVE_META_COMMAND = 1138, + D3D12_MESSAGE_ID_DESTROY_META_COMMAND = 1139, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALID_DST_RESOURCE = 1140, + D3D12_MESSAGE_ID_COPYBUFFERREGION_INVALID_SRC_RESOURCE = 1141, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_DST_RESOURCE = 1142, + D3D12_MESSAGE_ID_ATOMICCOPYBUFFER_INVALID_SRC_RESOURCE = 1143, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_NULL_BUFFER = 1144, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_NULL_RESOURCE_DESC = 1145, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_UNSUPPORTED = 1146, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_INVALID_BUFFER_DIMENSION = 1147, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_INVALID_BUFFER_FLAGS = 1148, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_INVALID_BUFFER_OFFSET = 1149, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_INVALID_RESOURCE_DIMENSION = 1150, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_INVALID_RESOURCE_FLAGS = 1151, + D3D12_MESSAGE_ID_CREATEPLACEDRESOURCEONBUFFER_OUTOFMEMORY_RETURN = 1152, + D3D12_MESSAGE_ID_CANNOT_CREATE_GRAPHICS_AND_VIDEO_COMMAND_RECORDER = 1153, + D3D12_MESSAGE_ID_UPDATETILEMAPPINGS_POSSIBLY_MISMATCHING_PROPERTIES = 1154, + D3D12_MESSAGE_ID_CREATE_COMMAND_LIST_INVALID_COMMAND_LIST_TYPE = 1155, + D3D12_MESSAGE_ID_CLEARUNORDEREDACCESSVIEW_INCOMPATIBLE_WITH_STRUCTURED_BUFFERS = 1156, + D3D12_MESSAGE_ID_COMPUTE_ONLY_DEVICE_OPERATION_UNSUPPORTED = 1157, + D3D12_MESSAGE_ID_BUILD_RAYTRACING_ACCELERATION_STRUCTURE_INVALID = 1158, + D3D12_MESSAGE_ID_EMIT_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_INVALID = 1159, + D3D12_MESSAGE_ID_COPY_RAYTRACING_ACCELERATION_STRUCTURE_INVALID = 1160, + D3D12_MESSAGE_ID_DISPATCH_RAYS_INVALID = 1161, + D3D12_MESSAGE_ID_GET_RAYTRACING_ACCELERATION_STRUCTURE_PREBUILD_INFO_INVALID = 1162, + D3D12_MESSAGE_ID_CREATE_LIFETIMETRACKER = 1163, + D3D12_MESSAGE_ID_LIVE_LIFETIMETRACKER = 1164, + D3D12_MESSAGE_ID_DESTROY_LIFETIMETRACKER = 1165, + D3D12_MESSAGE_ID_DESTROYOWNEDOBJECT_OBJECTNOTOWNED = 1166, + D3D12_MESSAGE_ID_CREATE_TRACKEDWORKLOAD = 1167, + D3D12_MESSAGE_ID_LIVE_TRACKEDWORKLOAD = 1168, + D3D12_MESSAGE_ID_DESTROY_TRACKEDWORKLOAD = 1169, + D3D12_MESSAGE_ID_RENDER_PASS_ERROR = 1170, + D3D12_MESSAGE_ID_META_COMMAND_ID_INVALID = 1171, + D3D12_MESSAGE_ID_META_COMMAND_UNSUPPORTED_PARAMS = 1172, + D3D12_MESSAGE_ID_META_COMMAND_FAILED_ENUMERATION = 1173, + D3D12_MESSAGE_ID_META_COMMAND_PARAMETER_SIZE_MISMATCH = 1174, + D3D12_MESSAGE_ID_UNINITIALIZED_META_COMMAND = 1175, + D3D12_MESSAGE_ID_META_COMMAND_INVALID_GPU_VIRTUAL_ADDRESS = 1176, + D3D12_MESSAGE_ID_CREATE_VIDEOENCODECOMMANDLIST = 1177, + D3D12_MESSAGE_ID_LIVE_VIDEOENCODECOMMANDLIST = 1178, + D3D12_MESSAGE_ID_DESTROY_VIDEOENCODECOMMANDLIST = 1179, + D3D12_MESSAGE_ID_CREATE_VIDEOENCODECOMMANDQUEUE = 1180, + D3D12_MESSAGE_ID_LIVE_VIDEOENCODECOMMANDQUEUE = 1181, + D3D12_MESSAGE_ID_DESTROY_VIDEOENCODECOMMANDQUEUE = 1182, + D3D12_MESSAGE_ID_CREATE_VIDEOMOTIONESTIMATOR = 1183, + D3D12_MESSAGE_ID_LIVE_VIDEOMOTIONESTIMATOR = 1184, + D3D12_MESSAGE_ID_DESTROY_VIDEOMOTIONESTIMATOR = 1185, + D3D12_MESSAGE_ID_CREATE_VIDEOMOTIONVECTORHEAP = 1186, + D3D12_MESSAGE_ID_LIVE_VIDEOMOTIONVECTORHEAP = 1187, + D3D12_MESSAGE_ID_DESTROY_VIDEOMOTIONVECTORHEAP = 1188, + D3D12_MESSAGE_ID_MULTIPLE_TRACKED_WORKLOADS = 1189, + D3D12_MESSAGE_ID_MULTIPLE_TRACKED_WORKLOAD_PAIRS = 1190, + D3D12_MESSAGE_ID_OUT_OF_ORDER_TRACKED_WORKLOAD_PAIR = 1191, + D3D12_MESSAGE_ID_CANNOT_ADD_TRACKED_WORKLOAD = 1192, + D3D12_MESSAGE_ID_INCOMPLETE_TRACKED_WORKLOAD_PAIR = 1193, + D3D12_MESSAGE_ID_CREATE_STATE_OBJECT_ERROR = 1194, + D3D12_MESSAGE_ID_GET_SHADER_IDENTIFIER_ERROR = 1195, + D3D12_MESSAGE_ID_GET_SHADER_STACK_SIZE_ERROR = 1196, + D3D12_MESSAGE_ID_GET_PIPELINE_STACK_SIZE_ERROR = 1197, + D3D12_MESSAGE_ID_SET_PIPELINE_STACK_SIZE_ERROR = 1198, + D3D12_MESSAGE_ID_GET_SHADER_IDENTIFIER_SIZE_INVALID = 1199, + D3D12_MESSAGE_ID_CHECK_DRIVER_MATCHING_IDENTIFIER_INVALID = 1200, + D3D12_MESSAGE_ID_CHECK_DRIVER_MATCHING_IDENTIFIER_DRIVER_REPORTED_ISSUE = 1201, + D3D12_MESSAGE_ID_RENDER_PASS_INVALID_RESOURCE_BARRIER = 1202, + D3D12_MESSAGE_ID_RENDER_PASS_DISALLOWED_API_CALLED = 1203, + D3D12_MESSAGE_ID_RENDER_PASS_CANNOT_NEST_RENDER_PASSES = 1204, + D3D12_MESSAGE_ID_RENDER_PASS_CANNOT_END_WITHOUT_BEGIN = 1205, + D3D12_MESSAGE_ID_RENDER_PASS_CANNOT_CLOSE_COMMAND_LIST = 1206, + D3D12_MESSAGE_ID_RENDER_PASS_GPU_WORK_WHILE_SUSPENDED = 1207, + D3D12_MESSAGE_ID_RENDER_PASS_MISMATCHING_SUSPEND_RESUME = 1208, + D3D12_MESSAGE_ID_RENDER_PASS_NO_PRIOR_SUSPEND_WITHIN_EXECUTECOMMANDLISTS = 1209, + D3D12_MESSAGE_ID_RENDER_PASS_NO_SUBSEQUENT_RESUME_WITHIN_EXECUTECOMMANDLISTS = 1210, + D3D12_MESSAGE_ID_TRACKED_WORKLOAD_COMMAND_QUEUE_MISMATCH = 1211, + D3D12_MESSAGE_ID_TRACKED_WORKLOAD_NOT_SUPPORTED = 1212, + D3D12_MESSAGE_ID_RENDER_PASS_MISMATCHING_NO_ACCESS = 1213, + D3D12_MESSAGE_ID_RENDER_PASS_UNSUPPORTED_RESOLVE = 1214, + D3D12_MESSAGE_ID_CLEARUNORDEREDACCESSVIEW_INVALID_RESOURCE_PTR = 1215, + D3D12_MESSAGE_ID_WINDOWS7_FENCE_OUTOFORDER_SIGNAL = 1216, + D3D12_MESSAGE_ID_WINDOWS7_FENCE_OUTOFORDER_WAIT = 1217, + D3D12_MESSAGE_ID_VIDEO_CREATE_MOTION_ESTIMATOR_INVALID_ARGUMENT = 1218, + D3D12_MESSAGE_ID_VIDEO_CREATE_MOTION_VECTOR_HEAP_INVALID_ARGUMENT = 1219, + D3D12_MESSAGE_ID_ESTIMATE_MOTION_INVALID_ARGUMENT = 1220, + D3D12_MESSAGE_ID_RESOLVE_MOTION_VECTOR_HEAP_INVALID_ARGUMENT = 1221, + D3D12_MESSAGE_ID_GETGPUVIRTUALADDRESS_INVALID_HEAP_TYPE = 1222, + D3D12_MESSAGE_ID_SET_BACKGROUND_PROCESSING_MODE_INVALID_ARGUMENT = 1223, + D3D12_MESSAGE_ID_CREATE_COMMAND_LIST_INVALID_COMMAND_LIST_TYPE_FOR_FEATURE_LEVEL = 1224, + D3D12_MESSAGE_ID_CREATE_VIDEOEXTENSIONCOMMAND = 1225, + D3D12_MESSAGE_ID_LIVE_VIDEOEXTENSIONCOMMAND = 1226, + D3D12_MESSAGE_ID_DESTROY_VIDEOEXTENSIONCOMMAND = 1227, + D3D12_MESSAGE_ID_INVALID_VIDEO_EXTENSION_COMMAND_ID = 1228, + D3D12_MESSAGE_ID_VIDEO_EXTENSION_COMMAND_INVALID_ARGUMENT = 1229, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_NOT_UNIQUE_IN_DXIL_LIBRARY = 1230, + D3D12_MESSAGE_ID_VARIABLE_SHADING_RATE_NOT_ALLOWED_WITH_TIR = 1231, + D3D12_MESSAGE_ID_GEOMETRY_SHADER_OUTPUTTING_BOTH_VIEWPORT_ARRAY_INDEX_AND_SHADING_RATE_NOT_SUPPORTED_ON_DEVICE = 1232, + D3D12_MESSAGE_ID_RSSETSHADING_RATE_INVALID_SHADING_RATE = 1233, + D3D12_MESSAGE_ID_RSSETSHADING_RATE_SHADING_RATE_NOT_PERMITTED_BY_CAP = 1234, + D3D12_MESSAGE_ID_RSSETSHADING_RATE_INVALID_COMBINER = 1235, + D3D12_MESSAGE_ID_RSSETSHADINGRATEIMAGE_REQUIRES_TIER_2 = 1236, + D3D12_MESSAGE_ID_RSSETSHADINGRATE_REQUIRES_TIER_1 = 1237, + D3D12_MESSAGE_ID_SHADING_RATE_IMAGE_INCORRECT_FORMAT = 1238, + D3D12_MESSAGE_ID_SHADING_RATE_IMAGE_INCORRECT_ARRAY_SIZE = 1239, + D3D12_MESSAGE_ID_SHADING_RATE_IMAGE_INCORRECT_MIP_LEVEL = 1240, + D3D12_MESSAGE_ID_SHADING_RATE_IMAGE_INCORRECT_SAMPLE_COUNT = 1241, + D3D12_MESSAGE_ID_SHADING_RATE_IMAGE_INCORRECT_SAMPLE_QUALITY = 1242, + D3D12_MESSAGE_ID_NON_RETAIL_SHADER_MODEL_WONT_VALIDATE = 1243, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_AS_ROOT_SIGNATURE_MISMATCH = 1244, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MS_ROOT_SIGNATURE_MISMATCH = 1245, + D3D12_MESSAGE_ID_ADD_TO_STATE_OBJECT_ERROR = 1246, + D3D12_MESSAGE_ID_CREATE_PROTECTED_RESOURCE_SESSION_INVALID_ARGUMENT = 1247, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MS_PSO_DESC_MISMATCH = 1248, + D3D12_MESSAGE_ID_CREATEPIPELINESTATE_MS_INCOMPLETE_TYPE = 1249, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_AS_NOT_MS_MISMATCH = 1250, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_MS_NOT_PS_MISMATCH = 1251, + D3D12_MESSAGE_ID_NONZERO_SAMPLER_FEEDBACK_MIP_REGION_WITH_INCOMPATIBLE_FORMAT = 1252, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_INPUTLAYOUT_SHADER_MISMATCH = 1253, + D3D12_MESSAGE_ID_EMPTY_DISPATCH = 1254, + D3D12_MESSAGE_ID_RESOURCE_FORMAT_REQUIRES_SAMPLER_FEEDBACK_CAPABILITY = 1255, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_MAP_INVALID_MIP_REGION = 1256, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_MAP_INVALID_DIMENSION = 1257, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_MAP_INVALID_SAMPLE_COUNT = 1258, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_MAP_INVALID_SAMPLE_QUALITY = 1259, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_MAP_INVALID_LAYOUT = 1260, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_MAP_REQUIRES_UNORDERED_ACCESS_FLAG = 1261, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_CREATE_UAV_NULL_ARGUMENTS = 1262, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_UAV_REQUIRES_SAMPLER_FEEDBACK_CAPABILITY = 1263, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_CREATE_UAV_REQUIRES_FEEDBACK_MAP_FORMAT = 1264, + D3D12_MESSAGE_ID_CREATEMESHSHADER_INVALIDSHADERBYTECODE = 1265, + D3D12_MESSAGE_ID_CREATEMESHSHADER_OUTOFMEMORY = 1266, + D3D12_MESSAGE_ID_CREATEMESHSHADERWITHSTREAMOUTPUT_INVALIDSHADERTYPE = 1267, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_SAMPLER_FEEDBACK_TRANSCODE_INVALID_FORMAT = 1268, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_SAMPLER_FEEDBACK_INVALID_MIP_LEVEL_COUNT = 1269, + D3D12_MESSAGE_ID_RESOLVESUBRESOURCE_SAMPLER_FEEDBACK_TRANSCODE_ARRAY_SIZE_MISMATCH = 1270, + D3D12_MESSAGE_ID_SAMPLER_FEEDBACK_CREATE_UAV_MISMATCHING_TARGETED_RESOURCE = 1271, + D3D12_MESSAGE_ID_CREATEMESHSHADER_OUTPUTEXCEEDSMAXSIZE = 1272, + D3D12_MESSAGE_ID_CREATEMESHSHADER_GROUPSHAREDEXCEEDSMAXSIZE = 1273, + D3D12_MESSAGE_ID_VERTEX_SHADER_OUTPUTTING_BOTH_VIEWPORT_ARRAY_INDEX_AND_SHADING_RATE_NOT_SUPPORTED_ON_DEVICE = 1274, + D3D12_MESSAGE_ID_MESH_SHADER_OUTPUTTING_BOTH_VIEWPORT_ARRAY_INDEX_AND_SHADING_RATE_NOT_SUPPORTED_ON_DEVICE = 1275, + D3D12_MESSAGE_ID_CREATEMESHSHADER_MISMATCHEDASMSPAYLOADSIZE = 1276, + D3D12_MESSAGE_ID_CREATE_ROOT_SIGNATURE_UNBOUNDED_STATIC_DESCRIPTORS = 1277, + D3D12_MESSAGE_ID_CREATEAMPLIFICATIONSHADER_INVALIDSHADERBYTECODE = 1278, + D3D12_MESSAGE_ID_CREATEAMPLIFICATIONSHADER_OUTOFMEMORY = 1279, + D3D12_MESSAGE_ID_CREATE_SHADERCACHESESSION = 1280, + D3D12_MESSAGE_ID_LIVE_SHADERCACHESESSION = 1281, + D3D12_MESSAGE_ID_DESTROY_SHADERCACHESESSION = 1282, + D3D12_MESSAGE_ID_CREATESHADERCACHESESSION_INVALIDARGS = 1283, + D3D12_MESSAGE_ID_CREATESHADERCACHESESSION_DISABLED = 1284, + D3D12_MESSAGE_ID_CREATESHADERCACHESESSION_ALREADYOPEN = 1285, + D3D12_MESSAGE_ID_SHADERCACHECONTROL_DEVELOPERMODE = 1286, + D3D12_MESSAGE_ID_SHADERCACHECONTROL_INVALIDFLAGS = 1287, + D3D12_MESSAGE_ID_SHADERCACHECONTROL_STATEALREADYSET = 1288, + D3D12_MESSAGE_ID_SHADERCACHECONTROL_IGNOREDFLAG = 1289, + D3D12_MESSAGE_ID_SHADERCACHESESSION_STOREVALUE_ALREADYPRESENT = 1290, + D3D12_MESSAGE_ID_SHADERCACHESESSION_STOREVALUE_HASHCOLLISION = 1291, + D3D12_MESSAGE_ID_SHADERCACHESESSION_STOREVALUE_CACHEFULL = 1292, + D3D12_MESSAGE_ID_SHADERCACHESESSION_FINDVALUE_NOTFOUND = 1293, + D3D12_MESSAGE_ID_SHADERCACHESESSION_CORRUPT = 1294, + D3D12_MESSAGE_ID_SHADERCACHESESSION_DISABLED = 1295, + D3D12_MESSAGE_ID_OVERSIZED_DISPATCH = 1296, + D3D12_MESSAGE_ID_CREATE_VIDEOENCODER = 1297, + D3D12_MESSAGE_ID_LIVE_VIDEOENCODER = 1298, + D3D12_MESSAGE_ID_DESTROY_VIDEOENCODER = 1299, + D3D12_MESSAGE_ID_CREATE_VIDEOENCODERHEAP = 1300, + D3D12_MESSAGE_ID_LIVE_VIDEOENCODERHEAP = 1301, + D3D12_MESSAGE_ID_DESTROY_VIDEOENCODERHEAP = 1302, + D3D12_MESSAGE_ID_COPYTEXTUREREGION_MISMATCH_ENCODE_REFERENCE_ONLY_FLAG = 1303, + D3D12_MESSAGE_ID_COPYRESOURCE_MISMATCH_ENCODE_REFERENCE_ONLY_FLAG = 1304, + D3D12_MESSAGE_ID_ENCODE_FRAME_INVALID_PARAMETERS = 1305, + D3D12_MESSAGE_ID_ENCODE_FRAME_UNSUPPORTED_PARAMETERS = 1306, + D3D12_MESSAGE_ID_RESOLVE_ENCODER_OUTPUT_METADATA_INVALID_PARAMETERS = 1307, + D3D12_MESSAGE_ID_RESOLVE_ENCODER_OUTPUT_METADATA_UNSUPPORTED_PARAMETERS = 1308, + D3D12_MESSAGE_ID_CREATE_VIDEO_ENCODER_INVALID_PARAMETERS = 1309, + D3D12_MESSAGE_ID_CREATE_VIDEO_ENCODER_UNSUPPORTED_PARAMETERS = 1310, + D3D12_MESSAGE_ID_CREATE_VIDEO_ENCODER_HEAP_INVALID_PARAMETERS = 1311, + D3D12_MESSAGE_ID_CREATE_VIDEO_ENCODER_HEAP_UNSUPPORTED_PARAMETERS = 1312, + D3D12_MESSAGE_ID_CREATECOMMANDLIST_NULL_COMMANDALLOCATOR = 1313, + D3D12_MESSAGE_ID_CLEAR_UNORDERED_ACCESS_VIEW_INVALID_DESCRIPTOR_HANDLE = 1314, + D3D12_MESSAGE_ID_DESCRIPTOR_HEAP_NOT_SHADER_VISIBLE = 1315, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_BLENDOP_WARNING = 1316, + D3D12_MESSAGE_ID_CREATEBLENDSTATE_BLENDOPALPHA_WARNING = 1317, + D3D12_MESSAGE_ID_WRITE_COMBINE_PERFORMANCE_WARNING = 1318, + D3D12_MESSAGE_ID_RESOLVE_QUERY_INVALID_QUERY_STATE = 1319, + D3D12_MESSAGE_ID_SETPRIVATEDATA_NO_ACCESS = 1320, + D3D12_MESSAGE_ID_COMMAND_LIST_STATIC_DESCRIPTOR_SAMPLER_MODE_MISMATCH = 1321, + D3D12_MESSAGE_ID_GETCOPYABLEFOOTPRINTS_UNSUPPORTED_BUFFER_WIDTH = 1322, + D3D12_MESSAGE_ID_CREATEMESHSHADER_TOPOLOGY_MISMATCH = 1323, + D3D12_MESSAGE_ID_VRS_SUM_COMBINER_REQUIRES_CAPABILITY = 1324, + D3D12_MESSAGE_ID_SETTING_SHADING_RATE_FROM_MS_REQUIRES_CAPABILITY = 1325, + D3D12_MESSAGE_ID_SHADERCACHESESSION_SHADERCACHEDELETE_NOTSUPPORTED = 1326, + D3D12_MESSAGE_ID_SHADERCACHECONTROL_SHADERCACHECLEAR_NOTSUPPORTED = 1327, + D3D12_MESSAGE_ID_CREATERESOURCE_STATE_IGNORED = 1328, + D3D12_MESSAGE_ID_UNUSED_CROSS_EXECUTE_SPLIT_BARRIER = 1329, + D3D12_MESSAGE_ID_DEVICE_OPEN_SHARED_HANDLE_ACCESS_DENIED = 1330, + D3D12_MESSAGE_ID_INCOMPATIBLE_BARRIER_VALUES = 1331, + D3D12_MESSAGE_ID_INCOMPATIBLE_BARRIER_ACCESS = 1332, + D3D12_MESSAGE_ID_INCOMPATIBLE_BARRIER_SYNC = 1333, + D3D12_MESSAGE_ID_INCOMPATIBLE_BARRIER_LAYOUT = 1334, + D3D12_MESSAGE_ID_INCOMPATIBLE_BARRIER_TYPE = 1335, + D3D12_MESSAGE_ID_OUT_OF_BOUNDS_BARRIER_SUBRESOURCE_RANGE = 1336, + D3D12_MESSAGE_ID_INCOMPATIBLE_BARRIER_RESOURCE_DIMENSION = 1337, + D3D12_MESSAGE_ID_SET_SCISSOR_RECTS_INVALID_RECT = 1338, + D3D12_MESSAGE_ID_SHADING_RATE_SOURCE_REQUIRES_DIMENSION_TEXTURE2D = 1339, + D3D12_MESSAGE_ID_BUFFER_BARRIER_SUBREGION_OUT_OF_BOUNDS = 1340, + D3D12_MESSAGE_ID_UNSUPPORTED_BARRIER_LAYOUT = 1341, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALID_PARAMETERS = 1342, + D3D12_MESSAGE_ID_ENHANCED_BARRIERS_NOT_SUPPORTED = 1343, + D3D12_MESSAGE_ID_LEGACY_BARRIER_VALIDATION_FORCED_ON = 1346, + D3D12_MESSAGE_ID_EMPTY_ROOT_DESCRIPTOR_TABLE = 1347, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_ELEMENT_OFFSET_UNALIGNED = 1348, + D3D12_MESSAGE_ID_ALPHA_BLEND_FACTOR_NOT_SUPPORTED = 1349, + D3D12_MESSAGE_ID_BARRIER_INTEROP_INVALID_LAYOUT = 1350, + D3D12_MESSAGE_ID_BARRIER_INTEROP_INVALID_STATE = 1351, + D3D12_MESSAGE_ID_GRAPHICS_PIPELINE_STATE_DESC_ZERO_SAMPLE_MASK = 1352, + D3D12_MESSAGE_ID_INDEPENDENT_STENCIL_REF_NOT_SUPPORTED = 1353, + D3D12_MESSAGE_ID_CREATEDEPTHSTENCILSTATE_INDEPENDENT_MASKS_UNSUPPORTED = 1354, + D3D12_MESSAGE_ID_TEXTURE_BARRIER_SUBRESOURCES_OUT_OF_BOUNDS = 1355, + D3D12_MESSAGE_ID_NON_OPTIMAL_BARRIER_ONLY_EXECUTE_COMMAND_LISTS = 1356, + D3D12_MESSAGE_ID_EXECUTE_INDIRECT_ZERO_COMMAND_COUNT = 1357, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_INCOMPATIBLE_TEXTURE_LAYOUT = 1358, + D3D12_MESSAGE_ID_DYNAMIC_INDEX_BUFFER_STRIP_CUT_NOT_SUPPORTED = 1359, + D3D12_MESSAGE_ID_PRIMITIVE_TOPOLOGY_TRIANGLE_FANS_NOT_SUPPORTED = 1360, + D3D12_MESSAGE_ID_CREATE_SAMPLER_COMPARISON_FUNC_IGNORED = 1361, + D3D12_MESSAGE_ID_CREATEHEAP_INVALIDHEAPTYPE = 1362, + D3D12_MESSAGE_ID_CREATERESOURCEANDHEAP_INVALIDHEAPTYPE = 1363, + D3D12_MESSAGE_ID_DYNAMIC_DEPTH_BIAS_NOT_SUPPORTED = 1364, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_NON_WHOLE_DYNAMIC_DEPTH_BIAS = 1365, + D3D12_MESSAGE_ID_DYNAMIC_DEPTH_BIAS_FLAG_MISSING = 1366, + D3D12_MESSAGE_ID_DYNAMIC_DEPTH_BIAS_NO_PIPELINE = 1367, + D3D12_MESSAGE_ID_DYNAMIC_INDEX_BUFFER_STRIP_CUT_FLAG_MISSING = 1368, + D3D12_MESSAGE_ID_DYNAMIC_INDEX_BUFFER_STRIP_CUT_NO_PIPELINE = 1369, + D3D12_MESSAGE_ID_NONNORMALIZED_COORDINATE_SAMPLING_NOT_SUPPORTED = 1370, + D3D12_MESSAGE_ID_INVALID_CAST_TARGET = 1371, + D3D12_MESSAGE_ID_RENDER_PASS_COMMANDLIST_INVALID_END_STATE = 1372, + D3D12_MESSAGE_ID_RENDER_PASS_COMMANDLIST_INVALID_START_STATE = 1373, + D3D12_MESSAGE_ID_RENDER_PASS_MISMATCHING_ACCESS = 1374, + D3D12_MESSAGE_ID_RENDER_PASS_MISMATCHING_LOCAL_PRESERVE_PARAMETERS = 1375, + D3D12_MESSAGE_ID_RENDER_PASS_LOCAL_PRESERVE_RENDER_PARAMETERS_ERROR = 1376, + D3D12_MESSAGE_ID_RENDER_PASS_LOCAL_DEPTH_STENCIL_ERROR = 1377, + D3D12_MESSAGE_ID_DRAW_POTENTIALLY_OUTSIDE_OF_VALID_RENDER_AREA = 1378, + D3D12_MESSAGE_ID_CREATERASTERIZERSTATE_INVALID_LINERASTERIZATIONMODE = 1379, + D3D12_MESSAGE_ID_CREATERESOURCE_INVALIDALIGNMENT_SMALLRESOURCE = 1380, + D3D12_MESSAGE_ID_GENERIC_DEVICE_OPERATION_UNSUPPORTED = 1381, + D3D12_MESSAGE_ID_CREATEGRAPHICSPIPELINESTATE_RENDER_TARGET_WRONG_WRITE_MASK = 1382, + D3D12_MESSAGE_ID_PROBABLE_PIX_EVENT_LEAK = 1383, + D3D12_MESSAGE_ID_PIX_EVENT_UNDERFLOW = 1384, + D3D12_MESSAGE_ID_RECREATEAT_INVALID_TARGET = 1385, + D3D12_MESSAGE_ID_RECREATEAT_INSUFFICIENT_SUPPORT = 1386, + D3D12_MESSAGE_ID_GPU_BASED_VALIDATION_STRUCTURED_BUFFER_STRIDE_MISMATCH = 1387, + D3D12_MESSAGE_ID_DISPATCH_GRAPH_INVALID = 1388, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_TARGET_FORMAT_INVALID = 1389, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_TARGET_DIMENSION_INVALID = 1390, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_SOURCE_COLOR_FORMAT_INVALID = 1391, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_SOURCE_DEPTH_FORMAT_INVALID = 1392, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_EXPOSURE_SCALE_FORMAT_INVALID = 1393, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_ENGINE_CREATE_FLAGS_INVALID = 1394, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_EXTENSION_INTERNAL_LOAD_FAILURE = 1395, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_EXTENSION_INTERNAL_ENGINE_CREATION_ERROR = 1396, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_EXTENSION_INTERNAL_UPSCALER_CREATION_ERROR = 1397, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_EXTENSION_INTERNAL_UPSCALER_EXECUTION_ERROR = 1398, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_REGION_INVALID = 1399, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_TIME_DELTA_INVALID = 1400, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_REQUIRED_TEXTURE_IS_NULL = 1401, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_MOTION_VECTORS_FORMAT_INVALID = 1402, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_FLAGS_INVALID = 1403, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_FORMAT_INVALID = 1404, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_EXPOSURE_SCALE_TEXTURE_SIZE_INVALID = 1405, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_VARIANT_INDEX_OUT_OF_BOUNDS = 1406, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_VARIANT_ID_NOT_FOUND = 1407, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_DUPLICATE_VARIANT_ID = 1408, + D3D12_MESSAGE_ID_DIRECTSR_OUT_OF_MEMORY = 1409, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_UNEXPECTED_TEXTURE_IS_IGNORED = 1410, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EVICT_UNDERFLOW = 1411, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_OPTIONAL_TEXTURE_IS_NULL = 1412, + D3D12_MESSAGE_ID_DIRECTSR_SUPERRES_UPSCALER_EXECUTE_INVALID_CAMERA_JITTER = 1413, + D3D12_MESSAGE_ID_CREATE_STATE_OBJECT_WARNING = 1414, + D3D12_MESSAGE_ID_GUID_TEXTURE_LAYOUT_UNSUPPORTED = 1415, + D3D12_MESSAGE_ID_RESOLVE_ENCODER_INPUT_PARAM_LAYOUT_INVALID_PARAMETERS = 1416, + D3D12_MESSAGE_ID_INVALID_BARRIER_ACCESS = 1417, + D3D12_MESSAGE_ID_COMMAND_LIST_DRAW_INSTANCE_COUNT_ZERO = 1418, + D3D12_MESSAGE_ID_DESCRIPTOR_HEAP_NOT_SET_BEFORE_ROOT_SIGNATURE_WITH_DIRECTLY_INDEXED_FLAG = 1419, + D3D12_MESSAGE_ID_DIFFERENT_DESCRIPTOR_HEAP_SET_AFTER_ROOT_SIGNATURE_WITH_DIRECTLY_INDEXED_FLAG = 1420, + D3D12_MESSAGE_ID_D3D12_MESSAGES_END = ( D3D12_MESSAGE_ID_DIFFERENT_DESCRIPTOR_HEAP_SET_AFTER_ROOT_SIGNATURE_WITH_DIRECTLY_INDEXED_FLAG + 1 ) + } D3D12_MESSAGE_ID; + +typedef struct D3D12_MESSAGE + { + D3D12_MESSAGE_CATEGORY Category; + D3D12_MESSAGE_SEVERITY Severity; + D3D12_MESSAGE_ID ID; + _Field_size_(DescriptionByteLength) const char *pDescription; + SIZE_T DescriptionByteLength; + } D3D12_MESSAGE; + +typedef struct D3D12_INFO_QUEUE_FILTER_DESC + { + UINT NumCategories; + _Field_size_(NumCategories) D3D12_MESSAGE_CATEGORY *pCategoryList; + UINT NumSeverities; + _Field_size_(NumSeverities) D3D12_MESSAGE_SEVERITY *pSeverityList; + UINT NumIDs; + _Field_size_(NumIDs) D3D12_MESSAGE_ID *pIDList; + } D3D12_INFO_QUEUE_FILTER_DESC; + +typedef struct D3D12_INFO_QUEUE_FILTER + { + D3D12_INFO_QUEUE_FILTER_DESC AllowList; + D3D12_INFO_QUEUE_FILTER_DESC DenyList; + } D3D12_INFO_QUEUE_FILTER; + +#define D3D12_INFO_QUEUE_DEFAULT_MESSAGE_COUNT_LIMIT 1024 + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0018_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0018_v0_0_s_ifspec; + +#ifndef __ID3D12InfoQueue_INTERFACE_DEFINED__ +#define __ID3D12InfoQueue_INTERFACE_DEFINED__ + +/* interface ID3D12InfoQueue */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12InfoQueue; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("0742a90b-c387-483f-b946-30a7e4e61458") + ID3D12InfoQueue : public IUnknown + { + public: + virtual HRESULT STDMETHODCALLTYPE SetMessageCountLimit( + _In_ UINT64 MessageCountLimit) = 0; + + virtual void STDMETHODCALLTYPE ClearStoredMessages( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetMessage( + _In_ UINT64 MessageIndex, + _Out_writes_bytes_opt_(*pMessageByteLength) D3D12_MESSAGE *pMessage, + _Inout_ SIZE_T *pMessageByteLength) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumMessagesAllowedByStorageFilter( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDeniedByStorageFilter( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessages( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumStoredMessagesAllowedByRetrievalFilter( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetNumMessagesDiscardedByMessageCountLimit( void) = 0; + + virtual UINT64 STDMETHODCALLTYPE GetMessageCountLimit( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddStorageFilterEntries( + _In_ D3D12_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetStorageFilter( + _Out_writes_bytes_opt_(*pFilterByteLength) D3D12_INFO_QUEUE_FILTER *pFilter, + _Inout_ SIZE_T *pFilterByteLength) = 0; + + virtual void STDMETHODCALLTYPE ClearStorageFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushEmptyStorageFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushCopyOfStorageFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushStorageFilter( + _In_ D3D12_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual void STDMETHODCALLTYPE PopStorageFilter( void) = 0; + + virtual UINT STDMETHODCALLTYPE GetStorageFilterStackSize( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddRetrievalFilterEntries( + _In_ D3D12_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual HRESULT STDMETHODCALLTYPE GetRetrievalFilter( + _Out_writes_bytes_opt_(*pFilterByteLength) D3D12_INFO_QUEUE_FILTER *pFilter, + _Inout_ SIZE_T *pFilterByteLength) = 0; + + virtual void STDMETHODCALLTYPE ClearRetrievalFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushEmptyRetrievalFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushCopyOfRetrievalFilter( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE PushRetrievalFilter( + _In_ D3D12_INFO_QUEUE_FILTER *pFilter) = 0; + + virtual void STDMETHODCALLTYPE PopRetrievalFilter( void) = 0; + + virtual UINT STDMETHODCALLTYPE GetRetrievalFilterStackSize( void) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddMessage( + _In_ D3D12_MESSAGE_CATEGORY Category, + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ D3D12_MESSAGE_ID ID, + _In_ LPCSTR pDescription) = 0; + + virtual HRESULT STDMETHODCALLTYPE AddApplicationMessage( + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ LPCSTR pDescription) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetBreakOnCategory( + _In_ D3D12_MESSAGE_CATEGORY Category, + _In_ BOOL bEnable) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetBreakOnSeverity( + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ BOOL bEnable) = 0; + + virtual HRESULT STDMETHODCALLTYPE SetBreakOnID( + _In_ D3D12_MESSAGE_ID ID, + _In_ BOOL bEnable) = 0; + + virtual BOOL STDMETHODCALLTYPE GetBreakOnCategory( + _In_ D3D12_MESSAGE_CATEGORY Category) = 0; + + virtual BOOL STDMETHODCALLTYPE GetBreakOnSeverity( + _In_ D3D12_MESSAGE_SEVERITY Severity) = 0; + + virtual BOOL STDMETHODCALLTYPE GetBreakOnID( + _In_ D3D12_MESSAGE_ID ID) = 0; + + virtual void STDMETHODCALLTYPE SetMuteDebugOutput( + _In_ BOOL bMute) = 0; + + virtual BOOL STDMETHODCALLTYPE GetMuteDebugOutput( void) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12InfoQueueVtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12InfoQueue * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetMessageCountLimit) + HRESULT ( STDMETHODCALLTYPE *SetMessageCountLimit )( + ID3D12InfoQueue * This, + _In_ UINT64 MessageCountLimit); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, ClearStoredMessages) + void ( STDMETHODCALLTYPE *ClearStoredMessages )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetMessage) + HRESULT ( STDMETHODCALLTYPE *GetMessage )( + ID3D12InfoQueue * This, + _In_ UINT64 MessageIndex, + _Out_writes_bytes_opt_(*pMessageByteLength) D3D12_MESSAGE *pMessage, + _Inout_ SIZE_T *pMessageByteLength); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumMessagesAllowedByStorageFilter) + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesAllowedByStorageFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumMessagesDeniedByStorageFilter) + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDeniedByStorageFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumStoredMessages) + UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessages )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumStoredMessagesAllowedByRetrievalFilter) + UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessagesAllowedByRetrievalFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumMessagesDiscardedByMessageCountLimit) + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDiscardedByMessageCountLimit )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetMessageCountLimit) + UINT64 ( STDMETHODCALLTYPE *GetMessageCountLimit )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddStorageFilterEntries) + HRESULT ( STDMETHODCALLTYPE *AddStorageFilterEntries )( + ID3D12InfoQueue * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetStorageFilter) + HRESULT ( STDMETHODCALLTYPE *GetStorageFilter )( + ID3D12InfoQueue * This, + _Out_writes_bytes_opt_(*pFilterByteLength) D3D12_INFO_QUEUE_FILTER *pFilter, + _Inout_ SIZE_T *pFilterByteLength); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, ClearStorageFilter) + void ( STDMETHODCALLTYPE *ClearStorageFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushEmptyStorageFilter) + HRESULT ( STDMETHODCALLTYPE *PushEmptyStorageFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushCopyOfStorageFilter) + HRESULT ( STDMETHODCALLTYPE *PushCopyOfStorageFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushStorageFilter) + HRESULT ( STDMETHODCALLTYPE *PushStorageFilter )( + ID3D12InfoQueue * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PopStorageFilter) + void ( STDMETHODCALLTYPE *PopStorageFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetStorageFilterStackSize) + UINT ( STDMETHODCALLTYPE *GetStorageFilterStackSize )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddRetrievalFilterEntries) + HRESULT ( STDMETHODCALLTYPE *AddRetrievalFilterEntries )( + ID3D12InfoQueue * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *GetRetrievalFilter )( + ID3D12InfoQueue * This, + _Out_writes_bytes_opt_(*pFilterByteLength) D3D12_INFO_QUEUE_FILTER *pFilter, + _Inout_ SIZE_T *pFilterByteLength); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, ClearRetrievalFilter) + void ( STDMETHODCALLTYPE *ClearRetrievalFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushEmptyRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *PushEmptyRetrievalFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushCopyOfRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *PushCopyOfRetrievalFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *PushRetrievalFilter )( + ID3D12InfoQueue * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PopRetrievalFilter) + void ( STDMETHODCALLTYPE *PopRetrievalFilter )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetRetrievalFilterStackSize) + UINT ( STDMETHODCALLTYPE *GetRetrievalFilterStackSize )( + ID3D12InfoQueue * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddMessage) + HRESULT ( STDMETHODCALLTYPE *AddMessage )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_CATEGORY Category, + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ D3D12_MESSAGE_ID ID, + _In_ LPCSTR pDescription); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddApplicationMessage) + HRESULT ( STDMETHODCALLTYPE *AddApplicationMessage )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ LPCSTR pDescription); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetBreakOnCategory) + HRESULT ( STDMETHODCALLTYPE *SetBreakOnCategory )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_CATEGORY Category, + _In_ BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetBreakOnSeverity) + HRESULT ( STDMETHODCALLTYPE *SetBreakOnSeverity )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetBreakOnID) + HRESULT ( STDMETHODCALLTYPE *SetBreakOnID )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_ID ID, + _In_ BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetBreakOnCategory) + BOOL ( STDMETHODCALLTYPE *GetBreakOnCategory )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_CATEGORY Category); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetBreakOnSeverity) + BOOL ( STDMETHODCALLTYPE *GetBreakOnSeverity )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_SEVERITY Severity); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetBreakOnID) + BOOL ( STDMETHODCALLTYPE *GetBreakOnID )( + ID3D12InfoQueue * This, + _In_ D3D12_MESSAGE_ID ID); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetMuteDebugOutput) + void ( STDMETHODCALLTYPE *SetMuteDebugOutput )( + ID3D12InfoQueue * This, + _In_ BOOL bMute); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetMuteDebugOutput) + BOOL ( STDMETHODCALLTYPE *GetMuteDebugOutput )( + ID3D12InfoQueue * This); + + END_INTERFACE + } ID3D12InfoQueueVtbl; + + interface ID3D12InfoQueue + { + CONST_VTBL struct ID3D12InfoQueueVtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12InfoQueue_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12InfoQueue_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12InfoQueue_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12InfoQueue_SetMessageCountLimit(This,MessageCountLimit) \ + ( (This)->lpVtbl -> SetMessageCountLimit(This,MessageCountLimit) ) + +#define ID3D12InfoQueue_ClearStoredMessages(This) \ + ( (This)->lpVtbl -> ClearStoredMessages(This) ) + +#define ID3D12InfoQueue_GetMessage(This,MessageIndex,pMessage,pMessageByteLength) \ + ( (This)->lpVtbl -> GetMessage(This,MessageIndex,pMessage,pMessageByteLength) ) + +#define ID3D12InfoQueue_GetNumMessagesAllowedByStorageFilter(This) \ + ( (This)->lpVtbl -> GetNumMessagesAllowedByStorageFilter(This) ) + +#define ID3D12InfoQueue_GetNumMessagesDeniedByStorageFilter(This) \ + ( (This)->lpVtbl -> GetNumMessagesDeniedByStorageFilter(This) ) + +#define ID3D12InfoQueue_GetNumStoredMessages(This) \ + ( (This)->lpVtbl -> GetNumStoredMessages(This) ) + +#define ID3D12InfoQueue_GetNumStoredMessagesAllowedByRetrievalFilter(This) \ + ( (This)->lpVtbl -> GetNumStoredMessagesAllowedByRetrievalFilter(This) ) + +#define ID3D12InfoQueue_GetNumMessagesDiscardedByMessageCountLimit(This) \ + ( (This)->lpVtbl -> GetNumMessagesDiscardedByMessageCountLimit(This) ) + +#define ID3D12InfoQueue_GetMessageCountLimit(This) \ + ( (This)->lpVtbl -> GetMessageCountLimit(This) ) + +#define ID3D12InfoQueue_AddStorageFilterEntries(This,pFilter) \ + ( (This)->lpVtbl -> AddStorageFilterEntries(This,pFilter) ) + +#define ID3D12InfoQueue_GetStorageFilter(This,pFilter,pFilterByteLength) \ + ( (This)->lpVtbl -> GetStorageFilter(This,pFilter,pFilterByteLength) ) + +#define ID3D12InfoQueue_ClearStorageFilter(This) \ + ( (This)->lpVtbl -> ClearStorageFilter(This) ) + +#define ID3D12InfoQueue_PushEmptyStorageFilter(This) \ + ( (This)->lpVtbl -> PushEmptyStorageFilter(This) ) + +#define ID3D12InfoQueue_PushCopyOfStorageFilter(This) \ + ( (This)->lpVtbl -> PushCopyOfStorageFilter(This) ) + +#define ID3D12InfoQueue_PushStorageFilter(This,pFilter) \ + ( (This)->lpVtbl -> PushStorageFilter(This,pFilter) ) + +#define ID3D12InfoQueue_PopStorageFilter(This) \ + ( (This)->lpVtbl -> PopStorageFilter(This) ) + +#define ID3D12InfoQueue_GetStorageFilterStackSize(This) \ + ( (This)->lpVtbl -> GetStorageFilterStackSize(This) ) + +#define ID3D12InfoQueue_AddRetrievalFilterEntries(This,pFilter) \ + ( (This)->lpVtbl -> AddRetrievalFilterEntries(This,pFilter) ) + +#define ID3D12InfoQueue_GetRetrievalFilter(This,pFilter,pFilterByteLength) \ + ( (This)->lpVtbl -> GetRetrievalFilter(This,pFilter,pFilterByteLength) ) + +#define ID3D12InfoQueue_ClearRetrievalFilter(This) \ + ( (This)->lpVtbl -> ClearRetrievalFilter(This) ) + +#define ID3D12InfoQueue_PushEmptyRetrievalFilter(This) \ + ( (This)->lpVtbl -> PushEmptyRetrievalFilter(This) ) + +#define ID3D12InfoQueue_PushCopyOfRetrievalFilter(This) \ + ( (This)->lpVtbl -> PushCopyOfRetrievalFilter(This) ) + +#define ID3D12InfoQueue_PushRetrievalFilter(This,pFilter) \ + ( (This)->lpVtbl -> PushRetrievalFilter(This,pFilter) ) + +#define ID3D12InfoQueue_PopRetrievalFilter(This) \ + ( (This)->lpVtbl -> PopRetrievalFilter(This) ) + +#define ID3D12InfoQueue_GetRetrievalFilterStackSize(This) \ + ( (This)->lpVtbl -> GetRetrievalFilterStackSize(This) ) + +#define ID3D12InfoQueue_AddMessage(This,Category,Severity,ID,pDescription) \ + ( (This)->lpVtbl -> AddMessage(This,Category,Severity,ID,pDescription) ) + +#define ID3D12InfoQueue_AddApplicationMessage(This,Severity,pDescription) \ + ( (This)->lpVtbl -> AddApplicationMessage(This,Severity,pDescription) ) + +#define ID3D12InfoQueue_SetBreakOnCategory(This,Category,bEnable) \ + ( (This)->lpVtbl -> SetBreakOnCategory(This,Category,bEnable) ) + +#define ID3D12InfoQueue_SetBreakOnSeverity(This,Severity,bEnable) \ + ( (This)->lpVtbl -> SetBreakOnSeverity(This,Severity,bEnable) ) + +#define ID3D12InfoQueue_SetBreakOnID(This,ID,bEnable) \ + ( (This)->lpVtbl -> SetBreakOnID(This,ID,bEnable) ) + +#define ID3D12InfoQueue_GetBreakOnCategory(This,Category) \ + ( (This)->lpVtbl -> GetBreakOnCategory(This,Category) ) + +#define ID3D12InfoQueue_GetBreakOnSeverity(This,Severity) \ + ( (This)->lpVtbl -> GetBreakOnSeverity(This,Severity) ) + +#define ID3D12InfoQueue_GetBreakOnID(This,ID) \ + ( (This)->lpVtbl -> GetBreakOnID(This,ID) ) + +#define ID3D12InfoQueue_SetMuteDebugOutput(This,bMute) \ + ( (This)->lpVtbl -> SetMuteDebugOutput(This,bMute) ) + +#define ID3D12InfoQueue_GetMuteDebugOutput(This) \ + ( (This)->lpVtbl -> GetMuteDebugOutput(This) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12InfoQueue_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0019 */ +/* [local] */ + +typedef +enum D3D12_MESSAGE_CALLBACK_FLAGS + { + D3D12_MESSAGE_CALLBACK_FLAG_NONE = 0, + D3D12_MESSAGE_CALLBACK_IGNORE_FILTERS = 0x1 + } D3D12_MESSAGE_CALLBACK_FLAGS; + +DEFINE_ENUM_FLAG_OPERATORS(D3D12_MESSAGE_CALLBACK_FLAGS) +typedef void ( __stdcall *D3D12MessageFunc )( + D3D12_MESSAGE_CATEGORY Category, + D3D12_MESSAGE_SEVERITY Severity, + D3D12_MESSAGE_ID ID, + LPCSTR pDescription, + void *pContext); + + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0019_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0019_v0_0_s_ifspec; + +#ifndef __ID3D12InfoQueue1_INTERFACE_DEFINED__ +#define __ID3D12InfoQueue1_INTERFACE_DEFINED__ + +/* interface ID3D12InfoQueue1 */ +/* [unique][local][object][uuid] */ + + +EXTERN_C const IID IID_ID3D12InfoQueue1; + +#if defined(__cplusplus) && !defined(CINTERFACE) + + MIDL_INTERFACE("2852dd88-b484-4c0c-b6b1-67168500e600") + ID3D12InfoQueue1 : public ID3D12InfoQueue + { + public: + virtual HRESULT STDMETHODCALLTYPE RegisterMessageCallback( + _In_ D3D12MessageFunc CallbackFunc, + _In_ D3D12_MESSAGE_CALLBACK_FLAGS CallbackFilterFlags, + _Inout_ void *pContext, + _Inout_ DWORD *pCallbackCookie) = 0; + + virtual HRESULT STDMETHODCALLTYPE UnregisterMessageCallback( + _In_ DWORD CallbackCookie) = 0; + + }; + + +#else /* C style interface */ + + typedef struct ID3D12InfoQueue1Vtbl + { + BEGIN_INTERFACE + + DECLSPEC_XFGVIRT(IUnknown, QueryInterface) + HRESULT ( STDMETHODCALLTYPE *QueryInterface )( + ID3D12InfoQueue1 * This, + REFIID riid, + _COM_Outptr_ void **ppvObject); + + DECLSPEC_XFGVIRT(IUnknown, AddRef) + ULONG ( STDMETHODCALLTYPE *AddRef )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(IUnknown, Release) + ULONG ( STDMETHODCALLTYPE *Release )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetMessageCountLimit) + HRESULT ( STDMETHODCALLTYPE *SetMessageCountLimit )( + ID3D12InfoQueue1 * This, + _In_ UINT64 MessageCountLimit); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, ClearStoredMessages) + void ( STDMETHODCALLTYPE *ClearStoredMessages )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetMessage) + HRESULT ( STDMETHODCALLTYPE *GetMessage )( + ID3D12InfoQueue1 * This, + _In_ UINT64 MessageIndex, + _Out_writes_bytes_opt_(*pMessageByteLength) D3D12_MESSAGE *pMessage, + _Inout_ SIZE_T *pMessageByteLength); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumMessagesAllowedByStorageFilter) + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesAllowedByStorageFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumMessagesDeniedByStorageFilter) + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDeniedByStorageFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumStoredMessages) + UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessages )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumStoredMessagesAllowedByRetrievalFilter) + UINT64 ( STDMETHODCALLTYPE *GetNumStoredMessagesAllowedByRetrievalFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetNumMessagesDiscardedByMessageCountLimit) + UINT64 ( STDMETHODCALLTYPE *GetNumMessagesDiscardedByMessageCountLimit )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetMessageCountLimit) + UINT64 ( STDMETHODCALLTYPE *GetMessageCountLimit )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddStorageFilterEntries) + HRESULT ( STDMETHODCALLTYPE *AddStorageFilterEntries )( + ID3D12InfoQueue1 * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetStorageFilter) + HRESULT ( STDMETHODCALLTYPE *GetStorageFilter )( + ID3D12InfoQueue1 * This, + _Out_writes_bytes_opt_(*pFilterByteLength) D3D12_INFO_QUEUE_FILTER *pFilter, + _Inout_ SIZE_T *pFilterByteLength); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, ClearStorageFilter) + void ( STDMETHODCALLTYPE *ClearStorageFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushEmptyStorageFilter) + HRESULT ( STDMETHODCALLTYPE *PushEmptyStorageFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushCopyOfStorageFilter) + HRESULT ( STDMETHODCALLTYPE *PushCopyOfStorageFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushStorageFilter) + HRESULT ( STDMETHODCALLTYPE *PushStorageFilter )( + ID3D12InfoQueue1 * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PopStorageFilter) + void ( STDMETHODCALLTYPE *PopStorageFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetStorageFilterStackSize) + UINT ( STDMETHODCALLTYPE *GetStorageFilterStackSize )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddRetrievalFilterEntries) + HRESULT ( STDMETHODCALLTYPE *AddRetrievalFilterEntries )( + ID3D12InfoQueue1 * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *GetRetrievalFilter )( + ID3D12InfoQueue1 * This, + _Out_writes_bytes_opt_(*pFilterByteLength) D3D12_INFO_QUEUE_FILTER *pFilter, + _Inout_ SIZE_T *pFilterByteLength); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, ClearRetrievalFilter) + void ( STDMETHODCALLTYPE *ClearRetrievalFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushEmptyRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *PushEmptyRetrievalFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushCopyOfRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *PushCopyOfRetrievalFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PushRetrievalFilter) + HRESULT ( STDMETHODCALLTYPE *PushRetrievalFilter )( + ID3D12InfoQueue1 * This, + _In_ D3D12_INFO_QUEUE_FILTER *pFilter); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, PopRetrievalFilter) + void ( STDMETHODCALLTYPE *PopRetrievalFilter )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetRetrievalFilterStackSize) + UINT ( STDMETHODCALLTYPE *GetRetrievalFilterStackSize )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddMessage) + HRESULT ( STDMETHODCALLTYPE *AddMessage )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_CATEGORY Category, + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ D3D12_MESSAGE_ID ID, + _In_ LPCSTR pDescription); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, AddApplicationMessage) + HRESULT ( STDMETHODCALLTYPE *AddApplicationMessage )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ LPCSTR pDescription); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetBreakOnCategory) + HRESULT ( STDMETHODCALLTYPE *SetBreakOnCategory )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_CATEGORY Category, + _In_ BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetBreakOnSeverity) + HRESULT ( STDMETHODCALLTYPE *SetBreakOnSeverity )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_SEVERITY Severity, + _In_ BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetBreakOnID) + HRESULT ( STDMETHODCALLTYPE *SetBreakOnID )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_ID ID, + _In_ BOOL bEnable); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetBreakOnCategory) + BOOL ( STDMETHODCALLTYPE *GetBreakOnCategory )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_CATEGORY Category); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetBreakOnSeverity) + BOOL ( STDMETHODCALLTYPE *GetBreakOnSeverity )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_SEVERITY Severity); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetBreakOnID) + BOOL ( STDMETHODCALLTYPE *GetBreakOnID )( + ID3D12InfoQueue1 * This, + _In_ D3D12_MESSAGE_ID ID); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, SetMuteDebugOutput) + void ( STDMETHODCALLTYPE *SetMuteDebugOutput )( + ID3D12InfoQueue1 * This, + _In_ BOOL bMute); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue, GetMuteDebugOutput) + BOOL ( STDMETHODCALLTYPE *GetMuteDebugOutput )( + ID3D12InfoQueue1 * This); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue1, RegisterMessageCallback) + HRESULT ( STDMETHODCALLTYPE *RegisterMessageCallback )( + ID3D12InfoQueue1 * This, + _In_ D3D12MessageFunc CallbackFunc, + _In_ D3D12_MESSAGE_CALLBACK_FLAGS CallbackFilterFlags, + _Inout_ void *pContext, + _Inout_ DWORD *pCallbackCookie); + + DECLSPEC_XFGVIRT(ID3D12InfoQueue1, UnregisterMessageCallback) + HRESULT ( STDMETHODCALLTYPE *UnregisterMessageCallback )( + ID3D12InfoQueue1 * This, + _In_ DWORD CallbackCookie); + + END_INTERFACE + } ID3D12InfoQueue1Vtbl; + + interface ID3D12InfoQueue1 + { + CONST_VTBL struct ID3D12InfoQueue1Vtbl *lpVtbl; + }; + + + +#ifdef COBJMACROS + + +#define ID3D12InfoQueue1_QueryInterface(This,riid,ppvObject) \ + ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) + +#define ID3D12InfoQueue1_AddRef(This) \ + ( (This)->lpVtbl -> AddRef(This) ) + +#define ID3D12InfoQueue1_Release(This) \ + ( (This)->lpVtbl -> Release(This) ) + + +#define ID3D12InfoQueue1_SetMessageCountLimit(This,MessageCountLimit) \ + ( (This)->lpVtbl -> SetMessageCountLimit(This,MessageCountLimit) ) + +#define ID3D12InfoQueue1_ClearStoredMessages(This) \ + ( (This)->lpVtbl -> ClearStoredMessages(This) ) + +#define ID3D12InfoQueue1_GetMessage(This,MessageIndex,pMessage,pMessageByteLength) \ + ( (This)->lpVtbl -> GetMessage(This,MessageIndex,pMessage,pMessageByteLength) ) + +#define ID3D12InfoQueue1_GetNumMessagesAllowedByStorageFilter(This) \ + ( (This)->lpVtbl -> GetNumMessagesAllowedByStorageFilter(This) ) + +#define ID3D12InfoQueue1_GetNumMessagesDeniedByStorageFilter(This) \ + ( (This)->lpVtbl -> GetNumMessagesDeniedByStorageFilter(This) ) + +#define ID3D12InfoQueue1_GetNumStoredMessages(This) \ + ( (This)->lpVtbl -> GetNumStoredMessages(This) ) + +#define ID3D12InfoQueue1_GetNumStoredMessagesAllowedByRetrievalFilter(This) \ + ( (This)->lpVtbl -> GetNumStoredMessagesAllowedByRetrievalFilter(This) ) + +#define ID3D12InfoQueue1_GetNumMessagesDiscardedByMessageCountLimit(This) \ + ( (This)->lpVtbl -> GetNumMessagesDiscardedByMessageCountLimit(This) ) + +#define ID3D12InfoQueue1_GetMessageCountLimit(This) \ + ( (This)->lpVtbl -> GetMessageCountLimit(This) ) + +#define ID3D12InfoQueue1_AddStorageFilterEntries(This,pFilter) \ + ( (This)->lpVtbl -> AddStorageFilterEntries(This,pFilter) ) + +#define ID3D12InfoQueue1_GetStorageFilter(This,pFilter,pFilterByteLength) \ + ( (This)->lpVtbl -> GetStorageFilter(This,pFilter,pFilterByteLength) ) + +#define ID3D12InfoQueue1_ClearStorageFilter(This) \ + ( (This)->lpVtbl -> ClearStorageFilter(This) ) + +#define ID3D12InfoQueue1_PushEmptyStorageFilter(This) \ + ( (This)->lpVtbl -> PushEmptyStorageFilter(This) ) + +#define ID3D12InfoQueue1_PushCopyOfStorageFilter(This) \ + ( (This)->lpVtbl -> PushCopyOfStorageFilter(This) ) + +#define ID3D12InfoQueue1_PushStorageFilter(This,pFilter) \ + ( (This)->lpVtbl -> PushStorageFilter(This,pFilter) ) + +#define ID3D12InfoQueue1_PopStorageFilter(This) \ + ( (This)->lpVtbl -> PopStorageFilter(This) ) + +#define ID3D12InfoQueue1_GetStorageFilterStackSize(This) \ + ( (This)->lpVtbl -> GetStorageFilterStackSize(This) ) + +#define ID3D12InfoQueue1_AddRetrievalFilterEntries(This,pFilter) \ + ( (This)->lpVtbl -> AddRetrievalFilterEntries(This,pFilter) ) + +#define ID3D12InfoQueue1_GetRetrievalFilter(This,pFilter,pFilterByteLength) \ + ( (This)->lpVtbl -> GetRetrievalFilter(This,pFilter,pFilterByteLength) ) + +#define ID3D12InfoQueue1_ClearRetrievalFilter(This) \ + ( (This)->lpVtbl -> ClearRetrievalFilter(This) ) + +#define ID3D12InfoQueue1_PushEmptyRetrievalFilter(This) \ + ( (This)->lpVtbl -> PushEmptyRetrievalFilter(This) ) + +#define ID3D12InfoQueue1_PushCopyOfRetrievalFilter(This) \ + ( (This)->lpVtbl -> PushCopyOfRetrievalFilter(This) ) + +#define ID3D12InfoQueue1_PushRetrievalFilter(This,pFilter) \ + ( (This)->lpVtbl -> PushRetrievalFilter(This,pFilter) ) + +#define ID3D12InfoQueue1_PopRetrievalFilter(This) \ + ( (This)->lpVtbl -> PopRetrievalFilter(This) ) + +#define ID3D12InfoQueue1_GetRetrievalFilterStackSize(This) \ + ( (This)->lpVtbl -> GetRetrievalFilterStackSize(This) ) + +#define ID3D12InfoQueue1_AddMessage(This,Category,Severity,ID,pDescription) \ + ( (This)->lpVtbl -> AddMessage(This,Category,Severity,ID,pDescription) ) + +#define ID3D12InfoQueue1_AddApplicationMessage(This,Severity,pDescription) \ + ( (This)->lpVtbl -> AddApplicationMessage(This,Severity,pDescription) ) + +#define ID3D12InfoQueue1_SetBreakOnCategory(This,Category,bEnable) \ + ( (This)->lpVtbl -> SetBreakOnCategory(This,Category,bEnable) ) + +#define ID3D12InfoQueue1_SetBreakOnSeverity(This,Severity,bEnable) \ + ( (This)->lpVtbl -> SetBreakOnSeverity(This,Severity,bEnable) ) + +#define ID3D12InfoQueue1_SetBreakOnID(This,ID,bEnable) \ + ( (This)->lpVtbl -> SetBreakOnID(This,ID,bEnable) ) + +#define ID3D12InfoQueue1_GetBreakOnCategory(This,Category) \ + ( (This)->lpVtbl -> GetBreakOnCategory(This,Category) ) + +#define ID3D12InfoQueue1_GetBreakOnSeverity(This,Severity) \ + ( (This)->lpVtbl -> GetBreakOnSeverity(This,Severity) ) + +#define ID3D12InfoQueue1_GetBreakOnID(This,ID) \ + ( (This)->lpVtbl -> GetBreakOnID(This,ID) ) + +#define ID3D12InfoQueue1_SetMuteDebugOutput(This,bMute) \ + ( (This)->lpVtbl -> SetMuteDebugOutput(This,bMute) ) + +#define ID3D12InfoQueue1_GetMuteDebugOutput(This) \ + ( (This)->lpVtbl -> GetMuteDebugOutput(This) ) + + +#define ID3D12InfoQueue1_RegisterMessageCallback(This,CallbackFunc,CallbackFilterFlags,pContext,pCallbackCookie) \ + ( (This)->lpVtbl -> RegisterMessageCallback(This,CallbackFunc,CallbackFilterFlags,pContext,pCallbackCookie) ) + +#define ID3D12InfoQueue1_UnregisterMessageCallback(This,CallbackCookie) \ + ( (This)->lpVtbl -> UnregisterMessageCallback(This,CallbackCookie) ) + +#endif /* COBJMACROS */ + + +#endif /* C style interface */ + + + + +#endif /* __ID3D12InfoQueue1_INTERFACE_DEFINED__ */ + + +/* interface __MIDL_itf_d3d12sdklayers_0000_0020 */ +/* [local] */ + +#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_GAMES) */ +#ifdef _MSC_VER +#pragma endregion +#endif +DEFINE_GUID(IID_ID3D12Debug,0x344488b7,0x6846,0x474b,0xb9,0x89,0xf0,0x27,0x44,0x82,0x45,0xe0); +DEFINE_GUID(IID_ID3D12Debug1,0xaffaa4ca,0x63fe,0x4d8e,0xb8,0xad,0x15,0x90,0x00,0xaf,0x43,0x04); +DEFINE_GUID(IID_ID3D12Debug2,0x93a665c4,0xa3b2,0x4e5d,0xb6,0x92,0xa2,0x6a,0xe1,0x4e,0x33,0x74); +DEFINE_GUID(IID_ID3D12Debug3,0x5cf4e58f,0xf671,0x4ff1,0xa5,0x42,0x36,0x86,0xe3,0xd1,0x53,0xd1); +DEFINE_GUID(IID_ID3D12Debug4,0x014b816e,0x9ec5,0x4a2f,0xa8,0x45,0xff,0xbe,0x44,0x1c,0xe1,0x3a); +DEFINE_GUID(IID_ID3D12Debug5,0x548d6b12,0x09fa,0x40e0,0x90,0x69,0x5d,0xcd,0x58,0x9a,0x52,0xc9); +DEFINE_GUID(IID_ID3D12Debug6,0x82a816d6,0x5d01,0x4157,0x97,0xd0,0x49,0x75,0x46,0x3f,0xd1,0xed); +DEFINE_GUID(IID_ID3D12DebugDevice1,0xa9b71770,0xd099,0x4a65,0xa6,0x98,0x3d,0xee,0x10,0x02,0x0f,0x88); +DEFINE_GUID(IID_ID3D12DebugDevice,0x3febd6dd,0x4973,0x4787,0x81,0x94,0xe4,0x5f,0x9e,0x28,0x92,0x3e); +DEFINE_GUID(IID_ID3D12DebugDevice2,0x60eccbc1,0x378d,0x4df1,0x89,0x4c,0xf8,0xac,0x5c,0xe4,0xd7,0xdd); +DEFINE_GUID(IID_ID3D12DebugCommandQueue,0x09e0bf36,0x54ac,0x484f,0x88,0x47,0x4b,0xae,0xea,0xb6,0x05,0x3a); +DEFINE_GUID(IID_ID3D12DebugCommandQueue1,0x16be35a2,0xbfd6,0x49f2,0xbc,0xae,0xea,0xae,0x4a,0xff,0x86,0x2d); +DEFINE_GUID(IID_ID3D12DebugCommandList1,0x102ca951,0x311b,0x4b01,0xb1,0x1f,0xec,0xb8,0x3e,0x06,0x1b,0x37); +DEFINE_GUID(IID_ID3D12DebugCommandList,0x09e0bf36,0x54ac,0x484f,0x88,0x47,0x4b,0xae,0xea,0xb6,0x05,0x3f); +DEFINE_GUID(IID_ID3D12DebugCommandList2,0xaeb575cf,0x4e06,0x48be,0xba,0x3b,0xc4,0x50,0xfc,0x96,0x65,0x2e); +DEFINE_GUID(IID_ID3D12DebugCommandList3,0x197d5e15,0x4d37,0x4d34,0xaf,0x78,0x72,0x4c,0xd7,0x0f,0xdb,0x1f); +DEFINE_GUID(IID_ID3D12SharingContract,0x0adf7d52,0x929c,0x4e61,0xad,0xdb,0xff,0xed,0x30,0xde,0x66,0xef); +DEFINE_GUID(IID_ID3D12ManualWriteTrackingResource,0x86ca3b85,0x49ad,0x4b6e,0xae,0xd5,0xed,0xdb,0x18,0x54,0x0f,0x41); +DEFINE_GUID(IID_ID3D12InfoQueue,0x0742a90b,0xc387,0x483f,0xb9,0x46,0x30,0xa7,0xe4,0xe6,0x14,0x58); +DEFINE_GUID(IID_ID3D12InfoQueue1,0x2852dd88,0xb484,0x4c0c,0xb6,0xb1,0x67,0x16,0x85,0x00,0xe6,0x00); + + +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0020_v0_0_c_ifspec; +extern RPC_IF_HANDLE __MIDL_itf_d3d12sdklayers_0000_0020_v0_0_s_ifspec; + +/* Additional Prototypes for ALL interfaces */ + +/* end of Additional Prototypes */ + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs b/contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs new file mode 100644 index 0000000..5878f93 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/directx/gen_xbox_cmacros.cs @@ -0,0 +1,91 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +// Build and run this any time you update d3d12.h/d3d12sdklayers.h! + +using System.IO; + +class Program +{ + static void GenMacros(string[] input, StreamWriter output) + { + for (int i = 0; i < input.Length; i += 1) + { + if (input[i].StartsWith("#define I")) + { + // Strip out the bad ABI calls, use D3D_CALL_RET instead! + if (input[i].Contains("_GetDesc(") || + input[i].Contains("_GetDesc1(") || + input[i].Contains("_GetCPUDescriptorHandleForHeapStart(") || + input[i].Contains("_GetGPUDescriptorHandleForHeapStart(") || + input[i].Contains("_GetResourceAllocationInfo(") || + input[i].Contains("_GetResourceAllocationInfo1(") || + input[i].Contains("_GetResourceAllocationInfo2(") || + input[i].Contains("_GetResourceAllocationInfo3(") || + input[i].Contains("_GetCustomHeapProperties(") || + input[i].Contains("_GetAdapterLuid(") || + input[i].Contains("_GetLUID(") || + input[i].Contains("_GetProgramIdentifier(") || + input[i].Contains("_GetNodeID(") || + input[i].Contains("_GetEntrypointID(")) + { + // May as well skip the next line... + i += 1; + continue; + } + + // The first line is fine as-is. + output.WriteLine(input[i]); + + // The second line, however... + i += 1; + + string notThis; + if (input[i].LastIndexOf("This,") > -1) + { + // Function with arguments + notThis = "This,"; + } + else + { + // Function with no arguments + notThis = "This"; + } + + int lastNotThis = input[i].LastIndexOf(notThis); + string alias = input[i].Substring(0, lastNotThis).Replace("lpVtbl -> ", ""); + string definition = input[i].Substring(lastNotThis).Replace(notThis, ""); + output.WriteLine(alias + definition); + } + } + } + + static void Main(string[] args) + { + using (FileStream SDL_d3d12_xbox_cmacros_h = File.OpenWrite("SDL_d3d12_xbox_cmacros.h")) + using (StreamWriter output = new StreamWriter(SDL_d3d12_xbox_cmacros_h)) + { + output.WriteLine("/* This file is autogenerated, DO NOT MODIFY */"); + GenMacros(File.ReadAllLines("d3d12.h"), output); + GenMacros(File.ReadAllLines("d3d12sdklayers.h"), output); + } + } +} diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c new file mode 100644 index 0000000..2a7cdd4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents.c @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_DUMMY + +/* Being a null driver, there's no event stream. We just define stubs for + most of the API. */ + +#include "../../events/SDL_events_c.h" + +#include "SDL_nullvideo.h" +#include "SDL_nullevents_c.h" + +void DUMMY_PumpEvents(SDL_VideoDevice *_this) +{ + // do nothing. +} + +#endif // SDL_VIDEO_DRIVER_DUMMY diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h new file mode 100644 index 0000000..8baed95 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullevents_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_nullevents_c_h_ +#define SDL_nullevents_c_h_ + +#include "SDL_internal.h" + +#include "SDL_nullvideo.h" + +extern void DUMMY_PumpEvents(SDL_VideoDevice *_this); + +#endif // SDL_nullevents_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c new file mode 100644 index 0000000..f37510c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer.c @@ -0,0 +1,78 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_DUMMY + +#include "../SDL_sysvideo.h" +#include "../../SDL_properties_c.h" +#include "SDL_nullframebuffer_c.h" + +#define DUMMY_SURFACE "SDL.internal.window.surface" + + +bool SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_Surface *surface; + const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB8888; + int w, h; + + // Create a new framebuffer + SDL_GetWindowSizeInPixels(window, &w, &h); + surface = SDL_CreateSurface(w, h, surface_format); + if (!surface) { + return false; + } + + // Save the info and return! + SDL_SetSurfaceProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE, surface); + *format = surface_format; + *pixels = surface->pixels; + *pitch = surface->pitch; + return true; +} + +bool SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + static int frame_number; + SDL_Surface *surface; + + surface = (SDL_Surface *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE, NULL); + if (!surface) { + return SDL_SetError("Couldn't find dummy surface for window"); + } + + // Send the data to the display + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DUMMY_SAVE_FRAMES, false)) { + char file[128]; + (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", + SDL_GetWindowID(window), ++frame_number); + SDL_SaveBMP(surface, file); + } + return true; +} + +void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_ClearProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE); +} + +#endif // SDL_VIDEO_DRIVER_DUMMY diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h new file mode 100644 index 0000000..819b841 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullframebuffer_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_nullframebuffer_c_h_ +#define SDL_nullframebuffer_c_h_ + +#include "SDL_internal.h" + +extern bool SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_DUMMY_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_nullframebuffer_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c new file mode 100644 index 0000000..7be4ae1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.c @@ -0,0 +1,182 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_DUMMY + +/* Dummy SDL video driver implementation; this is just enough to make an + * SDL-based application THINK it's got a working video driver, for + * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, + * and also for use as a collection of stubs when porting SDL to a new + * platform for which you haven't yet written a valid video driver. + * + * This is also a great way to determine bottlenecks: if you think that SDL + * is a performance problem for a given platform, enable this driver, and + * then see if your application runs faster without video overhead. + * + * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion + * of this was cut-and-pasted from Stephane Peter's work in the AAlib + * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. + */ + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" +#ifdef SDL_INPUT_LINUXEV +#include "../../core/linux/SDL_evdev.h" +#endif + +#include "SDL_nullvideo.h" +#include "SDL_nullevents_c.h" +#include "SDL_nullframebuffer_c.h" + +#define DUMMYVID_DRIVER_NAME "dummy" +#define DUMMYVID_DRIVER_EVDEV_NAME "evdev" + +// Initialization/Query functions +static bool DUMMY_VideoInit(SDL_VideoDevice *_this); +static void DUMMY_VideoQuit(SDL_VideoDevice *_this); + +static bool DUMMY_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, window->pending.x, window->pending.y); + return true; +} + +static void DUMMY_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->pending.w, window->pending.h); +} + +// DUMMY driver bootstrap functions + +static bool DUMMY_Available(const char *enable_hint) +{ + const char *hint = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); + if (hint) { + if (SDL_strcmp(hint, enable_hint) == 0) { + return true; + } + } + return false; +} + +static void DUMMY_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device); +} + +static SDL_VideoDevice *DUMMY_InternalCreateDevice(const char *enable_hint) +{ + SDL_VideoDevice *device; + + if (!DUMMY_Available(enable_hint)) { + return NULL; + } + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + device->is_dummy = true; + + // Set the function pointers + device->VideoInit = DUMMY_VideoInit; + device->VideoQuit = DUMMY_VideoQuit; + device->PumpEvents = DUMMY_PumpEvents; + device->SetWindowSize = DUMMY_SetWindowSize; + device->SetWindowPosition = DUMMY_SetWindowPosition; + device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = SDL_DUMMY_DestroyWindowFramebuffer; + device->free = DUMMY_DeleteDevice; + + return device; +} + +static SDL_VideoDevice *DUMMY_CreateDevice(void) +{ + return DUMMY_InternalCreateDevice(DUMMYVID_DRIVER_NAME); +} + +VideoBootStrap DUMMY_bootstrap = { + DUMMYVID_DRIVER_NAME, "SDL dummy video driver", + DUMMY_CreateDevice, + NULL, // no ShowMessageBox implementation + false +}; + +#ifdef SDL_INPUT_LINUXEV + +static void DUMMY_EVDEV_Poll(SDL_VideoDevice *_this) +{ + (void)_this; + SDL_EVDEV_Poll(); +} + +static SDL_VideoDevice *DUMMY_EVDEV_CreateDevice(void) +{ + SDL_VideoDevice *device = DUMMY_InternalCreateDevice(DUMMYVID_DRIVER_EVDEV_NAME); + if (device) { + device->PumpEvents = DUMMY_EVDEV_Poll; + } + return device; +} + +VideoBootStrap DUMMY_evdev_bootstrap = { + DUMMYVID_DRIVER_EVDEV_NAME, "SDL dummy video driver with evdev", + DUMMY_EVDEV_CreateDevice, + NULL, // no ShowMessageBox implementation + false +}; + +#endif // SDL_INPUT_LINUXEV + +bool DUMMY_VideoInit(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; + + // Use a fake 32-bpp desktop mode + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_XRGB8888; + mode.w = 1024; + mode.h = 768; + if (SDL_AddBasicVideoDisplay(&mode) == 0) { + return false; + } + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Init(); +#endif + + // We're done! + return true; +} + +void DUMMY_VideoQuit(SDL_VideoDevice *_this) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#endif +} + +#endif // SDL_VIDEO_DRIVER_DUMMY diff --git a/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h new file mode 100644 index 0000000..8a43794 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/dummy/SDL_nullvideo.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_nullvideo_h_ +#define SDL_nullvideo_h_ + +#include "../SDL_sysvideo.h" + +#endif // SDL_nullvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.c b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.c new file mode 100644 index 0000000..49a140f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.c @@ -0,0 +1,1117 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN + +#include +#include + +#include "../../events/SDL_dropevents_c.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_touch_c.h" + +#include "SDL_emscriptenevents.h" +#include "SDL_emscriptenvideo.h" + +/* +Emscripten PK code to scancode +https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent +https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code +*/ +static const SDL_Scancode emscripten_scancode_table[] = { + /* 0x00 "Unidentified" */ SDL_SCANCODE_UNKNOWN, + /* 0x01 "Escape" */ SDL_SCANCODE_ESCAPE, + /* 0x02 "Digit0" */ SDL_SCANCODE_0, + /* 0x03 "Digit1" */ SDL_SCANCODE_1, + /* 0x04 "Digit2" */ SDL_SCANCODE_2, + /* 0x05 "Digit3" */ SDL_SCANCODE_3, + /* 0x06 "Digit4" */ SDL_SCANCODE_4, + /* 0x07 "Digit5" */ SDL_SCANCODE_5, + /* 0x08 "Digit6" */ SDL_SCANCODE_6, + /* 0x09 "Digit7" */ SDL_SCANCODE_7, + /* 0x0A "Digit8" */ SDL_SCANCODE_8, + /* 0x0B "Digit9" */ SDL_SCANCODE_9, + /* 0x0C "Minus" */ SDL_SCANCODE_MINUS, + /* 0x0D "Equal" */ SDL_SCANCODE_EQUALS, + /* 0x0E "Backspace" */ SDL_SCANCODE_BACKSPACE, + /* 0x0F "Tab" */ SDL_SCANCODE_TAB, + /* 0x10 "KeyQ" */ SDL_SCANCODE_Q, + /* 0x11 "KeyW" */ SDL_SCANCODE_W, + /* 0x12 "KeyE" */ SDL_SCANCODE_E, + /* 0x13 "KeyR" */ SDL_SCANCODE_R, + /* 0x14 "KeyT" */ SDL_SCANCODE_T, + /* 0x15 "KeyY" */ SDL_SCANCODE_Y, + /* 0x16 "KeyU" */ SDL_SCANCODE_U, + /* 0x17 "KeyI" */ SDL_SCANCODE_I, + /* 0x18 "KeyO" */ SDL_SCANCODE_O, + /* 0x19 "KeyP" */ SDL_SCANCODE_P, + /* 0x1A "BracketLeft" */ SDL_SCANCODE_LEFTBRACKET, + /* 0x1B "BracketRight" */ SDL_SCANCODE_RIGHTBRACKET, + /* 0x1C "Enter" */ SDL_SCANCODE_RETURN, + /* 0x1D "ControlLeft" */ SDL_SCANCODE_LCTRL, + /* 0x1E "KeyA" */ SDL_SCANCODE_A, + /* 0x1F "KeyS" */ SDL_SCANCODE_S, + /* 0x20 "KeyD" */ SDL_SCANCODE_D, + /* 0x21 "KeyF" */ SDL_SCANCODE_F, + /* 0x22 "KeyG" */ SDL_SCANCODE_G, + /* 0x23 "KeyH" */ SDL_SCANCODE_H, + /* 0x24 "KeyJ" */ SDL_SCANCODE_J, + /* 0x25 "KeyK" */ SDL_SCANCODE_K, + /* 0x26 "KeyL" */ SDL_SCANCODE_L, + /* 0x27 "Semicolon" */ SDL_SCANCODE_SEMICOLON, + /* 0x28 "Quote" */ SDL_SCANCODE_APOSTROPHE, + /* 0x29 "Backquote" */ SDL_SCANCODE_GRAVE, + /* 0x2A "ShiftLeft" */ SDL_SCANCODE_LSHIFT, + /* 0x2B "Backslash" */ SDL_SCANCODE_BACKSLASH, + /* 0x2C "KeyZ" */ SDL_SCANCODE_Z, + /* 0x2D "KeyX" */ SDL_SCANCODE_X, + /* 0x2E "KeyC" */ SDL_SCANCODE_C, + /* 0x2F "KeyV" */ SDL_SCANCODE_V, + /* 0x30 "KeyB" */ SDL_SCANCODE_B, + /* 0x31 "KeyN" */ SDL_SCANCODE_N, + /* 0x32 "KeyM" */ SDL_SCANCODE_M, + /* 0x33 "Comma" */ SDL_SCANCODE_COMMA, + /* 0x34 "Period" */ SDL_SCANCODE_PERIOD, + /* 0x35 "Slash" */ SDL_SCANCODE_SLASH, + /* 0x36 "ShiftRight" */ SDL_SCANCODE_RSHIFT, + /* 0x37 "NumpadMultiply" */ SDL_SCANCODE_KP_MULTIPLY, + /* 0x38 "AltLeft" */ SDL_SCANCODE_LALT, + /* 0x39 "Space" */ SDL_SCANCODE_SPACE, + /* 0x3A "CapsLock" */ SDL_SCANCODE_CAPSLOCK, + /* 0x3B "F1" */ SDL_SCANCODE_F1, + /* 0x3C "F2" */ SDL_SCANCODE_F2, + /* 0x3D "F3" */ SDL_SCANCODE_F3, + /* 0x3E "F4" */ SDL_SCANCODE_F4, + /* 0x3F "F5" */ SDL_SCANCODE_F5, + /* 0x40 "F6" */ SDL_SCANCODE_F6, + /* 0x41 "F7" */ SDL_SCANCODE_F7, + /* 0x42 "F8" */ SDL_SCANCODE_F8, + /* 0x43 "F9" */ SDL_SCANCODE_F9, + /* 0x44 "F10" */ SDL_SCANCODE_F10, + /* 0x45 "Pause" */ SDL_SCANCODE_PAUSE, + /* 0x46 "ScrollLock" */ SDL_SCANCODE_SCROLLLOCK, + /* 0x47 "Numpad7" */ SDL_SCANCODE_KP_7, + /* 0x48 "Numpad8" */ SDL_SCANCODE_KP_8, + /* 0x49 "Numpad9" */ SDL_SCANCODE_KP_9, + /* 0x4A "NumpadSubtract" */ SDL_SCANCODE_KP_MINUS, + /* 0x4B "Numpad4" */ SDL_SCANCODE_KP_4, + /* 0x4C "Numpad5" */ SDL_SCANCODE_KP_5, + /* 0x4D "Numpad6" */ SDL_SCANCODE_KP_6, + /* 0x4E "NumpadAdd" */ SDL_SCANCODE_KP_PLUS, + /* 0x4F "Numpad1" */ SDL_SCANCODE_KP_1, + /* 0x50 "Numpad2" */ SDL_SCANCODE_KP_2, + /* 0x51 "Numpad3" */ SDL_SCANCODE_KP_3, + /* 0x52 "Numpad0" */ SDL_SCANCODE_KP_0, + /* 0x53 "NumpadDecimal" */ SDL_SCANCODE_KP_PERIOD, + /* 0x54 "PrintScreen" */ SDL_SCANCODE_PRINTSCREEN, + /* 0x55 */ SDL_SCANCODE_UNKNOWN, + /* 0x56 "IntlBackslash" */ SDL_SCANCODE_NONUSBACKSLASH, + /* 0x57 "F11" */ SDL_SCANCODE_F11, + /* 0x58 "F12" */ SDL_SCANCODE_F12, + /* 0x59 "NumpadEqual" */ SDL_SCANCODE_KP_EQUALS, + /* 0x5A */ SDL_SCANCODE_UNKNOWN, + /* 0x5B */ SDL_SCANCODE_UNKNOWN, + /* 0x5C */ SDL_SCANCODE_UNKNOWN, + /* 0x5D */ SDL_SCANCODE_UNKNOWN, + /* 0x5E */ SDL_SCANCODE_UNKNOWN, + /* 0x5F */ SDL_SCANCODE_UNKNOWN, + /* 0x60 */ SDL_SCANCODE_UNKNOWN, + /* 0x61 */ SDL_SCANCODE_UNKNOWN, + /* 0x62 */ SDL_SCANCODE_UNKNOWN, + /* 0x63 */ SDL_SCANCODE_UNKNOWN, + /* 0x64 "F13" */ SDL_SCANCODE_F13, + /* 0x65 "F14" */ SDL_SCANCODE_F14, + /* 0x66 "F15" */ SDL_SCANCODE_F15, + /* 0x67 "F16" */ SDL_SCANCODE_F16, + /* 0x68 "F17" */ SDL_SCANCODE_F17, + /* 0x69 "F18" */ SDL_SCANCODE_F18, + /* 0x6A "F19" */ SDL_SCANCODE_F19, + /* 0x6B "F20" */ SDL_SCANCODE_F20, + /* 0x6C "F21" */ SDL_SCANCODE_F21, + /* 0x6D "F22" */ SDL_SCANCODE_F22, + /* 0x6E "F23" */ SDL_SCANCODE_F23, + /* 0x6F */ SDL_SCANCODE_UNKNOWN, + /* 0x70 "KanaMode" */ SDL_SCANCODE_INTERNATIONAL2, + /* 0x71 "Lang2" */ SDL_SCANCODE_LANG2, + /* 0x72 "Lang1" */ SDL_SCANCODE_LANG1, + /* 0x73 "IntlRo" */ SDL_SCANCODE_INTERNATIONAL1, + /* 0x74 */ SDL_SCANCODE_UNKNOWN, + /* 0x75 */ SDL_SCANCODE_UNKNOWN, + /* 0x76 "F24" */ SDL_SCANCODE_F24, + /* 0x77 */ SDL_SCANCODE_UNKNOWN, + /* 0x78 */ SDL_SCANCODE_UNKNOWN, + /* 0x79 "Convert" */ SDL_SCANCODE_INTERNATIONAL4, + /* 0x7A */ SDL_SCANCODE_UNKNOWN, + /* 0x7B "NonConvert" */ SDL_SCANCODE_INTERNATIONAL5, + /* 0x7C */ SDL_SCANCODE_UNKNOWN, + /* 0x7D "IntlYen" */ SDL_SCANCODE_INTERNATIONAL3, + /* 0x7E "NumpadComma" */ SDL_SCANCODE_KP_COMMA +}; + +static SDL_Scancode Emscripten_MapScanCode(const char *code) +{ + const DOM_PK_CODE_TYPE pk_code = emscripten_compute_dom_pk_code(code); + if (pk_code < SDL_arraysize(emscripten_scancode_table)) { + return emscripten_scancode_table[pk_code]; + } + + switch (pk_code) { + case DOM_PK_PASTE: + return SDL_SCANCODE_PASTE; + case DOM_PK_MEDIA_TRACK_PREVIOUS: + return SDL_SCANCODE_MEDIA_PREVIOUS_TRACK; + case DOM_PK_CUT: + return SDL_SCANCODE_CUT; + case DOM_PK_COPY: + return SDL_SCANCODE_COPY; + case DOM_PK_MEDIA_TRACK_NEXT: + return SDL_SCANCODE_MEDIA_NEXT_TRACK; + case DOM_PK_NUMPAD_ENTER: + return SDL_SCANCODE_KP_ENTER; + case DOM_PK_CONTROL_RIGHT: + return SDL_SCANCODE_RCTRL; + case DOM_PK_AUDIO_VOLUME_MUTE: + return SDL_SCANCODE_MUTE; + case DOM_PK_MEDIA_PLAY_PAUSE: + return SDL_SCANCODE_MEDIA_PLAY_PAUSE; + case DOM_PK_MEDIA_STOP: + return SDL_SCANCODE_MEDIA_STOP; + case DOM_PK_EJECT: + return SDL_SCANCODE_MEDIA_EJECT; + case DOM_PK_AUDIO_VOLUME_DOWN: + return SDL_SCANCODE_VOLUMEDOWN; + case DOM_PK_AUDIO_VOLUME_UP: + return SDL_SCANCODE_VOLUMEUP; + case DOM_PK_BROWSER_HOME: + return SDL_SCANCODE_AC_HOME; + case DOM_PK_NUMPAD_DIVIDE: + return SDL_SCANCODE_KP_DIVIDE; + case DOM_PK_ALT_RIGHT: + return SDL_SCANCODE_RALT; + case DOM_PK_HELP: + return SDL_SCANCODE_HELP; + case DOM_PK_NUM_LOCK: + return SDL_SCANCODE_NUMLOCKCLEAR; + case DOM_PK_HOME: + return SDL_SCANCODE_HOME; + case DOM_PK_ARROW_UP: + return SDL_SCANCODE_UP; + case DOM_PK_PAGE_UP: + return SDL_SCANCODE_PAGEUP; + case DOM_PK_ARROW_LEFT: + return SDL_SCANCODE_LEFT; + case DOM_PK_ARROW_RIGHT: + return SDL_SCANCODE_RIGHT; + case DOM_PK_END: + return SDL_SCANCODE_END; + case DOM_PK_ARROW_DOWN: + return SDL_SCANCODE_DOWN; + case DOM_PK_PAGE_DOWN: + return SDL_SCANCODE_PAGEDOWN; + case DOM_PK_INSERT: + return SDL_SCANCODE_INSERT; + case DOM_PK_DELETE: + return SDL_SCANCODE_DELETE; + case DOM_PK_META_LEFT: + return SDL_SCANCODE_LGUI; + case DOM_PK_META_RIGHT: + return SDL_SCANCODE_RGUI; + case DOM_PK_CONTEXT_MENU: + return SDL_SCANCODE_APPLICATION; + case DOM_PK_POWER: + return SDL_SCANCODE_POWER; + case DOM_PK_BROWSER_SEARCH: + return SDL_SCANCODE_AC_SEARCH; + case DOM_PK_BROWSER_FAVORITES: + return SDL_SCANCODE_AC_BOOKMARKS; + case DOM_PK_BROWSER_REFRESH: + return SDL_SCANCODE_AC_REFRESH; + case DOM_PK_BROWSER_STOP: + return SDL_SCANCODE_AC_STOP; + case DOM_PK_BROWSER_FORWARD: + return SDL_SCANCODE_AC_FORWARD; + case DOM_PK_BROWSER_BACK: + return SDL_SCANCODE_AC_BACK; + case DOM_PK_MEDIA_SELECT: + return SDL_SCANCODE_MEDIA_SELECT; + } + + return SDL_SCANCODE_UNKNOWN; +} + +static EM_BOOL Emscripten_HandlePointerLockChange(int eventType, const EmscriptenPointerlockChangeEvent *changeEvent, void *userData) +{ + SDL_WindowData *window_data = (SDL_WindowData *)userData; + // keep track of lock losses, so we can regrab if/when appropriate. + window_data->has_pointer_lock = changeEvent->isActive; + return 0; +} + +static EM_BOOL Emscripten_HandleMouseMove(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + const bool isPointerLocked = window_data->has_pointer_lock; + float mx, my; + + // rescale (in case canvas is being scaled) + double client_w, client_h, xscale, yscale; + emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); + xscale = window_data->window->w / client_w; + yscale = window_data->window->h / client_h; + + if (isPointerLocked) { + mx = (float)(mouseEvent->movementX * xscale); + my = (float)(mouseEvent->movementY * yscale); + } else { + mx = (float)(mouseEvent->targetX * xscale); + my = (float)(mouseEvent->targetY * yscale); + } + + SDL_SendMouseMotion(0, window_data->window, SDL_DEFAULT_MOUSE_ID, isPointerLocked, mx, my); + return 0; +} + +static EM_BOOL Emscripten_HandleMouseButton(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + Uint8 sdl_button; + bool sdl_button_state; + double css_w, css_h; + bool prevent_default = false; // needed for iframe implementation in Chrome-based browsers. + + switch (mouseEvent->button) { + case 0: + sdl_button = SDL_BUTTON_LEFT; + break; + case 1: + sdl_button = SDL_BUTTON_MIDDLE; + break; + case 2: + sdl_button = SDL_BUTTON_RIGHT; + break; + default: + return 0; + } + + const SDL_Mouse *mouse = SDL_GetMouse(); + SDL_assert(mouse != NULL); + + if (eventType == EMSCRIPTEN_EVENT_MOUSEDOWN) { + if (mouse->relative_mode && !window_data->has_pointer_lock) { + emscripten_request_pointerlock(window_data->canvas_id, 0); // try to regrab lost pointer lock. + } + sdl_button_state = true; + } else { + sdl_button_state = false; + prevent_default = SDL_EventEnabled(SDL_EVENT_MOUSE_BUTTON_UP); + } + + SDL_SendMouseButton(0, window_data->window, SDL_DEFAULT_MOUSE_ID, sdl_button, sdl_button_state); + + // We have an imaginary mouse capture, because we need SDL to not drop our imaginary mouse focus when we leave the canvas. + if (mouse->auto_capture) { + if (SDL_GetMouseState(NULL, NULL) != 0) { + window_data->window->flags |= SDL_WINDOW_MOUSE_CAPTURE; + } else { + window_data->window->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; + } + } + + if ((eventType == EMSCRIPTEN_EVENT_MOUSEUP) && window_data->mouse_focus_loss_pending) { + window_data->mouse_focus_loss_pending = (window_data->window->flags & SDL_WINDOW_MOUSE_CAPTURE) != 0; + if (!window_data->mouse_focus_loss_pending) { + SDL_SetMouseFocus(NULL); + } + } else { + // Do not consume the event if the mouse is outside of the canvas. + emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h); + if (mouseEvent->targetX < 0 || mouseEvent->targetX >= css_w || + mouseEvent->targetY < 0 || mouseEvent->targetY >= css_h) { + return 0; + } + } + + return prevent_default; +} + +static EM_BOOL Emscripten_HandleMouseFocus(int eventType, const EmscriptenMouseEvent *mouseEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + + const bool isPointerLocked = window_data->has_pointer_lock; + + if (!isPointerLocked) { + // rescale (in case canvas is being scaled) + float mx, my; + double client_w, client_h; + emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); + + mx = (float)(mouseEvent->targetX * (window_data->window->w / client_w)); + my = (float)(mouseEvent->targetY * (window_data->window->h / client_h)); + SDL_SendMouseMotion(0, window_data->window, SDL_GLOBAL_MOUSE_ID, isPointerLocked, mx, my); + } + + const bool isenter = (eventType == EMSCRIPTEN_EVENT_MOUSEENTER); + if (isenter && window_data->mouse_focus_loss_pending) { + window_data->mouse_focus_loss_pending = false; // just drop the state, but don't send the enter event. + } else if (!isenter && (window_data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { + window_data->mouse_focus_loss_pending = true; // waiting on a mouse button to let go before we send the mouse focus update. + } else { + SDL_SetMouseFocus(isenter ? window_data->window : NULL); + } + + return SDL_EventEnabled(SDL_EVENT_MOUSE_MOTION); // !!! FIXME: should this be MOUSE_MOTION or something else? +} + +static EM_BOOL Emscripten_HandleWheel(int eventType, const EmscriptenWheelEvent *wheelEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + + float deltaY = wheelEvent->deltaY; + float deltaX = wheelEvent->deltaX; + + switch (wheelEvent->deltaMode) { + case DOM_DELTA_PIXEL: + deltaX /= 100; // 100 pixels make up a step + deltaY /= 100; // 100 pixels make up a step + break; + case DOM_DELTA_LINE: + deltaX /= 3; // 3 lines make up a step + deltaY /= 3; // 3 lines make up a step + break; + case DOM_DELTA_PAGE: + deltaX *= 80; // A page makes up 80 steps + deltaY *= 80; // A page makes up 80 steps + break; + } + + SDL_SendMouseWheel(0, window_data->window, SDL_DEFAULT_MOUSE_ID, deltaX, -deltaY, SDL_MOUSEWHEEL_NORMAL); + return SDL_EventEnabled(SDL_EVENT_MOUSE_WHEEL); +} + +static EM_BOOL Emscripten_HandleFocus(int eventType, const EmscriptenFocusEvent *wheelEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + SDL_EventType sdl_event_type; + + /* If the user switches away while keys are pressed (such as + * via Alt+Tab), key release events won't be received. */ + if (eventType == EMSCRIPTEN_EVENT_BLUR) { + SDL_ResetKeyboard(); + } + + sdl_event_type = (eventType == EMSCRIPTEN_EVENT_FOCUS) ? SDL_EVENT_WINDOW_FOCUS_GAINED : SDL_EVENT_WINDOW_FOCUS_LOST; + SDL_SetKeyboardFocus(sdl_event_type == SDL_EVENT_WINDOW_FOCUS_GAINED ? window_data->window : NULL); + return SDL_EventEnabled(sdl_event_type); +} + +static EM_BOOL Emscripten_HandleTouch(int eventType, const EmscriptenTouchEvent *touchEvent, void *userData) +{ + SDL_WindowData *window_data = (SDL_WindowData *)userData; + int i; + double client_w, client_h; + int preventDefault = 0; + + const SDL_TouchID deviceId = 1; + if (SDL_AddTouch(deviceId, SDL_TOUCH_DEVICE_DIRECT, "") < 0) { + return 0; + } + + emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); + + for (i = 0; i < touchEvent->numTouches; i++) { + SDL_FingerID id; + float x, y; + + if (!touchEvent->touches[i].isChanged) { + continue; + } + + id = touchEvent->touches[i].identifier + 1; + if (client_w <= 1) { + x = 0.5f; + } else { + x = touchEvent->touches[i].targetX / (client_w - 1); + } + if (client_h <= 1) { + y = 0.5f; + } else { + y = touchEvent->touches[i].targetY / (client_h - 1); + } + + if (eventType == EMSCRIPTEN_EVENT_TOUCHSTART) { + SDL_SendTouch(0, deviceId, id, window_data->window, SDL_EVENT_FINGER_DOWN, x, y, 1.0f); + + // disable browser scrolling/pinch-to-zoom if app handles touch events + if (!preventDefault && SDL_EventEnabled(SDL_EVENT_FINGER_DOWN)) { + preventDefault = 1; + } + } else if (eventType == EMSCRIPTEN_EVENT_TOUCHMOVE) { + SDL_SendTouchMotion(0, deviceId, id, window_data->window, x, y, 1.0f); + } else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) { + SDL_SendTouch(0, deviceId, id, window_data->window, SDL_EVENT_FINGER_UP, x, y, 1.0f); + + // block browser's simulated mousedown/mouseup on touchscreen devices + preventDefault = 1; + } else if (eventType == EMSCRIPTEN_EVENT_TOUCHCANCEL) { + SDL_SendTouch(0, deviceId, id, window_data->window, SDL_EVENT_FINGER_CANCELED, x, y, 1.0f); + } + } + + return preventDefault; +} + +static bool IsFunctionKey(SDL_Scancode scancode) +{ + if (scancode >= SDL_SCANCODE_F1 && scancode <= SDL_SCANCODE_F12) { + return true; + } + if (scancode >= SDL_SCANCODE_F13 && scancode <= SDL_SCANCODE_F24) { + return true; + } + return false; +} + +/* This is a great tool to see web keyboard events live: + * https://w3c.github.io/uievents/tools/key-event-viewer.html + */ +static EM_BOOL Emscripten_HandleKey(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) +{ + SDL_WindowData *window_data = (SDL_WindowData *)userData; + SDL_Scancode scancode = Emscripten_MapScanCode(keyEvent->code); + SDL_Keycode keycode = SDLK_UNKNOWN; + bool prevent_default = false; + bool is_nav_key = false; + + if (scancode == SDL_SCANCODE_UNKNOWN) { + if (SDL_strcmp(keyEvent->key, "Sleep") == 0) { + scancode = SDL_SCANCODE_SLEEP; + } else if (SDL_strcmp(keyEvent->key, "ChannelUp") == 0) { + scancode = SDL_SCANCODE_CHANNEL_INCREMENT; + } else if (SDL_strcmp(keyEvent->key, "ChannelDown") == 0) { + scancode = SDL_SCANCODE_CHANNEL_DECREMENT; + } else if (SDL_strcmp(keyEvent->key, "MediaPlay") == 0) { + scancode = SDL_SCANCODE_MEDIA_PLAY; + } else if (SDL_strcmp(keyEvent->key, "MediaPause") == 0) { + scancode = SDL_SCANCODE_MEDIA_PAUSE; + } else if (SDL_strcmp(keyEvent->key, "MediaRecord") == 0) { + scancode = SDL_SCANCODE_MEDIA_RECORD; + } else if (SDL_strcmp(keyEvent->key, "MediaFastForward") == 0) { + scancode = SDL_SCANCODE_MEDIA_FAST_FORWARD; + } else if (SDL_strcmp(keyEvent->key, "MediaRewind") == 0) { + scancode = SDL_SCANCODE_MEDIA_REWIND; + } else if (SDL_strcmp(keyEvent->key, "Close") == 0) { + scancode = SDL_SCANCODE_AC_CLOSE; + } else if (SDL_strcmp(keyEvent->key, "New") == 0) { + scancode = SDL_SCANCODE_AC_NEW; + } else if (SDL_strcmp(keyEvent->key, "Open") == 0) { + scancode = SDL_SCANCODE_AC_OPEN; + } else if (SDL_strcmp(keyEvent->key, "Print") == 0) { + scancode = SDL_SCANCODE_AC_PRINT; + } else if (SDL_strcmp(keyEvent->key, "Save") == 0) { + scancode = SDL_SCANCODE_AC_SAVE; + } else if (SDL_strcmp(keyEvent->key, "Props") == 0) { + scancode = SDL_SCANCODE_AC_PROPERTIES; + } + } + + if (scancode == SDL_SCANCODE_UNKNOWN) { + // KaiOS Left Soft Key and Right Soft Key, they act as OK/Next/Menu and Cancel/Back/Clear + if (SDL_strcmp(keyEvent->key, "SoftLeft") == 0) { + scancode = SDL_SCANCODE_AC_FORWARD; + } else if (SDL_strcmp(keyEvent->key, "SoftRight") == 0) { + scancode = SDL_SCANCODE_AC_BACK; + } + } + + if (keyEvent->location == 0 && SDL_utf8strlen(keyEvent->key) == 1) { + const char *key = keyEvent->key; + keycode = SDL_StepUTF8(&key, NULL); + if (keycode == SDL_INVALID_UNICODE_CODEPOINT) { + keycode = SDLK_UNKNOWN; + } + } + + if (keycode != SDLK_UNKNOWN) { + prevent_default = SDL_SendKeyboardKeyAndKeycode(0, SDL_DEFAULT_KEYBOARD_ID, 0, scancode, keycode, (eventType == EMSCRIPTEN_EVENT_KEYDOWN)); + } else { + prevent_default = SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, 0, scancode, (eventType == EMSCRIPTEN_EVENT_KEYDOWN)); + } + + /* if TEXTINPUT events are enabled we can't prevent keydown or we won't get keypress + * we need to ALWAYS prevent backspace and tab otherwise chrome takes action and does bad navigation UX + */ + if ((scancode == SDL_SCANCODE_BACKSPACE) || + (scancode == SDL_SCANCODE_TAB) || + (scancode == SDL_SCANCODE_LEFT) || + (scancode == SDL_SCANCODE_UP) || + (scancode == SDL_SCANCODE_RIGHT) || + (scancode == SDL_SCANCODE_DOWN) || + IsFunctionKey(scancode) || + keyEvent->ctrlKey) { + is_nav_key = true; + } + + if ((eventType == EMSCRIPTEN_EVENT_KEYDOWN) && SDL_TextInputActive(window_data->window) && !is_nav_key) { + prevent_default = false; + } + + return prevent_default; +} + +static EM_BOOL Emscripten_HandleKeyPress(int eventType, const EmscriptenKeyboardEvent *keyEvent, void *userData) +{ + SDL_WindowData *window_data = (SDL_WindowData *)userData; + + if (SDL_TextInputActive(window_data->window)) { + char text[5]; + char *end = SDL_UCS4ToUTF8(keyEvent->charCode, text); + *end = '\0'; + SDL_SendKeyboardText(text); + return EM_TRUE; + } + return EM_FALSE; +} + +static EM_BOOL Emscripten_HandleFullscreenChange(int eventType, const EmscriptenFullscreenChangeEvent *fullscreenChangeEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + + if (fullscreenChangeEvent->isFullscreen) { + SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); + window_data->fullscreen_mode_flags = 0; + } else { + SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + } + + SDL_UpdateFullscreenMode(window_data->window, fullscreenChangeEvent->isFullscreen, false); + + return 0; +} + +static EM_BOOL Emscripten_HandleResize(int eventType, const EmscriptenUiEvent *uiEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + bool force = false; + + // update pixel ratio + if (window_data->window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + if (window_data->pixel_ratio != emscripten_get_device_pixel_ratio()) { + window_data->pixel_ratio = emscripten_get_device_pixel_ratio(); + force = true; + } + } + + if (!(window_data->window->flags & SDL_WINDOW_FULLSCREEN)) { + // this will only work if the canvas size is set through css + if (window_data->window->flags & SDL_WINDOW_RESIZABLE) { + double w = window_data->window->w; + double h = window_data->window->h; + + if (window_data->external_size) { + emscripten_get_element_css_size(window_data->canvas_id, &w, &h); + } + + emscripten_set_canvas_element_size(window_data->canvas_id, SDL_lroundf(w * window_data->pixel_ratio), SDL_lroundf(h * window_data->pixel_ratio)); + + // set_canvas_size unsets this + if (!window_data->external_size && window_data->pixel_ratio != 1.0f) { + emscripten_set_element_css_size(window_data->canvas_id, w, h); + } + + if (force) { + // force the event to trigger, so pixel ratio changes can be handled + window_data->window->w = 0; + window_data->window->h = 0; + } + + SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(w), SDL_lroundf(h)); + } + } + + return 0; +} + +EM_BOOL +Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData) +{ + // this is used during fullscreen changes + SDL_WindowData *window_data = userData; + + if (window_data->fullscreen_resize) { + double css_w, css_h; + emscripten_get_element_css_size(window_data->canvas_id, &css_w, &css_h); + SDL_SendWindowEvent(window_data->window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(css_w), SDL_lroundf(css_h)); + } + + return 0; +} + +static EM_BOOL Emscripten_HandleVisibilityChange(int eventType, const EmscriptenVisibilityChangeEvent *visEvent, void *userData) +{ + SDL_WindowData *window_data = userData; + SDL_SendWindowEvent(window_data->window, visEvent->hidden ? SDL_EVENT_WINDOW_HIDDEN : SDL_EVENT_WINDOW_SHOWN, 0, 0); + return 0; +} + +static const char *Emscripten_HandleBeforeUnload(int eventType, const void *reserved, void *userData) +{ + /* This event will need to be handled synchronously, e.g. using + SDL_AddEventWatch, as the page is being closed *now*. */ + // No need to send a SDL_EVENT_QUIT, the app won't get control again. + SDL_SendAppEvent(SDL_EVENT_TERMINATING); + return ""; // don't trigger confirmation dialog +} + +static EM_BOOL Emscripten_HandleOrientationChange(int eventType, const EmscriptenOrientationChangeEvent *orientationChangeEvent, void *userData) +{ + SDL_DisplayOrientation orientation; + switch (orientationChangeEvent->orientationIndex) { + #define CHECK_ORIENTATION(emsdk, sdl) case EMSCRIPTEN_ORIENTATION_##emsdk: orientation = SDL_ORIENTATION_##sdl; break + CHECK_ORIENTATION(LANDSCAPE_PRIMARY, LANDSCAPE); + CHECK_ORIENTATION(LANDSCAPE_SECONDARY, LANDSCAPE_FLIPPED); + CHECK_ORIENTATION(PORTRAIT_PRIMARY, PORTRAIT); + CHECK_ORIENTATION(PORTRAIT_SECONDARY, PORTRAIT_FLIPPED); + #undef CHECK_ORIENTATION + default: orientation = SDL_ORIENTATION_UNKNOWN; break; + } + + SDL_WindowData *window_data = (SDL_WindowData *) userData; + SDL_SendDisplayEvent(SDL_GetVideoDisplayForWindow(window_data->window), SDL_EVENT_DISPLAY_ORIENTATION, orientation, 0); + + return 0; +} + +// IF YOU CHANGE THIS STRUCTURE, YOU NEED TO UPDATE THE JAVASCRIPT THAT FILLS IT IN: makePointerEventCStruct, below. +typedef struct Emscripten_PointerEvent +{ + int pointerid; + int button; + int buttons; + float movementX; + float movementY; + float targetX; + float targetY; + float pressure; + float tangential_pressure; + float tiltx; + float tilty; + float rotation; +} Emscripten_PointerEvent; + +static void Emscripten_UpdatePointerFromEvent(SDL_WindowData *window_data, const Emscripten_PointerEvent *event) +{ + const SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) event->pointerid); + if (pen) { + // rescale (in case canvas is being scaled) + double client_w, client_h; + emscripten_get_element_css_size(window_data->canvas_id, &client_w, &client_h); + const double xscale = window_data->window->w / client_w; + const double yscale = window_data->window->h / client_h; + + const bool isPointerLocked = window_data->has_pointer_lock; + float mx, my; + if (isPointerLocked) { + mx = (float)(event->movementX * xscale); + my = (float)(event->movementY * yscale); + } else { + mx = (float)(event->targetX * xscale); + my = (float)(event->targetY * yscale); + } + + SDL_SendPenMotion(0, pen, window_data->window, mx, my); + + if (event->button == 0) { // pen touch + bool down = ((event->buttons & 1) != 0); + SDL_SendPenTouch(0, pen, window_data->window, false, down); + } else if (event->button == 5) { // eraser touch...? Not sure if this is right... + bool down = ((event->buttons & 32) != 0); + SDL_SendPenTouch(0, pen, window_data->window, true, down); + } else if (event->button == 1) { + bool down = ((event->buttons & 4) != 0); + SDL_SendPenButton(0, pen, window_data->window, 2, down); + } else if (event->button == 2) { + bool down = ((event->buttons & 2) != 0); + SDL_SendPenButton(0, pen, window_data->window, 1, down); + } + + SDL_SendPenAxis(0, pen, window_data->window, SDL_PEN_AXIS_PRESSURE, event->pressure); + SDL_SendPenAxis(0, pen, window_data->window, SDL_PEN_AXIS_TANGENTIAL_PRESSURE, event->tangential_pressure); + SDL_SendPenAxis(0, pen, window_data->window, SDL_PEN_AXIS_XTILT, event->tiltx); + SDL_SendPenAxis(0, pen, window_data->window, SDL_PEN_AXIS_YTILT, event->tilty); + SDL_SendPenAxis(0, pen, window_data->window, SDL_PEN_AXIS_ROTATION, event->rotation); + } +} + +EMSCRIPTEN_KEEPALIVE void Emscripten_HandlePointerEnter(SDL_WindowData *window_data, const Emscripten_PointerEvent *event) +{ + // Web browsers offer almost none of this information as specifics, but can without warning offer any of these specific things. + SDL_PenInfo peninfo; + SDL_zero(peninfo); + peninfo.capabilities = SDL_PEN_CAPABILITY_PRESSURE | SDL_PEN_CAPABILITY_ROTATION | SDL_PEN_CAPABILITY_XTILT | SDL_PEN_CAPABILITY_YTILT | SDL_PEN_CAPABILITY_TANGENTIAL_PRESSURE | SDL_PEN_CAPABILITY_ERASER; + peninfo.max_tilt = 90.0f; + peninfo.num_buttons = 2; + peninfo.subtype = SDL_PEN_TYPE_PEN; + SDL_AddPenDevice(0, NULL, &peninfo, (void *) (size_t) event->pointerid); + Emscripten_UpdatePointerFromEvent(window_data, event); +} + +EMSCRIPTEN_KEEPALIVE void Emscripten_HandlePointerLeave(SDL_WindowData *window_data, const Emscripten_PointerEvent *event) +{ + const SDL_PenID pen = SDL_FindPenByHandle((void *) (size_t) event->pointerid); + if (pen) { + Emscripten_UpdatePointerFromEvent(window_data, event); // last data updates? + SDL_RemovePenDevice(0, pen); + } +} + +EMSCRIPTEN_KEEPALIVE void Emscripten_HandlePointerGeneric(SDL_WindowData *window_data, const Emscripten_PointerEvent *event) +{ + Emscripten_UpdatePointerFromEvent(window_data, event); +} + +static void Emscripten_set_pointer_event_callbacks(SDL_WindowData *data) +{ + MAIN_THREAD_EM_ASM({ + var target = document.querySelector(UTF8ToString($1)); + if (target) { + var data = $0; + + if (typeof(Module['SDL3']) === 'undefined') { + Module['SDL3'] = {}; + } + var SDL3 = Module['SDL3']; + + var makePointerEventCStruct = function(event) { + var ptr = 0; + if (event.pointerType == "pen") { + ptr = _SDL_malloc($2); + if (ptr != 0) { + var rect = target.getBoundingClientRect(); + var idx = ptr >> 2; + HEAP32[idx++] = event.pointerId; + HEAP32[idx++] = (typeof(event.button) !== "undefined") ? event.button : -1; + HEAP32[idx++] = event.buttons; + HEAPF32[idx++] = event.movementX; + HEAPF32[idx++] = event.movementY; + HEAPF32[idx++] = event.clientX - rect.left; + HEAPF32[idx++] = event.clientY - rect.top; + HEAPF32[idx++] = event.pressure; + HEAPF32[idx++] = event.tangentialPressure; + HEAPF32[idx++] = event.tiltX; + HEAPF32[idx++] = event.tiltY; + HEAPF32[idx++] = event.twist; + } + } + return ptr; + }; + + SDL3.eventHandlerPointerEnter = function(event) { + var d = makePointerEventCStruct(event); if (d != 0) { _Emscripten_HandlePointerEnter(data, d); _SDL_free(d); } + }; + target.addEventListener("pointerenter", SDL3.eventHandlerPointerEnter); + + SDL3.eventHandlerPointerLeave = function(event) { + var d = makePointerEventCStruct(event); if (d != 0) { _Emscripten_HandlePointerLeave(data, d); _SDL_free(d); } + }; + target.addEventListener("pointerleave", SDL3.eventHandlerPointerLeave); + target.addEventListener("pointercancel", SDL3.eventHandlerPointerLeave); // catch this, just in case. + + SDL3.eventHandlerPointerGeneric = function(event) { + var d = makePointerEventCStruct(event); if (d != 0) { _Emscripten_HandlePointerGeneric(data, d); _SDL_free(d); } + }; + target.addEventListener("pointerdown", SDL3.eventHandlerPointerGeneric); + target.addEventListener("pointerup", SDL3.eventHandlerPointerGeneric); + target.addEventListener("pointermove", SDL3.eventHandlerPointerGeneric); + } + }, data, data->canvas_id, sizeof (Emscripten_PointerEvent)); +} + +static void Emscripten_unset_pointer_event_callbacks(SDL_WindowData *data) +{ + MAIN_THREAD_EM_ASM({ + var target = document.querySelector(UTF8ToString($0)); + if (target) { + var SDL3 = Module['SDL3']; + target.removeEventListener("pointerenter", SDL3.eventHandlerPointerEnter); + target.removeEventListener("pointerleave", SDL3.eventHandlerPointerLeave); + target.removeEventListener("pointercancel", SDL3.eventHandlerPointerLeave); + target.removeEventListener("pointerdown", SDL3.eventHandlerPointerGeneric); + target.removeEventListener("pointerup", SDL3.eventHandlerPointerGeneric); + target.removeEventListener("pointermove", SDL3.eventHandlerPointerGeneric); + SDL3.eventHandlerPointerEnter = undefined; + SDL3.eventHandlerPointerLeave = undefined; + SDL3.eventHandlerPointerGeneric = undefined; + } + }, data->canvas_id); +} + +// IF YOU CHANGE THIS STRUCTURE, YOU NEED TO UPDATE THE JAVASCRIPT THAT FILLS IT IN: makeDropEventCStruct, below. +typedef struct Emscripten_DropEvent +{ + int x; + int y; +} Emscripten_DropEvent; + +EMSCRIPTEN_KEEPALIVE void Emscripten_SendDragEvent(SDL_WindowData *window_data, const Emscripten_DropEvent *event) +{ + SDL_SendDropPosition(window_data->window, event->x, event->y); +} + +EMSCRIPTEN_KEEPALIVE void Emscripten_SendDragCompleteEvent(SDL_WindowData *window_data) +{ + SDL_SendDropComplete(window_data->window); +} + +EMSCRIPTEN_KEEPALIVE void Emscripten_SendDragTextEvent(SDL_WindowData *window_data, char *text) +{ + SDL_SendDropText(window_data->window, text); +} + +EMSCRIPTEN_KEEPALIVE void Emscripten_SendDragFileEvent(SDL_WindowData *window_data, char *filename) +{ + SDL_SendDropFile(window_data->window, NULL, filename); +} + +EM_JS_DEPS(dragndrop, "$writeArrayToMemory"); + +static void Emscripten_set_drag_event_callbacks(SDL_WindowData *data) +{ + MAIN_THREAD_EM_ASM({ + var target = document.querySelector(UTF8ToString($1)); + if (target) { + var data = $0; + + if (typeof(Module['SDL3']) === 'undefined') { + Module['SDL3'] = {}; + } + var SDL3 = Module['SDL3']; + + var makeDropEventCStruct = function(event) { + var ptr = 0; + ptr = _SDL_malloc($2); + if (ptr != 0) { + var idx = ptr >> 2; + var rect = target.getBoundingClientRect(); + HEAP32[idx++] = event.clientX - rect.left; + HEAP32[idx++] = event.clientY - rect.top; + } + return ptr; + }; + + SDL3.eventHandlerDropDragover = function(event) { + event.preventDefault(); + var d = makeDropEventCStruct(event); if (d != 0) { _Emscripten_SendDragEvent(data, d); _SDL_free(d); } + }; + target.addEventListener("dragover", SDL3.eventHandlerDropDragover); + + SDL3.drop_count = 0; + FS.mkdir("/tmp/filedrop"); + SDL3.eventHandlerDropDrop = function(event) { + event.preventDefault(); + if (event.dataTransfer.types.includes("text/plain")) { + let plain_text = stringToNewUTF8(event.dataTransfer.getData("text/plain")); + _Emscripten_SendDragTextEvent(data, plain_text); + _free(plain_text); + } else if (event.dataTransfer.types.includes("Files")) { + for (let i = 0; i < event.dataTransfer.files.length; i++) { + const file = event.dataTransfer.files.item(i); + const file_reader = new FileReader(); + file_reader.readAsArrayBuffer(file); + file_reader.onload = function(event) { + const fs_dropdir = `/tmp/filedrop/${SDL3.drop_count}`; + SDL3.drop_count += 1; + + const fs_filepath = `${fs_dropdir}/${file.name}`; + const c_fs_filepath = stringToNewUTF8(fs_filepath); + const contents_array8 = new Uint8Array(event.target.result); + + FS.mkdir(fs_dropdir); + var stream = FS.open(fs_filepath, "w"); + FS.write(stream, contents_array8, 0, contents_array8.length, 0); + FS.close(stream); + + _Emscripten_SendDragFileEvent(data, c_fs_filepath); + _free(c_fs_filepath); + _Emscripten_SendDragCompleteEvent(data); + }; + } + } + _Emscripten_SendDragCompleteEvent(data); + }; + target.addEventListener("drop", SDL3.eventHandlerDropDrop); + + SDL3.eventHandlerDropDragend = function(event) { + event.preventDefault(); + _Emscripten_SendDragCompleteEvent(data); + }; + target.addEventListener("dragend", SDL3.eventHandlerDropDragend); + target.addEventListener("dragleave", SDL3.eventHandlerDropDragend); + } + }, data, data->canvas_id, sizeof (Emscripten_DropEvent)); +} + +static void Emscripten_unset_drag_event_callbacks(SDL_WindowData *data) +{ + MAIN_THREAD_EM_ASM({ + var target = document.querySelector(UTF8ToString($0)); + if (target) { + var SDL3 = Module['SDL3']; + target.removeEventListener("dragleave", SDL3.eventHandlerDropDragend); + target.removeEventListener("dragend", SDL3.eventHandlerDropDragend); + target.removeEventListener("drop", SDL3.eventHandlerDropDrop); + SDL3.drop_count = undefined; + + function recursive_remove(dirpath) { + FS.readdir(dirpath).forEach((filename) => { + const p = `${dirpath}/${filename}`; + const p_s = FS.stat(p); + if (FS.isFile(p_s.mode)) { + FS.unlink(p); + } else if (FS.isDir(p)) { + recursive_remove(p); + } + }); + FS.rmdir(dirpath); + }("/tmp/filedrop"); + + FS.rmdir("/tmp/filedrop"); + target.removeEventListener("dragover", SDL3.eventHandlerDropDragover); + SDL3.eventHandlerDropDragover = undefined; + SDL3.eventHandlerDropDrop = undefined; + SDL3.eventHandlerDropDragend = undefined; + } + }, data->canvas_id); +} + +void Emscripten_RegisterEventHandlers(SDL_WindowData *data) +{ + const char *keyElement; + + // There is only one window and that window is the canvas + emscripten_set_mousemove_callback(data->canvas_id, data, 0, Emscripten_HandleMouseMove); + + emscripten_set_mousedown_callback(data->canvas_id, data, 0, Emscripten_HandleMouseButton); + emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandleMouseButton); + + emscripten_set_mouseenter_callback(data->canvas_id, data, 0, Emscripten_HandleMouseFocus); + emscripten_set_mouseleave_callback(data->canvas_id, data, 0, Emscripten_HandleMouseFocus); + + emscripten_set_wheel_callback(data->canvas_id, data, 0, Emscripten_HandleWheel); + + emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, data, 0, Emscripten_HandleFocus); + emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, data, 0, Emscripten_HandleFocus); + + emscripten_set_orientationchange_callback(data, 0, Emscripten_HandleOrientationChange); + + emscripten_set_touchstart_callback(data->canvas_id, data, 0, Emscripten_HandleTouch); + emscripten_set_touchend_callback(data->canvas_id, data, 0, Emscripten_HandleTouch); + emscripten_set_touchmove_callback(data->canvas_id, data, 0, Emscripten_HandleTouch); + emscripten_set_touchcancel_callback(data->canvas_id, data, 0, Emscripten_HandleTouch); + + emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandlePointerLockChange); + + // Keyboard events are awkward + keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); + if (!keyElement || !*keyElement) { + keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW; + } + + if (SDL_strcmp(keyElement, "#none") != 0) { + emscripten_set_keydown_callback(keyElement, data, 0, Emscripten_HandleKey); + emscripten_set_keyup_callback(keyElement, data, 0, Emscripten_HandleKey); + emscripten_set_keypress_callback(keyElement, data, 0, Emscripten_HandleKeyPress); + } + + emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, data, 0, Emscripten_HandleFullscreenChange); + + emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, data, 0, Emscripten_HandleResize); + + emscripten_set_visibilitychange_callback(data, 0, Emscripten_HandleVisibilityChange); + + emscripten_set_beforeunload_callback(data, Emscripten_HandleBeforeUnload); + + // !!! FIXME: currently Emscripten doesn't have a Pointer Events functions like emscripten_set_*_callback, but we should use those when they do: + // !!! FIXME: https://github.com/emscripten-core/emscripten/issues/7278#issuecomment-2280024621 + Emscripten_set_pointer_event_callbacks(data); + + // !!! FIXME: currently Emscripten doesn't have a Drop Events functions like emscripten_set_*_callback, but we should use those when they do: + Emscripten_set_drag_event_callbacks(data); +} + +void Emscripten_UnregisterEventHandlers(SDL_WindowData *data) +{ + const char *target; + + // !!! FIXME: currently Emscripten doesn't have a Drop Events functions like emscripten_set_*_callback, but we should use those when they do: + Emscripten_unset_drag_event_callbacks(data); + + // !!! FIXME: currently Emscripten doesn't have a Pointer Events functions like emscripten_set_*_callback, but we should use those when they do: + // !!! FIXME: https://github.com/emscripten-core/emscripten/issues/7278#issuecomment-2280024621 + Emscripten_unset_pointer_event_callbacks(data); + + // only works due to having one window + emscripten_set_mousemove_callback(data->canvas_id, NULL, 0, NULL); + + emscripten_set_mousedown_callback(data->canvas_id, NULL, 0, NULL); + emscripten_set_mouseup_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL); + + emscripten_set_mouseenter_callback(data->canvas_id, NULL, 0, NULL); + emscripten_set_mouseleave_callback(data->canvas_id, NULL, 0, NULL); + + emscripten_set_wheel_callback(data->canvas_id, NULL, 0, NULL); + + emscripten_set_focus_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, NULL); + emscripten_set_blur_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, NULL); + + emscripten_set_orientationchange_callback(NULL, 0, NULL); + + emscripten_set_touchstart_callback(data->canvas_id, NULL, 0, NULL); + emscripten_set_touchend_callback(data->canvas_id, NULL, 0, NULL); + emscripten_set_touchmove_callback(data->canvas_id, NULL, 0, NULL); + emscripten_set_touchcancel_callback(data->canvas_id, NULL, 0, NULL); + + emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL); + + target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); + if (!target || !*target) { + target = EMSCRIPTEN_EVENT_TARGET_WINDOW; + } + + if (SDL_strcmp(target, "#none") != 0) { + emscripten_set_keydown_callback(target, NULL, 0, NULL); + emscripten_set_keyup_callback(target, NULL, 0, NULL); + emscripten_set_keypress_callback(target, NULL, 0, NULL); + } + + emscripten_set_fullscreenchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL); + + emscripten_set_resize_callback(EMSCRIPTEN_EVENT_TARGET_WINDOW, NULL, 0, NULL); + + emscripten_set_visibilitychange_callback(NULL, 0, NULL); + + emscripten_set_beforeunload_callback(NULL, NULL); +} + +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.h b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.h new file mode 100644 index 0000000..fcfacec --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenevents.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_emscriptenevents_h_ +#define SDL_emscriptenevents_h_ + +#include "SDL_emscriptenvideo.h" + +extern void Emscripten_RegisterEventHandlers(SDL_WindowData *data); +extern void Emscripten_UnregisterEventHandlers(SDL_WindowData *data); +extern EM_BOOL Emscripten_HandleCanvasResize(int eventType, const void *reserved, void *userData); + +#endif // SDL_emscriptenevents_h_ diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.c b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.c new file mode 100644 index 0000000..503fac6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -0,0 +1,161 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN + +#include "SDL_emscriptenvideo.h" +#include "SDL_emscriptenframebuffer.h" + +#include + +bool Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_Surface *surface; + const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XBGR8888; + int w, h; + + // Free the old framebuffer surface + SDL_WindowData *data = window->internal; + surface = data->surface; + SDL_DestroySurface(surface); + + // Create a new one + SDL_GetWindowSizeInPixels(window, &w, &h); + + surface = SDL_CreateSurface(w, h, surface_format); + if (!surface) { + return false; + } + + // Save the info and return! + data->surface = surface; + *format = surface_format; + *pixels = surface->pixels; + *pitch = surface->pitch; + return true; +} + +bool Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_Surface *surface; + + SDL_WindowData *data = window->internal; + surface = data->surface; + if (!surface) { + return SDL_SetError("Couldn't find framebuffer surface for window"); + } + + // Send the data to the display + + /* *INDENT-OFF* */ // clang-format off + MAIN_THREAD_EM_ASM({ + var w = $0; + var h = $1; + var pixels = $2; + var canvasId = UTF8ToString($3); + var canvas = document.querySelector(canvasId); + + //TODO: this should store a context per canvas + if (!Module['SDL3']) Module['SDL3'] = {}; + var SDL3 = Module['SDL3']; + if (SDL3.ctxCanvas !== canvas) { + SDL3.ctx = Module['createContext'](canvas, false, true); + SDL3.ctxCanvas = canvas; + } + if (SDL3.w !== w || SDL3.h !== h || SDL3.imageCtx !== SDL3.ctx) { + SDL3.image = SDL3.ctx.createImageData(w, h); + SDL3.w = w; + SDL3.h = h; + SDL3.imageCtx = SDL3.ctx; + } + var data = SDL3.image.data; + var src = pixels / 4; + var dst = 0; + var num; + + if (SDL3.data32Data !== data) { + SDL3.data32 = new Int32Array(data.buffer); + SDL3.data8 = new Uint8Array(data.buffer); + SDL3.data32Data = data; + } + var data32 = SDL3.data32; + num = data32.length; + // logically we need to do + // while (dst < num) { + // data32[dst++] = HEAP32[src++] | 0xff000000 + // } + // the following code is faster though, because + // .set() is almost free - easily 10x faster due to + // native SDL_memcpy efficiencies, and the remaining loop + // just stores, not load + store, so it is faster + data32.set(HEAP32.subarray(src, src + num)); + var data8 = SDL3.data8; + var i = 3; + var j = i + 4*num; + if (num % 8 == 0) { + // unrolling gives big speedups + while (i < j) { + data8[i] = 0xff; + i = i + 4 | 0; + data8[i] = 0xff; + i = i + 4 | 0; + data8[i] = 0xff; + i = i + 4 | 0; + data8[i] = 0xff; + i = i + 4 | 0; + data8[i] = 0xff; + i = i + 4 | 0; + data8[i] = 0xff; + i = i + 4 | 0; + data8[i] = 0xff; + i = i + 4 | 0; + data8[i] = 0xff; + i = i + 4 | 0; + } + } else { + while (i < j) { + data8[i] = 0xff; + i = i + 4 | 0; + } + } + + SDL3.ctx.putImageData(SDL3.image, 0, 0); + }, surface->w, surface->h, surface->pixels, data->canvas_id); + /* *INDENT-ON* */ // clang-format on + + if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, true)) { + // give back control to browser for screen refresh + emscripten_sleep(0); + } + + return true; +} + +void Emscripten_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + SDL_DestroySurface(data->surface); + data->surface = NULL; +} + +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.h b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.h new file mode 100644 index 0000000..1be7079 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenframebuffer.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_emscriptenframebuffer_h_ +#define SDL_emscriptenframebuffer_h_ + +extern bool Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void Emscripten_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_emscriptenframebuffer_h_ diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.c b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.c new file mode 100644 index 0000000..c959804 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.c @@ -0,0 +1,216 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN + +#include +#include +#include + +#include "SDL_emscriptenmouse.h" +#include "SDL_emscriptenvideo.h" + +#include "../SDL_video_c.h" +#include "../../events/SDL_mouse_c.h" + +// older Emscriptens don't have this, but we need to for wasm64 compatibility. +#ifndef MAIN_THREAD_EM_ASM_PTR + #ifdef __wasm64__ + #error You need to upgrade your Emscripten compiler to support wasm64 + #else + #define MAIN_THREAD_EM_ASM_PTR MAIN_THREAD_EM_ASM_INT + #endif +#endif + +static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, bool is_custom) +{ + SDL_CursorData *curdata; + SDL_Cursor *cursor = SDL_calloc(1, sizeof(SDL_Cursor)); + if (cursor) { + curdata = (SDL_CursorData *)SDL_calloc(1, sizeof(*curdata)); + if (!curdata) { + SDL_free(cursor); + return NULL; + } + + curdata->system_cursor = cursor_str; + curdata->is_custom = is_custom; + cursor->internal = curdata; + } + + return cursor; +} + +static SDL_Cursor *Emscripten_CreateDefaultCursor(void) +{ + SDL_SystemCursor id = SDL_GetDefaultSystemCursor(); + const char *cursor_name = SDL_GetCSSCursorName(id, NULL); + return Emscripten_CreateCursorFromString(cursor_name, false); +} + +EM_JS_DEPS(sdlmouse, "$stringToUTF8,$UTF8ToString"); + +static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + const char *cursor_url = NULL; + SDL_Surface *conv_surf; + + conv_surf = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ABGR8888); + + if (!conv_surf) { + return NULL; + } + + /* *INDENT-OFF* */ // clang-format off + cursor_url = (const char *)MAIN_THREAD_EM_ASM_PTR({ + var w = $0; + var h = $1; + var hot_x = $2; + var hot_y = $3; + var pixels = $4; + + var canvas = document.createElement("canvas"); + canvas.width = w; + canvas.height = h; + + var ctx = canvas.getContext("2d"); + + var image = ctx.createImageData(w, h); + var data = image.data; + var src = pixels / 4; + + var data32 = new Int32Array(data.buffer); + data32.set(HEAP32.subarray(src, src + data32.length)); + + ctx.putImageData(image, 0, 0); + var url = hot_x === 0 && hot_y === 0 + ? "url(" + canvas.toDataURL() + "), auto" + : "url(" + canvas.toDataURL() + ") " + hot_x + " " + hot_y + ", auto"; + + var urlBuf = _SDL_malloc(url.length + 1); + stringToUTF8(url, urlBuf, url.length + 1); + + return urlBuf; + }, surface->w, surface->h, hot_x, hot_y, conv_surf->pixels); + /* *INDENT-ON* */ // clang-format on + + SDL_DestroySurface(conv_surf); + + return Emscripten_CreateCursorFromString(cursor_url, true); +} + +static SDL_Cursor *Emscripten_CreateSystemCursor(SDL_SystemCursor id) +{ + const char *cursor_name = SDL_GetCSSCursorName(id, NULL); + + return Emscripten_CreateCursorFromString(cursor_name, false); +} + +static void Emscripten_FreeCursor(SDL_Cursor *cursor) +{ + SDL_CursorData *curdata; + if (cursor) { + curdata = cursor->internal; + + if (curdata) { + if (curdata->is_custom) { + SDL_free((char *)curdata->system_cursor); + } + SDL_free(cursor->internal); + } + + SDL_free(cursor); + } +} + +static bool Emscripten_ShowCursor(SDL_Cursor *cursor) +{ + SDL_CursorData *curdata; + if (SDL_GetMouseFocus() != NULL) { + if (cursor && cursor->internal) { + curdata = cursor->internal; + + if (curdata->system_cursor) { + /* *INDENT-OFF* */ // clang-format off + MAIN_THREAD_EM_ASM({ + if (Module['canvas']) { + Module['canvas'].style['cursor'] = UTF8ToString($0); + } + }, curdata->system_cursor); + /* *INDENT-ON* */ // clang-format on + } + } else { + /* *INDENT-OFF* */ // clang-format off + MAIN_THREAD_EM_ASM( + if (Module['canvas']) { + Module['canvas'].style['cursor'] = 'none'; + } + ); + /* *INDENT-ON* */ // clang-format on + } + } + return true; +} + +static bool Emscripten_SetRelativeMouseMode(bool enabled) +{ + SDL_Window *window; + SDL_WindowData *window_data; + + // TODO: pointer lock isn't actually enabled yet + if (enabled) { + window = SDL_GetMouseFocus(); + if (!window) { + return false; + } + + window_data = window->internal; + + if (emscripten_request_pointerlock(window_data->canvas_id, 1) >= EMSCRIPTEN_RESULT_SUCCESS) { + return true; + } + } else { + if (emscripten_exit_pointerlock() >= EMSCRIPTEN_RESULT_SUCCESS) { + return true; + } + } + return false; +} + +void Emscripten_InitMouse(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = Emscripten_CreateCursor; + mouse->ShowCursor = Emscripten_ShowCursor; + mouse->FreeCursor = Emscripten_FreeCursor; + mouse->CreateSystemCursor = Emscripten_CreateSystemCursor; + mouse->SetRelativeMouseMode = Emscripten_SetRelativeMouseMode; + + SDL_SetDefaultCursor(Emscripten_CreateDefaultCursor()); +} + +void Emscripten_QuitMouse(void) +{ +} + +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.h b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.h new file mode 100644 index 0000000..5fcfeb5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenmouse.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_emscriptenmouse_h_ +#define SDL_emscriptenmouse_h_ + +struct SDL_CursorData +{ + const char *system_cursor; + bool is_custom; +}; + +extern void Emscripten_InitMouse(void); +extern void Emscripten_QuitMouse(void); + +#endif // SDL_emscriptenmouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.c b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.c new file mode 100644 index 0000000..227cdc5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.c @@ -0,0 +1,162 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN + +#include +#include +#include + +#include "SDL_emscriptenvideo.h" +#include "SDL_emscriptenopengles.h" + +bool Emscripten_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + return true; +} + +void Emscripten_GLES_UnloadLibrary(SDL_VideoDevice *_this) +{ +} + +SDL_FunctionPointer Emscripten_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + return emscripten_webgl_get_proc_address(proc); +} + +bool Emscripten_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + if (interval < 0) { + return SDL_SetError("Late swap tearing currently unsupported"); + } + + if (Emscripten_ShouldSetSwapInterval(interval)) { + if (interval == 0) { + emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, 0); + } else { + emscripten_set_main_loop_timing(EM_TIMING_RAF, interval); + } + } + + return true; +} + +bool Emscripten_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + int mode, value; + + emscripten_get_main_loop_timing(&mode, &value); + + if (mode == EM_TIMING_RAF) { + *interval = value; + return true; + } else { + *interval = 0; + return true; + } +} + +SDL_GLContext Emscripten_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *window_data; + + EmscriptenWebGLContextAttributes attribs; + EMSCRIPTEN_WEBGL_CONTEXT_HANDLE context; + + emscripten_webgl_init_context_attributes(&attribs); + + attribs.alpha = _this->gl_config.alpha_size > 0; + attribs.depth = _this->gl_config.depth_size > 0; + attribs.stencil = _this->gl_config.stencil_size > 0; + attribs.antialias = _this->gl_config.multisamplebuffers == 1; + + if (_this->gl_config.major_version == 3) + attribs.majorVersion = 2; // WebGL 2.0 ~= GLES 3.0 + + window_data = window->internal; + + if (window_data->gl_context) { + SDL_SetError("Cannot create multiple webgl contexts per window"); + return NULL; + } + + context = emscripten_webgl_create_context(window_data->canvas_id, &attribs); + + if (context < 0) { + SDL_SetError("Could not create webgl context"); + return NULL; + } + + if (emscripten_webgl_make_context_current(context) != EMSCRIPTEN_RESULT_SUCCESS) { + emscripten_webgl_destroy_context(context); + return NULL; + } + + window_data->gl_context = (SDL_GLContext)context; + + return (SDL_GLContext)context; +} + +bool Emscripten_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + SDL_Window *window; + + // remove the context from its window + for (window = _this->windows; window; window = window->next) { + SDL_WindowData *window_data = window->internal; + + if (window_data->gl_context == context) { + window_data->gl_context = NULL; + } + } + + emscripten_webgl_destroy_context((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)context); + return true; +} + +bool Emscripten_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (emscripten_has_asyncify() && SDL_GetHintBoolean(SDL_HINT_EMSCRIPTEN_ASYNCIFY, true)) { + // give back control to browser for screen refresh + emscripten_sleep(0); + } + return true; +} + +bool Emscripten_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + // it isn't possible to reuse contexts across canvases + if (window && context) { + SDL_WindowData *window_data = window->internal; + + if (context != window_data->gl_context) { + return SDL_SetError("Cannot make context current to another window"); + } + } + + if (emscripten_webgl_make_context_current((EMSCRIPTEN_WEBGL_CONTEXT_HANDLE)context) != EMSCRIPTEN_RESULT_SUCCESS) { + return SDL_SetError("Unable to make context current"); + } + return true; +} + +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.h b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.h new file mode 100644 index 0000000..d0af111 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenopengles.h @@ -0,0 +1,43 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_emscriptenopengles_h_ +#define SDL_emscriptenopengles_h_ + +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN + +#include "../SDL_sysvideo.h" + +// OpenGLES functions +extern bool Emscripten_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void Emscripten_GLES_UnloadLibrary(SDL_VideoDevice *_this); +extern SDL_FunctionPointer Emscripten_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern bool Emscripten_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool Emscripten_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern SDL_GLContext Emscripten_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Emscripten_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern bool Emscripten_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Emscripten_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); + +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN + +#endif // SDL_emscriptenopengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.c b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.c new file mode 100644 index 0000000..1496268 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.c @@ -0,0 +1,459 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_EMSCRIPTEN + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_emscriptenvideo.h" +#include "SDL_emscriptenopengles.h" +#include "SDL_emscriptenframebuffer.h" +#include "SDL_emscriptenevents.h" +#include "SDL_emscriptenmouse.h" + +#define EMSCRIPTENVID_DRIVER_NAME "emscripten" + +// Initialization/Query functions +static bool Emscripten_VideoInit(SDL_VideoDevice *_this); +static bool Emscripten_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +static void Emscripten_VideoQuit(SDL_VideoDevice *_this); +static bool Emscripten_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); + +static bool Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +static void Emscripten_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +static void Emscripten_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); +static void Emscripten_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +static SDL_FullscreenResult Emscripten_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); +static void Emscripten_PumpEvents(SDL_VideoDevice *_this); +static void Emscripten_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); + +static bool pumpevents_has_run = false; +static int pending_swap_interval = -1; + + +// Emscripten driver bootstrap functions + +static void Emscripten_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device); +} + +static SDL_SystemTheme Emscripten_GetSystemTheme(void) +{ + /* Technically, light theme can mean explicit light theme or no preference. + https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme#syntax */ + + int theme_code = EM_ASM_INT({ + if (!window.matchMedia) { + return -1; + } + + if (window.matchMedia('(prefers-color-scheme: light)').matches) { + return 0; + } + + if (window.matchMedia('(prefers-color-scheme: dark)').matches) { + return 1; + } + + return -1; + }); + + switch (theme_code) { + case 0: + return SDL_SYSTEM_THEME_LIGHT; + + case 1: + return SDL_SYSTEM_THEME_DARK; + + default: + return SDL_SYSTEM_THEME_UNKNOWN; + } +} + +static void Emscripten_ListenSystemTheme(void) +{ + MAIN_THREAD_EM_ASM({ + if (window.matchMedia) { + if (typeof(Module['SDL3']) === 'undefined') { + Module['SDL3'] = {}; + } + + var SDL3 = Module['SDL3']; + + SDL3.eventHandlerThemeChanged = function(event) { + _Emscripten_SendSystemThemeChangedEvent(); + }; + + SDL3.themeChangedMatchMedia = window.matchMedia('(prefers-color-scheme: dark)'); + SDL3.themeChangedMatchMedia.addEventListener('change', SDL3.eventHandlerThemeChanged); + } + }); +} + +static void Emscripten_UnlistenSystemTheme(void) +{ + MAIN_THREAD_EM_ASM({ + if (typeof(Module['SDL3']) !== 'undefined') { + var SDL3 = Module['SDL3']; + + SDL3.themeChangedMatchMedia.removeEventListener('change', SDL3.eventHandlerThemeChanged); + SDL3.themeChangedMatchMedia = undefined; + SDL3.eventHandlerThemeChanged = undefined; + } + }); +} + +EMSCRIPTEN_KEEPALIVE void Emscripten_SendSystemThemeChangedEvent(void) +{ + SDL_SetSystemTheme(Emscripten_GetSystemTheme()); +} + +static SDL_VideoDevice *Emscripten_CreateDevice(void) +{ + SDL_VideoDevice *device; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + /* Firefox sends blur event which would otherwise prevent full screen + * when the user clicks to allow full screen. + * See https://bugzilla.mozilla.org/show_bug.cgi?id=1144964 + */ + SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); + + // Set the function pointers + device->VideoInit = Emscripten_VideoInit; + device->VideoQuit = Emscripten_VideoQuit; + device->GetDisplayUsableBounds = Emscripten_GetDisplayUsableBounds; + device->SetDisplayMode = Emscripten_SetDisplayMode; + + device->PumpEvents = Emscripten_PumpEvents; + + device->CreateSDLWindow = Emscripten_CreateWindow; + device->SetWindowTitle = Emscripten_SetWindowTitle; + /*device->SetWindowIcon = Emscripten_SetWindowIcon; + device->SetWindowPosition = Emscripten_SetWindowPosition;*/ + device->SetWindowSize = Emscripten_SetWindowSize; + /*device->ShowWindow = Emscripten_ShowWindow; + device->HideWindow = Emscripten_HideWindow; + device->RaiseWindow = Emscripten_RaiseWindow; + device->MaximizeWindow = Emscripten_MaximizeWindow; + device->MinimizeWindow = Emscripten_MinimizeWindow; + device->RestoreWindow = Emscripten_RestoreWindow; + device->SetWindowMouseGrab = Emscripten_SetWindowMouseGrab;*/ + device->GetWindowSizeInPixels = Emscripten_GetWindowSizeInPixels; + device->DestroyWindow = Emscripten_DestroyWindow; + device->SetWindowFullscreen = Emscripten_SetWindowFullscreen; + + device->CreateWindowFramebuffer = Emscripten_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = Emscripten_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = Emscripten_DestroyWindowFramebuffer; + + device->GL_LoadLibrary = Emscripten_GLES_LoadLibrary; + device->GL_GetProcAddress = Emscripten_GLES_GetProcAddress; + device->GL_UnloadLibrary = Emscripten_GLES_UnloadLibrary; + device->GL_CreateContext = Emscripten_GLES_CreateContext; + device->GL_MakeCurrent = Emscripten_GLES_MakeCurrent; + device->GL_SetSwapInterval = Emscripten_GLES_SetSwapInterval; + device->GL_GetSwapInterval = Emscripten_GLES_GetSwapInterval; + device->GL_SwapWindow = Emscripten_GLES_SwapWindow; + device->GL_DestroyContext = Emscripten_GLES_DestroyContext; + + device->free = Emscripten_DeleteDevice; + + Emscripten_ListenSystemTheme(); + device->system_theme = Emscripten_GetSystemTheme(); + + return device; +} + +VideoBootStrap Emscripten_bootstrap = { + EMSCRIPTENVID_DRIVER_NAME, "SDL emscripten video driver", + Emscripten_CreateDevice, + NULL, // no ShowMessageBox implementation + false +}; + +bool Emscripten_VideoInit(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; + + // Use a fake 32-bpp desktop mode + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_XRGB8888; + emscripten_get_screen_size(&mode.w, &mode.h); + mode.pixel_density = emscripten_get_device_pixel_ratio(); + + if (SDL_AddBasicVideoDisplay(&mode) == 0) { + return false; + } + + Emscripten_InitMouse(); + + // Assume we have a mouse and keyboard + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); + + // We're done! + return true; +} + +static bool Emscripten_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + // can't do this + return true; +} + +static void Emscripten_VideoQuit(SDL_VideoDevice *_this) +{ + Emscripten_QuitMouse(); + Emscripten_UnlistenSystemTheme(); + pumpevents_has_run = false; + pending_swap_interval = -1; +} + +static bool Emscripten_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + if (rect) { + rect->x = 0; + rect->y = 0; + rect->w = MAIN_THREAD_EM_ASM_INT({ + return window.innerWidth; + }); + rect->h = MAIN_THREAD_EM_ASM_INT({ + return window.innerHeight; + }); + } + return true; +} + +bool Emscripten_ShouldSetSwapInterval(int interval) +{ + if (!pumpevents_has_run) { + pending_swap_interval = interval; + return false; + } + return true; +} + +static void Emscripten_PumpEvents(SDL_VideoDevice *_this) +{ + if (!pumpevents_has_run) { + // we assume you've set a mainloop by the time you've called pumpevents, so we delay initial SetInterval changes until then. + // otherwise you'll get a warning on the javascript console. + pumpevents_has_run = true; + if (pending_swap_interval >= 0) { + Emscripten_GLES_SetSwapInterval(_this, pending_swap_interval); + pending_swap_interval = -1; + } + } +} + +EMSCRIPTEN_KEEPALIVE void requestFullscreenThroughSDL(SDL_Window *window) +{ + SDL_SetWindowFullscreen(window, true); +} + +static bool Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + SDL_WindowData *wdata; + double scaled_w, scaled_h; + double css_w, css_h; + const char *selector; + + // Allocate window internal data + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!wdata) { + return false; + } + + selector = SDL_GetHint(SDL_HINT_EMSCRIPTEN_CANVAS_SELECTOR); + if (!selector) { + selector = "#canvas"; + } + + wdata->canvas_id = SDL_strdup(selector); + + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + wdata->pixel_ratio = emscripten_get_device_pixel_ratio(); + } else { + wdata->pixel_ratio = 1.0f; + } + + scaled_w = SDL_floor(window->w * wdata->pixel_ratio); + scaled_h = SDL_floor(window->h * wdata->pixel_ratio); + + // set a fake size to check if there is any CSS sizing the canvas + emscripten_set_canvas_element_size(wdata->canvas_id, 1, 1); + emscripten_get_element_css_size(wdata->canvas_id, &css_w, &css_h); + + wdata->external_size = SDL_floor(css_w) != 1 || SDL_floor(css_h) != 1; + + if ((window->flags & SDL_WINDOW_RESIZABLE) && wdata->external_size) { + // external css has resized us + scaled_w = css_w * wdata->pixel_ratio; + scaled_h = css_h * wdata->pixel_ratio; + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, SDL_lroundf(css_w), SDL_lroundf(css_h)); + } + emscripten_set_canvas_element_size(wdata->canvas_id, SDL_lroundf(scaled_w), SDL_lroundf(scaled_h)); + + // if the size is not being controlled by css, we need to scale down for hidpi + if (!wdata->external_size) { + if (wdata->pixel_ratio != 1.0f) { + // scale canvas down + emscripten_set_element_css_size(wdata->canvas_id, window->w, window->h); + } + } + + wdata->window = window; + + // Setup driver data for this window + window->internal = wdata; + + // One window, it always has focus + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + Emscripten_RegisterEventHandlers(wdata); + + // disable the emscripten "fullscreen" button. + MAIN_THREAD_EM_ASM({ + Module['requestFullscreen'] = function(lockPointer, resizeCanvas) { + _requestFullscreenThroughSDL($0); + }; + }, window); + + // Window has been successfully created + return true; +} + +static void Emscripten_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data; + + if (window->internal) { + data = window->internal; + // update pixel ratio + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + data->pixel_ratio = emscripten_get_device_pixel_ratio(); + } + emscripten_set_canvas_element_size(data->canvas_id, SDL_lroundf(window->pending.w * data->pixel_ratio), SDL_lroundf(window->pending.h * data->pixel_ratio)); + + // scale canvas down + if (!data->external_size && data->pixel_ratio != 1.0f) { + emscripten_set_element_css_size(data->canvas_id, window->pending.w, window->pending.h); + } + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->pending.w, window->pending.h); + } +} + +static void Emscripten_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) +{ + SDL_WindowData *data; + if (window->internal) { + data = window->internal; + *w = SDL_lroundf(window->w * data->pixel_ratio); + *h = SDL_lroundf(window->h * data->pixel_ratio); + } +} + +static void Emscripten_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data; + + if (window->internal) { + data = window->internal; + + Emscripten_UnregisterEventHandlers(data); + + // We can't destroy the canvas, so resize it to zero instead + emscripten_set_canvas_element_size(data->canvas_id, 0, 0); + SDL_free(data->canvas_id); + + SDL_free(window->internal); + window->internal = NULL; + } + + // just ignore clicks on the fullscreen button while there's no SDL window. + MAIN_THREAD_EM_ASM({ Module['requestFullscreen'] = function(lockPointer, resizeCanvas) {}; }); +} + +static SDL_FullscreenResult Emscripten_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) +{ + SDL_WindowData *data; + int res = -1; + + if (window->internal) { + data = window->internal; + + if (fullscreen) { + EmscriptenFullscreenStrategy strategy; + bool is_fullscreen_desktop = !window->fullscreen_exclusive; + + SDL_zero(strategy); + strategy.scaleMode = is_fullscreen_desktop ? EMSCRIPTEN_FULLSCREEN_SCALE_STRETCH : EMSCRIPTEN_FULLSCREEN_SCALE_ASPECT; + + if (!is_fullscreen_desktop) { + strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_NONE; + } else if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_HIDEF; + } else { + strategy.canvasResolutionScaleMode = EMSCRIPTEN_FULLSCREEN_CANVAS_SCALE_STDDEF; + } + + strategy.filteringMode = EMSCRIPTEN_FULLSCREEN_FILTERING_DEFAULT; + + strategy.canvasResizedCallback = Emscripten_HandleCanvasResize; + strategy.canvasResizedCallbackUserData = data; + + data->fullscreen_mode_flags = (window->flags & SDL_WINDOW_FULLSCREEN); + data->fullscreen_resize = is_fullscreen_desktop; + + res = emscripten_request_fullscreen_strategy(data->canvas_id, 1, &strategy); + } else { + res = emscripten_exit_fullscreen(); + } + } + + if (res == EMSCRIPTEN_RESULT_SUCCESS) { + return SDL_FULLSCREEN_SUCCEEDED; + } else if (res == EMSCRIPTEN_RESULT_DEFERRED) { + return SDL_FULLSCREEN_PENDING; + } else { + return SDL_FULLSCREEN_FAILED; + } +} + +static void Emscripten_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ + emscripten_set_window_title(window->title); +} + +#endif // SDL_VIDEO_DRIVER_EMSCRIPTEN diff --git a/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.h b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.h new file mode 100644 index 0000000..892d074 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/emscripten/SDL_emscriptenvideo.h @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_emscriptenvideo_h_ +#define SDL_emscriptenvideo_h_ + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_touch_c.h" +#include +#include + +struct SDL_WindowData +{ + SDL_Window *window; + SDL_Surface *surface; + + SDL_GLContext gl_context; + + char *canvas_id; + + float pixel_ratio; + + bool external_size; + + Uint32 fullscreen_mode_flags; + bool fullscreen_resize; + + bool has_pointer_lock; + + bool mouse_focus_loss_pending; +}; + +bool Emscripten_ShouldSetSwapInterval(int interval); + +#endif // SDL_emscriptenvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.cpp b/contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.cpp new file mode 100644 index 0000000..e787871 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.cpp @@ -0,0 +1,321 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +/* + Screen keyboard and text input backend + for GDK platforms. +*/ +#include "SDL_internal.h" +#include "SDL_gdktextinput.h" + +#ifdef SDL_GDK_TEXTINPUT + +// GDK headers are weird here +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN +#endif +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../events/SDL_keyboard_c.h" +#include "../windows/SDL_windowsvideo.h" + +// TODO: Have a separate task queue for text input perhaps? +static XTaskQueueHandle g_TextTaskQueue = NULL; +// Global because there can be only one text entry shown at once. +static XAsyncBlock *g_TextBlock = NULL; + +// Creation parameters +static bool g_DidRegisterHints = false; +static char *g_TitleText = NULL; +static char *g_DescriptionText = NULL; +static char *g_DefaultText = NULL; +static const Sint32 g_DefaultTextInputScope = (Sint32)XGameUiTextEntryInputScope::Default; +static Sint32 g_TextInputScope = g_DefaultTextInputScope; +static const Sint32 g_DefaultMaxTextLength = 1024; // as per doc: maximum allowed amount on consoles +static Sint32 g_MaxTextLength = g_DefaultMaxTextLength; + +static void SDLCALL GDK_InternalHintCallback( + void *userdata, + const char *name, + const char *oldValue, + const char *newValue) +{ + if (!userdata) { + return; + } + + // oldValue is ignored because we store it ourselves. + // name is ignored because we deduce it from userdata + + if (userdata == &g_TextInputScope || userdata == &g_MaxTextLength) { + // int32 hint + Sint32 intValue = (!newValue || newValue[0] == '\0') ? 0 : SDL_atoi(newValue); + if (userdata == &g_MaxTextLength && intValue <= 0) { + intValue = g_DefaultMaxTextLength; + } else if (userdata == &g_TextInputScope && intValue < 0) { + intValue = g_DefaultTextInputScope; + } + + *(Sint32 *)userdata = intValue; + } else { + // string hint + if (!newValue || newValue[0] == '\0') { + // treat empty or NULL strings as just NULL for this impl + SDL_free(*(char **)userdata); + *(char **)userdata = NULL; + } else { + char *newString = SDL_strdup(newValue); + if (newString) { + // free previous value and write the new one + SDL_free(*(char **)userdata); + *(char **)userdata = newString; + } + } + } +} + +static bool GDK_InternalEnsureTaskQueue(void) +{ + if (!g_TextTaskQueue) { + if (!SDL_GetGDKTaskQueue(&g_TextTaskQueue)) { + // SetError will be done for us. + return false; + } + } + return true; +} + +static void CALLBACK GDK_InternalTextEntryCallback(XAsyncBlock *asyncBlock) +{ + HRESULT hR = S_OK; + Uint32 resultSize = 0; + Uint32 resultUsed = 0; + char *resultBuffer = NULL; + + // The keyboard will be already hidden when we reach this code + + if (FAILED(hR = XGameUiShowTextEntryResultSize( + asyncBlock, + &resultSize))) { + SDL_SetError("XGameUiShowTextEntryResultSize failure with HRESULT of %08X", hR); + } else if (resultSize > 0) { + // +1 to be super sure that the buffer will be null terminated + resultBuffer = (char *)SDL_calloc(1 + (size_t)resultSize, sizeof(*resultBuffer)); + if (resultBuffer) { + // still pass the original size that we got from ResultSize + if (FAILED(hR = XGameUiShowTextEntryResult( + asyncBlock, + resultSize, + resultBuffer, + &resultUsed))) { + SDL_SetError("XGameUiShowTextEntryResult failure with HRESULT of %08X", hR); + } + // check that we have some text and that we weren't cancelled + else if (resultUsed > 0 && resultBuffer[0] != '\0') { + // it's null terminated so it's fine + SDL_SendKeyboardText(resultBuffer); + } + // we're done with the buffer + SDL_free(resultBuffer); + resultBuffer = NULL; + } + } + + // free the async block after we're done + SDL_free(asyncBlock); + asyncBlock = NULL; + g_TextBlock = NULL; // once we do this we're fully done with the keyboard +} + +void GDK_EnsureHints(void) +{ + if (g_DidRegisterHints == false) { + SDL_AddHintCallback( + SDL_HINT_GDK_TEXTINPUT_TITLE, + GDK_InternalHintCallback, + &g_TitleText); + SDL_AddHintCallback( + SDL_HINT_GDK_TEXTINPUT_DESCRIPTION, + GDK_InternalHintCallback, + &g_DescriptionText); + SDL_AddHintCallback( + SDL_HINT_GDK_TEXTINPUT_DEFAULT_TEXT, + GDK_InternalHintCallback, + &g_DefaultText); + SDL_AddHintCallback( + SDL_HINT_GDK_TEXTINPUT_SCOPE, + GDK_InternalHintCallback, + &g_TextInputScope); + SDL_AddHintCallback( + SDL_HINT_GDK_TEXTINPUT_MAX_LENGTH, + GDK_InternalHintCallback, + &g_MaxTextLength); + g_DidRegisterHints = true; + } +} + +bool GDK_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + /* + * Currently a stub, since all input is handled by the virtual keyboard, + * but perhaps when implementing XGameUiTextEntryOpen in the future + * you will need this. + * + * Also XGameUiTextEntryOpen docs say that it is + * "not implemented on desktop" so... no thanks. + * + * Right now this function isn't implemented on Desktop + * and seems to be present only in the docs? So I didn't bother. + */ + return true; +} + +bool GDK_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + // See notice in GDK_StartTextInput + return true; +} + +bool GDK_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) +{ + /* + * XGameUiShowTextEntryAsync does not allow you to set + * the position of the virtual keyboard window. + * + * However, XGameUiTextEntryOpen seems to allow that, + * but again, see notice in GDK_StartTextInput. + * + * Right now it's a stub which may be useful later. + */ + return true; +} + +bool GDK_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window) +{ + // See notice in GDK_StartTextInput + return true; +} + +bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + // Currently always true for this input method + return true; +} + +void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + /* + * There is XGameUiTextEntryOpen but it's only in online docs, + * My October Update 1 GDKX installation does not have this function defined + * and as such I decided not to use it at all, since some folks might use even older GDKs. + * + * That means the only text input option for us is a simple virtual keyboard widget. + */ + + HRESULT hR = S_OK; + + if (g_TextBlock) { + // already showing the keyboard + return; + } + + if (!GDK_InternalEnsureTaskQueue()) { + // unable to obtain the SDL GDK queue + return; + } + + g_TextBlock = (XAsyncBlock *)SDL_calloc(1, sizeof(*g_TextBlock)); + if (!g_TextBlock) { + return; + } + + XGameUiTextEntryInputScope scope; + switch (SDL_GetTextInputType(props)) { + default: + case SDL_TEXTINPUT_TYPE_TEXT: + scope = (XGameUiTextEntryInputScope)g_TextInputScope; + break; + case SDL_TEXTINPUT_TYPE_TEXT_NAME: + scope = XGameUiTextEntryInputScope::Default; + break; + case SDL_TEXTINPUT_TYPE_TEXT_EMAIL: + scope = XGameUiTextEntryInputScope::EmailSmtpAddress; + break; + case SDL_TEXTINPUT_TYPE_TEXT_USERNAME: + scope = XGameUiTextEntryInputScope::Default; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN: + scope = XGameUiTextEntryInputScope::Password; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE: + scope = XGameUiTextEntryInputScope::Default; + break; + case SDL_TEXTINPUT_TYPE_NUMBER: + scope = XGameUiTextEntryInputScope::Number; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + // FIXME: Password or number scope? + scope = XGameUiTextEntryInputScope::Number; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE: + scope = XGameUiTextEntryInputScope::Number; + break; + } + + g_TextBlock->queue = g_TextTaskQueue; + g_TextBlock->context = _this; + g_TextBlock->callback = GDK_InternalTextEntryCallback; + if (FAILED(hR = XGameUiShowTextEntryAsync( + g_TextBlock, + g_TitleText, + g_DescriptionText, + g_DefaultText, + scope, + (uint32_t)g_MaxTextLength))) { + SDL_free(g_TextBlock); + g_TextBlock = NULL; + SDL_SetError("XGameUiShowTextEntryAsync failure with HRESULT of %08X", hR); + } +} + +void GDK_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (g_TextBlock) { + XAsyncCancel(g_TextBlock); + // the completion callback will free the block + } +} + +bool GDK_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +{ + return (g_TextBlock != NULL); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.h b/contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.h new file mode 100644 index 0000000..c3882ba --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/gdk/SDL_gdktextinput.h @@ -0,0 +1,50 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_gdktextinput_h_ +#define SDL_gdktextinput_h_ + +#ifdef SDL_GDK_TEXTINPUT +#ifdef __cplusplus +extern "C" { +#endif + +#include "../SDL_sysvideo.h" + +void GDK_EnsureHints(void); + +bool GDK_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +bool GDK_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); +bool GDK_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); +bool GDK_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window); + +bool GDK_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +void GDK_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); +bool GDK_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); + +#ifdef __cplusplus +} +#endif +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_BWin.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_BWin.h new file mode 100644 index 0000000..add3aaf --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_BWin.h @@ -0,0 +1,755 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BWin_h_ +#define SDL_BWin_h_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "SDL_internal.h" +#include "SDL_bframebuffer.h" + +#ifdef __cplusplus +} +#endif + +#include +#include +#include +#include +#ifdef SDL_VIDEO_OPENGL +#include +#endif +#include "../../core/haiku/SDL_BApp.h" + +enum WinCommands +{ + BWIN_MOVE_WINDOW, + BWIN_RESIZE_WINDOW, + BWIN_SHOW_WINDOW, + BWIN_HIDE_WINDOW, + BWIN_MAXIMIZE_WINDOW, + BWIN_MINIMIZE_WINDOW, + BWIN_RESTORE_WINDOW, + BWIN_SET_TITLE, + BWIN_SET_BORDERED, + BWIN_SET_RESIZABLE, + BWIN_FULLSCREEN, + BWIN_UPDATE_FRAMEBUFFER, + BWIN_MINIMUM_SIZE_WINDOW +}; + +// non-OpenGL framebuffer view +class SDL_BView : public BView +{ + public: + SDL_BView(BRect frame, const char *name, uint32 resizingMode) + : BView(frame, name, resizingMode, B_WILL_DRAW), + fBitmap(NULL) + { + } + + void Draw(BRect dirty) + { + if (fBitmap != NULL) + DrawBitmap(fBitmap, B_ORIGIN); + } + + void SetBitmap(BBitmap *bitmap) + { + fBitmap = bitmap; + } + + private: + BBitmap *fBitmap; +}; + +class SDL_BWin : public BWindow +{ + public: + // Constructor/Destructor + SDL_BWin(BRect bounds, window_look look, uint32 flags) + : BWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags) + { + _last_buttons = 0; + + _cur_view = NULL; + _SDL_View = NULL; + +#ifdef SDL_VIDEO_OPENGL + _SDL_GLView = NULL; + _gl_type = 0; +#endif + _shown = false; + _inhibit_resize = false; + _mouse_focused = false; + _prev_frame = NULL; + _fullscreen = NULL; + + // Handle framebuffer stuff + _buffer_locker = new BLocker(); + _bitmap = NULL; + } + + virtual ~SDL_BWin() + { + Lock(); + + if (_SDL_View != NULL && _SDL_View != _cur_view) { + delete _SDL_View; + _SDL_View = NULL; + } + +#ifdef SDL_VIDEO_OPENGL + if (_SDL_GLView) { + if (SDL_Looper->GetCurrentContext() == _SDL_GLView) + SDL_Looper->SetCurrentContext(NULL); + if (_SDL_GLView == _cur_view) + RemoveChild(_SDL_GLView); + _SDL_GLView = NULL; + // _SDL_GLView deleted by HAIKU_GL_DestroyContext + } + +#endif + Unlock(); + + delete _prev_frame; + + // Clean up framebuffer stuff + _buffer_locker->Lock(); + delete _buffer_locker; + } + + void SetCurrentView(BView *view) + { + if (_cur_view != view) { + if (_cur_view != NULL) + RemoveChild(_cur_view); + _cur_view = view; + if (_cur_view != NULL) + AddChild(_cur_view); + } + } + + void UpdateCurrentView() + { +#ifdef SDL_VIDEO_OPENGL + if (_SDL_GLView != NULL) { + SetCurrentView(_SDL_GLView); + } else +#endif + if (_SDL_View != NULL) { + SetCurrentView(_SDL_View); + } else { + SetCurrentView(NULL); + } + } + + SDL_BView *CreateView() + { + Lock(); + if (_SDL_View == NULL) { + _SDL_View = new SDL_BView(Bounds(), "SDL View", B_FOLLOW_ALL_SIDES); + UpdateCurrentView(); + } + Unlock(); + return _SDL_View; + } + + void RemoveView() + { + Lock(); + if (_SDL_View != NULL) { + SDL_BView *oldView = _SDL_View; + _SDL_View = NULL; + UpdateCurrentView(); + delete oldView; + } + Unlock(); + } + + /* * * * * OpenGL functionality * * * * */ +#ifdef SDL_VIDEO_OPENGL + BGLView *CreateGLView(Uint32 gl_flags) + { + Lock(); + if (_SDL_GLView == NULL) { + _SDL_GLView = new BGLView(Bounds(), "SDL GLView", + B_FOLLOW_ALL_SIDES, + (B_WILL_DRAW | B_FRAME_EVENTS), + gl_flags); + _gl_type = gl_flags; + UpdateCurrentView(); + } + Unlock(); + return _SDL_GLView; + } + + void RemoveGLView() + { + Lock(); + if (_SDL_GLView != NULL) { + if (SDL_Looper->GetCurrentContext() == _SDL_GLView) + SDL_Looper->SetCurrentContext(NULL); + _SDL_GLView = NULL; + UpdateCurrentView(); + // _SDL_GLView deleted by HAIKU_GL_DestroyContext + } + Unlock(); + } + + void SwapBuffers(void) + { + _SDL_GLView->SwapBuffers(); + } +#endif + + /* * * * * Event sending * * * * */ + // Hook functions + virtual void FrameMoved(BPoint origin) + { + // Post a message to the BApp so that it can handle the window event + BMessage msg(BAPP_WINDOW_MOVED); + msg.AddInt32("window-x", (int)origin.x); + msg.AddInt32("window-y", (int)origin.y); + _PostWindowEvent(msg); + + // Perform normal hook operations + BWindow::FrameMoved(origin); + } + + void FrameResized(float width, float height) + { + // Post a message to the BApp so that it can handle the window event + BMessage msg(BAPP_WINDOW_RESIZED); + + msg.AddInt32("window-w", (int)width + 1); + msg.AddInt32("window-h", (int)height + 1); + _PostWindowEvent(msg); + + // Perform normal hook operations + BWindow::FrameResized(width, height); + } + + bool QuitRequested() + { + BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED); + _PostWindowEvent(msg); + + // We won't allow a quit unless asked by DestroyWindow() + return false; + } + + void WindowActivated(bool active) + { + BMessage msg(BAPP_KEYBOARD_FOCUS); // Mouse focus sold separately + msg.AddBool("focusGained", active); + _PostWindowEvent(msg); + } + + void Zoom(BPoint origin, + float width, + float height) + { + BMessage msg(BAPP_MAXIMIZE); // Closest thing to maximization Haiku has + _PostWindowEvent(msg); + + // Before the window zooms, record its size + if (!_prev_frame) + _prev_frame = new BRect(Frame()); + + // Perform normal hook operations + BWindow::Zoom(origin, width, height); + } + + // Member functions + void Show() + { + while (IsHidden()) { + BWindow::Show(); + } + _shown = true; + + BMessage msg(BAPP_SHOW); + _PostWindowEvent(msg); + } + + void Hide() + { + BWindow::Hide(); + _shown = false; + + BMessage msg(BAPP_HIDE); + _PostWindowEvent(msg); + } + + void Minimize(bool minimize) + { + BWindow::Minimize(minimize); + int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE); + + BMessage msg(minState); + _PostWindowEvent(msg); + } + + void ScreenChanged(BRect screenFrame, color_space depth) + { + if (_fullscreen) { + MoveTo(screenFrame.left, screenFrame.top); + ResizeTo(screenFrame.Width(), screenFrame.Height()); + } + } + + // BView message interruption + void DispatchMessage(BMessage *msg, BHandler *target) + { + BPoint where; // Used by mouse moved + int32 buttons; // Used for mouse button events + int32 key; // Used for key events + + switch (msg->what) { + case B_MOUSE_MOVED: + int32 transit; + if (msg->FindPoint("where", &where) == B_OK && msg->FindInt32("be:transit", &transit) == B_OK) { + _MouseMotionEvent(where, transit); + } + break; + + case B_MOUSE_DOWN: + if (msg->FindInt32("buttons", &buttons) == B_OK) { + _MouseButtonEvent(buttons, true); + } + break; + + case B_MOUSE_UP: + if (msg->FindInt32("buttons", &buttons) == B_OK) { + _MouseButtonEvent(buttons, false); + } + break; + + case B_MOUSE_WHEEL_CHANGED: + float x, y; + if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { + _MouseWheelEvent((int)x, (int)y); + } + break; + + case B_KEY_DOWN: + { + int32 i = 0; + int8 byte; + int8 bytes[4] = { 0, 0, 0, 0 }; + while (i < 4 && msg->FindInt8("byte", i, &byte) == B_OK) { + bytes[i] = byte; + i++; + } + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent((SDL_Scancode)key, &bytes[0], i, true); + } + } break; + + case B_UNMAPPED_KEY_DOWN: // modifier keys are unmapped + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent((SDL_Scancode)key, NULL, 0, true); + } + break; + + case B_KEY_UP: + case B_UNMAPPED_KEY_UP: // modifier keys are unmapped + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent(key, NULL, 0, false); + } + break; + + default: + /* move it after switch{} so it's always handled + that way we keep Haiku features like: + - CTRL+Q to close window (and other shortcuts) + - PrintScreen to make screenshot into /boot/home + - etc.. */ + // BWindow::DispatchMessage(msg, target); + break; + } + + BWindow::DispatchMessage(msg, target); + } + + // Handle command messages + void MessageReceived(BMessage *message) + { + switch (message->what) { + // Handle commands from SDL + case BWIN_SET_TITLE: + _SetTitle(message); + break; + case BWIN_MOVE_WINDOW: + _MoveTo(message); + break; + case BWIN_RESIZE_WINDOW: + _ResizeTo(message); + break; + case BWIN_SET_BORDERED: + { + bool bEnabled; + if (message->FindBool("window-border", &bEnabled) == B_OK) + _SetBordered(bEnabled); + break; + } + case BWIN_SET_RESIZABLE: + { + bool bEnabled; + if (message->FindBool("window-resizable", &bEnabled) == B_OK) + _SetResizable(bEnabled); + break; + } + case BWIN_SHOW_WINDOW: + Show(); + break; + case BWIN_HIDE_WINDOW: + Hide(); + break; + case BWIN_MAXIMIZE_WINDOW: + BWindow::Zoom(); + break; + case BWIN_MINIMIZE_WINDOW: + Minimize(true); + break; + case BWIN_RESTORE_WINDOW: + _Restore(); + break; + case BWIN_FULLSCREEN: + { + bool fullscreen; + if (message->FindBool("fullscreen", &fullscreen) == B_OK) + _SetFullScreen(fullscreen); + break; + } + case BWIN_MINIMUM_SIZE_WINDOW: + _SetMinimumSize(message); + break; + case BWIN_UPDATE_FRAMEBUFFER: + { + BMessage *pendingMessage; + while ((pendingMessage = MessageQueue()->FindMessage(BWIN_UPDATE_FRAMEBUFFER, 0))) { + MessageQueue()->RemoveMessage(pendingMessage); + delete pendingMessage; + } + if (_bitmap != NULL) { +#ifdef SDL_VIDEO_OPENGL + if (_SDL_GLView != NULL && _cur_view == _SDL_GLView) { + _SDL_GLView->CopyPixelsIn(_bitmap, B_ORIGIN); + } else +#endif + if (_SDL_View != NULL && _cur_view == _SDL_View) { + _SDL_View->Draw(Bounds()); + } + } + break; + } + default: + // Perform normal message handling + BWindow::MessageReceived(message); + break; + } + } + + // Accessor methods + bool IsShown() { return _shown; } + int32 GetID() { return _id; } + BBitmap *GetBitmap() { return _bitmap; } + BView *GetCurView() { return _cur_view; } + SDL_BView *GetView() { return _SDL_View; } +#ifdef SDL_VIDEO_OPENGL + BGLView *GetGLView() + { + return _SDL_GLView; + } + Uint32 GetGLType() { return _gl_type; } +#endif + + // Setter methods + void SetID(int32 id) { _id = id; } + void LockBuffer() { _buffer_locker->Lock(); } + void UnlockBuffer() { _buffer_locker->Unlock(); } + void SetBitmap(BBitmap *bitmap) + { + _bitmap = bitmap; + if (_SDL_View != NULL) + _SDL_View->SetBitmap(bitmap); + } + + private: + // Event redirection + void _MouseMotionEvent(BPoint &where, int32 transit) + { + if (transit == B_EXITED_VIEW) { + // Change mouse focus + if (_mouse_focused) { + _MouseFocusEvent(false); + } + } else { + // Change mouse focus + if (!_mouse_focused) { + _MouseFocusEvent(true); + } + BMessage msg(BAPP_MOUSE_MOVED); + msg.AddInt32("x", (int)where.x); + msg.AddInt32("y", (int)where.y); + + _PostWindowEvent(msg); + } + } + + void _MouseFocusEvent(bool focusGained) + { + _mouse_focused = focusGained; + BMessage msg(BAPP_MOUSE_FOCUS); + msg.AddBool("focusGained", focusGained); + _PostWindowEvent(msg); + + /* FIXME: Why were these here? + if false: be_app->SetCursor(B_HAND_CURSOR); + if true: SDL_SetCursor(NULL); */ + } + + void _MouseButtonEvent(int32 buttons, bool down) + { + int32 buttonStateChange = buttons ^ _last_buttons; + + if (buttonStateChange & B_PRIMARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_LEFT, down); + } + if (buttonStateChange & B_SECONDARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_RIGHT, down); + } + if (buttonStateChange & B_TERTIARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_MIDDLE, down); + } + + _last_buttons = buttons; + } + + void _SendMouseButton(int32 button, bool down) + { + BMessage msg(BAPP_MOUSE_BUTTON); + msg.AddInt32("button-id", button); + msg.AddBool("button-down", down); + _PostWindowEvent(msg); + } + + void _MouseWheelEvent(int32 x, int32 y) + { + // Create a message to pass along to the BeApp thread + BMessage msg(BAPP_MOUSE_WHEEL); + msg.AddInt32("xticks", x); + msg.AddInt32("yticks", y); + _PostWindowEvent(msg); + } + + void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t &len, bool down) + { + // Create a message to pass along to the BeApp thread + BMessage msg(BAPP_KEY); + msg.AddInt32("key-scancode", keyCode); + if (keyUtf8 != NULL) { + msg.AddData("key-utf8", B_INT8_TYPE, (const void *)keyUtf8, len); + } + msg.AddBool("key-down", down); + SDL_Looper->PostMessage(&msg); + } + + void _RepaintEvent() + { + // Force a repaint: Call the SDL exposed event + BMessage msg(BAPP_REPAINT); + _PostWindowEvent(msg); + } + void _PostWindowEvent(BMessage &msg) + { + msg.AddInt32("window-id", _id); + SDL_Looper->PostMessage(&msg); + } + + // Command methods (functions called upon by SDL) + void _SetTitle(BMessage *msg) + { + const char *title; + if ( + msg->FindString("window-title", &title) != B_OK) { + return; + } + SetTitle(title); + } + + void _MoveTo(BMessage *msg) + { + int32 x, y; + if ( + msg->FindInt32("window-x", &x) != B_OK || + msg->FindInt32("window-y", &y) != B_OK) { + return; + } + if (_fullscreen) + _non_fullscreen_frame.OffsetTo(x, y); + else + MoveTo(x, y); + } + + void _ResizeTo(BMessage *msg) + { + int32 w, h; + if ( + msg->FindInt32("window-w", &w) != B_OK || + msg->FindInt32("window-h", &h) != B_OK) { + return; + } + if (_fullscreen) { + _non_fullscreen_frame.right = _non_fullscreen_frame.left + w; + _non_fullscreen_frame.bottom = _non_fullscreen_frame.top + h; + } else + ResizeTo(w, h); + } + + void _SetBordered(bool bEnabled) + { + if (_fullscreen) + _bordered = bEnabled; + else + SetLook(bEnabled ? B_TITLED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK); + } + + void _SetResizable(bool bEnabled) + { + if (_fullscreen) + _resizable = bEnabled; + else { + if (bEnabled) { + SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_ZOOMABLE)); + } else { + SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_ZOOMABLE)); + } + } + } + + void _SetMinimumSize(BMessage *msg) + { + float maxHeight; + float maxWidth; + float _; + int32 minHeight; + int32 minWidth; + + // This is a bit convoluted, we only want to set the minimum not the maximum + // But there is no direct call to do that, so store the maximum size beforehand + GetSizeLimits(&_, &maxWidth, &_, &maxHeight); + if (msg->FindInt32("window-w", &minWidth) != B_OK) + return; + if (msg->FindInt32("window-h", &minHeight) != B_OK) + return; + SetSizeLimits((float)minWidth, maxWidth, (float)minHeight, maxHeight); + UpdateSizeLimits(); + } + + void _Restore() + { + if (IsMinimized()) { + Minimize(false); + } else if (IsHidden()) { + Show(); + } else if (_fullscreen) { + + } else if (_prev_frame != NULL) { // Zoomed + MoveTo(_prev_frame->left, _prev_frame->top); + ResizeTo(_prev_frame->Width(), _prev_frame->Height()); + } + } + + void _SetFullScreen(bool fullscreen) + { + if (fullscreen != _fullscreen) { + if (fullscreen) { + BScreen screen(this); + BRect screenFrame = screen.Frame(); + printf("screen frame: "); + screenFrame.PrintToStream(); + printf("\n"); + _bordered = Look() != B_NO_BORDER_WINDOW_LOOK; + _resizable = !(Flags() & B_NOT_RESIZABLE); + _non_fullscreen_frame = Frame(); + _SetBordered(false); + _SetResizable(false); + MoveTo(screenFrame.left, screenFrame.top); + ResizeTo(screenFrame.Width(), screenFrame.Height()); + _fullscreen = fullscreen; + } else { + _fullscreen = fullscreen; + MoveTo(_non_fullscreen_frame.left, _non_fullscreen_frame.top); + ResizeTo(_non_fullscreen_frame.Width(), _non_fullscreen_frame.Height()); + _SetBordered(_bordered); + _SetResizable(_resizable); + } + } + } + + // Members + + BView *_cur_view; + SDL_BView *_SDL_View; +#ifdef SDL_VIDEO_OPENGL + BGLView *_SDL_GLView; + Uint32 _gl_type; +#endif + + int32 _last_buttons; + int32 _id; // Window id used by SDL_BApp + bool _mouse_focused; // Does this window have mouse focus? + bool _shown; + bool _inhibit_resize; + + BRect *_prev_frame; // Previous position and size of the window + bool _fullscreen; + // valid only if fullscreen + BRect _non_fullscreen_frame; + bool _bordered; + bool _resizable; + + // Framebuffer members + BLocker *_buffer_locker; + BBitmap *_bitmap; +}; + +/* FIXME: + * An explanation of framebuffer flags. + * + * _connected - Original variable used to let the drawing thread know + * when changes are being made to the other framebuffer + * members. + * _connection_disabled - Used to signal to the drawing thread that the window + * is closing, and the thread should exit. + * _buffer_created - True if the current buffer is valid + * _buffer_dirty - True if the window should be redrawn. + * _trash_window_buffer - True if the window buffer needs to be trashed partway + * through a draw cycle. Occurs when the previous + * buffer provided by DirectConnected() is invalidated. + */ +#endif // SDL_BWin_h_ diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.cc new file mode 100644 index 0000000..ff2bc6b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.cc @@ -0,0 +1,93 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + +// BWindow based clipboard implementation + +#include +#include + +#include "SDL_BWin.h" +#include "../SDL_sysvideo.h" + +#ifdef __cplusplus +extern "C" { +#endif + +bool HAIKU_SetClipboardText(SDL_VideoDevice *_this, const char *text) +{ + BMessage *clip = NULL; + if (be_clipboard->Lock()) { + be_clipboard->Clear(); + if ((clip = be_clipboard->Data())) { + // Presumably the string of characters is ascii-format + ssize_t asciiLength = 0; + for (; text[asciiLength] != 0; ++asciiLength) {} + clip->AddData("text/plain", B_MIME_TYPE, text, asciiLength); + be_clipboard->Commit(); + } + be_clipboard->Unlock(); + } + return true; +} + +char *HAIKU_GetClipboardText(SDL_VideoDevice *_this) { + BMessage *clip = NULL; + const char *text = NULL; + ssize_t length; + char *result; + if (be_clipboard->Lock()) { + if ((clip = be_clipboard->Data())) { + // Presumably the string of characters is ascii-format + clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text, + &length); + } + be_clipboard->Unlock(); + } + + if (!text) { + result = SDL_strdup(""); + } else { + // Copy the data and pass on to SDL + result = (char *)SDL_malloc((length + 1) * sizeof(char)); + SDL_strlcpy(result, text, length + 1); + } + + return result; +} + +bool HAIKU_HasClipboardText(SDL_VideoDevice *_this) { + bool result = false; + char *text = HAIKU_GetClipboardText(_this); + if (text) { + result = (text[0] != '\0'); + SDL_free(text); + } + return result; +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.h new file mode 100644 index 0000000..72965ba --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bclipboard.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_BCLIPBOARD_H +#define SDL_BCLIPBOARD_H + +extern bool HAIKU_SetClipboardText(SDL_VideoDevice *_this, const char *text); +extern char *HAIKU_GetClipboardText(SDL_VideoDevice *_this); +extern bool HAIKU_HasClipboardText(SDL_VideoDevice *_this); + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.cc new file mode 100644 index 0000000..ee23b20 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.cc @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + +#include "SDL_bevents.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void HAIKU_PumpEvents(SDL_VideoDevice *_this) { + // Since the event thread is its own thread, this isn't really necessary +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.h new file mode 100644 index 0000000..de2c909 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bevents.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BEVENTS_H +#define SDL_BEVENTS_H + +#include "../SDL_sysvideo.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void HAIKU_PumpEvents(SDL_VideoDevice *_this); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.cc new file mode 100644 index 0000000..d152255 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.cc @@ -0,0 +1,128 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + +#include "SDL_bframebuffer.h" + +#include +#include +#include "SDL_bmodes.h" +#include "SDL_BWin.h" + +#include "../../core/haiku/SDL_BApp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) +{ + return (SDL_BWin *)(window->internal); +} + +static SDL_INLINE SDL_BLooper *_GetBeLooper() +{ + return SDL_Looper; +} + +bool HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, SDL_PixelFormat * format, void ** pixels, int *pitch) +{ + SDL_BWin *bwin = _ToBeWin(window); + BScreen bscreen; + if (!bscreen.IsValid()) { + return false; + } + + // Make sure we have exclusive access to frame buffer data + bwin->LockBuffer(); + + bwin->CreateView(); + + // format + display_mode bmode; + bscreen.GetMode(&bmode); + *format = HAIKU_ColorSpaceToSDLPxFormat(bmode.space); + + // Create the new bitmap object + BBitmap *bitmap = bwin->GetBitmap(); + + if (bitmap) { + delete bitmap; + } + bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space, + false, // Views not accepted + true); // Contiguous memory required + + if (bitmap->InitCheck() != B_OK) { + delete bitmap; + return SDL_SetError("Could not initialize back buffer!"); + } + + + bwin->SetBitmap(bitmap); + + // Set the pixel pointer + *pixels = bitmap->Bits(); + + // pitch = width of window, in bytes + *pitch = bitmap->BytesPerRow(); + + bwin->UnlockBuffer(); + return true; +} + + + +bool HAIKU_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, + const SDL_Rect * rects, int numrects) { + if (!window) { + return true; + } + + SDL_BWin *bwin = _ToBeWin(window); + + bwin->PostMessage(BWIN_UPDATE_FRAMEBUFFER); + + return true; +} + +void HAIKU_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window) { + SDL_BWin *bwin = _ToBeWin(window); + + bwin->LockBuffer(); + + // Free and clear the window buffer + BBitmap *bitmap = bwin->GetBitmap(); + delete bitmap; + bwin->SetBitmap(NULL); + + bwin->RemoveView(); + + bwin->UnlockBuffer(); +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.h new file mode 100644 index 0000000..c782001 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bframebuffer.h @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BFRAMEBUFFER_H +#define SDL_BFRAMEBUFFER_H +#include +#ifdef __cplusplus +extern "C" { +#endif + +#define DRAWTHREAD + +#include "../SDL_sysvideo.h" + +extern bool HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, + SDL_PixelFormat *format, + void **pixels, int *pitch); +extern bool HAIKU_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, + const SDL_Rect *rects, int numrects); +extern void HAIKU_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); +extern int32 HAIKU_DrawThread(void *data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.cc new file mode 100644 index 0000000..c4f364e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.cc @@ -0,0 +1,168 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "SDL_bkeyboard.h" + + +#define KEYMAP_SIZE 128 + + +static SDL_Scancode keymap[KEYMAP_SIZE]; + +void HAIKU_InitOSKeymap(void) +{ + for ( uint i = 0; i < SDL_arraysize(keymap); ++i ) { + keymap[i] = SDL_SCANCODE_UNKNOWN; + } + + keymap[0x01] = SDL_SCANCODE_ESCAPE; + keymap[B_F1_KEY] = SDL_SCANCODE_F1; + keymap[B_F2_KEY] = SDL_SCANCODE_F2; + keymap[B_F3_KEY] = SDL_SCANCODE_F3; + keymap[B_F4_KEY] = SDL_SCANCODE_F4; + keymap[B_F5_KEY] = SDL_SCANCODE_F5; + keymap[B_F6_KEY] = SDL_SCANCODE_F6; + keymap[B_F7_KEY] = SDL_SCANCODE_F7; + keymap[B_F8_KEY] = SDL_SCANCODE_F8; + keymap[B_F9_KEY] = SDL_SCANCODE_F9; + keymap[B_F10_KEY] = SDL_SCANCODE_F10; + keymap[B_F11_KEY] = SDL_SCANCODE_F11; + keymap[B_F12_KEY] = SDL_SCANCODE_F12; + keymap[B_PRINT_KEY] = SDL_SCANCODE_PRINTSCREEN; + keymap[B_SCROLL_KEY]= SDL_SCANCODE_SCROLLLOCK; + keymap[B_PAUSE_KEY] = SDL_SCANCODE_PAUSE; + keymap[0x11] = SDL_SCANCODE_GRAVE; + keymap[0x12] = SDL_SCANCODE_1; + keymap[0x13] = SDL_SCANCODE_2; + keymap[0x14] = SDL_SCANCODE_3; + keymap[0x15] = SDL_SCANCODE_4; + keymap[0x16] = SDL_SCANCODE_5; + keymap[0x17] = SDL_SCANCODE_6; + keymap[0x18] = SDL_SCANCODE_7; + keymap[0x19] = SDL_SCANCODE_8; + keymap[0x1a] = SDL_SCANCODE_9; + keymap[0x1b] = SDL_SCANCODE_0; + keymap[0x1c] = SDL_SCANCODE_MINUS; + keymap[0x1d] = SDL_SCANCODE_EQUALS; + keymap[0x1e] = SDL_SCANCODE_BACKSPACE; + keymap[0x1f] = SDL_SCANCODE_INSERT; + keymap[0x20] = SDL_SCANCODE_HOME; + keymap[0x21] = SDL_SCANCODE_PAGEUP; + keymap[0x22] = SDL_SCANCODE_NUMLOCKCLEAR; + keymap[0x23] = SDL_SCANCODE_KP_DIVIDE; + keymap[0x24] = SDL_SCANCODE_KP_MULTIPLY; + keymap[0x25] = SDL_SCANCODE_KP_MINUS; + keymap[0x26] = SDL_SCANCODE_TAB; + keymap[0x27] = SDL_SCANCODE_Q; + keymap[0x28] = SDL_SCANCODE_W; + keymap[0x29] = SDL_SCANCODE_E; + keymap[0x2a] = SDL_SCANCODE_R; + keymap[0x2b] = SDL_SCANCODE_T; + keymap[0x2c] = SDL_SCANCODE_Y; + keymap[0x2d] = SDL_SCANCODE_U; + keymap[0x2e] = SDL_SCANCODE_I; + keymap[0x2f] = SDL_SCANCODE_O; + keymap[0x30] = SDL_SCANCODE_P; + keymap[0x31] = SDL_SCANCODE_LEFTBRACKET; + keymap[0x32] = SDL_SCANCODE_RIGHTBRACKET; + keymap[0x33] = SDL_SCANCODE_BACKSLASH; + keymap[0x34] = SDL_SCANCODE_DELETE; + keymap[0x35] = SDL_SCANCODE_END; + keymap[0x36] = SDL_SCANCODE_PAGEDOWN; + keymap[0x37] = SDL_SCANCODE_KP_7; + keymap[0x38] = SDL_SCANCODE_KP_8; + keymap[0x39] = SDL_SCANCODE_KP_9; + keymap[0x3a] = SDL_SCANCODE_KP_PLUS; + keymap[0x3b] = SDL_SCANCODE_CAPSLOCK; + keymap[0x3c] = SDL_SCANCODE_A; + keymap[0x3d] = SDL_SCANCODE_S; + keymap[0x3e] = SDL_SCANCODE_D; + keymap[0x3f] = SDL_SCANCODE_F; + keymap[0x40] = SDL_SCANCODE_G; + keymap[0x41] = SDL_SCANCODE_H; + keymap[0x42] = SDL_SCANCODE_J; + keymap[0x43] = SDL_SCANCODE_K; + keymap[0x44] = SDL_SCANCODE_L; + keymap[0x45] = SDL_SCANCODE_SEMICOLON; + keymap[0x46] = SDL_SCANCODE_APOSTROPHE; + keymap[0x47] = SDL_SCANCODE_RETURN; + keymap[0x48] = SDL_SCANCODE_KP_4; + keymap[0x49] = SDL_SCANCODE_KP_5; + keymap[0x4a] = SDL_SCANCODE_KP_6; + keymap[0x4b] = SDL_SCANCODE_LSHIFT; + keymap[0x4c] = SDL_SCANCODE_Z; + keymap[0x4d] = SDL_SCANCODE_X; + keymap[0x4e] = SDL_SCANCODE_C; + keymap[0x4f] = SDL_SCANCODE_V; + keymap[0x50] = SDL_SCANCODE_B; + keymap[0x51] = SDL_SCANCODE_N; + keymap[0x52] = SDL_SCANCODE_M; + keymap[0x53] = SDL_SCANCODE_COMMA; + keymap[0x54] = SDL_SCANCODE_PERIOD; + keymap[0x55] = SDL_SCANCODE_SLASH; + keymap[0x56] = SDL_SCANCODE_RSHIFT; + keymap[0x57] = SDL_SCANCODE_UP; + keymap[0x58] = SDL_SCANCODE_KP_1; + keymap[0x59] = SDL_SCANCODE_KP_2; + keymap[0x5a] = SDL_SCANCODE_KP_3; + keymap[0x5b] = SDL_SCANCODE_KP_ENTER; + keymap[0x5c] = SDL_SCANCODE_LCTRL; + keymap[0x5d] = SDL_SCANCODE_LALT; + keymap[0x5e] = SDL_SCANCODE_SPACE; + keymap[0x5f] = SDL_SCANCODE_RALT; + keymap[0x60] = SDL_SCANCODE_RCTRL; + keymap[0x61] = SDL_SCANCODE_LEFT; + keymap[0x62] = SDL_SCANCODE_DOWN; + keymap[0x63] = SDL_SCANCODE_RIGHT; + keymap[0x64] = SDL_SCANCODE_KP_0; + keymap[0x65] = SDL_SCANCODE_KP_PERIOD; + keymap[0x66] = SDL_SCANCODE_LGUI; + keymap[0x67] = SDL_SCANCODE_RGUI; + keymap[0x68] = SDL_SCANCODE_MENU; + keymap[0x69] = SDL_SCANCODE_2; // SDLK_EURO + keymap[0x6a] = SDL_SCANCODE_KP_EQUALS; + keymap[0x6b] = SDL_SCANCODE_POWER; +} + +SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey) { + if (bkey > 0 && bkey < (int32)SDL_arraysize(keymap)) { + return keymap[bkey]; + } else { + return SDL_SCANCODE_UNKNOWN; + } +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.h new file mode 100644 index 0000000..57fd77a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bkeyboard.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BKEYBOARD_H +#define SDL_BKEYBOARD_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern void HAIKU_InitOSKeymap(void); +extern SDL_Scancode HAIKU_GetScancodeFromBeKey(int32 bkey); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.cc new file mode 100644 index 0000000..75bef70 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.cc @@ -0,0 +1,383 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + Copyright (C) 2018-2019 EXL + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + + +// For application signature. +#include "../../core/haiku/SDL_BeApp.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + +enum +{ + G_CLOSE_BUTTON_ID = -1, + G_DEFAULT_BUTTON_ID = 0, + G_MAX_STRING_LENGTH_BYTES = 120 +}; + +class HAIKU_SDL_MessageBox : public BAlert +{ + float fComputedMessageBoxWidth; + + BTextView *fMessageBoxTextView; + + int fCloseButton; + int fDefaultButton; + + bool fCustomColorScheme; + bool fThereIsLongLine; + rgb_color fTextColor; + + const char *fTitle; + const char *HAIKU_SDL_DefTitle; + const char *HAIKU_SDL_DefMessage; + const char *HAIKU_SDL_DefButton; + + std::vector fButtons; + + static bool + SortButtonsPredicate(const SDL_MessageBoxButtonData *aButtonLeft, + const SDL_MessageBoxButtonData *aButtonRight) + { + return aButtonLeft->buttonID < aButtonRight->buttonID; + } + + alert_type + ConvertMessageBoxType(const SDL_MessageBoxFlags aWindowType) const + { + switch (aWindowType) + { + default: + case SDL_MESSAGEBOX_WARNING: + { + return B_WARNING_ALERT; + } + case SDL_MESSAGEBOX_ERROR: + { + return B_STOP_ALERT; + } + case SDL_MESSAGEBOX_INFORMATION: + { + return B_INFO_ALERT; + } + } + } + + rgb_color + ConvertColorType(const SDL_MessageBoxColor *aColor) const + { + rgb_color color = { aColor->r, aColor->g, aColor->b, color.alpha = 255 }; + return color; + } + + int32 + GetLeftPanelWidth(void) const + { + // See file "haiku/src/kits/interface/Alert.cpp" for this magic numbers. + // IconStripeWidth = 30 * Scale + // IconSize = 32 * Scale + // Scale = max_c(1, ((int32)be_plain_font->Size() + 15) / 16) + // RealWidth = (IconStripeWidth * Scale) + (IconSize * Scale) + + int32 scale = max_c(1, ((int32)be_plain_font->Size() + 15) / 16); + return (30 * scale) + (32 * scale); + } + + void + UpdateTextViewWidth(void) + { + fComputedMessageBoxWidth = fMessageBoxTextView->PreferredSize().Width() + GetLeftPanelWidth(); + } + + void + ParseSdlMessageBoxData(const SDL_MessageBoxData *aMessageBoxData) + { + if (aMessageBoxData == NULL) { + SetTitle(HAIKU_SDL_DefTitle); + SetMessageText(HAIKU_SDL_DefMessage); + AddButton(HAIKU_SDL_DefButton); + return; + } + + if (aMessageBoxData->numbuttons <= 0) { + AddButton(HAIKU_SDL_DefButton); + } else { + AddSdlButtons(aMessageBoxData->buttons, aMessageBoxData->numbuttons); + } + + if (aMessageBoxData->colorScheme != NULL) { + fCustomColorScheme = true; + ApplyAndParseColorScheme(aMessageBoxData->colorScheme); + } + + (aMessageBoxData->title[0]) ? + SetTitle(aMessageBoxData->title) : SetTitle(HAIKU_SDL_DefTitle); + (aMessageBoxData->message[0]) ? + SetMessageText(aMessageBoxData->message) : SetMessageText(HAIKU_SDL_DefMessage); + + SetType(ConvertMessageBoxType(aMessageBoxData->flags)); + } + + void + ApplyAndParseColorScheme(const SDL_MessageBoxColorScheme *aColorScheme) + { + SetBackgroundColor(&aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BACKGROUND]); + fTextColor = ConvertColorType(&aColorScheme->colors[SDL_MESSAGEBOX_COLOR_TEXT]); + SetButtonColors(&aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BUTTON_BORDER], + &aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND], + &aColorScheme->colors[SDL_MESSAGEBOX_COLOR_TEXT], + &aColorScheme->colors[SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED]); + } + + void + SetButtonColors(const SDL_MessageBoxColor *aBorderColor, + const SDL_MessageBoxColor *aBackgroundColor, + const SDL_MessageBoxColor *aTextColor, + const SDL_MessageBoxColor *aSelectedColor) + { + if (fCustomColorScheme) { + int32 countButtons = CountButtons(); + for (int i = 0; i < countButtons; ++i) { + ButtonAt(i)->SetViewColor(ConvertColorType(aBorderColor)); + ButtonAt(i)->SetLowColor(ConvertColorType(aBackgroundColor)); + + // This doesn't work. See this why: + // https://github.com/haiku/haiku/commit/de9c53f8f5008c7b3b0af75d944a628e17f6dffe + // Let it remain. + ButtonAt(i)->SetHighColor(ConvertColorType(aTextColor)); + } + } + // TODO: Not Implemented. + // Is it even necessary?! + (void)aSelectedColor; + } + + void + SetBackgroundColor(const SDL_MessageBoxColor *aColor) + { + rgb_color background = ConvertColorType(aColor); + + GetLayout()->View()->SetViewColor(background); + // See file "haiku/src/kits/interface/Alert.cpp", the "TAlertView" is the internal name of the left panel. + FindView("TAlertView")->SetViewColor(background); + fMessageBoxTextView->SetViewColor(background); + } + + bool + CheckLongLines(const char *aMessage) + { + int final = 0; + + // This UTF-8 friendly. + BString message = aMessage; + int32 length = message.CountChars(); + + for (int i = 0, c = 0; i < length; ++i) { + c++; + if (*(message.CharAt(i)) == '\n') { + c = 0; + } + if (c > final) { + final = c; + } + } + + return (final > G_MAX_STRING_LENGTH_BYTES); + } + + void + SetMessageText(const char *aMessage) + { + fThereIsLongLine = CheckLongLines(aMessage); + if (fThereIsLongLine) { + fMessageBoxTextView->SetWordWrap(true); + } + + rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR); + if (fCustomColorScheme) { + textColor = fTextColor; + } + + /* + if (fNoTitledWindow) { + fMessageBoxTextView->SetFontAndColor(be_bold_font); + fMessageBoxTextView->Insert(fTitle); + fMessageBoxTextView->Insert("\n\n"); + fMessageBoxTextView->SetFontAndColor(be_plain_font); + } + */ + + fMessageBoxTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor); + fMessageBoxTextView->Insert(aMessage); + + // Be sure to call update width method. + UpdateTextViewWidth(); + } + + void + AddSdlButtons(const SDL_MessageBoxButtonData *aButtons, int aNumButtons) + { + for (int i = 0; i < aNumButtons; ++i) { + fButtons.push_back(&aButtons[i]); + } + + std::sort(fButtons.begin(), fButtons.end(), &HAIKU_SDL_MessageBox::SortButtonsPredicate); + + size_t countButtons = fButtons.size(); + for (size_t i = 0; i < countButtons; ++i) { + if (fButtons[i]->flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) { + fCloseButton = static_cast(i); + } + if (fButtons[i]->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { + fDefaultButton = static_cast(i); + } + AddButton(fButtons[i]->text); + } + + SetDefaultButton(ButtonAt(fDefaultButton)); + } + +public: + explicit + HAIKU_SDL_MessageBox(const SDL_MessageBoxData *aMessageBoxData) + : BAlert(NULL, NULL, NULL, NULL, NULL, B_WIDTH_FROM_LABEL, B_WARNING_ALERT), + fComputedMessageBoxWidth(0.0f), + fCloseButton(G_CLOSE_BUTTON_ID), fDefaultButton(G_DEFAULT_BUTTON_ID), + fCustomColorScheme(false), fThereIsLongLine(false), + HAIKU_SDL_DefTitle("SDL MessageBox"), + HAIKU_SDL_DefMessage("Some information has been lost."), + HAIKU_SDL_DefButton("OK") + { + // MessageBox settings. + // We need a title to display it. + SetLook(B_TITLED_WINDOW_LOOK); + SetFlags(Flags() | B_CLOSE_ON_ESCAPE); + + // MessageBox TextView settings. + fMessageBoxTextView = TextView(); + fMessageBoxTextView->SetWordWrap(false); + fMessageBoxTextView->SetStylable(true); + + ParseSdlMessageBoxData(aMessageBoxData); + } + + int + GetCloseButtonId(void) const + { + return fCloseButton; + } + + virtual + ~HAIKU_SDL_MessageBox(void) + { + fButtons.clear(); + } + +protected: + virtual void + FrameResized(float aNewWidth, float aNewHeight) + { + if (fComputedMessageBoxWidth > aNewWidth) { + ResizeTo(fComputedMessageBoxWidth, aNewHeight); + } else { + BAlert::FrameResized(aNewWidth, aNewHeight); + } + } + + virtual void + SetTitle(const char* aTitle) + { + fTitle = aTitle; + BAlert::SetTitle(aTitle); + } +}; + +#ifdef __cplusplus +extern "C" { +#endif + +bool HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + // Initialize button by closed or error value first. + *buttonID = G_CLOSE_BUTTON_ID; + + // We need to check "be_app" pointer to "NULL". The "messageboxdata->window" pointer isn't appropriate here + // because it is possible to create a MessageBox from another thread. This fixes the following errors: + // "You need a valid BApplication object before interacting with the app_server." + // "2 BApplication objects were created. Only one is allowed." + std::unique_ptr application; + if (!be_app) { + application = std::unique_ptr(new(std::nothrow) BApplication(SDL_signature)); + if (!application) { + return SDL_SetError("Cannot create the BApplication object. Lack of memory?"); + } + } + + HAIKU_SDL_MessageBox *SDL_MessageBox = new(std::nothrow) HAIKU_SDL_MessageBox(messageboxdata); + if (!SDL_MessageBox) { + return SDL_SetError("Cannot create the HAIKU_SDL_MessageBox (BAlert inheritor) object. Lack of memory?"); + } + const int closeButton = SDL_MessageBox->GetCloseButtonId(); + int pushedButton = SDL_MessageBox->Go(); + + // The close button is equivalent to pressing Escape. + if (closeButton != G_CLOSE_BUTTON_ID && pushedButton == G_CLOSE_BUTTON_ID) { + pushedButton = closeButton; + } + + // It's deleted by itself after the "Go()" method was executed. + /* + if (messageBox != NULL) { + delete messageBox; + } + */ + // Initialize button by real pushed value then. + *buttonID = pushedButton; + + return true; +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.h new file mode 100644 index 0000000..e2800af --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmessagebox.h @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + Copyright (C) 2018-2019 EXL + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BMESSAGEBOX_H +#define SDL_BMESSAGEBOX_H + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + +#ifdef __cplusplus +extern "C" { +#endif + +extern bool HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.cc new file mode 100644 index 0000000..32c8b6d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.cc @@ -0,0 +1,307 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + +#include +#include +#include "SDL_bmodes.h" +#include "SDL_BWin.h" + +#ifdef SDL_VIDEO_OPENGL +#include "SDL_bopengl.h" +#endif + +#include "../../core/haiku/SDL_BApp.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define WRAP_BMODE 1 // FIXME: Some debate as to whether this is necessary + +#if WRAP_BMODE +/* This wrapper is here so that the internal can be freed without freeing + the display_mode structure */ +struct SDL_DisplayModeData { + display_mode *bmode; +}; +#endif + +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) +{ + return (SDL_BWin *)(window->internal); +} + +static SDL_INLINE SDL_BLooper *_GetBeLooper() +{ + return SDL_Looper; +} + +static SDL_INLINE display_mode * _ExtractBMode(SDL_DisplayMode *mode) +{ +#if WRAP_BMODE + return mode->internal->bmode; +#else + return (display_mode *)mode->internal; +#endif +} + +// Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp +static void get_refresh_rate(display_mode &mode, int *numerator, int *denominator) +{ + *numerator = (mode.timing.pixel_clock * 1000); + *denominator = (mode.timing.h_total * mode.timing.v_total); +} + + +#if 0 +/* TODO: + * This is a useful debugging tool. Uncomment and insert into code as needed. + */ +void _SpoutModeData(display_mode *bmode) +{ + printf("BMode:\n"); + printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height); + printf("\th,v = (%i,%i)\n", bmode->h_display_start, + bmode->v_display_start); + if (bmode->flags) { + printf("\tFlags:\n"); + if (bmode->flags & B_SCROLL) { + printf("\t\tB_SCROLL\n"); + } + if (bmode->flags & B_8_BIT_DAC) { + printf("\t\tB_8_BIT_DAC\n"); + } + if (bmode->flags & B_HARDWARE_CURSOR) { + printf("\t\tB_HARDWARE_CURSOR\n"); + } + if (bmode->flags & B_PARALLEL_ACCESS) { + printf("\t\tB_PARALLEL_ACCESS\n"); + } + if (bmode->flags & B_DPMS) { + printf("\t\tB_DPMS\n"); + } + if (bmode->flags & B_IO_FB_NA) { + printf("\t\tB_IO_FB_NA\n"); + } + } + printf("\tTiming:\n"); + printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock); + printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n", + bmode->timing.h_display, bmode->timing.h_sync_start, + bmode->timing.h_sync_end, bmode->timing.h_total); + printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n", + bmode->timing.v_display, bmode->timing.v_sync_start, + bmode->timing.v_sync_end, bmode->timing.v_total); + if (bmode->timing.flags) { + printf("\t\tFlags:\n"); + if (bmode->timing.flags & B_BLANK_PEDESTAL) { + printf("\t\t\tB_BLANK_PEDESTAL\n"); + } + if (bmode->timing.flags & B_TIMING_INTERLACED) { + printf("\t\t\tB_TIMING_INTERLACED\n"); + } + if (bmode->timing.flags & B_POSITIVE_HSYNC) { + printf("\t\t\tB_POSITIVE_HSYNC\n"); + } + if (bmode->timing.flags & B_POSITIVE_VSYNC) { + printf("\t\t\tB_POSITIVE_VSYNC\n"); + } + if (bmode->timing.flags & B_SYNC_ON_GREEN) { + printf("\t\t\tB_SYNC_ON_GREEN\n"); + } + } +} +#endif + + + +SDL_PixelFormat HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace) +{ + switch (colorspace) { + case B_CMAP8: + return SDL_PIXELFORMAT_INDEX8; + break; + case B_RGB15: + case B_RGBA15: + case B_RGB15_BIG: + case B_RGBA15_BIG: + return SDL_PIXELFORMAT_XRGB1555; + break; + case B_RGB16: + case B_RGB16_BIG: + return SDL_PIXELFORMAT_RGB565; + break; + case B_RGB24: + case B_RGB24_BIG: + return SDL_PIXELFORMAT_BGR24; + break; + case B_RGB32: + case B_RGBA32: + case B_RGB32_BIG: + case B_RGBA32_BIG: + return SDL_PIXELFORMAT_XRGB8888; + break; + } + + // May never get here, but safer and needed to shut up compiler + SDL_SetError("Invalid color space"); + return SDL_PIXELFORMAT_UNKNOWN; +} + +static void _BDisplayModeToSdlDisplayMode(display_mode *bmode, SDL_DisplayMode *mode) +{ + SDL_zerop(mode); + mode->w = bmode->virtual_width; + mode->h = bmode->virtual_height; + get_refresh_rate(*bmode, &mode->refresh_rate_numerator, &mode->refresh_rate_denominator); + +#if WRAP_BMODE + SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, sizeof(SDL_DisplayModeData)); + data->bmode = bmode; + + mode->internal = data; +#else + mode->internal = bmode; +#endif + + // Set the format + mode->format = HAIKU_ColorSpaceToSDLPxFormat(bmode->space); +} + +// Later, there may be more than one monitor available +static void _AddDisplay(BScreen *screen) +{ + SDL_DisplayMode mode; + display_mode bmode; + screen->GetMode(&bmode); + + _BDisplayModeToSdlDisplayMode(&bmode, &mode); + + SDL_AddBasicVideoDisplay(&mode); +} + +/* + * Functions called by SDL + */ + +bool HAIKU_InitModes(SDL_VideoDevice *_this) +{ + BScreen screen; + + /* TODO: When Haiku supports multiple display screens, call + _AddDisplayScreen() for each of them. */ + _AddDisplay(&screen); + return true; +} + +void HAIKU_QuitModes(SDL_VideoDevice *_this) +{ + return; +} + + +bool HAIKU_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + BScreen bscreen; + BRect rc = bscreen.Frame(); + rect->x = (int)rc.left; + rect->y = (int)rc.top; + rect->w = (int)rc.Width() + 1; + rect->h = (int)rc.Height() + 1; + return true; +} + +bool HAIKU_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + // Get the current screen + BScreen bscreen; + + // Iterate through all of the modes + SDL_DisplayMode mode; + display_mode this_bmode; + display_mode *bmodes; + uint32 count, i; + + // Get graphics-hardware supported modes + bscreen.GetModeList(&bmodes, &count); + bscreen.GetMode(&this_bmode); + + for (i = 0; i < count; ++i) { + // FIXME: Apparently there are errors with colorspace changes + if (bmodes[i].space == this_bmode.space) { + _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode); + SDL_AddFullscreenDisplayMode(display, &mode); + } + } + free(bmodes); // This should NOT be SDL_free() + return true; +} + + +bool HAIKU_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + // Get the current screen + BScreen bscreen; + if (!bscreen.IsValid()) { + printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__); + } + + // Set the mode using the driver data + display_mode *bmode = _ExtractBMode(mode); + + + // FIXME: Is the first option always going to be the right one? + uint32 c = 0, i; + display_mode *bmode_list; + bscreen.GetModeList(&bmode_list, &c); + for (i = 0; i < c; ++i) { + if ( bmode_list[i].space == bmode->space && + bmode_list[i].virtual_width == bmode->virtual_width && + bmode_list[i].virtual_height == bmode->virtual_height ) { + bmode = &bmode_list[i]; + break; + } + } + + if (bscreen.SetMode(bmode) != B_OK) { + return SDL_SetError("Bad video mode"); + } + + free(bmode_list); // This should NOT be SDL_free() + +#ifdef SDL_VIDEO_OPENGL + /* FIXME: Is there some way to reboot the OpenGL context? This doesn't + help */ +// HAIKU_GL_RebootContexts(_this); +#endif + + return true; +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.h new file mode 100644 index 0000000..2fd0bc2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bmodes.h @@ -0,0 +1,43 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BMODES_H +#define SDL_BMODES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../SDL_sysvideo.h" + +extern SDL_PixelFormat HAIKU_ColorSpaceToSDLPxFormat(uint32 colorspace); + +extern bool HAIKU_InitModes(SDL_VideoDevice *_this); +extern void HAIKU_QuitModes(SDL_VideoDevice *_this); +extern bool HAIKU_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); +extern bool HAIKU_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool HAIKU_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.cc new file mode 100644 index 0000000..469b7f6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.cc @@ -0,0 +1,205 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_HAIKU) && defined(SDL_VIDEO_OPENGL) + +#include "SDL_bopengl.h" + +#include +#include +#include +#include "SDL_BWin.h" +#include "../../core/haiku/SDL_BApp.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) +{ + return (SDL_BWin *)(window->internal); +} + +static SDL_INLINE SDL_BLooper *_GetBeLooper() +{ + return SDL_Looper; +} + +// Passing a NULL path means load pointers from the application +bool HAIKU_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ +// FIXME: Is this working correctly? + image_info info; + int32 cookie = 0; + while (get_next_image_info(0, &cookie, &info) == B_OK) { + void *location = NULL; + if ( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY, + &location) == B_OK) { + + _this->gl_config.dll_handle = (SDL_SharedObject *) (addr_t) info.id; + _this->gl_config.driver_loaded = 1; + SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", + SDL_arraysize(_this->gl_config.driver_path)); + } + } + return true; +} + +SDL_FunctionPointer HAIKU_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + if (_this->gl_config.dll_handle) { + void *location = NULL; + status_t err; + if ((err = + get_image_symbol((image_id) (addr_t) _this->gl_config.dll_handle, + proc, B_SYMBOL_TYPE_ANY, + &location)) == B_OK) { + return (SDL_FunctionPointer)location; + } else { + SDL_SetError("Couldn't find OpenGL symbol"); + return NULL; + } + } else { + SDL_SetError("OpenGL library not loaded"); + return NULL; + } +} + + +bool HAIKU_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + _ToBeWin(window)->SwapBuffers(); + return true; +} + +bool HAIKU_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window * window, SDL_GLContext context) +{ + BGLView* glView = (BGLView*)context; + // printf("HAIKU_GL_MakeCurrent(%llx), win = %llx, thread = %d\n", (uint64)context, (uint64)window, find_thread(NULL)); + if (glView) { + if ((glView->Window() == NULL) || (!window) || (_ToBeWin(window)->GetGLView() != glView)) { + return SDL_SetError("MakeCurrent failed"); + } + } + _GetBeLooper()->SetCurrentContext(glView); + return true; +} + + +SDL_GLContext HAIKU_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window * window) +{ + /* FIXME: Not sure what flags should be included here; may want to have + most of them */ + SDL_BWin *bwin = _ToBeWin(window); + // printf("HAIKU_GL_CreateContext, win = %llx, thread = %d\n", (uint64)window, find_thread(NULL)); + if (bwin->GetGLView() != NULL) { + SDL_SetError("Context already creaded"); + return NULL; + } + Uint32 gl_flags = BGL_RGB; + if (_this->gl_config.alpha_size) { + gl_flags |= BGL_ALPHA; + } + if (_this->gl_config.depth_size) { + gl_flags |= BGL_DEPTH; + } + if (_this->gl_config.stencil_size) { + gl_flags |= BGL_STENCIL; + } + if (_this->gl_config.double_buffer) { + gl_flags |= BGL_DOUBLE; + } else { + gl_flags |= BGL_SINGLE; + } + if (_this->gl_config.accum_red_size || + _this->gl_config.accum_green_size || + _this->gl_config.accum_blue_size || + _this->gl_config.accum_alpha_size) { + gl_flags |= BGL_ACCUM; + } +#if __GNUC__ > 3 + if (_this->gl_config.share_with_current_context) { + gl_flags |= BGL_SHARE_CONTEXT; + } +#endif + bwin->CreateGLView(gl_flags); + _GetBeLooper()->SetCurrentContext(bwin->GetGLView()); + return (SDL_GLContext)(bwin->GetGLView()); +} + +bool HAIKU_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + // printf("HAIKU_GL_DestroyContext(%llx), thread = %d\n", (uint64)context, find_thread(NULL)); + BGLView* glView = (BGLView*)context; + SDL_BWin *bwin = (SDL_BWin*)glView->Window(); + if (!bwin) { + delete glView; + } else { + bwin->RemoveGLView(); + } + return true; +} + + +bool HAIKU_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + // TODO: Implement this, if necessary? + return SDL_Unsupported(); +} + +bool HAIKU_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + return SDL_Unsupported(); +} + + +void HAIKU_GL_UnloadLibrary(SDL_VideoDevice *_this) +{ + // TODO: Implement this, if necessary? +} + + +/* FIXME: This function is meant to clear the OpenGL context when the video + mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not + currently in use. */ +void HAIKU_GL_RebootContexts(SDL_VideoDevice *_this) +{ + SDL_Window *window = _this->windows; + while (window) { + SDL_BWin *bwin = _ToBeWin(window); + if (bwin->GetGLView()) { + bwin->LockLooper(); + bwin->RemoveGLView(); + bwin->CreateGLView(bwin->GetGLType()); + bwin->UnlockLooper(); + } + window = window->next; + } +} + + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.h new file mode 100644 index 0000000..e0522a8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bopengl.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BOPENGL_H +#define SDL_BOPENGL_H + +#if defined(SDL_VIDEO_DRIVER_HAIKU) && defined(SDL_VIDEO_OPENGL) + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../SDL_sysvideo.h" + +extern bool HAIKU_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); // FIXME +extern SDL_FunctionPointer HAIKU_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); // FIXME +extern void HAIKU_GL_UnloadLibrary(SDL_VideoDevice *_this); // TODO +extern bool HAIKU_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, + SDL_GLContext context); +extern bool HAIKU_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); // TODO +extern bool HAIKU_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); // TODO +extern bool HAIKU_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_GLContext HAIKU_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool HAIKU_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); + +extern void HAIKU_GL_RebootContexts(SDL_VideoDevice *_this); + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU && SDL_VIDEO_OPENGL + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.cc new file mode 100644 index 0000000..d7f9e7c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.cc @@ -0,0 +1,326 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" +#include "../../core/haiku/SDL_BApp.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU + +#include "SDL_BWin.h" +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include "SDL_bkeyboard.h" +#include "SDL_bwindow.h" +#include "SDL_bclipboard.h" +#include "SDL_bvideo.h" +#include "SDL_bopengl.h" +#include "SDL_bmodes.h" +#include "SDL_bframebuffer.h" +#include "SDL_bevents.h" +#include "SDL_bmessagebox.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" + +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) { + return (SDL_BWin *)(window->internal); +} + +static SDL_VideoDevice * HAIKU_CreateDevice(void) +{ + SDL_VideoDevice *device; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + + device->internal = NULL; /* FIXME: Is this the cause of some of the + SDL_Quit() errors? */ + +// TODO: Figure out if any initialization needs to go here + + // Set the function pointers + device->VideoInit = HAIKU_VideoInit; + device->VideoQuit = HAIKU_VideoQuit; + device->GetDisplayBounds = HAIKU_GetDisplayBounds; + device->GetDisplayModes = HAIKU_GetDisplayModes; + device->SetDisplayMode = HAIKU_SetDisplayMode; + device->PumpEvents = HAIKU_PumpEvents; + + device->CreateSDLWindow = HAIKU_CreateWindow; + device->SetWindowTitle = HAIKU_SetWindowTitle; + device->SetWindowPosition = HAIKU_SetWindowPosition; + device->SetWindowSize = HAIKU_SetWindowSize; + device->ShowWindow = HAIKU_ShowWindow; + device->HideWindow = HAIKU_HideWindow; + device->RaiseWindow = HAIKU_RaiseWindow; + device->MaximizeWindow = HAIKU_MaximizeWindow; + device->MinimizeWindow = HAIKU_MinimizeWindow; + device->RestoreWindow = HAIKU_RestoreWindow; + device->SetWindowBordered = HAIKU_SetWindowBordered; + device->SetWindowResizable = HAIKU_SetWindowResizable; + device->SetWindowFullscreen = HAIKU_SetWindowFullscreen; + device->SetWindowMouseGrab = HAIKU_SetWindowMouseGrab; + device->SetWindowMinimumSize = HAIKU_SetWindowMinimumSize; + device->SetWindowParent = HAIKU_SetWindowParent; + device->SetWindowModal = HAIKU_SetWindowModal; + device->DestroyWindow = HAIKU_DestroyWindow; + device->CreateWindowFramebuffer = HAIKU_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = HAIKU_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = HAIKU_DestroyWindowFramebuffer; + +#ifdef SDL_VIDEO_OPENGL + device->GL_LoadLibrary = HAIKU_GL_LoadLibrary; + device->GL_GetProcAddress = HAIKU_GL_GetProcAddress; + device->GL_UnloadLibrary = HAIKU_GL_UnloadLibrary; + device->GL_CreateContext = HAIKU_GL_CreateContext; + device->GL_MakeCurrent = HAIKU_GL_MakeCurrent; + device->GL_SetSwapInterval = HAIKU_GL_SetSwapInterval; + device->GL_GetSwapInterval = HAIKU_GL_GetSwapInterval; + device->GL_SwapWindow = HAIKU_GL_SwapWindow; + device->GL_DestroyContext = HAIKU_GL_DestroyContext; +#endif + + device->SetClipboardText = HAIKU_SetClipboardText; + device->GetClipboardText = HAIKU_GetClipboardText; + device->HasClipboardText = HAIKU_HasClipboardText; + + device->free = HAIKU_DeleteDevice; + + return device; +} + +VideoBootStrap HAIKU_bootstrap = { + "haiku", "Haiku graphics", + HAIKU_CreateDevice, + HAIKU_ShowMessageBox, + false +}; + +void HAIKU_DeleteDevice(SDL_VideoDevice * device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +struct SDL_CursorData +{ + BCursor *cursor; +}; + +static SDL_Cursor *HAIKU_CreateCursorAndData(BCursor *bcursor) +{ + SDL_Cursor *cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + SDL_CursorData *data = (SDL_CursorData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_free(cursor); + return NULL; + } + data->cursor = bcursor; + cursor->internal = data; + } + return cursor; +} + +static SDL_Cursor * HAIKU_CreateSystemCursor(SDL_SystemCursor id) +{ + BCursorID cursorId = B_CURSOR_ID_SYSTEM_DEFAULT; + + switch(id) + { + #define CURSORCASE(sdlname, bname) case SDL_SYSTEM_CURSOR_##sdlname: cursorId = B_CURSOR_ID_##bname; break + CURSORCASE(DEFAULT, SYSTEM_DEFAULT); + CURSORCASE(TEXT, I_BEAM); + CURSORCASE(WAIT, PROGRESS); + CURSORCASE(CROSSHAIR, CROSS_HAIR); + CURSORCASE(PROGRESS, PROGRESS); + CURSORCASE(NWSE_RESIZE, RESIZE_NORTH_WEST_SOUTH_EAST); + CURSORCASE(NESW_RESIZE, RESIZE_NORTH_EAST_SOUTH_WEST); + CURSORCASE(EW_RESIZE, RESIZE_EAST_WEST); + CURSORCASE(NS_RESIZE, RESIZE_NORTH_SOUTH); + CURSORCASE(MOVE, MOVE); + CURSORCASE(NOT_ALLOWED, NOT_ALLOWED); + CURSORCASE(POINTER, FOLLOW_LINK); + CURSORCASE(NW_RESIZE, RESIZE_NORTH_WEST_SOUTH_EAST); + CURSORCASE(N_RESIZE, RESIZE_NORTH_SOUTH); + CURSORCASE(NE_RESIZE, RESIZE_NORTH_EAST_SOUTH_WEST); + CURSORCASE(E_RESIZE, RESIZE_EAST_WEST); + CURSORCASE(SE_RESIZE, RESIZE_NORTH_WEST_SOUTH_EAST); + CURSORCASE(S_RESIZE, RESIZE_NORTH_SOUTH); + CURSORCASE(SW_RESIZE, RESIZE_NORTH_EAST_SOUTH_WEST); + CURSORCASE(W_RESIZE, RESIZE_EAST_WEST); + #undef CURSORCASE + default: + SDL_assert(0); + return NULL; + } + + return HAIKU_CreateCursorAndData(new BCursor(cursorId)); +} + +static SDL_Cursor * HAIKU_CreateDefaultCursor() +{ + SDL_SystemCursor id = SDL_GetDefaultSystemCursor(); + return HAIKU_CreateSystemCursor(id); +} + +static void HAIKU_FreeCursor(SDL_Cursor * cursor) +{ + SDL_CursorData *data = cursor->internal; + + if (data) { + delete data->cursor; + } + SDL_free(data); + SDL_free(cursor); +} + +static SDL_Cursor * HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + SDL_Surface *converted; + + converted = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888); + if (!converted) { + return NULL; + } + + BBitmap *cursorBitmap = new BBitmap(BRect(0, 0, surface->w - 1, surface->h - 1), B_RGBA32); + cursorBitmap->SetBits(converted->pixels, converted->h * converted->pitch, 0, B_RGBA32); + SDL_DestroySurface(converted); + + return HAIKU_CreateCursorAndData(new BCursor(cursorBitmap, BPoint(hot_x, hot_y))); +} + +static bool HAIKU_ShowCursor(SDL_Cursor *cursor) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (!mouse) { + return true; + } + + if (cursor) { + BCursor *hCursor = cursor->internal->cursor; + be_app->SetCursor(hCursor); + } else { + BCursor *hCursor = new BCursor(B_CURSOR_ID_NO_CURSOR); + be_app->SetCursor(hCursor); + delete hCursor; + } + + return true; +} + +static bool HAIKU_SetRelativeMouseMode(bool enabled) +{ + SDL_Window *window = SDL_GetMouseFocus(); + if (!window) { + return true; + } + + SDL_BWin *bewin = _ToBeWin(window); + BGLView *_SDL_GLView = bewin->GetGLView(); + if (!_SDL_GLView) { + return false; + } + + bewin->Lock(); + if (enabled) + _SDL_GLView->SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY); + else + _SDL_GLView->SetEventMask(0, 0); + bewin->Unlock(); + + return true; +} + +static void HAIKU_MouseInit(SDL_VideoDevice *_this) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + if (!mouse) { + return; + } + mouse->CreateCursor = HAIKU_CreateCursor; + mouse->CreateSystemCursor = HAIKU_CreateSystemCursor; + mouse->ShowCursor = HAIKU_ShowCursor; + mouse->FreeCursor = HAIKU_FreeCursor; + mouse->SetRelativeMouseMode = HAIKU_SetRelativeMouseMode; + + SDL_SetDefaultCursor(HAIKU_CreateDefaultCursor()); +} + +bool HAIKU_VideoInit(SDL_VideoDevice *_this) +{ + // Initialize the Be Application for appserver interaction + if (!SDL_InitBeApp()) { + return false; + } + + // Initialize video modes + HAIKU_InitModes(_this); + + // Init the keymap + HAIKU_InitOSKeymap(); + + HAIKU_MouseInit(_this); + + // Assume we have a mouse and keyboard + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); + +#ifdef SDL_VIDEO_OPENGL + // testgl application doesn't load library, just tries to load symbols + // is it correct? if so we have to load library here + HAIKU_GL_LoadLibrary(_this, NULL); +#endif + + // We're done! + return true; +} + +void HAIKU_VideoQuit(SDL_VideoDevice *_this) +{ + + HAIKU_QuitModes(_this); + + SDL_QuitBeApp(); +} + +// just sticking this function in here so it's in a C++ source file. +extern "C" +bool HAIKU_OpenURL(const char *url) +{ + BUrl burl(url); + const status_t rc = burl.OpenWithPreferredApplication(false); + if (rc != B_NO_ERROR) { + return SDL_SetError("URL open failed (err=%d)", (int)rc); + } + return true; +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.h new file mode 100644 index 0000000..f107d80 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bvideo.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BVIDEO_H +#define BVIDEO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../core/haiku/SDL_BeApp.h" +#include "../SDL_sysvideo.h" + +extern void HAIKU_VideoQuit(SDL_VideoDevice *_this); +extern bool HAIKU_VideoInit(SDL_VideoDevice *_this); +extern void HAIKU_DeleteDevice(SDL_VideoDevice *_this); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.cc b/contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.cc new file mode 100644 index 0000000..47a28d3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.cc @@ -0,0 +1,224 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_HAIKU +#include "../SDL_sysvideo.h" + +#include "SDL_BWin.h" +#include + +// Define a path to window's BWIN data +#ifdef __cplusplus +extern "C" { +#endif + +static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) +{ + return (SDL_BWin *)(window->internal); +} + +static SDL_INLINE SDL_BLooper *_GetBeLooper() +{ + return SDL_Looper; +} + +static bool _InitWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + uint32 flags = 0; + window_look look = B_TITLED_WINDOW_LOOK; + + BRect bounds( + window->x, + window->y, + window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing + window->y + window->h - 1 + ); + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + // TODO: Add support for this flag + printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__); + } + if (window->flags & SDL_WINDOW_OPENGL) { + // TODO: Add support for this flag + } + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE; + } + if (window->flags & SDL_WINDOW_BORDERLESS) { + look = B_NO_BORDER_WINDOW_LOOK; + } + + SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags); + if (!bwin) { + return false; + } + + window->internal = (SDL_WindowData *)bwin; + int32 winID = _GetBeLooper()->GetID(window); + bwin->SetID(winID); + + return true; +} + +bool HAIKU_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + if (!_InitWindow(_this, window, create_props)) { + return false; + } + + // Start window loop + _ToBeWin(window)->Show(); + return true; +} + +void HAIKU_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_SET_TITLE); + msg.AddString("window-title", window->title); + _ToBeWin(window)->PostMessage(&msg); +} + +bool HAIKU_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_MOVE_WINDOW); + msg.AddInt32("window-x", window->pending.x); + msg.AddInt32("window-y", window->pending.y); + _ToBeWin(window)->PostMessage(&msg); + return true; +} + +void HAIKU_SetWindowSize(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_RESIZE_WINDOW); + msg.AddInt32("window-w", window->pending.w - 1); + msg.AddInt32("window-h", window->pending.h - 1); + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window * window, bool bordered) +{ + BMessage msg(BWIN_SET_BORDERED); + msg.AddBool("window-border", bordered != false); + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window * window, bool resizable) +{ + BMessage msg(BWIN_SET_RESIZABLE); + msg.AddBool("window-resizable", resizable != false); + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_ShowWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_SHOW_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_HideWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_HIDE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_RaiseWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_SHOW_WINDOW); // Activate this window and move to front + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_MAXIMIZE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_MINIMIZE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void HAIKU_RestoreWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_RESTORE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +SDL_FullscreenResult HAIKU_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay * display, SDL_FullscreenOp fullscreen) +{ + // Haiku tracks all video display information + BMessage msg(BWIN_FULLSCREEN); + msg.AddBool("fullscreen", !!fullscreen); + _ToBeWin(window)->PostMessage(&msg); + return SDL_FULLSCREEN_SUCCEEDED; +} + + +void HAIKU_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window * window) +{ + BMessage msg(BWIN_MINIMUM_SIZE_WINDOW); + msg.AddInt32("window-w", window->w -1); + msg.AddInt32("window-h", window->h -1); + _ToBeWin(window)->PostMessage(&msg); +} + +bool HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window * window, bool grabbed) +{ + // TODO: Implement this! + return SDL_Unsupported(); +} + +bool HAIKU_SetWindowParent(SDL_VideoDevice *_this, SDL_Window * window, SDL_Window *parent) +{ + return true; +} + +bool HAIKU_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal) +{ + if (modal) { + _ToBeWin(window)->SetLook(B_MODAL_WINDOW_LOOK); + _ToBeWin(window)->SetFeel(B_MODAL_SUBSET_WINDOW_FEEL); + _ToBeWin(window)->AddToSubset(_ToBeWin(window->parent)); + } else { + window_look look = (window->flags & SDL_WINDOW_BORDERLESS) ? B_NO_BORDER_WINDOW_LOOK : B_TITLED_WINDOW_LOOK; + _ToBeWin(window)->RemoveFromSubset(_ToBeWin(window->parent)); + _ToBeWin(window)->SetLook(look); + _ToBeWin(window)->SetFeel(B_NORMAL_WINDOW_FEEL); + } + + return true; +} + +void HAIKU_DestroyWindow(SDL_VideoDevice *_this, SDL_Window * window) +{ + _ToBeWin(window)->LockLooper(); // This MUST be locked + _GetBeLooper()->ClearID(_ToBeWin(window)); + _ToBeWin(window)->Quit(); + window->internal = NULL; +} + +#ifdef __cplusplus +} +#endif + +#endif // SDL_VIDEO_DRIVER_HAIKU diff --git a/contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.h b/contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.h new file mode 100644 index 0000000..0f0da85 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/haiku/SDL_bwindow.h @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BWINDOW_H +#define SDL_BWINDOW_H + +#include "../SDL_sysvideo.h" + +extern bool HAIKU_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void HAIKU_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool HAIKU_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void HAIKU_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void HAIKU_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern SDL_FullscreenResult HAIKU_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); +extern bool HAIKU_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern bool HAIKU_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); +extern bool HAIKU_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); +extern void HAIKU_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/EGL/egl.h b/contrib/SDL-3.2.8/src/video/khronos/EGL/egl.h new file mode 100644 index 0000000..c58f552 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/EGL/egl.h @@ -0,0 +1,342 @@ +#ifndef __egl_h_ +#define __egl_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +** +** This header is generated from the Khronos EGL XML API Registry. +** The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.khronos.org/registry/egl +** +** Khronos $Git commit SHA1: f4cc936b88 $ on $Git commit date: 2023-12-16 01:21:49 -0500 $ +*/ + +#include + +#ifndef EGL_EGL_PROTOTYPES +#define EGL_EGL_PROTOTYPES 1 +#endif + +/* Generated on date 20231215 */ + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_VERSION_1_0 +#define EGL_VERSION_1_0 1 +typedef unsigned int EGLBoolean; +typedef void *EGLDisplay; +#include +#include +typedef void *EGLConfig; +typedef void *EGLSurface; +typedef void *EGLContext; +typedef void (*__eglMustCastToProperFunctionPointerType)(void); +#define EGL_ALPHA_SIZE 0x3021 +#define EGL_BAD_ACCESS 0x3002 +#define EGL_BAD_ALLOC 0x3003 +#define EGL_BAD_ATTRIBUTE 0x3004 +#define EGL_BAD_CONFIG 0x3005 +#define EGL_BAD_CONTEXT 0x3006 +#define EGL_BAD_CURRENT_SURFACE 0x3007 +#define EGL_BAD_DISPLAY 0x3008 +#define EGL_BAD_MATCH 0x3009 +#define EGL_BAD_NATIVE_PIXMAP 0x300A +#define EGL_BAD_NATIVE_WINDOW 0x300B +#define EGL_BAD_PARAMETER 0x300C +#define EGL_BAD_SURFACE 0x300D +#define EGL_BLUE_SIZE 0x3022 +#define EGL_BUFFER_SIZE 0x3020 +#define EGL_CONFIG_CAVEAT 0x3027 +#define EGL_CONFIG_ID 0x3028 +#define EGL_CORE_NATIVE_ENGINE 0x305B +#define EGL_DEPTH_SIZE 0x3025 +#define EGL_DONT_CARE EGL_CAST(EGLint,-1) +#define EGL_DRAW 0x3059 +#define EGL_EXTENSIONS 0x3055 +#define EGL_FALSE 0 +#define EGL_GREEN_SIZE 0x3023 +#define EGL_HEIGHT 0x3056 +#define EGL_LARGEST_PBUFFER 0x3058 +#define EGL_LEVEL 0x3029 +#define EGL_MAX_PBUFFER_HEIGHT 0x302A +#define EGL_MAX_PBUFFER_PIXELS 0x302B +#define EGL_MAX_PBUFFER_WIDTH 0x302C +#define EGL_NATIVE_RENDERABLE 0x302D +#define EGL_NATIVE_VISUAL_ID 0x302E +#define EGL_NATIVE_VISUAL_TYPE 0x302F +#define EGL_NONE 0x3038 +#define EGL_NON_CONFORMANT_CONFIG 0x3051 +#define EGL_NOT_INITIALIZED 0x3001 +#define EGL_NO_CONTEXT EGL_CAST(EGLContext,0) +#define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0) +#define EGL_NO_SURFACE EGL_CAST(EGLSurface,0) +#define EGL_PBUFFER_BIT 0x0001 +#define EGL_PIXMAP_BIT 0x0002 +#define EGL_READ 0x305A +#define EGL_RED_SIZE 0x3024 +#define EGL_SAMPLES 0x3031 +#define EGL_SAMPLE_BUFFERS 0x3032 +#define EGL_SLOW_CONFIG 0x3050 +#define EGL_STENCIL_SIZE 0x3026 +#define EGL_SUCCESS 0x3000 +#define EGL_SURFACE_TYPE 0x3033 +#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 +#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 +#define EGL_TRANSPARENT_RED_VALUE 0x3037 +#define EGL_TRANSPARENT_RGB 0x3052 +#define EGL_TRANSPARENT_TYPE 0x3034 +#define EGL_TRUE 1 +#define EGL_VENDOR 0x3053 +#define EGL_VERSION 0x3054 +#define EGL_WIDTH 0x3057 +#define EGL_WINDOW_BIT 0x0004 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCHOOSECONFIGPROC) (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOPYBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +typedef EGLContext (EGLAPIENTRYP PFNEGLCREATECONTEXTPROC) (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERSURFACEPROC) (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGATTRIBPROC) (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCONFIGSPROC) (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETCURRENTDISPLAYPROC) (void); +typedef EGLSurface (EGLAPIENTRYP PFNEGLGETCURRENTSURFACEPROC) (EGLint readdraw); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETDISPLAYPROC) (EGLNativeDisplayType display_id); +typedef EGLint (EGLAPIENTRYP PFNEGLGETERRORPROC) (void); +typedef __eglMustCastToProperFunctionPointerType (EGLAPIENTRYP PFNEGLGETPROCADDRESSPROC) (const char *procname); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLINITIALIZEPROC) (EGLDisplay dpy, EGLint *major, EGLint *minor); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLMAKECURRENTPROC) (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYCONTEXTPROC) (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYSTRINGPROC) (EGLDisplay dpy, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSPROC) (EGLDisplay dpy, EGLSurface surface); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLTERMINATEPROC) (EGLDisplay dpy); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITGLPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITNATIVEPROC) (EGLint engine); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target); +EGLAPI EGLContext EGLAPIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config); +EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay (void); +EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface (EGLint readdraw); +EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay (EGLNativeDisplayType display_id); +EGLAPI EGLint EGLAPIENTRY eglGetError (void); +EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY eglGetProcAddress (const char *procname); +EGLAPI EGLBoolean EGLAPIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor); +EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value); +EGLAPI const char *EGLAPIENTRY eglQueryString (EGLDisplay dpy, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface surface); +EGLAPI EGLBoolean EGLAPIENTRY eglTerminate (EGLDisplay dpy); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative (EGLint engine); +#endif +#endif /* EGL_VERSION_1_0 */ + +#ifndef EGL_VERSION_1_1 +#define EGL_VERSION_1_1 1 +#define EGL_BACK_BUFFER 0x3084 +#define EGL_BIND_TO_TEXTURE_RGB 0x3039 +#define EGL_BIND_TO_TEXTURE_RGBA 0x303A +#define EGL_CONTEXT_LOST 0x300E +#define EGL_MIN_SWAP_INTERVAL 0x303B +#define EGL_MAX_SWAP_INTERVAL 0x303C +#define EGL_MIPMAP_TEXTURE 0x3082 +#define EGL_MIPMAP_LEVEL 0x3083 +#define EGL_NO_TEXTURE 0x305C +#define EGL_TEXTURE_2D 0x305F +#define EGL_TEXTURE_FORMAT 0x3080 +#define EGL_TEXTURE_RGB 0x305D +#define EGL_TEXTURE_RGBA 0x305E +#define EGL_TEXTURE_TARGET 0x3081 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDTEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETEXIMAGEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSURFACEATTRIBPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPINTERVALPROC) (EGLDisplay dpy, EGLint interval); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage (EGLDisplay dpy, EGLSurface surface, EGLint buffer); +EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval (EGLDisplay dpy, EGLint interval); +#endif +#endif /* EGL_VERSION_1_1 */ + +#ifndef EGL_VERSION_1_2 +#define EGL_VERSION_1_2 1 +typedef unsigned int EGLenum; +typedef void *EGLClientBuffer; +#define EGL_ALPHA_FORMAT 0x3088 +#define EGL_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_ALPHA_FORMAT_PRE 0x308C +#define EGL_ALPHA_MASK_SIZE 0x303E +#define EGL_BUFFER_PRESERVED 0x3094 +#define EGL_BUFFER_DESTROYED 0x3095 +#define EGL_CLIENT_APIS 0x308D +#define EGL_COLORSPACE 0x3087 +#define EGL_COLORSPACE_sRGB 0x3089 +#define EGL_COLORSPACE_LINEAR 0x308A +#define EGL_COLOR_BUFFER_TYPE 0x303F +#define EGL_CONTEXT_CLIENT_TYPE 0x3097 +#define EGL_DISPLAY_SCALING 10000 +#define EGL_HORIZONTAL_RESOLUTION 0x3090 +#define EGL_LUMINANCE_BUFFER 0x308F +#define EGL_LUMINANCE_SIZE 0x303D +#define EGL_OPENGL_ES_BIT 0x0001 +#define EGL_OPENVG_BIT 0x0002 +#define EGL_OPENGL_ES_API 0x30A0 +#define EGL_OPENVG_API 0x30A1 +#define EGL_OPENVG_IMAGE 0x3096 +#define EGL_PIXEL_ASPECT_RATIO 0x3092 +#define EGL_RENDERABLE_TYPE 0x3040 +#define EGL_RENDER_BUFFER 0x3086 +#define EGL_RGB_BUFFER 0x308E +#define EGL_SINGLE_BUFFER 0x3085 +#define EGL_SWAP_BEHAVIOR 0x3093 +#define EGL_UNKNOWN EGL_CAST(EGLint,-1) +#define EGL_VERTICAL_RESOLUTION 0x3091 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDAPIPROC) (EGLenum api); +typedef EGLenum (EGLAPIENTRYP PFNEGLQUERYAPIPROC) (void); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC) (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRELEASETHREADPROC) (void); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITCLIENTPROC) (void); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI (EGLenum api); +EGLAPI EGLenum EGLAPIENTRY eglQueryAPI (void); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer (EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread (void); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient (void); +#endif +#endif /* EGL_VERSION_1_2 */ + +#ifndef EGL_VERSION_1_3 +#define EGL_VERSION_1_3 1 +#define EGL_CONFORMANT 0x3042 +#define EGL_CONTEXT_CLIENT_VERSION 0x3098 +#define EGL_MATCH_NATIVE_PIXMAP 0x3041 +#define EGL_OPENGL_ES2_BIT 0x0004 +#define EGL_VG_ALPHA_FORMAT 0x3088 +#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B +#define EGL_VG_ALPHA_FORMAT_PRE 0x308C +#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 +#define EGL_VG_COLORSPACE 0x3087 +#define EGL_VG_COLORSPACE_sRGB 0x3089 +#define EGL_VG_COLORSPACE_LINEAR 0x308A +#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 +#endif /* EGL_VERSION_1_3 */ + +#ifndef EGL_VERSION_1_4 +#define EGL_VERSION_1_4 1 +#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0) +#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 +#define EGL_MULTISAMPLE_RESOLVE 0x3099 +#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A +#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B +#define EGL_OPENGL_API 0x30A2 +#define EGL_OPENGL_BIT 0x0008 +#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 +typedef EGLContext (EGLAPIENTRYP PFNEGLGETCURRENTCONTEXTPROC) (void); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext (void); +#endif +#endif /* EGL_VERSION_1_4 */ + +#ifndef EGL_VERSION_1_5 +#define EGL_VERSION_1_5 1 +typedef void *EGLSync; +typedef intptr_t EGLAttrib; +typedef khronos_utime_nanoseconds_t EGLTime; +typedef void *EGLImage; +#define EGL_CONTEXT_MAJOR_VERSION 0x3098 +#define EGL_CONTEXT_MINOR_VERSION 0x30FB +#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD +#define EGL_NO_RESET_NOTIFICATION 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002 +#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2 +#define EGL_OPENGL_ES3_BIT 0x00000040 +#define EGL_CL_EVENT_HANDLE 0x309C +#define EGL_SYNC_CL_EVENT 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0 +#define EGL_SYNC_TYPE 0x30F7 +#define EGL_SYNC_STATUS 0x30F1 +#define EGL_SYNC_CONDITION 0x30F8 +#define EGL_SIGNALED 0x30F2 +#define EGL_UNSIGNALED 0x30F3 +#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001 +#define EGL_FOREVER 0xFFFFFFFFFFFFFFFFull +#define EGL_TIMEOUT_EXPIRED 0x30F5 +#define EGL_CONDITION_SATISFIED 0x30F6 +#define EGL_NO_SYNC EGL_CAST(EGLSync,0) +#define EGL_SYNC_FENCE 0x30F9 +#define EGL_GL_COLORSPACE 0x309D +#define EGL_GL_COLORSPACE_SRGB 0x3089 +#define EGL_GL_COLORSPACE_LINEAR 0x308A +#define EGL_GL_RENDERBUFFER 0x30B9 +#define EGL_GL_TEXTURE_2D 0x30B1 +#define EGL_GL_TEXTURE_LEVEL 0x30BC +#define EGL_GL_TEXTURE_3D 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET 0x30BD +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8 +#define EGL_IMAGE_PRESERVED 0x30D2 +#define EGL_NO_IMAGE EGL_CAST(EGLImage,0) +typedef EGLSync (EGLAPIENTRYP PFNEGLCREATESYNCPROC) (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCPROC) (EGLDisplay dpy, EGLSync sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBPROC) (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +typedef EGLImage (EGLAPIENTRYP PFNEGLCREATEIMAGEPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEPROC) (EGLDisplay dpy, EGLImage image); +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYPROC) (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLWAITSYNCPROC) (EGLDisplay dpy, EGLSync sync, EGLint flags); +#if EGL_EGL_PROTOTYPES +EGLAPI EGLSync EGLAPIENTRY eglCreateSync (EGLDisplay dpy, EGLenum type, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySync (EGLDisplay dpy, EGLSync sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttrib (EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib *value); +EGLAPI EGLImage EGLAPIENTRY eglCreateImage (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImage (EGLDisplay dpy, EGLImage image); +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplay (EGLenum platform, void *native_display, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurface (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurface (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglWaitSync (EGLDisplay dpy, EGLSync sync, EGLint flags); +#endif +#endif /* EGL_VERSION_1_5 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/EGL/eglext.h b/contrib/SDL-3.2.8/src/video/khronos/EGL/eglext.h new file mode 100644 index 0000000..9932ebe --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/EGL/eglext.h @@ -0,0 +1,1507 @@ +#ifndef __eglext_h_ +#define __eglext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +** +** This header is generated from the Khronos EGL XML API Registry. +** The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** http://www.khronos.org/registry/egl +** +** Khronos $Git commit SHA1: f4cc936b88 $ on $Git commit date: 2023-12-16 01:21:49 -0500 $ +*/ + +#include + +#define EGL_EGLEXT_VERSION 20231215 + +/* Generated C header for: + * API: egl + * Versions considered: .* + * Versions emitted: _nomatch_^ + * Default extensions included: egl + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef EGL_KHR_cl_event +#define EGL_KHR_cl_event 1 +#define EGL_CL_EVENT_HANDLE_KHR 0x309C +#define EGL_SYNC_CL_EVENT_KHR 0x30FE +#define EGL_SYNC_CL_EVENT_COMPLETE_KHR 0x30FF +#endif /* EGL_KHR_cl_event */ + +#ifndef EGL_KHR_cl_event2 +#define EGL_KHR_cl_event2 1 +typedef void *EGLSyncKHR; +typedef intptr_t EGLAttribKHR; +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNC64KHRPROC) (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSync64KHR (EGLDisplay dpy, EGLenum type, const EGLAttribKHR *attrib_list); +#endif +#endif /* EGL_KHR_cl_event2 */ + +#ifndef EGL_KHR_client_get_all_proc_addresses +#define EGL_KHR_client_get_all_proc_addresses 1 +#endif /* EGL_KHR_client_get_all_proc_addresses */ + +#ifndef EGL_KHR_config_attribs +#define EGL_KHR_config_attribs 1 +#define EGL_CONFORMANT_KHR 0x3042 +#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 +#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 +#endif /* EGL_KHR_config_attribs */ + +#ifndef EGL_KHR_context_flush_control +#define EGL_KHR_context_flush_control 1 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 +#define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 +#endif /* EGL_KHR_context_flush_control */ + +#ifndef EGL_KHR_create_context +#define EGL_KHR_create_context 1 +#define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 +#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB +#define EGL_CONTEXT_FLAGS_KHR 0x30FC +#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD +#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF +#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 +#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 +#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 +#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 +#endif /* EGL_KHR_create_context */ + +#ifndef EGL_KHR_create_context_no_error +#define EGL_KHR_create_context_no_error 1 +#define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31B3 +#endif /* EGL_KHR_create_context_no_error */ + +#ifndef EGL_KHR_debug +#define EGL_KHR_debug 1 +typedef void *EGLLabelKHR; +typedef void *EGLObjectKHR; +typedef void (EGLAPIENTRY *EGLDEBUGPROCKHR)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message); +#define EGL_OBJECT_THREAD_KHR 0x33B0 +#define EGL_OBJECT_DISPLAY_KHR 0x33B1 +#define EGL_OBJECT_CONTEXT_KHR 0x33B2 +#define EGL_OBJECT_SURFACE_KHR 0x33B3 +#define EGL_OBJECT_IMAGE_KHR 0x33B4 +#define EGL_OBJECT_SYNC_KHR 0x33B5 +#define EGL_OBJECT_STREAM_KHR 0x33B6 +#define EGL_DEBUG_MSG_CRITICAL_KHR 0x33B9 +#define EGL_DEBUG_MSG_ERROR_KHR 0x33BA +#define EGL_DEBUG_MSG_WARN_KHR 0x33BB +#define EGL_DEBUG_MSG_INFO_KHR 0x33BC +#define EGL_DEBUG_CALLBACK_KHR 0x33B8 +typedef EGLint (EGLAPIENTRYP PFNEGLDEBUGMESSAGECONTROLKHRPROC) (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEBUGKHRPROC) (EGLint attribute, EGLAttrib *value); +typedef EGLint (EGLAPIENTRYP PFNEGLLABELOBJECTKHRPROC) (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDebugMessageControlKHR (EGLDEBUGPROCKHR callback, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDebugKHR (EGLint attribute, EGLAttrib *value); +EGLAPI EGLint EGLAPIENTRY eglLabelObjectKHR (EGLDisplay display, EGLenum objectType, EGLObjectKHR object, EGLLabelKHR label); +#endif +#endif /* EGL_KHR_debug */ + +#ifndef EGL_KHR_display_reference +#define EGL_KHR_display_reference 1 +#define EGL_TRACK_REFERENCES_KHR 0x3352 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBKHRPROC) (EGLDisplay dpy, EGLint name, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribKHR (EGLDisplay dpy, EGLint name, EGLAttrib *value); +#endif +#endif /* EGL_KHR_display_reference */ + +#ifndef EGL_KHR_fence_sync +#define EGL_KHR_fence_sync 1 +typedef khronos_utime_nanoseconds_t EGLTimeKHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR 0x30F0 +#define EGL_SYNC_CONDITION_KHR 0x30F8 +#define EGL_SYNC_FENCE_KHR 0x30F9 +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHRPROC) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR (EGLDisplay dpy, EGLSyncKHR sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_fence_sync */ + +#ifndef EGL_KHR_get_all_proc_addresses +#define EGL_KHR_get_all_proc_addresses 1 +#endif /* EGL_KHR_get_all_proc_addresses */ + +#ifndef EGL_KHR_gl_colorspace +#define EGL_KHR_gl_colorspace 1 +#define EGL_GL_COLORSPACE_KHR 0x309D +#define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 +#define EGL_GL_COLORSPACE_LINEAR_KHR 0x308A +#endif /* EGL_KHR_gl_colorspace */ + +#ifndef EGL_KHR_gl_renderbuffer_image +#define EGL_KHR_gl_renderbuffer_image 1 +#define EGL_GL_RENDERBUFFER_KHR 0x30B9 +#endif /* EGL_KHR_gl_renderbuffer_image */ + +#ifndef EGL_KHR_gl_texture_2D_image +#define EGL_KHR_gl_texture_2D_image 1 +#define EGL_GL_TEXTURE_2D_KHR 0x30B1 +#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC +#endif /* EGL_KHR_gl_texture_2D_image */ + +#ifndef EGL_KHR_gl_texture_3D_image +#define EGL_KHR_gl_texture_3D_image 1 +#define EGL_GL_TEXTURE_3D_KHR 0x30B2 +#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD +#endif /* EGL_KHR_gl_texture_3D_image */ + +#ifndef EGL_KHR_gl_texture_cubemap_image +#define EGL_KHR_gl_texture_cubemap_image 1 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 +#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 +#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 +#endif /* EGL_KHR_gl_texture_cubemap_image */ + +#ifndef EGL_KHR_image +#define EGL_KHR_image 1 +typedef void *EGLImageKHR; +#define EGL_NATIVE_PIXMAP_KHR 0x30B0 +#define EGL_NO_IMAGE_KHR EGL_CAST(EGLImageKHR,0) +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_KHR_image */ + +#ifndef EGL_KHR_image_base +#define EGL_KHR_image_base 1 +#define EGL_IMAGE_PRESERVED_KHR 0x30D2 +#endif /* EGL_KHR_image_base */ + +#ifndef EGL_KHR_image_pixmap +#define EGL_KHR_image_pixmap 1 +#endif /* EGL_KHR_image_pixmap */ + +#ifndef EGL_KHR_lock_surface +#define EGL_KHR_lock_surface 1 +#define EGL_READ_SURFACE_BIT_KHR 0x0001 +#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 +#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 +#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 +#define EGL_MATCH_FORMAT_KHR 0x3043 +#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 +#define EGL_FORMAT_RGB_565_KHR 0x30C1 +#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 +#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 +#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 +#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 +#define EGL_BITMAP_POINTER_KHR 0x30C6 +#define EGL_BITMAP_PITCH_KHR 0x30C7 +#define EGL_BITMAP_ORIGIN_KHR 0x30C8 +#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 +#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA +#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB +#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC +#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD +#define EGL_LOWER_LEFT_KHR 0x30CE +#define EGL_UPPER_LEFT_KHR 0x30CF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay dpy, EGLSurface surface); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay dpy, EGLSurface surface); +#endif +#endif /* EGL_KHR_lock_surface */ + +#ifndef EGL_KHR_lock_surface2 +#define EGL_KHR_lock_surface2 1 +#define EGL_BITMAP_PIXEL_SIZE_KHR 0x3110 +#endif /* EGL_KHR_lock_surface2 */ + +#ifndef EGL_KHR_lock_surface3 +#define EGL_KHR_lock_surface3 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACE64KHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface64KHR (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLAttribKHR *value); +#endif +#endif /* EGL_KHR_lock_surface3 */ + +#ifndef EGL_KHR_mutable_render_buffer +#define EGL_KHR_mutable_render_buffer 1 +#define EGL_MUTABLE_RENDER_BUFFER_BIT_KHR 0x1000 +#endif /* EGL_KHR_mutable_render_buffer */ + +#ifndef EGL_KHR_no_config_context +#define EGL_KHR_no_config_context 1 +#define EGL_NO_CONFIG_KHR EGL_CAST(EGLConfig,0) +#endif /* EGL_KHR_no_config_context */ + +#ifndef EGL_KHR_partial_update +#define EGL_KHR_partial_update 1 +#define EGL_BUFFER_AGE_KHR 0x313D +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETDAMAGEREGIONKHRPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSetDamageRegionKHR (EGLDisplay dpy, EGLSurface surface, EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_partial_update */ + +#ifndef EGL_KHR_platform_android +#define EGL_KHR_platform_android 1 +#define EGL_PLATFORM_ANDROID_KHR 0x3141 +#endif /* EGL_KHR_platform_android */ + +#ifndef EGL_KHR_platform_gbm +#define EGL_KHR_platform_gbm 1 +#define EGL_PLATFORM_GBM_KHR 0x31D7 +#endif /* EGL_KHR_platform_gbm */ + +#ifndef EGL_KHR_platform_wayland +#define EGL_KHR_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_KHR 0x31D8 +#endif /* EGL_KHR_platform_wayland */ + +#ifndef EGL_KHR_platform_x11 +#define EGL_KHR_platform_x11 1 +#define EGL_PLATFORM_X11_KHR 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 +#endif /* EGL_KHR_platform_x11 */ + +#ifndef EGL_KHR_reusable_sync +#define EGL_KHR_reusable_sync 1 +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_STATUS_KHR 0x30F1 +#define EGL_SIGNALED_KHR 0x30F2 +#define EGL_UNSIGNALED_KHR 0x30F3 +#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 +#define EGL_CONDITION_SATISFIED_KHR 0x30F6 +#define EGL_SYNC_TYPE_KHR 0x30F7 +#define EGL_SYNC_REUSABLE_KHR 0x30FA +#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 +#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull +#define EGL_NO_SYNC_KHR EGL_CAST(EGLSyncKHR,0) +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_reusable_sync */ + +#ifndef EGL_KHR_stream +#define EGL_KHR_stream 1 +typedef void *EGLStreamKHR; +typedef khronos_uint64_t EGLuint64KHR; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_NO_STREAM_KHR EGL_CAST(EGLStreamKHR,0) +#define EGL_CONSUMER_LATENCY_USEC_KHR 0x3210 +#define EGL_PRODUCER_FRAME_KHR 0x3212 +#define EGL_CONSUMER_FRAME_KHR 0x3213 +#define EGL_STREAM_STATE_KHR 0x3214 +#define EGL_STREAM_STATE_CREATED_KHR 0x3215 +#define EGL_STREAM_STATE_CONNECTING_KHR 0x3216 +#define EGL_STREAM_STATE_EMPTY_KHR 0x3217 +#define EGL_STREAM_STATE_NEW_FRAME_AVAILABLE_KHR 0x3218 +#define EGL_STREAM_STATE_OLD_FRAME_AVAILABLE_KHR 0x3219 +#define EGL_STREAM_STATE_DISCONNECTED_KHR 0x321A +#define EGL_BAD_STREAM_KHR 0x321B +#define EGL_BAD_STATE_KHR 0x321C +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMKHRPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMU64KHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamKHR (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroyStreamKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLint *value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamu64KHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLuint64KHR *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream */ + +#ifndef EGL_KHR_stream_attrib +#define EGL_KHR_stream_attrib 1 +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBKHRPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEATTRIBKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamAttribKHR (EGLDisplay dpy, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib *value); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseAttribKHR (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_KHR_stream_attrib */ + +#ifndef EGL_KHR_stream_consumer_gltexture +#define EGL_KHR_stream_consumer_gltexture 1 +#ifdef EGL_KHR_stream +#define EGL_CONSUMER_ACQUIRE_TIMEOUT_USEC_KHR 0x321E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERACQUIREKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERRELEASEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerAcquireKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerReleaseKHR (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_consumer_gltexture */ + +#ifndef EGL_KHR_stream_cross_process_fd +#define EGL_KHR_stream_cross_process_fd 1 +typedef int EGLNativeFileDescriptorKHR; +#ifdef EGL_KHR_stream +#define EGL_NO_FILE_DESCRIPTOR_KHR EGL_CAST(EGLNativeFileDescriptorKHR,-1) +typedef EGLNativeFileDescriptorKHR (EGLAPIENTRYP PFNEGLGETSTREAMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream); +typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMFROMFILEDESCRIPTORKHRPROC) (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLNativeFileDescriptorKHR EGLAPIENTRY eglGetStreamFileDescriptorKHR (EGLDisplay dpy, EGLStreamKHR stream); +EGLAPI EGLStreamKHR EGLAPIENTRY eglCreateStreamFromFileDescriptorKHR (EGLDisplay dpy, EGLNativeFileDescriptorKHR file_descriptor); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_cross_process_fd */ + +#ifndef EGL_KHR_stream_fifo +#define EGL_KHR_stream_fifo 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_FIFO_LENGTH_KHR 0x31FC +#define EGL_STREAM_TIME_NOW_KHR 0x31FD +#define EGL_STREAM_TIME_CONSUMER_KHR 0x31FE +#define EGL_STREAM_TIME_PRODUCER_KHR 0x31FF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMTIMEKHRPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamTimeKHR (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLTimeKHR *value); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_fifo */ + +#ifndef EGL_KHR_stream_producer_aldatalocator +#define EGL_KHR_stream_producer_aldatalocator 1 +#ifdef EGL_KHR_stream +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_aldatalocator */ + +#ifndef EGL_KHR_stream_producer_eglsurface +#define EGL_KHR_stream_producer_eglsurface 1 +#ifdef EGL_KHR_stream +#define EGL_STREAM_BIT_KHR 0x0800 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATESTREAMPRODUCERSURFACEKHRPROC) (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreateStreamProducerSurfaceKHR (EGLDisplay dpy, EGLConfig config, EGLStreamKHR stream, const EGLint *attrib_list); +#endif +#endif /* EGL_KHR_stream */ +#endif /* EGL_KHR_stream_producer_eglsurface */ + +#ifndef EGL_KHR_surfaceless_context +#define EGL_KHR_surfaceless_context 1 +#endif /* EGL_KHR_surfaceless_context */ + +#ifndef EGL_KHR_swap_buffers_with_damage +#define EGL_KHR_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageKHR (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_KHR_swap_buffers_with_damage */ + +#ifndef EGL_KHR_vg_parent_image +#define EGL_KHR_vg_parent_image 1 +#define EGL_VG_PARENT_IMAGE_KHR 0x30BA +#endif /* EGL_KHR_vg_parent_image */ + +#ifndef EGL_KHR_wait_sync +#define EGL_KHR_wait_sync 1 +typedef EGLint (EGLAPIENTRYP PFNEGLWAITSYNCKHRPROC) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglWaitSyncKHR (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags); +#endif +#endif /* EGL_KHR_wait_sync */ + +#ifndef EGL_ANDROID_GLES_layers +#define EGL_ANDROID_GLES_layers 1 +#endif /* EGL_ANDROID_GLES_layers */ + +#ifndef EGL_ANDROID_blob_cache +#define EGL_ANDROID_blob_cache 1 +typedef khronos_ssize_t EGLsizeiANDROID; +typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize); +typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize); +typedef void (EGLAPIENTRYP PFNEGLSETBLOBCACHEFUNCSANDROIDPROC) (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI void EGLAPIENTRY eglSetBlobCacheFuncsANDROID (EGLDisplay dpy, EGLSetBlobFuncANDROID set, EGLGetBlobFuncANDROID get); +#endif +#endif /* EGL_ANDROID_blob_cache */ + +#ifndef EGL_ANDROID_create_native_client_buffer +#define EGL_ANDROID_create_native_client_buffer 1 +#define EGL_NATIVE_BUFFER_USAGE_ANDROID 0x3143 +#define EGL_NATIVE_BUFFER_USAGE_PROTECTED_BIT_ANDROID 0x00000001 +#define EGL_NATIVE_BUFFER_USAGE_RENDERBUFFER_BIT_ANDROID 0x00000002 +#define EGL_NATIVE_BUFFER_USAGE_TEXTURE_BIT_ANDROID 0x00000004 +typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLCREATENATIVECLIENTBUFFERANDROIDPROC) (const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLClientBuffer EGLAPIENTRY eglCreateNativeClientBufferANDROID (const EGLint *attrib_list); +#endif +#endif /* EGL_ANDROID_create_native_client_buffer */ + +#ifndef EGL_ANDROID_framebuffer_target +#define EGL_ANDROID_framebuffer_target 1 +#define EGL_FRAMEBUFFER_TARGET_ANDROID 0x3147 +#endif /* EGL_ANDROID_framebuffer_target */ + +#ifndef EGL_ANDROID_front_buffer_auto_refresh +#define EGL_ANDROID_front_buffer_auto_refresh 1 +#define EGL_FRONT_BUFFER_AUTO_REFRESH_ANDROID 0x314C +#endif /* EGL_ANDROID_front_buffer_auto_refresh */ + +#ifndef EGL_ANDROID_get_frame_timestamps +#define EGL_ANDROID_get_frame_timestamps 1 +typedef khronos_stime_nanoseconds_t EGLnsecsANDROID; +#define EGL_TIMESTAMP_PENDING_ANDROID EGL_CAST(EGLnsecsANDROID,-2) +#define EGL_TIMESTAMP_INVALID_ANDROID EGL_CAST(EGLnsecsANDROID,-1) +#define EGL_TIMESTAMPS_ANDROID 0x3430 +#define EGL_COMPOSITE_DEADLINE_ANDROID 0x3431 +#define EGL_COMPOSITE_INTERVAL_ANDROID 0x3432 +#define EGL_COMPOSITE_TO_PRESENT_LATENCY_ANDROID 0x3433 +#define EGL_REQUESTED_PRESENT_TIME_ANDROID 0x3434 +#define EGL_RENDERING_COMPLETE_TIME_ANDROID 0x3435 +#define EGL_COMPOSITION_LATCH_TIME_ANDROID 0x3436 +#define EGL_FIRST_COMPOSITION_START_TIME_ANDROID 0x3437 +#define EGL_LAST_COMPOSITION_START_TIME_ANDROID 0x3438 +#define EGL_FIRST_COMPOSITION_GPU_FINISHED_TIME_ANDROID 0x3439 +#define EGL_DISPLAY_PRESENT_TIME_ANDROID 0x343A +#define EGL_DEQUEUE_READY_TIME_ANDROID 0x343B +#define EGL_READS_DONE_TIME_ANDROID 0x343C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETCOMPOSITORTIMINGANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETNEXTFRAMEIDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSUPPORTEDANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETFRAMETIMESTAMPSANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglGetCompositorTimingANDROID (EGLDisplay dpy, EGLSurface surface, EGLint numTimestamps, const EGLint *names, EGLnsecsANDROID *values); +EGLAPI EGLBoolean EGLAPIENTRY eglGetNextFrameIdANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR *frameId); +EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampSupportedANDROID (EGLDisplay dpy, EGLSurface surface, EGLint timestamp); +EGLAPI EGLBoolean EGLAPIENTRY eglGetFrameTimestampsANDROID (EGLDisplay dpy, EGLSurface surface, EGLuint64KHR frameId, EGLint numTimestamps, const EGLint *timestamps, EGLnsecsANDROID *values); +#endif +#endif /* EGL_ANDROID_get_frame_timestamps */ + +#ifndef EGL_ANDROID_get_native_client_buffer +#define EGL_ANDROID_get_native_client_buffer 1 +struct AHardwareBuffer; +typedef EGLClientBuffer (EGLAPIENTRYP PFNEGLGETNATIVECLIENTBUFFERANDROIDPROC) (const struct AHardwareBuffer *buffer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLClientBuffer EGLAPIENTRY eglGetNativeClientBufferANDROID (const struct AHardwareBuffer *buffer); +#endif +#endif /* EGL_ANDROID_get_native_client_buffer */ + +#ifndef EGL_ANDROID_image_native_buffer +#define EGL_ANDROID_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_ANDROID 0x3140 +#endif /* EGL_ANDROID_image_native_buffer */ + +#ifndef EGL_ANDROID_native_fence_sync +#define EGL_ANDROID_native_fence_sync 1 +#define EGL_SYNC_NATIVE_FENCE_ANDROID 0x3144 +#define EGL_SYNC_NATIVE_FENCE_FD_ANDROID 0x3145 +#define EGL_SYNC_NATIVE_FENCE_SIGNALED_ANDROID 0x3146 +#define EGL_NO_NATIVE_FENCE_FD_ANDROID -1 +typedef EGLint (EGLAPIENTRYP PFNEGLDUPNATIVEFENCEFDANDROIDPROC) (EGLDisplay dpy, EGLSyncKHR sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLint EGLAPIENTRY eglDupNativeFenceFDANDROID (EGLDisplay dpy, EGLSyncKHR sync); +#endif +#endif /* EGL_ANDROID_native_fence_sync */ + +#ifndef EGL_ANDROID_presentation_time +#define EGL_ANDROID_presentation_time 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPRESENTATIONTIMEANDROIDPROC) (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPresentationTimeANDROID (EGLDisplay dpy, EGLSurface surface, EGLnsecsANDROID time); +#endif +#endif /* EGL_ANDROID_presentation_time */ + +#ifndef EGL_ANDROID_recordable +#define EGL_ANDROID_recordable 1 +#define EGL_RECORDABLE_ANDROID 0x3142 +#endif /* EGL_ANDROID_recordable */ + +#ifndef EGL_ANGLE_d3d_share_handle_client_buffer +#define EGL_ANGLE_d3d_share_handle_client_buffer 1 +#define EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE 0x3200 +#endif /* EGL_ANGLE_d3d_share_handle_client_buffer */ + +#ifndef EGL_ANGLE_device_d3d +#define EGL_ANGLE_device_d3d 1 +#define EGL_D3D9_DEVICE_ANGLE 0x33A0 +#define EGL_D3D11_DEVICE_ANGLE 0x33A1 +#endif /* EGL_ANGLE_device_d3d */ + +#ifndef EGL_ANGLE_query_surface_pointer +#define EGL_ANGLE_query_surface_pointer 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSURFACEPOINTERANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurfacePointerANGLE (EGLDisplay dpy, EGLSurface surface, EGLint attribute, void **value); +#endif +#endif /* EGL_ANGLE_query_surface_pointer */ + +#ifndef EGL_ANGLE_surface_d3d_texture_2d_share_handle +#define EGL_ANGLE_surface_d3d_texture_2d_share_handle 1 +#endif /* EGL_ANGLE_surface_d3d_texture_2d_share_handle */ + +#ifndef EGL_ANGLE_sync_control_rate +#define EGL_ANGLE_sync_control_rate 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETMSCRATEANGLEPROC) (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetMscRateANGLE (EGLDisplay dpy, EGLSurface surface, EGLint *numerator, EGLint *denominator); +#endif +#endif /* EGL_ANGLE_sync_control_rate */ + +#ifndef EGL_ANGLE_window_fixed_size +#define EGL_ANGLE_window_fixed_size 1 +#define EGL_FIXED_SIZE_ANGLE 0x3201 +#endif /* EGL_ANGLE_window_fixed_size */ + +#ifndef EGL_ARM_image_format +#define EGL_ARM_image_format 1 +#define EGL_COLOR_COMPONENT_TYPE_UNSIGNED_INTEGER_ARM 0x3287 +#define EGL_COLOR_COMPONENT_TYPE_INTEGER_ARM 0x3288 +#endif /* EGL_ARM_image_format */ + +#ifndef EGL_ARM_implicit_external_sync +#define EGL_ARM_implicit_external_sync 1 +#define EGL_SYNC_PRIOR_COMMANDS_IMPLICIT_EXTERNAL_ARM 0x328A +#endif /* EGL_ARM_implicit_external_sync */ + +#ifndef EGL_ARM_pixmap_multisample_discard +#define EGL_ARM_pixmap_multisample_discard 1 +#define EGL_DISCARD_SAMPLES_ARM 0x3286 +#endif /* EGL_ARM_pixmap_multisample_discard */ + +#ifndef EGL_EXT_bind_to_front +#define EGL_EXT_bind_to_front 1 +#define EGL_FRONT_BUFFER_EXT 0x3464 +#endif /* EGL_EXT_bind_to_front */ + +#ifndef EGL_EXT_buffer_age +#define EGL_EXT_buffer_age 1 +#define EGL_BUFFER_AGE_EXT 0x313D +#endif /* EGL_EXT_buffer_age */ + +#ifndef EGL_EXT_client_extensions +#define EGL_EXT_client_extensions 1 +#endif /* EGL_EXT_client_extensions */ + +#ifndef EGL_EXT_client_sync +#define EGL_EXT_client_sync 1 +#define EGL_SYNC_CLIENT_EXT 0x3364 +#define EGL_SYNC_CLIENT_SIGNAL_EXT 0x3365 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCLIENTSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglClientSignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_EXT_client_sync */ + +#ifndef EGL_EXT_compositor +#define EGL_EXT_compositor 1 +#define EGL_PRIMARY_COMPOSITOR_CONTEXT_EXT 0x3460 +#define EGL_EXTERNAL_REF_ID_EXT 0x3461 +#define EGL_COMPOSITOR_DROP_NEWEST_FRAME_EXT 0x3462 +#define EGL_COMPOSITOR_KEEP_NEWEST_FRAME_EXT 0x3463 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTLISTEXTPROC) (const EGLint *external_ref_ids, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETCONTEXTATTRIBUTESEXTPROC) (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWLISTEXTPROC) (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETWINDOWATTRIBUTESEXTPROC) (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORBINDTEXWINDOWEXTPROC) (EGLint external_win_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSETSIZEEXTPROC) (EGLint external_win_id, EGLint width, EGLint height); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLCOMPOSITORSWAPPOLICYEXTPROC) (EGLint external_win_id, EGLint policy); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextListEXT (const EGLint *external_ref_ids, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetContextAttributesEXT (EGLint external_ref_id, const EGLint *context_attributes, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowListEXT (EGLint external_ref_id, const EGLint *external_win_ids, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetWindowAttributesEXT (EGLint external_win_id, const EGLint *window_attributes, EGLint num_entries); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorBindTexWindowEXT (EGLint external_win_id); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSetSizeEXT (EGLint external_win_id, EGLint width, EGLint height); +EGLAPI EGLBoolean EGLAPIENTRY eglCompositorSwapPolicyEXT (EGLint external_win_id, EGLint policy); +#endif +#endif /* EGL_EXT_compositor */ + +#ifndef EGL_EXT_config_select_group +#define EGL_EXT_config_select_group 1 +#define EGL_CONFIG_SELECT_GROUP_EXT 0x34C0 +#endif /* EGL_EXT_config_select_group */ + +#ifndef EGL_EXT_create_context_robustness +#define EGL_EXT_create_context_robustness 1 +#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT 0x30BF +#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT 0x3138 +#define EGL_NO_RESET_NOTIFICATION_EXT 0x31BE +#define EGL_LOSE_CONTEXT_ON_RESET_EXT 0x31BF +#endif /* EGL_EXT_create_context_robustness */ + +#ifndef EGL_EXT_device_base +#define EGL_EXT_device_base 1 +typedef void *EGLDeviceEXT; +#define EGL_NO_DEVICE_EXT EGL_CAST(EGLDeviceEXT,0) +#define EGL_BAD_DEVICE_EXT 0x322B +#define EGL_DEVICE_EXT 0x322C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEATTRIBEXTPROC) (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYDEVICESTRINGEXTPROC) (EGLDeviceEXT device, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICESEXTPROC) (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBEXTPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceAttribEXT (EGLDeviceEXT device, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryDeviceStringEXT (EGLDeviceEXT device, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDevicesEXT (EGLint max_devices, EGLDeviceEXT *devices, EGLint *num_devices); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribEXT (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +#endif +#endif /* EGL_EXT_device_base */ + +#ifndef EGL_EXT_device_drm +#define EGL_EXT_device_drm 1 +#define EGL_DRM_DEVICE_FILE_EXT 0x3233 +#define EGL_DRM_MASTER_FD_EXT 0x333C +#endif /* EGL_EXT_device_drm */ + +#ifndef EGL_EXT_device_drm_render_node +#define EGL_EXT_device_drm_render_node 1 +#define EGL_DRM_RENDER_NODE_FILE_EXT 0x3377 +#endif /* EGL_EXT_device_drm_render_node */ + +#ifndef EGL_EXT_device_enumeration +#define EGL_EXT_device_enumeration 1 +#endif /* EGL_EXT_device_enumeration */ + +#ifndef EGL_EXT_device_openwf +#define EGL_EXT_device_openwf 1 +#define EGL_OPENWF_DEVICE_ID_EXT 0x3237 +#define EGL_OPENWF_DEVICE_EXT 0x333D +#endif /* EGL_EXT_device_openwf */ + +#ifndef EGL_EXT_device_persistent_id +#define EGL_EXT_device_persistent_id 1 +#define EGL_DEVICE_UUID_EXT 0x335C +#define EGL_DRIVER_UUID_EXT 0x335D +#define EGL_DRIVER_NAME_EXT 0x335E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDEVICEBINARYEXTPROC) (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDeviceBinaryEXT (EGLDeviceEXT device, EGLint name, EGLint max_size, void *value, EGLint *size); +#endif +#endif /* EGL_EXT_device_persistent_id */ + +#ifndef EGL_EXT_device_query +#define EGL_EXT_device_query 1 +#endif /* EGL_EXT_device_query */ + +#ifndef EGL_EXT_device_query_name +#define EGL_EXT_device_query_name 1 +#define EGL_RENDERER_EXT 0x335F +#endif /* EGL_EXT_device_query_name */ + +#ifndef EGL_EXT_explicit_device +#define EGL_EXT_explicit_device 1 +#endif /* EGL_EXT_explicit_device */ + +#ifndef EGL_EXT_gl_colorspace_bt2020_hlg +#define EGL_EXT_gl_colorspace_bt2020_hlg 1 +#define EGL_GL_COLORSPACE_BT2020_HLG_EXT 0x3540 +#endif /* EGL_EXT_gl_colorspace_bt2020_hlg */ + +#ifndef EGL_EXT_gl_colorspace_bt2020_linear +#define EGL_EXT_gl_colorspace_bt2020_linear 1 +#define EGL_GL_COLORSPACE_BT2020_LINEAR_EXT 0x333F +#endif /* EGL_EXT_gl_colorspace_bt2020_linear */ + +#ifndef EGL_EXT_gl_colorspace_bt2020_pq +#define EGL_EXT_gl_colorspace_bt2020_pq 1 +#define EGL_GL_COLORSPACE_BT2020_PQ_EXT 0x3340 +#endif /* EGL_EXT_gl_colorspace_bt2020_pq */ + +#ifndef EGL_EXT_gl_colorspace_display_p3 +#define EGL_EXT_gl_colorspace_display_p3 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_EXT 0x3363 +#endif /* EGL_EXT_gl_colorspace_display_p3 */ + +#ifndef EGL_EXT_gl_colorspace_display_p3_linear +#define EGL_EXT_gl_colorspace_display_p3_linear 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_LINEAR_EXT 0x3362 +#endif /* EGL_EXT_gl_colorspace_display_p3_linear */ + +#ifndef EGL_EXT_gl_colorspace_display_p3_passthrough +#define EGL_EXT_gl_colorspace_display_p3_passthrough 1 +#define EGL_GL_COLORSPACE_DISPLAY_P3_PASSTHROUGH_EXT 0x3490 +#endif /* EGL_EXT_gl_colorspace_display_p3_passthrough */ + +#ifndef EGL_EXT_gl_colorspace_scrgb +#define EGL_EXT_gl_colorspace_scrgb 1 +#define EGL_GL_COLORSPACE_SCRGB_EXT 0x3351 +#endif /* EGL_EXT_gl_colorspace_scrgb */ + +#ifndef EGL_EXT_gl_colorspace_scrgb_linear +#define EGL_EXT_gl_colorspace_scrgb_linear 1 +#define EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT 0x3350 +#endif /* EGL_EXT_gl_colorspace_scrgb_linear */ + +#ifndef EGL_EXT_image_dma_buf_import +#define EGL_EXT_image_dma_buf_import 1 +#define EGL_LINUX_DMA_BUF_EXT 0x3270 +#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 +#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 +#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 +#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 +#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 +#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 +#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 +#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 +#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 +#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A +#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B +#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C +#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D +#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E +#define EGL_ITU_REC601_EXT 0x327F +#define EGL_ITU_REC709_EXT 0x3280 +#define EGL_ITU_REC2020_EXT 0x3281 +#define EGL_YUV_FULL_RANGE_EXT 0x3282 +#define EGL_YUV_NARROW_RANGE_EXT 0x3283 +#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 +#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 +#endif /* EGL_EXT_image_dma_buf_import */ + +#ifndef EGL_EXT_image_dma_buf_import_modifiers +#define EGL_EXT_image_dma_buf_import_modifiers 1 +#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 +#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 +#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 +#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 +#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 +#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 +#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 +#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 +#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 +#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 +#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC) (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC) (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufFormatsEXT (EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDmaBufModifiersEXT (EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); +#endif +#endif /* EGL_EXT_image_dma_buf_import_modifiers */ + +#ifndef EGL_EXT_image_gl_colorspace +#define EGL_EXT_image_gl_colorspace 1 +#define EGL_GL_COLORSPACE_DEFAULT_EXT 0x314D +#endif /* EGL_EXT_image_gl_colorspace */ + +#ifndef EGL_EXT_image_implicit_sync_control +#define EGL_EXT_image_implicit_sync_control 1 +#define EGL_IMPORT_SYNC_TYPE_EXT 0x3470 +#define EGL_IMPORT_IMPLICIT_SYNC_EXT 0x3471 +#define EGL_IMPORT_EXPLICIT_SYNC_EXT 0x3472 +#endif /* EGL_EXT_image_implicit_sync_control */ + +#ifndef EGL_EXT_multiview_window +#define EGL_EXT_multiview_window 1 +#define EGL_MULTIVIEW_VIEW_COUNT_EXT 0x3134 +#endif /* EGL_EXT_multiview_window */ + +#ifndef EGL_EXT_output_base +#define EGL_EXT_output_base 1 +typedef void *EGLOutputLayerEXT; +typedef void *EGLOutputPortEXT; +#define EGL_NO_OUTPUT_LAYER_EXT EGL_CAST(EGLOutputLayerEXT,0) +#define EGL_NO_OUTPUT_PORT_EXT EGL_CAST(EGLOutputPortEXT,0) +#define EGL_BAD_OUTPUT_LAYER_EXT 0x322D +#define EGL_BAD_OUTPUT_PORT_EXT 0x322E +#define EGL_SWAP_INTERVAL_EXT 0x322F +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTLAYERSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETOUTPUTPORTSEXTPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTLAYERSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTATTRIBEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +typedef const char *(EGLAPIENTRYP PFNEGLQUERYOUTPUTPORTSTRINGEXTPROC) (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputLayersEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputLayerEXT *layers, EGLint max_layers, EGLint *num_layers); +EGLAPI EGLBoolean EGLAPIENTRY eglGetOutputPortsEXT (EGLDisplay dpy, const EGLAttrib *attrib_list, EGLOutputPortEXT *ports, EGLint max_ports, EGLint *num_ports); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputLayerAttribEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputLayerStringEXT (EGLDisplay dpy, EGLOutputLayerEXT layer, EGLint name); +EGLAPI EGLBoolean EGLAPIENTRY eglOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib value); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryOutputPortAttribEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint attribute, EGLAttrib *value); +EGLAPI const char *EGLAPIENTRY eglQueryOutputPortStringEXT (EGLDisplay dpy, EGLOutputPortEXT port, EGLint name); +#endif +#endif /* EGL_EXT_output_base */ + +#ifndef EGL_EXT_output_drm +#define EGL_EXT_output_drm 1 +#define EGL_DRM_CRTC_EXT 0x3234 +#define EGL_DRM_PLANE_EXT 0x3235 +#define EGL_DRM_CONNECTOR_EXT 0x3236 +#endif /* EGL_EXT_output_drm */ + +#ifndef EGL_EXT_output_openwf +#define EGL_EXT_output_openwf 1 +#define EGL_OPENWF_PIPELINE_ID_EXT 0x3238 +#define EGL_OPENWF_PORT_ID_EXT 0x3239 +#endif /* EGL_EXT_output_openwf */ + +#ifndef EGL_EXT_pixel_format_float +#define EGL_EXT_pixel_format_float 1 +#define EGL_COLOR_COMPONENT_TYPE_EXT 0x3339 +#define EGL_COLOR_COMPONENT_TYPE_FIXED_EXT 0x333A +#define EGL_COLOR_COMPONENT_TYPE_FLOAT_EXT 0x333B +#endif /* EGL_EXT_pixel_format_float */ + +#ifndef EGL_EXT_platform_base +#define EGL_EXT_platform_base 1 +typedef EGLDisplay (EGLAPIENTRYP PFNEGLGETPLATFORMDISPLAYEXTPROC) (EGLenum platform, void *native_display, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPLATFORMPIXMAPSURFACEEXTPROC) (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLDisplay EGLAPIENTRY eglGetPlatformDisplayEXT (EGLenum platform, void *native_display, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformWindowSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_window, const EGLint *attrib_list); +EGLAPI EGLSurface EGLAPIENTRY eglCreatePlatformPixmapSurfaceEXT (EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLint *attrib_list); +#endif +#endif /* EGL_EXT_platform_base */ + +#ifndef EGL_EXT_platform_device +#define EGL_EXT_platform_device 1 +#define EGL_PLATFORM_DEVICE_EXT 0x313F +#endif /* EGL_EXT_platform_device */ + +#ifndef EGL_EXT_platform_wayland +#define EGL_EXT_platform_wayland 1 +#define EGL_PLATFORM_WAYLAND_EXT 0x31D8 +#endif /* EGL_EXT_platform_wayland */ + +#ifndef EGL_EXT_platform_x11 +#define EGL_EXT_platform_x11 1 +#define EGL_PLATFORM_X11_EXT 0x31D5 +#define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 +#endif /* EGL_EXT_platform_x11 */ + +#ifndef EGL_EXT_platform_xcb +#define EGL_EXT_platform_xcb 1 +#define EGL_PLATFORM_XCB_EXT 0x31DC +#define EGL_PLATFORM_XCB_SCREEN_EXT 0x31DE +#endif /* EGL_EXT_platform_xcb */ + +#ifndef EGL_EXT_present_opaque +#define EGL_EXT_present_opaque 1 +#define EGL_PRESENT_OPAQUE_EXT 0x31DF +#endif /* EGL_EXT_present_opaque */ + +#ifndef EGL_EXT_protected_content +#define EGL_EXT_protected_content 1 +#define EGL_PROTECTED_CONTENT_EXT 0x32C0 +#endif /* EGL_EXT_protected_content */ + +#ifndef EGL_EXT_protected_surface +#define EGL_EXT_protected_surface 1 +#endif /* EGL_EXT_protected_surface */ + +#ifndef EGL_EXT_query_reset_notification_strategy +#define EGL_EXT_query_reset_notification_strategy 1 +#endif /* EGL_EXT_query_reset_notification_strategy */ + +#ifndef EGL_EXT_stream_consumer_egloutput +#define EGL_EXT_stream_consumer_egloutput 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerOutputEXT (EGLDisplay dpy, EGLStreamKHR stream, EGLOutputLayerEXT layer); +#endif +#endif /* EGL_EXT_stream_consumer_egloutput */ + +#ifndef EGL_EXT_surface_CTA861_3_metadata +#define EGL_EXT_surface_CTA861_3_metadata 1 +#define EGL_CTA861_3_MAX_CONTENT_LIGHT_LEVEL_EXT 0x3360 +#define EGL_CTA861_3_MAX_FRAME_AVERAGE_LEVEL_EXT 0x3361 +#endif /* EGL_EXT_surface_CTA861_3_metadata */ + +#ifndef EGL_EXT_surface_SMPTE2086_metadata +#define EGL_EXT_surface_SMPTE2086_metadata 1 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_RX_EXT 0x3341 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_RY_EXT 0x3342 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_GX_EXT 0x3343 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_GY_EXT 0x3344 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_BX_EXT 0x3345 +#define EGL_SMPTE2086_DISPLAY_PRIMARY_BY_EXT 0x3346 +#define EGL_SMPTE2086_WHITE_POINT_X_EXT 0x3347 +#define EGL_SMPTE2086_WHITE_POINT_Y_EXT 0x3348 +#define EGL_SMPTE2086_MAX_LUMINANCE_EXT 0x3349 +#define EGL_SMPTE2086_MIN_LUMINANCE_EXT 0x334A +#define EGL_METADATA_SCALING_EXT 50000 +#endif /* EGL_EXT_surface_SMPTE2086_metadata */ + +#ifndef EGL_EXT_surface_compression +#define EGL_EXT_surface_compression 1 +#define EGL_SURFACE_COMPRESSION_EXT 0x34B0 +#define EGL_SURFACE_COMPRESSION_PLANE1_EXT 0x328E +#define EGL_SURFACE_COMPRESSION_PLANE2_EXT 0x328F +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x34B1 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x34B2 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x34B4 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x34B5 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x34B6 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x34B7 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x34B8 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x34B9 +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x34BA +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x34BB +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x34BC +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x34BD +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x34BE +#define EGL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x34BF +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSUPPORTEDCOMPRESSIONRATESEXTPROC) (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQuerySupportedCompressionRatesEXT (EGLDisplay dpy, EGLConfig config, const EGLAttrib *attrib_list, EGLint *rates, EGLint rate_size, EGLint *num_rates); +#endif +#endif /* EGL_EXT_surface_compression */ + +#ifndef EGL_EXT_swap_buffers_with_damage +#define EGL_EXT_swap_buffers_with_damage 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC) (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersWithDamageEXT (EGLDisplay dpy, EGLSurface surface, const EGLint *rects, EGLint n_rects); +#endif +#endif /* EGL_EXT_swap_buffers_with_damage */ + +#ifndef EGL_EXT_sync_reuse +#define EGL_EXT_sync_reuse 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNSIGNALSYNCEXTPROC) (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglUnsignalSyncEXT (EGLDisplay dpy, EGLSync sync, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_EXT_sync_reuse */ + +#ifndef EGL_EXT_yuv_surface +#define EGL_EXT_yuv_surface 1 +#define EGL_YUV_ORDER_EXT 0x3301 +#define EGL_YUV_NUMBER_OF_PLANES_EXT 0x3311 +#define EGL_YUV_SUBSAMPLE_EXT 0x3312 +#define EGL_YUV_DEPTH_RANGE_EXT 0x3317 +#define EGL_YUV_CSC_STANDARD_EXT 0x330A +#define EGL_YUV_PLANE_BPP_EXT 0x331A +#define EGL_YUV_BUFFER_EXT 0x3300 +#define EGL_YUV_ORDER_YUV_EXT 0x3302 +#define EGL_YUV_ORDER_YVU_EXT 0x3303 +#define EGL_YUV_ORDER_YUYV_EXT 0x3304 +#define EGL_YUV_ORDER_UYVY_EXT 0x3305 +#define EGL_YUV_ORDER_YVYU_EXT 0x3306 +#define EGL_YUV_ORDER_VYUY_EXT 0x3307 +#define EGL_YUV_ORDER_AYUV_EXT 0x3308 +#define EGL_YUV_SUBSAMPLE_4_2_0_EXT 0x3313 +#define EGL_YUV_SUBSAMPLE_4_2_2_EXT 0x3314 +#define EGL_YUV_SUBSAMPLE_4_4_4_EXT 0x3315 +#define EGL_YUV_DEPTH_RANGE_LIMITED_EXT 0x3318 +#define EGL_YUV_DEPTH_RANGE_FULL_EXT 0x3319 +#define EGL_YUV_CSC_STANDARD_601_EXT 0x330B +#define EGL_YUV_CSC_STANDARD_709_EXT 0x330C +#define EGL_YUV_CSC_STANDARD_2020_EXT 0x330D +#define EGL_YUV_PLANE_BPP_0_EXT 0x331B +#define EGL_YUV_PLANE_BPP_8_EXT 0x331C +#define EGL_YUV_PLANE_BPP_10_EXT 0x331D +#endif /* EGL_EXT_yuv_surface */ + +#ifndef EGL_HI_clientpixmap +#define EGL_HI_clientpixmap 1 +struct EGLClientPixmapHI { + void *pData; + EGLint iWidth; + EGLint iHeight; + EGLint iStride; +}; +#define EGL_CLIENT_PIXMAP_POINTER_HI 0x8F74 +typedef EGLSurface (EGLAPIENTRYP PFNEGLCREATEPIXMAPSURFACEHIPROC) (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurfaceHI (EGLDisplay dpy, EGLConfig config, struct EGLClientPixmapHI *pixmap); +#endif +#endif /* EGL_HI_clientpixmap */ + +#ifndef EGL_HI_colorformats +#define EGL_HI_colorformats 1 +#define EGL_COLOR_FORMAT_HI 0x8F70 +#define EGL_COLOR_RGB_HI 0x8F71 +#define EGL_COLOR_RGBA_HI 0x8F72 +#define EGL_COLOR_ARGB_HI 0x8F73 +#endif /* EGL_HI_colorformats */ + +#ifndef EGL_IMG_context_priority +#define EGL_IMG_context_priority 1 +#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 +#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 +#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 +#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 +#endif /* EGL_IMG_context_priority */ + +#ifndef EGL_IMG_image_plane_attribs +#define EGL_IMG_image_plane_attribs 1 +#define EGL_NATIVE_BUFFER_MULTIPLANE_SEPARATE_IMG 0x3105 +#define EGL_NATIVE_BUFFER_PLANE_OFFSET_IMG 0x3106 +#endif /* EGL_IMG_image_plane_attribs */ + +#ifndef EGL_MESA_drm_image +#define EGL_MESA_drm_image 1 +#define EGL_DRM_BUFFER_FORMAT_MESA 0x31D0 +#define EGL_DRM_BUFFER_USE_MESA 0x31D1 +#define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA 0x31D2 +#define EGL_DRM_BUFFER_MESA 0x31D3 +#define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 +#define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x00000001 +#define EGL_DRM_BUFFER_USE_SHARE_MESA 0x00000002 +#define EGL_DRM_BUFFER_USE_CURSOR_MESA 0x00000004 +typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEDRMIMAGEMESAPROC) (EGLDisplay dpy, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDRMIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLImageKHR EGLAPIENTRY eglCreateDRMImageMESA (EGLDisplay dpy, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDRMImageMESA (EGLDisplay dpy, EGLImageKHR image, EGLint *name, EGLint *handle, EGLint *stride); +#endif +#endif /* EGL_MESA_drm_image */ + +#ifndef EGL_MESA_image_dma_buf_export +#define EGL_MESA_image_dma_buf_export 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC) (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageQueryMESA (EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); +EGLAPI EGLBoolean EGLAPIENTRY eglExportDMABUFImageMESA (EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); +#endif +#endif /* EGL_MESA_image_dma_buf_export */ + +#ifndef EGL_MESA_platform_gbm +#define EGL_MESA_platform_gbm 1 +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif /* EGL_MESA_platform_gbm */ + +#ifndef EGL_MESA_platform_surfaceless +#define EGL_MESA_platform_surfaceless 1 +#define EGL_PLATFORM_SURFACELESS_MESA 0x31DD +#endif /* EGL_MESA_platform_surfaceless */ + +#ifndef EGL_MESA_query_driver +#define EGL_MESA_query_driver 1 +typedef char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERCONFIGPROC) (EGLDisplay dpy); +typedef const char *(EGLAPIENTRYP PFNEGLGETDISPLAYDRIVERNAMEPROC) (EGLDisplay dpy); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI char *EGLAPIENTRY eglGetDisplayDriverConfig (EGLDisplay dpy); +EGLAPI const char *EGLAPIENTRY eglGetDisplayDriverName (EGLDisplay dpy); +#endif +#endif /* EGL_MESA_query_driver */ + +#ifndef EGL_NOK_swap_region +#define EGL_NOK_swap_region 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGIONNOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegionNOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region */ + +#ifndef EGL_NOK_swap_region2 +#define EGL_NOK_swap_region2 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSWAPBUFFERSREGION2NOKPROC) (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffersRegion2NOK (EGLDisplay dpy, EGLSurface surface, EGLint numRects, const EGLint *rects); +#endif +#endif /* EGL_NOK_swap_region2 */ + +#ifndef EGL_NOK_texture_from_pixmap +#define EGL_NOK_texture_from_pixmap 1 +#define EGL_Y_INVERTED_NOK 0x307F +#endif /* EGL_NOK_texture_from_pixmap */ + +#ifndef EGL_NV_3dvision_surface +#define EGL_NV_3dvision_surface 1 +#define EGL_AUTO_STEREO_NV 0x3136 +#endif /* EGL_NV_3dvision_surface */ + +#ifndef EGL_NV_context_priority_realtime +#define EGL_NV_context_priority_realtime 1 +#define EGL_CONTEXT_PRIORITY_REALTIME_NV 0x3357 +#endif /* EGL_NV_context_priority_realtime */ + +#ifndef EGL_NV_coverage_sample +#define EGL_NV_coverage_sample 1 +#define EGL_COVERAGE_BUFFERS_NV 0x30E0 +#define EGL_COVERAGE_SAMPLES_NV 0x30E1 +#endif /* EGL_NV_coverage_sample */ + +#ifndef EGL_NV_coverage_sample_resolve +#define EGL_NV_coverage_sample_resolve 1 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NV 0x3131 +#define EGL_COVERAGE_SAMPLE_RESOLVE_DEFAULT_NV 0x3132 +#define EGL_COVERAGE_SAMPLE_RESOLVE_NONE_NV 0x3133 +#endif /* EGL_NV_coverage_sample_resolve */ + +#ifndef EGL_NV_cuda_event +#define EGL_NV_cuda_event 1 +#define EGL_CUDA_EVENT_HANDLE_NV 0x323B +#define EGL_SYNC_CUDA_EVENT_NV 0x323C +#define EGL_SYNC_CUDA_EVENT_COMPLETE_NV 0x323D +#endif /* EGL_NV_cuda_event */ + +#ifndef EGL_NV_depth_nonlinear +#define EGL_NV_depth_nonlinear 1 +#define EGL_DEPTH_ENCODING_NV 0x30E2 +#define EGL_DEPTH_ENCODING_NONE_NV 0 +#define EGL_DEPTH_ENCODING_NONLINEAR_NV 0x30E3 +#endif /* EGL_NV_depth_nonlinear */ + +#ifndef EGL_NV_device_cuda +#define EGL_NV_device_cuda 1 +#define EGL_CUDA_DEVICE_NV 0x323A +#endif /* EGL_NV_device_cuda */ + +#ifndef EGL_NV_native_query +#define EGL_NV_native_query 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEDISPLAYNVPROC) (EGLDisplay dpy, EGLNativeDisplayType *display_id); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEWINDOWNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYNATIVEPIXMAPNVPROC) (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeDisplayNV (EGLDisplay dpy, EGLNativeDisplayType *display_id); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativeWindowNV (EGLDisplay dpy, EGLSurface surf, EGLNativeWindowType *window); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryNativePixmapNV (EGLDisplay dpy, EGLSurface surf, EGLNativePixmapType *pixmap); +#endif +#endif /* EGL_NV_native_query */ + +#ifndef EGL_NV_post_convert_rounding +#define EGL_NV_post_convert_rounding 1 +#endif /* EGL_NV_post_convert_rounding */ + +#ifndef EGL_NV_post_sub_buffer +#define EGL_NV_post_sub_buffer 1 +#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE +typedef EGLBoolean (EGLAPIENTRYP PFNEGLPOSTSUBBUFFERNVPROC) (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglPostSubBufferNV (EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); +#endif +#endif /* EGL_NV_post_sub_buffer */ + +#ifndef EGL_NV_quadruple_buffer +#define EGL_NV_quadruple_buffer 1 +#define EGL_QUADRUPLE_BUFFER_NV 0x3231 +#endif /* EGL_NV_quadruple_buffer */ + +#ifndef EGL_NV_robustness_video_memory_purge +#define EGL_NV_robustness_video_memory_purge 1 +#define EGL_GENERATE_RESET_ON_VIDEO_MEMORY_PURGE_NV 0x334C +#endif /* EGL_NV_robustness_video_memory_purge */ + +#ifndef EGL_NV_stream_consumer_eglimage +#define EGL_NV_stream_consumer_eglimage 1 +#define EGL_STREAM_CONSUMER_IMAGE_NV 0x3373 +#define EGL_STREAM_IMAGE_ADD_NV 0x3374 +#define EGL_STREAM_IMAGE_REMOVE_NV 0x3375 +#define EGL_STREAM_IMAGE_AVAILABLE_NV 0x3376 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMIMAGECONSUMERCONNECTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list); +typedef EGLint (EGLAPIENTRYP PFNEGLQUERYSTREAMCONSUMEREVENTNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMACQUIREIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMRELEASEIMAGENVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamImageConsumerConnectNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint num_modifiers, const EGLuint64KHR *modifiers, const EGLAttrib *attrib_list); +EGLAPI EGLint EGLAPIENTRY eglQueryStreamConsumerEventNV (EGLDisplay dpy, EGLStreamKHR stream, EGLTime timeout, EGLenum *event, EGLAttrib *aux); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamAcquireImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage *pImage, EGLSync sync); +EGLAPI EGLBoolean EGLAPIENTRY eglStreamReleaseImageNV (EGLDisplay dpy, EGLStreamKHR stream, EGLImage image, EGLSync sync); +#endif +#endif /* EGL_NV_stream_consumer_eglimage */ + +#ifndef EGL_NV_stream_consumer_eglimage_use_scanout_attrib +#define EGL_NV_stream_consumer_eglimage_use_scanout_attrib 1 +#define EGL_STREAM_CONSUMER_IMAGE_USE_SCANOUT_NV 0x3378 +#endif /* EGL_NV_stream_consumer_eglimage_use_scanout_attrib */ + +#ifndef EGL_NV_stream_consumer_gltexture_yuv +#define EGL_NV_stream_consumer_gltexture_yuv 1 +#define EGL_YUV_PLANE0_TEXTURE_UNIT_NV 0x332C +#define EGL_YUV_PLANE1_TEXTURE_UNIT_NV 0x332D +#define EGL_YUV_PLANE2_TEXTURE_UNIT_NV 0x332E +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMERGLTEXTUREEXTERNALATTRIBSNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamConsumerGLTextureExternalAttribsNV (EGLDisplay dpy, EGLStreamKHR stream, const EGLAttrib *attrib_list); +#endif +#endif /* EGL_NV_stream_consumer_gltexture_yuv */ + +#ifndef EGL_NV_stream_cross_display +#define EGL_NV_stream_cross_display 1 +#define EGL_STREAM_CROSS_DISPLAY_NV 0x334E +#endif /* EGL_NV_stream_cross_display */ + +#ifndef EGL_NV_stream_cross_object +#define EGL_NV_stream_cross_object 1 +#define EGL_STREAM_CROSS_OBJECT_NV 0x334D +#endif /* EGL_NV_stream_cross_object */ + +#ifndef EGL_NV_stream_cross_partition +#define EGL_NV_stream_cross_partition 1 +#define EGL_STREAM_CROSS_PARTITION_NV 0x323F +#endif /* EGL_NV_stream_cross_partition */ + +#ifndef EGL_NV_stream_cross_process +#define EGL_NV_stream_cross_process 1 +#define EGL_STREAM_CROSS_PROCESS_NV 0x3245 +#endif /* EGL_NV_stream_cross_process */ + +#ifndef EGL_NV_stream_cross_system +#define EGL_NV_stream_cross_system 1 +#define EGL_STREAM_CROSS_SYSTEM_NV 0x334F +#endif /* EGL_NV_stream_cross_system */ + +#ifndef EGL_NV_stream_dma +#define EGL_NV_stream_dma 1 +#define EGL_STREAM_DMA_NV 0x3371 +#define EGL_STREAM_DMA_SERVER_NV 0x3372 +#endif /* EGL_NV_stream_dma */ + +#ifndef EGL_NV_stream_fifo_next +#define EGL_NV_stream_fifo_next 1 +#define EGL_PENDING_FRAME_NV 0x3329 +#define EGL_STREAM_TIME_PENDING_NV 0x332A +#endif /* EGL_NV_stream_fifo_next */ + +#ifndef EGL_NV_stream_fifo_synchronous +#define EGL_NV_stream_fifo_synchronous 1 +#define EGL_STREAM_FIFO_SYNCHRONOUS_NV 0x3336 +#endif /* EGL_NV_stream_fifo_synchronous */ + +#ifndef EGL_NV_stream_flush +#define EGL_NV_stream_flush 1 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMFLUSHNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglStreamFlushNV (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_NV_stream_flush */ + +#ifndef EGL_NV_stream_frame_limits +#define EGL_NV_stream_frame_limits 1 +#define EGL_PRODUCER_MAX_FRAME_HINT_NV 0x3337 +#define EGL_CONSUMER_MAX_FRAME_HINT_NV 0x3338 +#endif /* EGL_NV_stream_frame_limits */ + +#ifndef EGL_NV_stream_metadata +#define EGL_NV_stream_metadata 1 +#define EGL_MAX_STREAM_METADATA_BLOCKS_NV 0x3250 +#define EGL_MAX_STREAM_METADATA_BLOCK_SIZE_NV 0x3251 +#define EGL_MAX_STREAM_METADATA_TOTAL_SIZE_NV 0x3252 +#define EGL_PRODUCER_METADATA_NV 0x3253 +#define EGL_CONSUMER_METADATA_NV 0x3254 +#define EGL_PENDING_METADATA_NV 0x3328 +#define EGL_METADATA0_SIZE_NV 0x3255 +#define EGL_METADATA1_SIZE_NV 0x3256 +#define EGL_METADATA2_SIZE_NV 0x3257 +#define EGL_METADATA3_SIZE_NV 0x3258 +#define EGL_METADATA0_TYPE_NV 0x3259 +#define EGL_METADATA1_TYPE_NV 0x325A +#define EGL_METADATA2_TYPE_NV 0x325B +#define EGL_METADATA3_TYPE_NV 0x325C +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYDISPLAYATTRIBNVPROC) (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYSTREAMMETADATANVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglQueryDisplayAttribNV (EGLDisplay dpy, EGLint attribute, EGLAttrib *value); +EGLAPI EGLBoolean EGLAPIENTRY eglSetStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLint n, EGLint offset, EGLint size, const void *data); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryStreamMetadataNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum name, EGLint n, EGLint offset, EGLint size, void *data); +#endif +#endif /* EGL_NV_stream_metadata */ + +#ifndef EGL_NV_stream_origin +#define EGL_NV_stream_origin 1 +#define EGL_STREAM_FRAME_ORIGIN_X_NV 0x3366 +#define EGL_STREAM_FRAME_ORIGIN_Y_NV 0x3367 +#define EGL_STREAM_FRAME_MAJOR_AXIS_NV 0x3368 +#define EGL_CONSUMER_AUTO_ORIENTATION_NV 0x3369 +#define EGL_PRODUCER_AUTO_ORIENTATION_NV 0x336A +#define EGL_LEFT_NV 0x336B +#define EGL_RIGHT_NV 0x336C +#define EGL_TOP_NV 0x336D +#define EGL_BOTTOM_NV 0x336E +#define EGL_X_AXIS_NV 0x336F +#define EGL_Y_AXIS_NV 0x3370 +#endif /* EGL_NV_stream_origin */ + +#ifndef EGL_NV_stream_remote +#define EGL_NV_stream_remote 1 +#define EGL_STREAM_STATE_INITIALIZING_NV 0x3240 +#define EGL_STREAM_TYPE_NV 0x3241 +#define EGL_STREAM_PROTOCOL_NV 0x3242 +#define EGL_STREAM_ENDPOINT_NV 0x3243 +#define EGL_STREAM_LOCAL_NV 0x3244 +#define EGL_STREAM_PRODUCER_NV 0x3247 +#define EGL_STREAM_CONSUMER_NV 0x3248 +#define EGL_STREAM_PROTOCOL_FD_NV 0x3246 +#endif /* EGL_NV_stream_remote */ + +#ifndef EGL_NV_stream_reset +#define EGL_NV_stream_reset 1 +#define EGL_SUPPORT_RESET_NV 0x3334 +#define EGL_SUPPORT_REUSE_NV 0x3335 +typedef EGLBoolean (EGLAPIENTRYP PFNEGLRESETSTREAMNVPROC) (EGLDisplay dpy, EGLStreamKHR stream); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglResetStreamNV (EGLDisplay dpy, EGLStreamKHR stream); +#endif +#endif /* EGL_NV_stream_reset */ + +#ifndef EGL_NV_stream_socket +#define EGL_NV_stream_socket 1 +#define EGL_STREAM_PROTOCOL_SOCKET_NV 0x324B +#define EGL_SOCKET_HANDLE_NV 0x324C +#define EGL_SOCKET_TYPE_NV 0x324D +#endif /* EGL_NV_stream_socket */ + +#ifndef EGL_NV_stream_socket_inet +#define EGL_NV_stream_socket_inet 1 +#define EGL_SOCKET_TYPE_INET_NV 0x324F +#endif /* EGL_NV_stream_socket_inet */ + +#ifndef EGL_NV_stream_socket_unix +#define EGL_NV_stream_socket_unix 1 +#define EGL_SOCKET_TYPE_UNIX_NV 0x324E +#endif /* EGL_NV_stream_socket_unix */ + +#ifndef EGL_NV_stream_sync +#define EGL_NV_stream_sync 1 +#define EGL_SYNC_NEW_FRAME_NV 0x321F +typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESTREAMSYNCNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateStreamSyncNV (EGLDisplay dpy, EGLStreamKHR stream, EGLenum type, const EGLint *attrib_list); +#endif +#endif /* EGL_NV_stream_sync */ + +#ifndef EGL_NV_sync +#define EGL_NV_sync 1 +typedef void *EGLSyncNV; +typedef khronos_utime_nanoseconds_t EGLTimeNV; +#ifdef KHRONOS_SUPPORT_INT64 +#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE_NV 0x30E6 +#define EGL_SYNC_STATUS_NV 0x30E7 +#define EGL_SIGNALED_NV 0x30E8 +#define EGL_UNSIGNALED_NV 0x30E9 +#define EGL_SYNC_FLUSH_COMMANDS_BIT_NV 0x0001 +#define EGL_FOREVER_NV 0xFFFFFFFFFFFFFFFFull +#define EGL_ALREADY_SIGNALED_NV 0x30EA +#define EGL_TIMEOUT_EXPIRED_NV 0x30EB +#define EGL_CONDITION_SATISFIED_NV 0x30EC +#define EGL_SYNC_TYPE_NV 0x30ED +#define EGL_SYNC_CONDITION_NV 0x30EE +#define EGL_SYNC_FENCE_NV 0x30EF +#define EGL_NO_SYNC_NV EGL_CAST(EGLSyncNV,0) +typedef EGLSyncNV (EGLAPIENTRYP PFNEGLCREATEFENCESYNCNVPROC) (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCNVPROC) (EGLSyncNV sync); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLFENCENVPROC) (EGLSyncNV sync); +typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCNVPROC) (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCNVPROC) (EGLSyncNV sync, EGLenum mode); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBNVPROC) (EGLSyncNV sync, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLSyncNV EGLAPIENTRY eglCreateFenceSyncNV (EGLDisplay dpy, EGLenum condition, const EGLint *attrib_list); +EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncNV (EGLSyncNV sync); +EGLAPI EGLBoolean EGLAPIENTRY eglFenceNV (EGLSyncNV sync); +EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncNV (EGLSyncNV sync, EGLint flags, EGLTimeNV timeout); +EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncNV (EGLSyncNV sync, EGLenum mode); +EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribNV (EGLSyncNV sync, EGLint attribute, EGLint *value); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_sync */ + +#ifndef EGL_NV_system_time +#define EGL_NV_system_time 1 +typedef khronos_utime_nanoseconds_t EGLuint64NV; +#ifdef KHRONOS_SUPPORT_INT64 +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) (void); +typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC) (void); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV (void); +EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV (void); +#endif +#endif /* KHRONOS_SUPPORT_INT64 */ +#endif /* EGL_NV_system_time */ + +#ifndef EGL_NV_triple_buffer +#define EGL_NV_triple_buffer 1 +#define EGL_TRIPLE_BUFFER_NV 0x3230 +#endif /* EGL_NV_triple_buffer */ + +#ifndef EGL_QNX_image_native_buffer +#define EGL_QNX_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_QNX 0x3551 +#endif /* EGL_QNX_image_native_buffer */ + +#ifndef EGL_QNX_platform_screen +#define EGL_QNX_platform_screen 1 +#define EGL_PLATFORM_SCREEN_QNX 0x3550 +#endif /* EGL_QNX_platform_screen */ + +#ifndef EGL_TIZEN_image_native_buffer +#define EGL_TIZEN_image_native_buffer 1 +#define EGL_NATIVE_BUFFER_TIZEN 0x32A0 +#endif /* EGL_TIZEN_image_native_buffer */ + +#ifndef EGL_TIZEN_image_native_surface +#define EGL_TIZEN_image_native_surface 1 +#define EGL_NATIVE_SURFACE_TIZEN 0x32A1 +#endif /* EGL_TIZEN_image_native_surface */ + +#ifndef EGL_WL_bind_wayland_display +#define EGL_WL_bind_wayland_display 1 +#define PFNEGLBINDWAYLANDDISPLAYWL PFNEGLBINDWAYLANDDISPLAYWLPROC +#define PFNEGLUNBINDWAYLANDDISPLAYWL PFNEGLUNBINDWAYLANDDISPLAYWLPROC +#define PFNEGLQUERYWAYLANDBUFFERWL PFNEGLQUERYWAYLANDBUFFERWLPROC +struct wl_display; +struct wl_resource; +#define EGL_WAYLAND_BUFFER_WL 0x31D5 +#define EGL_WAYLAND_PLANE_WL 0x31D6 +#define EGL_TEXTURE_Y_U_V_WL 0x31D7 +#define EGL_TEXTURE_Y_UV_WL 0x31D8 +#define EGL_TEXTURE_Y_XUXV_WL 0x31D9 +#define EGL_TEXTURE_EXTERNAL_WL 0x31DA +#define EGL_WAYLAND_Y_INVERTED_WL 0x31DB +typedef EGLBoolean (EGLAPIENTRYP PFNEGLBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNBINDWAYLANDDISPLAYWLPROC) (EGLDisplay dpy, struct wl_display *display); +typedef EGLBoolean (EGLAPIENTRYP PFNEGLQUERYWAYLANDBUFFERWLPROC) (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI EGLBoolean EGLAPIENTRY eglBindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); +EGLAPI EGLBoolean EGLAPIENTRY eglUnbindWaylandDisplayWL (EGLDisplay dpy, struct wl_display *display); +EGLAPI EGLBoolean EGLAPIENTRY eglQueryWaylandBufferWL (EGLDisplay dpy, struct wl_resource *buffer, EGLint attribute, EGLint *value); +#endif +#endif /* EGL_WL_bind_wayland_display */ + +#ifndef EGL_WL_create_wayland_buffer_from_image +#define EGL_WL_create_wayland_buffer_from_image 1 +#define PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC +struct wl_buffer; +typedef struct wl_buffer *(EGLAPIENTRYP PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC) (EGLDisplay dpy, EGLImageKHR image); +#ifdef EGL_EGLEXT_PROTOTYPES +EGLAPI struct wl_buffer *EGLAPIENTRY eglCreateWaylandBufferFromImageWL (EGLDisplay dpy, EGLImageKHR image); +#endif +#endif /* EGL_WL_create_wayland_buffer_from_image */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/EGL/eglplatform.h b/contrib/SDL-3.2.8/src/video/khronos/EGL/eglplatform.h new file mode 100644 index 0000000..6786afd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/EGL/eglplatform.h @@ -0,0 +1,175 @@ +#ifndef __eglplatform_h_ +#define __eglplatform_h_ + +/* +** Copyright 2007-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* Platform-specific types and definitions for egl.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * You are encouraged to submit all modifications to the Khronos group so that + * they can be included in future versions of this file. Please submit changes + * by filing an issue or pull request on the public Khronos EGL Registry, at + * https://www.github.com/KhronosGroup/EGL-Registry/ + */ + +#include + +/* Macros used in EGL function prototype declarations. + * + * EGL functions should be prototyped as: + * + * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); + * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); + * + * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h + */ + +#ifndef EGLAPI +#define EGLAPI KHRONOS_APICALL +#endif + +#ifndef EGLAPIENTRY +#define EGLAPIENTRY KHRONOS_APIENTRY +#endif +#define EGLAPIENTRYP EGLAPIENTRY* + +/* The types NativeDisplayType, NativeWindowType, and NativePixmapType + * are aliases of window-system-dependent types, such as X Display * or + * Windows Device Context. They must be defined in platform-specific + * code below. The EGL-prefixed versions of Native*Type are the same + * types, renamed in EGL 1.3 so all types in the API start with "EGL". + * + * Khronos STRONGLY RECOMMENDS that you use the default definitions + * provided below, since these changes affect both binary and source + * portability of applications using EGL running on different EGL + * implementations. + */ + +#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES) + +typedef void *EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include + +typedef HDC EGLNativeDisplayType; +typedef HBITMAP EGLNativePixmapType; +typedef HWND EGLNativeWindowType; + +#elif defined(__QNX__) + +typedef khronos_uintptr_t EGLNativeDisplayType; +typedef struct _screen_pixmap* EGLNativePixmapType; /* screen_pixmap_t */ +typedef struct _screen_window* EGLNativeWindowType; /* screen_window_t */ + +#elif defined(__EMSCRIPTEN__) + +typedef int EGLNativeDisplayType; +typedef int EGLNativePixmapType; +typedef int EGLNativeWindowType; + +#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */ + +typedef int EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(WL_EGL_PLATFORM) + +typedef struct wl_display *EGLNativeDisplayType; +typedef struct wl_egl_pixmap *EGLNativePixmapType; +typedef struct wl_egl_window *EGLNativeWindowType; + +#elif defined(__GBM__) + +typedef struct gbm_device *EGLNativeDisplayType; +typedef struct gbm_bo *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__ANDROID__) || defined(ANDROID) + +struct ANativeWindow; +struct egl_native_pixmap_t; + +typedef void* EGLNativeDisplayType; +typedef struct egl_native_pixmap_t* EGLNativePixmapType; +typedef struct ANativeWindow* EGLNativeWindowType; + +#elif defined(USE_OZONE) + +typedef intptr_t EGLNativeDisplayType; +typedef intptr_t EGLNativePixmapType; +typedef intptr_t EGLNativeWindowType; + +#elif defined(USE_X11) + +/* X11 (tentative) */ +#include +#include + +typedef Display *EGLNativeDisplayType; +typedef Pixmap EGLNativePixmapType; +typedef Window EGLNativeWindowType; + +#elif defined(__unix__) + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#elif defined(__APPLE__) + +typedef int EGLNativeDisplayType; +typedef void *EGLNativePixmapType; +typedef void *EGLNativeWindowType; + +#elif defined(__HAIKU__) + +#include + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#elif defined(__Fuchsia__) + +typedef void *EGLNativeDisplayType; +typedef khronos_uintptr_t EGLNativePixmapType; +typedef khronos_uintptr_t EGLNativeWindowType; + +#else +#error "Platform not recognized" +#endif + +/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ +typedef EGLNativeDisplayType NativeDisplayType; +typedef EGLNativePixmapType NativePixmapType; +typedef EGLNativeWindowType NativeWindowType; + + +/* Define EGLint. This must be a signed integral type large enough to contain + * all legal attribute names and values passed into and out of EGL, whether + * their type is boolean, bitmask, enumerant (symbolic constant), integer, + * handle, or other. While in general a 32-bit integer will suffice, if + * handles are 64 bit types, then EGLint should be defined as a signed 64-bit + * integer type. + */ +typedef khronos_int32_t EGLint; + + +/* C++ / C typecast macros for special EGL handle values */ +#if defined(__cplusplus) +#define EGL_CAST(type, value) (static_cast(value)) +#else +#define EGL_CAST(type, value) ((type) (value)) +#endif + +#endif /* __eglplatform_h */ diff --git a/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2.h b/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2.h new file mode 100644 index 0000000..6be4e36 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2.h @@ -0,0 +1,656 @@ +#ifndef __gles2_gl2_h_ +#define __gles2_gl2_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#include + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20231129 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9] + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +#include +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2ext.h b/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2ext.h new file mode 100644 index 0000000..63b530b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2ext.h @@ -0,0 +1,4101 @@ +#ifndef __gles2_gl2ext_h_ +#define __gles2_gl2ext_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +/* Generated on date 20231129 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9] + * Versions emitted: _nomatch_^ + * Default extensions included: gles2 + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_KHR_blend_equation_advanced +#define GL_KHR_blend_equation_advanced 1 +#define GL_MULTIPLY_KHR 0x9294 +#define GL_SCREEN_KHR 0x9295 +#define GL_OVERLAY_KHR 0x9296 +#define GL_DARKEN_KHR 0x9297 +#define GL_LIGHTEN_KHR 0x9298 +#define GL_COLORDODGE_KHR 0x9299 +#define GL_COLORBURN_KHR 0x929A +#define GL_HARDLIGHT_KHR 0x929B +#define GL_SOFTLIGHT_KHR 0x929C +#define GL_DIFFERENCE_KHR 0x929E +#define GL_EXCLUSION_KHR 0x92A0 +#define GL_HSL_HUE_KHR 0x92AD +#define GL_HSL_SATURATION_KHR 0x92AE +#define GL_HSL_COLOR_KHR 0x92AF +#define GL_HSL_LUMINOSITY_KHR 0x92B0 +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERKHRPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendBarrierKHR (void); +#endif +#endif /* GL_KHR_blend_equation_advanced */ + +#ifndef GL_KHR_blend_equation_advanced_coherent +#define GL_KHR_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_KHR 0x9285 +#endif /* GL_KHR_blend_equation_advanced_coherent */ + +#ifndef GL_KHR_context_flush_control +#define GL_KHR_context_flush_control 1 +#define GL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x82FB +#define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x82FC +#endif /* GL_KHR_context_flush_control */ + +#ifndef GL_KHR_debug +#define GL_KHR_debug 1 +typedef void (GL_APIENTRY *GLDEBUGPROCKHR)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_SAMPLER 0x82E6 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH_KHR 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION_KHR 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM_KHR 0x8245 +#define GL_DEBUG_SOURCE_API_KHR 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM_KHR 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER_KHR 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY_KHR 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION_KHR 0x824A +#define GL_DEBUG_SOURCE_OTHER_KHR 0x824B +#define GL_DEBUG_TYPE_ERROR_KHR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_KHR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_KHR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY_KHR 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE_KHR 0x8250 +#define GL_DEBUG_TYPE_OTHER_KHR 0x8251 +#define GL_DEBUG_TYPE_MARKER_KHR 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP_KHR 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP_KHR 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION_KHR 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH_KHR 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH_KHR 0x826D +#define GL_BUFFER_KHR 0x82E0 +#define GL_SHADER_KHR 0x82E1 +#define GL_PROGRAM_KHR 0x82E2 +#define GL_VERTEX_ARRAY_KHR 0x8074 +#define GL_QUERY_KHR 0x82E3 +#define GL_PROGRAM_PIPELINE_KHR 0x82E4 +#define GL_SAMPLER_KHR 0x82E6 +#define GL_MAX_LABEL_LENGTH_KHR 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH_KHR 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES_KHR 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES_KHR 0x9145 +#define GL_DEBUG_SEVERITY_HIGH_KHR 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM_KHR 0x9147 +#define GL_DEBUG_SEVERITY_LOW_KHR 0x9148 +#define GL_DEBUG_OUTPUT_KHR 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT_KHR 0x00000002 +#define GL_STACK_OVERFLOW_KHR 0x0503 +#define GL_STACK_UNDERFLOW_KHR 0x0504 +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLKHRPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTKHRPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKKHRPROC) (GLDEBUGPROCKHR callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPKHRPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELKHRPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELKHRPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVKHRPROC) (GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDebugMessageControlKHR (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsertKHR (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallbackKHR (GLDEBUGPROCKHR callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLogKHR (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroupKHR (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroupKHR (void); +GL_APICALL void GL_APIENTRY glObjectLabelKHR (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelKHR (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabelKHR (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabelKHR (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointervKHR (GLenum pname, void **params); +#endif +#endif /* GL_KHR_debug */ + +#ifndef GL_KHR_no_error +#define GL_KHR_no_error 1 +#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 +#endif /* GL_KHR_no_error */ + +#ifndef GL_KHR_parallel_shader_compile +#define GL_KHR_parallel_shader_compile 1 +#define GL_MAX_SHADER_COMPILER_THREADS_KHR 0x91B0 +#define GL_COMPLETION_STATUS_KHR 0x91B1 +typedef void (GL_APIENTRYP PFNGLMAXSHADERCOMPILERTHREADSKHRPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMaxShaderCompilerThreadsKHR (GLuint count); +#endif +#endif /* GL_KHR_parallel_shader_compile */ + +#ifndef GL_KHR_robust_buffer_access_behavior +#define GL_KHR_robust_buffer_access_behavior 1 +#endif /* GL_KHR_robust_buffer_access_behavior */ + +#ifndef GL_KHR_robustness +#define GL_KHR_robustness 1 +#define GL_CONTEXT_ROBUST_ACCESS_KHR 0x90F3 +#define GL_LOSE_CONTEXT_ON_RESET_KHR 0x8252 +#define GL_GUILTY_CONTEXT_RESET_KHR 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_KHR 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_KHR 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY_KHR 0x8256 +#define GL_NO_RESET_NOTIFICATION_KHR 0x8261 +#define GL_CONTEXT_LOST_KHR 0x0507 +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSKHRPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVKHRPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusKHR (void); +GL_APICALL void GL_APIENTRY glReadnPixelsKHR (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvKHR (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivKHR (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GL_APICALL void GL_APIENTRY glGetnUniformuivKHR (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +#endif +#endif /* GL_KHR_robustness */ + +#ifndef GL_KHR_shader_subgroup +#define GL_KHR_shader_subgroup 1 +#define GL_SUBGROUP_SIZE_KHR 0x9532 +#define GL_SUBGROUP_SUPPORTED_STAGES_KHR 0x9533 +#define GL_SUBGROUP_SUPPORTED_FEATURES_KHR 0x9534 +#define GL_SUBGROUP_QUAD_ALL_STAGES_KHR 0x9535 +#define GL_SUBGROUP_FEATURE_BASIC_BIT_KHR 0x00000001 +#define GL_SUBGROUP_FEATURE_VOTE_BIT_KHR 0x00000002 +#define GL_SUBGROUP_FEATURE_ARITHMETIC_BIT_KHR 0x00000004 +#define GL_SUBGROUP_FEATURE_BALLOT_BIT_KHR 0x00000008 +#define GL_SUBGROUP_FEATURE_SHUFFLE_BIT_KHR 0x00000010 +#define GL_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT_KHR 0x00000020 +#define GL_SUBGROUP_FEATURE_CLUSTERED_BIT_KHR 0x00000040 +#define GL_SUBGROUP_FEATURE_QUAD_BIT_KHR 0x00000080 +#endif /* GL_KHR_shader_subgroup */ + +#ifndef GL_KHR_texture_compression_astc_hdr +#define GL_KHR_texture_compression_astc_hdr 1 +#define GL_COMPRESSED_RGBA_ASTC_4x4_KHR 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4_KHR 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5_KHR 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5_KHR 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6_KHR 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5_KHR 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6_KHR 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8_KHR 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5_KHR 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6_KHR 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8_KHR 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10_KHR 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10_KHR 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12_KHR 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR 0x93DD +#endif /* GL_KHR_texture_compression_astc_hdr */ + +#ifndef GL_KHR_texture_compression_astc_ldr +#define GL_KHR_texture_compression_astc_ldr 1 +#endif /* GL_KHR_texture_compression_astc_ldr */ + +#ifndef GL_KHR_texture_compression_astc_sliced_3d +#define GL_KHR_texture_compression_astc_sliced_3d 1 +#endif /* GL_KHR_texture_compression_astc_sliced_3d */ + +#ifndef GL_OES_EGL_image +#define GL_OES_EGL_image 1 +typedef void *GLeglImageOES; +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); +GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); +#endif +#endif /* GL_OES_EGL_image */ + +#ifndef GL_OES_EGL_image_external +#define GL_OES_EGL_image_external 1 +#define GL_TEXTURE_EXTERNAL_OES 0x8D65 +#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 +#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 +#define GL_SAMPLER_EXTERNAL_OES 0x8D66 +#endif /* GL_OES_EGL_image_external */ + +#ifndef GL_OES_EGL_image_external_essl3 +#define GL_OES_EGL_image_external_essl3 1 +#endif /* GL_OES_EGL_image_external_essl3 */ + +#ifndef GL_OES_compressed_ETC1_RGB8_sub_texture +#define GL_OES_compressed_ETC1_RGB8_sub_texture 1 +#endif /* GL_OES_compressed_ETC1_RGB8_sub_texture */ + +#ifndef GL_OES_compressed_ETC1_RGB8_texture +#define GL_OES_compressed_ETC1_RGB8_texture 1 +#define GL_ETC1_RGB8_OES 0x8D64 +#endif /* GL_OES_compressed_ETC1_RGB8_texture */ + +#ifndef GL_OES_compressed_paletted_texture +#define GL_OES_compressed_paletted_texture 1 +#define GL_PALETTE4_RGB8_OES 0x8B90 +#define GL_PALETTE4_RGBA8_OES 0x8B91 +#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 +#define GL_PALETTE4_RGBA4_OES 0x8B93 +#define GL_PALETTE4_RGB5_A1_OES 0x8B94 +#define GL_PALETTE8_RGB8_OES 0x8B95 +#define GL_PALETTE8_RGBA8_OES 0x8B96 +#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 +#define GL_PALETTE8_RGBA4_OES 0x8B98 +#define GL_PALETTE8_RGB5_A1_OES 0x8B99 +#endif /* GL_OES_compressed_paletted_texture */ + +#ifndef GL_OES_copy_image +#define GL_OES_copy_image 1 +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAOESPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyImageSubDataOES (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif +#endif /* GL_OES_copy_image */ + +#ifndef GL_OES_depth24 +#define GL_OES_depth24 1 +#define GL_DEPTH_COMPONENT24_OES 0x81A6 +#endif /* GL_OES_depth24 */ + +#ifndef GL_OES_depth32 +#define GL_OES_depth32 1 +#define GL_DEPTH_COMPONENT32_OES 0x81A7 +#endif /* GL_OES_depth32 */ + +#ifndef GL_OES_depth_texture +#define GL_OES_depth_texture 1 +#endif /* GL_OES_depth_texture */ + +#ifndef GL_OES_draw_buffers_indexed +#define GL_OES_draw_buffers_indexed 1 +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +typedef void (GL_APIENTRYP PFNGLENABLEIOESPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIOESPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIOESPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIOESPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIOESPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIOESPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIOESPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIOESPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEnableiOES (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiOES (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationiOES (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparateiOES (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunciOES (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparateiOES (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaskiOES (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediOES (GLenum target, GLuint index); +#endif +#endif /* GL_OES_draw_buffers_indexed */ + +#ifndef GL_OES_draw_elements_base_vertex +#define GL_OES_draw_elements_base_vertex 1 +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXOESPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXOESPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexOES (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexOES (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GL_APICALL void GL_APIENTRY glMultiDrawElementsBaseVertexEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei drawcount, const GLint *basevertex); +#endif +#endif /* GL_OES_draw_elements_base_vertex */ + +#ifndef GL_OES_element_index_uint +#define GL_OES_element_index_uint 1 +#endif /* GL_OES_element_index_uint */ + +#ifndef GL_OES_fbo_render_mipmap +#define GL_OES_fbo_render_mipmap 1 +#endif /* GL_OES_fbo_render_mipmap */ + +#ifndef GL_OES_fragment_precision_high +#define GL_OES_fragment_precision_high 1 +#endif /* GL_OES_fragment_precision_high */ + +#ifndef GL_OES_geometry_point_size +#define GL_OES_geometry_point_size 1 +#endif /* GL_OES_geometry_point_size */ + +#ifndef GL_OES_geometry_shader +#define GL_OES_geometry_shader 1 +#define GL_GEOMETRY_SHADER_OES 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT_OES 0x00000004 +#define GL_GEOMETRY_LINKED_VERTICES_OUT_OES 0x8916 +#define GL_GEOMETRY_LINKED_INPUT_TYPE_OES 0x8917 +#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_OES 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS_OES 0x887F +#define GL_LAYER_PROVOKING_VERTEX_OES 0x825E +#define GL_LINES_ADJACENCY_OES 0x000A +#define GL_LINE_STRIP_ADJACENCY_OES 0x000B +#define GL_TRIANGLES_ADJACENCY_OES 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_OES 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_OES 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_OES 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_OES 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_OES 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_OES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_OES 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_OES 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_OES 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_OES 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_OES 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_OES 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_OES 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION_OES 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_OES 0x8E4E +#define GL_UNDEFINED_VERTEX_OES 0x8260 +#define GL_PRIMITIVES_GENERATED_OES 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS_OES 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS_OES 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_OES 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_OES 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER_OES 0x9309 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREOESPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureOES (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif +#endif /* GL_OES_geometry_shader */ + +#ifndef GL_OES_get_program_binary +#define GL_OES_get_program_binary 1 +#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE +#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLint length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const void *binary, GLint length); +#endif +#endif /* GL_OES_get_program_binary */ + +#ifndef GL_OES_gpu_shader5 +#define GL_OES_gpu_shader5 1 +#endif /* GL_OES_gpu_shader5 */ + +#ifndef GL_OES_mapbuffer +#define GL_OES_mapbuffer 1 +#define GL_WRITE_ONLY_OES 0x88B9 +#define GL_BUFFER_ACCESS_OES 0x88BB +#define GL_BUFFER_MAPPED_OES 0x88BC +#define GL_BUFFER_MAP_POINTER_OES 0x88BD +typedef void *(GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void *GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); +GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, void **params); +#endif +#endif /* GL_OES_mapbuffer */ + +#ifndef GL_OES_packed_depth_stencil +#define GL_OES_packed_depth_stencil 1 +#define GL_DEPTH_STENCIL_OES 0x84F9 +#define GL_UNSIGNED_INT_24_8_OES 0x84FA +#define GL_DEPTH24_STENCIL8_OES 0x88F0 +#endif /* GL_OES_packed_depth_stencil */ + +#ifndef GL_OES_primitive_bounding_box +#define GL_OES_primitive_bounding_box 1 +#define GL_PRIMITIVE_BOUNDING_BOX_OES 0x92BE +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXOESPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxOES (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_OES_primitive_bounding_box */ + +#ifndef GL_OES_required_internalformat +#define GL_OES_required_internalformat 1 +#define GL_ALPHA8_OES 0x803C +#define GL_DEPTH_COMPONENT16_OES 0x81A5 +#define GL_LUMINANCE4_ALPHA4_OES 0x8043 +#define GL_LUMINANCE8_ALPHA8_OES 0x8045 +#define GL_LUMINANCE8_OES 0x8040 +#define GL_RGBA4_OES 0x8056 +#define GL_RGB5_A1_OES 0x8057 +#define GL_RGB565_OES 0x8D62 +#define GL_RGB8_OES 0x8051 +#define GL_RGBA8_OES 0x8058 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB10_A2_EXT 0x8059 +#endif /* GL_OES_required_internalformat */ + +#ifndef GL_OES_rgb8_rgba8 +#define GL_OES_rgb8_rgba8 1 +#endif /* GL_OES_rgb8_rgba8 */ + +#ifndef GL_OES_sample_shading +#define GL_OES_sample_shading 1 +#define GL_SAMPLE_SHADING_OES 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE_OES 0x8C37 +typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGOESPROC) (GLfloat value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMinSampleShadingOES (GLfloat value); +#endif +#endif /* GL_OES_sample_shading */ + +#ifndef GL_OES_sample_variables +#define GL_OES_sample_variables 1 +#endif /* GL_OES_sample_variables */ + +#ifndef GL_OES_shader_image_atomic +#define GL_OES_shader_image_atomic 1 +#endif /* GL_OES_shader_image_atomic */ + +#ifndef GL_OES_shader_io_blocks +#define GL_OES_shader_io_blocks 1 +#endif /* GL_OES_shader_io_blocks */ + +#ifndef GL_OES_shader_multisample_interpolation +#define GL_OES_shader_multisample_interpolation 1 +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET_OES 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS_OES 0x8E5D +#endif /* GL_OES_shader_multisample_interpolation */ + +#ifndef GL_OES_standard_derivatives +#define GL_OES_standard_derivatives 1 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B +#endif /* GL_OES_standard_derivatives */ + +#ifndef GL_OES_stencil1 +#define GL_OES_stencil1 1 +#define GL_STENCIL_INDEX1_OES 0x8D46 +#endif /* GL_OES_stencil1 */ + +#ifndef GL_OES_stencil4 +#define GL_OES_stencil4 1 +#define GL_STENCIL_INDEX4_OES 0x8D47 +#endif /* GL_OES_stencil4 */ + +#ifndef GL_OES_surfaceless_context +#define GL_OES_surfaceless_context 1 +#define GL_FRAMEBUFFER_UNDEFINED_OES 0x8219 +#endif /* GL_OES_surfaceless_context */ + +#ifndef GL_OES_tessellation_point_size +#define GL_OES_tessellation_point_size 1 +#endif /* GL_OES_tessellation_point_size */ + +#ifndef GL_OES_tessellation_shader +#define GL_OES_tessellation_shader 1 +#define GL_PATCHES_OES 0x000E +#define GL_PATCH_VERTICES_OES 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES_OES 0x8E75 +#define GL_TESS_GEN_MODE_OES 0x8E76 +#define GL_TESS_GEN_SPACING_OES 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER_OES 0x8E78 +#define GL_TESS_GEN_POINT_MODE_OES 0x8E79 +#define GL_ISOLINES_OES 0x8E7A +#define GL_QUADS_OES 0x0007 +#define GL_FRACTIONAL_ODD_OES 0x8E7B +#define GL_FRACTIONAL_EVEN_OES 0x8E7C +#define GL_MAX_PATCH_VERTICES_OES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL_OES 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_OES 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_OES 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_OES 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS_OES 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_OES 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_OES 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_OES 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_OES 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_OES 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_OES 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_OES 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_OES 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_OES 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_OES 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_OES 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_OES 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_OES 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_OES 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_OES 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_OES 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED_OES 0x8221 +#define GL_IS_PER_PATCH_OES 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_OES 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_OES 0x9308 +#define GL_TESS_CONTROL_SHADER_OES 0x8E88 +#define GL_TESS_EVALUATION_SHADER_OES 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT_OES 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT_OES 0x00000010 +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIOESPROC) (GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPatchParameteriOES (GLenum pname, GLint value); +#endif +#endif /* GL_OES_tessellation_shader */ + +#ifndef GL_OES_texture_3D +#define GL_OES_texture_3D 1 +#define GL_TEXTURE_WRAP_R_OES 0x8072 +#define GL_TEXTURE_3D_OES 0x806F +#define GL_TEXTURE_BINDING_3D_OES 0x806A +#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 +#define GL_SAMPLER_3D_OES 0x8B5F +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOESPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); +#endif +#endif /* GL_OES_texture_3D */ + +#ifndef GL_OES_texture_border_clamp +#define GL_OES_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_OES 0x1004 +#define GL_CLAMP_TO_BORDER_OES 0x812D +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVOESPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVOESPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVOESPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVOESPROC) (GLuint sampler, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexParameterIivOES (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuivOES (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIivOES (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuivOES (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIivOES (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuivOES (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIivOES (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivOES (GLuint sampler, GLenum pname, GLuint *params); +#endif +#endif /* GL_OES_texture_border_clamp */ + +#ifndef GL_OES_texture_buffer +#define GL_OES_texture_buffer 1 +#define GL_TEXTURE_BUFFER_OES 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING_OES 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_OES 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_OES 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_OES 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_OES 0x919F +#define GL_SAMPLER_BUFFER_OES 0x8DC2 +#define GL_INT_SAMPLER_BUFFER_OES 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_OES 0x8DD8 +#define GL_IMAGE_BUFFER_OES 0x9051 +#define GL_INT_IMAGE_BUFFER_OES 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER_OES 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET_OES 0x919D +#define GL_TEXTURE_BUFFER_SIZE_OES 0x919E +typedef void (GL_APIENTRYP PFNGLTEXBUFFEROESPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEOESPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexBufferOES (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRangeOES (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_OES_texture_buffer */ + +#ifndef GL_OES_texture_compression_astc +#define GL_OES_texture_compression_astc 1 +#define GL_COMPRESSED_RGBA_ASTC_3x3x3_OES 0x93C0 +#define GL_COMPRESSED_RGBA_ASTC_4x3x3_OES 0x93C1 +#define GL_COMPRESSED_RGBA_ASTC_4x4x3_OES 0x93C2 +#define GL_COMPRESSED_RGBA_ASTC_4x4x4_OES 0x93C3 +#define GL_COMPRESSED_RGBA_ASTC_5x4x4_OES 0x93C4 +#define GL_COMPRESSED_RGBA_ASTC_5x5x4_OES 0x93C5 +#define GL_COMPRESSED_RGBA_ASTC_5x5x5_OES 0x93C6 +#define GL_COMPRESSED_RGBA_ASTC_6x5x5_OES 0x93C7 +#define GL_COMPRESSED_RGBA_ASTC_6x6x5_OES 0x93C8 +#define GL_COMPRESSED_RGBA_ASTC_6x6x6_OES 0x93C9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES 0x93E0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES 0x93E1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES 0x93E2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES 0x93E3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES 0x93E4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES 0x93E5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES 0x93E6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES 0x93E7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES 0x93E8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES 0x93E9 +#endif /* GL_OES_texture_compression_astc */ + +#ifndef GL_OES_texture_cube_map_array +#define GL_OES_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_OES 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_OES 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY_OES 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_OES 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_OES 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY_OES 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_OES 0x906A +#endif /* GL_OES_texture_cube_map_array */ + +#ifndef GL_OES_texture_float +#define GL_OES_texture_float 1 +#endif /* GL_OES_texture_float */ + +#ifndef GL_OES_texture_float_linear +#define GL_OES_texture_float_linear 1 +#endif /* GL_OES_texture_float_linear */ + +#ifndef GL_OES_texture_half_float +#define GL_OES_texture_half_float 1 +#define GL_HALF_FLOAT_OES 0x8D61 +#endif /* GL_OES_texture_half_float */ + +#ifndef GL_OES_texture_half_float_linear +#define GL_OES_texture_half_float_linear 1 +#endif /* GL_OES_texture_half_float_linear */ + +#ifndef GL_OES_texture_npot +#define GL_OES_texture_npot 1 +#endif /* GL_OES_texture_npot */ + +#ifndef GL_OES_texture_stencil8 +#define GL_OES_texture_stencil8 1 +#define GL_STENCIL_INDEX_OES 0x1901 +#define GL_STENCIL_INDEX8_OES 0x8D48 +#endif /* GL_OES_texture_stencil8 */ + +#ifndef GL_OES_texture_storage_multisample_2d_array +#define GL_OES_texture_storage_multisample_2d_array 1 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY_OES 0x9102 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY_OES 0x9105 +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY_OES 0x910D +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEOESPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage3DMultisampleOES (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif +#endif /* GL_OES_texture_storage_multisample_2d_array */ + +#ifndef GL_OES_texture_view +#define GL_OES_texture_view 1 +#define GL_TEXTURE_VIEW_MIN_LEVEL_OES 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS_OES 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER_OES 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS_OES 0x82DE +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWOESPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureViewOES (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif +#endif /* GL_OES_texture_view */ + +#ifndef GL_OES_vertex_array_object +#define GL_OES_vertex_array_object 1 +#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); +#endif +#endif /* GL_OES_vertex_array_object */ + +#ifndef GL_OES_vertex_half_float +#define GL_OES_vertex_half_float 1 +#endif /* GL_OES_vertex_half_float */ + +#ifndef GL_OES_vertex_type_10_10_10_2 +#define GL_OES_vertex_type_10_10_10_2 1 +#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 +#define GL_INT_10_10_10_2_OES 0x8DF7 +#endif /* GL_OES_vertex_type_10_10_10_2 */ + +#ifndef GL_OES_viewport_array +#define GL_OES_viewport_array 1 +#define GL_MAX_VIEWPORTS_OES 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS_OES 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE_OES 0x825D +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_OES 0x825F +typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFOESPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVOESPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVOESPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDOESPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVOESPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVOESPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFOESPROC) (GLuint index, GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLGETFLOATI_VOESPROC) (GLenum target, GLuint index, GLfloat *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportArrayvOES (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glViewportIndexedfOES (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GL_APICALL void GL_APIENTRY glViewportIndexedfvOES (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glScissorArrayvOES (GLuint first, GLsizei count, const GLint *v); +GL_APICALL void GL_APIENTRY glScissorIndexedOES (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorIndexedvOES (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glDepthRangeArrayfvOES (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glDepthRangeIndexedfOES (GLuint index, GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glGetFloati_vOES (GLenum target, GLuint index, GLfloat *data); +#endif +#endif /* GL_OES_viewport_array */ + +#ifndef GL_AMD_compressed_3DC_texture +#define GL_AMD_compressed_3DC_texture 1 +#define GL_3DC_X_AMD 0x87F9 +#define GL_3DC_XY_AMD 0x87FA +#endif /* GL_AMD_compressed_3DC_texture */ + +#ifndef GL_AMD_compressed_ATC_texture +#define GL_AMD_compressed_ATC_texture 1 +#define GL_ATC_RGB_AMD 0x8C92 +#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE +#endif /* GL_AMD_compressed_ATC_texture */ + +#ifndef GL_AMD_framebuffer_multisample_advanced +#define GL_AMD_framebuffer_multisample_advanced 1 +#define GL_RENDERBUFFER_STORAGE_SAMPLES_AMD 0x91B2 +#define GL_MAX_COLOR_FRAMEBUFFER_SAMPLES_AMD 0x91B3 +#define GL_MAX_COLOR_FRAMEBUFFER_STORAGE_SAMPLES_AMD 0x91B4 +#define GL_MAX_DEPTH_STENCIL_FRAMEBUFFER_SAMPLES_AMD 0x91B5 +#define GL_NUM_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B6 +#define GL_SUPPORTED_MULTISAMPLE_MODES_AMD 0x91B7 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEADVANCEDAMDPROC) (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAdvancedAMD (GLenum target, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glNamedRenderbufferStorageMultisampleAdvancedAMD (GLuint renderbuffer, GLsizei samples, GLsizei storageSamples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_AMD_framebuffer_multisample_advanced */ + +#ifndef GL_AMD_performance_monitor +#define GL_AMD_performance_monitor 1 +#define GL_COUNTER_TYPE_AMD 0x8BC0 +#define GL_COUNTER_RANGE_AMD 0x8BC1 +#define GL_UNSIGNED_INT64_AMD 0x8BC2 +#define GL_PERCENTAGE_AMD 0x8BC3 +#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 +#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 +#define GL_PERFMON_RESULT_AMD 0x8BC6 +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data); +typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); +typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); +typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); +GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, void *data); +GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); +GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList); +GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); +GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); +#endif +#endif /* GL_AMD_performance_monitor */ + +#ifndef GL_AMD_program_binary_Z400 +#define GL_AMD_program_binary_Z400 1 +#define GL_Z400_BINARY_AMD 0x8740 +#endif /* GL_AMD_program_binary_Z400 */ + +#ifndef GL_ANDROID_extension_pack_es31a +#define GL_ANDROID_extension_pack_es31a 1 +#endif /* GL_ANDROID_extension_pack_es31a */ + +#ifndef GL_ANGLE_depth_texture +#define GL_ANGLE_depth_texture 1 +#endif /* GL_ANGLE_depth_texture */ + +#ifndef GL_ANGLE_framebuffer_blit +#define GL_ANGLE_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_ANGLE_framebuffer_blit */ + +#ifndef GL_ANGLE_framebuffer_multisample +#define GL_ANGLE_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 +#define GL_MAX_SAMPLES_ANGLE 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_ANGLE_framebuffer_multisample */ + +#ifndef GL_ANGLE_instanced_arrays +#define GL_ANGLE_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE 0x88FE +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDANGLEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDANGLEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORANGLEPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedANGLE (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedANGLE (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +GL_APICALL void GL_APIENTRY glVertexAttribDivisorANGLE (GLuint index, GLuint divisor); +#endif +#endif /* GL_ANGLE_instanced_arrays */ + +#ifndef GL_ANGLE_pack_reverse_row_order +#define GL_ANGLE_pack_reverse_row_order 1 +#define GL_PACK_REVERSE_ROW_ORDER_ANGLE 0x93A4 +#endif /* GL_ANGLE_pack_reverse_row_order */ + +#ifndef GL_ANGLE_program_binary +#define GL_ANGLE_program_binary 1 +#define GL_PROGRAM_BINARY_ANGLE 0x93A6 +#endif /* GL_ANGLE_program_binary */ + +#ifndef GL_ANGLE_texture_compression_dxt3 +#define GL_ANGLE_texture_compression_dxt3 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE 0x83F2 +#endif /* GL_ANGLE_texture_compression_dxt3 */ + +#ifndef GL_ANGLE_texture_compression_dxt5 +#define GL_ANGLE_texture_compression_dxt5 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE 0x83F3 +#endif /* GL_ANGLE_texture_compression_dxt5 */ + +#ifndef GL_ANGLE_texture_usage +#define GL_ANGLE_texture_usage 1 +#define GL_TEXTURE_USAGE_ANGLE 0x93A2 +#define GL_FRAMEBUFFER_ATTACHMENT_ANGLE 0x93A3 +#endif /* GL_ANGLE_texture_usage */ + +#ifndef GL_ANGLE_translated_shader_source +#define GL_ANGLE_translated_shader_source 1 +#define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0 +typedef void (GL_APIENTRYP PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetTranslatedShaderSourceANGLE (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +#endif +#endif /* GL_ANGLE_translated_shader_source */ + +#ifndef GL_APPLE_clip_distance +#define GL_APPLE_clip_distance 1 +#define GL_MAX_CLIP_DISTANCES_APPLE 0x0D32 +#define GL_CLIP_DISTANCE0_APPLE 0x3000 +#define GL_CLIP_DISTANCE1_APPLE 0x3001 +#define GL_CLIP_DISTANCE2_APPLE 0x3002 +#define GL_CLIP_DISTANCE3_APPLE 0x3003 +#define GL_CLIP_DISTANCE4_APPLE 0x3004 +#define GL_CLIP_DISTANCE5_APPLE 0x3005 +#define GL_CLIP_DISTANCE6_APPLE 0x3006 +#define GL_CLIP_DISTANCE7_APPLE 0x3007 +#endif /* GL_APPLE_clip_distance */ + +#ifndef GL_APPLE_color_buffer_packed_float +#define GL_APPLE_color_buffer_packed_float 1 +#endif /* GL_APPLE_color_buffer_packed_float */ + +#ifndef GL_APPLE_copy_texture_levels +#define GL_APPLE_copy_texture_levels 1 +typedef void (GL_APIENTRYP PFNGLCOPYTEXTURELEVELSAPPLEPROC) (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyTextureLevelsAPPLE (GLuint destinationTexture, GLuint sourceTexture, GLint sourceBaseLevel, GLsizei sourceLevelCount); +#endif +#endif /* GL_APPLE_copy_texture_levels */ + +#ifndef GL_APPLE_framebuffer_multisample +#define GL_APPLE_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 +#define GL_MAX_SAMPLES_APPLE 0x8D57 +#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); +#endif +#endif /* GL_APPLE_framebuffer_multisample */ + +#ifndef GL_APPLE_rgb_422 +#define GL_APPLE_rgb_422 1 +#define GL_RGB_422_APPLE 0x8A1F +#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA +#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB +#define GL_RGB_RAW_422_APPLE 0x8A51 +#endif /* GL_APPLE_rgb_422 */ + +#ifndef GL_APPLE_sync +#define GL_APPLE_sync 1 +#define GL_SYNC_OBJECT_APPLE 0x8A53 +#define GL_MAX_SERVER_WAIT_TIMEOUT_APPLE 0x9111 +#define GL_OBJECT_TYPE_APPLE 0x9112 +#define GL_SYNC_CONDITION_APPLE 0x9113 +#define GL_SYNC_STATUS_APPLE 0x9114 +#define GL_SYNC_FLAGS_APPLE 0x9115 +#define GL_SYNC_FENCE_APPLE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE_APPLE 0x9117 +#define GL_UNSIGNALED_APPLE 0x9118 +#define GL_SIGNALED_APPLE 0x9119 +#define GL_ALREADY_SIGNALED_APPLE 0x911A +#define GL_TIMEOUT_EXPIRED_APPLE 0x911B +#define GL_CONDITION_SATISFIED_APPLE 0x911C +#define GL_WAIT_FAILED_APPLE 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT_APPLE 0x00000001 +#define GL_TIMEOUT_IGNORED_APPLE 0xFFFFFFFFFFFFFFFFull +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCAPPLEPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCAPPLEPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCAPPLEPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCAPPLEPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VAPPLEPROC) (GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVAPPLEPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLsync GL_APIENTRY glFenceSyncAPPLE (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSyncAPPLE (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSyncAPPLE (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSyncAPPLE (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64vAPPLE (GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetSyncivAPPLE (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +#endif +#endif /* GL_APPLE_sync */ + +#ifndef GL_APPLE_texture_format_BGRA8888 +#define GL_APPLE_texture_format_BGRA8888 1 +#define GL_BGRA_EXT 0x80E1 +#define GL_BGRA8_EXT 0x93A1 +#endif /* GL_APPLE_texture_format_BGRA8888 */ + +#ifndef GL_APPLE_texture_max_level +#define GL_APPLE_texture_max_level 1 +#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D +#endif /* GL_APPLE_texture_max_level */ + +#ifndef GL_APPLE_texture_packed_float +#define GL_APPLE_texture_packed_float 1 +#define GL_UNSIGNED_INT_10F_11F_11F_REV_APPLE 0x8C3B +#define GL_UNSIGNED_INT_5_9_9_9_REV_APPLE 0x8C3E +#define GL_R11F_G11F_B10F_APPLE 0x8C3A +#define GL_RGB9_E5_APPLE 0x8C3D +#endif /* GL_APPLE_texture_packed_float */ + +#ifndef GL_ARM_mali_program_binary +#define GL_ARM_mali_program_binary 1 +#define GL_MALI_PROGRAM_BINARY_ARM 0x8F61 +#endif /* GL_ARM_mali_program_binary */ + +#ifndef GL_ARM_mali_shader_binary +#define GL_ARM_mali_shader_binary 1 +#define GL_MALI_SHADER_BINARY_ARM 0x8F60 +#endif /* GL_ARM_mali_shader_binary */ + +#ifndef GL_ARM_rgba8 +#define GL_ARM_rgba8 1 +#endif /* GL_ARM_rgba8 */ + +#ifndef GL_ARM_shader_core_properties +#define GL_ARM_shader_core_properties 1 +#define GL_SHADER_CORE_COUNT_ARM 0x96F0 +#define GL_SHADER_CORE_ACTIVE_COUNT_ARM 0x96F1 +#define GL_SHADER_CORE_PRESENT_MASK_ARM 0x96F2 +#define GL_SHADER_CORE_MAX_WARP_COUNT_ARM 0x96F3 +#define GL_SHADER_CORE_PIXEL_RATE_ARM 0x96F4 +#define GL_SHADER_CORE_TEXEL_RATE_ARM 0x96F5 +#define GL_SHADER_CORE_FMA_RATE_ARM 0x96F6 +typedef void (GL_APIENTRYP PFNGLMAXACTIVESHADERCORESARMPROC) (GLuint count); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMaxActiveShaderCoresARM (GLuint count); +#endif +#endif /* GL_ARM_shader_core_properties */ + +#ifndef GL_ARM_shader_framebuffer_fetch +#define GL_ARM_shader_framebuffer_fetch 1 +#define GL_FETCH_PER_SAMPLE_ARM 0x8F65 +#define GL_FRAGMENT_SHADER_FRAMEBUFFER_FETCH_MRT_ARM 0x8F66 +#endif /* GL_ARM_shader_framebuffer_fetch */ + +#ifndef GL_ARM_shader_framebuffer_fetch_depth_stencil +#define GL_ARM_shader_framebuffer_fetch_depth_stencil 1 +#endif /* GL_ARM_shader_framebuffer_fetch_depth_stencil */ + +#ifndef GL_ARM_texture_unnormalized_coordinates +#define GL_ARM_texture_unnormalized_coordinates 1 +#define GL_TEXTURE_UNNORMALIZED_COORDINATES_ARM 0x8F6A +#endif /* GL_ARM_texture_unnormalized_coordinates */ + +#ifndef GL_DMP_program_binary +#define GL_DMP_program_binary 1 +#define GL_SMAPHS30_PROGRAM_BINARY_DMP 0x9251 +#define GL_SMAPHS_PROGRAM_BINARY_DMP 0x9252 +#define GL_DMP_PROGRAM_BINARY_DMP 0x9253 +#endif /* GL_DMP_program_binary */ + +#ifndef GL_DMP_shader_binary +#define GL_DMP_shader_binary 1 +#define GL_SHADER_BINARY_DMP 0x9250 +#endif /* GL_DMP_shader_binary */ + +#ifndef GL_EXT_EGL_image_array +#define GL_EXT_EGL_image_array 1 +#endif /* GL_EXT_EGL_image_array */ + +#ifndef GL_EXT_EGL_image_storage +#define GL_EXT_EGL_image_storage 1 +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXSTORAGEEXTPROC) (GLenum target, GLeglImageOES image, const GLint* attrib_list); +typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURESTORAGEEXTPROC) (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEGLImageTargetTexStorageEXT (GLenum target, GLeglImageOES image, const GLint* attrib_list); +GL_APICALL void GL_APIENTRY glEGLImageTargetTextureStorageEXT (GLuint texture, GLeglImageOES image, const GLint* attrib_list); +#endif +#endif /* GL_EXT_EGL_image_storage */ + +#ifndef GL_EXT_EGL_image_storage_compression +#define GL_EXT_EGL_image_storage_compression 1 +#define GL_SURFACE_COMPRESSION_EXT 0x96C0 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_NONE_EXT 0x96C1 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_DEFAULT_EXT 0x96C2 +#endif /* GL_EXT_EGL_image_storage_compression */ + +#ifndef GL_EXT_YUV_target +#define GL_EXT_YUV_target 1 +#define GL_SAMPLER_EXTERNAL_2D_Y2Y_EXT 0x8BE7 +#endif /* GL_EXT_YUV_target */ + +#ifndef GL_EXT_base_instance +#define GL_EXT_base_instance 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedBaseInstanceEXT (GLenum mode, GLint first, GLsizei count, GLsizei instancecount, GLuint baseinstance); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLuint baseinstance); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexBaseInstanceEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex, GLuint baseinstance); +#endif +#endif /* GL_EXT_base_instance */ + +#ifndef GL_EXT_blend_func_extended +#define GL_EXT_blend_func_extended 1 +#define GL_SRC1_COLOR_EXT 0x88F9 +#define GL_SRC1_ALPHA_EXT 0x8589 +#define GL_ONE_MINUS_SRC1_COLOR_EXT 0x88FA +#define GL_ONE_MINUS_SRC1_ALPHA_EXT 0x88FB +#define GL_SRC_ALPHA_SATURATE_EXT 0x0308 +#define GL_LOCATION_INDEX_EXT 0x930F +#define GL_MAX_DUAL_SOURCE_DRAW_BUFFERS_EXT 0x88FC +typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONINDEXEDEXTPROC) (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name); +typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATAINDEXEXTPROC) (GLuint program, const GLchar *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindFragDataLocationIndexedEXT (GLuint program, GLuint colorNumber, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindFragDataLocationEXT (GLuint program, GLuint color, const GLchar *name); +GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocationIndexEXT (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL GLint GL_APIENTRY glGetFragDataIndexEXT (GLuint program, const GLchar *name); +#endif +#endif /* GL_EXT_blend_func_extended */ + +#ifndef GL_EXT_blend_minmax +#define GL_EXT_blend_minmax 1 +#define GL_MIN_EXT 0x8007 +#define GL_MAX_EXT 0x8008 +#endif /* GL_EXT_blend_minmax */ + +#ifndef GL_EXT_buffer_storage +#define GL_EXT_buffer_storage 1 +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_PERSISTENT_BIT_EXT 0x0040 +#define GL_MAP_COHERENT_BIT_EXT 0x0080 +#define GL_DYNAMIC_STORAGE_BIT_EXT 0x0100 +#define GL_CLIENT_STORAGE_BIT_EXT 0x0200 +#define GL_CLIENT_MAPPED_BUFFER_BARRIER_BIT_EXT 0x00004000 +#define GL_BUFFER_IMMUTABLE_STORAGE_EXT 0x821F +#define GL_BUFFER_STORAGE_FLAGS_EXT 0x8220 +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTPROC) (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferStorageEXT (GLenum target, GLsizeiptr size, const void *data, GLbitfield flags); +#endif +#endif /* GL_EXT_buffer_storage */ + +#ifndef GL_EXT_clear_texture +#define GL_EXT_clear_texture 1 +typedef void (GL_APIENTRYP PFNGLCLEARTEXIMAGEEXTPROC) (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +typedef void (GL_APIENTRYP PFNGLCLEARTEXSUBIMAGEEXTPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClearTexImageEXT (GLuint texture, GLint level, GLenum format, GLenum type, const void *data); +GL_APICALL void GL_APIENTRY glClearTexSubImageEXT (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data); +#endif +#endif /* GL_EXT_clear_texture */ + +#ifndef GL_EXT_clip_control +#define GL_EXT_clip_control 1 +#define GL_LOWER_LEFT_EXT 0x8CA1 +#define GL_UPPER_LEFT_EXT 0x8CA2 +#define GL_NEGATIVE_ONE_TO_ONE_EXT 0x935E +#define GL_ZERO_TO_ONE_EXT 0x935F +#define GL_CLIP_ORIGIN_EXT 0x935C +#define GL_CLIP_DEPTH_MODE_EXT 0x935D +typedef void (GL_APIENTRYP PFNGLCLIPCONTROLEXTPROC) (GLenum origin, GLenum depth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glClipControlEXT (GLenum origin, GLenum depth); +#endif +#endif /* GL_EXT_clip_control */ + +#ifndef GL_EXT_clip_cull_distance +#define GL_EXT_clip_cull_distance 1 +#define GL_MAX_CLIP_DISTANCES_EXT 0x0D32 +#define GL_MAX_CULL_DISTANCES_EXT 0x82F9 +#define GL_MAX_COMBINED_CLIP_AND_CULL_DISTANCES_EXT 0x82FA +#define GL_CLIP_DISTANCE0_EXT 0x3000 +#define GL_CLIP_DISTANCE1_EXT 0x3001 +#define GL_CLIP_DISTANCE2_EXT 0x3002 +#define GL_CLIP_DISTANCE3_EXT 0x3003 +#define GL_CLIP_DISTANCE4_EXT 0x3004 +#define GL_CLIP_DISTANCE5_EXT 0x3005 +#define GL_CLIP_DISTANCE6_EXT 0x3006 +#define GL_CLIP_DISTANCE7_EXT 0x3007 +#endif /* GL_EXT_clip_cull_distance */ + +#ifndef GL_EXT_color_buffer_float +#define GL_EXT_color_buffer_float 1 +#endif /* GL_EXT_color_buffer_float */ + +#ifndef GL_EXT_color_buffer_half_float +#define GL_EXT_color_buffer_half_float 1 +#define GL_RGBA16F_EXT 0x881A +#define GL_RGB16F_EXT 0x881B +#define GL_RG16F_EXT 0x822F +#define GL_R16F_EXT 0x822D +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT 0x8211 +#define GL_UNSIGNED_NORMALIZED_EXT 0x8C17 +#endif /* GL_EXT_color_buffer_half_float */ + +#ifndef GL_EXT_conservative_depth +#define GL_EXT_conservative_depth 1 +#endif /* GL_EXT_conservative_depth */ + +#ifndef GL_EXT_copy_image +#define GL_EXT_copy_image 1 +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAEXTPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyImageSubDataEXT (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +#endif +#endif /* GL_EXT_copy_image */ + +#ifndef GL_EXT_debug_label +#define GL_EXT_debug_label 1 +#define GL_PROGRAM_PIPELINE_OBJECT_EXT 0x8A4F +#define GL_PROGRAM_OBJECT_EXT 0x8B40 +#define GL_SHADER_OBJECT_EXT 0x8B48 +#define GL_BUFFER_OBJECT_EXT 0x9151 +#define GL_QUERY_OBJECT_EXT 0x9153 +#define GL_VERTEX_ARRAY_OBJECT_EXT 0x9154 +#define GL_TRANSFORM_FEEDBACK 0x8E22 +typedef void (GL_APIENTRYP PFNGLLABELOBJECTEXTPROC) (GLenum type, GLuint object, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELEXTPROC) (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glLabelObjectEXT (GLenum type, GLuint object, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabelEXT (GLenum type, GLuint object, GLsizei bufSize, GLsizei *length, GLchar *label); +#endif +#endif /* GL_EXT_debug_label */ + +#ifndef GL_EXT_debug_marker +#define GL_EXT_debug_marker 1 +typedef void (GL_APIENTRYP PFNGLINSERTEVENTMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPUSHGROUPMARKEREXTPROC) (GLsizei length, const GLchar *marker); +typedef void (GL_APIENTRYP PFNGLPOPGROUPMARKEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glInsertEventMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPushGroupMarkerEXT (GLsizei length, const GLchar *marker); +GL_APICALL void GL_APIENTRY glPopGroupMarkerEXT (void); +#endif +#endif /* GL_EXT_debug_marker */ + +#ifndef GL_EXT_depth_clamp +#define GL_EXT_depth_clamp 1 +#define GL_DEPTH_CLAMP_EXT 0x864F +#endif /* GL_EXT_depth_clamp */ + +#ifndef GL_EXT_discard_framebuffer +#define GL_EXT_discard_framebuffer 1 +#define GL_COLOR_EXT 0x1800 +#define GL_DEPTH_EXT 0x1801 +#define GL_STENCIL_EXT 0x1802 +typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); +#endif +#endif /* GL_EXT_discard_framebuffer */ + +#ifndef GL_EXT_disjoint_timer_query +#define GL_EXT_disjoint_timer_query 1 +#define GL_QUERY_COUNTER_BITS_EXT 0x8864 +#define GL_CURRENT_QUERY_EXT 0x8865 +#define GL_QUERY_RESULT_EXT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE_EXT 0x8867 +#define GL_TIME_ELAPSED_EXT 0x88BF +#define GL_TIMESTAMP_EXT 0x8E28 +#define GL_GPU_DISJOINT_EXT 0x8FBB +typedef void (GL_APIENTRYP PFNGLGENQUERIESEXTPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESEXTPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYEXTPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYEXTPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYEXTPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLQUERYCOUNTEREXTPROC) (GLuint id, GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTIVEXTPROC) (GLuint id, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVEXTPROC) (GLuint id, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VEXTPROC) (GLenum pname, GLint64 *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenQueriesEXT (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueriesEXT (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQueryEXT (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQueryEXT (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQueryEXT (GLenum target); +GL_APICALL void GL_APIENTRY glQueryCounterEXT (GLuint id, GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectivEXT (GLuint id, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuivEXT (GLuint id, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjecti64vEXT (GLuint id, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectui64vEXT (GLuint id, GLenum pname, GLuint64 *params); +GL_APICALL void GL_APIENTRY glGetInteger64vEXT (GLenum pname, GLint64 *data); +#endif +#endif /* GL_EXT_disjoint_timer_query */ + +#ifndef GL_EXT_draw_buffers +#define GL_EXT_draw_buffers 1 +#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF +#define GL_MAX_DRAW_BUFFERS_EXT 0x8824 +#define GL_DRAW_BUFFER0_EXT 0x8825 +#define GL_DRAW_BUFFER1_EXT 0x8826 +#define GL_DRAW_BUFFER2_EXT 0x8827 +#define GL_DRAW_BUFFER3_EXT 0x8828 +#define GL_DRAW_BUFFER4_EXT 0x8829 +#define GL_DRAW_BUFFER5_EXT 0x882A +#define GL_DRAW_BUFFER6_EXT 0x882B +#define GL_DRAW_BUFFER7_EXT 0x882C +#define GL_DRAW_BUFFER8_EXT 0x882D +#define GL_DRAW_BUFFER9_EXT 0x882E +#define GL_DRAW_BUFFER10_EXT 0x882F +#define GL_DRAW_BUFFER11_EXT 0x8830 +#define GL_DRAW_BUFFER12_EXT 0x8831 +#define GL_DRAW_BUFFER13_EXT 0x8832 +#define GL_DRAW_BUFFER14_EXT 0x8833 +#define GL_DRAW_BUFFER15_EXT 0x8834 +#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 +#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 +#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 +#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 +#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 +#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 +#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 +#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 +#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 +#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 +#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA +#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB +#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC +#define GL_COLOR_ATTACHMENT13_EXT 0x8CED +#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE +#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSEXTPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersEXT (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_EXT_draw_buffers */ + +#ifndef GL_EXT_draw_buffers_indexed +#define GL_EXT_draw_buffers_indexed 1 +typedef void (GL_APIENTRYP PFNGLENABLEIEXTPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIEXTPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIEXTPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIEXTPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIEXTPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIEXTPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIEXTPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glEnableiEXT (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiEXT (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationiEXT (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparateiEXT (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunciEXT (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparateiEXT (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaskiEXT (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediEXT (GLenum target, GLuint index); +#endif +#endif /* GL_EXT_draw_buffers_indexed */ + +#ifndef GL_EXT_draw_elements_base_vertex +#define GL_EXT_draw_elements_base_vertex 1 +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertexEXT (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertexEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +#endif +#endif /* GL_EXT_draw_elements_base_vertex */ + +#ifndef GL_EXT_draw_instanced +#define GL_EXT_draw_instanced 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedEXT (GLenum mode, GLint start, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedEXT (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_EXT_draw_instanced */ + +#ifndef GL_EXT_draw_transform_feedback +#define GL_EXT_draw_transform_feedback 1 +typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKEXTPROC) (GLenum mode, GLuint id); +typedef void (GL_APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDEXTPROC) (GLenum mode, GLuint id, GLsizei instancecount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawTransformFeedbackEXT (GLenum mode, GLuint id); +GL_APICALL void GL_APIENTRY glDrawTransformFeedbackInstancedEXT (GLenum mode, GLuint id, GLsizei instancecount); +#endif +#endif /* GL_EXT_draw_transform_feedback */ + +#ifndef GL_EXT_external_buffer +#define GL_EXT_external_buffer 1 +typedef void *GLeglClientBufferEXT; +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEEXTERNALEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEEXTERNALEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferStorageExternalEXT (GLenum target, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +GL_APICALL void GL_APIENTRY glNamedBufferStorageExternalEXT (GLuint buffer, GLintptr offset, GLsizeiptr size, GLeglClientBufferEXT clientBuffer, GLbitfield flags); +#endif +#endif /* GL_EXT_external_buffer */ + +#ifndef GL_EXT_float_blend +#define GL_EXT_float_blend 1 +#endif /* GL_EXT_float_blend */ + +#ifndef GL_EXT_fragment_shading_rate +#define GL_EXT_fragment_shading_rate 1 +#define GL_SHADING_RATE_1X1_PIXELS_EXT 0x96A6 +#define GL_SHADING_RATE_1X2_PIXELS_EXT 0x96A7 +#define GL_SHADING_RATE_2X1_PIXELS_EXT 0x96A8 +#define GL_SHADING_RATE_2X2_PIXELS_EXT 0x96A9 +#define GL_SHADING_RATE_1X4_PIXELS_EXT 0x96AA +#define GL_SHADING_RATE_4X1_PIXELS_EXT 0x96AB +#define GL_SHADING_RATE_4X2_PIXELS_EXT 0x96AC +#define GL_SHADING_RATE_2X4_PIXELS_EXT 0x96AD +#define GL_SHADING_RATE_4X4_PIXELS_EXT 0x96AE +#define GL_SHADING_RATE_EXT 0x96D0 +#define GL_SHADING_RATE_ATTACHMENT_EXT 0x96D1 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_EXT 0x96D2 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_EXT 0x96D3 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_EXT 0x96D4 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_EXT 0x96D5 +#define GL_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_EXT 0x96D6 +#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D7 +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_WIDTH_EXT 0x96D8 +#define GL_MIN_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96D9 +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_HEIGHT_EXT 0x96DA +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_TEXEL_ASPECT_RATIO_EXT 0x96DB +#define GL_MAX_FRAGMENT_SHADING_RATE_ATTACHMENT_LAYERS_EXT 0x96DC +#define GL_FRAGMENT_SHADING_RATE_WITH_SHADER_DEPTH_STENCIL_WRITES_SUPPORTED_EXT 0x96DD +#define GL_FRAGMENT_SHADING_RATE_WITH_SAMPLE_MASK_SUPPORTED_EXT 0x96DE +#define GL_FRAGMENT_SHADING_RATE_ATTACHMENT_WITH_DEFAULT_FRAMEBUFFER_SUPPORTED_EXT 0x96DF +#define GL_FRAGMENT_SHADING_RATE_NON_TRIVIAL_COMBINERS_SUPPORTED_EXT 0x8F6F +typedef void (GL_APIENTRYP PFNGLGETFRAGMENTSHADINGRATESEXTPROC) (GLsizei samples, GLsizei maxCount, GLsizei *count, GLenum *shadingRates); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEEXTPROC) (GLenum rate); +typedef void (GL_APIENTRYP PFNGLSHADINGRATECOMBINEROPSEXTPROC) (GLenum combinerOp0, GLenum combinerOp1); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSHADINGRATEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetFragmentShadingRatesEXT (GLsizei samples, GLsizei maxCount, GLsizei *count, GLenum *shadingRates); +GL_APICALL void GL_APIENTRY glShadingRateEXT (GLenum rate); +GL_APICALL void GL_APIENTRY glShadingRateCombinerOpsEXT (GLenum combinerOp0, GLenum combinerOp1); +GL_APICALL void GL_APIENTRY glFramebufferShadingRateEXT (GLenum target, GLenum attachment, GLuint texture, GLint baseLayer, GLsizei numLayers, GLsizei texelWidth, GLsizei texelHeight); +#endif +#endif /* GL_EXT_fragment_shading_rate */ + +#ifndef GL_EXT_framebuffer_blit_layers +#define GL_EXT_framebuffer_blit_layers 1 +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERLAYERSEXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERLAYEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint srcLayer, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstLayer, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferLayersEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glBlitFramebufferLayerEXT (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint srcLayer, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLint dstLayer, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_EXT_framebuffer_blit_layers */ + +#ifndef GL_EXT_geometry_point_size +#define GL_EXT_geometry_point_size 1 +#endif /* GL_EXT_geometry_point_size */ + +#ifndef GL_EXT_geometry_shader +#define GL_EXT_geometry_shader 1 +#define GL_GEOMETRY_SHADER_EXT 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT_EXT 0x00000004 +#define GL_GEOMETRY_LINKED_VERTICES_OUT_EXT 0x8916 +#define GL_GEOMETRY_LINKED_INPUT_TYPE_EXT 0x8917 +#define GL_GEOMETRY_LINKED_OUTPUT_TYPE_EXT 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS_EXT 0x887F +#define GL_LAYER_PROVOKING_VERTEX_EXT 0x825E +#define GL_LINES_ADJACENCY_EXT 0x000A +#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B +#define GL_TRIANGLES_ADJACENCY_EXT 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS_EXT 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS_EXT 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS_EXT 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS_EXT 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS_EXT 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS_EXT 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS_EXT 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS_EXT 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D +#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E +#define GL_UNDEFINED_VERTEX_EXT 0x8260 +#define GL_PRIMITIVES_GENERATED_EXT 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS_EXT 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS_EXT 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER_EXT 0x9309 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureEXT (GLenum target, GLenum attachment, GLuint texture, GLint level); +#endif +#endif /* GL_EXT_geometry_shader */ + +#ifndef GL_EXT_gpu_shader5 +#define GL_EXT_gpu_shader5 1 +#endif /* GL_EXT_gpu_shader5 */ + +#ifndef GL_EXT_instanced_arrays +#define GL_EXT_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_EXT 0x88FE +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISOREXTPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorEXT (GLuint index, GLuint divisor); +#endif +#endif /* GL_EXT_instanced_arrays */ + +#ifndef GL_EXT_map_buffer_range +#define GL_EXT_map_buffer_range 1 +#define GL_MAP_READ_BIT_EXT 0x0001 +#define GL_MAP_WRITE_BIT_EXT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT_EXT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT_EXT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT_EXT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT_EXT 0x0020 +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEEXTPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void *GL_APIENTRY glMapBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRangeEXT (GLenum target, GLintptr offset, GLsizeiptr length); +#endif +#endif /* GL_EXT_map_buffer_range */ + +#ifndef GL_EXT_memory_object +#define GL_EXT_memory_object 1 +#define GL_TEXTURE_TILING_EXT 0x9580 +#define GL_DEDICATED_MEMORY_OBJECT_EXT 0x9581 +#define GL_PROTECTED_MEMORY_OBJECT_EXT 0x959B +#define GL_NUM_TILING_TYPES_EXT 0x9582 +#define GL_TILING_TYPES_EXT 0x9583 +#define GL_OPTIMAL_TILING_EXT 0x9584 +#define GL_LINEAR_TILING_EXT 0x9585 +#define GL_NUM_DEVICE_UUIDS_EXT 0x9596 +#define GL_DEVICE_UUID_EXT 0x9597 +#define GL_DRIVER_UUID_EXT 0x9598 +#define GL_UUID_SIZE_EXT 16 +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEVEXTPROC) (GLenum pname, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLGETUNSIGNEDBYTEI_VEXTPROC) (GLenum target, GLuint index, GLubyte *data); +typedef void (GL_APIENTRYP PFNGLDELETEMEMORYOBJECTSEXTPROC) (GLsizei n, const GLuint *memoryObjects); +typedef GLboolean (GL_APIENTRYP PFNGLISMEMORYOBJECTEXTPROC) (GLuint memoryObject); +typedef void (GL_APIENTRYP PFNGLCREATEMEMORYOBJECTSEXTPROC) (GLsizei n, GLuint *memoryObjects); +typedef void (GL_APIENTRYP PFNGLMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTPARAMETERIVEXTPROC) (GLuint memoryObject, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM2DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEMEM3DMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERSTORAGEMEMEXTPROC) (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM2DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DEXTPROC) (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGEMEM3DMULTISAMPLEEXTPROC) (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERSTORAGEMEMEXTPROC) (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetUnsignedBytevEXT (GLenum pname, GLubyte *data); +GL_APICALL void GL_APIENTRY glGetUnsignedBytei_vEXT (GLenum target, GLuint index, GLubyte *data); +GL_APICALL void GL_APIENTRY glDeleteMemoryObjectsEXT (GLsizei n, const GLuint *memoryObjects); +GL_APICALL GLboolean GL_APIENTRY glIsMemoryObjectEXT (GLuint memoryObject); +GL_APICALL void GL_APIENTRY glCreateMemoryObjectsEXT (GLsizei n, GLuint *memoryObjects); +GL_APICALL void GL_APIENTRY glMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glGetMemoryObjectParameterivEXT (GLuint memoryObject, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glTexStorageMem2DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem2DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DEXT (GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTexStorageMem3DMultisampleEXT (GLenum target, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferStorageMemEXT (GLenum target, GLsizeiptr size, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem2DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DEXT (GLuint texture, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureStorageMem3DMultisampleEXT (GLuint texture, GLsizei samples, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferStorageMemEXT (GLuint buffer, GLsizeiptr size, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_EXT_memory_object */ + +#ifndef GL_EXT_memory_object_fd +#define GL_EXT_memory_object_fd 1 +#define GL_HANDLE_TYPE_OPAQUE_FD_EXT 0x9586 +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYFDEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryFdEXT (GLuint memory, GLuint64 size, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_memory_object_fd */ + +#ifndef GL_EXT_memory_object_win32 +#define GL_EXT_memory_object_win32 1 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_EXT 0x9587 +#define GL_HANDLE_TYPE_OPAQUE_WIN32_KMT_EXT 0x9588 +#define GL_DEVICE_LUID_EXT 0x9599 +#define GL_DEVICE_NODE_MASK_EXT 0x959A +#define GL_LUID_SIZE_EXT 8 +#define GL_HANDLE_TYPE_D3D12_TILEPOOL_EXT 0x9589 +#define GL_HANDLE_TYPE_D3D12_RESOURCE_EXT 0x958A +#define GL_HANDLE_TYPE_D3D11_IMAGE_EXT 0x958B +#define GL_HANDLE_TYPE_D3D11_IMAGE_KMT_EXT 0x958C +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32HANDLEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTMEMORYWIN32NAMEEXTPROC) (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportMemoryWin32HandleEXT (GLuint memory, GLuint64 size, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportMemoryWin32NameEXT (GLuint memory, GLuint64 size, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_memory_object_win32 */ + +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum mode, const GLsizei *count, GLenum type, const void *const*indices, GLsizei primcount); +#endif +#endif /* GL_EXT_multi_draw_arrays */ + +#ifndef GL_EXT_multi_draw_indirect +#define GL_EXT_multi_draw_indirect 1 +typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTEXTPROC) (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTEXTPROC) (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glMultiDrawArraysIndirectEXT (GLenum mode, const void *indirect, GLsizei drawcount, GLsizei stride); +GL_APICALL void GL_APIENTRY glMultiDrawElementsIndirectEXT (GLenum mode, GLenum type, const void *indirect, GLsizei drawcount, GLsizei stride); +#endif +#endif /* GL_EXT_multi_draw_indirect */ + +#ifndef GL_EXT_multisampled_compatibility +#define GL_EXT_multisampled_compatibility 1 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#endif /* GL_EXT_multisampled_compatibility */ + +#ifndef GL_EXT_multisampled_render_to_texture +#define GL_EXT_multisampled_render_to_texture 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT 0x8D6C +#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 +#define GL_MAX_SAMPLES_EXT 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleEXT (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleEXT (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +#endif /* GL_EXT_multisampled_render_to_texture */ + +#ifndef GL_EXT_multisampled_render_to_texture2 +#define GL_EXT_multisampled_render_to_texture2 1 +#endif /* GL_EXT_multisampled_render_to_texture2 */ + +#ifndef GL_EXT_multiview_draw_buffers +#define GL_EXT_multiview_draw_buffers 1 +#define GL_COLOR_ATTACHMENT_EXT 0x90F0 +#define GL_MULTIVIEW_EXT 0x90F1 +#define GL_DRAW_BUFFER_EXT 0x0C01 +#define GL_READ_BUFFER_EXT 0x0C02 +#define GL_MAX_MULTIVIEW_BUFFERS_EXT 0x90F2 +typedef void (GL_APIENTRYP PFNGLREADBUFFERINDEXEDEXTPROC) (GLenum src, GLint index); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSINDEXEDEXTPROC) (GLint n, const GLenum *location, const GLint *indices); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VEXTPROC) (GLenum target, GLuint index, GLint *data); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferIndexedEXT (GLenum src, GLint index); +GL_APICALL void GL_APIENTRY glDrawBuffersIndexedEXT (GLint n, const GLenum *location, const GLint *indices); +GL_APICALL void GL_APIENTRY glGetIntegeri_vEXT (GLenum target, GLuint index, GLint *data); +#endif +#endif /* GL_EXT_multiview_draw_buffers */ + +#ifndef GL_EXT_multiview_tessellation_geometry_shader +#define GL_EXT_multiview_tessellation_geometry_shader 1 +#endif /* GL_EXT_multiview_tessellation_geometry_shader */ + +#ifndef GL_EXT_multiview_texture_multisample +#define GL_EXT_multiview_texture_multisample 1 +#endif /* GL_EXT_multiview_texture_multisample */ + +#ifndef GL_EXT_multiview_timer_query +#define GL_EXT_multiview_timer_query 1 +#endif /* GL_EXT_multiview_timer_query */ + +#ifndef GL_EXT_occlusion_query_boolean +#define GL_EXT_occlusion_query_boolean 1 +#define GL_ANY_SAMPLES_PASSED_EXT 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT 0x8D6A +#endif /* GL_EXT_occlusion_query_boolean */ + +#ifndef GL_EXT_polygon_offset_clamp +#define GL_EXT_polygon_offset_clamp 1 +#define GL_POLYGON_OFFSET_CLAMP_EXT 0x8E1B +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETCLAMPEXTPROC) (GLfloat factor, GLfloat units, GLfloat clamp); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPolygonOffsetClampEXT (GLfloat factor, GLfloat units, GLfloat clamp); +#endif +#endif /* GL_EXT_polygon_offset_clamp */ + +#ifndef GL_EXT_post_depth_coverage +#define GL_EXT_post_depth_coverage 1 +#endif /* GL_EXT_post_depth_coverage */ + +#ifndef GL_EXT_primitive_bounding_box +#define GL_EXT_primitive_bounding_box 1 +#define GL_PRIMITIVE_BOUNDING_BOX_EXT 0x92BE +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXEXTPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBoxEXT (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +#endif +#endif /* GL_EXT_primitive_bounding_box */ + +#ifndef GL_EXT_protected_textures +#define GL_EXT_protected_textures 1 +#define GL_CONTEXT_FLAG_PROTECTED_CONTENT_BIT_EXT 0x00000010 +#define GL_TEXTURE_PROTECTED_EXT 0x8BFA +#endif /* GL_EXT_protected_textures */ + +#ifndef GL_EXT_pvrtc_sRGB +#define GL_EXT_pvrtc_sRGB 1 +#define GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT 0x8A54 +#define GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT 0x8A55 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT 0x8A56 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT 0x8A57 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV2_IMG 0x93F0 +#define GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV2_IMG 0x93F1 +#endif /* GL_EXT_pvrtc_sRGB */ + +#ifndef GL_EXT_raster_multisample +#define GL_EXT_raster_multisample 1 +#define GL_RASTER_MULTISAMPLE_EXT 0x9327 +#define GL_RASTER_SAMPLES_EXT 0x9328 +#define GL_MAX_RASTER_SAMPLES_EXT 0x9329 +#define GL_RASTER_FIXED_SAMPLE_LOCATIONS_EXT 0x932A +#define GL_MULTISAMPLE_RASTERIZATION_ALLOWED_EXT 0x932B +#define GL_EFFECTIVE_RASTER_SAMPLES_EXT 0x932C +typedef void (GL_APIENTRYP PFNGLRASTERSAMPLESEXTPROC) (GLuint samples, GLboolean fixedsamplelocations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRasterSamplesEXT (GLuint samples, GLboolean fixedsamplelocations); +#endif +#endif /* GL_EXT_raster_multisample */ + +#ifndef GL_EXT_read_format_bgra +#define GL_EXT_read_format_bgra 1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 +#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 +#endif /* GL_EXT_read_format_bgra */ + +#ifndef GL_EXT_render_snorm +#define GL_EXT_render_snorm 1 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_R16_SNORM_EXT 0x8F98 +#define GL_RG16_SNORM_EXT 0x8F99 +#define GL_RGBA16_SNORM_EXT 0x8F9B +#endif /* GL_EXT_render_snorm */ + +#ifndef GL_EXT_robustness +#define GL_EXT_robustness 1 +#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 +#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 +#define GL_CONTEXT_ROBUST_ACCESS_EXT 0x90F3 +#define GL_RESET_NOTIFICATION_STRATEGY_EXT 0x8256 +#define GL_LOSE_CONTEXT_ON_RESET_EXT 0x8252 +#define GL_NO_RESET_NOTIFICATION_EXT 0x8261 +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSEXTPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSEXTPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVEXTPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatusEXT (void); +GL_APICALL void GL_APIENTRY glReadnPixelsEXT (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfvEXT (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformivEXT (GLuint program, GLint location, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_EXT_robustness */ + +#ifndef GL_EXT_sRGB +#define GL_EXT_sRGB 1 +#define GL_SRGB_EXT 0x8C40 +#define GL_SRGB_ALPHA_EXT 0x8C42 +#define GL_SRGB8_ALPHA8_EXT 0x8C43 +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT 0x8210 +#endif /* GL_EXT_sRGB */ + +#ifndef GL_EXT_sRGB_write_control +#define GL_EXT_sRGB_write_control 1 +#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9 +#endif /* GL_EXT_sRGB_write_control */ + +#ifndef GL_EXT_semaphore +#define GL_EXT_semaphore 1 +#define GL_LAYOUT_GENERAL_EXT 0x958D +#define GL_LAYOUT_COLOR_ATTACHMENT_EXT 0x958E +#define GL_LAYOUT_DEPTH_STENCIL_ATTACHMENT_EXT 0x958F +#define GL_LAYOUT_DEPTH_STENCIL_READ_ONLY_EXT 0x9590 +#define GL_LAYOUT_SHADER_READ_ONLY_EXT 0x9591 +#define GL_LAYOUT_TRANSFER_SRC_EXT 0x9592 +#define GL_LAYOUT_TRANSFER_DST_EXT 0x9593 +#define GL_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_EXT 0x9530 +#define GL_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_EXT 0x9531 +typedef void (GL_APIENTRYP PFNGLGENSEMAPHORESEXTPROC) (GLsizei n, GLuint *semaphores); +typedef void (GL_APIENTRYP PFNGLDELETESEMAPHORESEXTPROC) (GLsizei n, const GLuint *semaphores); +typedef GLboolean (GL_APIENTRYP PFNGLISSEMAPHOREEXTPROC) (GLuint semaphore); +typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, const GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERUI64VEXTPROC) (GLuint semaphore, GLenum pname, GLuint64 *params); +typedef void (GL_APIENTRYP PFNGLWAITSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +typedef void (GL_APIENTRYP PFNGLSIGNALSEMAPHOREEXTPROC) (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenSemaphoresEXT (GLsizei n, GLuint *semaphores); +GL_APICALL void GL_APIENTRY glDeleteSemaphoresEXT (GLsizei n, const GLuint *semaphores); +GL_APICALL GLboolean GL_APIENTRY glIsSemaphoreEXT (GLuint semaphore); +GL_APICALL void GL_APIENTRY glSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, const GLuint64 *params); +GL_APICALL void GL_APIENTRY glGetSemaphoreParameterui64vEXT (GLuint semaphore, GLenum pname, GLuint64 *params); +GL_APICALL void GL_APIENTRY glWaitSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *srcLayouts); +GL_APICALL void GL_APIENTRY glSignalSemaphoreEXT (GLuint semaphore, GLuint numBufferBarriers, const GLuint *buffers, GLuint numTextureBarriers, const GLuint *textures, const GLenum *dstLayouts); +#endif +#endif /* GL_EXT_semaphore */ + +#ifndef GL_EXT_semaphore_fd +#define GL_EXT_semaphore_fd 1 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREFDEXTPROC) (GLuint semaphore, GLenum handleType, GLint fd); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreFdEXT (GLuint semaphore, GLenum handleType, GLint fd); +#endif +#endif /* GL_EXT_semaphore_fd */ + +#ifndef GL_EXT_semaphore_win32 +#define GL_EXT_semaphore_win32 1 +#define GL_HANDLE_TYPE_D3D12_FENCE_EXT 0x9594 +#define GL_D3D12_FENCE_VALUE_EXT 0x9595 +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32HANDLEEXTPROC) (GLuint semaphore, GLenum handleType, void *handle); +typedef void (GL_APIENTRYP PFNGLIMPORTSEMAPHOREWIN32NAMEEXTPROC) (GLuint semaphore, GLenum handleType, const void *name); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32HandleEXT (GLuint semaphore, GLenum handleType, void *handle); +GL_APICALL void GL_APIENTRY glImportSemaphoreWin32NameEXT (GLuint semaphore, GLenum handleType, const void *name); +#endif +#endif /* GL_EXT_semaphore_win32 */ + +#ifndef GL_EXT_separate_depth_stencil +#define GL_EXT_separate_depth_stencil 1 +#endif /* GL_EXT_separate_depth_stencil */ + +#ifndef GL_EXT_separate_shader_objects +#define GL_EXT_separate_shader_objects 1 +#define GL_ACTIVE_PROGRAM_EXT 0x8259 +#define GL_VERTEX_SHADER_BIT_EXT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT_EXT 0x00000002 +#define GL_ALL_SHADER_BITS_EXT 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE_EXT 0x8258 +#define GL_PROGRAM_PIPELINE_BINDING_EXT 0x825A +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMEXTPROC) (GLuint pipeline, GLuint program); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVEXTPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESEXTPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESEXTPROC) (GLsizei n, GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGEXTPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVEXTPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESEXTPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEEXTPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveShaderProgramEXT (GLuint pipeline, GLuint program); +GL_APICALL void GL_APIENTRY glBindProgramPipelineEXT (GLuint pipeline); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramvEXT (GLenum type, GLsizei count, const GLchar *const*strings); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelinesEXT (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelinesEXT (GLsizei n, GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLogEXT (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetProgramPipelineivEXT (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramParameteriEXT (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glProgramUniform1fEXT (GLuint program, GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glProgramUniform1fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform1iEXT (GLuint program, GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glProgramUniform1ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glProgramUniform2fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2iEXT (GLuint program, GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glProgramUniform2ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glProgramUniform3fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glProgramUniform3ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fEXT (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glProgramUniform4fvEXT (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4iEXT (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glProgramUniform4ivEXT (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgramStagesEXT (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgramPipelineEXT (GLuint pipeline); +GL_APICALL void GL_APIENTRY glProgramUniform1uiEXT (GLuint program, GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4uiEXT (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4uivEXT (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_EXT_separate_shader_objects */ + +#ifndef GL_EXT_shader_framebuffer_fetch +#define GL_EXT_shader_framebuffer_fetch 1 +#define GL_FRAGMENT_SHADER_DISCARDS_SAMPLES_EXT 0x8A52 +#endif /* GL_EXT_shader_framebuffer_fetch */ + +#ifndef GL_EXT_shader_framebuffer_fetch_non_coherent +#define GL_EXT_shader_framebuffer_fetch_non_coherent 1 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIEREXTPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierEXT (void); +#endif +#endif /* GL_EXT_shader_framebuffer_fetch_non_coherent */ + +#ifndef GL_EXT_shader_group_vote +#define GL_EXT_shader_group_vote 1 +#endif /* GL_EXT_shader_group_vote */ + +#ifndef GL_EXT_shader_implicit_conversions +#define GL_EXT_shader_implicit_conversions 1 +#endif /* GL_EXT_shader_implicit_conversions */ + +#ifndef GL_EXT_shader_integer_mix +#define GL_EXT_shader_integer_mix 1 +#endif /* GL_EXT_shader_integer_mix */ + +#ifndef GL_EXT_shader_io_blocks +#define GL_EXT_shader_io_blocks 1 +#endif /* GL_EXT_shader_io_blocks */ + +#ifndef GL_EXT_shader_non_constant_global_initializers +#define GL_EXT_shader_non_constant_global_initializers 1 +#endif /* GL_EXT_shader_non_constant_global_initializers */ + +#ifndef GL_EXT_shader_pixel_local_storage +#define GL_EXT_shader_pixel_local_storage 1 +#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_FAST_SIZE_EXT 0x8F63 +#define GL_MAX_SHADER_PIXEL_LOCAL_STORAGE_SIZE_EXT 0x8F67 +#define GL_SHADER_PIXEL_LOCAL_STORAGE_EXT 0x8F64 +#endif /* GL_EXT_shader_pixel_local_storage */ + +#ifndef GL_EXT_shader_pixel_local_storage2 +#define GL_EXT_shader_pixel_local_storage2 1 +#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_FAST_SIZE_EXT 0x9650 +#define GL_MAX_SHADER_COMBINED_LOCAL_STORAGE_SIZE_EXT 0x9651 +#define GL_FRAMEBUFFER_INCOMPLETE_INSUFFICIENT_SHADER_COMBINED_LOCAL_STORAGE_EXT 0x9652 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target, GLsizei size); +typedef GLsizei (GL_APIENTRYP PFNGLGETFRAMEBUFFERPIXELLOCALSTORAGESIZEEXTPROC) (GLuint target); +typedef void (GL_APIENTRYP PFNGLCLEARPIXELLOCALSTORAGEUIEXTPROC) (GLsizei offset, GLsizei n, const GLuint *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferPixelLocalStorageSizeEXT (GLuint target, GLsizei size); +GL_APICALL GLsizei GL_APIENTRY glGetFramebufferPixelLocalStorageSizeEXT (GLuint target); +GL_APICALL void GL_APIENTRY glClearPixelLocalStorageuiEXT (GLsizei offset, GLsizei n, const GLuint *values); +#endif +#endif /* GL_EXT_shader_pixel_local_storage2 */ + +#ifndef GL_EXT_shader_samples_identical +#define GL_EXT_shader_samples_identical 1 +#endif /* GL_EXT_shader_samples_identical */ + +#ifndef GL_EXT_shader_texture_lod +#define GL_EXT_shader_texture_lod 1 +#endif /* GL_EXT_shader_texture_lod */ + +#ifndef GL_EXT_shadow_samplers +#define GL_EXT_shadow_samplers 1 +#define GL_TEXTURE_COMPARE_MODE_EXT 0x884C +#define GL_TEXTURE_COMPARE_FUNC_EXT 0x884D +#define GL_COMPARE_REF_TO_TEXTURE_EXT 0x884E +#define GL_SAMPLER_2D_SHADOW_EXT 0x8B62 +#endif /* GL_EXT_shadow_samplers */ + +#ifndef GL_EXT_sparse_texture +#define GL_EXT_sparse_texture 1 +#define GL_TEXTURE_SPARSE_EXT 0x91A6 +#define GL_VIRTUAL_PAGE_SIZE_INDEX_EXT 0x91A7 +#define GL_NUM_SPARSE_LEVELS_EXT 0x91AA +#define GL_NUM_VIRTUAL_PAGE_SIZES_EXT 0x91A8 +#define GL_VIRTUAL_PAGE_SIZE_X_EXT 0x9195 +#define GL_VIRTUAL_PAGE_SIZE_Y_EXT 0x9196 +#define GL_VIRTUAL_PAGE_SIZE_Z_EXT 0x9197 +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_3D 0x806F +#define GL_MAX_SPARSE_TEXTURE_SIZE_EXT 0x9198 +#define GL_MAX_SPARSE_3D_TEXTURE_SIZE_EXT 0x9199 +#define GL_MAX_SPARSE_ARRAY_TEXTURE_LAYERS_EXT 0x919A +#define GL_SPARSE_TEXTURE_FULL_ARRAY_CUBE_MIPMAPS_EXT 0x91A9 +typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexPageCommitmentEXT (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit); +#endif +#endif /* GL_EXT_sparse_texture */ + +#ifndef GL_EXT_sparse_texture2 +#define GL_EXT_sparse_texture2 1 +#endif /* GL_EXT_sparse_texture2 */ + +#ifndef GL_EXT_tessellation_point_size +#define GL_EXT_tessellation_point_size 1 +#endif /* GL_EXT_tessellation_point_size */ + +#ifndef GL_EXT_tessellation_shader +#define GL_EXT_tessellation_shader 1 +#define GL_PATCHES_EXT 0x000E +#define GL_PATCH_VERTICES_EXT 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES_EXT 0x8E75 +#define GL_TESS_GEN_MODE_EXT 0x8E76 +#define GL_TESS_GEN_SPACING_EXT 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER_EXT 0x8E78 +#define GL_TESS_GEN_POINT_MODE_EXT 0x8E79 +#define GL_ISOLINES_EXT 0x8E7A +#define GL_QUADS_EXT 0x0007 +#define GL_FRACTIONAL_ODD_EXT 0x8E7B +#define GL_FRACTIONAL_EVEN_EXT 0x8E7C +#define GL_MAX_PATCH_VERTICES_EXT 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL_EXT 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS_EXT 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS_EXT 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS_EXT 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS_EXT 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS_EXT 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS_EXT 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS_EXT 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS_EXT 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS_EXT 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS_EXT 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS_EXT 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS_EXT 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS_EXT 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS_EXT 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS_EXT 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS_EXT 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS_EXT 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS_EXT 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS_EXT 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS_EXT 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_IS_PER_PATCH_EXT 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER_EXT 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER_EXT 0x9308 +#define GL_TESS_CONTROL_SHADER_EXT 0x8E88 +#define GL_TESS_EVALUATION_SHADER_EXT 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT_EXT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT_EXT 0x00000010 +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIEXTPROC) (GLenum pname, GLint value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPatchParameteriEXT (GLenum pname, GLint value); +#endif +#endif /* GL_EXT_tessellation_shader */ + +#ifndef GL_EXT_texture_border_clamp +#define GL_EXT_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_EXT 0x1004 +#define GL_CLAMP_TO_BORDER_EXT 0x812D +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVEXTPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVEXTPROC) (GLuint sampler, GLenum pname, GLuint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexParameterIivEXT (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuivEXT (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIivEXT (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuivEXT (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIivEXT (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuivEXT (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIivEXT (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuivEXT (GLuint sampler, GLenum pname, GLuint *params); +#endif +#endif /* GL_EXT_texture_border_clamp */ + +#ifndef GL_EXT_texture_buffer +#define GL_EXT_texture_buffer 1 +#define GL_TEXTURE_BUFFER_EXT 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING_EXT 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT_EXT 0x919F +#define GL_SAMPLER_BUFFER_EXT 0x8DC2 +#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8 +#define GL_IMAGE_BUFFER_EXT 0x9051 +#define GL_INT_IMAGE_BUFFER_EXT 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER_EXT 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET_EXT 0x919D +#define GL_TEXTURE_BUFFER_SIZE_EXT 0x919E +typedef void (GL_APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEEXTPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexBufferEXT (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRangeEXT (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +#endif +#endif /* GL_EXT_texture_buffer */ + +#ifndef GL_EXT_texture_compression_astc_decode_mode +#define GL_EXT_texture_compression_astc_decode_mode 1 +#define GL_TEXTURE_ASTC_DECODE_PRECISION_EXT 0x8F69 +#endif /* GL_EXT_texture_compression_astc_decode_mode */ + +#ifndef GL_EXT_texture_compression_bptc +#define GL_EXT_texture_compression_bptc 1 +#define GL_COMPRESSED_RGBA_BPTC_UNORM_EXT 0x8E8C +#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D +#define GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT 0x8E8E +#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT 0x8E8F +#endif /* GL_EXT_texture_compression_bptc */ + +#ifndef GL_EXT_texture_compression_dxt1 +#define GL_EXT_texture_compression_dxt1 1 +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#endif /* GL_EXT_texture_compression_dxt1 */ + +#ifndef GL_EXT_texture_compression_rgtc +#define GL_EXT_texture_compression_rgtc 1 +#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB +#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC +#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD +#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE +#endif /* GL_EXT_texture_compression_rgtc */ + +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 +#endif /* GL_EXT_texture_compression_s3tc */ + +#ifndef GL_EXT_texture_compression_s3tc_srgb +#define GL_EXT_texture_compression_s3tc_srgb 1 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F +#endif /* GL_EXT_texture_compression_s3tc_srgb */ + +#ifndef GL_EXT_texture_cube_map_array +#define GL_EXT_texture_cube_map_array 1 +#define GL_TEXTURE_CUBE_MAP_ARRAY_EXT 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY_EXT 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW_EXT 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY_EXT 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY_EXT 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY_EXT 0x906A +#endif /* GL_EXT_texture_cube_map_array */ + +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF +#endif /* GL_EXT_texture_filter_anisotropic */ + +#ifndef GL_EXT_texture_filter_minmax +#define GL_EXT_texture_filter_minmax 1 +#define GL_TEXTURE_REDUCTION_MODE_EXT 0x9366 +#define GL_WEIGHTED_AVERAGE_EXT 0x9367 +#endif /* GL_EXT_texture_filter_minmax */ + +#ifndef GL_EXT_texture_format_BGRA8888 +#define GL_EXT_texture_format_BGRA8888 1 +#endif /* GL_EXT_texture_format_BGRA8888 */ + +#ifndef GL_EXT_texture_format_sRGB_override +#define GL_EXT_texture_format_sRGB_override 1 +#define GL_TEXTURE_FORMAT_SRGB_OVERRIDE_EXT 0x8FBF +#endif /* GL_EXT_texture_format_sRGB_override */ + +#ifndef GL_EXT_texture_mirror_clamp_to_edge +#define GL_EXT_texture_mirror_clamp_to_edge 1 +#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743 +#endif /* GL_EXT_texture_mirror_clamp_to_edge */ + +#ifndef GL_EXT_texture_norm16 +#define GL_EXT_texture_norm16 1 +#define GL_R16_EXT 0x822A +#define GL_RG16_EXT 0x822C +#define GL_RGBA16_EXT 0x805B +#define GL_RGB16_EXT 0x8054 +#define GL_RGB16_SNORM_EXT 0x8F9A +#endif /* GL_EXT_texture_norm16 */ + +#ifndef GL_EXT_texture_query_lod +#define GL_EXT_texture_query_lod 1 +#endif /* GL_EXT_texture_query_lod */ + +#ifndef GL_EXT_texture_rg +#define GL_EXT_texture_rg 1 +#define GL_RED_EXT 0x1903 +#define GL_RG_EXT 0x8227 +#define GL_R8_EXT 0x8229 +#define GL_RG8_EXT 0x822B +#endif /* GL_EXT_texture_rg */ + +#ifndef GL_EXT_texture_sRGB_R8 +#define GL_EXT_texture_sRGB_R8 1 +#define GL_SR8_EXT 0x8FBD +#endif /* GL_EXT_texture_sRGB_R8 */ + +#ifndef GL_EXT_texture_sRGB_RG8 +#define GL_EXT_texture_sRGB_RG8 1 +#define GL_SRG8_EXT 0x8FBE +#endif /* GL_EXT_texture_sRGB_RG8 */ + +#ifndef GL_EXT_texture_sRGB_decode +#define GL_EXT_texture_sRGB_decode 1 +#define GL_TEXTURE_SRGB_DECODE_EXT 0x8A48 +#define GL_DECODE_EXT 0x8A49 +#define GL_SKIP_DECODE_EXT 0x8A4A +#endif /* GL_EXT_texture_sRGB_decode */ + +#ifndef GL_EXT_texture_shadow_lod +#define GL_EXT_texture_shadow_lod 1 +#endif /* GL_EXT_texture_shadow_lod */ + +#ifndef GL_EXT_texture_storage +#define GL_EXT_texture_storage 1 +#define GL_TEXTURE_IMMUTABLE_FORMAT_EXT 0x912F +#define GL_ALPHA8_EXT 0x803C +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_RGBA32F_EXT 0x8814 +#define GL_RGB32F_EXT 0x8815 +#define GL_ALPHA32F_EXT 0x8816 +#define GL_LUMINANCE32F_EXT 0x8818 +#define GL_LUMINANCE_ALPHA32F_EXT 0x8819 +#define GL_ALPHA16F_EXT 0x881C +#define GL_LUMINANCE16F_EXT 0x881E +#define GL_LUMINANCE_ALPHA16F_EXT 0x881F +#define GL_R32F_EXT 0x822E +#define GL_RG32F_EXT 0x8230 +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE1DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorage1DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTexStorage2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width); +GL_APICALL void GL_APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +#endif +#endif /* GL_EXT_texture_storage */ + +#ifndef GL_EXT_texture_storage_compression +#define GL_EXT_texture_storage_compression 1 +#define GL_NUM_SURFACE_COMPRESSION_FIXED_RATES_EXT 0x8F6E +#define GL_SURFACE_COMPRESSION_FIXED_RATE_1BPC_EXT 0x96C4 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_2BPC_EXT 0x96C5 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_3BPC_EXT 0x96C6 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_4BPC_EXT 0x96C7 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_5BPC_EXT 0x96C8 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_6BPC_EXT 0x96C9 +#define GL_SURFACE_COMPRESSION_FIXED_RATE_7BPC_EXT 0x96CA +#define GL_SURFACE_COMPRESSION_FIXED_RATE_8BPC_EXT 0x96CB +#define GL_SURFACE_COMPRESSION_FIXED_RATE_9BPC_EXT 0x96CC +#define GL_SURFACE_COMPRESSION_FIXED_RATE_10BPC_EXT 0x96CD +#define GL_SURFACE_COMPRESSION_FIXED_RATE_11BPC_EXT 0x96CE +#define GL_SURFACE_COMPRESSION_FIXED_RATE_12BPC_EXT 0x96CF +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEATTRIBS2DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint* attrib_list); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGEATTRIBS3DEXTPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint* attrib_list); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexStorageAttribs2DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, const GLint* attrib_list); +GL_APICALL void GL_APIENTRY glTexStorageAttribs3DEXT (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, const GLint* attrib_list); +#endif +#endif /* GL_EXT_texture_storage_compression */ + +#ifndef GL_EXT_texture_type_2_10_10_10_REV +#define GL_EXT_texture_type_2_10_10_10_REV 1 +#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 +#endif /* GL_EXT_texture_type_2_10_10_10_REV */ + +#ifndef GL_EXT_texture_view +#define GL_EXT_texture_view 1 +#define GL_TEXTURE_VIEW_MIN_LEVEL_EXT 0x82DB +#define GL_TEXTURE_VIEW_NUM_LEVELS_EXT 0x82DC +#define GL_TEXTURE_VIEW_MIN_LAYER_EXT 0x82DD +#define GL_TEXTURE_VIEW_NUM_LAYERS_EXT 0x82DE +typedef void (GL_APIENTRYP PFNGLTEXTUREVIEWEXTPROC) (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureViewEXT (GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers); +#endif +#endif /* GL_EXT_texture_view */ + +#ifndef GL_EXT_unpack_subimage +#define GL_EXT_unpack_subimage 1 +#define GL_UNPACK_ROW_LENGTH_EXT 0x0CF2 +#define GL_UNPACK_SKIP_ROWS_EXT 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS_EXT 0x0CF4 +#endif /* GL_EXT_unpack_subimage */ + +#ifndef GL_EXT_win32_keyed_mutex +#define GL_EXT_win32_keyed_mutex 1 +typedef GLboolean (GL_APIENTRYP PFNGLACQUIREKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key, GLuint timeout); +typedef GLboolean (GL_APIENTRYP PFNGLRELEASEKEYEDMUTEXWIN32EXTPROC) (GLuint memory, GLuint64 key); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLboolean GL_APIENTRY glAcquireKeyedMutexWin32EXT (GLuint memory, GLuint64 key, GLuint timeout); +GL_APICALL GLboolean GL_APIENTRY glReleaseKeyedMutexWin32EXT (GLuint memory, GLuint64 key); +#endif +#endif /* GL_EXT_win32_keyed_mutex */ + +#ifndef GL_EXT_window_rectangles +#define GL_EXT_window_rectangles 1 +#define GL_INCLUSIVE_EXT 0x8F10 +#define GL_EXCLUSIVE_EXT 0x8F11 +#define GL_WINDOW_RECTANGLE_EXT 0x8F12 +#define GL_WINDOW_RECTANGLE_MODE_EXT 0x8F13 +#define GL_MAX_WINDOW_RECTANGLES_EXT 0x8F14 +#define GL_NUM_WINDOW_RECTANGLES_EXT 0x8F15 +typedef void (GL_APIENTRYP PFNGLWINDOWRECTANGLESEXTPROC) (GLenum mode, GLsizei count, const GLint *box); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glWindowRectanglesEXT (GLenum mode, GLsizei count, const GLint *box); +#endif +#endif /* GL_EXT_window_rectangles */ + +#ifndef GL_FJ_shader_binary_GCCSO +#define GL_FJ_shader_binary_GCCSO 1 +#define GL_GCCSO_SHADER_BINARY_FJ 0x9260 +#endif /* GL_FJ_shader_binary_GCCSO */ + +#ifndef GL_IMG_bindless_texture +#define GL_IMG_bindless_texture 1 +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLEIMGPROC) (GLuint texture); +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLEIMGPROC) (GLuint texture, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64IMGPROC) (GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VIMGPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64IMGPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VIMGPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleIMG (GLuint texture); +GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleIMG (GLuint texture, GLuint sampler); +GL_APICALL void GL_APIENTRY glUniformHandleui64IMG (GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glUniformHandleui64vIMG (GLint location, GLsizei count, const GLuint64 *value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64IMG (GLuint program, GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vIMG (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +#endif +#endif /* GL_IMG_bindless_texture */ + +#ifndef GL_IMG_framebuffer_downsample +#define GL_IMG_framebuffer_downsample 1 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_AND_DOWNSAMPLE_IMG 0x913C +#define GL_NUM_DOWNSAMPLE_SCALES_IMG 0x913D +#define GL_DOWNSAMPLE_SCALES_IMG 0x913E +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SCALE_IMG 0x913F +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERDOWNSAMPLEIMGPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTexture2DDownsampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint xscale, GLint yscale); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayerDownsampleIMG (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer, GLint xscale, GLint yscale); +#endif +#endif /* GL_IMG_framebuffer_downsample */ + +#ifndef GL_IMG_multisampled_render_to_texture +#define GL_IMG_multisampled_render_to_texture 1 +#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 +#define GL_MAX_SAMPLES_IMG 0x9135 +#define GL_TEXTURE_SAMPLES_IMG 0x9136 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMGPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMGPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); +#endif +#endif /* GL_IMG_multisampled_render_to_texture */ + +#ifndef GL_IMG_program_binary +#define GL_IMG_program_binary 1 +#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 +#endif /* GL_IMG_program_binary */ + +#ifndef GL_IMG_read_format +#define GL_IMG_read_format 1 +#define GL_BGRA_IMG 0x80E1 +#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 +#endif /* GL_IMG_read_format */ + +#ifndef GL_IMG_shader_binary +#define GL_IMG_shader_binary 1 +#define GL_SGX_BINARY_IMG 0x8C0A +#endif /* GL_IMG_shader_binary */ + +#ifndef GL_IMG_texture_compression_pvrtc +#define GL_IMG_texture_compression_pvrtc 1 +#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 +#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 +#endif /* GL_IMG_texture_compression_pvrtc */ + +#ifndef GL_IMG_texture_compression_pvrtc2 +#define GL_IMG_texture_compression_pvrtc2 1 +#define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137 +#define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138 +#endif /* GL_IMG_texture_compression_pvrtc2 */ + +#ifndef GL_IMG_texture_filter_cubic +#define GL_IMG_texture_filter_cubic 1 +#define GL_CUBIC_IMG 0x9139 +#define GL_CUBIC_MIPMAP_NEAREST_IMG 0x913A +#define GL_CUBIC_MIPMAP_LINEAR_IMG 0x913B +#endif /* GL_IMG_texture_filter_cubic */ + +#ifndef GL_INTEL_blackhole_render +#define GL_INTEL_blackhole_render 1 +#define GL_BLACKHOLE_RENDER_INTEL 0x83FC +#endif /* GL_INTEL_blackhole_render */ + +#ifndef GL_INTEL_conservative_rasterization +#define GL_INTEL_conservative_rasterization 1 +#define GL_CONSERVATIVE_RASTERIZATION_INTEL 0x83FE +#endif /* GL_INTEL_conservative_rasterization */ + +#ifndef GL_INTEL_framebuffer_CMAA +#define GL_INTEL_framebuffer_CMAA 1 +typedef void (GL_APIENTRYP PFNGLAPPLYFRAMEBUFFERATTACHMENTCMAAINTELPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glApplyFramebufferAttachmentCMAAINTEL (void); +#endif +#endif /* GL_INTEL_framebuffer_CMAA */ + +#ifndef GL_INTEL_performance_query +#define GL_INTEL_performance_query 1 +#define GL_PERFQUERY_SINGLE_CONTEXT_INTEL 0x00000000 +#define GL_PERFQUERY_GLOBAL_CONTEXT_INTEL 0x00000001 +#define GL_PERFQUERY_WAIT_INTEL 0x83FB +#define GL_PERFQUERY_FLUSH_INTEL 0x83FA +#define GL_PERFQUERY_DONOT_FLUSH_INTEL 0x83F9 +#define GL_PERFQUERY_COUNTER_EVENT_INTEL 0x94F0 +#define GL_PERFQUERY_COUNTER_DURATION_NORM_INTEL 0x94F1 +#define GL_PERFQUERY_COUNTER_DURATION_RAW_INTEL 0x94F2 +#define GL_PERFQUERY_COUNTER_THROUGHPUT_INTEL 0x94F3 +#define GL_PERFQUERY_COUNTER_RAW_INTEL 0x94F4 +#define GL_PERFQUERY_COUNTER_TIMESTAMP_INTEL 0x94F5 +#define GL_PERFQUERY_COUNTER_DATA_UINT32_INTEL 0x94F8 +#define GL_PERFQUERY_COUNTER_DATA_UINT64_INTEL 0x94F9 +#define GL_PERFQUERY_COUNTER_DATA_FLOAT_INTEL 0x94FA +#define GL_PERFQUERY_COUNTER_DATA_DOUBLE_INTEL 0x94FB +#define GL_PERFQUERY_COUNTER_DATA_BOOL32_INTEL 0x94FC +#define GL_PERFQUERY_QUERY_NAME_LENGTH_MAX_INTEL 0x94FD +#define GL_PERFQUERY_COUNTER_NAME_LENGTH_MAX_INTEL 0x94FE +#define GL_PERFQUERY_COUNTER_DESC_LENGTH_MAX_INTEL 0x94FF +#define GL_PERFQUERY_GPA_EXTENDED_COUNTERS_INTEL 0x9500 +typedef void (GL_APIENTRYP PFNGLBEGINPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLCREATEPERFQUERYINTELPROC) (GLuint queryId, GLuint *queryHandle); +typedef void (GL_APIENTRYP PFNGLDELETEPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLENDPERFQUERYINTELPROC) (GLuint queryHandle); +typedef void (GL_APIENTRYP PFNGLGETFIRSTPERFQUERYIDINTELPROC) (GLuint *queryId); +typedef void (GL_APIENTRYP PFNGLGETNEXTPERFQUERYIDINTELPROC) (GLuint queryId, GLuint *nextQueryId); +typedef void (GL_APIENTRYP PFNGLGETPERFCOUNTERINFOINTELPROC) (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYDATAINTELPROC) (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYIDBYNAMEINTELPROC) (GLchar *queryName, GLuint *queryId); +typedef void (GL_APIENTRYP PFNGLGETPERFQUERYINFOINTELPROC) (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBeginPerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glCreatePerfQueryINTEL (GLuint queryId, GLuint *queryHandle); +GL_APICALL void GL_APIENTRY glDeletePerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glEndPerfQueryINTEL (GLuint queryHandle); +GL_APICALL void GL_APIENTRY glGetFirstPerfQueryIdINTEL (GLuint *queryId); +GL_APICALL void GL_APIENTRY glGetNextPerfQueryIdINTEL (GLuint queryId, GLuint *nextQueryId); +GL_APICALL void GL_APIENTRY glGetPerfCounterInfoINTEL (GLuint queryId, GLuint counterId, GLuint counterNameLength, GLchar *counterName, GLuint counterDescLength, GLchar *counterDesc, GLuint *counterOffset, GLuint *counterDataSize, GLuint *counterTypeEnum, GLuint *counterDataTypeEnum, GLuint64 *rawCounterMaxValue); +GL_APICALL void GL_APIENTRY glGetPerfQueryDataINTEL (GLuint queryHandle, GLuint flags, GLsizei dataSize, void *data, GLuint *bytesWritten); +GL_APICALL void GL_APIENTRY glGetPerfQueryIdByNameINTEL (GLchar *queryName, GLuint *queryId); +GL_APICALL void GL_APIENTRY glGetPerfQueryInfoINTEL (GLuint queryId, GLuint queryNameLength, GLchar *queryName, GLuint *dataSize, GLuint *noCounters, GLuint *noInstances, GLuint *capsMask); +#endif +#endif /* GL_INTEL_performance_query */ + +#ifndef GL_MESA_bgra +#define GL_MESA_bgra 1 +#define GL_BGR_EXT 0x80E0 +#endif /* GL_MESA_bgra */ + +#ifndef GL_MESA_framebuffer_flip_x +#define GL_MESA_framebuffer_flip_x 1 +#define GL_FRAMEBUFFER_FLIP_X_MESA 0x8BBC +#endif /* GL_MESA_framebuffer_flip_x */ + +#ifndef GL_MESA_framebuffer_flip_y +#define GL_MESA_framebuffer_flip_y 1 +#define GL_FRAMEBUFFER_FLIP_Y_MESA 0x8BBB +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIMESAPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVMESAPROC) (GLenum target, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferParameteriMESA (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glGetFramebufferParameterivMESA (GLenum target, GLenum pname, GLint *params); +#endif +#endif /* GL_MESA_framebuffer_flip_y */ + +#ifndef GL_MESA_framebuffer_swap_xy +#define GL_MESA_framebuffer_swap_xy 1 +#define GL_FRAMEBUFFER_SWAP_XY_MESA 0x8BBD +#endif /* GL_MESA_framebuffer_swap_xy */ + +#ifndef GL_MESA_program_binary_formats +#define GL_MESA_program_binary_formats 1 +#define GL_PROGRAM_BINARY_FORMAT_MESA 0x875F +#endif /* GL_MESA_program_binary_formats */ + +#ifndef GL_MESA_sampler_objects +#define GL_MESA_sampler_objects 1 +#define GL_SAMPLER_BINDING 0x8919 +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +#endif +#endif /* GL_MESA_sampler_objects */ + +#ifndef GL_MESA_shader_integer_functions +#define GL_MESA_shader_integer_functions 1 +#endif /* GL_MESA_shader_integer_functions */ + +#ifndef GL_NVX_blend_equation_advanced_multi_draw_buffers +#define GL_NVX_blend_equation_advanced_multi_draw_buffers 1 +#endif /* GL_NVX_blend_equation_advanced_multi_draw_buffers */ + +#ifndef GL_NV_bindless_texture +#define GL_NV_bindless_texture 1 +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTUREHANDLENVPROC) (GLuint texture); +typedef GLuint64 (GL_APIENTRYP PFNGLGETTEXTURESAMPLERHANDLENVPROC) (GLuint texture, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef void (GL_APIENTRYP PFNGLMAKETEXTUREHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef GLuint64 (GL_APIENTRYP PFNGLGETIMAGEHANDLENVPROC) (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle, GLenum access); +typedef void (GL_APIENTRYP PFNGLMAKEIMAGEHANDLENONRESIDENTNVPROC) (GLuint64 handle); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64NVPROC) (GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLUNIFORMHANDLEUI64VNVPROC) (GLint location, GLsizei count, const GLuint64 *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64NVPROC) (GLuint program, GLint location, GLuint64 value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMHANDLEUI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREHANDLERESIDENTNVPROC) (GLuint64 handle); +typedef GLboolean (GL_APIENTRYP PFNGLISIMAGEHANDLERESIDENTNVPROC) (GLuint64 handle); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint64 GL_APIENTRY glGetTextureHandleNV (GLuint texture); +GL_APICALL GLuint64 GL_APIENTRY glGetTextureSamplerHandleNV (GLuint texture, GLuint sampler); +GL_APICALL void GL_APIENTRY glMakeTextureHandleResidentNV (GLuint64 handle); +GL_APICALL void GL_APIENTRY glMakeTextureHandleNonResidentNV (GLuint64 handle); +GL_APICALL GLuint64 GL_APIENTRY glGetImageHandleNV (GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum format); +GL_APICALL void GL_APIENTRY glMakeImageHandleResidentNV (GLuint64 handle, GLenum access); +GL_APICALL void GL_APIENTRY glMakeImageHandleNonResidentNV (GLuint64 handle); +GL_APICALL void GL_APIENTRY glUniformHandleui64NV (GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glUniformHandleui64vNV (GLint location, GLsizei count, const GLuint64 *value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64NV (GLuint program, GLint location, GLuint64 value); +GL_APICALL void GL_APIENTRY glProgramUniformHandleui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64 *values); +GL_APICALL GLboolean GL_APIENTRY glIsTextureHandleResidentNV (GLuint64 handle); +GL_APICALL GLboolean GL_APIENTRY glIsImageHandleResidentNV (GLuint64 handle); +#endif +#endif /* GL_NV_bindless_texture */ + +#ifndef GL_NV_blend_equation_advanced +#define GL_NV_blend_equation_advanced 1 +#define GL_BLEND_OVERLAP_NV 0x9281 +#define GL_BLEND_PREMULTIPLIED_SRC_NV 0x9280 +#define GL_BLUE_NV 0x1905 +#define GL_COLORBURN_NV 0x929A +#define GL_COLORDODGE_NV 0x9299 +#define GL_CONJOINT_NV 0x9284 +#define GL_CONTRAST_NV 0x92A1 +#define GL_DARKEN_NV 0x9297 +#define GL_DIFFERENCE_NV 0x929E +#define GL_DISJOINT_NV 0x9283 +#define GL_DST_ATOP_NV 0x928F +#define GL_DST_IN_NV 0x928B +#define GL_DST_NV 0x9287 +#define GL_DST_OUT_NV 0x928D +#define GL_DST_OVER_NV 0x9289 +#define GL_EXCLUSION_NV 0x92A0 +#define GL_GREEN_NV 0x1904 +#define GL_HARDLIGHT_NV 0x929B +#define GL_HARDMIX_NV 0x92A9 +#define GL_HSL_COLOR_NV 0x92AF +#define GL_HSL_HUE_NV 0x92AD +#define GL_HSL_LUMINOSITY_NV 0x92B0 +#define GL_HSL_SATURATION_NV 0x92AE +#define GL_INVERT_OVG_NV 0x92B4 +#define GL_INVERT_RGB_NV 0x92A3 +#define GL_LIGHTEN_NV 0x9298 +#define GL_LINEARBURN_NV 0x92A5 +#define GL_LINEARDODGE_NV 0x92A4 +#define GL_LINEARLIGHT_NV 0x92A7 +#define GL_MINUS_CLAMPED_NV 0x92B3 +#define GL_MINUS_NV 0x929F +#define GL_MULTIPLY_NV 0x9294 +#define GL_OVERLAY_NV 0x9296 +#define GL_PINLIGHT_NV 0x92A8 +#define GL_PLUS_CLAMPED_ALPHA_NV 0x92B2 +#define GL_PLUS_CLAMPED_NV 0x92B1 +#define GL_PLUS_DARKER_NV 0x9292 +#define GL_PLUS_NV 0x9291 +#define GL_RED_NV 0x1903 +#define GL_SCREEN_NV 0x9295 +#define GL_SOFTLIGHT_NV 0x929C +#define GL_SRC_ATOP_NV 0x928E +#define GL_SRC_IN_NV 0x928A +#define GL_SRC_NV 0x9286 +#define GL_SRC_OUT_NV 0x928C +#define GL_SRC_OVER_NV 0x9288 +#define GL_UNCORRELATED_NV 0x9282 +#define GL_VIVIDLIGHT_NV 0x92A6 +#define GL_XOR_NV 0x1506 +typedef void (GL_APIENTRYP PFNGLBLENDPARAMETERINVPROC) (GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendParameteriNV (GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glBlendBarrierNV (void); +#endif +#endif /* GL_NV_blend_equation_advanced */ + +#ifndef GL_NV_blend_equation_advanced_coherent +#define GL_NV_blend_equation_advanced_coherent 1 +#define GL_BLEND_ADVANCED_COHERENT_NV 0x9285 +#endif /* GL_NV_blend_equation_advanced_coherent */ + +#ifndef GL_NV_blend_minmax_factor +#define GL_NV_blend_minmax_factor 1 +#define GL_FACTOR_MIN_AMD 0x901C +#define GL_FACTOR_MAX_AMD 0x901D +#endif /* GL_NV_blend_minmax_factor */ + +#ifndef GL_NV_clip_space_w_scaling +#define GL_NV_clip_space_w_scaling 1 +#define GL_VIEWPORT_POSITION_W_SCALE_NV 0x937C +#define GL_VIEWPORT_POSITION_W_SCALE_X_COEFF_NV 0x937D +#define GL_VIEWPORT_POSITION_W_SCALE_Y_COEFF_NV 0x937E +typedef void (GL_APIENTRYP PFNGLVIEWPORTPOSITIONWSCALENVPROC) (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportPositionWScaleNV (GLuint index, GLfloat xcoeff, GLfloat ycoeff); +#endif +#endif /* GL_NV_clip_space_w_scaling */ + +#ifndef GL_NV_compute_shader_derivatives +#define GL_NV_compute_shader_derivatives 1 +#endif /* GL_NV_compute_shader_derivatives */ + +#ifndef GL_NV_conditional_render +#define GL_NV_conditional_render 1 +#define GL_QUERY_WAIT_NV 0x8E13 +#define GL_QUERY_NO_WAIT_NV 0x8E14 +#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15 +#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16 +typedef void (GL_APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode); +typedef void (GL_APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBeginConditionalRenderNV (GLuint id, GLenum mode); +GL_APICALL void GL_APIENTRY glEndConditionalRenderNV (void); +#endif +#endif /* GL_NV_conditional_render */ + +#ifndef GL_NV_conservative_raster +#define GL_NV_conservative_raster 1 +#define GL_CONSERVATIVE_RASTERIZATION_NV 0x9346 +#define GL_SUBPIXEL_PRECISION_BIAS_X_BITS_NV 0x9347 +#define GL_SUBPIXEL_PRECISION_BIAS_Y_BITS_NV 0x9348 +#define GL_MAX_SUBPIXEL_PRECISION_BIAS_BITS_NV 0x9349 +typedef void (GL_APIENTRYP PFNGLSUBPIXELPRECISIONBIASNVPROC) (GLuint xbits, GLuint ybits); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glSubpixelPrecisionBiasNV (GLuint xbits, GLuint ybits); +#endif +#endif /* GL_NV_conservative_raster */ + +#ifndef GL_NV_conservative_raster_pre_snap +#define GL_NV_conservative_raster_pre_snap 1 +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_NV 0x9550 +#endif /* GL_NV_conservative_raster_pre_snap */ + +#ifndef GL_NV_conservative_raster_pre_snap_triangles +#define GL_NV_conservative_raster_pre_snap_triangles 1 +#define GL_CONSERVATIVE_RASTER_MODE_NV 0x954D +#define GL_CONSERVATIVE_RASTER_MODE_POST_SNAP_NV 0x954E +#define GL_CONSERVATIVE_RASTER_MODE_PRE_SNAP_TRIANGLES_NV 0x954F +typedef void (GL_APIENTRYP PFNGLCONSERVATIVERASTERPARAMETERINVPROC) (GLenum pname, GLint param); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glConservativeRasterParameteriNV (GLenum pname, GLint param); +#endif +#endif /* GL_NV_conservative_raster_pre_snap_triangles */ + +#ifndef GL_NV_copy_buffer +#define GL_NV_copy_buffer 1 +#define GL_COPY_READ_BUFFER_NV 0x8F36 +#define GL_COPY_WRITE_BUFFER_NV 0x8F37 +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATANVPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCopyBufferSubDataNV (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +#endif +#endif /* GL_NV_copy_buffer */ + +#ifndef GL_NV_coverage_sample +#define GL_NV_coverage_sample 1 +#define GL_COVERAGE_COMPONENT_NV 0x8ED0 +#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 +#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 +#define GL_COVERAGE_BUFFERS_NV 0x8ED3 +#define GL_COVERAGE_SAMPLES_NV 0x8ED4 +#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 +#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 +#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 +#define GL_COVERAGE_BUFFER_BIT_NV 0x00008000 +typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); +typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); +GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); +#endif +#endif /* GL_NV_coverage_sample */ + +#ifndef GL_NV_depth_nonlinear +#define GL_NV_depth_nonlinear 1 +#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C +#endif /* GL_NV_depth_nonlinear */ + +#ifndef GL_NV_draw_buffers +#define GL_NV_draw_buffers 1 +#define GL_MAX_DRAW_BUFFERS_NV 0x8824 +#define GL_DRAW_BUFFER0_NV 0x8825 +#define GL_DRAW_BUFFER1_NV 0x8826 +#define GL_DRAW_BUFFER2_NV 0x8827 +#define GL_DRAW_BUFFER3_NV 0x8828 +#define GL_DRAW_BUFFER4_NV 0x8829 +#define GL_DRAW_BUFFER5_NV 0x882A +#define GL_DRAW_BUFFER6_NV 0x882B +#define GL_DRAW_BUFFER7_NV 0x882C +#define GL_DRAW_BUFFER8_NV 0x882D +#define GL_DRAW_BUFFER9_NV 0x882E +#define GL_DRAW_BUFFER10_NV 0x882F +#define GL_DRAW_BUFFER11_NV 0x8830 +#define GL_DRAW_BUFFER12_NV 0x8831 +#define GL_DRAW_BUFFER13_NV 0x8832 +#define GL_DRAW_BUFFER14_NV 0x8833 +#define GL_DRAW_BUFFER15_NV 0x8834 +#define GL_COLOR_ATTACHMENT0_NV 0x8CE0 +#define GL_COLOR_ATTACHMENT1_NV 0x8CE1 +#define GL_COLOR_ATTACHMENT2_NV 0x8CE2 +#define GL_COLOR_ATTACHMENT3_NV 0x8CE3 +#define GL_COLOR_ATTACHMENT4_NV 0x8CE4 +#define GL_COLOR_ATTACHMENT5_NV 0x8CE5 +#define GL_COLOR_ATTACHMENT6_NV 0x8CE6 +#define GL_COLOR_ATTACHMENT7_NV 0x8CE7 +#define GL_COLOR_ATTACHMENT8_NV 0x8CE8 +#define GL_COLOR_ATTACHMENT9_NV 0x8CE9 +#define GL_COLOR_ATTACHMENT10_NV 0x8CEA +#define GL_COLOR_ATTACHMENT11_NV 0x8CEB +#define GL_COLOR_ATTACHMENT12_NV 0x8CEC +#define GL_COLOR_ATTACHMENT13_NV 0x8CED +#define GL_COLOR_ATTACHMENT14_NV 0x8CEE +#define GL_COLOR_ATTACHMENT15_NV 0x8CEF +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSNVPROC) (GLsizei n, const GLenum *bufs); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawBuffersNV (GLsizei n, const GLenum *bufs); +#endif +#endif /* GL_NV_draw_buffers */ + +#ifndef GL_NV_draw_instanced +#define GL_NV_draw_instanced 1 +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDNVPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDNVPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawArraysInstancedNV (GLenum mode, GLint first, GLsizei count, GLsizei primcount); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedNV (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount); +#endif +#endif /* GL_NV_draw_instanced */ + +#ifndef GL_NV_draw_vulkan_image +#define GL_NV_draw_vulkan_image 1 +typedef void (GL_APIENTRY *GLVULKANPROCNV)(void); +typedef void (GL_APIENTRYP PFNGLDRAWVKIMAGENVPROC) (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +typedef GLVULKANPROCNV (GL_APIENTRYP PFNGLGETVKPROCADDRNVPROC) (const GLchar *name); +typedef void (GL_APIENTRYP PFNGLWAITVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (GL_APIENTRYP PFNGLSIGNALVKSEMAPHORENVPROC) (GLuint64 vkSemaphore); +typedef void (GL_APIENTRYP PFNGLSIGNALVKFENCENVPROC) (GLuint64 vkFence); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawVkImageNV (GLuint64 vkImage, GLuint sampler, GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1, GLfloat z, GLfloat s0, GLfloat t0, GLfloat s1, GLfloat t1); +GL_APICALL GLVULKANPROCNV GL_APIENTRY glGetVkProcAddrNV (const GLchar *name); +GL_APICALL void GL_APIENTRY glWaitVkSemaphoreNV (GLuint64 vkSemaphore); +GL_APICALL void GL_APIENTRY glSignalVkSemaphoreNV (GLuint64 vkSemaphore); +GL_APICALL void GL_APIENTRY glSignalVkFenceNV (GLuint64 vkFence); +#endif +#endif /* GL_NV_draw_vulkan_image */ + +#ifndef GL_NV_explicit_attrib_location +#define GL_NV_explicit_attrib_location 1 +#endif /* GL_NV_explicit_attrib_location */ + +#ifndef GL_NV_fbo_color_attachments +#define GL_NV_fbo_color_attachments 1 +#define GL_MAX_COLOR_ATTACHMENTS_NV 0x8CDF +#endif /* GL_NV_fbo_color_attachments */ + +#ifndef GL_NV_fence +#define GL_NV_fence 1 +#define GL_ALL_COMPLETED_NV 0x84F2 +#define GL_FENCE_STATUS_NV 0x84F3 +#define GL_FENCE_CONDITION_NV 0x84F4 +typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); +typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); +typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); +typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); +typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei n, const GLuint *fences); +GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei n, GLuint *fences); +GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint fence); +GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint fence, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint fence); +GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint fence, GLenum condition); +#endif +#endif /* GL_NV_fence */ + +#ifndef GL_NV_fill_rectangle +#define GL_NV_fill_rectangle 1 +#define GL_FILL_RECTANGLE_NV 0x933C +#endif /* GL_NV_fill_rectangle */ + +#ifndef GL_NV_fragment_coverage_to_color +#define GL_NV_fragment_coverage_to_color 1 +#define GL_FRAGMENT_COVERAGE_TO_COLOR_NV 0x92DD +#define GL_FRAGMENT_COVERAGE_COLOR_NV 0x92DE +typedef void (GL_APIENTRYP PFNGLFRAGMENTCOVERAGECOLORNVPROC) (GLuint color); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFragmentCoverageColorNV (GLuint color); +#endif +#endif /* GL_NV_fragment_coverage_to_color */ + +#ifndef GL_NV_fragment_shader_barycentric +#define GL_NV_fragment_shader_barycentric 1 +#endif /* GL_NV_fragment_shader_barycentric */ + +#ifndef GL_NV_fragment_shader_interlock +#define GL_NV_fragment_shader_interlock 1 +#endif /* GL_NV_fragment_shader_interlock */ + +#ifndef GL_NV_framebuffer_blit +#define GL_NV_framebuffer_blit 1 +#define GL_READ_FRAMEBUFFER_NV 0x8CA8 +#define GL_DRAW_FRAMEBUFFER_NV 0x8CA9 +#define GL_DRAW_FRAMEBUFFER_BINDING_NV 0x8CA6 +#define GL_READ_FRAMEBUFFER_BINDING_NV 0x8CAA +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERNVPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlitFramebufferNV (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +#endif +#endif /* GL_NV_framebuffer_blit */ + +#ifndef GL_NV_framebuffer_mixed_samples +#define GL_NV_framebuffer_mixed_samples 1 +#define GL_COVERAGE_MODULATION_TABLE_NV 0x9331 +#define GL_COLOR_SAMPLES_NV 0x8E20 +#define GL_DEPTH_SAMPLES_NV 0x932D +#define GL_STENCIL_SAMPLES_NV 0x932E +#define GL_MIXED_DEPTH_SAMPLES_SUPPORTED_NV 0x932F +#define GL_MIXED_STENCIL_SAMPLES_SUPPORTED_NV 0x9330 +#define GL_COVERAGE_MODULATION_NV 0x9332 +#define GL_COVERAGE_MODULATION_TABLE_SIZE_NV 0x9333 +typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONTABLENVPROC) (GLsizei n, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLGETCOVERAGEMODULATIONTABLENVPROC) (GLsizei bufSize, GLfloat *v); +typedef void (GL_APIENTRYP PFNGLCOVERAGEMODULATIONNVPROC) (GLenum components); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCoverageModulationTableNV (GLsizei n, const GLfloat *v); +GL_APICALL void GL_APIENTRY glGetCoverageModulationTableNV (GLsizei bufSize, GLfloat *v); +GL_APICALL void GL_APIENTRY glCoverageModulationNV (GLenum components); +#endif +#endif /* GL_NV_framebuffer_mixed_samples */ + +#ifndef GL_NV_framebuffer_multisample +#define GL_NV_framebuffer_multisample 1 +#define GL_RENDERBUFFER_SAMPLES_NV 0x8CAB +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_NV 0x8D56 +#define GL_MAX_SAMPLES_NV 0x8D57 +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLENVPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleNV (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +#endif +#endif /* GL_NV_framebuffer_multisample */ + +#ifndef GL_NV_generate_mipmap_sRGB +#define GL_NV_generate_mipmap_sRGB 1 +#endif /* GL_NV_generate_mipmap_sRGB */ + +#ifndef GL_NV_geometry_shader_passthrough +#define GL_NV_geometry_shader_passthrough 1 +#endif /* GL_NV_geometry_shader_passthrough */ + +#ifndef GL_NV_gpu_shader5 +#define GL_NV_gpu_shader5 1 +typedef khronos_int64_t GLint64EXT; +typedef khronos_uint64_t GLuint64EXT; +#define GL_INT64_NV 0x140E +#define GL_UNSIGNED_INT64_NV 0x140F +#define GL_INT8_NV 0x8FE0 +#define GL_INT8_VEC2_NV 0x8FE1 +#define GL_INT8_VEC3_NV 0x8FE2 +#define GL_INT8_VEC4_NV 0x8FE3 +#define GL_INT16_NV 0x8FE4 +#define GL_INT16_VEC2_NV 0x8FE5 +#define GL_INT16_VEC3_NV 0x8FE6 +#define GL_INT16_VEC4_NV 0x8FE7 +#define GL_INT64_VEC2_NV 0x8FE9 +#define GL_INT64_VEC3_NV 0x8FEA +#define GL_INT64_VEC4_NV 0x8FEB +#define GL_UNSIGNED_INT8_NV 0x8FEC +#define GL_UNSIGNED_INT8_VEC2_NV 0x8FED +#define GL_UNSIGNED_INT8_VEC3_NV 0x8FEE +#define GL_UNSIGNED_INT8_VEC4_NV 0x8FEF +#define GL_UNSIGNED_INT16_NV 0x8FF0 +#define GL_UNSIGNED_INT16_VEC2_NV 0x8FF1 +#define GL_UNSIGNED_INT16_VEC3_NV 0x8FF2 +#define GL_UNSIGNED_INT16_VEC4_NV 0x8FF3 +#define GL_UNSIGNED_INT64_VEC2_NV 0x8FF5 +#define GL_UNSIGNED_INT64_VEC3_NV 0x8FF6 +#define GL_UNSIGNED_INT64_VEC4_NV 0x8FF7 +#define GL_FLOAT16_NV 0x8FF8 +#define GL_FLOAT16_VEC2_NV 0x8FF9 +#define GL_FLOAT16_VEC3_NV 0x8FFA +#define GL_FLOAT16_VEC4_NV 0x8FFB +#define GL_PATCHES 0x000E +typedef void (GL_APIENTRYP PFNGLUNIFORM1I64NVPROC) (GLint location, GLint64EXT x); +typedef void (GL_APIENTRYP PFNGLUNIFORM2I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GL_APIENTRYP PFNGLUNIFORM3I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GL_APIENTRYP PFNGLUNIFORM4I64NVPROC) (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GL_APIENTRYP PFNGLUNIFORM1I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4I64VNVPROC) (GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64NVPROC) (GLint location, GLuint64EXT x); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64NVPROC) (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UI64VNVPROC) (GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMI64VNVPROC) (GLuint program, GLint location, GLint64EXT *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64NVPROC) (GLuint program, GLint location, GLint64EXT x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64NVPROC) (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4I64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64NVPROC) (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UI64VNVPROC) (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUniform1i64NV (GLint location, GLint64EXT x); +GL_APICALL void GL_APIENTRY glUniform2i64NV (GLint location, GLint64EXT x, GLint64EXT y); +GL_APICALL void GL_APIENTRY glUniform3i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GL_APICALL void GL_APIENTRY glUniform4i64NV (GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GL_APICALL void GL_APIENTRY glUniform1i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform2i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform3i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform4i64vNV (GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform1ui64NV (GLint location, GLuint64EXT x); +GL_APICALL void GL_APIENTRY glUniform2ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y); +GL_APICALL void GL_APIENTRY glUniform3ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GL_APICALL void GL_APIENTRY glUniform4ui64NV (GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GL_APICALL void GL_APIENTRY glUniform1ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform2ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform3ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glUniform4ui64vNV (GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glGetUniformi64vNV (GLuint program, GLint location, GLint64EXT *params); +GL_APICALL void GL_APIENTRY glProgramUniform1i64NV (GLuint program, GLint location, GLint64EXT x); +GL_APICALL void GL_APIENTRY glProgramUniform2i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y); +GL_APICALL void GL_APIENTRY glProgramUniform3i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z); +GL_APICALL void GL_APIENTRY glProgramUniform4i64NV (GLuint program, GLint location, GLint64EXT x, GLint64EXT y, GLint64EXT z, GLint64EXT w); +GL_APICALL void GL_APIENTRY glProgramUniform1i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform2i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform3i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform4i64vNV (GLuint program, GLint location, GLsizei count, const GLint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform1ui64NV (GLuint program, GLint location, GLuint64EXT x); +GL_APICALL void GL_APIENTRY glProgramUniform2ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y); +GL_APICALL void GL_APIENTRY glProgramUniform3ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z); +GL_APICALL void GL_APIENTRY glProgramUniform4ui64NV (GLuint program, GLint location, GLuint64EXT x, GLuint64EXT y, GLuint64EXT z, GLuint64EXT w); +GL_APICALL void GL_APIENTRY glProgramUniform1ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform2ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform3ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +GL_APICALL void GL_APIENTRY glProgramUniform4ui64vNV (GLuint program, GLint location, GLsizei count, const GLuint64EXT *value); +#endif +#endif /* GL_NV_gpu_shader5 */ + +#ifndef GL_NV_image_formats +#define GL_NV_image_formats 1 +#endif /* GL_NV_image_formats */ + +#ifndef GL_NV_instanced_arrays +#define GL_NV_instanced_arrays 1 +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR_NV 0x88FE +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORNVPROC) (GLuint index, GLuint divisor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glVertexAttribDivisorNV (GLuint index, GLuint divisor); +#endif +#endif /* GL_NV_instanced_arrays */ + +#ifndef GL_NV_internalformat_sample_query +#define GL_NV_internalformat_sample_query 1 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_MULTISAMPLES_NV 0x9371 +#define GL_SUPERSAMPLE_SCALE_X_NV 0x9372 +#define GL_SUPERSAMPLE_SCALE_Y_NV 0x9373 +#define GL_CONFORMANT_NV 0x9374 +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATSAMPLEIVNVPROC) (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetInternalformatSampleivNV (GLenum target, GLenum internalformat, GLsizei samples, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_NV_internalformat_sample_query */ + +#ifndef GL_NV_memory_attachment +#define GL_NV_memory_attachment 1 +#define GL_ATTACHED_MEMORY_OBJECT_NV 0x95A4 +#define GL_ATTACHED_MEMORY_OFFSET_NV 0x95A5 +#define GL_MEMORY_ATTACHABLE_ALIGNMENT_NV 0x95A6 +#define GL_MEMORY_ATTACHABLE_SIZE_NV 0x95A7 +#define GL_MEMORY_ATTACHABLE_NV 0x95A8 +#define GL_DETACHED_MEMORY_INCARNATION_NV 0x95A9 +#define GL_DETACHED_TEXTURES_NV 0x95AA +#define GL_DETACHED_BUFFERS_NV 0x95AB +#define GL_MAX_DETACHED_TEXTURES_NV 0x95AC +#define GL_MAX_DETACHED_BUFFERS_NV 0x95AD +typedef void (GL_APIENTRYP PFNGLGETMEMORYOBJECTDETACHEDRESOURCESUIVNVPROC) (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +typedef void (GL_APIENTRYP PFNGLRESETMEMORYOBJECTPARAMETERNVPROC) (GLuint memory, GLenum pname); +typedef void (GL_APIENTRYP PFNGLTEXATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLBUFFERATTACHMEMORYNVPROC) (GLenum target, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLTEXTUREATTACHMEMORYNVPROC) (GLuint texture, GLuint memory, GLuint64 offset); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERATTACHMEMORYNVPROC) (GLuint buffer, GLuint memory, GLuint64 offset); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetMemoryObjectDetachedResourcesuivNV (GLuint memory, GLenum pname, GLint first, GLsizei count, GLuint *params); +GL_APICALL void GL_APIENTRY glResetMemoryObjectParameterNV (GLuint memory, GLenum pname); +GL_APICALL void GL_APIENTRY glTexAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glBufferAttachMemoryNV (GLenum target, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glTextureAttachMemoryNV (GLuint texture, GLuint memory, GLuint64 offset); +GL_APICALL void GL_APIENTRY glNamedBufferAttachMemoryNV (GLuint buffer, GLuint memory, GLuint64 offset); +#endif +#endif /* GL_NV_memory_attachment */ + +#ifndef GL_NV_memory_object_sparse +#define GL_NV_memory_object_sparse 1 +typedef void (GL_APIENTRYP PFNGLBUFFERPAGECOMMITMENTMEMNVPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (GL_APIENTRYP PFNGLTEXPAGECOMMITMENTMEMNVPROC) (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +typedef void (GL_APIENTRYP PFNGLNAMEDBUFFERPAGECOMMITMENTMEMNVPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +typedef void (GL_APIENTRYP PFNGLTEXTUREPAGECOMMITMENTMEMNVPROC) (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBufferPageCommitmentMemNV (GLenum target, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GL_APICALL void GL_APIENTRY glTexPageCommitmentMemNV (GLenum target, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +GL_APICALL void GL_APIENTRY glNamedBufferPageCommitmentMemNV (GLuint buffer, GLintptr offset, GLsizeiptr size, GLuint memory, GLuint64 memOffset, GLboolean commit); +GL_APICALL void GL_APIENTRY glTexturePageCommitmentMemNV (GLuint texture, GLint layer, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLuint memory, GLuint64 offset, GLboolean commit); +#endif +#endif /* GL_NV_memory_object_sparse */ + +#ifndef GL_NV_mesh_shader +#define GL_NV_mesh_shader 1 +#define GL_MESH_SHADER_NV 0x9559 +#define GL_TASK_SHADER_NV 0x955A +#define GL_MAX_MESH_UNIFORM_BLOCKS_NV 0x8E60 +#define GL_MAX_MESH_TEXTURE_IMAGE_UNITS_NV 0x8E61 +#define GL_MAX_MESH_IMAGE_UNIFORMS_NV 0x8E62 +#define GL_MAX_MESH_UNIFORM_COMPONENTS_NV 0x8E63 +#define GL_MAX_MESH_ATOMIC_COUNTER_BUFFERS_NV 0x8E64 +#define GL_MAX_MESH_ATOMIC_COUNTERS_NV 0x8E65 +#define GL_MAX_MESH_SHADER_STORAGE_BLOCKS_NV 0x8E66 +#define GL_MAX_COMBINED_MESH_UNIFORM_COMPONENTS_NV 0x8E67 +#define GL_MAX_TASK_UNIFORM_BLOCKS_NV 0x8E68 +#define GL_MAX_TASK_TEXTURE_IMAGE_UNITS_NV 0x8E69 +#define GL_MAX_TASK_IMAGE_UNIFORMS_NV 0x8E6A +#define GL_MAX_TASK_UNIFORM_COMPONENTS_NV 0x8E6B +#define GL_MAX_TASK_ATOMIC_COUNTER_BUFFERS_NV 0x8E6C +#define GL_MAX_TASK_ATOMIC_COUNTERS_NV 0x8E6D +#define GL_MAX_TASK_SHADER_STORAGE_BLOCKS_NV 0x8E6E +#define GL_MAX_COMBINED_TASK_UNIFORM_COMPONENTS_NV 0x8E6F +#define GL_MAX_MESH_WORK_GROUP_INVOCATIONS_NV 0x95A2 +#define GL_MAX_TASK_WORK_GROUP_INVOCATIONS_NV 0x95A3 +#define GL_MAX_MESH_TOTAL_MEMORY_SIZE_NV 0x9536 +#define GL_MAX_TASK_TOTAL_MEMORY_SIZE_NV 0x9537 +#define GL_MAX_MESH_OUTPUT_VERTICES_NV 0x9538 +#define GL_MAX_MESH_OUTPUT_PRIMITIVES_NV 0x9539 +#define GL_MAX_TASK_OUTPUT_COUNT_NV 0x953A +#define GL_MAX_DRAW_MESH_TASKS_COUNT_NV 0x953D +#define GL_MAX_MESH_VIEWS_NV 0x9557 +#define GL_MESH_OUTPUT_PER_VERTEX_GRANULARITY_NV 0x92DF +#define GL_MESH_OUTPUT_PER_PRIMITIVE_GRANULARITY_NV 0x9543 +#define GL_MAX_MESH_WORK_GROUP_SIZE_NV 0x953B +#define GL_MAX_TASK_WORK_GROUP_SIZE_NV 0x953C +#define GL_MESH_WORK_GROUP_SIZE_NV 0x953E +#define GL_TASK_WORK_GROUP_SIZE_NV 0x953F +#define GL_MESH_VERTICES_OUT_NV 0x9579 +#define GL_MESH_PRIMITIVES_OUT_NV 0x957A +#define GL_MESH_OUTPUT_TYPE_NV 0x957B +#define GL_UNIFORM_BLOCK_REFERENCED_BY_MESH_SHADER_NV 0x959C +#define GL_UNIFORM_BLOCK_REFERENCED_BY_TASK_SHADER_NV 0x959D +#define GL_REFERENCED_BY_MESH_SHADER_NV 0x95A0 +#define GL_REFERENCED_BY_TASK_SHADER_NV 0x95A1 +#define GL_MESH_SHADER_BIT_NV 0x00000040 +#define GL_TASK_SHADER_BIT_NV 0x00000080 +#define GL_MESH_SUBROUTINE_NV 0x957C +#define GL_TASK_SUBROUTINE_NV 0x957D +#define GL_MESH_SUBROUTINE_UNIFORM_NV 0x957E +#define GL_TASK_SUBROUTINE_UNIFORM_NV 0x957F +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_MESH_SHADER_NV 0x959E +#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TASK_SHADER_NV 0x959F +typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSNVPROC) (GLuint first, GLuint count); +typedef void (GL_APIENTRYP PFNGLDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTNVPROC) (GLintptr indirect, GLsizei drawcount, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLMULTIDRAWMESHTASKSINDIRECTCOUNTNVPROC) (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glDrawMeshTasksNV (GLuint first, GLuint count); +GL_APICALL void GL_APIENTRY glDrawMeshTasksIndirectNV (GLintptr indirect); +GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectNV (GLintptr indirect, GLsizei drawcount, GLsizei stride); +GL_APICALL void GL_APIENTRY glMultiDrawMeshTasksIndirectCountNV (GLintptr indirect, GLintptr drawcount, GLsizei maxdrawcount, GLsizei stride); +#endif +#endif /* GL_NV_mesh_shader */ + +#ifndef GL_NV_non_square_matrices +#define GL_NV_non_square_matrices 1 +#define GL_FLOAT_MAT2x3_NV 0x8B65 +#define GL_FLOAT_MAT2x4_NV 0x8B66 +#define GL_FLOAT_MAT3x2_NV 0x8B67 +#define GL_FLOAT_MAT3x4_NV 0x8B68 +#define GL_FLOAT_MAT4x2_NV 0x8B69 +#define GL_FLOAT_MAT4x3_NV 0x8B6A +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVNVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fvNV (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +#endif +#endif /* GL_NV_non_square_matrices */ + +#ifndef GL_NV_pack_subimage +#define GL_NV_pack_subimage 1 +#define GL_PACK_ROW_LENGTH_NV 0x0D02 +#define GL_PACK_SKIP_ROWS_NV 0x0D03 +#define GL_PACK_SKIP_PIXELS_NV 0x0D04 +#endif /* GL_NV_pack_subimage */ + +#ifndef GL_NV_path_rendering +#define GL_NV_path_rendering 1 +typedef double GLdouble; +#define GL_PATH_FORMAT_SVG_NV 0x9070 +#define GL_PATH_FORMAT_PS_NV 0x9071 +#define GL_STANDARD_FONT_NAME_NV 0x9072 +#define GL_SYSTEM_FONT_NAME_NV 0x9073 +#define GL_FILE_NAME_NV 0x9074 +#define GL_PATH_STROKE_WIDTH_NV 0x9075 +#define GL_PATH_END_CAPS_NV 0x9076 +#define GL_PATH_INITIAL_END_CAP_NV 0x9077 +#define GL_PATH_TERMINAL_END_CAP_NV 0x9078 +#define GL_PATH_JOIN_STYLE_NV 0x9079 +#define GL_PATH_MITER_LIMIT_NV 0x907A +#define GL_PATH_DASH_CAPS_NV 0x907B +#define GL_PATH_INITIAL_DASH_CAP_NV 0x907C +#define GL_PATH_TERMINAL_DASH_CAP_NV 0x907D +#define GL_PATH_DASH_OFFSET_NV 0x907E +#define GL_PATH_CLIENT_LENGTH_NV 0x907F +#define GL_PATH_FILL_MODE_NV 0x9080 +#define GL_PATH_FILL_MASK_NV 0x9081 +#define GL_PATH_FILL_COVER_MODE_NV 0x9082 +#define GL_PATH_STROKE_COVER_MODE_NV 0x9083 +#define GL_PATH_STROKE_MASK_NV 0x9084 +#define GL_COUNT_UP_NV 0x9088 +#define GL_COUNT_DOWN_NV 0x9089 +#define GL_PATH_OBJECT_BOUNDING_BOX_NV 0x908A +#define GL_CONVEX_HULL_NV 0x908B +#define GL_BOUNDING_BOX_NV 0x908D +#define GL_TRANSLATE_X_NV 0x908E +#define GL_TRANSLATE_Y_NV 0x908F +#define GL_TRANSLATE_2D_NV 0x9090 +#define GL_TRANSLATE_3D_NV 0x9091 +#define GL_AFFINE_2D_NV 0x9092 +#define GL_AFFINE_3D_NV 0x9094 +#define GL_TRANSPOSE_AFFINE_2D_NV 0x9096 +#define GL_TRANSPOSE_AFFINE_3D_NV 0x9098 +#define GL_UTF8_NV 0x909A +#define GL_UTF16_NV 0x909B +#define GL_BOUNDING_BOX_OF_BOUNDING_BOXES_NV 0x909C +#define GL_PATH_COMMAND_COUNT_NV 0x909D +#define GL_PATH_COORD_COUNT_NV 0x909E +#define GL_PATH_DASH_ARRAY_COUNT_NV 0x909F +#define GL_PATH_COMPUTED_LENGTH_NV 0x90A0 +#define GL_PATH_FILL_BOUNDING_BOX_NV 0x90A1 +#define GL_PATH_STROKE_BOUNDING_BOX_NV 0x90A2 +#define GL_SQUARE_NV 0x90A3 +#define GL_ROUND_NV 0x90A4 +#define GL_TRIANGULAR_NV 0x90A5 +#define GL_BEVEL_NV 0x90A6 +#define GL_MITER_REVERT_NV 0x90A7 +#define GL_MITER_TRUNCATE_NV 0x90A8 +#define GL_SKIP_MISSING_GLYPH_NV 0x90A9 +#define GL_USE_MISSING_GLYPH_NV 0x90AA +#define GL_PATH_ERROR_POSITION_NV 0x90AB +#define GL_ACCUM_ADJACENT_PAIRS_NV 0x90AD +#define GL_ADJACENT_PAIRS_NV 0x90AE +#define GL_FIRST_TO_REST_NV 0x90AF +#define GL_PATH_GEN_MODE_NV 0x90B0 +#define GL_PATH_GEN_COEFF_NV 0x90B1 +#define GL_PATH_GEN_COMPONENTS_NV 0x90B3 +#define GL_PATH_STENCIL_FUNC_NV 0x90B7 +#define GL_PATH_STENCIL_REF_NV 0x90B8 +#define GL_PATH_STENCIL_VALUE_MASK_NV 0x90B9 +#define GL_PATH_STENCIL_DEPTH_OFFSET_FACTOR_NV 0x90BD +#define GL_PATH_STENCIL_DEPTH_OFFSET_UNITS_NV 0x90BE +#define GL_PATH_COVER_DEPTH_FUNC_NV 0x90BF +#define GL_PATH_DASH_OFFSET_RESET_NV 0x90B4 +#define GL_MOVE_TO_RESETS_NV 0x90B5 +#define GL_MOVE_TO_CONTINUES_NV 0x90B6 +#define GL_CLOSE_PATH_NV 0x00 +#define GL_MOVE_TO_NV 0x02 +#define GL_RELATIVE_MOVE_TO_NV 0x03 +#define GL_LINE_TO_NV 0x04 +#define GL_RELATIVE_LINE_TO_NV 0x05 +#define GL_HORIZONTAL_LINE_TO_NV 0x06 +#define GL_RELATIVE_HORIZONTAL_LINE_TO_NV 0x07 +#define GL_VERTICAL_LINE_TO_NV 0x08 +#define GL_RELATIVE_VERTICAL_LINE_TO_NV 0x09 +#define GL_QUADRATIC_CURVE_TO_NV 0x0A +#define GL_RELATIVE_QUADRATIC_CURVE_TO_NV 0x0B +#define GL_CUBIC_CURVE_TO_NV 0x0C +#define GL_RELATIVE_CUBIC_CURVE_TO_NV 0x0D +#define GL_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0E +#define GL_RELATIVE_SMOOTH_QUADRATIC_CURVE_TO_NV 0x0F +#define GL_SMOOTH_CUBIC_CURVE_TO_NV 0x10 +#define GL_RELATIVE_SMOOTH_CUBIC_CURVE_TO_NV 0x11 +#define GL_SMALL_CCW_ARC_TO_NV 0x12 +#define GL_RELATIVE_SMALL_CCW_ARC_TO_NV 0x13 +#define GL_SMALL_CW_ARC_TO_NV 0x14 +#define GL_RELATIVE_SMALL_CW_ARC_TO_NV 0x15 +#define GL_LARGE_CCW_ARC_TO_NV 0x16 +#define GL_RELATIVE_LARGE_CCW_ARC_TO_NV 0x17 +#define GL_LARGE_CW_ARC_TO_NV 0x18 +#define GL_RELATIVE_LARGE_CW_ARC_TO_NV 0x19 +#define GL_RESTART_PATH_NV 0xF0 +#define GL_DUP_FIRST_CUBIC_CURVE_TO_NV 0xF2 +#define GL_DUP_LAST_CUBIC_CURVE_TO_NV 0xF4 +#define GL_RECT_NV 0xF6 +#define GL_CIRCULAR_CCW_ARC_TO_NV 0xF8 +#define GL_CIRCULAR_CW_ARC_TO_NV 0xFA +#define GL_CIRCULAR_TANGENT_ARC_TO_NV 0xFC +#define GL_ARC_TO_NV 0xFE +#define GL_RELATIVE_ARC_TO_NV 0xFF +#define GL_BOLD_BIT_NV 0x01 +#define GL_ITALIC_BIT_NV 0x02 +#define GL_GLYPH_WIDTH_BIT_NV 0x01 +#define GL_GLYPH_HEIGHT_BIT_NV 0x02 +#define GL_GLYPH_HORIZONTAL_BEARING_X_BIT_NV 0x04 +#define GL_GLYPH_HORIZONTAL_BEARING_Y_BIT_NV 0x08 +#define GL_GLYPH_HORIZONTAL_BEARING_ADVANCE_BIT_NV 0x10 +#define GL_GLYPH_VERTICAL_BEARING_X_BIT_NV 0x20 +#define GL_GLYPH_VERTICAL_BEARING_Y_BIT_NV 0x40 +#define GL_GLYPH_VERTICAL_BEARING_ADVANCE_BIT_NV 0x80 +#define GL_GLYPH_HAS_KERNING_BIT_NV 0x100 +#define GL_FONT_X_MIN_BOUNDS_BIT_NV 0x00010000 +#define GL_FONT_Y_MIN_BOUNDS_BIT_NV 0x00020000 +#define GL_FONT_X_MAX_BOUNDS_BIT_NV 0x00040000 +#define GL_FONT_Y_MAX_BOUNDS_BIT_NV 0x00080000 +#define GL_FONT_UNITS_PER_EM_BIT_NV 0x00100000 +#define GL_FONT_ASCENDER_BIT_NV 0x00200000 +#define GL_FONT_DESCENDER_BIT_NV 0x00400000 +#define GL_FONT_HEIGHT_BIT_NV 0x00800000 +#define GL_FONT_MAX_ADVANCE_WIDTH_BIT_NV 0x01000000 +#define GL_FONT_MAX_ADVANCE_HEIGHT_BIT_NV 0x02000000 +#define GL_FONT_UNDERLINE_POSITION_BIT_NV 0x04000000 +#define GL_FONT_UNDERLINE_THICKNESS_BIT_NV 0x08000000 +#define GL_FONT_HAS_KERNING_BIT_NV 0x10000000 +#define GL_ROUNDED_RECT_NV 0xE8 +#define GL_RELATIVE_ROUNDED_RECT_NV 0xE9 +#define GL_ROUNDED_RECT2_NV 0xEA +#define GL_RELATIVE_ROUNDED_RECT2_NV 0xEB +#define GL_ROUNDED_RECT4_NV 0xEC +#define GL_RELATIVE_ROUNDED_RECT4_NV 0xED +#define GL_ROUNDED_RECT8_NV 0xEE +#define GL_RELATIVE_ROUNDED_RECT8_NV 0xEF +#define GL_RELATIVE_RECT_NV 0xF7 +#define GL_FONT_GLYPHS_AVAILABLE_NV 0x9368 +#define GL_FONT_TARGET_UNAVAILABLE_NV 0x9369 +#define GL_FONT_UNAVAILABLE_NV 0x936A +#define GL_FONT_UNINTELLIGIBLE_NV 0x936B +#define GL_CONIC_CURVE_TO_NV 0x1A +#define GL_RELATIVE_CONIC_CURVE_TO_NV 0x1B +#define GL_FONT_NUM_GLYPH_INDICES_BIT_NV 0x20000000 +#define GL_STANDARD_FONT_FORMAT_NV 0x936C +#define GL_PATH_PROJECTION_NV 0x1701 +#define GL_PATH_MODELVIEW_NV 0x1700 +#define GL_PATH_MODELVIEW_STACK_DEPTH_NV 0x0BA3 +#define GL_PATH_MODELVIEW_MATRIX_NV 0x0BA6 +#define GL_PATH_MAX_MODELVIEW_STACK_DEPTH_NV 0x0D36 +#define GL_PATH_TRANSPOSE_MODELVIEW_MATRIX_NV 0x84E3 +#define GL_PATH_PROJECTION_STACK_DEPTH_NV 0x0BA4 +#define GL_PATH_PROJECTION_MATRIX_NV 0x0BA7 +#define GL_PATH_MAX_PROJECTION_STACK_DEPTH_NV 0x0D38 +#define GL_PATH_TRANSPOSE_PROJECTION_MATRIX_NV 0x84E4 +#define GL_FRAGMENT_INPUT_NV 0x936D +typedef GLuint (GL_APIENTRYP PFNGLGENPATHSNVPROC) (GLsizei range); +typedef void (GL_APIENTRYP PFNGLDELETEPATHSNVPROC) (GLuint path, GLsizei range); +typedef GLboolean (GL_APIENTRYP PFNGLISPATHNVPROC) (GLuint path); +typedef void (GL_APIENTRYP PFNGLPATHCOMMANDSNVPROC) (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHCOORDSNVPROC) (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSUBCOMMANDSNVPROC) (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSUBCOORDSNVPROC) (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +typedef void (GL_APIENTRYP PFNGLPATHSTRINGNVPROC) (GLuint path, GLenum format, GLsizei length, const void *pathString); +typedef void (GL_APIENTRYP PFNGLPATHGLYPHSNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLPATHGLYPHRANGENVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLWEIGHTPATHSNVPROC) (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +typedef void (GL_APIENTRYP PFNGLCOPYPATHNVPROC) (GLuint resultPath, GLuint srcPath); +typedef void (GL_APIENTRYP PFNGLINTERPOLATEPATHSNVPROC) (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +typedef void (GL_APIENTRYP PFNGLTRANSFORMPATHNVPROC) (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERINVPROC) (GLuint path, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPATHPARAMETERFNVPROC) (GLuint path, GLenum pname, GLfloat value); +typedef void (GL_APIENTRYP PFNGLPATHDASHARRAYNVPROC) (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +typedef void (GL_APIENTRYP PFNGLPATHSTENCILFUNCNVPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLPATHSTENCILDEPTHOFFSETNVPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLSTENCILSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLPATHCOVERDEPTHFUNCNVPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHNVPROC) (GLuint path, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERIVNVPROC) (GLuint path, GLenum pname, GLint *value); +typedef void (GL_APIENTRYP PFNGLGETPATHPARAMETERFVNVPROC) (GLuint path, GLenum pname, GLfloat *value); +typedef void (GL_APIENTRYP PFNGLGETPATHCOMMANDSNVPROC) (GLuint path, GLubyte *commands); +typedef void (GL_APIENTRYP PFNGLGETPATHCOORDSNVPROC) (GLuint path, GLfloat *coords); +typedef void (GL_APIENTRYP PFNGLGETPATHDASHARRAYNVPROC) (GLuint path, GLfloat *dashArray); +typedef void (GL_APIENTRYP PFNGLGETPATHMETRICSNVPROC) (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +typedef void (GL_APIENTRYP PFNGLGETPATHMETRICRANGENVPROC) (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +typedef void (GL_APIENTRYP PFNGLGETPATHSPACINGNVPROC) (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINFILLPATHNVPROC) (GLuint path, GLuint mask, GLfloat x, GLfloat y); +typedef GLboolean (GL_APIENTRYP PFNGLISPOINTINSTROKEPATHNVPROC) (GLuint path, GLfloat x, GLfloat y); +typedef GLfloat (GL_APIENTRYP PFNGLGETPATHLENGTHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments); +typedef GLboolean (GL_APIENTRYP PFNGLPOINTALONGPATHNVPROC) (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOAD3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X2FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULT3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSE3X3FNVPROC) (GLenum matrixMode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHNVPROC) (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHNVPROC) (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERFILLPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef void (GL_APIENTRYP PFNGLSTENCILTHENCOVERSTROKEPATHINSTANCEDNVPROC) (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXRANGENVPROC) (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +typedef GLenum (GL_APIENTRYP PFNGLPATHGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef GLenum (GL_APIENTRYP PFNGLPATHMEMORYGLYPHINDEXARRAYNVPROC) (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +typedef void (GL_APIENTRYP PFNGLPROGRAMPATHFRAGMENTINPUTGENNVPROC) (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEFVNVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m); +typedef void (GL_APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m); +typedef void (GL_APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +typedef void (GL_APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL GLuint GL_APIENTRY glGenPathsNV (GLsizei range); +GL_APICALL void GL_APIENTRY glDeletePathsNV (GLuint path, GLsizei range); +GL_APICALL GLboolean GL_APIENTRY glIsPathNV (GLuint path); +GL_APICALL void GL_APIENTRY glPathCommandsNV (GLuint path, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathCoordsNV (GLuint path, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathSubCommandsNV (GLuint path, GLsizei commandStart, GLsizei commandsToDelete, GLsizei numCommands, const GLubyte *commands, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathSubCoordsNV (GLuint path, GLsizei coordStart, GLsizei numCoords, GLenum coordType, const void *coords); +GL_APICALL void GL_APIENTRY glPathStringNV (GLuint path, GLenum format, GLsizei length, const void *pathString); +GL_APICALL void GL_APIENTRY glPathGlyphsNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLsizei numGlyphs, GLenum type, const void *charcodes, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glPathGlyphRangeNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyph, GLsizei numGlyphs, GLenum handleMissingGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glWeightPathsNV (GLuint resultPath, GLsizei numPaths, const GLuint *paths, const GLfloat *weights); +GL_APICALL void GL_APIENTRY glCopyPathNV (GLuint resultPath, GLuint srcPath); +GL_APICALL void GL_APIENTRY glInterpolatePathsNV (GLuint resultPath, GLuint pathA, GLuint pathB, GLfloat weight); +GL_APICALL void GL_APIENTRY glTransformPathNV (GLuint resultPath, GLuint srcPath, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glPathParameterivNV (GLuint path, GLenum pname, const GLint *value); +GL_APICALL void GL_APIENTRY glPathParameteriNV (GLuint path, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glPathParameterfvNV (GLuint path, GLenum pname, const GLfloat *value); +GL_APICALL void GL_APIENTRY glPathParameterfNV (GLuint path, GLenum pname, GLfloat value); +GL_APICALL void GL_APIENTRY glPathDashArrayNV (GLuint path, GLsizei dashCount, const GLfloat *dashArray); +GL_APICALL void GL_APIENTRY glPathStencilFuncNV (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glPathStencilDepthOffsetNV (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glStencilFillPathNV (GLuint path, GLenum fillMode, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilStrokePathNV (GLuint path, GLint reference, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glStencilStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glPathCoverDepthFuncNV (GLenum func); +GL_APICALL void GL_APIENTRY glCoverFillPathNV (GLuint path, GLenum coverMode); +GL_APICALL void GL_APIENTRY glCoverStrokePathNV (GLuint path, GLenum coverMode); +GL_APICALL void GL_APIENTRY glCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glGetPathParameterivNV (GLuint path, GLenum pname, GLint *value); +GL_APICALL void GL_APIENTRY glGetPathParameterfvNV (GLuint path, GLenum pname, GLfloat *value); +GL_APICALL void GL_APIENTRY glGetPathCommandsNV (GLuint path, GLubyte *commands); +GL_APICALL void GL_APIENTRY glGetPathCoordsNV (GLuint path, GLfloat *coords); +GL_APICALL void GL_APIENTRY glGetPathDashArrayNV (GLuint path, GLfloat *dashArray); +GL_APICALL void GL_APIENTRY glGetPathMetricsNV (GLbitfield metricQueryMask, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLsizei stride, GLfloat *metrics); +GL_APICALL void GL_APIENTRY glGetPathMetricRangeNV (GLbitfield metricQueryMask, GLuint firstPathName, GLsizei numPaths, GLsizei stride, GLfloat *metrics); +GL_APICALL void GL_APIENTRY glGetPathSpacingNV (GLenum pathListMode, GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLfloat advanceScale, GLfloat kerningScale, GLenum transformType, GLfloat *returnedSpacing); +GL_APICALL GLboolean GL_APIENTRY glIsPointInFillPathNV (GLuint path, GLuint mask, GLfloat x, GLfloat y); +GL_APICALL GLboolean GL_APIENTRY glIsPointInStrokePathNV (GLuint path, GLfloat x, GLfloat y); +GL_APICALL GLfloat GL_APIENTRY glGetPathLengthNV (GLuint path, GLsizei startSegment, GLsizei numSegments); +GL_APICALL GLboolean GL_APIENTRY glPointAlongPathNV (GLuint path, GLsizei startSegment, GLsizei numSegments, GLfloat distance, GLfloat *x, GLfloat *y, GLfloat *tangentX, GLfloat *tangentY); +GL_APICALL void GL_APIENTRY glMatrixLoad3x2fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoad3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoadTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMult3x2fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMult3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultTranspose3x3fNV (GLenum matrixMode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathNV (GLuint path, GLenum fillMode, GLuint mask, GLenum coverMode); +GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathNV (GLuint path, GLint reference, GLuint mask, GLenum coverMode); +GL_APICALL void GL_APIENTRY glStencilThenCoverFillPathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLenum fillMode, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL void GL_APIENTRY glStencilThenCoverStrokePathInstancedNV (GLsizei numPaths, GLenum pathNameType, const void *paths, GLuint pathBase, GLint reference, GLuint mask, GLenum coverMode, GLenum transformType, const GLfloat *transformValues); +GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexRangeNV (GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint pathParameterTemplate, GLfloat emScale, GLuint *baseAndCount); +GL_APICALL GLenum GL_APIENTRY glPathGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, const void *fontName, GLbitfield fontStyle, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL GLenum GL_APIENTRY glPathMemoryGlyphIndexArrayNV (GLuint firstPathName, GLenum fontTarget, GLsizeiptr fontSize, const void *fontData, GLsizei faceIndex, GLuint firstGlyphIndex, GLsizei numGlyphs, GLuint pathParameterTemplate, GLfloat emScale); +GL_APICALL void GL_APIENTRY glProgramPathFragmentInputGenNV (GLuint program, GLint location, GLenum genMode, GLint components, const GLfloat *coeffs); +GL_APICALL void GL_APIENTRY glGetProgramResourcefvNV (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei count, GLsizei *length, GLfloat *params); +GL_APICALL void GL_APIENTRY glMatrixFrustumEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixLoadIdentityEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoadTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixLoadfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixLoaddEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposefEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultTransposedEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixMultfEXT (GLenum mode, const GLfloat *m); +GL_APICALL void GL_APIENTRY glMatrixMultdEXT (GLenum mode, const GLdouble *m); +GL_APICALL void GL_APIENTRY glMatrixOrthoEXT (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); +GL_APICALL void GL_APIENTRY glMatrixPopEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixPushEXT (GLenum mode); +GL_APICALL void GL_APIENTRY glMatrixRotatefEXT (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixRotatedEXT (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixScalefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixScaledEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +GL_APICALL void GL_APIENTRY glMatrixTranslatefEXT (GLenum mode, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glMatrixTranslatedEXT (GLenum mode, GLdouble x, GLdouble y, GLdouble z); +#endif +#endif /* GL_NV_path_rendering */ + +#ifndef GL_NV_path_rendering_shared_edge +#define GL_NV_path_rendering_shared_edge 1 +#define GL_SHARED_EDGE_NV 0xC0 +#endif /* GL_NV_path_rendering_shared_edge */ + +#ifndef GL_NV_pixel_buffer_object +#define GL_NV_pixel_buffer_object 1 +#define GL_PIXEL_PACK_BUFFER_NV 0x88EB +#define GL_PIXEL_UNPACK_BUFFER_NV 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING_NV 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING_NV 0x88EF +#endif /* GL_NV_pixel_buffer_object */ + +#ifndef GL_NV_polygon_mode +#define GL_NV_polygon_mode 1 +#define GL_POLYGON_MODE_NV 0x0B40 +#define GL_POLYGON_OFFSET_POINT_NV 0x2A01 +#define GL_POLYGON_OFFSET_LINE_NV 0x2A02 +#define GL_POINT_NV 0x1B00 +#define GL_LINE_NV 0x1B01 +#define GL_FILL_NV 0x1B02 +typedef void (GL_APIENTRYP PFNGLPOLYGONMODENVPROC) (GLenum face, GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glPolygonModeNV (GLenum face, GLenum mode); +#endif +#endif /* GL_NV_polygon_mode */ + +#ifndef GL_NV_primitive_shading_rate +#define GL_NV_primitive_shading_rate 1 +#define GL_SHADING_RATE_IMAGE_PER_PRIMITIVE_NV 0x95B1 +#define GL_SHADING_RATE_IMAGE_PALETTE_COUNT_NV 0x95B2 +#endif /* GL_NV_primitive_shading_rate */ + +#ifndef GL_NV_read_buffer +#define GL_NV_read_buffer 1 +#define GL_READ_BUFFER_NV 0x0C02 +typedef void (GL_APIENTRYP PFNGLREADBUFFERNVPROC) (GLenum mode); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBufferNV (GLenum mode); +#endif +#endif /* GL_NV_read_buffer */ + +#ifndef GL_NV_read_buffer_front +#define GL_NV_read_buffer_front 1 +#endif /* GL_NV_read_buffer_front */ + +#ifndef GL_NV_read_depth +#define GL_NV_read_depth 1 +#endif /* GL_NV_read_depth */ + +#ifndef GL_NV_read_depth_stencil +#define GL_NV_read_depth_stencil 1 +#endif /* GL_NV_read_depth_stencil */ + +#ifndef GL_NV_read_stencil +#define GL_NV_read_stencil 1 +#endif /* GL_NV_read_stencil */ + +#ifndef GL_NV_representative_fragment_test +#define GL_NV_representative_fragment_test 1 +#define GL_REPRESENTATIVE_FRAGMENT_TEST_NV 0x937F +#endif /* GL_NV_representative_fragment_test */ + +#ifndef GL_NV_sRGB_formats +#define GL_NV_sRGB_formats 1 +#define GL_SLUMINANCE_NV 0x8C46 +#define GL_SLUMINANCE_ALPHA_NV 0x8C44 +#define GL_SRGB8_NV 0x8C41 +#define GL_SLUMINANCE8_NV 0x8C47 +#define GL_SLUMINANCE8_ALPHA8_NV 0x8C45 +#define GL_COMPRESSED_SRGB_S3TC_DXT1_NV 0x8C4C +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_NV 0x8C4D +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_NV 0x8C4E +#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_NV 0x8C4F +#define GL_ETC1_SRGB8_NV 0x88EE +#endif /* GL_NV_sRGB_formats */ + +#ifndef GL_NV_sample_locations +#define GL_NV_sample_locations 1 +#define GL_SAMPLE_LOCATION_SUBPIXEL_BITS_NV 0x933D +#define GL_SAMPLE_LOCATION_PIXEL_GRID_WIDTH_NV 0x933E +#define GL_SAMPLE_LOCATION_PIXEL_GRID_HEIGHT_NV 0x933F +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_TABLE_SIZE_NV 0x9340 +#define GL_SAMPLE_LOCATION_NV 0x8E50 +#define GL_PROGRAMMABLE_SAMPLE_LOCATION_NV 0x9341 +#define GL_FRAMEBUFFER_PROGRAMMABLE_SAMPLE_LOCATIONS_NV 0x9342 +#define GL_FRAMEBUFFER_SAMPLE_LOCATION_PIXEL_GRID_NV 0x9343 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLNAMEDFRAMEBUFFERSAMPLELOCATIONSFVNVPROC) (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLRESOLVEDEPTHVALUESNVPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferSampleLocationsfvNV (GLenum target, GLuint start, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glNamedFramebufferSampleLocationsfvNV (GLuint framebuffer, GLuint start, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glResolveDepthValuesNV (void); +#endif +#endif /* GL_NV_sample_locations */ + +#ifndef GL_NV_sample_mask_override_coverage +#define GL_NV_sample_mask_override_coverage 1 +#endif /* GL_NV_sample_mask_override_coverage */ + +#ifndef GL_NV_scissor_exclusive +#define GL_NV_scissor_exclusive 1 +#define GL_SCISSOR_TEST_EXCLUSIVE_NV 0x9555 +#define GL_SCISSOR_BOX_EXCLUSIVE_NV 0x9556 +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVENVPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSOREXCLUSIVEARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glScissorExclusiveNV (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorExclusiveArrayvNV (GLuint first, GLsizei count, const GLint *v); +#endif +#endif /* GL_NV_scissor_exclusive */ + +#ifndef GL_NV_shader_atomic_fp16_vector +#define GL_NV_shader_atomic_fp16_vector 1 +#endif /* GL_NV_shader_atomic_fp16_vector */ + +#ifndef GL_NV_shader_noperspective_interpolation +#define GL_NV_shader_noperspective_interpolation 1 +#endif /* GL_NV_shader_noperspective_interpolation */ + +#ifndef GL_NV_shader_subgroup_partitioned +#define GL_NV_shader_subgroup_partitioned 1 +#define GL_SUBGROUP_FEATURE_PARTITIONED_BIT_NV 0x00000100 +#endif /* GL_NV_shader_subgroup_partitioned */ + +#ifndef GL_NV_shader_texture_footprint +#define GL_NV_shader_texture_footprint 1 +#endif /* GL_NV_shader_texture_footprint */ + +#ifndef GL_NV_shading_rate_image +#define GL_NV_shading_rate_image 1 +#define GL_SHADING_RATE_IMAGE_NV 0x9563 +#define GL_SHADING_RATE_NO_INVOCATIONS_NV 0x9564 +#define GL_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV 0x9565 +#define GL_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV 0x9566 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV 0x9567 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV 0x9568 +#define GL_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV 0x9569 +#define GL_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV 0x956A +#define GL_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV 0x956B +#define GL_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV 0x956C +#define GL_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV 0x956D +#define GL_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV 0x956E +#define GL_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV 0x956F +#define GL_SHADING_RATE_IMAGE_BINDING_NV 0x955B +#define GL_SHADING_RATE_IMAGE_TEXEL_WIDTH_NV 0x955C +#define GL_SHADING_RATE_IMAGE_TEXEL_HEIGHT_NV 0x955D +#define GL_SHADING_RATE_IMAGE_PALETTE_SIZE_NV 0x955E +#define GL_MAX_COARSE_FRAGMENT_SAMPLES_NV 0x955F +#define GL_SHADING_RATE_SAMPLE_ORDER_DEFAULT_NV 0x95AE +#define GL_SHADING_RATE_SAMPLE_ORDER_PIXEL_MAJOR_NV 0x95AF +#define GL_SHADING_RATE_SAMPLE_ORDER_SAMPLE_MAJOR_NV 0x95B0 +typedef void (GL_APIENTRYP PFNGLBINDSHADINGRATEIMAGENVPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLGETSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint entry, GLenum *rate); +typedef void (GL_APIENTRYP PFNGLGETSHADINGRATESAMPLELOCATIONIVNVPROC) (GLenum rate, GLuint samples, GLuint index, GLint *location); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEBARRIERNVPROC) (GLboolean synchronize); +typedef void (GL_APIENTRYP PFNGLSHADINGRATEIMAGEPALETTENVPROC) (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERNVPROC) (GLenum order); +typedef void (GL_APIENTRYP PFNGLSHADINGRATESAMPLEORDERCUSTOMNVPROC) (GLenum rate, GLuint samples, const GLint *locations); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glBindShadingRateImageNV (GLuint texture); +GL_APICALL void GL_APIENTRY glGetShadingRateImagePaletteNV (GLuint viewport, GLuint entry, GLenum *rate); +GL_APICALL void GL_APIENTRY glGetShadingRateSampleLocationivNV (GLenum rate, GLuint samples, GLuint index, GLint *location); +GL_APICALL void GL_APIENTRY glShadingRateImageBarrierNV (GLboolean synchronize); +GL_APICALL void GL_APIENTRY glShadingRateImagePaletteNV (GLuint viewport, GLuint first, GLsizei count, const GLenum *rates); +GL_APICALL void GL_APIENTRY glShadingRateSampleOrderNV (GLenum order); +GL_APICALL void GL_APIENTRY glShadingRateSampleOrderCustomNV (GLenum rate, GLuint samples, const GLint *locations); +#endif +#endif /* GL_NV_shading_rate_image */ + +#ifndef GL_NV_shadow_samplers_array +#define GL_NV_shadow_samplers_array 1 +#define GL_SAMPLER_2D_ARRAY_SHADOW_NV 0x8DC4 +#endif /* GL_NV_shadow_samplers_array */ + +#ifndef GL_NV_shadow_samplers_cube +#define GL_NV_shadow_samplers_cube 1 +#define GL_SAMPLER_CUBE_SHADOW_NV 0x8DC5 +#endif /* GL_NV_shadow_samplers_cube */ + +#ifndef GL_NV_stereo_view_rendering +#define GL_NV_stereo_view_rendering 1 +#endif /* GL_NV_stereo_view_rendering */ + +#ifndef GL_NV_texture_border_clamp +#define GL_NV_texture_border_clamp 1 +#define GL_TEXTURE_BORDER_COLOR_NV 0x1004 +#define GL_CLAMP_TO_BORDER_NV 0x812D +#endif /* GL_NV_texture_border_clamp */ + +#ifndef GL_NV_texture_compression_s3tc_update +#define GL_NV_texture_compression_s3tc_update 1 +#endif /* GL_NV_texture_compression_s3tc_update */ + +#ifndef GL_NV_texture_npot_2D_mipmap +#define GL_NV_texture_npot_2D_mipmap 1 +#endif /* GL_NV_texture_npot_2D_mipmap */ + +#ifndef GL_NV_timeline_semaphore +#define GL_NV_timeline_semaphore 1 +#define GL_TIMELINE_SEMAPHORE_VALUE_NV 0x9595 +#define GL_SEMAPHORE_TYPE_NV 0x95B3 +#define GL_SEMAPHORE_TYPE_BINARY_NV 0x95B4 +#define GL_SEMAPHORE_TYPE_TIMELINE_NV 0x95B5 +#define GL_MAX_TIMELINE_SEMAPHORE_VALUE_DIFFERENCE_NV 0x95B6 +typedef void (GL_APIENTRYP PFNGLCREATESEMAPHORESNVPROC) (GLsizei n, GLuint *semaphores); +typedef void (GL_APIENTRYP PFNGLSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSEMAPHOREPARAMETERIVNVPROC) (GLuint semaphore, GLenum pname, GLint *params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glCreateSemaphoresNV (GLsizei n, GLuint *semaphores); +GL_APICALL void GL_APIENTRY glSemaphoreParameterivNV (GLuint semaphore, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glGetSemaphoreParameterivNV (GLuint semaphore, GLenum pname, GLint *params); +#endif +#endif /* GL_NV_timeline_semaphore */ + +#ifndef GL_NV_viewport_array +#define GL_NV_viewport_array 1 +#define GL_MAX_VIEWPORTS_NV 0x825B +#define GL_VIEWPORT_SUBPIXEL_BITS_NV 0x825C +#define GL_VIEWPORT_BOUNDS_RANGE_NV 0x825D +#define GL_VIEWPORT_INDEX_PROVOKING_VERTEX_NV 0x825F +typedef void (GL_APIENTRYP PFNGLVIEWPORTARRAYVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +typedef void (GL_APIENTRYP PFNGLVIEWPORTINDEXEDFVNVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLSCISSORARRAYVNVPROC) (GLuint first, GLsizei count, const GLint *v); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDNVPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSCISSORINDEXEDVNVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEARRAYFVNVPROC) (GLuint first, GLsizei count, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEINDEXEDFNVPROC) (GLuint index, GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLGETFLOATI_VNVPROC) (GLenum target, GLuint index, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLENABLEINVPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEINVPROC) (GLenum target, GLuint index); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDINVPROC) (GLenum target, GLuint index); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportArrayvNV (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glViewportIndexedfNV (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h); +GL_APICALL void GL_APIENTRY glViewportIndexedfvNV (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glScissorArrayvNV (GLuint first, GLsizei count, const GLint *v); +GL_APICALL void GL_APIENTRY glScissorIndexedNV (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glScissorIndexedvNV (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glDepthRangeArrayfvNV (GLuint first, GLsizei count, const GLfloat *v); +GL_APICALL void GL_APIENTRY glDepthRangeIndexedfNV (GLuint index, GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glGetFloati_vNV (GLenum target, GLuint index, GLfloat *data); +GL_APICALL void GL_APIENTRY glEnableiNV (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisableiNV (GLenum target, GLuint index); +GL_APICALL GLboolean GL_APIENTRY glIsEnablediNV (GLenum target, GLuint index); +#endif +#endif /* GL_NV_viewport_array */ + +#ifndef GL_NV_viewport_array2 +#define GL_NV_viewport_array2 1 +#endif /* GL_NV_viewport_array2 */ + +#ifndef GL_NV_viewport_swizzle +#define GL_NV_viewport_swizzle 1 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_X_NV 0x9350 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_X_NV 0x9351 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Y_NV 0x9352 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Y_NV 0x9353 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_Z_NV 0x9354 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_Z_NV 0x9355 +#define GL_VIEWPORT_SWIZZLE_POSITIVE_W_NV 0x9356 +#define GL_VIEWPORT_SWIZZLE_NEGATIVE_W_NV 0x9357 +#define GL_VIEWPORT_SWIZZLE_X_NV 0x9358 +#define GL_VIEWPORT_SWIZZLE_Y_NV 0x9359 +#define GL_VIEWPORT_SWIZZLE_Z_NV 0x935A +#define GL_VIEWPORT_SWIZZLE_W_NV 0x935B +typedef void (GL_APIENTRYP PFNGLVIEWPORTSWIZZLENVPROC) (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glViewportSwizzleNV (GLuint index, GLenum swizzlex, GLenum swizzley, GLenum swizzlez, GLenum swizzlew); +#endif +#endif /* GL_NV_viewport_swizzle */ + +#ifndef GL_OVR_multiview +#define GL_OVR_multiview 1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR 0x9630 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR 0x9632 +#define GL_MAX_VIEWS_OVR 0x9631 +#define GL_FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR 0x9633 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview */ + +#ifndef GL_OVR_multiview2 +#define GL_OVR_multiview2 1 +#endif /* GL_OVR_multiview2 */ + +#ifndef GL_OVR_multiview_multisampled_render_to_texture +#define GL_OVR_multiview_multisampled_render_to_texture 1 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREMULTISAMPLEMULTIVIEWOVRPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferTextureMultisampleMultiviewOVR (GLenum target, GLenum attachment, GLuint texture, GLint level, GLsizei samples, GLint baseViewIndex, GLsizei numViews); +#endif +#endif /* GL_OVR_multiview_multisampled_render_to_texture */ + +#ifndef GL_QCOM_YUV_texture_gather +#define GL_QCOM_YUV_texture_gather 1 +#endif /* GL_QCOM_YUV_texture_gather */ + +#ifndef GL_QCOM_alpha_test +#define GL_QCOM_alpha_test 1 +#define GL_ALPHA_TEST_QCOM 0x0BC0 +#define GL_ALPHA_TEST_FUNC_QCOM 0x0BC1 +#define GL_ALPHA_TEST_REF_QCOM 0x0BC2 +typedef void (GL_APIENTRYP PFNGLALPHAFUNCQCOMPROC) (GLenum func, GLclampf ref); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glAlphaFuncQCOM (GLenum func, GLclampf ref); +#endif +#endif /* GL_QCOM_alpha_test */ + +#ifndef GL_QCOM_binning_control +#define GL_QCOM_binning_control 1 +#define GL_BINNING_CONTROL_HINT_QCOM 0x8FB0 +#define GL_CPU_OPTIMIZED_QCOM 0x8FB1 +#define GL_GPU_OPTIMIZED_QCOM 0x8FB2 +#define GL_RENDER_DIRECT_TO_FRAMEBUFFER_QCOM 0x8FB3 +#endif /* GL_QCOM_binning_control */ + +#ifndef GL_QCOM_driver_control +#define GL_QCOM_driver_control 1 +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); +typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); +GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, GLchar *driverControlString); +GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); +GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); +#endif +#endif /* GL_QCOM_driver_control */ + +#ifndef GL_QCOM_extended_get +#define GL_QCOM_extended_get 1 +#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 +#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 +#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 +#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 +#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 +#define GL_TEXTURE_TYPE_QCOM 0x8BD7 +#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 +#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 +#define GL_TEXTURE_TARGET_QCOM 0x8BDA +#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB +#define GL_STATE_RESTORE 0x8BDC +typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); +typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, void **params); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); +GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); +GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); +GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); +GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, void *texels); +GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, void **params); +#endif +#endif /* GL_QCOM_extended_get */ + +#ifndef GL_QCOM_extended_get2 +#define GL_QCOM_extended_get2 1 +typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); +GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); +GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); +GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, GLchar *source, GLint *length); +#endif +#endif /* GL_QCOM_extended_get2 */ + +#ifndef GL_QCOM_frame_extrapolation +#define GL_QCOM_frame_extrapolation 1 +typedef void (GL_APIENTRYP PFNGLEXTRAPOLATETEX2DQCOMPROC) (GLuint src1, GLuint src2, GLuint output, GLfloat scaleFactor); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glExtrapolateTex2DQCOM (GLuint src1, GLuint src2, GLuint output, GLfloat scaleFactor); +#endif +#endif /* GL_QCOM_frame_extrapolation */ + +#ifndef GL_QCOM_framebuffer_foveated +#define GL_QCOM_framebuffer_foveated 1 +#define GL_FOVEATION_ENABLE_BIT_QCOM 0x00000001 +#define GL_FOVEATION_SCALED_BIN_METHOD_BIT_QCOM 0x00000002 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONCONFIGQCOMPROC) (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFOVEATIONPARAMETERSQCOMPROC) (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFoveationConfigQCOM (GLuint framebuffer, GLuint numLayers, GLuint focalPointsPerLayer, GLuint requestedFeatures, GLuint *providedFeatures); +GL_APICALL void GL_APIENTRY glFramebufferFoveationParametersQCOM (GLuint framebuffer, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#endif +#endif /* GL_QCOM_framebuffer_foveated */ + +#ifndef GL_QCOM_motion_estimation +#define GL_QCOM_motion_estimation 1 +#define GL_MOTION_ESTIMATION_SEARCH_BLOCK_X_QCOM 0x8C90 +#define GL_MOTION_ESTIMATION_SEARCH_BLOCK_Y_QCOM 0x8C91 +typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONQCOMPROC) (GLuint ref, GLuint target, GLuint output); +typedef void (GL_APIENTRYP PFNGLTEXESTIMATEMOTIONREGIONSQCOMPROC) (GLuint ref, GLuint target, GLuint output, GLuint mask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTexEstimateMotionQCOM (GLuint ref, GLuint target, GLuint output); +GL_APICALL void GL_APIENTRY glTexEstimateMotionRegionsQCOM (GLuint ref, GLuint target, GLuint output, GLuint mask); +#endif +#endif /* GL_QCOM_motion_estimation */ + +#ifndef GL_QCOM_perfmon_global_mode +#define GL_QCOM_perfmon_global_mode 1 +#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 +#endif /* GL_QCOM_perfmon_global_mode */ + +#ifndef GL_QCOM_render_sRGB_R8_RG8 +#define GL_QCOM_render_sRGB_R8_RG8 1 +#endif /* GL_QCOM_render_sRGB_R8_RG8 */ + +#ifndef GL_QCOM_render_shared_exponent +#define GL_QCOM_render_shared_exponent 1 +#endif /* GL_QCOM_render_shared_exponent */ + +#ifndef GL_QCOM_shader_framebuffer_fetch_noncoherent +#define GL_QCOM_shader_framebuffer_fetch_noncoherent 1 +#define GL_FRAMEBUFFER_FETCH_NONCOHERENT_QCOM 0x96A2 +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERFETCHBARRIERQCOMPROC) (void); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glFramebufferFetchBarrierQCOM (void); +#endif +#endif /* GL_QCOM_shader_framebuffer_fetch_noncoherent */ + +#ifndef GL_QCOM_shader_framebuffer_fetch_rate +#define GL_QCOM_shader_framebuffer_fetch_rate 1 +#endif /* GL_QCOM_shader_framebuffer_fetch_rate */ + +#ifndef GL_QCOM_shading_rate +#define GL_QCOM_shading_rate 1 +#define GL_SHADING_RATE_QCOM 0x96A4 +#define GL_SHADING_RATE_PRESERVE_ASPECT_RATIO_QCOM 0x96A5 +#define GL_SHADING_RATE_1X1_PIXELS_QCOM 0x96A6 +#define GL_SHADING_RATE_1X2_PIXELS_QCOM 0x96A7 +#define GL_SHADING_RATE_2X1_PIXELS_QCOM 0x96A8 +#define GL_SHADING_RATE_2X2_PIXELS_QCOM 0x96A9 +#define GL_SHADING_RATE_4X2_PIXELS_QCOM 0x96AC +#define GL_SHADING_RATE_4X4_PIXELS_QCOM 0x96AE +typedef void (GL_APIENTRYP PFNGLSHADINGRATEQCOMPROC) (GLenum rate); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glShadingRateQCOM (GLenum rate); +#endif +#endif /* GL_QCOM_shading_rate */ + +#ifndef GL_QCOM_texture_foveated +#define GL_QCOM_texture_foveated 1 +#define GL_TEXTURE_FOVEATED_FEATURE_BITS_QCOM 0x8BFB +#define GL_TEXTURE_FOVEATED_MIN_PIXEL_DENSITY_QCOM 0x8BFC +#define GL_TEXTURE_FOVEATED_FEATURE_QUERY_QCOM 0x8BFD +#define GL_TEXTURE_FOVEATED_NUM_FOCAL_POINTS_QUERY_QCOM 0x8BFE +#define GL_FRAMEBUFFER_INCOMPLETE_FOVEATION_QCOM 0x8BFF +typedef void (GL_APIENTRYP PFNGLTEXTUREFOVEATIONPARAMETERSQCOMPROC) (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glTextureFoveationParametersQCOM (GLuint texture, GLuint layer, GLuint focalPoint, GLfloat focalX, GLfloat focalY, GLfloat gainX, GLfloat gainY, GLfloat foveaArea); +#endif +#endif /* GL_QCOM_texture_foveated */ + +#ifndef GL_QCOM_texture_foveated2 +#define GL_QCOM_texture_foveated2 1 +#define GL_TEXTURE_FOVEATED_CUTOFF_DENSITY_QCOM 0x96A0 +#endif /* GL_QCOM_texture_foveated2 */ + +#ifndef GL_QCOM_texture_foveated_subsampled_layout +#define GL_QCOM_texture_foveated_subsampled_layout 1 +#define GL_FOVEATION_SUBSAMPLED_LAYOUT_METHOD_BIT_QCOM 0x00000004 +#define GL_MAX_SHADER_SUBSAMPLED_IMAGE_UNITS_QCOM 0x8FA1 +#endif /* GL_QCOM_texture_foveated_subsampled_layout */ + +#ifndef GL_QCOM_texture_lod_bias +#define GL_QCOM_texture_lod_bias 1 +#define GL_TEXTURE_LOD_BIAS_QCOM 0x8C96 +#endif /* GL_QCOM_texture_lod_bias */ + +#ifndef GL_QCOM_tiled_rendering +#define GL_QCOM_tiled_rendering 1 +#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 +#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 +#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 +#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 +#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 +#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 +#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 +#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 +#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 +#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 +#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 +#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 +#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 +#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 +#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 +#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 +#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 +#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 +#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 +#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 +#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 +#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 +#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 +#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 +#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 +#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 +#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 +#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 +#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 +#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 +#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 +#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 +typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); +#ifdef GL_GLEXT_PROTOTYPES +GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); +GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); +#endif +#endif /* GL_QCOM_tiled_rendering */ + +#ifndef GL_QCOM_writeonly_rendering +#define GL_QCOM_writeonly_rendering 1 +#define GL_WRITEONLY_RENDERING_QCOM 0x8823 +#endif /* GL_QCOM_writeonly_rendering */ + +#ifndef GL_VIV_shader_binary +#define GL_VIV_shader_binary 1 +#define GL_SHADER_BINARY_VIV 0x8FC4 +#endif /* GL_VIV_shader_binary */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2platform.h b/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2platform.h new file mode 100644 index 0000000..5bcce6d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/GLES2/gl2platform.h @@ -0,0 +1,27 @@ +#ifndef __gl2platform_h_ +#define __gl2platform_h_ + +/* +** Copyright 2017-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * Please contribute modifications back to Khronos as pull requests on the + * public github repository: + * https://github.com/KhronosGroup/OpenGL-Registry + */ + +#include + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl2platform_h_ */ diff --git a/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3.h b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3.h new file mode 100644 index 0000000..850eb83 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3.h @@ -0,0 +1,1192 @@ +#ifndef __gles2_gl3_h_ +#define __gles2_gl3_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#include + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20240815 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9]|3\.0 + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +#include +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum src); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void *GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte *GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei count, GLsizei *length, GLint *values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei count, GLint *params); +#endif +#endif /* GL_ES_VERSION_3_0 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl31.h b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl31.h new file mode 100644 index 0000000..502d6fe --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl31.h @@ -0,0 +1,1507 @@ +#ifndef __gles2_gl31_h_ +#define __gles2_gl31_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#include + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20191013 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9]|3\.[01] + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +#include +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum src); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void *GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte *GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_ES_VERSION_3_0 */ + +#ifndef GL_ES_VERSION_3_1 +#define GL_ES_VERSION_3_1 1 +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_STENCIL_INDEX 0x1901 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (GL_APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (GL_APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (GL_APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GL_APICALL void GL_APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GL_APICALL void GL_APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GL_APICALL void GL_APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GL_APICALL void GL_APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GL_APICALL void GL_APIENTRY glBindProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glValidateProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GL_APICALL void GL_APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GL_APICALL void GL_APIENTRY glMemoryBarrier (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GL_APICALL void GL_APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GL_APICALL void GL_APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +GL_APICALL void GL_APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GL_APICALL void GL_APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GL_APICALL void GL_APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ES_VERSION_3_1 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl32.h b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl32.h new file mode 100644 index 0000000..ae56b0e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl32.h @@ -0,0 +1,1808 @@ +#ifndef __gles2_gl32_h_ +#define __gles2_gl32_h_ 1 + +#ifdef __cplusplus +extern "C" { +#endif + +/* +** Copyright 2013-2020 The Khronos Group Inc. +** SPDX-License-Identifier: MIT +** +** This header is generated from the Khronos OpenGL / OpenGL ES XML +** API Registry. The current version of the Registry, generator scripts +** used to make the header, and the header can be found at +** https://github.com/KhronosGroup/OpenGL-Registry +*/ + +#include + +#ifndef GL_APIENTRYP +#define GL_APIENTRYP GL_APIENTRY* +#endif + +#ifndef GL_GLES_PROTOTYPES +#define GL_GLES_PROTOTYPES 1 +#endif + +/* Generated on date 20191013 */ + +/* Generated C header for: + * API: gles2 + * Profile: common + * Versions considered: 2\.[0-9]|3\.[012] + * Versions emitted: .* + * Default extensions included: None + * Additional extensions included: _nomatch_^ + * Extensions removed: _nomatch_^ + */ + +#ifndef GL_ES_VERSION_2_0 +#define GL_ES_VERSION_2_0 1 +#include +typedef khronos_int8_t GLbyte; +typedef khronos_float_t GLclampf; +typedef khronos_int32_t GLfixed; +typedef khronos_int16_t GLshort; +typedef khronos_uint16_t GLushort; +typedef void GLvoid; +typedef struct __GLsync *GLsync; +typedef khronos_int64_t GLint64; +typedef khronos_uint64_t GLuint64; +typedef unsigned int GLenum; +typedef unsigned int GLuint; +typedef char GLchar; +typedef khronos_float_t GLfloat; +typedef khronos_ssize_t GLsizeiptr; +typedef khronos_intptr_t GLintptr; +typedef unsigned int GLbitfield; +typedef int GLint; +typedef unsigned char GLboolean; +typedef int GLsizei; +typedef khronos_uint8_t GLubyte; +#define GL_DEPTH_BUFFER_BIT 0x00000100 +#define GL_STENCIL_BUFFER_BIT 0x00000400 +#define GL_COLOR_BUFFER_BIT 0x00004000 +#define GL_FALSE 0 +#define GL_TRUE 1 +#define GL_POINTS 0x0000 +#define GL_LINES 0x0001 +#define GL_LINE_LOOP 0x0002 +#define GL_LINE_STRIP 0x0003 +#define GL_TRIANGLES 0x0004 +#define GL_TRIANGLE_STRIP 0x0005 +#define GL_TRIANGLE_FAN 0x0006 +#define GL_ZERO 0 +#define GL_ONE 1 +#define GL_SRC_COLOR 0x0300 +#define GL_ONE_MINUS_SRC_COLOR 0x0301 +#define GL_SRC_ALPHA 0x0302 +#define GL_ONE_MINUS_SRC_ALPHA 0x0303 +#define GL_DST_ALPHA 0x0304 +#define GL_ONE_MINUS_DST_ALPHA 0x0305 +#define GL_DST_COLOR 0x0306 +#define GL_ONE_MINUS_DST_COLOR 0x0307 +#define GL_SRC_ALPHA_SATURATE 0x0308 +#define GL_FUNC_ADD 0x8006 +#define GL_BLEND_EQUATION 0x8009 +#define GL_BLEND_EQUATION_RGB 0x8009 +#define GL_BLEND_EQUATION_ALPHA 0x883D +#define GL_FUNC_SUBTRACT 0x800A +#define GL_FUNC_REVERSE_SUBTRACT 0x800B +#define GL_BLEND_DST_RGB 0x80C8 +#define GL_BLEND_SRC_RGB 0x80C9 +#define GL_BLEND_DST_ALPHA 0x80CA +#define GL_BLEND_SRC_ALPHA 0x80CB +#define GL_CONSTANT_COLOR 0x8001 +#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 +#define GL_CONSTANT_ALPHA 0x8003 +#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 +#define GL_BLEND_COLOR 0x8005 +#define GL_ARRAY_BUFFER 0x8892 +#define GL_ELEMENT_ARRAY_BUFFER 0x8893 +#define GL_ARRAY_BUFFER_BINDING 0x8894 +#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 +#define GL_STREAM_DRAW 0x88E0 +#define GL_STATIC_DRAW 0x88E4 +#define GL_DYNAMIC_DRAW 0x88E8 +#define GL_BUFFER_SIZE 0x8764 +#define GL_BUFFER_USAGE 0x8765 +#define GL_CURRENT_VERTEX_ATTRIB 0x8626 +#define GL_FRONT 0x0404 +#define GL_BACK 0x0405 +#define GL_FRONT_AND_BACK 0x0408 +#define GL_TEXTURE_2D 0x0DE1 +#define GL_CULL_FACE 0x0B44 +#define GL_BLEND 0x0BE2 +#define GL_DITHER 0x0BD0 +#define GL_STENCIL_TEST 0x0B90 +#define GL_DEPTH_TEST 0x0B71 +#define GL_SCISSOR_TEST 0x0C11 +#define GL_POLYGON_OFFSET_FILL 0x8037 +#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E +#define GL_SAMPLE_COVERAGE 0x80A0 +#define GL_NO_ERROR 0 +#define GL_INVALID_ENUM 0x0500 +#define GL_INVALID_VALUE 0x0501 +#define GL_INVALID_OPERATION 0x0502 +#define GL_OUT_OF_MEMORY 0x0505 +#define GL_CW 0x0900 +#define GL_CCW 0x0901 +#define GL_LINE_WIDTH 0x0B21 +#define GL_ALIASED_POINT_SIZE_RANGE 0x846D +#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E +#define GL_CULL_FACE_MODE 0x0B45 +#define GL_FRONT_FACE 0x0B46 +#define GL_DEPTH_RANGE 0x0B70 +#define GL_DEPTH_WRITEMASK 0x0B72 +#define GL_DEPTH_CLEAR_VALUE 0x0B73 +#define GL_DEPTH_FUNC 0x0B74 +#define GL_STENCIL_CLEAR_VALUE 0x0B91 +#define GL_STENCIL_FUNC 0x0B92 +#define GL_STENCIL_FAIL 0x0B94 +#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 +#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 +#define GL_STENCIL_REF 0x0B97 +#define GL_STENCIL_VALUE_MASK 0x0B93 +#define GL_STENCIL_WRITEMASK 0x0B98 +#define GL_STENCIL_BACK_FUNC 0x8800 +#define GL_STENCIL_BACK_FAIL 0x8801 +#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 +#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 +#define GL_STENCIL_BACK_REF 0x8CA3 +#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 +#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 +#define GL_VIEWPORT 0x0BA2 +#define GL_SCISSOR_BOX 0x0C10 +#define GL_COLOR_CLEAR_VALUE 0x0C22 +#define GL_COLOR_WRITEMASK 0x0C23 +#define GL_UNPACK_ALIGNMENT 0x0CF5 +#define GL_PACK_ALIGNMENT 0x0D05 +#define GL_MAX_TEXTURE_SIZE 0x0D33 +#define GL_MAX_VIEWPORT_DIMS 0x0D3A +#define GL_SUBPIXEL_BITS 0x0D50 +#define GL_RED_BITS 0x0D52 +#define GL_GREEN_BITS 0x0D53 +#define GL_BLUE_BITS 0x0D54 +#define GL_ALPHA_BITS 0x0D55 +#define GL_DEPTH_BITS 0x0D56 +#define GL_STENCIL_BITS 0x0D57 +#define GL_POLYGON_OFFSET_UNITS 0x2A00 +#define GL_POLYGON_OFFSET_FACTOR 0x8038 +#define GL_TEXTURE_BINDING_2D 0x8069 +#define GL_SAMPLE_BUFFERS 0x80A8 +#define GL_SAMPLES 0x80A9 +#define GL_SAMPLE_COVERAGE_VALUE 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT 0x80AB +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 +#define GL_DONT_CARE 0x1100 +#define GL_FASTEST 0x1101 +#define GL_NICEST 0x1102 +#define GL_GENERATE_MIPMAP_HINT 0x8192 +#define GL_BYTE 0x1400 +#define GL_UNSIGNED_BYTE 0x1401 +#define GL_SHORT 0x1402 +#define GL_UNSIGNED_SHORT 0x1403 +#define GL_INT 0x1404 +#define GL_UNSIGNED_INT 0x1405 +#define GL_FLOAT 0x1406 +#define GL_FIXED 0x140C +#define GL_DEPTH_COMPONENT 0x1902 +#define GL_ALPHA 0x1906 +#define GL_RGB 0x1907 +#define GL_RGBA 0x1908 +#define GL_LUMINANCE 0x1909 +#define GL_LUMINANCE_ALPHA 0x190A +#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 +#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 +#define GL_UNSIGNED_SHORT_5_6_5 0x8363 +#define GL_FRAGMENT_SHADER 0x8B30 +#define GL_VERTEX_SHADER 0x8B31 +#define GL_MAX_VERTEX_ATTRIBS 0x8869 +#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB +#define GL_MAX_VARYING_VECTORS 0x8DFC +#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D +#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C +#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 +#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD +#define GL_SHADER_TYPE 0x8B4F +#define GL_DELETE_STATUS 0x8B80 +#define GL_LINK_STATUS 0x8B82 +#define GL_VALIDATE_STATUS 0x8B83 +#define GL_ATTACHED_SHADERS 0x8B85 +#define GL_ACTIVE_UNIFORMS 0x8B86 +#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 +#define GL_ACTIVE_ATTRIBUTES 0x8B89 +#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A +#define GL_SHADING_LANGUAGE_VERSION 0x8B8C +#define GL_CURRENT_PROGRAM 0x8B8D +#define GL_NEVER 0x0200 +#define GL_LESS 0x0201 +#define GL_EQUAL 0x0202 +#define GL_LEQUAL 0x0203 +#define GL_GREATER 0x0204 +#define GL_NOTEQUAL 0x0205 +#define GL_GEQUAL 0x0206 +#define GL_ALWAYS 0x0207 +#define GL_KEEP 0x1E00 +#define GL_REPLACE 0x1E01 +#define GL_INCR 0x1E02 +#define GL_DECR 0x1E03 +#define GL_INVERT 0x150A +#define GL_INCR_WRAP 0x8507 +#define GL_DECR_WRAP 0x8508 +#define GL_VENDOR 0x1F00 +#define GL_RENDERER 0x1F01 +#define GL_VERSION 0x1F02 +#define GL_EXTENSIONS 0x1F03 +#define GL_NEAREST 0x2600 +#define GL_LINEAR 0x2601 +#define GL_NEAREST_MIPMAP_NEAREST 0x2700 +#define GL_LINEAR_MIPMAP_NEAREST 0x2701 +#define GL_NEAREST_MIPMAP_LINEAR 0x2702 +#define GL_LINEAR_MIPMAP_LINEAR 0x2703 +#define GL_TEXTURE_MAG_FILTER 0x2800 +#define GL_TEXTURE_MIN_FILTER 0x2801 +#define GL_TEXTURE_WRAP_S 0x2802 +#define GL_TEXTURE_WRAP_T 0x2803 +#define GL_TEXTURE 0x1702 +#define GL_TEXTURE_CUBE_MAP 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C +#define GL_TEXTURE0 0x84C0 +#define GL_TEXTURE1 0x84C1 +#define GL_TEXTURE2 0x84C2 +#define GL_TEXTURE3 0x84C3 +#define GL_TEXTURE4 0x84C4 +#define GL_TEXTURE5 0x84C5 +#define GL_TEXTURE6 0x84C6 +#define GL_TEXTURE7 0x84C7 +#define GL_TEXTURE8 0x84C8 +#define GL_TEXTURE9 0x84C9 +#define GL_TEXTURE10 0x84CA +#define GL_TEXTURE11 0x84CB +#define GL_TEXTURE12 0x84CC +#define GL_TEXTURE13 0x84CD +#define GL_TEXTURE14 0x84CE +#define GL_TEXTURE15 0x84CF +#define GL_TEXTURE16 0x84D0 +#define GL_TEXTURE17 0x84D1 +#define GL_TEXTURE18 0x84D2 +#define GL_TEXTURE19 0x84D3 +#define GL_TEXTURE20 0x84D4 +#define GL_TEXTURE21 0x84D5 +#define GL_TEXTURE22 0x84D6 +#define GL_TEXTURE23 0x84D7 +#define GL_TEXTURE24 0x84D8 +#define GL_TEXTURE25 0x84D9 +#define GL_TEXTURE26 0x84DA +#define GL_TEXTURE27 0x84DB +#define GL_TEXTURE28 0x84DC +#define GL_TEXTURE29 0x84DD +#define GL_TEXTURE30 0x84DE +#define GL_TEXTURE31 0x84DF +#define GL_ACTIVE_TEXTURE 0x84E0 +#define GL_REPEAT 0x2901 +#define GL_CLAMP_TO_EDGE 0x812F +#define GL_MIRRORED_REPEAT 0x8370 +#define GL_FLOAT_VEC2 0x8B50 +#define GL_FLOAT_VEC3 0x8B51 +#define GL_FLOAT_VEC4 0x8B52 +#define GL_INT_VEC2 0x8B53 +#define GL_INT_VEC3 0x8B54 +#define GL_INT_VEC4 0x8B55 +#define GL_BOOL 0x8B56 +#define GL_BOOL_VEC2 0x8B57 +#define GL_BOOL_VEC3 0x8B58 +#define GL_BOOL_VEC4 0x8B59 +#define GL_FLOAT_MAT2 0x8B5A +#define GL_FLOAT_MAT3 0x8B5B +#define GL_FLOAT_MAT4 0x8B5C +#define GL_SAMPLER_2D 0x8B5E +#define GL_SAMPLER_CUBE 0x8B60 +#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 +#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 +#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 +#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 +#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A +#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 +#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F +#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A +#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B +#define GL_COMPILE_STATUS 0x8B81 +#define GL_INFO_LOG_LENGTH 0x8B84 +#define GL_SHADER_SOURCE_LENGTH 0x8B88 +#define GL_SHADER_COMPILER 0x8DFA +#define GL_SHADER_BINARY_FORMATS 0x8DF8 +#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 +#define GL_LOW_FLOAT 0x8DF0 +#define GL_MEDIUM_FLOAT 0x8DF1 +#define GL_HIGH_FLOAT 0x8DF2 +#define GL_LOW_INT 0x8DF3 +#define GL_MEDIUM_INT 0x8DF4 +#define GL_HIGH_INT 0x8DF5 +#define GL_FRAMEBUFFER 0x8D40 +#define GL_RENDERBUFFER 0x8D41 +#define GL_RGBA4 0x8056 +#define GL_RGB5_A1 0x8057 +#define GL_RGB565 0x8D62 +#define GL_DEPTH_COMPONENT16 0x81A5 +#define GL_STENCIL_INDEX8 0x8D48 +#define GL_RENDERBUFFER_WIDTH 0x8D42 +#define GL_RENDERBUFFER_HEIGHT 0x8D43 +#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 +#define GL_RENDERBUFFER_RED_SIZE 0x8D50 +#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 +#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 +#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 +#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 +#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 +#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 +#define GL_COLOR_ATTACHMENT0 0x8CE0 +#define GL_DEPTH_ATTACHMENT 0x8D00 +#define GL_STENCIL_ATTACHMENT 0x8D20 +#define GL_NONE 0 +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 +#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 +#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 +#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_RENDERBUFFER_BINDING 0x8CA7 +#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 +#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 +typedef void (GL_APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture); +typedef void (GL_APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer); +typedef void (GL_APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture); +typedef void (GL_APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCPROC) (GLenum sfactor, GLenum dfactor); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +typedef void (GL_APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +typedef void (GL_APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +typedef GLenum (GL_APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLCLEARPROC) (GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +typedef void (GL_APIENTRYP PFNGLCLEARDEPTHFPROC) (GLfloat d); +typedef void (GL_APIENTRYP PFNGLCLEARSTENCILPROC) (GLint s); +typedef void (GL_APIENTRYP PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +typedef void (GL_APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef GLuint (GL_APIENTRYP PFNGLCREATEPROGRAMPROC) (void); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROC) (GLenum type); +typedef void (GL_APIENTRYP PFNGLCULLFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader); +typedef void (GL_APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures); +typedef void (GL_APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func); +typedef void (GL_APIENTRYP PFNGLDEPTHMASKPROC) (GLboolean flag); +typedef void (GL_APIENTRYP PFNGLDEPTHRANGEFPROC) (GLfloat n, GLfloat f); +typedef void (GL_APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader); +typedef void (GL_APIENTRYP PFNGLDISABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLENABLEPROC) (GLenum cap); +typedef void (GL_APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index); +typedef void (GL_APIENTRYP PFNGLFINISHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFLUSHPROC) (void); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode); +typedef void (GL_APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers); +typedef void (GL_APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers); +typedef void (GL_APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers); +typedef void (GL_APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures); +typedef void (GL_APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +typedef GLint (GL_APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef GLenum (GL_APIENTRYP PFNGLGETERRORPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETFLOATVPROC) (GLenum pname, GLfloat *data); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETINTEGERVPROC) (GLenum pname, GLint *data); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLGETSHADERPRECISIONFORMATPROC) (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +typedef void (GL_APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGPROC) (GLenum name); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, void **pointer); +typedef void (GL_APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode); +typedef GLboolean (GL_APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDPROC) (GLenum cap); +typedef GLboolean (GL_APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPROC) (GLuint program); +typedef GLboolean (GL_APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer); +typedef GLboolean (GL_APIENTRYP PFNGLISSHADERPROC) (GLuint shader); +typedef GLboolean (GL_APIENTRYP PFNGLISTEXTUREPROC) (GLuint texture); +typedef void (GL_APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width); +typedef void (GL_APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units); +typedef void (GL_APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +typedef void (GL_APIENTRYP PFNGLRELEASESHADERCOMPILERPROC) (void); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert); +typedef void (GL_APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLSHADERBINARYPROC) (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCPROC) (GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum face, GLenum func, GLint ref, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKPROC) (GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask); +typedef void (GL_APIENTRYP PFNGLSTENCILOPPROC) (GLenum fail, GLenum zfail, GLenum zpass); +typedef void (GL_APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); +GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar *name); +GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); +GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); +GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); +GL_APICALL void GL_APIENTRY glBlendColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glBlendEquation (GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); +GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); +GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const void *data, GLenum usage); +GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const void *data); +GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); +GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); +GL_APICALL void GL_APIENTRY glClearColor (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GL_APICALL void GL_APIENTRY glClearDepthf (GLfloat d); +GL_APICALL void GL_APIENTRY glClearStencil (GLint s); +GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); +GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); +GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); +GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); +GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); +GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint *buffers); +GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); +GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); +GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint *textures); +GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); +GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); +GL_APICALL void GL_APIENTRY glDepthRangef (GLfloat n, GLfloat f); +GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); +GL_APICALL void GL_APIENTRY glDisable (GLenum cap); +GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); +GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glEnable (GLenum cap); +GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); +GL_APICALL void GL_APIENTRY glFinish (void); +GL_APICALL void GL_APIENTRY glFlush (void); +GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); +GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint *buffers); +GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); +GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint *framebuffers); +GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint *renderbuffers); +GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint *textures); +GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *shaders); +GL_APICALL GLint GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL GLenum GL_APIENTRY glGetError (void); +GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat *data); +GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint *data); +GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint *range, GLint *precision); +GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source); +GL_APICALL const GLubyte *GL_APIENTRY glGetString (GLenum name); +GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, void **pointer); +GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); +GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); +GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); +GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); +GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); +GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); +GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); +GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); +GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); +GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); +GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); +GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void *pixels); +GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); +GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glSampleCoverage (GLfloat value, GLboolean invert); +GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei count, const GLuint *shaders, GLenum binaryformat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar *const*string, const GLint *length); +GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); +GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); +GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); +GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass); +GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat *params); +GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); +GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); +GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint index, GLfloat x); +GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint index, GLfloat x, GLfloat y); +GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint index, GLfloat x, GLfloat y, GLfloat z); +GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint index, const GLfloat *v); +GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); +#endif +#endif /* GL_ES_VERSION_2_0 */ + +#ifndef GL_ES_VERSION_3_0 +#define GL_ES_VERSION_3_0 1 +typedef khronos_uint16_t GLhalf; +#define GL_READ_BUFFER 0x0C02 +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#define GL_UNPACK_SKIP_ROWS 0x0CF3 +#define GL_UNPACK_SKIP_PIXELS 0x0CF4 +#define GL_PACK_ROW_LENGTH 0x0D02 +#define GL_PACK_SKIP_ROWS 0x0D03 +#define GL_PACK_SKIP_PIXELS 0x0D04 +#define GL_COLOR 0x1800 +#define GL_DEPTH 0x1801 +#define GL_STENCIL 0x1802 +#define GL_RED 0x1903 +#define GL_RGB8 0x8051 +#define GL_RGBA8 0x8058 +#define GL_RGB10_A2 0x8059 +#define GL_TEXTURE_BINDING_3D 0x806A +#define GL_UNPACK_SKIP_IMAGES 0x806D +#define GL_UNPACK_IMAGE_HEIGHT 0x806E +#define GL_TEXTURE_3D 0x806F +#define GL_TEXTURE_WRAP_R 0x8072 +#define GL_MAX_3D_TEXTURE_SIZE 0x8073 +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 +#define GL_MAX_ELEMENTS_VERTICES 0x80E8 +#define GL_MAX_ELEMENTS_INDICES 0x80E9 +#define GL_TEXTURE_MIN_LOD 0x813A +#define GL_TEXTURE_MAX_LOD 0x813B +#define GL_TEXTURE_BASE_LEVEL 0x813C +#define GL_TEXTURE_MAX_LEVEL 0x813D +#define GL_MIN 0x8007 +#define GL_MAX 0x8008 +#define GL_DEPTH_COMPONENT24 0x81A6 +#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD +#define GL_TEXTURE_COMPARE_MODE 0x884C +#define GL_TEXTURE_COMPARE_FUNC 0x884D +#define GL_CURRENT_QUERY 0x8865 +#define GL_QUERY_RESULT 0x8866 +#define GL_QUERY_RESULT_AVAILABLE 0x8867 +#define GL_BUFFER_MAPPED 0x88BC +#define GL_BUFFER_MAP_POINTER 0x88BD +#define GL_STREAM_READ 0x88E1 +#define GL_STREAM_COPY 0x88E2 +#define GL_STATIC_READ 0x88E5 +#define GL_STATIC_COPY 0x88E6 +#define GL_DYNAMIC_READ 0x88E9 +#define GL_DYNAMIC_COPY 0x88EA +#define GL_MAX_DRAW_BUFFERS 0x8824 +#define GL_DRAW_BUFFER0 0x8825 +#define GL_DRAW_BUFFER1 0x8826 +#define GL_DRAW_BUFFER2 0x8827 +#define GL_DRAW_BUFFER3 0x8828 +#define GL_DRAW_BUFFER4 0x8829 +#define GL_DRAW_BUFFER5 0x882A +#define GL_DRAW_BUFFER6 0x882B +#define GL_DRAW_BUFFER7 0x882C +#define GL_DRAW_BUFFER8 0x882D +#define GL_DRAW_BUFFER9 0x882E +#define GL_DRAW_BUFFER10 0x882F +#define GL_DRAW_BUFFER11 0x8830 +#define GL_DRAW_BUFFER12 0x8831 +#define GL_DRAW_BUFFER13 0x8832 +#define GL_DRAW_BUFFER14 0x8833 +#define GL_DRAW_BUFFER15 0x8834 +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#define GL_SAMPLER_3D 0x8B5F +#define GL_SAMPLER_2D_SHADOW 0x8B62 +#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B +#define GL_PIXEL_PACK_BUFFER 0x88EB +#define GL_PIXEL_UNPACK_BUFFER 0x88EC +#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED +#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF +#define GL_FLOAT_MAT2x3 0x8B65 +#define GL_FLOAT_MAT2x4 0x8B66 +#define GL_FLOAT_MAT3x2 0x8B67 +#define GL_FLOAT_MAT3x4 0x8B68 +#define GL_FLOAT_MAT4x2 0x8B69 +#define GL_FLOAT_MAT4x3 0x8B6A +#define GL_SRGB 0x8C40 +#define GL_SRGB8 0x8C41 +#define GL_SRGB8_ALPHA8 0x8C43 +#define GL_COMPARE_REF_TO_TEXTURE 0x884E +#define GL_MAJOR_VERSION 0x821B +#define GL_MINOR_VERSION 0x821C +#define GL_NUM_EXTENSIONS 0x821D +#define GL_RGBA32F 0x8814 +#define GL_RGB32F 0x8815 +#define GL_RGBA16F 0x881A +#define GL_RGB16F 0x881B +#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD +#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF +#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904 +#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905 +#define GL_MAX_VARYING_COMPONENTS 0x8B4B +#define GL_TEXTURE_2D_ARRAY 0x8C1A +#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D +#define GL_R11F_G11F_B10F 0x8C3A +#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B +#define GL_RGB9_E5 0x8C3D +#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E +#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76 +#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80 +#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83 +#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84 +#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85 +#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88 +#define GL_RASTERIZER_DISCARD 0x8C89 +#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A +#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B +#define GL_INTERLEAVED_ATTRIBS 0x8C8C +#define GL_SEPARATE_ATTRIBS 0x8C8D +#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E +#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F +#define GL_RGBA32UI 0x8D70 +#define GL_RGB32UI 0x8D71 +#define GL_RGBA16UI 0x8D76 +#define GL_RGB16UI 0x8D77 +#define GL_RGBA8UI 0x8D7C +#define GL_RGB8UI 0x8D7D +#define GL_RGBA32I 0x8D82 +#define GL_RGB32I 0x8D83 +#define GL_RGBA16I 0x8D88 +#define GL_RGB16I 0x8D89 +#define GL_RGBA8I 0x8D8E +#define GL_RGB8I 0x8D8F +#define GL_RED_INTEGER 0x8D94 +#define GL_RGB_INTEGER 0x8D98 +#define GL_RGBA_INTEGER 0x8D99 +#define GL_SAMPLER_2D_ARRAY 0x8DC1 +#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4 +#define GL_SAMPLER_CUBE_SHADOW 0x8DC5 +#define GL_UNSIGNED_INT_VEC2 0x8DC6 +#define GL_UNSIGNED_INT_VEC3 0x8DC7 +#define GL_UNSIGNED_INT_VEC4 0x8DC8 +#define GL_INT_SAMPLER_2D 0x8DCA +#define GL_INT_SAMPLER_3D 0x8DCB +#define GL_INT_SAMPLER_CUBE 0x8DCC +#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF +#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2 +#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3 +#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4 +#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7 +#define GL_BUFFER_ACCESS_FLAGS 0x911F +#define GL_BUFFER_MAP_LENGTH 0x9120 +#define GL_BUFFER_MAP_OFFSET 0x9121 +#define GL_DEPTH_COMPONENT32F 0x8CAC +#define GL_DEPTH32F_STENCIL8 0x8CAD +#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 +#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 +#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212 +#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213 +#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214 +#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215 +#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216 +#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217 +#define GL_FRAMEBUFFER_DEFAULT 0x8218 +#define GL_FRAMEBUFFER_UNDEFINED 0x8219 +#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A +#define GL_DEPTH_STENCIL 0x84F9 +#define GL_UNSIGNED_INT_24_8 0x84FA +#define GL_DEPTH24_STENCIL8 0x88F0 +#define GL_UNSIGNED_NORMALIZED 0x8C17 +#define GL_DRAW_FRAMEBUFFER_BINDING 0x8CA6 +#define GL_READ_FRAMEBUFFER 0x8CA8 +#define GL_DRAW_FRAMEBUFFER 0x8CA9 +#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA +#define GL_RENDERBUFFER_SAMPLES 0x8CAB +#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4 +#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF +#define GL_COLOR_ATTACHMENT1 0x8CE1 +#define GL_COLOR_ATTACHMENT2 0x8CE2 +#define GL_COLOR_ATTACHMENT3 0x8CE3 +#define GL_COLOR_ATTACHMENT4 0x8CE4 +#define GL_COLOR_ATTACHMENT5 0x8CE5 +#define GL_COLOR_ATTACHMENT6 0x8CE6 +#define GL_COLOR_ATTACHMENT7 0x8CE7 +#define GL_COLOR_ATTACHMENT8 0x8CE8 +#define GL_COLOR_ATTACHMENT9 0x8CE9 +#define GL_COLOR_ATTACHMENT10 0x8CEA +#define GL_COLOR_ATTACHMENT11 0x8CEB +#define GL_COLOR_ATTACHMENT12 0x8CEC +#define GL_COLOR_ATTACHMENT13 0x8CED +#define GL_COLOR_ATTACHMENT14 0x8CEE +#define GL_COLOR_ATTACHMENT15 0x8CEF +#define GL_COLOR_ATTACHMENT16 0x8CF0 +#define GL_COLOR_ATTACHMENT17 0x8CF1 +#define GL_COLOR_ATTACHMENT18 0x8CF2 +#define GL_COLOR_ATTACHMENT19 0x8CF3 +#define GL_COLOR_ATTACHMENT20 0x8CF4 +#define GL_COLOR_ATTACHMENT21 0x8CF5 +#define GL_COLOR_ATTACHMENT22 0x8CF6 +#define GL_COLOR_ATTACHMENT23 0x8CF7 +#define GL_COLOR_ATTACHMENT24 0x8CF8 +#define GL_COLOR_ATTACHMENT25 0x8CF9 +#define GL_COLOR_ATTACHMENT26 0x8CFA +#define GL_COLOR_ATTACHMENT27 0x8CFB +#define GL_COLOR_ATTACHMENT28 0x8CFC +#define GL_COLOR_ATTACHMENT29 0x8CFD +#define GL_COLOR_ATTACHMENT30 0x8CFE +#define GL_COLOR_ATTACHMENT31 0x8CFF +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#define GL_MAX_SAMPLES 0x8D57 +#define GL_HALF_FLOAT 0x140B +#define GL_MAP_READ_BIT 0x0001 +#define GL_MAP_WRITE_BIT 0x0002 +#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 +#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 +#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 +#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 +#define GL_RG 0x8227 +#define GL_RG_INTEGER 0x8228 +#define GL_R8 0x8229 +#define GL_RG8 0x822B +#define GL_R16F 0x822D +#define GL_R32F 0x822E +#define GL_RG16F 0x822F +#define GL_RG32F 0x8230 +#define GL_R8I 0x8231 +#define GL_R8UI 0x8232 +#define GL_R16I 0x8233 +#define GL_R16UI 0x8234 +#define GL_R32I 0x8235 +#define GL_R32UI 0x8236 +#define GL_RG8I 0x8237 +#define GL_RG8UI 0x8238 +#define GL_RG16I 0x8239 +#define GL_RG16UI 0x823A +#define GL_RG32I 0x823B +#define GL_RG32UI 0x823C +#define GL_VERTEX_ARRAY_BINDING 0x85B5 +#define GL_R8_SNORM 0x8F94 +#define GL_RG8_SNORM 0x8F95 +#define GL_RGB8_SNORM 0x8F96 +#define GL_RGBA8_SNORM 0x8F97 +#define GL_SIGNED_NORMALIZED 0x8F9C +#define GL_PRIMITIVE_RESTART_FIXED_INDEX 0x8D69 +#define GL_COPY_READ_BUFFER 0x8F36 +#define GL_COPY_WRITE_BUFFER 0x8F37 +#define GL_COPY_READ_BUFFER_BINDING 0x8F36 +#define GL_COPY_WRITE_BUFFER_BINDING 0x8F37 +#define GL_UNIFORM_BUFFER 0x8A11 +#define GL_UNIFORM_BUFFER_BINDING 0x8A28 +#define GL_UNIFORM_BUFFER_START 0x8A29 +#define GL_UNIFORM_BUFFER_SIZE 0x8A2A +#define GL_MAX_VERTEX_UNIFORM_BLOCKS 0x8A2B +#define GL_MAX_FRAGMENT_UNIFORM_BLOCKS 0x8A2D +#define GL_MAX_COMBINED_UNIFORM_BLOCKS 0x8A2E +#define GL_MAX_UNIFORM_BUFFER_BINDINGS 0x8A2F +#define GL_MAX_UNIFORM_BLOCK_SIZE 0x8A30 +#define GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS 0x8A31 +#define GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS 0x8A33 +#define GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT 0x8A34 +#define GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH 0x8A35 +#define GL_ACTIVE_UNIFORM_BLOCKS 0x8A36 +#define GL_UNIFORM_TYPE 0x8A37 +#define GL_UNIFORM_SIZE 0x8A38 +#define GL_UNIFORM_NAME_LENGTH 0x8A39 +#define GL_UNIFORM_BLOCK_INDEX 0x8A3A +#define GL_UNIFORM_OFFSET 0x8A3B +#define GL_UNIFORM_ARRAY_STRIDE 0x8A3C +#define GL_UNIFORM_MATRIX_STRIDE 0x8A3D +#define GL_UNIFORM_IS_ROW_MAJOR 0x8A3E +#define GL_UNIFORM_BLOCK_BINDING 0x8A3F +#define GL_UNIFORM_BLOCK_DATA_SIZE 0x8A40 +#define GL_UNIFORM_BLOCK_NAME_LENGTH 0x8A41 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS 0x8A42 +#define GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES 0x8A43 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER 0x8A44 +#define GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER 0x8A46 +#define GL_INVALID_INDEX 0xFFFFFFFFu +#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122 +#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125 +#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111 +#define GL_OBJECT_TYPE 0x9112 +#define GL_SYNC_CONDITION 0x9113 +#define GL_SYNC_STATUS 0x9114 +#define GL_SYNC_FLAGS 0x9115 +#define GL_SYNC_FENCE 0x9116 +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_UNSIGNALED 0x9118 +#define GL_SIGNALED 0x9119 +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001 +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_VERTEX_ATTRIB_ARRAY_DIVISOR 0x88FE +#define GL_ANY_SAMPLES_PASSED 0x8C2F +#define GL_ANY_SAMPLES_PASSED_CONSERVATIVE 0x8D6A +#define GL_SAMPLER_BINDING 0x8919 +#define GL_RGB10_A2UI 0x906F +#define GL_TEXTURE_SWIZZLE_R 0x8E42 +#define GL_TEXTURE_SWIZZLE_G 0x8E43 +#define GL_TEXTURE_SWIZZLE_B 0x8E44 +#define GL_TEXTURE_SWIZZLE_A 0x8E45 +#define GL_GREEN 0x1904 +#define GL_BLUE 0x1905 +#define GL_INT_2_10_10_10_REV 0x8D9F +#define GL_TRANSFORM_FEEDBACK 0x8E22 +#define GL_TRANSFORM_FEEDBACK_PAUSED 0x8E23 +#define GL_TRANSFORM_FEEDBACK_ACTIVE 0x8E24 +#define GL_TRANSFORM_FEEDBACK_BINDING 0x8E25 +#define GL_PROGRAM_BINARY_RETRIEVABLE_HINT 0x8257 +#define GL_PROGRAM_BINARY_LENGTH 0x8741 +#define GL_NUM_PROGRAM_BINARY_FORMATS 0x87FE +#define GL_PROGRAM_BINARY_FORMATS 0x87FF +#define GL_COMPRESSED_R11_EAC 0x9270 +#define GL_COMPRESSED_SIGNED_R11_EAC 0x9271 +#define GL_COMPRESSED_RG11_EAC 0x9272 +#define GL_COMPRESSED_SIGNED_RG11_EAC 0x9273 +#define GL_COMPRESSED_RGB8_ETC2 0x9274 +#define GL_COMPRESSED_SRGB8_ETC2 0x9275 +#define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276 +#define GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9277 +#define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278 +#define GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC 0x9279 +#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F +#define GL_MAX_ELEMENT_INDEX 0x8D6B +#define GL_NUM_SAMPLE_COUNTS 0x9380 +#define GL_TEXTURE_IMMUTABLE_LEVELS 0x82DF +typedef void (GL_APIENTRYP PFNGLREADBUFFERPROC) (GLenum src); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +typedef void (GL_APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids); +typedef void (GL_APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISQUERYPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLENDQUERYPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params); +typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +typedef void *(GL_APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +typedef void (GL_APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays); +typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays); +typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array); +typedef void (GL_APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data); +typedef void (GL_APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode); +typedef void (GL_APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +typedef void (GL_APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params); +typedef GLint (GL_APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +typedef const GLubyte *(GL_APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index); +typedef void (GL_APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLGETUNIFORMINDICESPROC) (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMSIVPROC) (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKIVPROC) (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETACTIVEUNIFORMBLOCKNAMEPROC) (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +typedef void (GL_APIENTRYP PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINSTANCEDPROC) (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +typedef GLsync (GL_APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags); +typedef GLboolean (GL_APIENTRYP PFNGLISSYNCPROC) (GLsync sync); +typedef void (GL_APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync); +typedef GLenum (GL_APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +typedef void (GL_APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data); +typedef void (GL_APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params); +typedef void (GL_APIENTRYP PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint *samplers); +typedef void (GL_APIENTRYP PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint *samplers); +typedef GLboolean (GL_APIENTRYP PFNGLISSAMPLERPROC) (GLuint sampler); +typedef void (GL_APIENTRYP PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor); +typedef void (GL_APIENTRYP PFNGLBINDTRANSFORMFEEDBACKPROC) (GLenum target, GLuint id); +typedef void (GL_APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSPROC) (GLsizei n, const GLuint *ids); +typedef void (GL_APIENTRYP PFNGLGENTRANSFORMFEEDBACKSPROC) (GLsizei n, GLuint *ids); +typedef GLboolean (GL_APIENTRYP PFNGLISTRANSFORMFEEDBACKPROC) (GLuint id); +typedef void (GL_APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKPROC) (void); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +typedef void (GL_APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); +typedef void (GL_APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +typedef void (GL_APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glReadBuffer (GLenum src); +GL_APICALL void GL_APIENTRY glDrawRangeElements (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices); +GL_APICALL void GL_APIENTRY glTexImage3D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *pixels); +GL_APICALL void GL_APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glCompressedTexImage3D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const void *data); +GL_APICALL void GL_APIENTRY glGenQueries (GLsizei n, GLuint *ids); +GL_APICALL void GL_APIENTRY glDeleteQueries (GLsizei n, const GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsQuery (GLuint id); +GL_APICALL void GL_APIENTRY glBeginQuery (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glEndQuery (GLenum target); +GL_APICALL void GL_APIENTRY glGetQueryiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetQueryObjectuiv (GLuint id, GLenum pname, GLuint *params); +GL_APICALL GLboolean GL_APIENTRY glUnmapBuffer (GLenum target); +GL_APICALL void GL_APIENTRY glGetBufferPointerv (GLenum target, GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glDrawBuffers (GLsizei n, const GLenum *bufs); +GL_APICALL void GL_APIENTRY glUniformMatrix2x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix2x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix3x4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glUniformMatrix4x3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glBlitFramebuffer (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glFramebufferTextureLayer (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +GL_APICALL void *GL_APIENTRY glMapBufferRange (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); +GL_APICALL void GL_APIENTRY glFlushMappedBufferRange (GLenum target, GLintptr offset, GLsizeiptr length); +GL_APICALL void GL_APIENTRY glBindVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glDeleteVertexArrays (GLsizei n, const GLuint *arrays); +GL_APICALL void GL_APIENTRY glGenVertexArrays (GLsizei n, GLuint *arrays); +GL_APICALL GLboolean GL_APIENTRY glIsVertexArray (GLuint array); +GL_APICALL void GL_APIENTRY glGetIntegeri_v (GLenum target, GLuint index, GLint *data); +GL_APICALL void GL_APIENTRY glBeginTransformFeedback (GLenum primitiveMode); +GL_APICALL void GL_APIENTRY glEndTransformFeedback (void); +GL_APICALL void GL_APIENTRY glBindBufferRange (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glBindBufferBase (GLenum target, GLuint index, GLuint buffer); +GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings (GLuint program, GLsizei count, const GLchar *const*varyings, GLenum bufferMode); +GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name); +GL_APICALL void GL_APIENTRY glVertexAttribIPointer (GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer); +GL_APICALL void GL_APIENTRY glGetVertexAttribIiv (GLuint index, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetVertexAttribIuiv (GLuint index, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glVertexAttribI4i (GLuint index, GLint x, GLint y, GLint z, GLint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4ui (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w); +GL_APICALL void GL_APIENTRY glVertexAttribI4iv (GLuint index, const GLint *v); +GL_APICALL void GL_APIENTRY glVertexAttribI4uiv (GLuint index, const GLuint *v); +GL_APICALL void GL_APIENTRY glGetUniformuiv (GLuint program, GLint location, GLuint *params); +GL_APICALL GLint GL_APIENTRY glGetFragDataLocation (GLuint program, const GLchar *name); +GL_APICALL void GL_APIENTRY glUniform1ui (GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glUniform2ui (GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glUniform3ui (GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glUniform4ui (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glUniform1uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform2uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform3uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glUniform4uiv (GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferiv (GLenum buffer, GLint drawbuffer, const GLint *value); +GL_APICALL void GL_APIENTRY glClearBufferuiv (GLenum buffer, GLint drawbuffer, const GLuint *value); +GL_APICALL void GL_APIENTRY glClearBufferfv (GLenum buffer, GLint drawbuffer, const GLfloat *value); +GL_APICALL void GL_APIENTRY glClearBufferfi (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil); +GL_APICALL const GLubyte *GL_APIENTRY glGetStringi (GLenum name, GLuint index); +GL_APICALL void GL_APIENTRY glCopyBufferSubData (GLenum readTarget, GLenum writeTarget, GLintptr readOffset, GLintptr writeOffset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glGetUniformIndices (GLuint program, GLsizei uniformCount, const GLchar *const*uniformNames, GLuint *uniformIndices); +GL_APICALL void GL_APIENTRY glGetActiveUniformsiv (GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetUniformBlockIndex (GLuint program, const GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockiv (GLuint program, GLuint uniformBlockIndex, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetActiveUniformBlockName (GLuint program, GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName); +GL_APICALL void GL_APIENTRY glUniformBlockBinding (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GL_APICALL void GL_APIENTRY glDrawArraysInstanced (GLenum mode, GLint first, GLsizei count, GLsizei instancecount); +GL_APICALL void GL_APIENTRY glDrawElementsInstanced (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount); +GL_APICALL GLsync GL_APIENTRY glFenceSync (GLenum condition, GLbitfield flags); +GL_APICALL GLboolean GL_APIENTRY glIsSync (GLsync sync); +GL_APICALL void GL_APIENTRY glDeleteSync (GLsync sync); +GL_APICALL GLenum GL_APIENTRY glClientWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glWaitSync (GLsync sync, GLbitfield flags, GLuint64 timeout); +GL_APICALL void GL_APIENTRY glGetInteger64v (GLenum pname, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetSynciv (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values); +GL_APICALL void GL_APIENTRY glGetInteger64i_v (GLenum target, GLuint index, GLint64 *data); +GL_APICALL void GL_APIENTRY glGetBufferParameteri64v (GLenum target, GLenum pname, GLint64 *params); +GL_APICALL void GL_APIENTRY glGenSamplers (GLsizei count, GLuint *samplers); +GL_APICALL void GL_APIENTRY glDeleteSamplers (GLsizei count, const GLuint *samplers); +GL_APICALL GLboolean GL_APIENTRY glIsSampler (GLuint sampler); +GL_APICALL void GL_APIENTRY glBindSampler (GLuint unit, GLuint sampler); +GL_APICALL void GL_APIENTRY glSamplerParameteri (GLuint sampler, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glSamplerParameteriv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterf (GLuint sampler, GLenum pname, GLfloat param); +GL_APICALL void GL_APIENTRY glSamplerParameterfv (GLuint sampler, GLenum pname, const GLfloat *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameteriv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterfv (GLuint sampler, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glVertexAttribDivisor (GLuint index, GLuint divisor); +GL_APICALL void GL_APIENTRY glBindTransformFeedback (GLenum target, GLuint id); +GL_APICALL void GL_APIENTRY glDeleteTransformFeedbacks (GLsizei n, const GLuint *ids); +GL_APICALL void GL_APIENTRY glGenTransformFeedbacks (GLsizei n, GLuint *ids); +GL_APICALL GLboolean GL_APIENTRY glIsTransformFeedback (GLuint id); +GL_APICALL void GL_APIENTRY glPauseTransformFeedback (void); +GL_APICALL void GL_APIENTRY glResumeTransformFeedback (void); +GL_APICALL void GL_APIENTRY glGetProgramBinary (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, void *binary); +GL_APICALL void GL_APIENTRY glProgramBinary (GLuint program, GLenum binaryFormat, const void *binary, GLsizei length); +GL_APICALL void GL_APIENTRY glProgramParameteri (GLuint program, GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments); +GL_APICALL void GL_APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height); +GL_APICALL void GL_APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth); +GL_APICALL void GL_APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params); +#endif +#endif /* GL_ES_VERSION_3_0 */ + +#ifndef GL_ES_VERSION_3_1 +#define GL_ES_VERSION_3_1 1 +#define GL_COMPUTE_SHADER 0x91B9 +#define GL_MAX_COMPUTE_UNIFORM_BLOCKS 0x91BB +#define GL_MAX_COMPUTE_TEXTURE_IMAGE_UNITS 0x91BC +#define GL_MAX_COMPUTE_IMAGE_UNIFORMS 0x91BD +#define GL_MAX_COMPUTE_SHARED_MEMORY_SIZE 0x8262 +#define GL_MAX_COMPUTE_UNIFORM_COMPONENTS 0x8263 +#define GL_MAX_COMPUTE_ATOMIC_COUNTER_BUFFERS 0x8264 +#define GL_MAX_COMPUTE_ATOMIC_COUNTERS 0x8265 +#define GL_MAX_COMBINED_COMPUTE_UNIFORM_COMPONENTS 0x8266 +#define GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS 0x90EB +#define GL_MAX_COMPUTE_WORK_GROUP_COUNT 0x91BE +#define GL_MAX_COMPUTE_WORK_GROUP_SIZE 0x91BF +#define GL_COMPUTE_WORK_GROUP_SIZE 0x8267 +#define GL_DISPATCH_INDIRECT_BUFFER 0x90EE +#define GL_DISPATCH_INDIRECT_BUFFER_BINDING 0x90EF +#define GL_COMPUTE_SHADER_BIT 0x00000020 +#define GL_DRAW_INDIRECT_BUFFER 0x8F3F +#define GL_DRAW_INDIRECT_BUFFER_BINDING 0x8F43 +#define GL_MAX_UNIFORM_LOCATIONS 0x826E +#define GL_FRAMEBUFFER_DEFAULT_WIDTH 0x9310 +#define GL_FRAMEBUFFER_DEFAULT_HEIGHT 0x9311 +#define GL_FRAMEBUFFER_DEFAULT_SAMPLES 0x9313 +#define GL_FRAMEBUFFER_DEFAULT_FIXED_SAMPLE_LOCATIONS 0x9314 +#define GL_MAX_FRAMEBUFFER_WIDTH 0x9315 +#define GL_MAX_FRAMEBUFFER_HEIGHT 0x9316 +#define GL_MAX_FRAMEBUFFER_SAMPLES 0x9318 +#define GL_UNIFORM 0x92E1 +#define GL_UNIFORM_BLOCK 0x92E2 +#define GL_PROGRAM_INPUT 0x92E3 +#define GL_PROGRAM_OUTPUT 0x92E4 +#define GL_BUFFER_VARIABLE 0x92E5 +#define GL_SHADER_STORAGE_BLOCK 0x92E6 +#define GL_ATOMIC_COUNTER_BUFFER 0x92C0 +#define GL_TRANSFORM_FEEDBACK_VARYING 0x92F4 +#define GL_ACTIVE_RESOURCES 0x92F5 +#define GL_MAX_NAME_LENGTH 0x92F6 +#define GL_MAX_NUM_ACTIVE_VARIABLES 0x92F7 +#define GL_NAME_LENGTH 0x92F9 +#define GL_TYPE 0x92FA +#define GL_ARRAY_SIZE 0x92FB +#define GL_OFFSET 0x92FC +#define GL_BLOCK_INDEX 0x92FD +#define GL_ARRAY_STRIDE 0x92FE +#define GL_MATRIX_STRIDE 0x92FF +#define GL_IS_ROW_MAJOR 0x9300 +#define GL_ATOMIC_COUNTER_BUFFER_INDEX 0x9301 +#define GL_BUFFER_BINDING 0x9302 +#define GL_BUFFER_DATA_SIZE 0x9303 +#define GL_NUM_ACTIVE_VARIABLES 0x9304 +#define GL_ACTIVE_VARIABLES 0x9305 +#define GL_REFERENCED_BY_VERTEX_SHADER 0x9306 +#define GL_REFERENCED_BY_FRAGMENT_SHADER 0x930A +#define GL_REFERENCED_BY_COMPUTE_SHADER 0x930B +#define GL_TOP_LEVEL_ARRAY_SIZE 0x930C +#define GL_TOP_LEVEL_ARRAY_STRIDE 0x930D +#define GL_LOCATION 0x930E +#define GL_VERTEX_SHADER_BIT 0x00000001 +#define GL_FRAGMENT_SHADER_BIT 0x00000002 +#define GL_ALL_SHADER_BITS 0xFFFFFFFF +#define GL_PROGRAM_SEPARABLE 0x8258 +#define GL_ACTIVE_PROGRAM 0x8259 +#define GL_PROGRAM_PIPELINE_BINDING 0x825A +#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1 +#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2 +#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3 +#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC +#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0 +#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1 +#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2 +#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6 +#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8 +#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC +#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9 +#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB +#define GL_MAX_IMAGE_UNITS 0x8F38 +#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA +#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE +#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF +#define GL_IMAGE_BINDING_NAME 0x8F3A +#define GL_IMAGE_BINDING_LEVEL 0x8F3B +#define GL_IMAGE_BINDING_LAYERED 0x8F3C +#define GL_IMAGE_BINDING_LAYER 0x8F3D +#define GL_IMAGE_BINDING_ACCESS 0x8F3E +#define GL_IMAGE_BINDING_FORMAT 0x906E +#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001 +#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002 +#define GL_UNIFORM_BARRIER_BIT 0x00000004 +#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008 +#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020 +#define GL_COMMAND_BARRIER_BIT 0x00000040 +#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080 +#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100 +#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200 +#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400 +#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800 +#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000 +#define GL_ALL_BARRIER_BITS 0xFFFFFFFF +#define GL_IMAGE_2D 0x904D +#define GL_IMAGE_3D 0x904E +#define GL_IMAGE_CUBE 0x9050 +#define GL_IMAGE_2D_ARRAY 0x9053 +#define GL_INT_IMAGE_2D 0x9058 +#define GL_INT_IMAGE_3D 0x9059 +#define GL_INT_IMAGE_CUBE 0x905B +#define GL_INT_IMAGE_2D_ARRAY 0x905E +#define GL_UNSIGNED_INT_IMAGE_2D 0x9063 +#define GL_UNSIGNED_INT_IMAGE_3D 0x9064 +#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066 +#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069 +#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8 +#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9 +#define GL_READ_ONLY 0x88B8 +#define GL_WRITE_ONLY 0x88B9 +#define GL_READ_WRITE 0x88BA +#define GL_SHADER_STORAGE_BUFFER 0x90D2 +#define GL_SHADER_STORAGE_BUFFER_BINDING 0x90D3 +#define GL_SHADER_STORAGE_BUFFER_START 0x90D4 +#define GL_SHADER_STORAGE_BUFFER_SIZE 0x90D5 +#define GL_MAX_VERTEX_SHADER_STORAGE_BLOCKS 0x90D6 +#define GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS 0x90DA +#define GL_MAX_COMPUTE_SHADER_STORAGE_BLOCKS 0x90DB +#define GL_MAX_COMBINED_SHADER_STORAGE_BLOCKS 0x90DC +#define GL_MAX_SHADER_STORAGE_BUFFER_BINDINGS 0x90DD +#define GL_MAX_SHADER_STORAGE_BLOCK_SIZE 0x90DE +#define GL_SHADER_STORAGE_BUFFER_OFFSET_ALIGNMENT 0x90DF +#define GL_SHADER_STORAGE_BARRIER_BIT 0x00002000 +#define GL_MAX_COMBINED_SHADER_OUTPUT_RESOURCES 0x8F39 +#define GL_DEPTH_STENCIL_TEXTURE_MODE 0x90EA +#define GL_STENCIL_INDEX 0x1901 +#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E +#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F +#define GL_SAMPLE_POSITION 0x8E50 +#define GL_SAMPLE_MASK 0x8E51 +#define GL_SAMPLE_MASK_VALUE 0x8E52 +#define GL_TEXTURE_2D_MULTISAMPLE 0x9100 +#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59 +#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E +#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F +#define GL_MAX_INTEGER_SAMPLES 0x9110 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104 +#define GL_TEXTURE_SAMPLES 0x9106 +#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107 +#define GL_TEXTURE_WIDTH 0x1000 +#define GL_TEXTURE_HEIGHT 0x1001 +#define GL_TEXTURE_DEPTH 0x8071 +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#define GL_TEXTURE_RED_SIZE 0x805C +#define GL_TEXTURE_GREEN_SIZE 0x805D +#define GL_TEXTURE_BLUE_SIZE 0x805E +#define GL_TEXTURE_ALPHA_SIZE 0x805F +#define GL_TEXTURE_DEPTH_SIZE 0x884A +#define GL_TEXTURE_STENCIL_SIZE 0x88F1 +#define GL_TEXTURE_SHARED_SIZE 0x8C3F +#define GL_TEXTURE_RED_TYPE 0x8C10 +#define GL_TEXTURE_GREEN_TYPE 0x8C11 +#define GL_TEXTURE_BLUE_TYPE 0x8C12 +#define GL_TEXTURE_ALPHA_TYPE 0x8C13 +#define GL_TEXTURE_DEPTH_TYPE 0x8C16 +#define GL_TEXTURE_COMPRESSED 0x86A1 +#define GL_SAMPLER_2D_MULTISAMPLE 0x9108 +#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109 +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A +#define GL_VERTEX_ATTRIB_BINDING 0x82D4 +#define GL_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D5 +#define GL_VERTEX_BINDING_DIVISOR 0x82D6 +#define GL_VERTEX_BINDING_OFFSET 0x82D7 +#define GL_VERTEX_BINDING_STRIDE 0x82D8 +#define GL_VERTEX_BINDING_BUFFER 0x8F4F +#define GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET 0x82D9 +#define GL_MAX_VERTEX_ATTRIB_BINDINGS 0x82DA +#define GL_MAX_VERTEX_ATTRIB_STRIDE 0x82E5 +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEPROC) (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +typedef void (GL_APIENTRYP PFNGLDISPATCHCOMPUTEINDIRECTPROC) (GLintptr indirect); +typedef void (GL_APIENTRYP PFNGLDRAWARRAYSINDIRECTPROC) (GLenum mode, const void *indirect); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINDIRECTPROC) (GLenum mode, GLenum type, const void *indirect); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERPARAMETERIPROC) (GLenum target, GLenum pname, GLint param); +typedef void (GL_APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMINTERFACEIVPROC) (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +typedef GLuint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEINDEXPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCENAMEPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMRESOURCEIVPROC) (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +typedef GLint (GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONPROC) (GLuint program, GLenum programInterface, const GLchar *name); +typedef void (GL_APIENTRYP PFNGLUSEPROGRAMSTAGESPROC) (GLuint pipeline, GLbitfield stages, GLuint program); +typedef void (GL_APIENTRYP PFNGLACTIVESHADERPROGRAMPROC) (GLuint pipeline, GLuint program); +typedef GLuint (GL_APIENTRYP PFNGLCREATESHADERPROGRAMVPROC) (GLenum type, GLsizei count, const GLchar *const*strings); +typedef void (GL_APIENTRYP PFNGLBINDPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLDELETEPROGRAMPIPELINESPROC) (GLsizei n, const GLuint *pipelines); +typedef void (GL_APIENTRYP PFNGLGENPROGRAMPIPELINESPROC) (GLsizei n, GLuint *pipelines); +typedef GLboolean (GL_APIENTRYP PFNGLISPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEIVPROC) (GLuint pipeline, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IPROC) (GLuint program, GLint location, GLint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IPROC) (GLuint program, GLint location, GLint v0, GLint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIPROC) (GLuint program, GLint location, GLuint v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FPROC) (GLuint program, GLint location, GLfloat v0); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4IVPROC) (GLuint program, GLint location, GLsizei count, const GLint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4UIVPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM1FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM2FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM3FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORM4FVPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +typedef void (GL_APIENTRYP PFNGLVALIDATEPROGRAMPIPELINEPROC) (GLuint pipeline); +typedef void (GL_APIENTRYP PFNGLGETPROGRAMPIPELINEINFOLOGPROC) (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +typedef void (GL_APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +typedef void (GL_APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLMEMORYBARRIERBYREGIONPROC) (GLbitfield barriers); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +typedef void (GL_APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val); +typedef void (GL_APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint maskNumber, GLbitfield mask); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint level, GLenum pname, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLBINDVERTEXBUFFERPROC) (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBIFORMATPROC) (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +typedef void (GL_APIENTRYP PFNGLVERTEXATTRIBBINDINGPROC) (GLuint attribindex, GLuint bindingindex); +typedef void (GL_APIENTRYP PFNGLVERTEXBINDINGDIVISORPROC) (GLuint bindingindex, GLuint divisor); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glDispatchCompute (GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z); +GL_APICALL void GL_APIENTRY glDispatchComputeIndirect (GLintptr indirect); +GL_APICALL void GL_APIENTRY glDrawArraysIndirect (GLenum mode, const void *indirect); +GL_APICALL void GL_APIENTRY glDrawElementsIndirect (GLenum mode, GLenum type, const void *indirect); +GL_APICALL void GL_APIENTRY glFramebufferParameteri (GLenum target, GLenum pname, GLint param); +GL_APICALL void GL_APIENTRY glGetFramebufferParameteriv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetProgramInterfaceiv (GLuint program, GLenum programInterface, GLenum pname, GLint *params); +GL_APICALL GLuint GL_APIENTRY glGetProgramResourceIndex (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceName (GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei *length, GLchar *name); +GL_APICALL void GL_APIENTRY glGetProgramResourceiv (GLuint program, GLenum programInterface, GLuint index, GLsizei propCount, const GLenum *props, GLsizei bufSize, GLsizei *length, GLint *params); +GL_APICALL GLint GL_APIENTRY glGetProgramResourceLocation (GLuint program, GLenum programInterface, const GLchar *name); +GL_APICALL void GL_APIENTRY glUseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program); +GL_APICALL void GL_APIENTRY glActiveShaderProgram (GLuint pipeline, GLuint program); +GL_APICALL GLuint GL_APIENTRY glCreateShaderProgramv (GLenum type, GLsizei count, const GLchar *const*strings); +GL_APICALL void GL_APIENTRY glBindProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glDeleteProgramPipelines (GLsizei n, const GLuint *pipelines); +GL_APICALL void GL_APIENTRY glGenProgramPipelines (GLsizei n, GLuint *pipelines); +GL_APICALL GLboolean GL_APIENTRY glIsProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glProgramUniform1i (GLuint program, GLint location, GLint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2i (GLuint program, GLint location, GLint v0, GLint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4i (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1ui (GLuint program, GLint location, GLuint v0); +GL_APICALL void GL_APIENTRY glProgramUniform2ui (GLuint program, GLint location, GLuint v0, GLuint v1); +GL_APICALL void GL_APIENTRY glProgramUniform3ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2); +GL_APICALL void GL_APIENTRY glProgramUniform4ui (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +GL_APICALL void GL_APIENTRY glProgramUniform1f (GLuint program, GLint location, GLfloat v0); +GL_APICALL void GL_APIENTRY glProgramUniform2f (GLuint program, GLint location, GLfloat v0, GLfloat v1); +GL_APICALL void GL_APIENTRY glProgramUniform3f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +GL_APICALL void GL_APIENTRY glProgramUniform4f (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +GL_APICALL void GL_APIENTRY glProgramUniform1iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4iv (GLuint program, GLint location, GLsizei count, const GLint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform2uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform3uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform4uiv (GLuint program, GLint location, GLsizei count, const GLuint *value); +GL_APICALL void GL_APIENTRY glProgramUniform1fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform2fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform3fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniform4fv (GLuint program, GLint location, GLsizei count, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix2x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x2fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix3x4fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glProgramUniformMatrix4x3fv (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); +GL_APICALL void GL_APIENTRY glValidateProgramPipeline (GLuint pipeline); +GL_APICALL void GL_APIENTRY glGetProgramPipelineInfoLog (GLuint pipeline, GLsizei bufSize, GLsizei *length, GLchar *infoLog); +GL_APICALL void GL_APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format); +GL_APICALL void GL_APIENTRY glGetBooleani_v (GLenum target, GLuint index, GLboolean *data); +GL_APICALL void GL_APIENTRY glMemoryBarrier (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glMemoryBarrierByRegion (GLbitfield barriers); +GL_APICALL void GL_APIENTRY glTexStorage2DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations); +GL_APICALL void GL_APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val); +GL_APICALL void GL_APIENTRY glSampleMaski (GLuint maskNumber, GLbitfield mask); +GL_APICALL void GL_APIENTRY glGetTexLevelParameteriv (GLenum target, GLint level, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexLevelParameterfv (GLenum target, GLint level, GLenum pname, GLfloat *params); +GL_APICALL void GL_APIENTRY glBindVertexBuffer (GLuint bindingindex, GLuint buffer, GLintptr offset, GLsizei stride); +GL_APICALL void GL_APIENTRY glVertexAttribFormat (GLuint attribindex, GLint size, GLenum type, GLboolean normalized, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribIFormat (GLuint attribindex, GLint size, GLenum type, GLuint relativeoffset); +GL_APICALL void GL_APIENTRY glVertexAttribBinding (GLuint attribindex, GLuint bindingindex); +GL_APICALL void GL_APIENTRY glVertexBindingDivisor (GLuint bindingindex, GLuint divisor); +#endif +#endif /* GL_ES_VERSION_3_1 */ + +#ifndef GL_ES_VERSION_3_2 +#define GL_ES_VERSION_3_2 1 +typedef void (GL_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const void *userParam); +#define GL_MULTISAMPLE_LINE_WIDTH_RANGE 0x9381 +#define GL_MULTISAMPLE_LINE_WIDTH_GRANULARITY 0x9382 +#define GL_MULTIPLY 0x9294 +#define GL_SCREEN 0x9295 +#define GL_OVERLAY 0x9296 +#define GL_DARKEN 0x9297 +#define GL_LIGHTEN 0x9298 +#define GL_COLORDODGE 0x9299 +#define GL_COLORBURN 0x929A +#define GL_HARDLIGHT 0x929B +#define GL_SOFTLIGHT 0x929C +#define GL_DIFFERENCE 0x929E +#define GL_EXCLUSION 0x92A0 +#define GL_HSL_HUE 0x92AD +#define GL_HSL_SATURATION 0x92AE +#define GL_HSL_COLOR 0x92AF +#define GL_HSL_LUMINOSITY 0x92B0 +#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242 +#define GL_DEBUG_NEXT_LOGGED_MESSAGE_LENGTH 0x8243 +#define GL_DEBUG_CALLBACK_FUNCTION 0x8244 +#define GL_DEBUG_CALLBACK_USER_PARAM 0x8245 +#define GL_DEBUG_SOURCE_API 0x8246 +#define GL_DEBUG_SOURCE_WINDOW_SYSTEM 0x8247 +#define GL_DEBUG_SOURCE_SHADER_COMPILER 0x8248 +#define GL_DEBUG_SOURCE_THIRD_PARTY 0x8249 +#define GL_DEBUG_SOURCE_APPLICATION 0x824A +#define GL_DEBUG_SOURCE_OTHER 0x824B +#define GL_DEBUG_TYPE_ERROR 0x824C +#define GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR 0x824D +#define GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR 0x824E +#define GL_DEBUG_TYPE_PORTABILITY 0x824F +#define GL_DEBUG_TYPE_PERFORMANCE 0x8250 +#define GL_DEBUG_TYPE_OTHER 0x8251 +#define GL_DEBUG_TYPE_MARKER 0x8268 +#define GL_DEBUG_TYPE_PUSH_GROUP 0x8269 +#define GL_DEBUG_TYPE_POP_GROUP 0x826A +#define GL_DEBUG_SEVERITY_NOTIFICATION 0x826B +#define GL_MAX_DEBUG_GROUP_STACK_DEPTH 0x826C +#define GL_DEBUG_GROUP_STACK_DEPTH 0x826D +#define GL_BUFFER 0x82E0 +#define GL_SHADER 0x82E1 +#define GL_PROGRAM 0x82E2 +#define GL_VERTEX_ARRAY 0x8074 +#define GL_QUERY 0x82E3 +#define GL_PROGRAM_PIPELINE 0x82E4 +#define GL_SAMPLER 0x82E6 +#define GL_MAX_LABEL_LENGTH 0x82E8 +#define GL_MAX_DEBUG_MESSAGE_LENGTH 0x9143 +#define GL_MAX_DEBUG_LOGGED_MESSAGES 0x9144 +#define GL_DEBUG_LOGGED_MESSAGES 0x9145 +#define GL_DEBUG_SEVERITY_HIGH 0x9146 +#define GL_DEBUG_SEVERITY_MEDIUM 0x9147 +#define GL_DEBUG_SEVERITY_LOW 0x9148 +#define GL_DEBUG_OUTPUT 0x92E0 +#define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 +#define GL_STACK_OVERFLOW 0x0503 +#define GL_STACK_UNDERFLOW 0x0504 +#define GL_GEOMETRY_SHADER 0x8DD9 +#define GL_GEOMETRY_SHADER_BIT 0x00000004 +#define GL_GEOMETRY_VERTICES_OUT 0x8916 +#define GL_GEOMETRY_INPUT_TYPE 0x8917 +#define GL_GEOMETRY_OUTPUT_TYPE 0x8918 +#define GL_GEOMETRY_SHADER_INVOCATIONS 0x887F +#define GL_LAYER_PROVOKING_VERTEX 0x825E +#define GL_LINES_ADJACENCY 0x000A +#define GL_LINE_STRIP_ADJACENCY 0x000B +#define GL_TRIANGLES_ADJACENCY 0x000C +#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D +#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF +#define GL_MAX_GEOMETRY_UNIFORM_BLOCKS 0x8A2C +#define GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS 0x8A32 +#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123 +#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124 +#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0 +#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1 +#define GL_MAX_GEOMETRY_SHADER_INVOCATIONS 0x8E5A +#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29 +#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF +#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5 +#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD +#define GL_MAX_GEOMETRY_SHADER_STORAGE_BLOCKS 0x90D7 +#define GL_FIRST_VERTEX_CONVENTION 0x8E4D +#define GL_LAST_VERTEX_CONVENTION 0x8E4E +#define GL_UNDEFINED_VERTEX 0x8260 +#define GL_PRIMITIVES_GENERATED 0x8C87 +#define GL_FRAMEBUFFER_DEFAULT_LAYERS 0x9312 +#define GL_MAX_FRAMEBUFFER_LAYERS 0x9317 +#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8 +#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7 +#define GL_REFERENCED_BY_GEOMETRY_SHADER 0x9309 +#define GL_PRIMITIVE_BOUNDING_BOX 0x92BE +#define GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT 0x00000004 +#define GL_CONTEXT_FLAGS 0x821E +#define GL_LOSE_CONTEXT_ON_RESET 0x8252 +#define GL_GUILTY_CONTEXT_RESET 0x8253 +#define GL_INNOCENT_CONTEXT_RESET 0x8254 +#define GL_UNKNOWN_CONTEXT_RESET 0x8255 +#define GL_RESET_NOTIFICATION_STRATEGY 0x8256 +#define GL_NO_RESET_NOTIFICATION 0x8261 +#define GL_CONTEXT_LOST 0x0507 +#define GL_SAMPLE_SHADING 0x8C36 +#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37 +#define GL_MIN_FRAGMENT_INTERPOLATION_OFFSET 0x8E5B +#define GL_MAX_FRAGMENT_INTERPOLATION_OFFSET 0x8E5C +#define GL_FRAGMENT_INTERPOLATION_OFFSET_BITS 0x8E5D +#define GL_PATCHES 0x000E +#define GL_PATCH_VERTICES 0x8E72 +#define GL_TESS_CONTROL_OUTPUT_VERTICES 0x8E75 +#define GL_TESS_GEN_MODE 0x8E76 +#define GL_TESS_GEN_SPACING 0x8E77 +#define GL_TESS_GEN_VERTEX_ORDER 0x8E78 +#define GL_TESS_GEN_POINT_MODE 0x8E79 +#define GL_ISOLINES 0x8E7A +#define GL_QUADS 0x0007 +#define GL_FRACTIONAL_ODD 0x8E7B +#define GL_FRACTIONAL_EVEN 0x8E7C +#define GL_MAX_PATCH_VERTICES 0x8E7D +#define GL_MAX_TESS_GEN_LEVEL 0x8E7E +#define GL_MAX_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E7F +#define GL_MAX_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E80 +#define GL_MAX_TESS_CONTROL_TEXTURE_IMAGE_UNITS 0x8E81 +#define GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS 0x8E82 +#define GL_MAX_TESS_CONTROL_OUTPUT_COMPONENTS 0x8E83 +#define GL_MAX_TESS_PATCH_COMPONENTS 0x8E84 +#define GL_MAX_TESS_CONTROL_TOTAL_OUTPUT_COMPONENTS 0x8E85 +#define GL_MAX_TESS_EVALUATION_OUTPUT_COMPONENTS 0x8E86 +#define GL_MAX_TESS_CONTROL_UNIFORM_BLOCKS 0x8E89 +#define GL_MAX_TESS_EVALUATION_UNIFORM_BLOCKS 0x8E8A +#define GL_MAX_TESS_CONTROL_INPUT_COMPONENTS 0x886C +#define GL_MAX_TESS_EVALUATION_INPUT_COMPONENTS 0x886D +#define GL_MAX_COMBINED_TESS_CONTROL_UNIFORM_COMPONENTS 0x8E1E +#define GL_MAX_COMBINED_TESS_EVALUATION_UNIFORM_COMPONENTS 0x8E1F +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE +#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3 +#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4 +#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB +#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC +#define GL_MAX_TESS_CONTROL_SHADER_STORAGE_BLOCKS 0x90D8 +#define GL_MAX_TESS_EVALUATION_SHADER_STORAGE_BLOCKS 0x90D9 +#define GL_PRIMITIVE_RESTART_FOR_PATCHES_SUPPORTED 0x8221 +#define GL_IS_PER_PATCH 0x92E7 +#define GL_REFERENCED_BY_TESS_CONTROL_SHADER 0x9307 +#define GL_REFERENCED_BY_TESS_EVALUATION_SHADER 0x9308 +#define GL_TESS_CONTROL_SHADER 0x8E88 +#define GL_TESS_EVALUATION_SHADER 0x8E87 +#define GL_TESS_CONTROL_SHADER_BIT 0x00000008 +#define GL_TESS_EVALUATION_SHADER_BIT 0x00000010 +#define GL_TEXTURE_BORDER_COLOR 0x1004 +#define GL_CLAMP_TO_BORDER 0x812D +#define GL_TEXTURE_BUFFER 0x8C2A +#define GL_TEXTURE_BUFFER_BINDING 0x8C2A +#define GL_MAX_TEXTURE_BUFFER_SIZE 0x8C2B +#define GL_TEXTURE_BINDING_BUFFER 0x8C2C +#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING 0x8C2D +#define GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT 0x919F +#define GL_SAMPLER_BUFFER 0x8DC2 +#define GL_INT_SAMPLER_BUFFER 0x8DD0 +#define GL_UNSIGNED_INT_SAMPLER_BUFFER 0x8DD8 +#define GL_IMAGE_BUFFER 0x9051 +#define GL_INT_IMAGE_BUFFER 0x905C +#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067 +#define GL_TEXTURE_BUFFER_OFFSET 0x919D +#define GL_TEXTURE_BUFFER_SIZE 0x919E +#define GL_COMPRESSED_RGBA_ASTC_4x4 0x93B0 +#define GL_COMPRESSED_RGBA_ASTC_5x4 0x93B1 +#define GL_COMPRESSED_RGBA_ASTC_5x5 0x93B2 +#define GL_COMPRESSED_RGBA_ASTC_6x5 0x93B3 +#define GL_COMPRESSED_RGBA_ASTC_6x6 0x93B4 +#define GL_COMPRESSED_RGBA_ASTC_8x5 0x93B5 +#define GL_COMPRESSED_RGBA_ASTC_8x6 0x93B6 +#define GL_COMPRESSED_RGBA_ASTC_8x8 0x93B7 +#define GL_COMPRESSED_RGBA_ASTC_10x5 0x93B8 +#define GL_COMPRESSED_RGBA_ASTC_10x6 0x93B9 +#define GL_COMPRESSED_RGBA_ASTC_10x8 0x93BA +#define GL_COMPRESSED_RGBA_ASTC_10x10 0x93BB +#define GL_COMPRESSED_RGBA_ASTC_12x10 0x93BC +#define GL_COMPRESSED_RGBA_ASTC_12x12 0x93BD +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4 0x93D0 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4 0x93D1 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5 0x93D2 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5 0x93D3 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6 0x93D4 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5 0x93D5 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6 0x93D6 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8 0x93D7 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5 0x93D8 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6 0x93D9 +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8 0x93DA +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10 0x93DB +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10 0x93DC +#define GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12 0x93DD +#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A +#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C +#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D +#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E +#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F +#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054 +#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F +#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A +#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102 +#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105 +#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B +#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C +#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D +typedef void (GL_APIENTRYP PFNGLBLENDBARRIERPROC) (void); +typedef void (GL_APIENTRYP PFNGLCOPYIMAGESUBDATAPROC) (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECONTROLPROC) (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGEINSERTPROC) (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +typedef void (GL_APIENTRYP PFNGLDEBUGMESSAGECALLBACKPROC) (GLDEBUGPROC callback, const void *userParam); +typedef GLuint (GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGPROC) (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +typedef void (GL_APIENTRYP PFNGLPUSHDEBUGGROUPPROC) (GLenum source, GLuint id, GLsizei length, const GLchar *message); +typedef void (GL_APIENTRYP PFNGLPOPDEBUGGROUPPROC) (void); +typedef void (GL_APIENTRYP PFNGLOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTLABELPROC) (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLOBJECTPTRLABELPROC) (const void *ptr, GLsizei length, const GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETOBJECTPTRLABELPROC) (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +typedef void (GL_APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, void **params); +typedef void (GL_APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode); +typedef void (GL_APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst); +typedef void (GL_APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +typedef void (GL_APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +typedef GLboolean (GL_APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level); +typedef void (GL_APIENTRYP PFNGLPRIMITIVEBOUNDINGBOXPROC) (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +typedef GLenum (GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSPROC) (void); +typedef void (GL_APIENTRYP PFNGLREADNPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMFVPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETNUNIFORMUIVPROC) (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +typedef void (GL_APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLfloat value); +typedef void (GL_APIENTRYP PFNGLPATCHPARAMETERIPROC) (GLenum pname, GLint value); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (GL_APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, const GLint *param); +typedef void (GL_APIENTRYP PFNGLSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, const GLuint *param); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIIVPROC) (GLuint sampler, GLenum pname, GLint *params); +typedef void (GL_APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalformat, GLuint buffer); +typedef void (GL_APIENTRYP PFNGLTEXBUFFERRANGEPROC) (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +typedef void (GL_APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#if GL_GLES_PROTOTYPES +GL_APICALL void GL_APIENTRY glBlendBarrier (void); +GL_APICALL void GL_APIENTRY glCopyImageSubData (GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +GL_APICALL void GL_APIENTRY glDebugMessageControl (GLenum source, GLenum type, GLenum severity, GLsizei count, const GLuint *ids, GLboolean enabled); +GL_APICALL void GL_APIENTRY glDebugMessageInsert (GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *buf); +GL_APICALL void GL_APIENTRY glDebugMessageCallback (GLDEBUGPROC callback, const void *userParam); +GL_APICALL GLuint GL_APIENTRY glGetDebugMessageLog (GLuint count, GLsizei bufSize, GLenum *sources, GLenum *types, GLuint *ids, GLenum *severities, GLsizei *lengths, GLchar *messageLog); +GL_APICALL void GL_APIENTRY glPushDebugGroup (GLenum source, GLuint id, GLsizei length, const GLchar *message); +GL_APICALL void GL_APIENTRY glPopDebugGroup (void); +GL_APICALL void GL_APIENTRY glObjectLabel (GLenum identifier, GLuint name, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectLabel (GLenum identifier, GLuint name, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glObjectPtrLabel (const void *ptr, GLsizei length, const GLchar *label); +GL_APICALL void GL_APIENTRY glGetObjectPtrLabel (const void *ptr, GLsizei bufSize, GLsizei *length, GLchar *label); +GL_APICALL void GL_APIENTRY glGetPointerv (GLenum pname, void **params); +GL_APICALL void GL_APIENTRY glEnablei (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDisablei (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glBlendEquationi (GLuint buf, GLenum mode); +GL_APICALL void GL_APIENTRY glBlendEquationSeparatei (GLuint buf, GLenum modeRGB, GLenum modeAlpha); +GL_APICALL void GL_APIENTRY glBlendFunci (GLuint buf, GLenum src, GLenum dst); +GL_APICALL void GL_APIENTRY glBlendFuncSeparatei (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); +GL_APICALL void GL_APIENTRY glColorMaski (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a); +GL_APICALL GLboolean GL_APIENTRY glIsEnabledi (GLenum target, GLuint index); +GL_APICALL void GL_APIENTRY glDrawElementsBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawRangeElementsBaseVertex (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices, GLint basevertex); +GL_APICALL void GL_APIENTRY glDrawElementsInstancedBaseVertex (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount, GLint basevertex); +GL_APICALL void GL_APIENTRY glFramebufferTexture (GLenum target, GLenum attachment, GLuint texture, GLint level); +GL_APICALL void GL_APIENTRY glPrimitiveBoundingBox (GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW, GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW); +GL_APICALL GLenum GL_APIENTRY glGetGraphicsResetStatus (void); +GL_APICALL void GL_APIENTRY glReadnPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, void *data); +GL_APICALL void GL_APIENTRY glGetnUniformfv (GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +GL_APICALL void GL_APIENTRY glGetnUniformiv (GLuint program, GLint location, GLsizei bufSize, GLint *params); +GL_APICALL void GL_APIENTRY glGetnUniformuiv (GLuint program, GLint location, GLsizei bufSize, GLuint *params); +GL_APICALL void GL_APIENTRY glMinSampleShading (GLfloat value); +GL_APICALL void GL_APIENTRY glPatchParameteri (GLenum pname, GLint value); +GL_APICALL void GL_APIENTRY glTexParameterIiv (GLenum target, GLenum pname, const GLint *params); +GL_APICALL void GL_APIENTRY glTexParameterIuiv (GLenum target, GLenum pname, const GLuint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIiv (GLenum target, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetTexParameterIuiv (GLenum target, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glSamplerParameterIiv (GLuint sampler, GLenum pname, const GLint *param); +GL_APICALL void GL_APIENTRY glSamplerParameterIuiv (GLuint sampler, GLenum pname, const GLuint *param); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIiv (GLuint sampler, GLenum pname, GLint *params); +GL_APICALL void GL_APIENTRY glGetSamplerParameterIuiv (GLuint sampler, GLenum pname, GLuint *params); +GL_APICALL void GL_APIENTRY glTexBuffer (GLenum target, GLenum internalformat, GLuint buffer); +GL_APICALL void GL_APIENTRY glTexBufferRange (GLenum target, GLenum internalformat, GLuint buffer, GLintptr offset, GLsizeiptr size); +GL_APICALL void GL_APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations); +#endif +#endif /* GL_ES_VERSION_3_2 */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3platform.h b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3platform.h new file mode 100644 index 0000000..8699212 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/GLES3/gl3platform.h @@ -0,0 +1,27 @@ +#ifndef __gl3platform_h_ +#define __gl3platform_h_ + +/* +** Copyright 2017-2020 The Khronos Group Inc. +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* Platform-specific types and definitions for OpenGL ES 3.X gl3.h + * + * Adopters may modify khrplatform.h and this file to suit their platform. + * Please contribute modifications back to Khronos as pull requests on the + * public github repository: + * https://github.com/KhronosGroup/OpenGL-Registry + */ + +#include + +#ifndef GL_APICALL +#define GL_APICALL KHRONOS_APICALL +#endif + +#ifndef GL_APIENTRY +#define GL_APIENTRY KHRONOS_APIENTRY +#endif + +#endif /* __gl3platform_h_ */ diff --git a/contrib/SDL-3.2.8/src/video/khronos/KHR/khrplatform.h b/contrib/SDL-3.2.8/src/video/khronos/KHR/khrplatform.h new file mode 100644 index 0000000..0164644 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/KHR/khrplatform.h @@ -0,0 +1,311 @@ +#ifndef __khrplatform_h_ +#define __khrplatform_h_ + +/* +** Copyright (c) 2008-2018 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +/* Khronos platform-specific types and definitions. + * + * The master copy of khrplatform.h is maintained in the Khronos EGL + * Registry repository at https://github.com/KhronosGroup/EGL-Registry + * The last semantic modification to khrplatform.h was at commit ID: + * 67a3e0864c2d75ea5287b9f3d2eb74a745936692 + * + * Adopters may modify this file to suit their platform. Adopters are + * encouraged to submit platform specific modifications to the Khronos + * group so that they can be included in future versions of this file. + * Please submit changes by filing pull requests or issues on + * the EGL Registry repository linked above. + * + * + * See the Implementer's Guidelines for information about where this file + * should be located on your system and for more details of its use: + * http://www.khronos.org/registry/implementers_guide.pdf + * + * This file should be included as + * #include + * by Khronos client API header files that use its types and defines. + * + * The types in khrplatform.h should only be used to define API-specific types. + * + * Types defined in khrplatform.h: + * khronos_int8_t signed 8 bit + * khronos_uint8_t unsigned 8 bit + * khronos_int16_t signed 16 bit + * khronos_uint16_t unsigned 16 bit + * khronos_int32_t signed 32 bit + * khronos_uint32_t unsigned 32 bit + * khronos_int64_t signed 64 bit + * khronos_uint64_t unsigned 64 bit + * khronos_intptr_t signed same number of bits as a pointer + * khronos_uintptr_t unsigned same number of bits as a pointer + * khronos_ssize_t signed size + * khronos_usize_t unsigned size + * khronos_float_t signed 32 bit floating point + * khronos_time_ns_t unsigned 64 bit time in nanoseconds + * khronos_utime_nanoseconds_t unsigned time interval or absolute time in + * nanoseconds + * khronos_stime_nanoseconds_t signed time interval in nanoseconds + * khronos_boolean_enum_t enumerated boolean type. This should + * only be used as a base type when a client API's boolean type is + * an enum. Client APIs which use an integer or other type for + * booleans cannot use this as the base type for their boolean. + * + * Tokens defined in khrplatform.h: + * + * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. + * + * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. + * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. + * + * Calling convention macros defined in this file: + * KHRONOS_APICALL + * KHRONOS_APIENTRY + * KHRONOS_APIATTRIBUTES + * + * These may be used in function prototypes as: + * + * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( + * int arg1, + * int arg2) KHRONOS_APIATTRIBUTES; + */ + +#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC) +# define KHRONOS_STATIC 1 +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APICALL + *------------------------------------------------------------------------- + * This precedes the return type of the function in the function prototype. + */ +#if defined(KHRONOS_STATIC) + /* If the preprocessor constant KHRONOS_STATIC is defined, make the + * header compatible with static linking. */ +# define KHRONOS_APICALL +#elif defined(_WIN32) +# define KHRONOS_APICALL __declspec(dllimport) +#elif defined (__SYMBIAN32__) +# define KHRONOS_APICALL IMPORT_C +#elif defined(__ANDROID__) +# define KHRONOS_APICALL __attribute__((visibility("default"))) +#else +# define KHRONOS_APICALL +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIENTRY + *------------------------------------------------------------------------- + * This follows the return type of the function and precedes the function + * name in the function prototype. + */ +#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) + /* Win32 but not WinCE */ +# define KHRONOS_APIENTRY __stdcall +#else +# define KHRONOS_APIENTRY +#endif + +/*------------------------------------------------------------------------- + * Definition of KHRONOS_APIATTRIBUTES + *------------------------------------------------------------------------- + * This follows the closing parenthesis of the function prototype arguments. + */ +#if defined (__ARMCC_2__) +#define KHRONOS_APIATTRIBUTES __softfp +#else +#define KHRONOS_APIATTRIBUTES +#endif + +/*------------------------------------------------------------------------- + * basic type definitions + *-----------------------------------------------------------------------*/ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) + + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 +/* + * To support platform where unsigned long cannot be used interchangeably with + * inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t. + * Ideally, we could just use (u)intptr_t everywhere, but this could result in + * ABI breakage if khronos_uintptr_t is changed from unsigned long to + * unsigned long long or similar (this results in different C++ name mangling). + * To avoid changes for existing platforms, we restrict usage of intptr_t to + * platforms where the size of a pointer is larger than the size of long. + */ +#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__) +#if __SIZEOF_POINTER__ > __SIZEOF_LONG__ +#define KHRONOS_USE_INTPTR_T +#endif +#endif + +#elif defined(__VMS ) || defined(__sgi) + +/* + * Using + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) + +/* + * Win32 + */ +typedef __int32 khronos_int32_t; +typedef unsigned __int32 khronos_uint32_t; +typedef __int64 khronos_int64_t; +typedef unsigned __int64 khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif defined(__sun__) || defined(__digital__) + +/* + * Sun or Digital + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#if defined(__arch64__) || defined(_LP64) +typedef long int khronos_int64_t; +typedef unsigned long int khronos_uint64_t; +#else +typedef long long int khronos_int64_t; +typedef unsigned long long int khronos_uint64_t; +#endif /* __arch64__ */ +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#elif 0 + +/* + * Hypothetical platform with no float or int64 support + */ +typedef int khronos_int32_t; +typedef unsigned int khronos_uint32_t; +#define KHRONOS_SUPPORT_INT64 0 +#define KHRONOS_SUPPORT_FLOAT 0 + +#else + +/* + * Generic fallback + */ +#include +typedef int32_t khronos_int32_t; +typedef uint32_t khronos_uint32_t; +typedef int64_t khronos_int64_t; +typedef uint64_t khronos_uint64_t; +#define KHRONOS_SUPPORT_INT64 1 +#define KHRONOS_SUPPORT_FLOAT 1 + +#endif + + +/* + * Types that are (so far) the same on all platforms + */ +typedef signed char khronos_int8_t; +typedef unsigned char khronos_uint8_t; +typedef signed short int khronos_int16_t; +typedef unsigned short int khronos_uint16_t; + +/* + * Types that differ between LLP64 and LP64 architectures - in LLP64, + * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears + * to be the only LLP64 architecture in current use. + */ +#ifdef KHRONOS_USE_INTPTR_T +typedef intptr_t khronos_intptr_t; +typedef uintptr_t khronos_uintptr_t; +#elif defined(_WIN64) +typedef signed long long int khronos_intptr_t; +typedef unsigned long long int khronos_uintptr_t; +#else +typedef signed long int khronos_intptr_t; +typedef unsigned long int khronos_uintptr_t; +#endif + +#if defined(_WIN64) +typedef signed long long int khronos_ssize_t; +typedef unsigned long long int khronos_usize_t; +#else +typedef signed long int khronos_ssize_t; +typedef unsigned long int khronos_usize_t; +#endif + +#if KHRONOS_SUPPORT_FLOAT +/* + * Float type + */ +typedef float khronos_float_t; +#endif + +#if KHRONOS_SUPPORT_INT64 +/* Time types + * + * These types can be used to represent a time interval in nanoseconds or + * an absolute Unadjusted System Time. Unadjusted System Time is the number + * of nanoseconds since some arbitrary system event (e.g. since the last + * time the system booted). The Unadjusted System Time is an unsigned + * 64 bit value that wraps back to 0 every 584 years. Time intervals + * may be either signed or unsigned. + */ +typedef khronos_uint64_t khronos_utime_nanoseconds_t; +typedef khronos_int64_t khronos_stime_nanoseconds_t; +#endif + +/* + * Dummy value used to pad enum types to 32 bits. + */ +#ifndef KHRONOS_MAX_ENUM +#define KHRONOS_MAX_ENUM 0x7FFFFFFF +#endif + +/* + * Enumerated boolean type + * + * Values other than zero should be considered to be true. Therefore + * comparisons should not be made against KHRONOS_TRUE. + */ +typedef enum { + KHRONOS_FALSE = 0, + KHRONOS_TRUE = 1, + KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM +} khronos_boolean_enum_t; + +#endif /* __khrplatform_h_ */ diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std.h new file mode 100644 index 0000000..8ce283e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std.h @@ -0,0 +1,392 @@ +#ifndef VULKAN_VIDEO_CODEC_AV1STD_H_ +#define VULKAN_VIDEO_CODEC_AV1STD_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_av1std is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_av1std 1 +#include "vulkan_video_codecs_common.h" +#define STD_VIDEO_AV1_NUM_REF_FRAMES 8 +#define STD_VIDEO_AV1_REFS_PER_FRAME 7 +#define STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME 8 +#define STD_VIDEO_AV1_MAX_TILE_COLS 64 +#define STD_VIDEO_AV1_MAX_TILE_ROWS 64 +#define STD_VIDEO_AV1_MAX_SEGMENTS 8 +#define STD_VIDEO_AV1_SEG_LVL_MAX 8 +#define STD_VIDEO_AV1_PRIMARY_REF_NONE 7 +#define STD_VIDEO_AV1_SELECT_INTEGER_MV 2 +#define STD_VIDEO_AV1_SELECT_SCREEN_CONTENT_TOOLS 2 +#define STD_VIDEO_AV1_SKIP_MODE_FRAMES 2 +#define STD_VIDEO_AV1_MAX_LOOP_FILTER_STRENGTHS 4 +#define STD_VIDEO_AV1_LOOP_FILTER_ADJUSTMENTS 2 +#define STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS 8 +#define STD_VIDEO_AV1_MAX_NUM_PLANES 3 +#define STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS 6 +#define STD_VIDEO_AV1_MAX_NUM_Y_POINTS 14 +#define STD_VIDEO_AV1_MAX_NUM_CB_POINTS 10 +#define STD_VIDEO_AV1_MAX_NUM_CR_POINTS 10 +#define STD_VIDEO_AV1_MAX_NUM_POS_LUMA 24 +#define STD_VIDEO_AV1_MAX_NUM_POS_CHROMA 25 + +typedef enum StdVideoAV1Profile { + STD_VIDEO_AV1_PROFILE_MAIN = 0, + STD_VIDEO_AV1_PROFILE_HIGH = 1, + STD_VIDEO_AV1_PROFILE_PROFESSIONAL = 2, + STD_VIDEO_AV1_PROFILE_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_PROFILE_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1Profile; + +typedef enum StdVideoAV1Level { + STD_VIDEO_AV1_LEVEL_2_0 = 0, + STD_VIDEO_AV1_LEVEL_2_1 = 1, + STD_VIDEO_AV1_LEVEL_2_2 = 2, + STD_VIDEO_AV1_LEVEL_2_3 = 3, + STD_VIDEO_AV1_LEVEL_3_0 = 4, + STD_VIDEO_AV1_LEVEL_3_1 = 5, + STD_VIDEO_AV1_LEVEL_3_2 = 6, + STD_VIDEO_AV1_LEVEL_3_3 = 7, + STD_VIDEO_AV1_LEVEL_4_0 = 8, + STD_VIDEO_AV1_LEVEL_4_1 = 9, + STD_VIDEO_AV1_LEVEL_4_2 = 10, + STD_VIDEO_AV1_LEVEL_4_3 = 11, + STD_VIDEO_AV1_LEVEL_5_0 = 12, + STD_VIDEO_AV1_LEVEL_5_1 = 13, + STD_VIDEO_AV1_LEVEL_5_2 = 14, + STD_VIDEO_AV1_LEVEL_5_3 = 15, + STD_VIDEO_AV1_LEVEL_6_0 = 16, + STD_VIDEO_AV1_LEVEL_6_1 = 17, + STD_VIDEO_AV1_LEVEL_6_2 = 18, + STD_VIDEO_AV1_LEVEL_6_3 = 19, + STD_VIDEO_AV1_LEVEL_7_0 = 20, + STD_VIDEO_AV1_LEVEL_7_1 = 21, + STD_VIDEO_AV1_LEVEL_7_2 = 22, + STD_VIDEO_AV1_LEVEL_7_3 = 23, + STD_VIDEO_AV1_LEVEL_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_LEVEL_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1Level; + +typedef enum StdVideoAV1FrameType { + STD_VIDEO_AV1_FRAME_TYPE_KEY = 0, + STD_VIDEO_AV1_FRAME_TYPE_INTER = 1, + STD_VIDEO_AV1_FRAME_TYPE_INTRA_ONLY = 2, + STD_VIDEO_AV1_FRAME_TYPE_SWITCH = 3, + STD_VIDEO_AV1_FRAME_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_FRAME_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1FrameType; + +typedef enum StdVideoAV1ReferenceName { + STD_VIDEO_AV1_REFERENCE_NAME_INTRA_FRAME = 0, + STD_VIDEO_AV1_REFERENCE_NAME_LAST_FRAME = 1, + STD_VIDEO_AV1_REFERENCE_NAME_LAST2_FRAME = 2, + STD_VIDEO_AV1_REFERENCE_NAME_LAST3_FRAME = 3, + STD_VIDEO_AV1_REFERENCE_NAME_GOLDEN_FRAME = 4, + STD_VIDEO_AV1_REFERENCE_NAME_BWDREF_FRAME = 5, + STD_VIDEO_AV1_REFERENCE_NAME_ALTREF2_FRAME = 6, + STD_VIDEO_AV1_REFERENCE_NAME_ALTREF_FRAME = 7, + STD_VIDEO_AV1_REFERENCE_NAME_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_REFERENCE_NAME_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1ReferenceName; + +typedef enum StdVideoAV1InterpolationFilter { + STD_VIDEO_AV1_INTERPOLATION_FILTER_EIGHTTAP = 0, + STD_VIDEO_AV1_INTERPOLATION_FILTER_EIGHTTAP_SMOOTH = 1, + STD_VIDEO_AV1_INTERPOLATION_FILTER_EIGHTTAP_SHARP = 2, + STD_VIDEO_AV1_INTERPOLATION_FILTER_BILINEAR = 3, + STD_VIDEO_AV1_INTERPOLATION_FILTER_SWITCHABLE = 4, + STD_VIDEO_AV1_INTERPOLATION_FILTER_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_INTERPOLATION_FILTER_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1InterpolationFilter; + +typedef enum StdVideoAV1TxMode { + STD_VIDEO_AV1_TX_MODE_ONLY_4X4 = 0, + STD_VIDEO_AV1_TX_MODE_LARGEST = 1, + STD_VIDEO_AV1_TX_MODE_SELECT = 2, + STD_VIDEO_AV1_TX_MODE_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_TX_MODE_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1TxMode; + +typedef enum StdVideoAV1FrameRestorationType { + STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE = 0, + STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_WIENER = 1, + STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SGRPROJ = 2, + STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SWITCHABLE = 3, + STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1FrameRestorationType; + +typedef enum StdVideoAV1ColorPrimaries { + STD_VIDEO_AV1_COLOR_PRIMARIES_BT_709 = 1, + STD_VIDEO_AV1_COLOR_PRIMARIES_BT_UNSPECIFIED = 2, + STD_VIDEO_AV1_COLOR_PRIMARIES_BT_470_M = 4, + STD_VIDEO_AV1_COLOR_PRIMARIES_BT_470_B_G = 5, + STD_VIDEO_AV1_COLOR_PRIMARIES_BT_601 = 6, + STD_VIDEO_AV1_COLOR_PRIMARIES_SMPTE_240 = 7, + STD_VIDEO_AV1_COLOR_PRIMARIES_GENERIC_FILM = 8, + STD_VIDEO_AV1_COLOR_PRIMARIES_BT_2020 = 9, + STD_VIDEO_AV1_COLOR_PRIMARIES_XYZ = 10, + STD_VIDEO_AV1_COLOR_PRIMARIES_SMPTE_431 = 11, + STD_VIDEO_AV1_COLOR_PRIMARIES_SMPTE_432 = 12, + STD_VIDEO_AV1_COLOR_PRIMARIES_EBU_3213 = 22, + STD_VIDEO_AV1_COLOR_PRIMARIES_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_COLOR_PRIMARIES_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1ColorPrimaries; + +typedef enum StdVideoAV1TransferCharacteristics { + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_RESERVED_0 = 0, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_709 = 1, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_UNSPECIFIED = 2, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_RESERVED_3 = 3, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_470_M = 4, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_470_B_G = 5, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_601 = 6, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SMPTE_240 = 7, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_LINEAR = 8, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_LOG_100 = 9, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_LOG_100_SQRT10 = 10, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_IEC_61966 = 11, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_1361 = 12, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SRGB = 13, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_2020_10_BIT = 14, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_BT_2020_12_BIT = 15, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SMPTE_2084 = 16, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_SMPTE_428 = 17, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_HLG = 18, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_TRANSFER_CHARACTERISTICS_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1TransferCharacteristics; + +typedef enum StdVideoAV1MatrixCoefficients { + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_IDENTITY = 0, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_709 = 1, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_UNSPECIFIED = 2, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_RESERVED_3 = 3, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_FCC = 4, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_470_B_G = 5, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_601 = 6, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_SMPTE_240 = 7, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_SMPTE_YCGCO = 8, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_2020_NCL = 9, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_BT_2020_CL = 10, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_SMPTE_2085 = 11, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_CHROMAT_NCL = 12, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_CHROMAT_CL = 13, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_ICTCP = 14, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_MATRIX_COEFFICIENTS_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1MatrixCoefficients; + +typedef enum StdVideoAV1ChromaSamplePosition { + STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_UNKNOWN = 0, + STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_VERTICAL = 1, + STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_COLOCATED = 2, + STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_RESERVED = 3, + STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_INVALID = 0x7FFFFFFF, + STD_VIDEO_AV1_CHROMA_SAMPLE_POSITION_MAX_ENUM = 0x7FFFFFFF +} StdVideoAV1ChromaSamplePosition; +typedef struct StdVideoAV1ColorConfigFlags { + uint32_t mono_chrome : 1; + uint32_t color_range : 1; + uint32_t separate_uv_delta_q : 1; + uint32_t color_description_present_flag : 1; + uint32_t reserved : 28; +} StdVideoAV1ColorConfigFlags; + +typedef struct StdVideoAV1ColorConfig { + StdVideoAV1ColorConfigFlags flags; + uint8_t BitDepth; + uint8_t subsampling_x; + uint8_t subsampling_y; + uint8_t reserved1; + StdVideoAV1ColorPrimaries color_primaries; + StdVideoAV1TransferCharacteristics transfer_characteristics; + StdVideoAV1MatrixCoefficients matrix_coefficients; + StdVideoAV1ChromaSamplePosition chroma_sample_position; +} StdVideoAV1ColorConfig; + +typedef struct StdVideoAV1TimingInfoFlags { + uint32_t equal_picture_interval : 1; + uint32_t reserved : 31; +} StdVideoAV1TimingInfoFlags; + +typedef struct StdVideoAV1TimingInfo { + StdVideoAV1TimingInfoFlags flags; + uint32_t num_units_in_display_tick; + uint32_t time_scale; + uint32_t num_ticks_per_picture_minus_1; +} StdVideoAV1TimingInfo; + +typedef struct StdVideoAV1LoopFilterFlags { + uint32_t loop_filter_delta_enabled : 1; + uint32_t loop_filter_delta_update : 1; + uint32_t reserved : 30; +} StdVideoAV1LoopFilterFlags; + +typedef struct StdVideoAV1LoopFilter { + StdVideoAV1LoopFilterFlags flags; + uint8_t loop_filter_level[STD_VIDEO_AV1_MAX_LOOP_FILTER_STRENGTHS]; + uint8_t loop_filter_sharpness; + uint8_t update_ref_delta; + int8_t loop_filter_ref_deltas[STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME]; + uint8_t update_mode_delta; + int8_t loop_filter_mode_deltas[STD_VIDEO_AV1_LOOP_FILTER_ADJUSTMENTS]; +} StdVideoAV1LoopFilter; + +typedef struct StdVideoAV1QuantizationFlags { + uint32_t using_qmatrix : 1; + uint32_t diff_uv_delta : 1; + uint32_t reserved : 30; +} StdVideoAV1QuantizationFlags; + +typedef struct StdVideoAV1Quantization { + StdVideoAV1QuantizationFlags flags; + uint8_t base_q_idx; + int8_t DeltaQYDc; + int8_t DeltaQUDc; + int8_t DeltaQUAc; + int8_t DeltaQVDc; + int8_t DeltaQVAc; + uint8_t qm_y; + uint8_t qm_u; + uint8_t qm_v; +} StdVideoAV1Quantization; + +typedef struct StdVideoAV1Segmentation { + uint8_t FeatureEnabled[STD_VIDEO_AV1_MAX_SEGMENTS]; + int16_t FeatureData[STD_VIDEO_AV1_MAX_SEGMENTS][STD_VIDEO_AV1_SEG_LVL_MAX]; +} StdVideoAV1Segmentation; + +typedef struct StdVideoAV1TileInfoFlags { + uint32_t uniform_tile_spacing_flag : 1; + uint32_t reserved : 31; +} StdVideoAV1TileInfoFlags; + +typedef struct StdVideoAV1TileInfo { + StdVideoAV1TileInfoFlags flags; + uint8_t TileCols; + uint8_t TileRows; + uint16_t context_update_tile_id; + uint8_t tile_size_bytes_minus_1; + uint8_t reserved1[7]; + const uint16_t* pMiColStarts; + const uint16_t* pMiRowStarts; + const uint16_t* pWidthInSbsMinus1; + const uint16_t* pHeightInSbsMinus1; +} StdVideoAV1TileInfo; + +typedef struct StdVideoAV1CDEF { + uint8_t cdef_damping_minus_3; + uint8_t cdef_bits; + uint8_t cdef_y_pri_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS]; + uint8_t cdef_y_sec_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS]; + uint8_t cdef_uv_pri_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS]; + uint8_t cdef_uv_sec_strength[STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS]; +} StdVideoAV1CDEF; + +typedef struct StdVideoAV1LoopRestoration { + StdVideoAV1FrameRestorationType FrameRestorationType[STD_VIDEO_AV1_MAX_NUM_PLANES]; + uint16_t LoopRestorationSize[STD_VIDEO_AV1_MAX_NUM_PLANES]; +} StdVideoAV1LoopRestoration; + +typedef struct StdVideoAV1GlobalMotion { + uint8_t GmType[STD_VIDEO_AV1_NUM_REF_FRAMES]; + int32_t gm_params[STD_VIDEO_AV1_NUM_REF_FRAMES][STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS]; +} StdVideoAV1GlobalMotion; + +typedef struct StdVideoAV1FilmGrainFlags { + uint32_t chroma_scaling_from_luma : 1; + uint32_t overlap_flag : 1; + uint32_t clip_to_restricted_range : 1; + uint32_t update_grain : 1; + uint32_t reserved : 28; +} StdVideoAV1FilmGrainFlags; + +typedef struct StdVideoAV1FilmGrain { + StdVideoAV1FilmGrainFlags flags; + uint8_t grain_scaling_minus_8; + uint8_t ar_coeff_lag; + uint8_t ar_coeff_shift_minus_6; + uint8_t grain_scale_shift; + uint16_t grain_seed; + uint8_t film_grain_params_ref_idx; + uint8_t num_y_points; + uint8_t point_y_value[STD_VIDEO_AV1_MAX_NUM_Y_POINTS]; + uint8_t point_y_scaling[STD_VIDEO_AV1_MAX_NUM_Y_POINTS]; + uint8_t num_cb_points; + uint8_t point_cb_value[STD_VIDEO_AV1_MAX_NUM_CB_POINTS]; + uint8_t point_cb_scaling[STD_VIDEO_AV1_MAX_NUM_CB_POINTS]; + uint8_t num_cr_points; + uint8_t point_cr_value[STD_VIDEO_AV1_MAX_NUM_CR_POINTS]; + uint8_t point_cr_scaling[STD_VIDEO_AV1_MAX_NUM_CR_POINTS]; + int8_t ar_coeffs_y_plus_128[STD_VIDEO_AV1_MAX_NUM_POS_LUMA]; + int8_t ar_coeffs_cb_plus_128[STD_VIDEO_AV1_MAX_NUM_POS_CHROMA]; + int8_t ar_coeffs_cr_plus_128[STD_VIDEO_AV1_MAX_NUM_POS_CHROMA]; + uint8_t cb_mult; + uint8_t cb_luma_mult; + uint16_t cb_offset; + uint8_t cr_mult; + uint8_t cr_luma_mult; + uint16_t cr_offset; +} StdVideoAV1FilmGrain; + +typedef struct StdVideoAV1SequenceHeaderFlags { + uint32_t still_picture : 1; + uint32_t reduced_still_picture_header : 1; + uint32_t use_128x128_superblock : 1; + uint32_t enable_filter_intra : 1; + uint32_t enable_intra_edge_filter : 1; + uint32_t enable_interintra_compound : 1; + uint32_t enable_masked_compound : 1; + uint32_t enable_warped_motion : 1; + uint32_t enable_dual_filter : 1; + uint32_t enable_order_hint : 1; + uint32_t enable_jnt_comp : 1; + uint32_t enable_ref_frame_mvs : 1; + uint32_t frame_id_numbers_present_flag : 1; + uint32_t enable_superres : 1; + uint32_t enable_cdef : 1; + uint32_t enable_restoration : 1; + uint32_t film_grain_params_present : 1; + uint32_t timing_info_present_flag : 1; + uint32_t initial_display_delay_present_flag : 1; + uint32_t reserved : 13; +} StdVideoAV1SequenceHeaderFlags; + +typedef struct StdVideoAV1SequenceHeader { + StdVideoAV1SequenceHeaderFlags flags; + StdVideoAV1Profile seq_profile; + uint8_t frame_width_bits_minus_1; + uint8_t frame_height_bits_minus_1; + uint16_t max_frame_width_minus_1; + uint16_t max_frame_height_minus_1; + uint8_t delta_frame_id_length_minus_2; + uint8_t additional_frame_id_length_minus_1; + uint8_t order_hint_bits_minus_1; + uint8_t seq_force_integer_mv; + uint8_t seq_force_screen_content_tools; + uint8_t reserved1[5]; + const StdVideoAV1ColorConfig* pColorConfig; + const StdVideoAV1TimingInfo* pTimingInfo; +} StdVideoAV1SequenceHeader; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std_decode.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std_decode.h new file mode 100644 index 0000000..6b8130c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_av1std_decode.h @@ -0,0 +1,109 @@ +#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_av1std_decode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_av1std_decode 1 +#include "vulkan_video_codec_av1std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_av1_decode" +typedef struct StdVideoDecodeAV1PictureInfoFlags { + uint32_t error_resilient_mode : 1; + uint32_t disable_cdf_update : 1; + uint32_t use_superres : 1; + uint32_t render_and_frame_size_different : 1; + uint32_t allow_screen_content_tools : 1; + uint32_t is_filter_switchable : 1; + uint32_t force_integer_mv : 1; + uint32_t frame_size_override_flag : 1; + uint32_t buffer_removal_time_present_flag : 1; + uint32_t allow_intrabc : 1; + uint32_t frame_refs_short_signaling : 1; + uint32_t allow_high_precision_mv : 1; + uint32_t is_motion_mode_switchable : 1; + uint32_t use_ref_frame_mvs : 1; + uint32_t disable_frame_end_update_cdf : 1; + uint32_t allow_warped_motion : 1; + uint32_t reduced_tx_set : 1; + uint32_t reference_select : 1; + uint32_t skip_mode_present : 1; + uint32_t delta_q_present : 1; + uint32_t delta_lf_present : 1; + uint32_t delta_lf_multi : 1; + uint32_t segmentation_enabled : 1; + uint32_t segmentation_update_map : 1; + uint32_t segmentation_temporal_update : 1; + uint32_t segmentation_update_data : 1; + uint32_t UsesLr : 1; + uint32_t usesChromaLr : 1; + uint32_t apply_grain : 1; + uint32_t reserved : 3; +} StdVideoDecodeAV1PictureInfoFlags; + +typedef struct StdVideoDecodeAV1PictureInfo { + StdVideoDecodeAV1PictureInfoFlags flags; + StdVideoAV1FrameType frame_type; + uint32_t current_frame_id; + uint8_t OrderHint; + uint8_t primary_ref_frame; + uint8_t refresh_frame_flags; + uint8_t reserved1; + StdVideoAV1InterpolationFilter interpolation_filter; + StdVideoAV1TxMode TxMode; + uint8_t delta_q_res; + uint8_t delta_lf_res; + uint8_t SkipModeFrame[STD_VIDEO_AV1_SKIP_MODE_FRAMES]; + uint8_t coded_denom; + uint8_t reserved2[3]; + uint8_t OrderHints[STD_VIDEO_AV1_NUM_REF_FRAMES]; + uint32_t expectedFrameId[STD_VIDEO_AV1_NUM_REF_FRAMES]; + const StdVideoAV1TileInfo* pTileInfo; + const StdVideoAV1Quantization* pQuantization; + const StdVideoAV1Segmentation* pSegmentation; + const StdVideoAV1LoopFilter* pLoopFilter; + const StdVideoAV1CDEF* pCDEF; + const StdVideoAV1LoopRestoration* pLoopRestoration; + const StdVideoAV1GlobalMotion* pGlobalMotion; + const StdVideoAV1FilmGrain* pFilmGrain; +} StdVideoDecodeAV1PictureInfo; + +typedef struct StdVideoDecodeAV1ReferenceInfoFlags { + uint32_t disable_frame_end_update_cdf : 1; + uint32_t segmentation_enabled : 1; + uint32_t reserved : 30; +} StdVideoDecodeAV1ReferenceInfoFlags; + +typedef struct StdVideoDecodeAV1ReferenceInfo { + StdVideoDecodeAV1ReferenceInfoFlags flags; + uint8_t frame_type; + uint8_t RefFrameSignBias; + uint8_t OrderHint; + uint8_t SavedOrderHints[STD_VIDEO_AV1_NUM_REF_FRAMES]; +} StdVideoDecodeAV1ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std.h new file mode 100644 index 0000000..6d27af3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std.h @@ -0,0 +1,312 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_H_ +#define VULKAN_VIDEO_CODEC_H264STD_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h264std is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h264std 1 +#include "vulkan_video_codecs_common.h" +#define STD_VIDEO_H264_CPB_CNT_LIST_SIZE 32 +#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS 6 +#define STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS 16 +#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS 6 +#define STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS 64 +#define STD_VIDEO_H264_MAX_NUM_LIST_REF 32 +#define STD_VIDEO_H264_MAX_CHROMA_PLANES 2 +#define STD_VIDEO_H264_NO_REFERENCE_PICTURE 0xFF + +typedef enum StdVideoH264ChromaFormatIdc { + STD_VIDEO_H264_CHROMA_FORMAT_IDC_MONOCHROME = 0, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_420 = 1, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_422 = 2, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_444 = 3, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ChromaFormatIdc; + +typedef enum StdVideoH264ProfileIdc { + STD_VIDEO_H264_PROFILE_IDC_BASELINE = 66, + STD_VIDEO_H264_PROFILE_IDC_MAIN = 77, + STD_VIDEO_H264_PROFILE_IDC_HIGH = 100, + STD_VIDEO_H264_PROFILE_IDC_HIGH_444_PREDICTIVE = 244, + STD_VIDEO_H264_PROFILE_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ProfileIdc; + +typedef enum StdVideoH264LevelIdc { + STD_VIDEO_H264_LEVEL_IDC_1_0 = 0, + STD_VIDEO_H264_LEVEL_IDC_1_1 = 1, + STD_VIDEO_H264_LEVEL_IDC_1_2 = 2, + STD_VIDEO_H264_LEVEL_IDC_1_3 = 3, + STD_VIDEO_H264_LEVEL_IDC_2_0 = 4, + STD_VIDEO_H264_LEVEL_IDC_2_1 = 5, + STD_VIDEO_H264_LEVEL_IDC_2_2 = 6, + STD_VIDEO_H264_LEVEL_IDC_3_0 = 7, + STD_VIDEO_H264_LEVEL_IDC_3_1 = 8, + STD_VIDEO_H264_LEVEL_IDC_3_2 = 9, + STD_VIDEO_H264_LEVEL_IDC_4_0 = 10, + STD_VIDEO_H264_LEVEL_IDC_4_1 = 11, + STD_VIDEO_H264_LEVEL_IDC_4_2 = 12, + STD_VIDEO_H264_LEVEL_IDC_5_0 = 13, + STD_VIDEO_H264_LEVEL_IDC_5_1 = 14, + STD_VIDEO_H264_LEVEL_IDC_5_2 = 15, + STD_VIDEO_H264_LEVEL_IDC_6_0 = 16, + STD_VIDEO_H264_LEVEL_IDC_6_1 = 17, + STD_VIDEO_H264_LEVEL_IDC_6_2 = 18, + STD_VIDEO_H264_LEVEL_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264LevelIdc; + +typedef enum StdVideoH264PocType { + STD_VIDEO_H264_POC_TYPE_0 = 0, + STD_VIDEO_H264_POC_TYPE_1 = 1, + STD_VIDEO_H264_POC_TYPE_2 = 2, + STD_VIDEO_H264_POC_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_POC_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264PocType; + +typedef enum StdVideoH264AspectRatioIdc { + STD_VIDEO_H264_ASPECT_RATIO_IDC_UNSPECIFIED = 0, + STD_VIDEO_H264_ASPECT_RATIO_IDC_SQUARE = 1, + STD_VIDEO_H264_ASPECT_RATIO_IDC_12_11 = 2, + STD_VIDEO_H264_ASPECT_RATIO_IDC_10_11 = 3, + STD_VIDEO_H264_ASPECT_RATIO_IDC_16_11 = 4, + STD_VIDEO_H264_ASPECT_RATIO_IDC_40_33 = 5, + STD_VIDEO_H264_ASPECT_RATIO_IDC_24_11 = 6, + STD_VIDEO_H264_ASPECT_RATIO_IDC_20_11 = 7, + STD_VIDEO_H264_ASPECT_RATIO_IDC_32_11 = 8, + STD_VIDEO_H264_ASPECT_RATIO_IDC_80_33 = 9, + STD_VIDEO_H264_ASPECT_RATIO_IDC_18_11 = 10, + STD_VIDEO_H264_ASPECT_RATIO_IDC_15_11 = 11, + STD_VIDEO_H264_ASPECT_RATIO_IDC_64_33 = 12, + STD_VIDEO_H264_ASPECT_RATIO_IDC_160_99 = 13, + STD_VIDEO_H264_ASPECT_RATIO_IDC_4_3 = 14, + STD_VIDEO_H264_ASPECT_RATIO_IDC_3_2 = 15, + STD_VIDEO_H264_ASPECT_RATIO_IDC_2_1 = 16, + STD_VIDEO_H264_ASPECT_RATIO_IDC_EXTENDED_SAR = 255, + STD_VIDEO_H264_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264AspectRatioIdc; + +typedef enum StdVideoH264WeightedBipredIdc { + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_DEFAULT = 0, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_EXPLICIT = 1, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_IMPLICIT = 2, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_WEIGHTED_BIPRED_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264WeightedBipredIdc; + +typedef enum StdVideoH264ModificationOfPicNumsIdc { + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_SUBTRACT = 0, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_SHORT_TERM_ADD = 1, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_LONG_TERM = 2, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_END = 3, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_MODIFICATION_OF_PIC_NUMS_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264ModificationOfPicNumsIdc; + +typedef enum StdVideoH264MemMgmtControlOp { + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_END = 0, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_SHORT_TERM = 1, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_LONG_TERM = 2, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_LONG_TERM = 3, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_SET_MAX_LONG_TERM_INDEX = 4, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_UNMARK_ALL = 5, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MARK_CURRENT_AS_LONG_TERM = 6, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_MEM_MGMT_CONTROL_OP_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264MemMgmtControlOp; + +typedef enum StdVideoH264CabacInitIdc { + STD_VIDEO_H264_CABAC_INIT_IDC_0 = 0, + STD_VIDEO_H264_CABAC_INIT_IDC_1 = 1, + STD_VIDEO_H264_CABAC_INIT_IDC_2 = 2, + STD_VIDEO_H264_CABAC_INIT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_CABAC_INIT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264CabacInitIdc; + +typedef enum StdVideoH264DisableDeblockingFilterIdc { + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_DISABLED = 0, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_ENABLED = 1, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_PARTIAL = 2, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_DISABLE_DEBLOCKING_FILTER_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264DisableDeblockingFilterIdc; + +typedef enum StdVideoH264SliceType { + STD_VIDEO_H264_SLICE_TYPE_P = 0, + STD_VIDEO_H264_SLICE_TYPE_B = 1, + STD_VIDEO_H264_SLICE_TYPE_I = 2, + STD_VIDEO_H264_SLICE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264SliceType; + +typedef enum StdVideoH264PictureType { + STD_VIDEO_H264_PICTURE_TYPE_P = 0, + STD_VIDEO_H264_PICTURE_TYPE_B = 1, + STD_VIDEO_H264_PICTURE_TYPE_I = 2, + STD_VIDEO_H264_PICTURE_TYPE_IDR = 5, + STD_VIDEO_H264_PICTURE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264PictureType; + +typedef enum StdVideoH264NonVclNaluType { + STD_VIDEO_H264_NON_VCL_NALU_TYPE_SPS = 0, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PPS = 1, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_AUD = 2, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PREFIX = 3, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_SEQUENCE = 4, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_END_OF_STREAM = 5, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_PRECODED = 6, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H264_NON_VCL_NALU_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH264NonVclNaluType; +typedef struct StdVideoH264SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag : 1; + uint32_t overscan_info_present_flag : 1; + uint32_t overscan_appropriate_flag : 1; + uint32_t video_signal_type_present_flag : 1; + uint32_t video_full_range_flag : 1; + uint32_t color_description_present_flag : 1; + uint32_t chroma_loc_info_present_flag : 1; + uint32_t timing_info_present_flag : 1; + uint32_t fixed_frame_rate_flag : 1; + uint32_t bitstream_restriction_flag : 1; + uint32_t nal_hrd_parameters_present_flag : 1; + uint32_t vcl_hrd_parameters_present_flag : 1; +} StdVideoH264SpsVuiFlags; + +typedef struct StdVideoH264HrdParameters { + uint8_t cpb_cnt_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint8_t reserved1; + uint32_t bit_rate_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_value_minus1[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint8_t cbr_flag[STD_VIDEO_H264_CPB_CNT_LIST_SIZE]; + uint32_t initial_cpb_removal_delay_length_minus1; + uint32_t cpb_removal_delay_length_minus1; + uint32_t dpb_output_delay_length_minus1; + uint32_t time_offset_length; +} StdVideoH264HrdParameters; + +typedef struct StdVideoH264SequenceParameterSetVui { + StdVideoH264SpsVuiFlags flags; + StdVideoH264AspectRatioIdc aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coefficients; + uint32_t num_units_in_tick; + uint32_t time_scale; + uint8_t max_num_reorder_frames; + uint8_t max_dec_frame_buffering; + uint8_t chroma_sample_loc_type_top_field; + uint8_t chroma_sample_loc_type_bottom_field; + uint32_t reserved1; + const StdVideoH264HrdParameters* pHrdParameters; +} StdVideoH264SequenceParameterSetVui; + +typedef struct StdVideoH264SpsFlags { + uint32_t constraint_set0_flag : 1; + uint32_t constraint_set1_flag : 1; + uint32_t constraint_set2_flag : 1; + uint32_t constraint_set3_flag : 1; + uint32_t constraint_set4_flag : 1; + uint32_t constraint_set5_flag : 1; + uint32_t direct_8x8_inference_flag : 1; + uint32_t mb_adaptive_frame_field_flag : 1; + uint32_t frame_mbs_only_flag : 1; + uint32_t delta_pic_order_always_zero_flag : 1; + uint32_t separate_colour_plane_flag : 1; + uint32_t gaps_in_frame_num_value_allowed_flag : 1; + uint32_t qpprime_y_zero_transform_bypass_flag : 1; + uint32_t frame_cropping_flag : 1; + uint32_t seq_scaling_matrix_present_flag : 1; + uint32_t vui_parameters_present_flag : 1; +} StdVideoH264SpsFlags; + +typedef struct StdVideoH264ScalingLists { + uint16_t scaling_list_present_mask; + uint16_t use_default_scaling_matrix_mask; + uint8_t ScalingList4x4[STD_VIDEO_H264_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_4X4_NUM_ELEMENTS]; + uint8_t ScalingList8x8[STD_VIDEO_H264_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H264_SCALING_LIST_8X8_NUM_ELEMENTS]; +} StdVideoH264ScalingLists; + +typedef struct StdVideoH264SequenceParameterSet { + StdVideoH264SpsFlags flags; + StdVideoH264ProfileIdc profile_idc; + StdVideoH264LevelIdc level_idc; + StdVideoH264ChromaFormatIdc chroma_format_idc; + uint8_t seq_parameter_set_id; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_frame_num_minus4; + StdVideoH264PocType pic_order_cnt_type; + int32_t offset_for_non_ref_pic; + int32_t offset_for_top_to_bottom_field; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t num_ref_frames_in_pic_order_cnt_cycle; + uint8_t max_num_ref_frames; + uint8_t reserved1; + uint32_t pic_width_in_mbs_minus1; + uint32_t pic_height_in_map_units_minus1; + uint32_t frame_crop_left_offset; + uint32_t frame_crop_right_offset; + uint32_t frame_crop_top_offset; + uint32_t frame_crop_bottom_offset; + uint32_t reserved2; + const int32_t* pOffsetForRefFrame; + const StdVideoH264ScalingLists* pScalingLists; + const StdVideoH264SequenceParameterSetVui* pSequenceParameterSetVui; +} StdVideoH264SequenceParameterSet; + +typedef struct StdVideoH264PpsFlags { + uint32_t transform_8x8_mode_flag : 1; + uint32_t redundant_pic_cnt_present_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t bottom_field_pic_order_in_frame_present_flag : 1; + uint32_t entropy_coding_mode_flag : 1; + uint32_t pic_scaling_matrix_present_flag : 1; +} StdVideoH264PpsFlags; + +typedef struct StdVideoH264PictureParameterSet { + StdVideoH264PpsFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + StdVideoH264WeightedBipredIdc weighted_bipred_idc; + int8_t pic_init_qp_minus26; + int8_t pic_init_qs_minus26; + int8_t chroma_qp_index_offset; + int8_t second_chroma_qp_index_offset; + const StdVideoH264ScalingLists* pScalingLists; +} StdVideoH264PictureParameterSet; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h new file mode 100644 index 0000000..439cb88 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_decode.h @@ -0,0 +1,77 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H264STD_DECODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h264std_decode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h264std_decode 1 +#include "vulkan_video_codec_h264std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H264_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_decode" +#define STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE 2 + +typedef enum StdVideoDecodeH264FieldOrderCount { + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_TOP = 0, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_BOTTOM = 1, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_INVALID = 0x7FFFFFFF, + STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_MAX_ENUM = 0x7FFFFFFF +} StdVideoDecodeH264FieldOrderCount; +typedef struct StdVideoDecodeH264PictureInfoFlags { + uint32_t field_pic_flag : 1; + uint32_t is_intra : 1; + uint32_t IdrPicFlag : 1; + uint32_t bottom_field_flag : 1; + uint32_t is_reference : 1; + uint32_t complementary_field_pair : 1; +} StdVideoDecodeH264PictureInfoFlags; + +typedef struct StdVideoDecodeH264PictureInfo { + StdVideoDecodeH264PictureInfoFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint8_t reserved1; + uint8_t reserved2; + uint16_t frame_num; + uint16_t idr_pic_id; + int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; +} StdVideoDecodeH264PictureInfo; + +typedef struct StdVideoDecodeH264ReferenceInfoFlags { + uint32_t top_field_flag : 1; + uint32_t bottom_field_flag : 1; + uint32_t used_for_long_term_reference : 1; + uint32_t is_non_existing : 1; +} StdVideoDecodeH264ReferenceInfoFlags; + +typedef struct StdVideoDecodeH264ReferenceInfo { + StdVideoDecodeH264ReferenceInfoFlags flags; + uint16_t FrameNum; + uint16_t reserved; + int32_t PicOrderCnt[STD_VIDEO_DECODE_H264_FIELD_ORDER_COUNT_LIST_SIZE]; +} StdVideoDecodeH264ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h new file mode 100644 index 0000000..9e24aa5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h264std_encode.h @@ -0,0 +1,147 @@ +#ifndef VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ +#define VULKAN_VIDEO_CODEC_H264STD_ENCODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h264std_encode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h264std_encode 1 +#include "vulkan_video_codec_h264std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H264_ENCODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h264_encode" +typedef struct StdVideoEncodeH264WeightTableFlags { + uint32_t luma_weight_l0_flag; + uint32_t chroma_weight_l0_flag; + uint32_t luma_weight_l1_flag; + uint32_t chroma_weight_l1_flag; +} StdVideoEncodeH264WeightTableFlags; + +typedef struct StdVideoEncodeH264WeightTable { + StdVideoEncodeH264WeightTableFlags flags; + uint8_t luma_log2_weight_denom; + uint8_t chroma_log2_weight_denom; + int8_t luma_weight_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t luma_offset_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t chroma_weight_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; + int8_t chroma_offset_l0[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; + int8_t luma_weight_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t luma_offset_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + int8_t chroma_weight_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; + int8_t chroma_offset_l1[STD_VIDEO_H264_MAX_NUM_LIST_REF][STD_VIDEO_H264_MAX_CHROMA_PLANES]; +} StdVideoEncodeH264WeightTable; + +typedef struct StdVideoEncodeH264SliceHeaderFlags { + uint32_t direct_spatial_mv_pred_flag : 1; + uint32_t num_ref_idx_active_override_flag : 1; + uint32_t reserved : 30; +} StdVideoEncodeH264SliceHeaderFlags; + +typedef struct StdVideoEncodeH264PictureInfoFlags { + uint32_t IdrPicFlag : 1; + uint32_t is_reference : 1; + uint32_t no_output_of_prior_pics_flag : 1; + uint32_t long_term_reference_flag : 1; + uint32_t adaptive_ref_pic_marking_mode_flag : 1; + uint32_t reserved : 27; +} StdVideoEncodeH264PictureInfoFlags; + +typedef struct StdVideoEncodeH264ReferenceInfoFlags { + uint32_t used_for_long_term_reference : 1; + uint32_t reserved : 31; +} StdVideoEncodeH264ReferenceInfoFlags; + +typedef struct StdVideoEncodeH264ReferenceListsInfoFlags { + uint32_t ref_pic_list_modification_flag_l0 : 1; + uint32_t ref_pic_list_modification_flag_l1 : 1; + uint32_t reserved : 30; +} StdVideoEncodeH264ReferenceListsInfoFlags; + +typedef struct StdVideoEncodeH264RefListModEntry { + StdVideoH264ModificationOfPicNumsIdc modification_of_pic_nums_idc; + uint16_t abs_diff_pic_num_minus1; + uint16_t long_term_pic_num; +} StdVideoEncodeH264RefListModEntry; + +typedef struct StdVideoEncodeH264RefPicMarkingEntry { + StdVideoH264MemMgmtControlOp memory_management_control_operation; + uint16_t difference_of_pic_nums_minus1; + uint16_t long_term_pic_num; + uint16_t long_term_frame_idx; + uint16_t max_long_term_frame_idx_plus1; +} StdVideoEncodeH264RefPicMarkingEntry; + +typedef struct StdVideoEncodeH264ReferenceListsInfo { + StdVideoEncodeH264ReferenceListsInfoFlags flags; + uint8_t num_ref_idx_l0_active_minus1; + uint8_t num_ref_idx_l1_active_minus1; + uint8_t RefPicList0[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + uint8_t RefPicList1[STD_VIDEO_H264_MAX_NUM_LIST_REF]; + uint8_t refList0ModOpCount; + uint8_t refList1ModOpCount; + uint8_t refPicMarkingOpCount; + uint8_t reserved1[7]; + const StdVideoEncodeH264RefListModEntry* pRefList0ModOperations; + const StdVideoEncodeH264RefListModEntry* pRefList1ModOperations; + const StdVideoEncodeH264RefPicMarkingEntry* pRefPicMarkingOperations; +} StdVideoEncodeH264ReferenceListsInfo; + +typedef struct StdVideoEncodeH264PictureInfo { + StdVideoEncodeH264PictureInfoFlags flags; + uint8_t seq_parameter_set_id; + uint8_t pic_parameter_set_id; + uint16_t idr_pic_id; + StdVideoH264PictureType primary_pic_type; + uint32_t frame_num; + int32_t PicOrderCnt; + uint8_t temporal_id; + uint8_t reserved1[3]; + const StdVideoEncodeH264ReferenceListsInfo* pRefLists; +} StdVideoEncodeH264PictureInfo; + +typedef struct StdVideoEncodeH264ReferenceInfo { + StdVideoEncodeH264ReferenceInfoFlags flags; + StdVideoH264PictureType primary_pic_type; + uint32_t FrameNum; + int32_t PicOrderCnt; + uint16_t long_term_pic_num; + uint16_t long_term_frame_idx; + uint8_t temporal_id; +} StdVideoEncodeH264ReferenceInfo; + +typedef struct StdVideoEncodeH264SliceHeader { + StdVideoEncodeH264SliceHeaderFlags flags; + uint32_t first_mb_in_slice; + StdVideoH264SliceType slice_type; + int8_t slice_alpha_c0_offset_div2; + int8_t slice_beta_offset_div2; + int8_t slice_qp_delta; + uint8_t reserved1; + StdVideoH264CabacInitIdc cabac_init_idc; + StdVideoH264DisableDeblockingFilterIdc disable_deblocking_filter_idc; + const StdVideoEncodeH264WeightTable* pWeightTable; +} StdVideoEncodeH264SliceHeader; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std.h new file mode 100644 index 0000000..d0a1bac --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std.h @@ -0,0 +1,446 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_H_ +#define VULKAN_VIDEO_CODEC_H265STD_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h265std is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h265std 1 +#include "vulkan_video_codecs_common.h" +#define STD_VIDEO_H265_CPB_CNT_LIST_SIZE 32 +#define STD_VIDEO_H265_SUBLAYERS_LIST_SIZE 7 +#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS 16 +#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS 6 +#define STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS 2 +#define STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS 64 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE 6 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE 19 +#define STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE 21 +#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE 3 +#define STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE 128 +#define STD_VIDEO_H265_MAX_NUM_LIST_REF 15 +#define STD_VIDEO_H265_MAX_CHROMA_PLANES 2 +#define STD_VIDEO_H265_MAX_SHORT_TERM_REF_PIC_SETS 64 +#define STD_VIDEO_H265_MAX_DPB_SIZE 16 +#define STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS 32 +#define STD_VIDEO_H265_MAX_LONG_TERM_PICS 16 +#define STD_VIDEO_H265_MAX_DELTA_POC 48 +#define STD_VIDEO_H265_NO_REFERENCE_PICTURE 0xFF + +typedef enum StdVideoH265ChromaFormatIdc { + STD_VIDEO_H265_CHROMA_FORMAT_IDC_MONOCHROME = 0, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_420 = 1, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_422 = 2, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_444 = 3, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_CHROMA_FORMAT_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265ChromaFormatIdc; + +typedef enum StdVideoH265ProfileIdc { + STD_VIDEO_H265_PROFILE_IDC_MAIN = 1, + STD_VIDEO_H265_PROFILE_IDC_MAIN_10 = 2, + STD_VIDEO_H265_PROFILE_IDC_MAIN_STILL_PICTURE = 3, + STD_VIDEO_H265_PROFILE_IDC_FORMAT_RANGE_EXTENSIONS = 4, + STD_VIDEO_H265_PROFILE_IDC_SCC_EXTENSIONS = 9, + STD_VIDEO_H265_PROFILE_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_PROFILE_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265ProfileIdc; + +typedef enum StdVideoH265LevelIdc { + STD_VIDEO_H265_LEVEL_IDC_1_0 = 0, + STD_VIDEO_H265_LEVEL_IDC_2_0 = 1, + STD_VIDEO_H265_LEVEL_IDC_2_1 = 2, + STD_VIDEO_H265_LEVEL_IDC_3_0 = 3, + STD_VIDEO_H265_LEVEL_IDC_3_1 = 4, + STD_VIDEO_H265_LEVEL_IDC_4_0 = 5, + STD_VIDEO_H265_LEVEL_IDC_4_1 = 6, + STD_VIDEO_H265_LEVEL_IDC_5_0 = 7, + STD_VIDEO_H265_LEVEL_IDC_5_1 = 8, + STD_VIDEO_H265_LEVEL_IDC_5_2 = 9, + STD_VIDEO_H265_LEVEL_IDC_6_0 = 10, + STD_VIDEO_H265_LEVEL_IDC_6_1 = 11, + STD_VIDEO_H265_LEVEL_IDC_6_2 = 12, + STD_VIDEO_H265_LEVEL_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_LEVEL_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265LevelIdc; + +typedef enum StdVideoH265SliceType { + STD_VIDEO_H265_SLICE_TYPE_B = 0, + STD_VIDEO_H265_SLICE_TYPE_P = 1, + STD_VIDEO_H265_SLICE_TYPE_I = 2, + STD_VIDEO_H265_SLICE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_SLICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265SliceType; + +typedef enum StdVideoH265PictureType { + STD_VIDEO_H265_PICTURE_TYPE_P = 0, + STD_VIDEO_H265_PICTURE_TYPE_B = 1, + STD_VIDEO_H265_PICTURE_TYPE_I = 2, + STD_VIDEO_H265_PICTURE_TYPE_IDR = 3, + STD_VIDEO_H265_PICTURE_TYPE_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_PICTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265PictureType; + +typedef enum StdVideoH265AspectRatioIdc { + STD_VIDEO_H265_ASPECT_RATIO_IDC_UNSPECIFIED = 0, + STD_VIDEO_H265_ASPECT_RATIO_IDC_SQUARE = 1, + STD_VIDEO_H265_ASPECT_RATIO_IDC_12_11 = 2, + STD_VIDEO_H265_ASPECT_RATIO_IDC_10_11 = 3, + STD_VIDEO_H265_ASPECT_RATIO_IDC_16_11 = 4, + STD_VIDEO_H265_ASPECT_RATIO_IDC_40_33 = 5, + STD_VIDEO_H265_ASPECT_RATIO_IDC_24_11 = 6, + STD_VIDEO_H265_ASPECT_RATIO_IDC_20_11 = 7, + STD_VIDEO_H265_ASPECT_RATIO_IDC_32_11 = 8, + STD_VIDEO_H265_ASPECT_RATIO_IDC_80_33 = 9, + STD_VIDEO_H265_ASPECT_RATIO_IDC_18_11 = 10, + STD_VIDEO_H265_ASPECT_RATIO_IDC_15_11 = 11, + STD_VIDEO_H265_ASPECT_RATIO_IDC_64_33 = 12, + STD_VIDEO_H265_ASPECT_RATIO_IDC_160_99 = 13, + STD_VIDEO_H265_ASPECT_RATIO_IDC_4_3 = 14, + STD_VIDEO_H265_ASPECT_RATIO_IDC_3_2 = 15, + STD_VIDEO_H265_ASPECT_RATIO_IDC_2_1 = 16, + STD_VIDEO_H265_ASPECT_RATIO_IDC_EXTENDED_SAR = 255, + STD_VIDEO_H265_ASPECT_RATIO_IDC_INVALID = 0x7FFFFFFF, + STD_VIDEO_H265_ASPECT_RATIO_IDC_MAX_ENUM = 0x7FFFFFFF +} StdVideoH265AspectRatioIdc; +typedef struct StdVideoH265DecPicBufMgr { + uint32_t max_latency_increase_plus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint8_t max_dec_pic_buffering_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint8_t max_num_reorder_pics[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; +} StdVideoH265DecPicBufMgr; + +typedef struct StdVideoH265SubLayerHrdParameters { + uint32_t bit_rate_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cpb_size_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t bit_rate_du_value_minus1[STD_VIDEO_H265_CPB_CNT_LIST_SIZE]; + uint32_t cbr_flag; +} StdVideoH265SubLayerHrdParameters; + +typedef struct StdVideoH265HrdFlags { + uint32_t nal_hrd_parameters_present_flag : 1; + uint32_t vcl_hrd_parameters_present_flag : 1; + uint32_t sub_pic_hrd_params_present_flag : 1; + uint32_t sub_pic_cpb_params_in_pic_timing_sei_flag : 1; + uint32_t fixed_pic_rate_general_flag : 8; + uint32_t fixed_pic_rate_within_cvs_flag : 8; + uint32_t low_delay_hrd_flag : 8; +} StdVideoH265HrdFlags; + +typedef struct StdVideoH265HrdParameters { + StdVideoH265HrdFlags flags; + uint8_t tick_divisor_minus2; + uint8_t du_cpb_removal_delay_increment_length_minus1; + uint8_t dpb_output_delay_du_length_minus1; + uint8_t bit_rate_scale; + uint8_t cpb_size_scale; + uint8_t cpb_size_du_scale; + uint8_t initial_cpb_removal_delay_length_minus1; + uint8_t au_cpb_removal_delay_length_minus1; + uint8_t dpb_output_delay_length_minus1; + uint8_t cpb_cnt_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint16_t elemental_duration_in_tc_minus1[STD_VIDEO_H265_SUBLAYERS_LIST_SIZE]; + uint16_t reserved[3]; + const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersNal; + const StdVideoH265SubLayerHrdParameters* pSubLayerHrdParametersVcl; +} StdVideoH265HrdParameters; + +typedef struct StdVideoH265VpsFlags { + uint32_t vps_temporal_id_nesting_flag : 1; + uint32_t vps_sub_layer_ordering_info_present_flag : 1; + uint32_t vps_timing_info_present_flag : 1; + uint32_t vps_poc_proportional_to_timing_flag : 1; +} StdVideoH265VpsFlags; + +typedef struct StdVideoH265ProfileTierLevelFlags { + uint32_t general_tier_flag : 1; + uint32_t general_progressive_source_flag : 1; + uint32_t general_interlaced_source_flag : 1; + uint32_t general_non_packed_constraint_flag : 1; + uint32_t general_frame_only_constraint_flag : 1; +} StdVideoH265ProfileTierLevelFlags; + +typedef struct StdVideoH265ProfileTierLevel { + StdVideoH265ProfileTierLevelFlags flags; + StdVideoH265ProfileIdc general_profile_idc; + StdVideoH265LevelIdc general_level_idc; +} StdVideoH265ProfileTierLevel; + +typedef struct StdVideoH265VideoParameterSet { + StdVideoH265VpsFlags flags; + uint8_t vps_video_parameter_set_id; + uint8_t vps_max_sub_layers_minus1; + uint8_t reserved1; + uint8_t reserved2; + uint32_t vps_num_units_in_tick; + uint32_t vps_time_scale; + uint32_t vps_num_ticks_poc_diff_one_minus1; + uint32_t reserved3; + const StdVideoH265DecPicBufMgr* pDecPicBufMgr; + const StdVideoH265HrdParameters* pHrdParameters; + const StdVideoH265ProfileTierLevel* pProfileTierLevel; +} StdVideoH265VideoParameterSet; + +typedef struct StdVideoH265ScalingLists { + uint8_t ScalingList4x4[STD_VIDEO_H265_SCALING_LIST_4X4_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_4X4_NUM_ELEMENTS]; + uint8_t ScalingList8x8[STD_VIDEO_H265_SCALING_LIST_8X8_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_8X8_NUM_ELEMENTS]; + uint8_t ScalingList16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_16X16_NUM_ELEMENTS]; + uint8_t ScalingList32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS][STD_VIDEO_H265_SCALING_LIST_32X32_NUM_ELEMENTS]; + uint8_t ScalingListDCCoef16x16[STD_VIDEO_H265_SCALING_LIST_16X16_NUM_LISTS]; + uint8_t ScalingListDCCoef32x32[STD_VIDEO_H265_SCALING_LIST_32X32_NUM_LISTS]; +} StdVideoH265ScalingLists; + +typedef struct StdVideoH265SpsVuiFlags { + uint32_t aspect_ratio_info_present_flag : 1; + uint32_t overscan_info_present_flag : 1; + uint32_t overscan_appropriate_flag : 1; + uint32_t video_signal_type_present_flag : 1; + uint32_t video_full_range_flag : 1; + uint32_t colour_description_present_flag : 1; + uint32_t chroma_loc_info_present_flag : 1; + uint32_t neutral_chroma_indication_flag : 1; + uint32_t field_seq_flag : 1; + uint32_t frame_field_info_present_flag : 1; + uint32_t default_display_window_flag : 1; + uint32_t vui_timing_info_present_flag : 1; + uint32_t vui_poc_proportional_to_timing_flag : 1; + uint32_t vui_hrd_parameters_present_flag : 1; + uint32_t bitstream_restriction_flag : 1; + uint32_t tiles_fixed_structure_flag : 1; + uint32_t motion_vectors_over_pic_boundaries_flag : 1; + uint32_t restricted_ref_pic_lists_flag : 1; +} StdVideoH265SpsVuiFlags; + +typedef struct StdVideoH265SequenceParameterSetVui { + StdVideoH265SpsVuiFlags flags; + StdVideoH265AspectRatioIdc aspect_ratio_idc; + uint16_t sar_width; + uint16_t sar_height; + uint8_t video_format; + uint8_t colour_primaries; + uint8_t transfer_characteristics; + uint8_t matrix_coeffs; + uint8_t chroma_sample_loc_type_top_field; + uint8_t chroma_sample_loc_type_bottom_field; + uint8_t reserved1; + uint8_t reserved2; + uint16_t def_disp_win_left_offset; + uint16_t def_disp_win_right_offset; + uint16_t def_disp_win_top_offset; + uint16_t def_disp_win_bottom_offset; + uint32_t vui_num_units_in_tick; + uint32_t vui_time_scale; + uint32_t vui_num_ticks_poc_diff_one_minus1; + uint16_t min_spatial_segmentation_idc; + uint16_t reserved3; + uint8_t max_bytes_per_pic_denom; + uint8_t max_bits_per_min_cu_denom; + uint8_t log2_max_mv_length_horizontal; + uint8_t log2_max_mv_length_vertical; + const StdVideoH265HrdParameters* pHrdParameters; +} StdVideoH265SequenceParameterSetVui; + +typedef struct StdVideoH265PredictorPaletteEntries { + uint16_t PredictorPaletteEntries[STD_VIDEO_H265_PREDICTOR_PALETTE_COMPONENTS_LIST_SIZE][STD_VIDEO_H265_PREDICTOR_PALETTE_COMP_ENTRIES_LIST_SIZE]; +} StdVideoH265PredictorPaletteEntries; + +typedef struct StdVideoH265SpsFlags { + uint32_t sps_temporal_id_nesting_flag : 1; + uint32_t separate_colour_plane_flag : 1; + uint32_t conformance_window_flag : 1; + uint32_t sps_sub_layer_ordering_info_present_flag : 1; + uint32_t scaling_list_enabled_flag : 1; + uint32_t sps_scaling_list_data_present_flag : 1; + uint32_t amp_enabled_flag : 1; + uint32_t sample_adaptive_offset_enabled_flag : 1; + uint32_t pcm_enabled_flag : 1; + uint32_t pcm_loop_filter_disabled_flag : 1; + uint32_t long_term_ref_pics_present_flag : 1; + uint32_t sps_temporal_mvp_enabled_flag : 1; + uint32_t strong_intra_smoothing_enabled_flag : 1; + uint32_t vui_parameters_present_flag : 1; + uint32_t sps_extension_present_flag : 1; + uint32_t sps_range_extension_flag : 1; + uint32_t transform_skip_rotation_enabled_flag : 1; + uint32_t transform_skip_context_enabled_flag : 1; + uint32_t implicit_rdpcm_enabled_flag : 1; + uint32_t explicit_rdpcm_enabled_flag : 1; + uint32_t extended_precision_processing_flag : 1; + uint32_t intra_smoothing_disabled_flag : 1; + uint32_t high_precision_offsets_enabled_flag : 1; + uint32_t persistent_rice_adaptation_enabled_flag : 1; + uint32_t cabac_bypass_alignment_enabled_flag : 1; + uint32_t sps_scc_extension_flag : 1; + uint32_t sps_curr_pic_ref_enabled_flag : 1; + uint32_t palette_mode_enabled_flag : 1; + uint32_t sps_palette_predictor_initializers_present_flag : 1; + uint32_t intra_boundary_filtering_disabled_flag : 1; +} StdVideoH265SpsFlags; + +typedef struct StdVideoH265ShortTermRefPicSetFlags { + uint32_t inter_ref_pic_set_prediction_flag : 1; + uint32_t delta_rps_sign : 1; +} StdVideoH265ShortTermRefPicSetFlags; + +typedef struct StdVideoH265ShortTermRefPicSet { + StdVideoH265ShortTermRefPicSetFlags flags; + uint32_t delta_idx_minus1; + uint16_t use_delta_flag; + uint16_t abs_delta_rps_minus1; + uint16_t used_by_curr_pic_flag; + uint16_t used_by_curr_pic_s0_flag; + uint16_t used_by_curr_pic_s1_flag; + uint16_t reserved1; + uint8_t reserved2; + uint8_t reserved3; + uint8_t num_negative_pics; + uint8_t num_positive_pics; + uint16_t delta_poc_s0_minus1[STD_VIDEO_H265_MAX_DPB_SIZE]; + uint16_t delta_poc_s1_minus1[STD_VIDEO_H265_MAX_DPB_SIZE]; +} StdVideoH265ShortTermRefPicSet; + +typedef struct StdVideoH265LongTermRefPicsSps { + uint32_t used_by_curr_pic_lt_sps_flag; + uint32_t lt_ref_pic_poc_lsb_sps[STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS]; +} StdVideoH265LongTermRefPicsSps; + +typedef struct StdVideoH265SequenceParameterSet { + StdVideoH265SpsFlags flags; + StdVideoH265ChromaFormatIdc chroma_format_idc; + uint32_t pic_width_in_luma_samples; + uint32_t pic_height_in_luma_samples; + uint8_t sps_video_parameter_set_id; + uint8_t sps_max_sub_layers_minus1; + uint8_t sps_seq_parameter_set_id; + uint8_t bit_depth_luma_minus8; + uint8_t bit_depth_chroma_minus8; + uint8_t log2_max_pic_order_cnt_lsb_minus4; + uint8_t log2_min_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_luma_coding_block_size; + uint8_t log2_min_luma_transform_block_size_minus2; + uint8_t log2_diff_max_min_luma_transform_block_size; + uint8_t max_transform_hierarchy_depth_inter; + uint8_t max_transform_hierarchy_depth_intra; + uint8_t num_short_term_ref_pic_sets; + uint8_t num_long_term_ref_pics_sps; + uint8_t pcm_sample_bit_depth_luma_minus1; + uint8_t pcm_sample_bit_depth_chroma_minus1; + uint8_t log2_min_pcm_luma_coding_block_size_minus3; + uint8_t log2_diff_max_min_pcm_luma_coding_block_size; + uint8_t reserved1; + uint8_t reserved2; + uint8_t palette_max_size; + uint8_t delta_palette_max_predictor_size; + uint8_t motion_vector_resolution_control_idc; + uint8_t sps_num_palette_predictor_initializers_minus1; + uint32_t conf_win_left_offset; + uint32_t conf_win_right_offset; + uint32_t conf_win_top_offset; + uint32_t conf_win_bottom_offset; + const StdVideoH265ProfileTierLevel* pProfileTierLevel; + const StdVideoH265DecPicBufMgr* pDecPicBufMgr; + const StdVideoH265ScalingLists* pScalingLists; + const StdVideoH265ShortTermRefPicSet* pShortTermRefPicSet; + const StdVideoH265LongTermRefPicsSps* pLongTermRefPicsSps; + const StdVideoH265SequenceParameterSetVui* pSequenceParameterSetVui; + const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; +} StdVideoH265SequenceParameterSet; + +typedef struct StdVideoH265PpsFlags { + uint32_t dependent_slice_segments_enabled_flag : 1; + uint32_t output_flag_present_flag : 1; + uint32_t sign_data_hiding_enabled_flag : 1; + uint32_t cabac_init_present_flag : 1; + uint32_t constrained_intra_pred_flag : 1; + uint32_t transform_skip_enabled_flag : 1; + uint32_t cu_qp_delta_enabled_flag : 1; + uint32_t pps_slice_chroma_qp_offsets_present_flag : 1; + uint32_t weighted_pred_flag : 1; + uint32_t weighted_bipred_flag : 1; + uint32_t transquant_bypass_enabled_flag : 1; + uint32_t tiles_enabled_flag : 1; + uint32_t entropy_coding_sync_enabled_flag : 1; + uint32_t uniform_spacing_flag : 1; + uint32_t loop_filter_across_tiles_enabled_flag : 1; + uint32_t pps_loop_filter_across_slices_enabled_flag : 1; + uint32_t deblocking_filter_control_present_flag : 1; + uint32_t deblocking_filter_override_enabled_flag : 1; + uint32_t pps_deblocking_filter_disabled_flag : 1; + uint32_t pps_scaling_list_data_present_flag : 1; + uint32_t lists_modification_present_flag : 1; + uint32_t slice_segment_header_extension_present_flag : 1; + uint32_t pps_extension_present_flag : 1; + uint32_t cross_component_prediction_enabled_flag : 1; + uint32_t chroma_qp_offset_list_enabled_flag : 1; + uint32_t pps_curr_pic_ref_enabled_flag : 1; + uint32_t residual_adaptive_colour_transform_enabled_flag : 1; + uint32_t pps_slice_act_qp_offsets_present_flag : 1; + uint32_t pps_palette_predictor_initializers_present_flag : 1; + uint32_t monochrome_palette_flag : 1; + uint32_t pps_range_extension_flag : 1; +} StdVideoH265PpsFlags; + +typedef struct StdVideoH265PictureParameterSet { + StdVideoH265PpsFlags flags; + uint8_t pps_pic_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t sps_video_parameter_set_id; + uint8_t num_extra_slice_header_bits; + uint8_t num_ref_idx_l0_default_active_minus1; + uint8_t num_ref_idx_l1_default_active_minus1; + int8_t init_qp_minus26; + uint8_t diff_cu_qp_delta_depth; + int8_t pps_cb_qp_offset; + int8_t pps_cr_qp_offset; + int8_t pps_beta_offset_div2; + int8_t pps_tc_offset_div2; + uint8_t log2_parallel_merge_level_minus2; + uint8_t log2_max_transform_skip_block_size_minus2; + uint8_t diff_cu_chroma_qp_offset_depth; + uint8_t chroma_qp_offset_list_len_minus1; + int8_t cb_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]; + int8_t cr_qp_offset_list[STD_VIDEO_H265_CHROMA_QP_OFFSET_LIST_SIZE]; + uint8_t log2_sao_offset_scale_luma; + uint8_t log2_sao_offset_scale_chroma; + int8_t pps_act_y_qp_offset_plus5; + int8_t pps_act_cb_qp_offset_plus5; + int8_t pps_act_cr_qp_offset_plus3; + uint8_t pps_num_palette_predictor_initializers; + uint8_t luma_bit_depth_entry_minus8; + uint8_t chroma_bit_depth_entry_minus8; + uint8_t num_tile_columns_minus1; + uint8_t num_tile_rows_minus1; + uint8_t reserved1; + uint8_t reserved2; + uint16_t column_width_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_COLS_LIST_SIZE]; + uint16_t row_height_minus1[STD_VIDEO_H265_CHROMA_QP_OFFSET_TILE_ROWS_LIST_SIZE]; + uint32_t reserved3; + const StdVideoH265ScalingLists* pScalingLists; + const StdVideoH265PredictorPaletteEntries* pPredictorPaletteEntries; +} StdVideoH265PictureParameterSet; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h new file mode 100644 index 0000000..0178793 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_decode.h @@ -0,0 +1,67 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ +#define VULKAN_VIDEO_CODEC_H265STD_DECODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h265std_decode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h265std_decode 1 +#include "vulkan_video_codec_h265std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H265_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_decode" +#define STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE 8 +typedef struct StdVideoDecodeH265PictureInfoFlags { + uint32_t IrapPicFlag : 1; + uint32_t IdrPicFlag : 1; + uint32_t IsReference : 1; + uint32_t short_term_ref_pic_set_sps_flag : 1; +} StdVideoDecodeH265PictureInfoFlags; + +typedef struct StdVideoDecodeH265PictureInfo { + StdVideoDecodeH265PictureInfoFlags flags; + uint8_t sps_video_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t pps_pic_parameter_set_id; + uint8_t NumDeltaPocsOfRefRpsIdx; + int32_t PicOrderCntVal; + uint16_t NumBitsForSTRefPicSetInSlice; + uint16_t reserved; + uint8_t RefPicSetStCurrBefore[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; + uint8_t RefPicSetStCurrAfter[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; + uint8_t RefPicSetLtCurr[STD_VIDEO_DECODE_H265_REF_PIC_SET_LIST_SIZE]; +} StdVideoDecodeH265PictureInfo; + +typedef struct StdVideoDecodeH265ReferenceInfoFlags { + uint32_t used_for_long_term_reference : 1; + uint32_t unused_for_reference : 1; +} StdVideoDecodeH265ReferenceInfoFlags; + +typedef struct StdVideoDecodeH265ReferenceInfo { + StdVideoDecodeH265ReferenceInfoFlags flags; + int32_t PicOrderCntVal; +} StdVideoDecodeH265ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h new file mode 100644 index 0000000..ee34491 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codec_h265std_encode.h @@ -0,0 +1,157 @@ +#ifndef VULKAN_VIDEO_CODEC_H265STD_ENCODE_H_ +#define VULKAN_VIDEO_CODEC_H265STD_ENCODE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codec_h265std_encode is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codec_h265std_encode 1 +#include "vulkan_video_codec_h265std.h" + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0 VK_MAKE_VIDEO_STD_VERSION(1, 0, 0) + +#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_API_VERSION_1_0_0 +#define VK_STD_VULKAN_VIDEO_CODEC_H265_ENCODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_h265_encode" +typedef struct StdVideoEncodeH265WeightTableFlags { + uint16_t luma_weight_l0_flag; + uint16_t chroma_weight_l0_flag; + uint16_t luma_weight_l1_flag; + uint16_t chroma_weight_l1_flag; +} StdVideoEncodeH265WeightTableFlags; + +typedef struct StdVideoEncodeH265WeightTable { + StdVideoEncodeH265WeightTableFlags flags; + uint8_t luma_log2_weight_denom; + int8_t delta_chroma_log2_weight_denom; + int8_t delta_luma_weight_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t luma_offset_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t delta_chroma_weight_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; + int8_t delta_chroma_offset_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; + int8_t delta_luma_weight_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t luma_offset_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + int8_t delta_chroma_weight_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; + int8_t delta_chroma_offset_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF][STD_VIDEO_H265_MAX_CHROMA_PLANES]; +} StdVideoEncodeH265WeightTable; + +typedef struct StdVideoEncodeH265SliceSegmentHeaderFlags { + uint32_t first_slice_segment_in_pic_flag : 1; + uint32_t dependent_slice_segment_flag : 1; + uint32_t slice_sao_luma_flag : 1; + uint32_t slice_sao_chroma_flag : 1; + uint32_t num_ref_idx_active_override_flag : 1; + uint32_t mvd_l1_zero_flag : 1; + uint32_t cabac_init_flag : 1; + uint32_t cu_chroma_qp_offset_enabled_flag : 1; + uint32_t deblocking_filter_override_flag : 1; + uint32_t slice_deblocking_filter_disabled_flag : 1; + uint32_t collocated_from_l0_flag : 1; + uint32_t slice_loop_filter_across_slices_enabled_flag : 1; + uint32_t reserved : 20; +} StdVideoEncodeH265SliceSegmentHeaderFlags; + +typedef struct StdVideoEncodeH265SliceSegmentHeader { + StdVideoEncodeH265SliceSegmentHeaderFlags flags; + StdVideoH265SliceType slice_type; + uint32_t slice_segment_address; + uint8_t collocated_ref_idx; + uint8_t MaxNumMergeCand; + int8_t slice_cb_qp_offset; + int8_t slice_cr_qp_offset; + int8_t slice_beta_offset_div2; + int8_t slice_tc_offset_div2; + int8_t slice_act_y_qp_offset; + int8_t slice_act_cb_qp_offset; + int8_t slice_act_cr_qp_offset; + int8_t slice_qp_delta; + uint16_t reserved1; + const StdVideoEncodeH265WeightTable* pWeightTable; +} StdVideoEncodeH265SliceSegmentHeader; + +typedef struct StdVideoEncodeH265ReferenceListsInfoFlags { + uint32_t ref_pic_list_modification_flag_l0 : 1; + uint32_t ref_pic_list_modification_flag_l1 : 1; + uint32_t reserved : 30; +} StdVideoEncodeH265ReferenceListsInfoFlags; + +typedef struct StdVideoEncodeH265ReferenceListsInfo { + StdVideoEncodeH265ReferenceListsInfoFlags flags; + uint8_t num_ref_idx_l0_active_minus1; + uint8_t num_ref_idx_l1_active_minus1; + uint8_t RefPicList0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + uint8_t RefPicList1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + uint8_t list_entry_l0[STD_VIDEO_H265_MAX_NUM_LIST_REF]; + uint8_t list_entry_l1[STD_VIDEO_H265_MAX_NUM_LIST_REF]; +} StdVideoEncodeH265ReferenceListsInfo; + +typedef struct StdVideoEncodeH265PictureInfoFlags { + uint32_t is_reference : 1; + uint32_t IrapPicFlag : 1; + uint32_t used_for_long_term_reference : 1; + uint32_t discardable_flag : 1; + uint32_t cross_layer_bla_flag : 1; + uint32_t pic_output_flag : 1; + uint32_t no_output_of_prior_pics_flag : 1; + uint32_t short_term_ref_pic_set_sps_flag : 1; + uint32_t slice_temporal_mvp_enabled_flag : 1; + uint32_t reserved : 23; +} StdVideoEncodeH265PictureInfoFlags; + +typedef struct StdVideoEncodeH265LongTermRefPics { + uint8_t num_long_term_sps; + uint8_t num_long_term_pics; + uint8_t lt_idx_sps[STD_VIDEO_H265_MAX_LONG_TERM_REF_PICS_SPS]; + uint8_t poc_lsb_lt[STD_VIDEO_H265_MAX_LONG_TERM_PICS]; + uint16_t used_by_curr_pic_lt_flag; + uint8_t delta_poc_msb_present_flag[STD_VIDEO_H265_MAX_DELTA_POC]; + uint8_t delta_poc_msb_cycle_lt[STD_VIDEO_H265_MAX_DELTA_POC]; +} StdVideoEncodeH265LongTermRefPics; + +typedef struct StdVideoEncodeH265PictureInfo { + StdVideoEncodeH265PictureInfoFlags flags; + StdVideoH265PictureType pic_type; + uint8_t sps_video_parameter_set_id; + uint8_t pps_seq_parameter_set_id; + uint8_t pps_pic_parameter_set_id; + uint8_t short_term_ref_pic_set_idx; + int32_t PicOrderCntVal; + uint8_t TemporalId; + uint8_t reserved1[7]; + const StdVideoEncodeH265ReferenceListsInfo* pRefLists; + const StdVideoH265ShortTermRefPicSet* pShortTermRefPicSet; + const StdVideoEncodeH265LongTermRefPics* pLongTermRefPics; +} StdVideoEncodeH265PictureInfo; + +typedef struct StdVideoEncodeH265ReferenceInfoFlags { + uint32_t used_for_long_term_reference : 1; + uint32_t unused_for_reference : 1; + uint32_t reserved : 30; +} StdVideoEncodeH265ReferenceInfoFlags; + +typedef struct StdVideoEncodeH265ReferenceInfo { + StdVideoEncodeH265ReferenceInfoFlags flags; + StdVideoH265PictureType pic_type; + int32_t PicOrderCntVal; + uint8_t TemporalId; +} StdVideoEncodeH265ReferenceInfo; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codecs_common.h b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codecs_common.h new file mode 100644 index 0000000..5e6ef1d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vk_video/vulkan_video_codecs_common.h @@ -0,0 +1,36 @@ +#ifndef VULKAN_VIDEO_CODECS_COMMON_H_ +#define VULKAN_VIDEO_CODECS_COMMON_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// vulkan_video_codecs_common is a preprocessor guard. Do not pass it to API calls. +#define vulkan_video_codecs_common 1 +#if !defined(VK_NO_STDINT_H) + #include +#endif + +#define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \ + ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch))) + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_icd.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_icd.h new file mode 100644 index 0000000..59204a3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_icd.h @@ -0,0 +1,244 @@ +/* + * Copyright 2015-2023 The Khronos Group Inc. + * Copyright 2015-2023 Valve Corporation + * Copyright 2015-2023 LunarG, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "vulkan.h" +#include + +// Loader-ICD version negotiation API. Versions add the following features: +// Version 0 - Initial. Doesn't support vk_icdGetInstanceProcAddr +// or vk_icdNegotiateLoaderICDInterfaceVersion. +// Version 1 - Add support for vk_icdGetInstanceProcAddr. +// Version 2 - Add Loader/ICD Interface version negotiation +// via vk_icdNegotiateLoaderICDInterfaceVersion. +// Version 3 - Add ICD creation/destruction of KHR_surface objects. +// Version 4 - Add unknown physical device extension querying via +// vk_icdGetPhysicalDeviceProcAddr. +// Version 5 - Tells ICDs that the loader is now paying attention to the +// application version of Vulkan passed into the ApplicationInfo +// structure during vkCreateInstance. This will tell the ICD +// that if the loader is older, it should automatically fail a +// call for any API version > 1.0. Otherwise, the loader will +// manually determine if it can support the expected version. +// Version 6 - Add support for vk_icdEnumerateAdapterPhysicalDevices. +// Version 7 - If an ICD supports any of the following functions, they must be +// queryable with vk_icdGetInstanceProcAddr: +// vk_icdNegotiateLoaderICDInterfaceVersion +// vk_icdGetPhysicalDeviceProcAddr +// vk_icdEnumerateAdapterPhysicalDevices (Windows only) +// In addition, these functions no longer need to be exported directly. +// This version allows drivers provided through the extension +// VK_LUNARG_direct_driver_loading be able to support the entire +// Driver-Loader interface. + +#define CURRENT_LOADER_ICD_INTERFACE_VERSION 7 +#define MIN_SUPPORTED_LOADER_ICD_INTERFACE_VERSION 0 +#define MIN_PHYS_DEV_EXTENSION_ICD_INTERFACE_VERSION 4 + +// Old typedefs that don't follow a proper naming convention but are preserved for compatibility +typedef VkResult(VKAPI_PTR *PFN_vkNegotiateLoaderICDInterfaceVersion)(uint32_t *pVersion); +// This is defined in vk_layer.h which will be found by the loader, but if an ICD is building against this +// file directly, it won't be found. +#ifndef PFN_GetPhysicalDeviceProcAddr +typedef PFN_vkVoidFunction(VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char *pName); +#endif + +// Typedefs for loader/ICD interface +typedef VkResult (VKAPI_PTR *PFN_vk_icdNegotiateLoaderICDInterfaceVersion)(uint32_t* pVersion); +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetInstanceProcAddr)(VkInstance instance, const char* pName); +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vk_icdGetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName); +#if defined(VK_USE_PLATFORM_WIN32_KHR) +typedef VkResult (VKAPI_PTR *PFN_vk_icdEnumerateAdapterPhysicalDevices)(VkInstance instance, LUID adapterLUID, + uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); +#endif + +// Prototypes for loader/ICD interface +#if !defined(VK_NO_PROTOTYPES) +#ifdef __cplusplus +extern "C" { +#endif + VKAPI_ATTR VkResult VKAPI_CALL vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t* pVersion); + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(VkInstance instance, const char* pName); + VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(VkInstance instance, const char* pName); +#if defined(VK_USE_PLATFORM_WIN32_KHR) + VKAPI_ATTR VkResult VKAPI_CALL vk_icdEnumerateAdapterPhysicalDevices(VkInstance instance, LUID adapterLUID, + uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); +#endif +#ifdef __cplusplus +} +#endif +#endif + +/* + * The ICD must reserve space for a pointer for the loader's dispatch + * table, at the start of . + * The ICD must initialize this variable using the SET_LOADER_MAGIC_VALUE macro. + */ + +#define ICD_LOADER_MAGIC 0x01CDC0DE + +typedef union { + uintptr_t loaderMagic; + void *loaderData; +} VK_LOADER_DATA; + +static inline void set_loader_magic_value(void *pNewObject) { + VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; + loader_info->loaderMagic = ICD_LOADER_MAGIC; +} + +static inline bool valid_loader_magic_value(void *pNewObject) { + const VK_LOADER_DATA *loader_info = (VK_LOADER_DATA *)pNewObject; + return (loader_info->loaderMagic & 0xffffffff) == ICD_LOADER_MAGIC; +} + +/* + * Windows and Linux ICDs will treat VkSurfaceKHR as a pointer to a struct that + * contains the platform-specific connection and surface information. + */ +typedef enum { + VK_ICD_WSI_PLATFORM_MIR, + VK_ICD_WSI_PLATFORM_WAYLAND, + VK_ICD_WSI_PLATFORM_WIN32, + VK_ICD_WSI_PLATFORM_XCB, + VK_ICD_WSI_PLATFORM_XLIB, + VK_ICD_WSI_PLATFORM_ANDROID, + VK_ICD_WSI_PLATFORM_MACOS, + VK_ICD_WSI_PLATFORM_IOS, + VK_ICD_WSI_PLATFORM_DISPLAY, + VK_ICD_WSI_PLATFORM_HEADLESS, + VK_ICD_WSI_PLATFORM_METAL, + VK_ICD_WSI_PLATFORM_DIRECTFB, + VK_ICD_WSI_PLATFORM_VI, + VK_ICD_WSI_PLATFORM_GGP, + VK_ICD_WSI_PLATFORM_SCREEN, + VK_ICD_WSI_PLATFORM_FUCHSIA, +} VkIcdWsiPlatform; + +typedef struct { + VkIcdWsiPlatform platform; +} VkIcdSurfaceBase; + +#ifdef VK_USE_PLATFORM_MIR_KHR +typedef struct { + VkIcdSurfaceBase base; + MirConnection *connection; + MirSurface *mirSurface; +} VkIcdSurfaceMir; +#endif // VK_USE_PLATFORM_MIR_KHR + +#ifdef VK_USE_PLATFORM_WAYLAND_KHR +typedef struct { + VkIcdSurfaceBase base; + struct wl_display *display; + struct wl_surface *surface; +} VkIcdSurfaceWayland; +#endif // VK_USE_PLATFORM_WAYLAND_KHR + +#ifdef VK_USE_PLATFORM_WIN32_KHR +typedef struct { + VkIcdSurfaceBase base; + HINSTANCE hinstance; + HWND hwnd; +} VkIcdSurfaceWin32; +#endif // VK_USE_PLATFORM_WIN32_KHR + +#ifdef VK_USE_PLATFORM_XCB_KHR +typedef struct { + VkIcdSurfaceBase base; + xcb_connection_t *connection; + xcb_window_t window; +} VkIcdSurfaceXcb; +#endif // VK_USE_PLATFORM_XCB_KHR + +#ifdef VK_USE_PLATFORM_XLIB_KHR +typedef struct { + VkIcdSurfaceBase base; + Display *dpy; + Window window; +} VkIcdSurfaceXlib; +#endif // VK_USE_PLATFORM_XLIB_KHR + +#ifdef VK_USE_PLATFORM_DIRECTFB_EXT +typedef struct { + VkIcdSurfaceBase base; + IDirectFB *dfb; + IDirectFBSurface *surface; +} VkIcdSurfaceDirectFB; +#endif // VK_USE_PLATFORM_DIRECTFB_EXT + +#ifdef VK_USE_PLATFORM_ANDROID_KHR +typedef struct { + VkIcdSurfaceBase base; + struct ANativeWindow *window; +} VkIcdSurfaceAndroid; +#endif // VK_USE_PLATFORM_ANDROID_KHR + +#ifdef VK_USE_PLATFORM_MACOS_MVK +typedef struct { + VkIcdSurfaceBase base; + const void *pView; +} VkIcdSurfaceMacOS; +#endif // VK_USE_PLATFORM_MACOS_MVK + +#ifdef VK_USE_PLATFORM_IOS_MVK +typedef struct { + VkIcdSurfaceBase base; + const void *pView; +} VkIcdSurfaceIOS; +#endif // VK_USE_PLATFORM_IOS_MVK + +#ifdef VK_USE_PLATFORM_GGP +typedef struct { + VkIcdSurfaceBase base; + GgpStreamDescriptor streamDescriptor; +} VkIcdSurfaceGgp; +#endif // VK_USE_PLATFORM_GGP + +typedef struct { + VkIcdSurfaceBase base; + VkDisplayModeKHR displayMode; + uint32_t planeIndex; + uint32_t planeStackIndex; + VkSurfaceTransformFlagBitsKHR transform; + float globalAlpha; + VkDisplayPlaneAlphaFlagBitsKHR alphaMode; + VkExtent2D imageExtent; +} VkIcdSurfaceDisplay; + +typedef struct { + VkIcdSurfaceBase base; +} VkIcdSurfaceHeadless; + +#ifdef VK_USE_PLATFORM_METAL_EXT +typedef struct { + VkIcdSurfaceBase base; + const CAMetalLayer *pLayer; +} VkIcdSurfaceMetal; +#endif // VK_USE_PLATFORM_METAL_EXT + +#ifdef VK_USE_PLATFORM_VI_NN +typedef struct { + VkIcdSurfaceBase base; + void *window; +} VkIcdSurfaceVi; +#endif // VK_USE_PLATFORM_VI_NN + +#ifdef VK_USE_PLATFORM_SCREEN_QNX +typedef struct { + VkIcdSurfaceBase base; + struct _screen_context *context; + struct _screen_window *window; +} VkIcdSurfaceScreen; +#endif // VK_USE_PLATFORM_SCREEN_QNX + +#ifdef VK_USE_PLATFORM_FUCHSIA +typedef struct { + VkIcdSurfaceBase base; +} VkIcdSurfaceImagePipe; +#endif // VK_USE_PLATFORM_FUCHSIA diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_layer.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_layer.h new file mode 100644 index 0000000..19d88fc --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_layer.h @@ -0,0 +1,189 @@ +/* + * Copyright 2015-2023 The Khronos Group Inc. + * Copyright 2015-2023 Valve Corporation + * Copyright 2015-2023 LunarG, Inc. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +/* Need to define dispatch table + * Core struct can then have ptr to dispatch table at the top + * Along with object ptrs for current and next OBJ + */ + +#include "vulkan_core.h" + +#define MAX_NUM_UNKNOWN_EXTS 250 + + // Loader-Layer version negotiation API. Versions add the following features: + // Versions 0/1 - Initial. Doesn't support vk_layerGetPhysicalDeviceProcAddr + // or vk_icdNegotiateLoaderLayerInterfaceVersion. + // Version 2 - Add support for vk_layerGetPhysicalDeviceProcAddr and + // vk_icdNegotiateLoaderLayerInterfaceVersion. +#define CURRENT_LOADER_LAYER_INTERFACE_VERSION 2 +#define MIN_SUPPORTED_LOADER_LAYER_INTERFACE_VERSION 1 + +#define VK_CURRENT_CHAIN_VERSION 1 + +// Typedef for use in the interfaces below +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_GetPhysicalDeviceProcAddr)(VkInstance instance, const char* pName); + +// Version negotiation values +typedef enum VkNegotiateLayerStructType { + LAYER_NEGOTIATE_UNINTIALIZED = 0, + LAYER_NEGOTIATE_INTERFACE_STRUCT = 1, +} VkNegotiateLayerStructType; + +// Version negotiation structures +typedef struct VkNegotiateLayerInterface { + VkNegotiateLayerStructType sType; + void *pNext; + uint32_t loaderLayerInterfaceVersion; + PFN_vkGetInstanceProcAddr pfnGetInstanceProcAddr; + PFN_vkGetDeviceProcAddr pfnGetDeviceProcAddr; + PFN_GetPhysicalDeviceProcAddr pfnGetPhysicalDeviceProcAddr; +} VkNegotiateLayerInterface; + +// Version negotiation functions +typedef VkResult (VKAPI_PTR *PFN_vkNegotiateLoaderLayerInterfaceVersion)(VkNegotiateLayerInterface *pVersionStruct); + +// Function prototype for unknown physical device extension command +typedef VkResult(VKAPI_PTR *PFN_PhysDevExt)(VkPhysicalDevice phys_device); + +// ------------------------------------------------------------------------------------------------ +// CreateInstance and CreateDevice support structures + +/* Sub type of structure for instance and device loader ext of CreateInfo. + * When sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO + * or sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO + * then VkLayerFunction indicates struct type pointed to by pNext + */ +typedef enum VkLayerFunction_ { + VK_LAYER_LINK_INFO = 0, + VK_LOADER_DATA_CALLBACK = 1, + VK_LOADER_LAYER_CREATE_DEVICE_CALLBACK = 2, + VK_LOADER_FEATURES = 3, +} VkLayerFunction; + +typedef struct VkLayerInstanceLink_ { + struct VkLayerInstanceLink_ *pNext; + PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; + PFN_GetPhysicalDeviceProcAddr pfnNextGetPhysicalDeviceProcAddr; +} VkLayerInstanceLink; + +/* + * When creating the device chain the loader needs to pass + * down information about it's device structure needed at + * the end of the chain. Passing the data via the + * VkLayerDeviceInfo avoids issues with finding the + * exact instance being used. + */ +typedef struct VkLayerDeviceInfo_ { + void *device_info; + PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; +} VkLayerDeviceInfo; + +typedef VkResult (VKAPI_PTR *PFN_vkSetInstanceLoaderData)(VkInstance instance, + void *object); +typedef VkResult (VKAPI_PTR *PFN_vkSetDeviceLoaderData)(VkDevice device, + void *object); +typedef VkResult (VKAPI_PTR *PFN_vkLayerCreateDevice)(VkInstance instance, VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, + const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, PFN_vkGetInstanceProcAddr layerGIPA, PFN_vkGetDeviceProcAddr *nextGDPA); +typedef void (VKAPI_PTR *PFN_vkLayerDestroyDevice)(VkDevice physicalDevice, const VkAllocationCallbacks *pAllocator, PFN_vkDestroyDevice destroyFunction); + +typedef enum VkLoaderFeastureFlagBits { + VK_LOADER_FEATURE_PHYSICAL_DEVICE_SORTING = 0x00000001, +} VkLoaderFlagBits; +typedef VkFlags VkLoaderFeatureFlags; + +typedef struct { + VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO + const void *pNext; + VkLayerFunction function; + union { + VkLayerInstanceLink *pLayerInfo; + PFN_vkSetInstanceLoaderData pfnSetInstanceLoaderData; + struct { + PFN_vkLayerCreateDevice pfnLayerCreateDevice; + PFN_vkLayerDestroyDevice pfnLayerDestroyDevice; + } layerDevice; + VkLoaderFeatureFlags loaderFeatures; + } u; +} VkLayerInstanceCreateInfo; + +typedef struct VkLayerDeviceLink_ { + struct VkLayerDeviceLink_ *pNext; + PFN_vkGetInstanceProcAddr pfnNextGetInstanceProcAddr; + PFN_vkGetDeviceProcAddr pfnNextGetDeviceProcAddr; +} VkLayerDeviceLink; + +typedef struct { + VkStructureType sType; // VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO + const void *pNext; + VkLayerFunction function; + union { + VkLayerDeviceLink *pLayerInfo; + PFN_vkSetDeviceLoaderData pfnSetDeviceLoaderData; + } u; +} VkLayerDeviceCreateInfo; + +#ifdef __cplusplus +extern "C" { +#endif + +VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *pVersionStruct); + +typedef enum VkChainType { + VK_CHAIN_TYPE_UNKNOWN = 0, + VK_CHAIN_TYPE_ENUMERATE_INSTANCE_EXTENSION_PROPERTIES = 1, + VK_CHAIN_TYPE_ENUMERATE_INSTANCE_LAYER_PROPERTIES = 2, + VK_CHAIN_TYPE_ENUMERATE_INSTANCE_VERSION = 3, +} VkChainType; + +typedef struct VkChainHeader { + VkChainType type; + uint32_t version; + uint32_t size; +} VkChainHeader; + +typedef struct VkEnumerateInstanceExtensionPropertiesChain { + VkChainHeader header; + VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceExtensionPropertiesChain *, const char *, uint32_t *, + VkExtensionProperties *); + const struct VkEnumerateInstanceExtensionPropertiesChain *pNextLink; + +#if defined(__cplusplus) + inline VkResult CallDown(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties) const { + return pfnNextLayer(pNextLink, pLayerName, pPropertyCount, pProperties); + } +#endif +} VkEnumerateInstanceExtensionPropertiesChain; + +typedef struct VkEnumerateInstanceLayerPropertiesChain { + VkChainHeader header; + VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceLayerPropertiesChain *, uint32_t *, VkLayerProperties *); + const struct VkEnumerateInstanceLayerPropertiesChain *pNextLink; + +#if defined(__cplusplus) + inline VkResult CallDown(uint32_t *pPropertyCount, VkLayerProperties *pProperties) const { + return pfnNextLayer(pNextLink, pPropertyCount, pProperties); + } +#endif +} VkEnumerateInstanceLayerPropertiesChain; + +typedef struct VkEnumerateInstanceVersionChain { + VkChainHeader header; + VkResult(VKAPI_PTR *pfnNextLayer)(const struct VkEnumerateInstanceVersionChain *, uint32_t *); + const struct VkEnumerateInstanceVersionChain *pNextLink; + +#if defined(__cplusplus) + inline VkResult CallDown(uint32_t *pApiVersion) const { + return pfnNextLayer(pNextLink, pApiVersion); + } +#endif +} VkEnumerateInstanceVersionChain; + +#ifdef __cplusplus +} +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_platform.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_platform.h new file mode 100644 index 0000000..0ecd4f6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vk_platform.h @@ -0,0 +1,84 @@ +// +// File: vk_platform.h +// +/* +** Copyright 2014-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + + +#ifndef VK_PLATFORM_H_ +#define VK_PLATFORM_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +/* +*************************************************************************************************** +* Platform-specific directives and type declarations +*************************************************************************************************** +*/ + +/* Platform-specific calling convention macros. + * + * Platforms should define these so that Vulkan clients call Vulkan commands + * with the same calling conventions that the Vulkan implementation expects. + * + * VKAPI_ATTR - Placed before the return type in function declarations. + * Useful for C++11 and GCC/Clang-style function attribute syntax. + * VKAPI_CALL - Placed after the return type in function declarations. + * Useful for MSVC-style calling convention syntax. + * VKAPI_PTR - Placed between the '(' and '*' in function pointer types. + * + * Function declaration: VKAPI_ATTR void VKAPI_CALL vkCommand(void); + * Function pointer type: typedef void (VKAPI_PTR *PFN_vkCommand)(void); + */ +#if defined(_WIN32) + // On Windows, Vulkan commands use the stdcall convention + #define VKAPI_ATTR + #define VKAPI_CALL __stdcall + #define VKAPI_PTR VKAPI_CALL +#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7 + #error "Vulkan is not supported for the 'armeabi' NDK ABI" +#elif defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE) + // On Android 32-bit ARM targets, Vulkan functions use the "hardfloat" + // calling convention, i.e. float parameters are passed in registers. This + // is true even if the rest of the application passes floats on the stack, + // as it does by default when compiling for the armeabi-v7a NDK ABI. + #define VKAPI_ATTR __attribute__((pcs("aapcs-vfp"))) + #define VKAPI_CALL + #define VKAPI_PTR VKAPI_ATTR +#else + // On other platforms, use the default calling convention + #define VKAPI_ATTR + #define VKAPI_CALL + #define VKAPI_PTR +#endif + +#if !defined(VK_NO_STDDEF_H) + #include +#endif // !defined(VK_NO_STDDEF_H) + +#if !defined(VK_NO_STDINT_H) + #if defined(_MSC_VER) && (_MSC_VER < 1600) + typedef signed __int8 int8_t; + typedef unsigned __int8 uint8_t; + typedef signed __int16 int16_t; + typedef unsigned __int16 uint16_t; + typedef signed __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef signed __int64 int64_t; + typedef unsigned __int64 uint64_t; + #else + #include + #endif +#endif // !defined(VK_NO_STDINT_H) + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan.h new file mode 100644 index 0000000..ef94006 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan.h @@ -0,0 +1,99 @@ +#ifndef VULKAN_H_ +#define VULKAN_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +#include "vk_platform.h" +#include "vulkan_core.h" + +#ifdef VK_USE_PLATFORM_ANDROID_KHR +#include "vulkan_android.h" +#endif + +#ifdef VK_USE_PLATFORM_FUCHSIA +#include +#include "vulkan_fuchsia.h" +#endif + +#ifdef VK_USE_PLATFORM_IOS_MVK +#include "vulkan_ios.h" +#endif + + +#ifdef VK_USE_PLATFORM_MACOS_MVK +#include "vulkan_macos.h" +#endif + +#ifdef VK_USE_PLATFORM_METAL_EXT +#include "vulkan_metal.h" +#endif + +#ifdef VK_USE_PLATFORM_VI_NN +#include "vulkan_vi.h" +#endif + + +#ifdef VK_USE_PLATFORM_WAYLAND_KHR +#include "vulkan_wayland.h" +#endif + + +#ifdef VK_USE_PLATFORM_WIN32_KHR +#include +#include "vulkan_win32.h" +#endif + + +#ifdef VK_USE_PLATFORM_XCB_KHR +#include +#include "vulkan_xcb.h" +#endif + + +#ifdef VK_USE_PLATFORM_XLIB_KHR +#include +#include "vulkan_xlib.h" +#endif + + +#ifdef VK_USE_PLATFORM_DIRECTFB_EXT +#include +#include "vulkan_directfb.h" +#endif + + +#ifdef VK_USE_PLATFORM_XLIB_XRANDR_EXT +#include +#include +#include "vulkan_xlib_xrandr.h" +#endif + + +#ifdef VK_USE_PLATFORM_GGP +#include +#include "vulkan_ggp.h" +#endif + + +#ifdef VK_USE_PLATFORM_SCREEN_QNX +#include +#include "vulkan_screen.h" +#endif + + +#ifdef VK_USE_PLATFORM_SCI +#include +#include +#include "vulkan_sci.h" +#endif + + +#ifdef VK_ENABLE_BETA_EXTENSIONS +#include "vulkan_beta.h" +#endif + +#endif // VULKAN_H_ diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_android.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_android.h new file mode 100644 index 0000000..61ff40b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_android.h @@ -0,0 +1,153 @@ +#ifndef VULKAN_ANDROID_H_ +#define VULKAN_ANDROID_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_KHR_android_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_android_surface 1 +struct ANativeWindow; +#define VK_KHR_ANDROID_SURFACE_SPEC_VERSION 6 +#define VK_KHR_ANDROID_SURFACE_EXTENSION_NAME "VK_KHR_android_surface" +typedef VkFlags VkAndroidSurfaceCreateFlagsKHR; +typedef struct VkAndroidSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkAndroidSurfaceCreateFlagsKHR flags; + struct ANativeWindow* window; +} VkAndroidSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateAndroidSurfaceKHR)(VkInstance instance, const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateAndroidSurfaceKHR( + VkInstance instance, + const VkAndroidSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +// VK_ANDROID_external_memory_android_hardware_buffer is a preprocessor guard. Do not pass it to API calls. +#define VK_ANDROID_external_memory_android_hardware_buffer 1 +struct AHardwareBuffer; +#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_SPEC_VERSION 5 +#define VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME "VK_ANDROID_external_memory_android_hardware_buffer" +typedef struct VkAndroidHardwareBufferUsageANDROID { + VkStructureType sType; + void* pNext; + uint64_t androidHardwareBufferUsage; +} VkAndroidHardwareBufferUsageANDROID; + +typedef struct VkAndroidHardwareBufferPropertiesANDROID { + VkStructureType sType; + void* pNext; + VkDeviceSize allocationSize; + uint32_t memoryTypeBits; +} VkAndroidHardwareBufferPropertiesANDROID; + +typedef struct VkAndroidHardwareBufferFormatPropertiesANDROID { + VkStructureType sType; + void* pNext; + VkFormat format; + uint64_t externalFormat; + VkFormatFeatureFlags formatFeatures; + VkComponentMapping samplerYcbcrConversionComponents; + VkSamplerYcbcrModelConversion suggestedYcbcrModel; + VkSamplerYcbcrRange suggestedYcbcrRange; + VkChromaLocation suggestedXChromaOffset; + VkChromaLocation suggestedYChromaOffset; +} VkAndroidHardwareBufferFormatPropertiesANDROID; + +typedef struct VkImportAndroidHardwareBufferInfoANDROID { + VkStructureType sType; + const void* pNext; + struct AHardwareBuffer* buffer; +} VkImportAndroidHardwareBufferInfoANDROID; + +typedef struct VkMemoryGetAndroidHardwareBufferInfoANDROID { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; +} VkMemoryGetAndroidHardwareBufferInfoANDROID; + +typedef struct VkExternalFormatANDROID { + VkStructureType sType; + void* pNext; + uint64_t externalFormat; +} VkExternalFormatANDROID; + +typedef struct VkAndroidHardwareBufferFormatProperties2ANDROID { + VkStructureType sType; + void* pNext; + VkFormat format; + uint64_t externalFormat; + VkFormatFeatureFlags2 formatFeatures; + VkComponentMapping samplerYcbcrConversionComponents; + VkSamplerYcbcrModelConversion suggestedYcbcrModel; + VkSamplerYcbcrRange suggestedYcbcrRange; + VkChromaLocation suggestedXChromaOffset; + VkChromaLocation suggestedYChromaOffset; +} VkAndroidHardwareBufferFormatProperties2ANDROID; + +typedef VkResult (VKAPI_PTR *PFN_vkGetAndroidHardwareBufferPropertiesANDROID)(VkDevice device, const struct AHardwareBuffer* buffer, VkAndroidHardwareBufferPropertiesANDROID* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryAndroidHardwareBufferANDROID)(VkDevice device, const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, struct AHardwareBuffer** pBuffer); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetAndroidHardwareBufferPropertiesANDROID( + VkDevice device, + const struct AHardwareBuffer* buffer, + VkAndroidHardwareBufferPropertiesANDROID* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryAndroidHardwareBufferANDROID( + VkDevice device, + const VkMemoryGetAndroidHardwareBufferInfoANDROID* pInfo, + struct AHardwareBuffer** pBuffer); +#endif + + +// VK_ANDROID_external_format_resolve is a preprocessor guard. Do not pass it to API calls. +#define VK_ANDROID_external_format_resolve 1 +#define VK_ANDROID_EXTERNAL_FORMAT_RESOLVE_SPEC_VERSION 1 +#define VK_ANDROID_EXTERNAL_FORMAT_RESOLVE_EXTENSION_NAME "VK_ANDROID_external_format_resolve" +typedef struct VkPhysicalDeviceExternalFormatResolveFeaturesANDROID { + VkStructureType sType; + void* pNext; + VkBool32 externalFormatResolve; +} VkPhysicalDeviceExternalFormatResolveFeaturesANDROID; + +typedef struct VkPhysicalDeviceExternalFormatResolvePropertiesANDROID { + VkStructureType sType; + void* pNext; + VkBool32 nullColorAttachmentWithExternalFormatResolve; + VkChromaLocation externalFormatResolveChromaOffsetX; + VkChromaLocation externalFormatResolveChromaOffsetY; +} VkPhysicalDeviceExternalFormatResolvePropertiesANDROID; + +typedef struct VkAndroidHardwareBufferFormatResolvePropertiesANDROID { + VkStructureType sType; + void* pNext; + VkFormat colorAttachmentFormat; +} VkAndroidHardwareBufferFormatResolvePropertiesANDROID; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_beta.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_beta.h new file mode 100644 index 0000000..df18b40 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_beta.h @@ -0,0 +1,216 @@ +#ifndef VULKAN_BETA_H_ +#define VULKAN_BETA_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_KHR_portability_subset is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_portability_subset 1 +#define VK_KHR_PORTABILITY_SUBSET_SPEC_VERSION 1 +#define VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME "VK_KHR_portability_subset" +typedef struct VkPhysicalDevicePortabilitySubsetFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 constantAlphaColorBlendFactors; + VkBool32 events; + VkBool32 imageViewFormatReinterpretation; + VkBool32 imageViewFormatSwizzle; + VkBool32 imageView2DOn3DImage; + VkBool32 multisampleArrayImage; + VkBool32 mutableComparisonSamplers; + VkBool32 pointPolygons; + VkBool32 samplerMipLodBias; + VkBool32 separateStencilMaskRef; + VkBool32 shaderSampleRateInterpolationFunctions; + VkBool32 tessellationIsolines; + VkBool32 tessellationPointMode; + VkBool32 triangleFans; + VkBool32 vertexAttributeAccessBeyondStride; +} VkPhysicalDevicePortabilitySubsetFeaturesKHR; + +typedef struct VkPhysicalDevicePortabilitySubsetPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t minVertexInputBindingStrideAlignment; +} VkPhysicalDevicePortabilitySubsetPropertiesKHR; + + + +// VK_AMDX_shader_enqueue is a preprocessor guard. Do not pass it to API calls. +#define VK_AMDX_shader_enqueue 1 +#define VK_AMDX_SHADER_ENQUEUE_SPEC_VERSION 1 +#define VK_AMDX_SHADER_ENQUEUE_EXTENSION_NAME "VK_AMDX_shader_enqueue" +#define VK_SHADER_INDEX_UNUSED_AMDX (~0U) +typedef struct VkPhysicalDeviceShaderEnqueueFeaturesAMDX { + VkStructureType sType; + void* pNext; + VkBool32 shaderEnqueue; +} VkPhysicalDeviceShaderEnqueueFeaturesAMDX; + +typedef struct VkPhysicalDeviceShaderEnqueuePropertiesAMDX { + VkStructureType sType; + void* pNext; + uint32_t maxExecutionGraphDepth; + uint32_t maxExecutionGraphShaderOutputNodes; + uint32_t maxExecutionGraphShaderPayloadSize; + uint32_t maxExecutionGraphShaderPayloadCount; + uint32_t executionGraphDispatchAddressAlignment; +} VkPhysicalDeviceShaderEnqueuePropertiesAMDX; + +typedef struct VkExecutionGraphPipelineScratchSizeAMDX { + VkStructureType sType; + void* pNext; + VkDeviceSize size; +} VkExecutionGraphPipelineScratchSizeAMDX; + +typedef struct VkExecutionGraphPipelineCreateInfoAMDX { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + const VkPipelineLibraryCreateInfoKHR* pLibraryInfo; + VkPipelineLayout layout; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkExecutionGraphPipelineCreateInfoAMDX; + +typedef union VkDeviceOrHostAddressConstAMDX { + VkDeviceAddress deviceAddress; + const void* hostAddress; +} VkDeviceOrHostAddressConstAMDX; + +typedef struct VkDispatchGraphInfoAMDX { + uint32_t nodeIndex; + uint32_t payloadCount; + VkDeviceOrHostAddressConstAMDX payloads; + uint64_t payloadStride; +} VkDispatchGraphInfoAMDX; + +typedef struct VkDispatchGraphCountInfoAMDX { + uint32_t count; + VkDeviceOrHostAddressConstAMDX infos; + uint64_t stride; +} VkDispatchGraphCountInfoAMDX; + +typedef struct VkPipelineShaderStageNodeCreateInfoAMDX { + VkStructureType sType; + const void* pNext; + const char* pName; + uint32_t index; +} VkPipelineShaderStageNodeCreateInfoAMDX; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateExecutionGraphPipelinesAMDX)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkExecutionGraphPipelineCreateInfoAMDX* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineScratchSizeAMDX)(VkDevice device, VkPipeline executionGraph, VkExecutionGraphPipelineScratchSizeAMDX* pSizeInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetExecutionGraphPipelineNodeIndexAMDX)(VkDevice device, VkPipeline executionGraph, const VkPipelineShaderStageNodeCreateInfoAMDX* pNodeInfo, uint32_t* pNodeIndex); +typedef void (VKAPI_PTR *PFN_vkCmdInitializeGraphScratchMemoryAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, const VkDispatchGraphCountInfoAMDX* pCountInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, const VkDispatchGraphCountInfoAMDX* pCountInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchGraphIndirectCountAMDX)(VkCommandBuffer commandBuffer, VkDeviceAddress scratch, VkDeviceAddress countInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateExecutionGraphPipelinesAMDX( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkExecutionGraphPipelineCreateInfoAMDX* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetExecutionGraphPipelineScratchSizeAMDX( + VkDevice device, + VkPipeline executionGraph, + VkExecutionGraphPipelineScratchSizeAMDX* pSizeInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetExecutionGraphPipelineNodeIndexAMDX( + VkDevice device, + VkPipeline executionGraph, + const VkPipelineShaderStageNodeCreateInfoAMDX* pNodeInfo, + uint32_t* pNodeIndex); + +VKAPI_ATTR void VKAPI_CALL vkCmdInitializeGraphScratchMemoryAMDX( + VkCommandBuffer commandBuffer, + VkDeviceAddress scratch); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphAMDX( + VkCommandBuffer commandBuffer, + VkDeviceAddress scratch, + const VkDispatchGraphCountInfoAMDX* pCountInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphIndirectAMDX( + VkCommandBuffer commandBuffer, + VkDeviceAddress scratch, + const VkDispatchGraphCountInfoAMDX* pCountInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchGraphIndirectCountAMDX( + VkCommandBuffer commandBuffer, + VkDeviceAddress scratch, + VkDeviceAddress countInfo); +#endif + + +// VK_NV_displacement_micromap is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_displacement_micromap 1 +#define VK_NV_DISPLACEMENT_MICROMAP_SPEC_VERSION 2 +#define VK_NV_DISPLACEMENT_MICROMAP_EXTENSION_NAME "VK_NV_displacement_micromap" + +typedef enum VkDisplacementMicromapFormatNV { + VK_DISPLACEMENT_MICROMAP_FORMAT_64_TRIANGLES_64_BYTES_NV = 1, + VK_DISPLACEMENT_MICROMAP_FORMAT_256_TRIANGLES_128_BYTES_NV = 2, + VK_DISPLACEMENT_MICROMAP_FORMAT_1024_TRIANGLES_128_BYTES_NV = 3, + VK_DISPLACEMENT_MICROMAP_FORMAT_MAX_ENUM_NV = 0x7FFFFFFF +} VkDisplacementMicromapFormatNV; +typedef struct VkPhysicalDeviceDisplacementMicromapFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 displacementMicromap; +} VkPhysicalDeviceDisplacementMicromapFeaturesNV; + +typedef struct VkPhysicalDeviceDisplacementMicromapPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t maxDisplacementMicromapSubdivisionLevel; +} VkPhysicalDeviceDisplacementMicromapPropertiesNV; + +typedef struct VkAccelerationStructureTrianglesDisplacementMicromapNV { + VkStructureType sType; + void* pNext; + VkFormat displacementBiasAndScaleFormat; + VkFormat displacementVectorFormat; + VkDeviceOrHostAddressConstKHR displacementBiasAndScaleBuffer; + VkDeviceSize displacementBiasAndScaleStride; + VkDeviceOrHostAddressConstKHR displacementVectorBuffer; + VkDeviceSize displacementVectorStride; + VkDeviceOrHostAddressConstKHR displacedMicromapPrimitiveFlags; + VkDeviceSize displacedMicromapPrimitiveFlagsStride; + VkIndexType indexType; + VkDeviceOrHostAddressConstKHR indexBuffer; + VkDeviceSize indexStride; + uint32_t baseTriangle; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkMicromapEXT micromap; +} VkAccelerationStructureTrianglesDisplacementMicromapNV; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_core.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_core.h new file mode 100644 index 0000000..dd46027 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_core.h @@ -0,0 +1,19661 @@ +#ifndef VULKAN_CORE_H_ +#define VULKAN_CORE_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_VERSION_1_0 is a preprocessor guard. Do not pass it to API calls. +#define VK_VERSION_1_0 1 +#include "vk_platform.h" + +#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; + + +#ifndef VK_USE_64_BIT_PTR_DEFINES + #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) || (defined(__riscv) && __riscv_xlen == 64) + #define VK_USE_64_BIT_PTR_DEFINES 1 + #else + #define VK_USE_64_BIT_PTR_DEFINES 0 + #endif +#endif + + +#ifndef VK_DEFINE_NON_DISPATCHABLE_HANDLE + #if (VK_USE_64_BIT_PTR_DEFINES==1) + #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L)) + #define VK_NULL_HANDLE nullptr + #else + #define VK_NULL_HANDLE ((void*)0) + #endif + #else + #define VK_NULL_HANDLE 0ULL + #endif +#endif +#ifndef VK_NULL_HANDLE + #define VK_NULL_HANDLE 0 +#endif + + +#ifndef VK_DEFINE_NON_DISPATCHABLE_HANDLE + #if (VK_USE_64_BIT_PTR_DEFINES==1) + #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object; + #else + #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; + #endif +#endif + +#define VK_MAKE_API_VERSION(variant, major, minor, patch) \ + ((((uint32_t)(variant)) << 29U) | (((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) + +// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead. +//#define VK_API_VERSION VK_MAKE_API_VERSION(0, 1, 0, 0) // Patch version should always be set to 0 + +// Vulkan 1.0 version number +#define VK_API_VERSION_1_0 VK_MAKE_API_VERSION(0, 1, 0, 0)// Patch version should always be set to 0 + +// Version of this file +#define VK_HEADER_VERSION 282 + +// Complete version of this file +#define VK_HEADER_VERSION_COMPLETE VK_MAKE_API_VERSION(0, 1, 3, VK_HEADER_VERSION) + +// DEPRECATED: This define is deprecated. VK_MAKE_API_VERSION should be used instead. +#define VK_MAKE_VERSION(major, minor, patch) \ + ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch))) + +// DEPRECATED: This define is deprecated. VK_API_VERSION_MAJOR should be used instead. +#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22U) + +// DEPRECATED: This define is deprecated. VK_API_VERSION_MINOR should be used instead. +#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) + +// DEPRECATED: This define is deprecated. VK_API_VERSION_PATCH should be used instead. +#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) + +#define VK_API_VERSION_VARIANT(version) ((uint32_t)(version) >> 29U) +#define VK_API_VERSION_MAJOR(version) (((uint32_t)(version) >> 22U) & 0x7FU) +#define VK_API_VERSION_MINOR(version) (((uint32_t)(version) >> 12U) & 0x3FFU) +#define VK_API_VERSION_PATCH(version) ((uint32_t)(version) & 0xFFFU) +typedef uint32_t VkBool32; +typedef uint64_t VkDeviceAddress; +typedef uint64_t VkDeviceSize; +typedef uint32_t VkFlags; +typedef uint32_t VkSampleMask; +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBuffer) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImage) +VK_DEFINE_HANDLE(VkInstance) +VK_DEFINE_HANDLE(VkPhysicalDevice) +VK_DEFINE_HANDLE(VkDevice) +VK_DEFINE_HANDLE(VkQueue) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSemaphore) +VK_DEFINE_HANDLE(VkCommandBuffer) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFence) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeviceMemory) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkEvent) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkQueryPool) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferView) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkImageView) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderModule) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineCache) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipelineLayout) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPipeline) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkRenderPass) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSetLayout) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSampler) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorSet) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorPool) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkFramebuffer) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCommandPool) +#define VK_ATTACHMENT_UNUSED (~0U) +#define VK_FALSE 0U +#define VK_LOD_CLAMP_NONE 1000.0F +#define VK_QUEUE_FAMILY_IGNORED (~0U) +#define VK_REMAINING_ARRAY_LAYERS (~0U) +#define VK_REMAINING_MIP_LEVELS (~0U) +#define VK_SUBPASS_EXTERNAL (~0U) +#define VK_TRUE 1U +#define VK_WHOLE_SIZE (~0ULL) +#define VK_MAX_MEMORY_TYPES 32U +#define VK_MAX_PHYSICAL_DEVICE_NAME_SIZE 256U +#define VK_UUID_SIZE 16U +#define VK_MAX_EXTENSION_NAME_SIZE 256U +#define VK_MAX_DESCRIPTION_SIZE 256U +#define VK_MAX_MEMORY_HEAPS 16U + +typedef enum VkResult { + VK_SUCCESS = 0, + VK_NOT_READY = 1, + VK_TIMEOUT = 2, + VK_EVENT_SET = 3, + VK_EVENT_RESET = 4, + VK_INCOMPLETE = 5, + VK_ERROR_OUT_OF_HOST_MEMORY = -1, + VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, + VK_ERROR_INITIALIZATION_FAILED = -3, + VK_ERROR_DEVICE_LOST = -4, + VK_ERROR_MEMORY_MAP_FAILED = -5, + VK_ERROR_LAYER_NOT_PRESENT = -6, + VK_ERROR_EXTENSION_NOT_PRESENT = -7, + VK_ERROR_FEATURE_NOT_PRESENT = -8, + VK_ERROR_INCOMPATIBLE_DRIVER = -9, + VK_ERROR_TOO_MANY_OBJECTS = -10, + VK_ERROR_FORMAT_NOT_SUPPORTED = -11, + VK_ERROR_FRAGMENTED_POOL = -12, + VK_ERROR_UNKNOWN = -13, + VK_ERROR_OUT_OF_POOL_MEMORY = -1000069000, + VK_ERROR_INVALID_EXTERNAL_HANDLE = -1000072003, + VK_ERROR_FRAGMENTATION = -1000161000, + VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS = -1000257000, + VK_PIPELINE_COMPILE_REQUIRED = 1000297000, + VK_ERROR_SURFACE_LOST_KHR = -1000000000, + VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, + VK_SUBOPTIMAL_KHR = 1000001003, + VK_ERROR_OUT_OF_DATE_KHR = -1000001004, + VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, + VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, + VK_ERROR_INVALID_SHADER_NV = -1000012000, + VK_ERROR_IMAGE_USAGE_NOT_SUPPORTED_KHR = -1000023000, + VK_ERROR_VIDEO_PICTURE_LAYOUT_NOT_SUPPORTED_KHR = -1000023001, + VK_ERROR_VIDEO_PROFILE_OPERATION_NOT_SUPPORTED_KHR = -1000023002, + VK_ERROR_VIDEO_PROFILE_FORMAT_NOT_SUPPORTED_KHR = -1000023003, + VK_ERROR_VIDEO_PROFILE_CODEC_NOT_SUPPORTED_KHR = -1000023004, + VK_ERROR_VIDEO_STD_VERSION_NOT_SUPPORTED_KHR = -1000023005, + VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT = -1000158000, + VK_ERROR_NOT_PERMITTED_KHR = -1000174001, + VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT = -1000255000, + VK_THREAD_IDLE_KHR = 1000268000, + VK_THREAD_DONE_KHR = 1000268001, + VK_OPERATION_DEFERRED_KHR = 1000268002, + VK_OPERATION_NOT_DEFERRED_KHR = 1000268003, + VK_ERROR_INVALID_VIDEO_STD_PARAMETERS_KHR = -1000299000, + VK_ERROR_COMPRESSION_EXHAUSTED_EXT = -1000338000, + VK_INCOMPATIBLE_SHADER_BINARY_EXT = 1000482000, + VK_ERROR_OUT_OF_POOL_MEMORY_KHR = VK_ERROR_OUT_OF_POOL_MEMORY, + VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR = VK_ERROR_INVALID_EXTERNAL_HANDLE, + VK_ERROR_FRAGMENTATION_EXT = VK_ERROR_FRAGMENTATION, + VK_ERROR_NOT_PERMITTED_EXT = VK_ERROR_NOT_PERMITTED_KHR, + VK_ERROR_INVALID_DEVICE_ADDRESS_EXT = VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, + VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR = VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS, + VK_PIPELINE_COMPILE_REQUIRED_EXT = VK_PIPELINE_COMPILE_REQUIRED, + VK_ERROR_PIPELINE_COMPILE_REQUIRED_EXT = VK_PIPELINE_COMPILE_REQUIRED, + VK_ERROR_INCOMPATIBLE_SHADER_BINARY_EXT = VK_INCOMPATIBLE_SHADER_BINARY_EXT, + VK_RESULT_MAX_ENUM = 0x7FFFFFFF +} VkResult; + +typedef enum VkStructureType { + VK_STRUCTURE_TYPE_APPLICATION_INFO = 0, + VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO = 1, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO = 2, + VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO = 3, + VK_STRUCTURE_TYPE_SUBMIT_INFO = 4, + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO = 5, + VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE = 6, + VK_STRUCTURE_TYPE_BIND_SPARSE_INFO = 7, + VK_STRUCTURE_TYPE_FENCE_CREATE_INFO = 8, + VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO = 9, + VK_STRUCTURE_TYPE_EVENT_CREATE_INFO = 10, + VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO = 11, + VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO = 12, + VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO = 13, + VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO = 14, + VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO = 15, + VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO = 16, + VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO = 17, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO = 18, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO = 19, + VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO = 20, + VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO = 21, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO = 22, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO = 23, + VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO = 24, + VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO = 25, + VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO = 26, + VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO = 27, + VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO = 28, + VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO = 29, + VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO = 30, + VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO = 31, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO = 32, + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO = 33, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO = 34, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET = 35, + VK_STRUCTURE_TYPE_COPY_DESCRIPTOR_SET = 36, + VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO = 37, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO = 38, + VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO = 39, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO = 40, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO = 41, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO = 42, + VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO = 43, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER = 44, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER = 45, + VK_STRUCTURE_TYPE_MEMORY_BARRIER = 46, + VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO = 47, + VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO = 48, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES = 1000094000, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO = 1000157000, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO = 1000157001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES = 1000083000, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS = 1000127000, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO = 1000127001, + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO = 1000060000, + VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO = 1000060003, + VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO = 1000060004, + VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO = 1000060005, + VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO = 1000060006, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO = 1000060013, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO = 1000060014, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES = 1000070000, + VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO = 1000070001, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2 = 1000146000, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2 = 1000146001, + VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2 = 1000146002, + VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2 = 1000146003, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2 = 1000146004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 = 1000059000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2 = 1000059001, + VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2 = 1000059002, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2 = 1000059003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2 = 1000059004, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2 = 1000059005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2 = 1000059006, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2 = 1000059007, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2 = 1000059008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES = 1000117000, + VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO = 1000117001, + VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO = 1000117002, + VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO = 1000117003, + VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO = 1000053000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES = 1000053001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES = 1000053002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES = 1000120000, + VK_STRUCTURE_TYPE_PROTECTED_SUBMIT_INFO = 1000145000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES = 1000145001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_PROPERTIES = 1000145002, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_INFO_2 = 1000145003, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO = 1000156000, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO = 1000156001, + VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO = 1000156002, + VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO = 1000156003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES = 1000156004, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES = 1000156005, + VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO = 1000085000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO = 1000071000, + VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES = 1000071001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO = 1000071002, + VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES = 1000071003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES = 1000071004, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO = 1000072000, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO = 1000072001, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO = 1000072002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO = 1000112000, + VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES = 1000112001, + VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO = 1000113000, + VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO = 1000077000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO = 1000076000, + VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES = 1000076001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES = 1000168000, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT = 1000168001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES = 1000063000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_FEATURES = 49, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_1_PROPERTIES = 50, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES = 51, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_PROPERTIES = 52, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO = 1000147000, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2 = 1000109000, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2 = 1000109001, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2 = 1000109002, + VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2 = 1000109003, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2 = 1000109004, + VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO = 1000109005, + VK_STRUCTURE_TYPE_SUBPASS_END_INFO = 1000109006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES = 1000177000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES = 1000196000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES = 1000180000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES = 1000082000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES = 1000197000, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO = 1000161000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES = 1000161001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES = 1000161002, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO = 1000161003, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT = 1000161004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES = 1000199000, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE = 1000199001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES = 1000221000, + VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO = 1000246000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES = 1000130000, + VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO = 1000130001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES = 1000211000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES = 1000108000, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO = 1000108001, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO = 1000108002, + VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO = 1000108003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES = 1000253000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES = 1000175000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES = 1000241000, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT = 1000241001, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT = 1000241002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES = 1000261000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES = 1000207000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES = 1000207001, + VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO = 1000207002, + VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO = 1000207003, + VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO = 1000207004, + VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO = 1000207005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES = 1000257000, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO = 1000244001, + VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO = 1000257002, + VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO = 1000257003, + VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO = 1000257004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES = 53, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_PROPERTIES = 54, + VK_STRUCTURE_TYPE_PIPELINE_CREATION_FEEDBACK_CREATE_INFO = 1000192000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES = 1000215000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES = 1000245000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES = 1000276000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES = 1000295000, + VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO = 1000295001, + VK_STRUCTURE_TYPE_PRIVATE_DATA_SLOT_CREATE_INFO = 1000295002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES = 1000297000, + VK_STRUCTURE_TYPE_MEMORY_BARRIER_2 = 1000314000, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2 = 1000314001, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2 = 1000314002, + VK_STRUCTURE_TYPE_DEPENDENCY_INFO = 1000314003, + VK_STRUCTURE_TYPE_SUBMIT_INFO_2 = 1000314004, + VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO = 1000314005, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO = 1000314006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES = 1000314007, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES = 1000325000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES = 1000335000, + VK_STRUCTURE_TYPE_COPY_BUFFER_INFO_2 = 1000337000, + VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2 = 1000337001, + VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2 = 1000337002, + VK_STRUCTURE_TYPE_COPY_IMAGE_TO_BUFFER_INFO_2 = 1000337003, + VK_STRUCTURE_TYPE_BLIT_IMAGE_INFO_2 = 1000337004, + VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2 = 1000337005, + VK_STRUCTURE_TYPE_BUFFER_COPY_2 = 1000337006, + VK_STRUCTURE_TYPE_IMAGE_COPY_2 = 1000337007, + VK_STRUCTURE_TYPE_IMAGE_BLIT_2 = 1000337008, + VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2 = 1000337009, + VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2 = 1000337010, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES = 1000225000, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO = 1000225001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES = 1000225002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES = 1000138000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES = 1000138001, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK = 1000138002, + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO = 1000138003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES = 1000066000, + VK_STRUCTURE_TYPE_RENDERING_INFO = 1000044000, + VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO = 1000044001, + VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO = 1000044002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES = 1000044003, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO = 1000044004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES = 1000280000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES = 1000280001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES = 1000281001, + VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3 = 1000360000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES = 1000413000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES = 1000413001, + VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS = 1000413002, + VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS = 1000413003, + VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR = 1000001000, + VK_STRUCTURE_TYPE_PRESENT_INFO_KHR = 1000001001, + VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_CAPABILITIES_KHR = 1000060007, + VK_STRUCTURE_TYPE_IMAGE_SWAPCHAIN_CREATE_INFO_KHR = 1000060008, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_SWAPCHAIN_INFO_KHR = 1000060009, + VK_STRUCTURE_TYPE_ACQUIRE_NEXT_IMAGE_INFO_KHR = 1000060010, + VK_STRUCTURE_TYPE_DEVICE_GROUP_PRESENT_INFO_KHR = 1000060011, + VK_STRUCTURE_TYPE_DEVICE_GROUP_SWAPCHAIN_CREATE_INFO_KHR = 1000060012, + VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR = 1000002000, + VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR = 1000002001, + VK_STRUCTURE_TYPE_DISPLAY_PRESENT_INFO_KHR = 1000003000, + VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, + VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, + VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, + VK_STRUCTURE_TYPE_ANDROID_SURFACE_CREATE_INFO_KHR = 1000008000, + VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, + VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT = 1000011000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_RASTERIZATION_ORDER_AMD = 1000018000, + VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT = 1000022000, + VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT = 1000022001, + VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT = 1000022002, + VK_STRUCTURE_TYPE_VIDEO_PROFILE_INFO_KHR = 1000023000, + VK_STRUCTURE_TYPE_VIDEO_CAPABILITIES_KHR = 1000023001, + VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR = 1000023002, + VK_STRUCTURE_TYPE_VIDEO_SESSION_MEMORY_REQUIREMENTS_KHR = 1000023003, + VK_STRUCTURE_TYPE_BIND_VIDEO_SESSION_MEMORY_INFO_KHR = 1000023004, + VK_STRUCTURE_TYPE_VIDEO_SESSION_CREATE_INFO_KHR = 1000023005, + VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000023006, + VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_UPDATE_INFO_KHR = 1000023007, + VK_STRUCTURE_TYPE_VIDEO_BEGIN_CODING_INFO_KHR = 1000023008, + VK_STRUCTURE_TYPE_VIDEO_END_CODING_INFO_KHR = 1000023009, + VK_STRUCTURE_TYPE_VIDEO_CODING_CONTROL_INFO_KHR = 1000023010, + VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR = 1000023011, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_VIDEO_PROPERTIES_KHR = 1000023012, + VK_STRUCTURE_TYPE_VIDEO_PROFILE_LIST_INFO_KHR = 1000023013, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_FORMAT_INFO_KHR = 1000023014, + VK_STRUCTURE_TYPE_VIDEO_FORMAT_PROPERTIES_KHR = 1000023015, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_QUERY_RESULT_STATUS_PROPERTIES_KHR = 1000023016, + VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR = 1000024000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_CAPABILITIES_KHR = 1000024001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR = 1000024002, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_IMAGE_CREATE_INFO_NV = 1000026000, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_BUFFER_CREATE_INFO_NV = 1000026001, + VK_STRUCTURE_TYPE_DEDICATED_ALLOCATION_MEMORY_ALLOCATE_INFO_NV = 1000026002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_FEATURES_EXT = 1000028000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TRANSFORM_FEEDBACK_PROPERTIES_EXT = 1000028001, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_STREAM_CREATE_INFO_EXT = 1000028002, + VK_STRUCTURE_TYPE_CU_MODULE_CREATE_INFO_NVX = 1000029000, + VK_STRUCTURE_TYPE_CU_FUNCTION_CREATE_INFO_NVX = 1000029001, + VK_STRUCTURE_TYPE_CU_LAUNCH_INFO_NVX = 1000029002, + VK_STRUCTURE_TYPE_IMAGE_VIEW_HANDLE_INFO_NVX = 1000030000, + VK_STRUCTURE_TYPE_IMAGE_VIEW_ADDRESS_PROPERTIES_NVX = 1000030001, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_CAPABILITIES_KHR = 1000038000, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000038001, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_ADD_INFO_KHR = 1000038002, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PICTURE_INFO_KHR = 1000038003, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_DPB_SLOT_INFO_KHR = 1000038004, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_NALU_SLICE_INFO_KHR = 1000038005, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_GOP_REMAINING_FRAME_INFO_KHR = 1000038006, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_PROFILE_INFO_KHR = 1000038007, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_INFO_KHR = 1000038008, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_RATE_CONTROL_LAYER_INFO_KHR = 1000038009, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_CREATE_INFO_KHR = 1000038010, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_QUALITY_LEVEL_PROPERTIES_KHR = 1000038011, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_GET_INFO_KHR = 1000038012, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H264_SESSION_PARAMETERS_FEEDBACK_INFO_KHR = 1000038013, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_CAPABILITIES_KHR = 1000039000, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000039001, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR = 1000039002, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PICTURE_INFO_KHR = 1000039003, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_DPB_SLOT_INFO_KHR = 1000039004, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_NALU_SLICE_SEGMENT_INFO_KHR = 1000039005, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_GOP_REMAINING_FRAME_INFO_KHR = 1000039006, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_PROFILE_INFO_KHR = 1000039007, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_INFO_KHR = 1000039009, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_RATE_CONTROL_LAYER_INFO_KHR = 1000039010, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_CREATE_INFO_KHR = 1000039011, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_QUALITY_LEVEL_PROPERTIES_KHR = 1000039012, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_GET_INFO_KHR = 1000039013, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_H265_SESSION_PARAMETERS_FEEDBACK_INFO_KHR = 1000039014, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_CAPABILITIES_KHR = 1000040000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PICTURE_INFO_KHR = 1000040001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR = 1000040003, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000040004, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_SESSION_PARAMETERS_ADD_INFO_KHR = 1000040005, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_DPB_SLOT_INFO_KHR = 1000040006, + VK_STRUCTURE_TYPE_TEXTURE_LOD_GATHER_FORMAT_PROPERTIES_AMD = 1000041000, + VK_STRUCTURE_TYPE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000044006, + VK_STRUCTURE_TYPE_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_INFO_EXT = 1000044007, + VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD = 1000044008, + VK_STRUCTURE_TYPE_MULTIVIEW_PER_VIEW_ATTRIBUTES_INFO_NVX = 1000044009, + VK_STRUCTURE_TYPE_STREAM_DESCRIPTOR_SURFACE_CREATE_INFO_GGP = 1000049000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CORNER_SAMPLED_IMAGE_FEATURES_NV = 1000050000, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_NV = 1000056000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_NV = 1000056001, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_NV = 1000057001, + VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_NV = 1000058000, + VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT = 1000061000, + VK_STRUCTURE_TYPE_VI_SURFACE_CREATE_INFO_NN = 1000062000, + VK_STRUCTURE_TYPE_IMAGE_VIEW_ASTC_DECODE_MODE_EXT = 1000067000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ASTC_DECODE_FEATURES_EXT = 1000067001, + VK_STRUCTURE_TYPE_PIPELINE_ROBUSTNESS_CREATE_INFO_EXT = 1000068000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_FEATURES_EXT = 1000068001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_ROBUSTNESS_PROPERTIES_EXT = 1000068002, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073000, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_WIN32_HANDLE_INFO_KHR = 1000073001, + VK_STRUCTURE_TYPE_MEMORY_WIN32_HANDLE_PROPERTIES_KHR = 1000073002, + VK_STRUCTURE_TYPE_MEMORY_GET_WIN32_HANDLE_INFO_KHR = 1000073003, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_FD_INFO_KHR = 1000074000, + VK_STRUCTURE_TYPE_MEMORY_FD_PROPERTIES_KHR = 1000074001, + VK_STRUCTURE_TYPE_MEMORY_GET_FD_INFO_KHR = 1000074002, + VK_STRUCTURE_TYPE_WIN32_KEYED_MUTEX_ACQUIRE_RELEASE_INFO_KHR = 1000075000, + VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078000, + VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_WIN32_HANDLE_INFO_KHR = 1000078001, + VK_STRUCTURE_TYPE_D3D12_FENCE_SUBMIT_INFO_KHR = 1000078002, + VK_STRUCTURE_TYPE_SEMAPHORE_GET_WIN32_HANDLE_INFO_KHR = 1000078003, + VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_FD_INFO_KHR = 1000079000, + VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR = 1000079001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PUSH_DESCRIPTOR_PROPERTIES_KHR = 1000080000, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT = 1000081000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONDITIONAL_RENDERING_FEATURES_EXT = 1000081001, + VK_STRUCTURE_TYPE_CONDITIONAL_RENDERING_BEGIN_INFO_EXT = 1000081002, + VK_STRUCTURE_TYPE_PRESENT_REGIONS_KHR = 1000084000, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV = 1000087000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT = 1000090000, + VK_STRUCTURE_TYPE_DISPLAY_POWER_INFO_EXT = 1000091000, + VK_STRUCTURE_TYPE_DEVICE_EVENT_INFO_EXT = 1000091001, + VK_STRUCTURE_TYPE_DISPLAY_EVENT_INFO_EXT = 1000091002, + VK_STRUCTURE_TYPE_SWAPCHAIN_COUNTER_CREATE_INFO_EXT = 1000091003, + VK_STRUCTURE_TYPE_PRESENT_TIMES_INFO_GOOGLE = 1000092000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_ATTRIBUTES_PROPERTIES_NVX = 1000097000, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV = 1000098000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISCARD_RECTANGLE_PROPERTIES_EXT = 1000099000, + VK_STRUCTURE_TYPE_PIPELINE_DISCARD_RECTANGLE_STATE_CREATE_INFO_EXT = 1000099001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CONSERVATIVE_RASTERIZATION_PROPERTIES_EXT = 1000101000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_CONSERVATIVE_STATE_CREATE_INFO_EXT = 1000101001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_ENABLE_FEATURES_EXT = 1000102000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_DEPTH_CLIP_STATE_CREATE_INFO_EXT = 1000102001, + VK_STRUCTURE_TYPE_HDR_METADATA_EXT = 1000105000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RELAXED_LINE_RASTERIZATION_FEATURES_IMG = 1000110000, + VK_STRUCTURE_TYPE_SHARED_PRESENT_SURFACE_CAPABILITIES_KHR = 1000111000, + VK_STRUCTURE_TYPE_IMPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114000, + VK_STRUCTURE_TYPE_EXPORT_FENCE_WIN32_HANDLE_INFO_KHR = 1000114001, + VK_STRUCTURE_TYPE_FENCE_GET_WIN32_HANDLE_INFO_KHR = 1000114002, + VK_STRUCTURE_TYPE_IMPORT_FENCE_FD_INFO_KHR = 1000115000, + VK_STRUCTURE_TYPE_FENCE_GET_FD_INFO_KHR = 1000115001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_FEATURES_KHR = 1000116000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PERFORMANCE_QUERY_PROPERTIES_KHR = 1000116001, + VK_STRUCTURE_TYPE_QUERY_POOL_PERFORMANCE_CREATE_INFO_KHR = 1000116002, + VK_STRUCTURE_TYPE_PERFORMANCE_QUERY_SUBMIT_INFO_KHR = 1000116003, + VK_STRUCTURE_TYPE_ACQUIRE_PROFILING_LOCK_INFO_KHR = 1000116004, + VK_STRUCTURE_TYPE_PERFORMANCE_COUNTER_KHR = 1000116005, + VK_STRUCTURE_TYPE_PERFORMANCE_COUNTER_DESCRIPTION_KHR = 1000116006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR = 1000119000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_KHR = 1000119001, + VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR = 1000119002, + VK_STRUCTURE_TYPE_DISPLAY_PROPERTIES_2_KHR = 1000121000, + VK_STRUCTURE_TYPE_DISPLAY_PLANE_PROPERTIES_2_KHR = 1000121001, + VK_STRUCTURE_TYPE_DISPLAY_MODE_PROPERTIES_2_KHR = 1000121002, + VK_STRUCTURE_TYPE_DISPLAY_PLANE_INFO_2_KHR = 1000121003, + VK_STRUCTURE_TYPE_DISPLAY_PLANE_CAPABILITIES_2_KHR = 1000121004, + VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK = 1000122000, + VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, + VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_NAME_INFO_EXT = 1000128000, + VK_STRUCTURE_TYPE_DEBUG_UTILS_OBJECT_TAG_INFO_EXT = 1000128001, + VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT = 1000128002, + VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CALLBACK_DATA_EXT = 1000128003, + VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT = 1000128004, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_USAGE_ANDROID = 1000129000, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID = 1000129001, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID = 1000129002, + VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129003, + VK_STRUCTURE_TYPE_MEMORY_GET_ANDROID_HARDWARE_BUFFER_INFO_ANDROID = 1000129004, + VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_ANDROID = 1000129005, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_2_ANDROID = 1000129006, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ENQUEUE_FEATURES_AMDX = 1000134000, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ENQUEUE_PROPERTIES_AMDX = 1000134001, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_EXECUTION_GRAPH_PIPELINE_SCRATCH_SIZE_AMDX = 1000134002, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_EXECUTION_GRAPH_PIPELINE_CREATE_INFO_AMDX = 1000134003, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_NODE_CREATE_INFO_AMDX = 1000134004, +#endif + VK_STRUCTURE_TYPE_SAMPLE_LOCATIONS_INFO_EXT = 1000143000, + VK_STRUCTURE_TYPE_RENDER_PASS_SAMPLE_LOCATIONS_BEGIN_INFO_EXT = 1000143001, + VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT = 1000143002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT = 1000143003, + VK_STRUCTURE_TYPE_MULTISAMPLE_PROPERTIES_EXT = 1000143004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_FEATURES_EXT = 1000148000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BLEND_OPERATION_ADVANCED_PROPERTIES_EXT = 1000148001, + VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT = 1000148002, + VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_TO_COLOR_STATE_CREATE_INFO_NV = 1000149000, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR = 1000150007, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR = 1000150000, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_DEVICE_ADDRESS_INFO_KHR = 1000150002, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR = 1000150003, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR = 1000150004, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR = 1000150005, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR = 1000150006, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_VERSION_INFO_KHR = 1000150009, + VK_STRUCTURE_TYPE_COPY_ACCELERATION_STRUCTURE_INFO_KHR = 1000150010, + VK_STRUCTURE_TYPE_COPY_ACCELERATION_STRUCTURE_TO_MEMORY_INFO_KHR = 1000150011, + VK_STRUCTURE_TYPE_COPY_MEMORY_TO_ACCELERATION_STRUCTURE_INFO_KHR = 1000150012, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_FEATURES_KHR = 1000150013, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ACCELERATION_STRUCTURE_PROPERTIES_KHR = 1000150014, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_KHR = 1000150017, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_SIZES_INFO_KHR = 1000150020, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_FEATURES_KHR = 1000347000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PIPELINE_PROPERTIES_KHR = 1000347001, + VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_CREATE_INFO_KHR = 1000150015, + VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_KHR = 1000150016, + VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_INTERFACE_CREATE_INFO_KHR = 1000150018, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_QUERY_FEATURES_KHR = 1000348013, + VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_MODULATION_STATE_CREATE_INFO_NV = 1000152000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SM_BUILTINS_FEATURES_NV = 1000154000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SM_BUILTINS_PROPERTIES_NV = 1000154001, + VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT = 1000158000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT = 1000158002, + VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT = 1000158003, + VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT = 1000158004, + VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT = 1000158005, + VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_2_EXT = 1000158006, + VK_STRUCTURE_TYPE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160000, + VK_STRUCTURE_TYPE_SHADER_MODULE_VALIDATION_CACHE_CREATE_INFO_EXT = 1000160001, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_FEATURES_KHR = 1000163000, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PORTABILITY_SUBSET_PROPERTIES_KHR = 1000163001, +#endif + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV = 1000164000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADING_RATE_IMAGE_FEATURES_NV = 1000164001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADING_RATE_IMAGE_PROPERTIES_NV = 1000164002, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV = 1000164005, + VK_STRUCTURE_TYPE_RAY_TRACING_PIPELINE_CREATE_INFO_NV = 1000165000, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CREATE_INFO_NV = 1000165001, + VK_STRUCTURE_TYPE_GEOMETRY_NV = 1000165003, + VK_STRUCTURE_TYPE_GEOMETRY_TRIANGLES_NV = 1000165004, + VK_STRUCTURE_TYPE_GEOMETRY_AABB_NV = 1000165005, + VK_STRUCTURE_TYPE_BIND_ACCELERATION_STRUCTURE_MEMORY_INFO_NV = 1000165006, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_NV = 1000165007, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_INFO_NV = 1000165008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_PROPERTIES_NV = 1000165009, + VK_STRUCTURE_TYPE_RAY_TRACING_SHADER_GROUP_CREATE_INFO_NV = 1000165011, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_INFO_NV = 1000165012, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_REPRESENTATIVE_FRAGMENT_TEST_FEATURES_NV = 1000166000, + VK_STRUCTURE_TYPE_PIPELINE_REPRESENTATIVE_FRAGMENT_TEST_STATE_CREATE_INFO_NV = 1000166001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_IMAGE_FORMAT_INFO_EXT = 1000170000, + VK_STRUCTURE_TYPE_FILTER_CUBIC_IMAGE_VIEW_IMAGE_FORMAT_PROPERTIES_EXT = 1000170001, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_HOST_POINTER_INFO_EXT = 1000178000, + VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT = 1000178001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_HOST_PROPERTIES_EXT = 1000178002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CLOCK_FEATURES_KHR = 1000181000, + VK_STRUCTURE_TYPE_PIPELINE_COMPILER_CONTROL_CREATE_INFO_AMD = 1000183000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_AMD = 1000185000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR = 1000187000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000187001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_ADD_INFO_KHR = 1000187002, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR = 1000187003, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PICTURE_INFO_KHR = 1000187004, + VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_DPB_SLOT_INFO_KHR = 1000187005, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR = 1000174000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR = 1000388000, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR = 1000388001, + VK_STRUCTURE_TYPE_DEVICE_MEMORY_OVERALLOCATION_CREATE_INFO_AMD = 1000189000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_EXT = 1000190000, + VK_STRUCTURE_TYPE_PRESENT_FRAME_TOKEN_GGP = 1000191000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COMPUTE_SHADER_DERIVATIVES_FEATURES_NV = 1000201000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_NV = 1000202000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_NV = 1000202001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_FOOTPRINT_FEATURES_NV = 1000204000, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV = 1000205000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXCLUSIVE_SCISSOR_FEATURES_NV = 1000205002, + VK_STRUCTURE_TYPE_CHECKPOINT_DATA_NV = 1000206000, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_CHECKPOINT_PROPERTIES_NV = 1000206001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_FUNCTIONS_2_FEATURES_INTEL = 1000209000, + VK_STRUCTURE_TYPE_QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL = 1000210000, + VK_STRUCTURE_TYPE_INITIALIZE_PERFORMANCE_API_INFO_INTEL = 1000210001, + VK_STRUCTURE_TYPE_PERFORMANCE_MARKER_INFO_INTEL = 1000210002, + VK_STRUCTURE_TYPE_PERFORMANCE_STREAM_MARKER_INFO_INTEL = 1000210003, + VK_STRUCTURE_TYPE_PERFORMANCE_OVERRIDE_INFO_INTEL = 1000210004, + VK_STRUCTURE_TYPE_PERFORMANCE_CONFIGURATION_ACQUIRE_INFO_INTEL = 1000210005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT = 1000212000, + VK_STRUCTURE_TYPE_DISPLAY_NATIVE_HDR_SURFACE_CAPABILITIES_AMD = 1000213000, + VK_STRUCTURE_TYPE_SWAPCHAIN_DISPLAY_NATIVE_HDR_CREATE_INFO_AMD = 1000213001, + VK_STRUCTURE_TYPE_IMAGEPIPE_SURFACE_CREATE_INFO_FUCHSIA = 1000214000, + VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_FEATURES_EXT = 1000218000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_PROPERTIES_EXT = 1000218001, + VK_STRUCTURE_TYPE_RENDER_PASS_FRAGMENT_DENSITY_MAP_CREATE_INFO_EXT = 1000218002, + VK_STRUCTURE_TYPE_FRAGMENT_SHADING_RATE_ATTACHMENT_INFO_KHR = 1000226000, + VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_STATE_CREATE_INFO_KHR = 1000226001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_PROPERTIES_KHR = 1000226002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_FEATURES_KHR = 1000226003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_KHR = 1000226004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_2_AMD = 1000227000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COHERENT_MEMORY_FEATURES_AMD = 1000229000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_LOCAL_READ_FEATURES_KHR = 1000232000, + VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_LOCATION_INFO_KHR = 1000232001, + VK_STRUCTURE_TYPE_RENDERING_INPUT_ATTACHMENT_INDEX_INFO_KHR = 1000232002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_IMAGE_ATOMIC_INT64_FEATURES_EXT = 1000234000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_QUAD_CONTROL_FEATURES_KHR = 1000235000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_BUDGET_PROPERTIES_EXT = 1000237000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PRIORITY_FEATURES_EXT = 1000238000, + VK_STRUCTURE_TYPE_MEMORY_PRIORITY_ALLOCATE_INFO_EXT = 1000238001, + VK_STRUCTURE_TYPE_SURFACE_PROTECTED_CAPABILITIES_KHR = 1000239000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEDICATED_ALLOCATION_IMAGE_ALIASING_FEATURES_NV = 1000240000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT = 1000244000, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_CREATE_INFO_EXT = 1000244002, + VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT = 1000247000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR = 1000248000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_NV = 1000249000, + VK_STRUCTURE_TYPE_COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_NV = 1000249002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COVERAGE_REDUCTION_MODE_FEATURES_NV = 1000250000, + VK_STRUCTURE_TYPE_PIPELINE_COVERAGE_REDUCTION_STATE_CREATE_INFO_NV = 1000250001, + VK_STRUCTURE_TYPE_FRAMEBUFFER_MIXED_SAMPLES_COMBINATION_NV = 1000250002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_INTERLOCK_FEATURES_EXT = 1000251000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_IMAGE_ARRAYS_FEATURES_EXT = 1000252000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_FEATURES_EXT = 1000254000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT = 1000254001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROVOKING_VERTEX_PROPERTIES_EXT = 1000254002, + VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT = 1000255000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_FULL_SCREEN_EXCLUSIVE_EXT = 1000255002, + VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT = 1000255001, + VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_FEATURES_EXT = 1000260000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_FEATURES_EXT = 1000267000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_EXECUTABLE_PROPERTIES_FEATURES_KHR = 1000269000, + VK_STRUCTURE_TYPE_PIPELINE_INFO_KHR = 1000269001, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_PROPERTIES_KHR = 1000269002, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INFO_KHR = 1000269003, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_STATISTIC_KHR = 1000269004, + VK_STRUCTURE_TYPE_PIPELINE_EXECUTABLE_INTERNAL_REPRESENTATION_KHR = 1000269005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_FEATURES_EXT = 1000270000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_IMAGE_COPY_PROPERTIES_EXT = 1000270001, + VK_STRUCTURE_TYPE_MEMORY_TO_IMAGE_COPY_EXT = 1000270002, + VK_STRUCTURE_TYPE_IMAGE_TO_MEMORY_COPY_EXT = 1000270003, + VK_STRUCTURE_TYPE_COPY_IMAGE_TO_MEMORY_INFO_EXT = 1000270004, + VK_STRUCTURE_TYPE_COPY_MEMORY_TO_IMAGE_INFO_EXT = 1000270005, + VK_STRUCTURE_TYPE_HOST_IMAGE_LAYOUT_TRANSITION_INFO_EXT = 1000270006, + VK_STRUCTURE_TYPE_COPY_IMAGE_TO_IMAGE_INFO_EXT = 1000270007, + VK_STRUCTURE_TYPE_SUBRESOURCE_HOST_MEMCPY_SIZE_EXT = 1000270008, + VK_STRUCTURE_TYPE_HOST_IMAGE_COPY_DEVICE_PERFORMANCE_QUERY_EXT = 1000270009, + VK_STRUCTURE_TYPE_MEMORY_MAP_INFO_KHR = 1000271000, + VK_STRUCTURE_TYPE_MEMORY_UNMAP_INFO_KHR = 1000271001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAP_MEMORY_PLACED_FEATURES_EXT = 1000272000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAP_MEMORY_PLACED_PROPERTIES_EXT = 1000272001, + VK_STRUCTURE_TYPE_MEMORY_MAP_PLACED_INFO_EXT = 1000272002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT_2_FEATURES_EXT = 1000273000, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_EXT = 1000274000, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_SCALING_CAPABILITIES_EXT = 1000274001, + VK_STRUCTURE_TYPE_SURFACE_PRESENT_MODE_COMPATIBILITY_EXT = 1000274002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SWAPCHAIN_MAINTENANCE_1_FEATURES_EXT = 1000275000, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_FENCE_INFO_EXT = 1000275001, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODES_CREATE_INFO_EXT = 1000275002, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_MODE_INFO_EXT = 1000275003, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_SCALING_CREATE_INFO_EXT = 1000275004, + VK_STRUCTURE_TYPE_RELEASE_SWAPCHAIN_IMAGES_INFO_EXT = 1000275005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_PROPERTIES_NV = 1000277000, + VK_STRUCTURE_TYPE_GRAPHICS_SHADER_GROUP_CREATE_INFO_NV = 1000277001, + VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_SHADER_GROUPS_CREATE_INFO_NV = 1000277002, + VK_STRUCTURE_TYPE_INDIRECT_COMMANDS_LAYOUT_TOKEN_NV = 1000277003, + VK_STRUCTURE_TYPE_INDIRECT_COMMANDS_LAYOUT_CREATE_INFO_NV = 1000277004, + VK_STRUCTURE_TYPE_GENERATED_COMMANDS_INFO_NV = 1000277005, + VK_STRUCTURE_TYPE_GENERATED_COMMANDS_MEMORY_REQUIREMENTS_INFO_NV = 1000277006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_FEATURES_NV = 1000277007, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INHERITED_VIEWPORT_SCISSOR_FEATURES_NV = 1000278000, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_VIEWPORT_SCISSOR_INFO_NV = 1000278001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_FEATURES_EXT = 1000281000, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDER_PASS_TRANSFORM_INFO_QCOM = 1000282000, + VK_STRUCTURE_TYPE_RENDER_PASS_TRANSFORM_BEGIN_INFO_QCOM = 1000282001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_BIAS_CONTROL_FEATURES_EXT = 1000283000, + VK_STRUCTURE_TYPE_DEPTH_BIAS_INFO_EXT = 1000283001, + VK_STRUCTURE_TYPE_DEPTH_BIAS_REPRESENTATION_INFO_EXT = 1000283002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_MEMORY_REPORT_FEATURES_EXT = 1000284000, + VK_STRUCTURE_TYPE_DEVICE_DEVICE_MEMORY_REPORT_CREATE_INFO_EXT = 1000284001, + VK_STRUCTURE_TYPE_DEVICE_MEMORY_REPORT_CALLBACK_DATA_EXT = 1000284002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_FEATURES_EXT = 1000286000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ROBUSTNESS_2_PROPERTIES_EXT = 1000286001, + VK_STRUCTURE_TYPE_SAMPLER_CUSTOM_BORDER_COLOR_CREATE_INFO_EXT = 1000287000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_PROPERTIES_EXT = 1000287001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUSTOM_BORDER_COLOR_FEATURES_EXT = 1000287002, + VK_STRUCTURE_TYPE_PIPELINE_LIBRARY_CREATE_INFO_KHR = 1000290000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_BARRIER_FEATURES_NV = 1000292000, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_PRESENT_BARRIER_NV = 1000292001, + VK_STRUCTURE_TYPE_SWAPCHAIN_PRESENT_BARRIER_CREATE_INFO_NV = 1000292002, + VK_STRUCTURE_TYPE_PRESENT_ID_KHR = 1000294000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR = 1000294001, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_INFO_KHR = 1000299000, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_INFO_KHR = 1000299001, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_RATE_CONTROL_LAYER_INFO_KHR = 1000299002, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_CAPABILITIES_KHR = 1000299003, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_USAGE_INFO_KHR = 1000299004, + VK_STRUCTURE_TYPE_QUERY_POOL_VIDEO_ENCODE_FEEDBACK_CREATE_INFO_KHR = 1000299005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR = 1000299006, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_PROPERTIES_KHR = 1000299007, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_QUALITY_LEVEL_INFO_KHR = 1000299008, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_GET_INFO_KHR = 1000299009, + VK_STRUCTURE_TYPE_VIDEO_ENCODE_SESSION_PARAMETERS_FEEDBACK_INFO_KHR = 1000299010, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DIAGNOSTICS_CONFIG_FEATURES_NV = 1000300000, + VK_STRUCTURE_TYPE_DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV = 1000300001, + VK_STRUCTURE_TYPE_CUDA_MODULE_CREATE_INFO_NV = 1000307000, + VK_STRUCTURE_TYPE_CUDA_FUNCTION_CREATE_INFO_NV = 1000307001, + VK_STRUCTURE_TYPE_CUDA_LAUNCH_INFO_NV = 1000307002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUDA_KERNEL_LAUNCH_FEATURES_NV = 1000307003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUDA_KERNEL_LAUNCH_PROPERTIES_NV = 1000307004, + VK_STRUCTURE_TYPE_QUERY_LOW_LATENCY_SUPPORT_NV = 1000310000, + VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECT_CREATE_INFO_EXT = 1000311000, + VK_STRUCTURE_TYPE_EXPORT_METAL_OBJECTS_INFO_EXT = 1000311001, + VK_STRUCTURE_TYPE_EXPORT_METAL_DEVICE_INFO_EXT = 1000311002, + VK_STRUCTURE_TYPE_EXPORT_METAL_COMMAND_QUEUE_INFO_EXT = 1000311003, + VK_STRUCTURE_TYPE_EXPORT_METAL_BUFFER_INFO_EXT = 1000311004, + VK_STRUCTURE_TYPE_IMPORT_METAL_BUFFER_INFO_EXT = 1000311005, + VK_STRUCTURE_TYPE_EXPORT_METAL_TEXTURE_INFO_EXT = 1000311006, + VK_STRUCTURE_TYPE_IMPORT_METAL_TEXTURE_INFO_EXT = 1000311007, + VK_STRUCTURE_TYPE_EXPORT_METAL_IO_SURFACE_INFO_EXT = 1000311008, + VK_STRUCTURE_TYPE_IMPORT_METAL_IO_SURFACE_INFO_EXT = 1000311009, + VK_STRUCTURE_TYPE_EXPORT_METAL_SHARED_EVENT_INFO_EXT = 1000311010, + VK_STRUCTURE_TYPE_IMPORT_METAL_SHARED_EVENT_INFO_EXT = 1000311011, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_CHECKPOINT_PROPERTIES_2_NV = 1000314008, + VK_STRUCTURE_TYPE_CHECKPOINT_DATA_2_NV = 1000314009, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_PROPERTIES_EXT = 1000316000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_DENSITY_MAP_PROPERTIES_EXT = 1000316001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_BUFFER_FEATURES_EXT = 1000316002, + VK_STRUCTURE_TYPE_DESCRIPTOR_ADDRESS_INFO_EXT = 1000316003, + VK_STRUCTURE_TYPE_DESCRIPTOR_GET_INFO_EXT = 1000316004, + VK_STRUCTURE_TYPE_BUFFER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316005, + VK_STRUCTURE_TYPE_IMAGE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316006, + VK_STRUCTURE_TYPE_IMAGE_VIEW_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316007, + VK_STRUCTURE_TYPE_SAMPLER_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316008, + VK_STRUCTURE_TYPE_OPAQUE_CAPTURE_DESCRIPTOR_DATA_CREATE_INFO_EXT = 1000316010, + VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_INFO_EXT = 1000316011, + VK_STRUCTURE_TYPE_DESCRIPTOR_BUFFER_BINDING_PUSH_DESCRIPTOR_BUFFER_HANDLE_EXT = 1000316012, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_CAPTURE_DESCRIPTOR_DATA_INFO_EXT = 1000316009, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_FEATURES_EXT = 1000320000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GRAPHICS_PIPELINE_LIBRARY_PROPERTIES_EXT = 1000320001, + VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_LIBRARY_CREATE_INFO_EXT = 1000320002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_FEATURES_AMD = 1000321000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR = 1000203000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_PROPERTIES_KHR = 1000322000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_FEATURES_KHR = 1000323000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_PROPERTIES_NV = 1000326000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADING_RATE_ENUMS_FEATURES_NV = 1000326001, + VK_STRUCTURE_TYPE_PIPELINE_FRAGMENT_SHADING_RATE_ENUM_STATE_CREATE_INFO_NV = 1000326002, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_MOTION_TRIANGLES_DATA_NV = 1000327000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MOTION_BLUR_FEATURES_NV = 1000327001, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_MOTION_INFO_NV = 1000327002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_FEATURES_EXT = 1000328000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MESH_SHADER_PROPERTIES_EXT = 1000328001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_2_PLANE_444_FORMATS_FEATURES_EXT = 1000330000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_FEATURES_EXT = 1000332000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_2_PROPERTIES_EXT = 1000332001, + VK_STRUCTURE_TYPE_COPY_COMMAND_TRANSFORM_INFO_QCOM = 1000333000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_FEATURES_KHR = 1000336000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_FEATURES_EXT = 1000338000, + VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_CONTROL_EXT = 1000338001, + VK_STRUCTURE_TYPE_IMAGE_COMPRESSION_PROPERTIES_EXT = 1000338004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_FEATURES_EXT = 1000339000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_4444_FORMATS_FEATURES_EXT = 1000340000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FAULT_FEATURES_EXT = 1000341000, + VK_STRUCTURE_TYPE_DEVICE_FAULT_COUNTS_EXT = 1000341001, + VK_STRUCTURE_TYPE_DEVICE_FAULT_INFO_EXT = 1000341002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RGBA10X6_FORMATS_FEATURES_EXT = 1000344000, + VK_STRUCTURE_TYPE_DIRECTFB_SURFACE_CREATE_INFO_EXT = 1000346000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_INPUT_DYNAMIC_STATE_FEATURES_EXT = 1000352000, + VK_STRUCTURE_TYPE_VERTEX_INPUT_BINDING_DESCRIPTION_2_EXT = 1000352001, + VK_STRUCTURE_TYPE_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION_2_EXT = 1000352002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRM_PROPERTIES_EXT = 1000353000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ADDRESS_BINDING_REPORT_FEATURES_EXT = 1000354000, + VK_STRUCTURE_TYPE_DEVICE_ADDRESS_BINDING_CALLBACK_DATA_EXT = 1000354001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLIP_CONTROL_FEATURES_EXT = 1000355000, + VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_DEPTH_CLIP_CONTROL_CREATE_INFO_EXT = 1000355001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVE_TOPOLOGY_LIST_RESTART_FEATURES_EXT = 1000356000, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_ZIRCON_HANDLE_INFO_FUCHSIA = 1000364000, + VK_STRUCTURE_TYPE_MEMORY_ZIRCON_HANDLE_PROPERTIES_FUCHSIA = 1000364001, + VK_STRUCTURE_TYPE_MEMORY_GET_ZIRCON_HANDLE_INFO_FUCHSIA = 1000364002, + VK_STRUCTURE_TYPE_IMPORT_SEMAPHORE_ZIRCON_HANDLE_INFO_FUCHSIA = 1000365000, + VK_STRUCTURE_TYPE_SEMAPHORE_GET_ZIRCON_HANDLE_INFO_FUCHSIA = 1000365001, + VK_STRUCTURE_TYPE_BUFFER_COLLECTION_CREATE_INFO_FUCHSIA = 1000366000, + VK_STRUCTURE_TYPE_IMPORT_MEMORY_BUFFER_COLLECTION_FUCHSIA = 1000366001, + VK_STRUCTURE_TYPE_BUFFER_COLLECTION_IMAGE_CREATE_INFO_FUCHSIA = 1000366002, + VK_STRUCTURE_TYPE_BUFFER_COLLECTION_PROPERTIES_FUCHSIA = 1000366003, + VK_STRUCTURE_TYPE_BUFFER_CONSTRAINTS_INFO_FUCHSIA = 1000366004, + VK_STRUCTURE_TYPE_BUFFER_COLLECTION_BUFFER_CREATE_INFO_FUCHSIA = 1000366005, + VK_STRUCTURE_TYPE_IMAGE_CONSTRAINTS_INFO_FUCHSIA = 1000366006, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_CONSTRAINTS_INFO_FUCHSIA = 1000366007, + VK_STRUCTURE_TYPE_SYSMEM_COLOR_SPACE_FUCHSIA = 1000366008, + VK_STRUCTURE_TYPE_BUFFER_COLLECTION_CONSTRAINTS_INFO_FUCHSIA = 1000366009, + VK_STRUCTURE_TYPE_SUBPASS_SHADING_PIPELINE_CREATE_INFO_HUAWEI = 1000369000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_SHADING_FEATURES_HUAWEI = 1000369001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_SHADING_PROPERTIES_HUAWEI = 1000369002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INVOCATION_MASK_FEATURES_HUAWEI = 1000370000, + VK_STRUCTURE_TYPE_MEMORY_GET_REMOTE_ADDRESS_INFO_NV = 1000371000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_RDMA_FEATURES_NV = 1000371001, + VK_STRUCTURE_TYPE_PIPELINE_PROPERTIES_IDENTIFIER_EXT = 1000372000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROPERTIES_FEATURES_EXT = 1000372001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAME_BOUNDARY_FEATURES_EXT = 1000375000, + VK_STRUCTURE_TYPE_FRAME_BOUNDARY_EXT = 1000375001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_FEATURES_EXT = 1000376000, + VK_STRUCTURE_TYPE_SUBPASS_RESOLVE_PERFORMANCE_QUERY_EXT = 1000376001, + VK_STRUCTURE_TYPE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_INFO_EXT = 1000376002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_2_FEATURES_EXT = 1000377000, + VK_STRUCTURE_TYPE_SCREEN_SURFACE_CREATE_INFO_QNX = 1000378000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT = 1000381000, + VK_STRUCTURE_TYPE_PIPELINE_COLOR_WRITE_CREATE_INFO_EXT = 1000381001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIMITIVES_GENERATED_QUERY_FEATURES_EXT = 1000382000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_MAINTENANCE_1_FEATURES_KHR = 1000386000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_VIEW_MIN_LOD_FEATURES_EXT = 1000391000, + VK_STRUCTURE_TYPE_IMAGE_VIEW_MIN_LOD_CREATE_INFO_EXT = 1000391001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_FEATURES_EXT = 1000392000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTI_DRAW_PROPERTIES_EXT = 1000392001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_2D_VIEW_OF_3D_FEATURES_EXT = 1000393000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TILE_IMAGE_FEATURES_EXT = 1000395000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TILE_IMAGE_PROPERTIES_EXT = 1000395001, + VK_STRUCTURE_TYPE_MICROMAP_BUILD_INFO_EXT = 1000396000, + VK_STRUCTURE_TYPE_MICROMAP_VERSION_INFO_EXT = 1000396001, + VK_STRUCTURE_TYPE_COPY_MICROMAP_INFO_EXT = 1000396002, + VK_STRUCTURE_TYPE_COPY_MICROMAP_TO_MEMORY_INFO_EXT = 1000396003, + VK_STRUCTURE_TYPE_COPY_MEMORY_TO_MICROMAP_INFO_EXT = 1000396004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_FEATURES_EXT = 1000396005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPACITY_MICROMAP_PROPERTIES_EXT = 1000396006, + VK_STRUCTURE_TYPE_MICROMAP_CREATE_INFO_EXT = 1000396007, + VK_STRUCTURE_TYPE_MICROMAP_BUILD_SIZES_INFO_EXT = 1000396008, + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_OPACITY_MICROMAP_EXT = 1000396009, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_FEATURES_NV = 1000397000, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DISPLACEMENT_MICROMAP_PROPERTIES_NV = 1000397001, +#endif +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_TRIANGLES_DISPLACEMENT_MICROMAP_NV = 1000397002, +#endif + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_FEATURES_HUAWEI = 1000404000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_PROPERTIES_HUAWEI = 1000404001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CLUSTER_CULLING_SHADER_VRS_FEATURES_HUAWEI = 1000404002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BORDER_COLOR_SWIZZLE_FEATURES_EXT = 1000411000, + VK_STRUCTURE_TYPE_SAMPLER_BORDER_COLOR_COMPONENT_MAPPING_CREATE_INFO_EXT = 1000411001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PAGEABLE_DEVICE_LOCAL_MEMORY_FEATURES_EXT = 1000412000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_PROPERTIES_ARM = 1000415000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_ROTATE_FEATURES_KHR = 1000416000, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_SHADER_CORE_CONTROL_CREATE_INFO_ARM = 1000417000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCHEDULING_CONTROLS_FEATURES_ARM = 1000417001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCHEDULING_CONTROLS_PROPERTIES_ARM = 1000417002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_SLICED_VIEW_OF_3D_FEATURES_EXT = 1000418000, + VK_STRUCTURE_TYPE_IMAGE_VIEW_SLICED_CREATE_INFO_EXT = 1000418001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_SET_HOST_MAPPING_FEATURES_VALVE = 1000420000, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_BINDING_REFERENCE_VALVE = 1000420001, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_HOST_MAPPING_INFO_VALVE = 1000420002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_CLAMP_ZERO_ONE_FEATURES_EXT = 1000421000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NON_SEAMLESS_CUBE_MAP_FEATURES_EXT = 1000422000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RENDER_PASS_STRIPED_FEATURES_ARM = 1000424000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RENDER_PASS_STRIPED_PROPERTIES_ARM = 1000424001, + VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_BEGIN_INFO_ARM = 1000424002, + VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_INFO_ARM = 1000424003, + VK_STRUCTURE_TYPE_RENDER_PASS_STRIPE_SUBMIT_INFO_ARM = 1000424004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_FEATURES_QCOM = 1000425000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_DENSITY_MAP_OFFSET_PROPERTIES_QCOM = 1000425001, + VK_STRUCTURE_TYPE_SUBPASS_FRAGMENT_DENSITY_MAP_OFFSET_END_INFO_QCOM = 1000425002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_FEATURES_NV = 1000426000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COPY_MEMORY_INDIRECT_PROPERTIES_NV = 1000426001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_FEATURES_NV = 1000427000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_DECOMPRESSION_PROPERTIES_NV = 1000427001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEVICE_GENERATED_COMMANDS_COMPUTE_FEATURES_NV = 1000428000, + VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_INDIRECT_BUFFER_INFO_NV = 1000428001, + VK_STRUCTURE_TYPE_PIPELINE_INDIRECT_DEVICE_ADDRESS_INFO_NV = 1000428002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINEAR_COLOR_ATTACHMENT_FEATURES_NV = 1000430000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MAXIMAL_RECONVERGENCE_FEATURES_KHR = 1000434000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_FEATURES_EXT = 1000437000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_FEATURES_QCOM = 1000440000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_PROPERTIES_QCOM = 1000440001, + VK_STRUCTURE_TYPE_IMAGE_VIEW_SAMPLE_WEIGHT_CREATE_INFO_QCOM = 1000440002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NESTED_COMMAND_BUFFER_FEATURES_EXT = 1000451000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_NESTED_COMMAND_BUFFER_PROPERTIES_EXT = 1000451001, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_EXT = 1000453000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_FEATURES_EXT = 1000455000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_DYNAMIC_STATE_3_PROPERTIES_EXT = 1000455001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBPASS_MERGE_FEEDBACK_FEATURES_EXT = 1000458000, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_CONTROL_EXT = 1000458001, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATION_FEEDBACK_CREATE_INFO_EXT = 1000458002, + VK_STRUCTURE_TYPE_RENDER_PASS_SUBPASS_FEEDBACK_CREATE_INFO_EXT = 1000458003, + VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_INFO_LUNARG = 1000459000, + VK_STRUCTURE_TYPE_DIRECT_DRIVER_LOADING_LIST_LUNARG = 1000459001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_FEATURES_EXT = 1000462000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_MODULE_IDENTIFIER_PROPERTIES_EXT = 1000462001, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_MODULE_IDENTIFIER_CREATE_INFO_EXT = 1000462002, + VK_STRUCTURE_TYPE_SHADER_MODULE_IDENTIFIER_EXT = 1000462003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT = 1000342000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_FEATURES_NV = 1000464000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_OPTICAL_FLOW_PROPERTIES_NV = 1000464001, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_INFO_NV = 1000464002, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_IMAGE_FORMAT_PROPERTIES_NV = 1000464003, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_INFO_NV = 1000464004, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_EXECUTE_INFO_NV = 1000464005, + VK_STRUCTURE_TYPE_OPTICAL_FLOW_SESSION_CREATE_PRIVATE_DATA_INFO_NV = 1000464010, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LEGACY_DITHERING_FEATURES_EXT = 1000465000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_PROTECTED_ACCESS_FEATURES_EXT = 1000466000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FORMAT_RESOLVE_FEATURES_ANDROID = 1000468000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FORMAT_RESOLVE_PROPERTIES_ANDROID = 1000468001, + VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_RESOLVE_PROPERTIES_ANDROID = 1000468002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_FEATURES_KHR = 1000470000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_5_PROPERTIES_KHR = 1000470001, + VK_STRUCTURE_TYPE_RENDERING_AREA_INFO_KHR = 1000470003, + VK_STRUCTURE_TYPE_DEVICE_IMAGE_SUBRESOURCE_INFO_KHR = 1000470004, + VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_KHR = 1000338002, + VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_KHR = 1000338003, + VK_STRUCTURE_TYPE_PIPELINE_CREATE_FLAGS_2_CREATE_INFO_KHR = 1000470005, + VK_STRUCTURE_TYPE_BUFFER_USAGE_FLAGS_2_CREATE_INFO_KHR = 1000470006, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_POSITION_FETCH_FEATURES_KHR = 1000481000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_FEATURES_EXT = 1000482000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_OBJECT_PROPERTIES_EXT = 1000482001, + VK_STRUCTURE_TYPE_SHADER_CREATE_INFO_EXT = 1000482002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TILE_PROPERTIES_FEATURES_QCOM = 1000484000, + VK_STRUCTURE_TYPE_TILE_PROPERTIES_QCOM = 1000484001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_AMIGO_PROFILING_FEATURES_SEC = 1000485000, + VK_STRUCTURE_TYPE_AMIGO_PROFILING_SUBMIT_INFO_SEC = 1000485001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_VIEWPORTS_FEATURES_QCOM = 1000488000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_FEATURES_NV = 1000490000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_INVOCATION_REORDER_PROPERTIES_NV = 1000490001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_SPARSE_ADDRESS_SPACE_FEATURES_NV = 1000492000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTENDED_SPARSE_ADDRESS_SPACE_PROPERTIES_NV = 1000492001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT = 1000351000, + VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT = 1000351002, + VK_STRUCTURE_TYPE_LAYER_SETTINGS_CREATE_INFO_EXT = 1000496000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_FEATURES_ARM = 1000497000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_CORE_BUILTINS_PROPERTIES_ARM = 1000497001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_LIBRARY_GROUP_HANDLES_FEATURES_EXT = 1000498000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_FEATURES_EXT = 1000499000, + VK_STRUCTURE_TYPE_LATENCY_SLEEP_MODE_INFO_NV = 1000505000, + VK_STRUCTURE_TYPE_LATENCY_SLEEP_INFO_NV = 1000505001, + VK_STRUCTURE_TYPE_SET_LATENCY_MARKER_INFO_NV = 1000505002, + VK_STRUCTURE_TYPE_GET_LATENCY_MARKER_INFO_NV = 1000505003, + VK_STRUCTURE_TYPE_LATENCY_TIMINGS_FRAME_REPORT_NV = 1000505004, + VK_STRUCTURE_TYPE_LATENCY_SUBMISSION_PRESENT_ID_NV = 1000505005, + VK_STRUCTURE_TYPE_OUT_OF_BAND_QUEUE_TYPE_INFO_NV = 1000505006, + VK_STRUCTURE_TYPE_SWAPCHAIN_LATENCY_CREATE_INFO_NV = 1000505007, + VK_STRUCTURE_TYPE_LATENCY_SURFACE_CAPABILITIES_NV = 1000505008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_FEATURES_KHR = 1000506000, + VK_STRUCTURE_TYPE_COOPERATIVE_MATRIX_PROPERTIES_KHR = 1000506001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COOPERATIVE_MATRIX_PROPERTIES_KHR = 1000506002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PER_VIEW_RENDER_AREAS_FEATURES_QCOM = 1000510000, + VK_STRUCTURE_TYPE_MULTIVIEW_PER_VIEW_RENDER_AREAS_RENDER_PASS_BEGIN_INFO_QCOM = 1000510001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR = 1000512000, + VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_KHR = 1000512001, + VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR = 1000512003, + VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR = 1000512004, + VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_KHR = 1000512005, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VIDEO_MAINTENANCE_1_FEATURES_KHR = 1000515000, + VK_STRUCTURE_TYPE_VIDEO_INLINE_QUERY_INFO_KHR = 1000515001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PER_STAGE_DESCRIPTOR_SET_FEATURES_NV = 1000516000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_2_FEATURES_QCOM = 1000518000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_PROCESSING_2_PROPERTIES_QCOM = 1000518001, + VK_STRUCTURE_TYPE_SAMPLER_BLOCK_MATCH_WINDOW_CREATE_INFO_QCOM = 1000518002, + VK_STRUCTURE_TYPE_SAMPLER_CUBIC_WEIGHTS_CREATE_INFO_QCOM = 1000519000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_WEIGHTS_FEATURES_QCOM = 1000519001, + VK_STRUCTURE_TYPE_BLIT_IMAGE_CUBIC_WEIGHTS_INFO_QCOM = 1000519002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_YCBCR_DEGAMMA_FEATURES_QCOM = 1000520000, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_YCBCR_DEGAMMA_CREATE_INFO_QCOM = 1000520001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_CUBIC_CLAMP_FEATURES_QCOM = 1000521000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_FEATURES_EXT = 1000524000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_PROPERTIES_KHR = 1000525000, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_KHR = 1000190001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_KHR = 1000190002, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT_CONTROLS_2_FEATURES_KHR = 1000528000, + VK_STRUCTURE_TYPE_SCREEN_BUFFER_PROPERTIES_QNX = 1000529000, + VK_STRUCTURE_TYPE_SCREEN_BUFFER_FORMAT_PROPERTIES_QNX = 1000529001, + VK_STRUCTURE_TYPE_IMPORT_SCREEN_BUFFER_INFO_QNX = 1000529002, + VK_STRUCTURE_TYPE_EXTERNAL_FORMAT_QNX = 1000529003, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_MEMORY_SCREEN_BUFFER_FEATURES_QNX = 1000529004, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LAYERED_DRIVER_PROPERTIES_MSFT = 1000530000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_KHR = 1000265000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_KHR = 1000259000, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_KHR = 1000259001, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_KHR = 1000259002, + VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_KHR = 1000184000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_EXPECT_ASSUME_FEATURES_KHR = 1000544000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_FEATURES_KHR = 1000545000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_6_PROPERTIES_KHR = 1000545001, + VK_STRUCTURE_TYPE_BIND_MEMORY_STATUS_KHR = 1000545002, + VK_STRUCTURE_TYPE_BIND_DESCRIPTOR_SETS_INFO_KHR = 1000545003, + VK_STRUCTURE_TYPE_PUSH_CONSTANTS_INFO_KHR = 1000545004, + VK_STRUCTURE_TYPE_PUSH_DESCRIPTOR_SET_INFO_KHR = 1000545005, + VK_STRUCTURE_TYPE_PUSH_DESCRIPTOR_SET_WITH_TEMPLATE_INFO_KHR = 1000545006, + VK_STRUCTURE_TYPE_SET_DESCRIPTOR_BUFFER_OFFSETS_INFO_EXT = 1000545007, + VK_STRUCTURE_TYPE_BIND_DESCRIPTOR_BUFFER_EMBEDDED_SAMPLERS_INFO_EXT = 1000545008, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_POOL_OVERALLOCATION_FEATURES_NV = 1000546000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAW_ACCESS_CHAINS_FEATURES_NV = 1000555000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_FLOAT16_VECTOR_FEATURES_NV = 1000563000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RAY_TRACING_VALIDATION_FEATURES_NV = 1000568000, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETER_FEATURES = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES, + VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT, + VK_STRUCTURE_TYPE_RENDERING_INFO_KHR = VK_STRUCTURE_TYPE_RENDERING_INFO, + VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR = VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO, + VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_PIPELINE_RENDERING_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DYNAMIC_RENDERING_FEATURES, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO_KHR = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_RENDERING_INFO, + VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_NV = VK_STRUCTURE_TYPE_ATTACHMENT_SAMPLE_COUNT_INFO_AMD, + VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, + VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_IMAGE_FORMAT_PROPERTIES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_QUEUE_FAMILY_PROPERTIES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MEMORY_PROPERTIES_2, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2_KHR = VK_STRUCTURE_TYPE_SPARSE_IMAGE_FORMAT_PROPERTIES_2, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SPARSE_IMAGE_FORMAT_INFO_2, + VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO_KHR = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_FLAGS_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_RENDER_PASS_BEGIN_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_COMMAND_BUFFER_BEGIN_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_SUBMIT_INFO, + VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_BIND_SPARSE_INFO, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO_KHR = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_DEVICE_GROUP_INFO, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO_KHR = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_DEVICE_GROUP_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXTURE_COMPRESSION_ASTC_HDR_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GROUP_PROPERTIES, + VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_GROUP_DEVICE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_IMAGE_FORMAT_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_IMAGE_FORMAT_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_BUFFER_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_BUFFER_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_BUFFER_CREATE_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO, + VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO_KHR = VK_STRUCTURE_TYPE_EXPORT_MEMORY_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_SEMAPHORE_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_SEMAPHORE_PROPERTIES, + VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXPORT_SEMAPHORE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT16_INT8_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES, + VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_CREATE_INFO, + VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES2_EXT = VK_STRUCTURE_TYPE_SURFACE_CAPABILITIES_2_EXT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENTS_CREATE_INFO, + VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO_KHR = VK_STRUCTURE_TYPE_FRAMEBUFFER_ATTACHMENT_IMAGE_INFO, + VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_ATTACHMENT_BEGIN_INFO, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_2, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_2, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2_KHR = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_2, + VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2_KHR = VK_STRUCTURE_TYPE_SUBPASS_DEPENDENCY_2, + VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO_2, + VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO_KHR = VK_STRUCTURE_TYPE_SUBPASS_BEGIN_INFO, + VK_STRUCTURE_TYPE_SUBPASS_END_INFO_KHR = VK_STRUCTURE_TYPE_SUBPASS_END_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_EXTERNAL_FENCE_INFO, + VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_EXTERNAL_FENCE_PROPERTIES, + VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_EXPORT_FENCE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_POINT_CLIPPING_PROPERTIES, + VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_RENDER_PASS_INPUT_ATTACHMENT_ASPECT_CREATE_INFO, + VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO, + VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTER_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES_KHR, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS, + VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO_KHR = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_FILTER_MINMAX_PROPERTIES, + VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_SAMPLER_REDUCTION_MODE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INLINE_UNIFORM_BLOCK_PROPERTIES, + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK_EXT = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_INLINE_UNIFORM_BLOCK, + VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_INLINE_UNIFORM_BLOCK_CREATE_INFO, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2_KHR = VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2_KHR = VK_STRUCTURE_TYPE_IMAGE_MEMORY_REQUIREMENTS_INFO_2, + VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2_KHR = VK_STRUCTURE_TYPE_IMAGE_SPARSE_MEMORY_REQUIREMENTS_INFO_2, + VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2_KHR = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2, + VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2_KHR = VK_STRUCTURE_TYPE_SPARSE_IMAGE_MEMORY_REQUIREMENTS_2, + VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_CREATE_INFO, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO_KHR = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO, + VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO_KHR = VK_STRUCTURE_TYPE_BIND_IMAGE_PLANE_MEMORY_INFO, + VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO_KHR = VK_STRUCTURE_TYPE_IMAGE_PLANE_MEMORY_REQUIREMENTS_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES, + VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES_KHR = VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES, + VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO_KHR = VK_STRUCTURE_TYPE_BIND_BUFFER_MEMORY_INFO, + VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO_KHR = VK_STRUCTURE_TYPE_BIND_IMAGE_MEMORY_INFO, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_PROPERTIES, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO_EXT = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT_EXT = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_VARIABLE_DESCRIPTOR_COUNT_LAYOUT_SUPPORT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES, + VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT_KHR = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_SUPPORT, + VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES, + VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_EXT = VK_STRUCTURE_TYPE_CALIBRATED_TIMESTAMP_INFO_KHR, + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VERTEX_ATTRIBUTE_DIVISOR_FEATURES_KHR, + VK_STRUCTURE_TYPE_PIPELINE_CREATION_FEEDBACK_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_CREATION_FEEDBACK_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DEPTH_STENCIL_RESOLVE_PROPERTIES, + VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE_KHR = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION_DEPTH_STENCIL_RESOLVE, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_NV = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FRAGMENT_SHADER_BARYCENTRIC_FEATURES_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_PROPERTIES, + VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO, + VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO_KHR = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO, + VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_WAIT_INFO, + VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_SIGNAL_INFO, + VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO_INTEL = VK_STRUCTURE_TYPE_QUERY_POOL_PERFORMANCE_QUERY_CREATE_INFO_INTEL, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_TERMINATE_INVOCATION_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_PROPERTIES, + VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_SIZE_CONTROL_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES, + VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_REFERENCE_STENCIL_LAYOUT, + VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT_KHR = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION_STENCIL_LAYOUT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_ADDRESS_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_EXT, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_EXT = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TOOL_PROPERTIES, + VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_IMAGE_STENCIL_USAGE_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES, + VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO_KHR = VK_STRUCTURE_TYPE_BUFFER_DEVICE_ADDRESS_INFO, + VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO_KHR = VK_STRUCTURE_TYPE_BUFFER_OPAQUE_CAPTURE_ADDRESS_CREATE_INFO, + VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO_KHR = VK_STRUCTURE_TYPE_MEMORY_OPAQUE_CAPTURE_ADDRESS_ALLOCATE_INFO, + VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO_KHR = VK_STRUCTURE_TYPE_DEVICE_MEMORY_OPAQUE_CAPTURE_ADDRESS_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_KHR, + VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_INDEX_TYPE_UINT8_FEATURES_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DEMOTE_TO_HELPER_INVOCATION_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_INTEGER_DOT_PRODUCT_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TEXEL_BUFFER_ALIGNMENT_PROPERTIES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRIVATE_DATA_FEATURES, + VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_DEVICE_PRIVATE_DATA_CREATE_INFO, + VK_STRUCTURE_TYPE_PRIVATE_DATA_SLOT_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PRIVATE_DATA_SLOT_CREATE_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PIPELINE_CREATION_CACHE_CONTROL_FEATURES, + VK_STRUCTURE_TYPE_MEMORY_BARRIER_2_KHR = VK_STRUCTURE_TYPE_MEMORY_BARRIER_2, + VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2_KHR = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER_2, + VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2_KHR = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER_2, + VK_STRUCTURE_TYPE_DEPENDENCY_INFO_KHR = VK_STRUCTURE_TYPE_DEPENDENCY_INFO, + VK_STRUCTURE_TYPE_SUBMIT_INFO_2_KHR = VK_STRUCTURE_TYPE_SUBMIT_INFO_2, + VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO_KHR = VK_STRUCTURE_TYPE_SEMAPHORE_SUBMIT_INFO, + VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO_KHR = VK_STRUCTURE_TYPE_COMMAND_BUFFER_SUBMIT_INFO, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SYNCHRONIZATION_2_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ZERO_INITIALIZE_WORKGROUP_MEMORY_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_ROBUSTNESS_FEATURES, + VK_STRUCTURE_TYPE_COPY_BUFFER_INFO_2_KHR = VK_STRUCTURE_TYPE_COPY_BUFFER_INFO_2, + VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2_KHR = VK_STRUCTURE_TYPE_COPY_IMAGE_INFO_2, + VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2_KHR = VK_STRUCTURE_TYPE_COPY_BUFFER_TO_IMAGE_INFO_2, + VK_STRUCTURE_TYPE_COPY_IMAGE_TO_BUFFER_INFO_2_KHR = VK_STRUCTURE_TYPE_COPY_IMAGE_TO_BUFFER_INFO_2, + VK_STRUCTURE_TYPE_BLIT_IMAGE_INFO_2_KHR = VK_STRUCTURE_TYPE_BLIT_IMAGE_INFO_2, + VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2_KHR = VK_STRUCTURE_TYPE_RESOLVE_IMAGE_INFO_2, + VK_STRUCTURE_TYPE_BUFFER_COPY_2_KHR = VK_STRUCTURE_TYPE_BUFFER_COPY_2, + VK_STRUCTURE_TYPE_IMAGE_COPY_2_KHR = VK_STRUCTURE_TYPE_IMAGE_COPY_2, + VK_STRUCTURE_TYPE_IMAGE_BLIT_2_KHR = VK_STRUCTURE_TYPE_IMAGE_BLIT_2, + VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2_KHR = VK_STRUCTURE_TYPE_BUFFER_IMAGE_COPY_2, + VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2_KHR = VK_STRUCTURE_TYPE_IMAGE_RESOLVE_2, + VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_EXT = VK_STRUCTURE_TYPE_SUBRESOURCE_LAYOUT_2_KHR, + VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_EXT = VK_STRUCTURE_TYPE_IMAGE_SUBRESOURCE_2_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_ARM = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_FEATURES_EXT, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_VALVE = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MUTABLE_DESCRIPTOR_TYPE_FEATURES_EXT, + VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_VALVE = VK_STRUCTURE_TYPE_MUTABLE_DESCRIPTOR_TYPE_CREATE_INFO_EXT, + VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3_KHR = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3, + VK_STRUCTURE_TYPE_PIPELINE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_INFO_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_EXT = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_GLOBAL_PRIORITY_QUERY_FEATURES_KHR, + VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_EXT = VK_STRUCTURE_TYPE_QUEUE_FAMILY_GLOBAL_PRIORITY_PROPERTIES_KHR, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_FEATURES, + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES_KHR = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_4_PROPERTIES, + VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_DEVICE_BUFFER_MEMORY_REQUIREMENTS, + VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS_KHR = VK_STRUCTURE_TYPE_DEVICE_IMAGE_MEMORY_REQUIREMENTS, + VK_STRUCTURE_TYPE_SHADER_REQUIRED_SUBGROUP_SIZE_CREATE_INFO_EXT = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_REQUIRED_SUBGROUP_SIZE_CREATE_INFO, + VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkStructureType; + +typedef enum VkPipelineCacheHeaderVersion { + VK_PIPELINE_CACHE_HEADER_VERSION_ONE = 1, + VK_PIPELINE_CACHE_HEADER_VERSION_MAX_ENUM = 0x7FFFFFFF +} VkPipelineCacheHeaderVersion; + +typedef enum VkImageLayout { + VK_IMAGE_LAYOUT_UNDEFINED = 0, + VK_IMAGE_LAYOUT_GENERAL = 1, + VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL = 2, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL = 3, + VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL = 4, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL = 5, + VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL = 6, + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL = 7, + VK_IMAGE_LAYOUT_PREINITIALIZED = 8, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL = 1000117000, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL = 1000117001, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL = 1000241000, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL = 1000241001, + VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL = 1000241002, + VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL = 1000241003, + VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL = 1000314000, + VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL = 1000314001, + VK_IMAGE_LAYOUT_PRESENT_SRC_KHR = 1000001002, + VK_IMAGE_LAYOUT_VIDEO_DECODE_DST_KHR = 1000024000, + VK_IMAGE_LAYOUT_VIDEO_DECODE_SRC_KHR = 1000024001, + VK_IMAGE_LAYOUT_VIDEO_DECODE_DPB_KHR = 1000024002, + VK_IMAGE_LAYOUT_SHARED_PRESENT_KHR = 1000111000, + VK_IMAGE_LAYOUT_FRAGMENT_DENSITY_MAP_OPTIMAL_EXT = 1000218000, + VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR = 1000164003, + VK_IMAGE_LAYOUT_RENDERING_LOCAL_READ_KHR = 1000232000, + VK_IMAGE_LAYOUT_VIDEO_ENCODE_DST_KHR = 1000299000, + VK_IMAGE_LAYOUT_VIDEO_ENCODE_SRC_KHR = 1000299001, + VK_IMAGE_LAYOUT_VIDEO_ENCODE_DPB_KHR = 1000299002, + VK_IMAGE_LAYOUT_ATTACHMENT_FEEDBACK_LOOP_OPTIMAL_EXT = 1000339000, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_STENCIL_ATTACHMENT_OPTIMAL, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_STENCIL_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_SHADING_RATE_OPTIMAL_NV = VK_IMAGE_LAYOUT_FRAGMENT_SHADING_RATE_ATTACHMENT_OPTIMAL_KHR, + VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL, + VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_DEPTH_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_STENCIL_ATTACHMENT_OPTIMAL, + VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_STENCIL_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL_KHR = VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL, + VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL_KHR = VK_IMAGE_LAYOUT_ATTACHMENT_OPTIMAL, + VK_IMAGE_LAYOUT_MAX_ENUM = 0x7FFFFFFF +} VkImageLayout; + +typedef enum VkObjectType { + VK_OBJECT_TYPE_UNKNOWN = 0, + VK_OBJECT_TYPE_INSTANCE = 1, + VK_OBJECT_TYPE_PHYSICAL_DEVICE = 2, + VK_OBJECT_TYPE_DEVICE = 3, + VK_OBJECT_TYPE_QUEUE = 4, + VK_OBJECT_TYPE_SEMAPHORE = 5, + VK_OBJECT_TYPE_COMMAND_BUFFER = 6, + VK_OBJECT_TYPE_FENCE = 7, + VK_OBJECT_TYPE_DEVICE_MEMORY = 8, + VK_OBJECT_TYPE_BUFFER = 9, + VK_OBJECT_TYPE_IMAGE = 10, + VK_OBJECT_TYPE_EVENT = 11, + VK_OBJECT_TYPE_QUERY_POOL = 12, + VK_OBJECT_TYPE_BUFFER_VIEW = 13, + VK_OBJECT_TYPE_IMAGE_VIEW = 14, + VK_OBJECT_TYPE_SHADER_MODULE = 15, + VK_OBJECT_TYPE_PIPELINE_CACHE = 16, + VK_OBJECT_TYPE_PIPELINE_LAYOUT = 17, + VK_OBJECT_TYPE_RENDER_PASS = 18, + VK_OBJECT_TYPE_PIPELINE = 19, + VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT = 20, + VK_OBJECT_TYPE_SAMPLER = 21, + VK_OBJECT_TYPE_DESCRIPTOR_POOL = 22, + VK_OBJECT_TYPE_DESCRIPTOR_SET = 23, + VK_OBJECT_TYPE_FRAMEBUFFER = 24, + VK_OBJECT_TYPE_COMMAND_POOL = 25, + VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION = 1000156000, + VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE = 1000085000, + VK_OBJECT_TYPE_PRIVATE_DATA_SLOT = 1000295000, + VK_OBJECT_TYPE_SURFACE_KHR = 1000000000, + VK_OBJECT_TYPE_SWAPCHAIN_KHR = 1000001000, + VK_OBJECT_TYPE_DISPLAY_KHR = 1000002000, + VK_OBJECT_TYPE_DISPLAY_MODE_KHR = 1000002001, + VK_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT = 1000011000, + VK_OBJECT_TYPE_VIDEO_SESSION_KHR = 1000023000, + VK_OBJECT_TYPE_VIDEO_SESSION_PARAMETERS_KHR = 1000023001, + VK_OBJECT_TYPE_CU_MODULE_NVX = 1000029000, + VK_OBJECT_TYPE_CU_FUNCTION_NVX = 1000029001, + VK_OBJECT_TYPE_DEBUG_UTILS_MESSENGER_EXT = 1000128000, + VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR = 1000150000, + VK_OBJECT_TYPE_VALIDATION_CACHE_EXT = 1000160000, + VK_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV = 1000165000, + VK_OBJECT_TYPE_PERFORMANCE_CONFIGURATION_INTEL = 1000210000, + VK_OBJECT_TYPE_DEFERRED_OPERATION_KHR = 1000268000, + VK_OBJECT_TYPE_INDIRECT_COMMANDS_LAYOUT_NV = 1000277000, + VK_OBJECT_TYPE_CUDA_MODULE_NV = 1000307000, + VK_OBJECT_TYPE_CUDA_FUNCTION_NV = 1000307001, + VK_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA = 1000366000, + VK_OBJECT_TYPE_MICROMAP_EXT = 1000396000, + VK_OBJECT_TYPE_OPTICAL_FLOW_SESSION_NV = 1000464000, + VK_OBJECT_TYPE_SHADER_EXT = 1000482000, + VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR = VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE, + VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR = VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION, + VK_OBJECT_TYPE_PRIVATE_DATA_SLOT_EXT = VK_OBJECT_TYPE_PRIVATE_DATA_SLOT, + VK_OBJECT_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkObjectType; + +typedef enum VkVendorId { + VK_VENDOR_ID_VIV = 0x10001, + VK_VENDOR_ID_VSI = 0x10002, + VK_VENDOR_ID_KAZAN = 0x10003, + VK_VENDOR_ID_CODEPLAY = 0x10004, + VK_VENDOR_ID_MESA = 0x10005, + VK_VENDOR_ID_POCL = 0x10006, + VK_VENDOR_ID_MOBILEYE = 0x10007, + VK_VENDOR_ID_MAX_ENUM = 0x7FFFFFFF +} VkVendorId; + +typedef enum VkSystemAllocationScope { + VK_SYSTEM_ALLOCATION_SCOPE_COMMAND = 0, + VK_SYSTEM_ALLOCATION_SCOPE_OBJECT = 1, + VK_SYSTEM_ALLOCATION_SCOPE_CACHE = 2, + VK_SYSTEM_ALLOCATION_SCOPE_DEVICE = 3, + VK_SYSTEM_ALLOCATION_SCOPE_INSTANCE = 4, + VK_SYSTEM_ALLOCATION_SCOPE_MAX_ENUM = 0x7FFFFFFF +} VkSystemAllocationScope; + +typedef enum VkInternalAllocationType { + VK_INTERNAL_ALLOCATION_TYPE_EXECUTABLE = 0, + VK_INTERNAL_ALLOCATION_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkInternalAllocationType; + +typedef enum VkFormat { + VK_FORMAT_UNDEFINED = 0, + VK_FORMAT_R4G4_UNORM_PACK8 = 1, + VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2, + VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3, + VK_FORMAT_R5G6B5_UNORM_PACK16 = 4, + VK_FORMAT_B5G6R5_UNORM_PACK16 = 5, + VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6, + VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7, + VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8, + VK_FORMAT_R8_UNORM = 9, + VK_FORMAT_R8_SNORM = 10, + VK_FORMAT_R8_USCALED = 11, + VK_FORMAT_R8_SSCALED = 12, + VK_FORMAT_R8_UINT = 13, + VK_FORMAT_R8_SINT = 14, + VK_FORMAT_R8_SRGB = 15, + VK_FORMAT_R8G8_UNORM = 16, + VK_FORMAT_R8G8_SNORM = 17, + VK_FORMAT_R8G8_USCALED = 18, + VK_FORMAT_R8G8_SSCALED = 19, + VK_FORMAT_R8G8_UINT = 20, + VK_FORMAT_R8G8_SINT = 21, + VK_FORMAT_R8G8_SRGB = 22, + VK_FORMAT_R8G8B8_UNORM = 23, + VK_FORMAT_R8G8B8_SNORM = 24, + VK_FORMAT_R8G8B8_USCALED = 25, + VK_FORMAT_R8G8B8_SSCALED = 26, + VK_FORMAT_R8G8B8_UINT = 27, + VK_FORMAT_R8G8B8_SINT = 28, + VK_FORMAT_R8G8B8_SRGB = 29, + VK_FORMAT_B8G8R8_UNORM = 30, + VK_FORMAT_B8G8R8_SNORM = 31, + VK_FORMAT_B8G8R8_USCALED = 32, + VK_FORMAT_B8G8R8_SSCALED = 33, + VK_FORMAT_B8G8R8_UINT = 34, + VK_FORMAT_B8G8R8_SINT = 35, + VK_FORMAT_B8G8R8_SRGB = 36, + VK_FORMAT_R8G8B8A8_UNORM = 37, + VK_FORMAT_R8G8B8A8_SNORM = 38, + VK_FORMAT_R8G8B8A8_USCALED = 39, + VK_FORMAT_R8G8B8A8_SSCALED = 40, + VK_FORMAT_R8G8B8A8_UINT = 41, + VK_FORMAT_R8G8B8A8_SINT = 42, + VK_FORMAT_R8G8B8A8_SRGB = 43, + VK_FORMAT_B8G8R8A8_UNORM = 44, + VK_FORMAT_B8G8R8A8_SNORM = 45, + VK_FORMAT_B8G8R8A8_USCALED = 46, + VK_FORMAT_B8G8R8A8_SSCALED = 47, + VK_FORMAT_B8G8R8A8_UINT = 48, + VK_FORMAT_B8G8R8A8_SINT = 49, + VK_FORMAT_B8G8R8A8_SRGB = 50, + VK_FORMAT_A8B8G8R8_UNORM_PACK32 = 51, + VK_FORMAT_A8B8G8R8_SNORM_PACK32 = 52, + VK_FORMAT_A8B8G8R8_USCALED_PACK32 = 53, + VK_FORMAT_A8B8G8R8_SSCALED_PACK32 = 54, + VK_FORMAT_A8B8G8R8_UINT_PACK32 = 55, + VK_FORMAT_A8B8G8R8_SINT_PACK32 = 56, + VK_FORMAT_A8B8G8R8_SRGB_PACK32 = 57, + VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58, + VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59, + VK_FORMAT_A2R10G10B10_USCALED_PACK32 = 60, + VK_FORMAT_A2R10G10B10_SSCALED_PACK32 = 61, + VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62, + VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63, + VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64, + VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65, + VK_FORMAT_A2B10G10R10_USCALED_PACK32 = 66, + VK_FORMAT_A2B10G10R10_SSCALED_PACK32 = 67, + VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68, + VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69, + VK_FORMAT_R16_UNORM = 70, + VK_FORMAT_R16_SNORM = 71, + VK_FORMAT_R16_USCALED = 72, + VK_FORMAT_R16_SSCALED = 73, + VK_FORMAT_R16_UINT = 74, + VK_FORMAT_R16_SINT = 75, + VK_FORMAT_R16_SFLOAT = 76, + VK_FORMAT_R16G16_UNORM = 77, + VK_FORMAT_R16G16_SNORM = 78, + VK_FORMAT_R16G16_USCALED = 79, + VK_FORMAT_R16G16_SSCALED = 80, + VK_FORMAT_R16G16_UINT = 81, + VK_FORMAT_R16G16_SINT = 82, + VK_FORMAT_R16G16_SFLOAT = 83, + VK_FORMAT_R16G16B16_UNORM = 84, + VK_FORMAT_R16G16B16_SNORM = 85, + VK_FORMAT_R16G16B16_USCALED = 86, + VK_FORMAT_R16G16B16_SSCALED = 87, + VK_FORMAT_R16G16B16_UINT = 88, + VK_FORMAT_R16G16B16_SINT = 89, + VK_FORMAT_R16G16B16_SFLOAT = 90, + VK_FORMAT_R16G16B16A16_UNORM = 91, + VK_FORMAT_R16G16B16A16_SNORM = 92, + VK_FORMAT_R16G16B16A16_USCALED = 93, + VK_FORMAT_R16G16B16A16_SSCALED = 94, + VK_FORMAT_R16G16B16A16_UINT = 95, + VK_FORMAT_R16G16B16A16_SINT = 96, + VK_FORMAT_R16G16B16A16_SFLOAT = 97, + VK_FORMAT_R32_UINT = 98, + VK_FORMAT_R32_SINT = 99, + VK_FORMAT_R32_SFLOAT = 100, + VK_FORMAT_R32G32_UINT = 101, + VK_FORMAT_R32G32_SINT = 102, + VK_FORMAT_R32G32_SFLOAT = 103, + VK_FORMAT_R32G32B32_UINT = 104, + VK_FORMAT_R32G32B32_SINT = 105, + VK_FORMAT_R32G32B32_SFLOAT = 106, + VK_FORMAT_R32G32B32A32_UINT = 107, + VK_FORMAT_R32G32B32A32_SINT = 108, + VK_FORMAT_R32G32B32A32_SFLOAT = 109, + VK_FORMAT_R64_UINT = 110, + VK_FORMAT_R64_SINT = 111, + VK_FORMAT_R64_SFLOAT = 112, + VK_FORMAT_R64G64_UINT = 113, + VK_FORMAT_R64G64_SINT = 114, + VK_FORMAT_R64G64_SFLOAT = 115, + VK_FORMAT_R64G64B64_UINT = 116, + VK_FORMAT_R64G64B64_SINT = 117, + VK_FORMAT_R64G64B64_SFLOAT = 118, + VK_FORMAT_R64G64B64A64_UINT = 119, + VK_FORMAT_R64G64B64A64_SINT = 120, + VK_FORMAT_R64G64B64A64_SFLOAT = 121, + VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122, + VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123, + VK_FORMAT_D16_UNORM = 124, + VK_FORMAT_X8_D24_UNORM_PACK32 = 125, + VK_FORMAT_D32_SFLOAT = 126, + VK_FORMAT_S8_UINT = 127, + VK_FORMAT_D16_UNORM_S8_UINT = 128, + VK_FORMAT_D24_UNORM_S8_UINT = 129, + VK_FORMAT_D32_SFLOAT_S8_UINT = 130, + VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131, + VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132, + VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133, + VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134, + VK_FORMAT_BC2_UNORM_BLOCK = 135, + VK_FORMAT_BC2_SRGB_BLOCK = 136, + VK_FORMAT_BC3_UNORM_BLOCK = 137, + VK_FORMAT_BC3_SRGB_BLOCK = 138, + VK_FORMAT_BC4_UNORM_BLOCK = 139, + VK_FORMAT_BC4_SNORM_BLOCK = 140, + VK_FORMAT_BC5_UNORM_BLOCK = 141, + VK_FORMAT_BC5_SNORM_BLOCK = 142, + VK_FORMAT_BC6H_UFLOAT_BLOCK = 143, + VK_FORMAT_BC6H_SFLOAT_BLOCK = 144, + VK_FORMAT_BC7_UNORM_BLOCK = 145, + VK_FORMAT_BC7_SRGB_BLOCK = 146, + VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147, + VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148, + VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149, + VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150, + VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151, + VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152, + VK_FORMAT_EAC_R11_UNORM_BLOCK = 153, + VK_FORMAT_EAC_R11_SNORM_BLOCK = 154, + VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155, + VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156, + VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157, + VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158, + VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159, + VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160, + VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161, + VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162, + VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163, + VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164, + VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165, + VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166, + VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167, + VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168, + VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169, + VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170, + VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171, + VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172, + VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173, + VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174, + VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175, + VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176, + VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177, + VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178, + VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179, + VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180, + VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181, + VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182, + VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183, + VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184, + VK_FORMAT_G8B8G8R8_422_UNORM = 1000156000, + VK_FORMAT_B8G8R8G8_422_UNORM = 1000156001, + VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM = 1000156002, + VK_FORMAT_G8_B8R8_2PLANE_420_UNORM = 1000156003, + VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM = 1000156004, + VK_FORMAT_G8_B8R8_2PLANE_422_UNORM = 1000156005, + VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM = 1000156006, + VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007, + VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008, + VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009, + VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010, + VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 = 1000156012, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 = 1000156013, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 = 1000156014, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 = 1000156015, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 = 1000156016, + VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017, + VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018, + VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019, + VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020, + VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 = 1000156022, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 = 1000156023, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 = 1000156024, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 = 1000156025, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 = 1000156026, + VK_FORMAT_G16B16G16R16_422_UNORM = 1000156027, + VK_FORMAT_B16G16R16G16_422_UNORM = 1000156028, + VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM = 1000156029, + VK_FORMAT_G16_B16R16_2PLANE_420_UNORM = 1000156030, + VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM = 1000156031, + VK_FORMAT_G16_B16R16_2PLANE_422_UNORM = 1000156032, + VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM = 1000156033, + VK_FORMAT_G8_B8R8_2PLANE_444_UNORM = 1000330000, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16 = 1000330001, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16 = 1000330002, + VK_FORMAT_G16_B16R16_2PLANE_444_UNORM = 1000330003, + VK_FORMAT_A4R4G4B4_UNORM_PACK16 = 1000340000, + VK_FORMAT_A4B4G4R4_UNORM_PACK16 = 1000340001, + VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK = 1000066000, + VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK = 1000066001, + VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK = 1000066002, + VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK = 1000066003, + VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK = 1000066004, + VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK = 1000066005, + VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK = 1000066006, + VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK = 1000066007, + VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK = 1000066008, + VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK = 1000066009, + VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK = 1000066010, + VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK = 1000066011, + VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK = 1000066012, + VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK = 1000066013, + VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000, + VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001, + VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002, + VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003, + VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004, + VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005, + VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006, + VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007, + VK_FORMAT_R16G16_SFIXED5_NV = 1000464000, + VK_FORMAT_A1B5G5R5_UNORM_PACK16_KHR = 1000470000, + VK_FORMAT_A8_UNORM_KHR = 1000470001, + VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK, + VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK, + VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK, + VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK, + VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK, + VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK, + VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK, + VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK, + VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK, + VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK, + VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK, + VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK, + VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK, + VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT = VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK, + VK_FORMAT_G8B8G8R8_422_UNORM_KHR = VK_FORMAT_G8B8G8R8_422_UNORM, + VK_FORMAT_B8G8R8G8_422_UNORM_KHR = VK_FORMAT_B8G8R8G8_422_UNORM, + VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM_KHR = VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, + VK_FORMAT_G8_B8R8_2PLANE_420_UNORM_KHR = VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, + VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM_KHR = VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, + VK_FORMAT_G8_B8R8_2PLANE_422_UNORM_KHR = VK_FORMAT_G8_B8R8_2PLANE_422_UNORM, + VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM_KHR = VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM, + VK_FORMAT_R10X6_UNORM_PACK16_KHR = VK_FORMAT_R10X6_UNORM_PACK16, + VK_FORMAT_R10X6G10X6_UNORM_2PACK16_KHR = VK_FORMAT_R10X6G10X6_UNORM_2PACK16, + VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16_KHR = VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16, + VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16_KHR = VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16, + VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16_KHR = VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16, + VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16_KHR = VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16, + VK_FORMAT_R12X4_UNORM_PACK16_KHR = VK_FORMAT_R12X4_UNORM_PACK16, + VK_FORMAT_R12X4G12X4_UNORM_2PACK16_KHR = VK_FORMAT_R12X4G12X4_UNORM_2PACK16, + VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16_KHR = VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16, + VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16_KHR = VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16, + VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16_KHR = VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16_KHR = VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16, + VK_FORMAT_G16B16G16R16_422_UNORM_KHR = VK_FORMAT_G16B16G16R16_422_UNORM, + VK_FORMAT_B16G16R16G16_422_UNORM_KHR = VK_FORMAT_B16G16R16G16_422_UNORM, + VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM_KHR = VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM, + VK_FORMAT_G16_B16R16_2PLANE_420_UNORM_KHR = VK_FORMAT_G16_B16R16_2PLANE_420_UNORM, + VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM_KHR = VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM, + VK_FORMAT_G16_B16R16_2PLANE_422_UNORM_KHR = VK_FORMAT_G16_B16R16_2PLANE_422_UNORM, + VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM_KHR = VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM, + VK_FORMAT_G8_B8R8_2PLANE_444_UNORM_EXT = VK_FORMAT_G8_B8R8_2PLANE_444_UNORM, + VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16_EXT = VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16, + VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16_EXT = VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16, + VK_FORMAT_G16_B16R16_2PLANE_444_UNORM_EXT = VK_FORMAT_G16_B16R16_2PLANE_444_UNORM, + VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT = VK_FORMAT_A4R4G4B4_UNORM_PACK16, + VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT = VK_FORMAT_A4B4G4R4_UNORM_PACK16, + VK_FORMAT_R16G16_S10_5_NV = VK_FORMAT_R16G16_SFIXED5_NV, + VK_FORMAT_MAX_ENUM = 0x7FFFFFFF +} VkFormat; + +typedef enum VkImageTiling { + VK_IMAGE_TILING_OPTIMAL = 0, + VK_IMAGE_TILING_LINEAR = 1, + VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT = 1000158000, + VK_IMAGE_TILING_MAX_ENUM = 0x7FFFFFFF +} VkImageTiling; + +typedef enum VkImageType { + VK_IMAGE_TYPE_1D = 0, + VK_IMAGE_TYPE_2D = 1, + VK_IMAGE_TYPE_3D = 2, + VK_IMAGE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkImageType; + +typedef enum VkPhysicalDeviceType { + VK_PHYSICAL_DEVICE_TYPE_OTHER = 0, + VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU = 1, + VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU = 2, + VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU = 3, + VK_PHYSICAL_DEVICE_TYPE_CPU = 4, + VK_PHYSICAL_DEVICE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkPhysicalDeviceType; + +typedef enum VkQueryType { + VK_QUERY_TYPE_OCCLUSION = 0, + VK_QUERY_TYPE_PIPELINE_STATISTICS = 1, + VK_QUERY_TYPE_TIMESTAMP = 2, + VK_QUERY_TYPE_RESULT_STATUS_ONLY_KHR = 1000023000, + VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT = 1000028004, + VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR = 1000116000, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR = 1000150000, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR = 1000150001, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV = 1000165000, + VK_QUERY_TYPE_PERFORMANCE_QUERY_INTEL = 1000210000, + VK_QUERY_TYPE_VIDEO_ENCODE_FEEDBACK_KHR = 1000299000, + VK_QUERY_TYPE_MESH_PRIMITIVES_GENERATED_EXT = 1000328000, + VK_QUERY_TYPE_PRIMITIVES_GENERATED_EXT = 1000382000, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_BOTTOM_LEVEL_POINTERS_KHR = 1000386000, + VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SIZE_KHR = 1000386001, + VK_QUERY_TYPE_MICROMAP_SERIALIZATION_SIZE_EXT = 1000396000, + VK_QUERY_TYPE_MICROMAP_COMPACTED_SIZE_EXT = 1000396001, + VK_QUERY_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkQueryType; + +typedef enum VkSharingMode { + VK_SHARING_MODE_EXCLUSIVE = 0, + VK_SHARING_MODE_CONCURRENT = 1, + VK_SHARING_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSharingMode; + +typedef enum VkComponentSwizzle { + VK_COMPONENT_SWIZZLE_IDENTITY = 0, + VK_COMPONENT_SWIZZLE_ZERO = 1, + VK_COMPONENT_SWIZZLE_ONE = 2, + VK_COMPONENT_SWIZZLE_R = 3, + VK_COMPONENT_SWIZZLE_G = 4, + VK_COMPONENT_SWIZZLE_B = 5, + VK_COMPONENT_SWIZZLE_A = 6, + VK_COMPONENT_SWIZZLE_MAX_ENUM = 0x7FFFFFFF +} VkComponentSwizzle; + +typedef enum VkImageViewType { + VK_IMAGE_VIEW_TYPE_1D = 0, + VK_IMAGE_VIEW_TYPE_2D = 1, + VK_IMAGE_VIEW_TYPE_3D = 2, + VK_IMAGE_VIEW_TYPE_CUBE = 3, + VK_IMAGE_VIEW_TYPE_1D_ARRAY = 4, + VK_IMAGE_VIEW_TYPE_2D_ARRAY = 5, + VK_IMAGE_VIEW_TYPE_CUBE_ARRAY = 6, + VK_IMAGE_VIEW_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkImageViewType; + +typedef enum VkBlendFactor { + VK_BLEND_FACTOR_ZERO = 0, + VK_BLEND_FACTOR_ONE = 1, + VK_BLEND_FACTOR_SRC_COLOR = 2, + VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR = 3, + VK_BLEND_FACTOR_DST_COLOR = 4, + VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR = 5, + VK_BLEND_FACTOR_SRC_ALPHA = 6, + VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA = 7, + VK_BLEND_FACTOR_DST_ALPHA = 8, + VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA = 9, + VK_BLEND_FACTOR_CONSTANT_COLOR = 10, + VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR = 11, + VK_BLEND_FACTOR_CONSTANT_ALPHA = 12, + VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA = 13, + VK_BLEND_FACTOR_SRC_ALPHA_SATURATE = 14, + VK_BLEND_FACTOR_SRC1_COLOR = 15, + VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR = 16, + VK_BLEND_FACTOR_SRC1_ALPHA = 17, + VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA = 18, + VK_BLEND_FACTOR_MAX_ENUM = 0x7FFFFFFF +} VkBlendFactor; + +typedef enum VkBlendOp { + VK_BLEND_OP_ADD = 0, + VK_BLEND_OP_SUBTRACT = 1, + VK_BLEND_OP_REVERSE_SUBTRACT = 2, + VK_BLEND_OP_MIN = 3, + VK_BLEND_OP_MAX = 4, + VK_BLEND_OP_ZERO_EXT = 1000148000, + VK_BLEND_OP_SRC_EXT = 1000148001, + VK_BLEND_OP_DST_EXT = 1000148002, + VK_BLEND_OP_SRC_OVER_EXT = 1000148003, + VK_BLEND_OP_DST_OVER_EXT = 1000148004, + VK_BLEND_OP_SRC_IN_EXT = 1000148005, + VK_BLEND_OP_DST_IN_EXT = 1000148006, + VK_BLEND_OP_SRC_OUT_EXT = 1000148007, + VK_BLEND_OP_DST_OUT_EXT = 1000148008, + VK_BLEND_OP_SRC_ATOP_EXT = 1000148009, + VK_BLEND_OP_DST_ATOP_EXT = 1000148010, + VK_BLEND_OP_XOR_EXT = 1000148011, + VK_BLEND_OP_MULTIPLY_EXT = 1000148012, + VK_BLEND_OP_SCREEN_EXT = 1000148013, + VK_BLEND_OP_OVERLAY_EXT = 1000148014, + VK_BLEND_OP_DARKEN_EXT = 1000148015, + VK_BLEND_OP_LIGHTEN_EXT = 1000148016, + VK_BLEND_OP_COLORDODGE_EXT = 1000148017, + VK_BLEND_OP_COLORBURN_EXT = 1000148018, + VK_BLEND_OP_HARDLIGHT_EXT = 1000148019, + VK_BLEND_OP_SOFTLIGHT_EXT = 1000148020, + VK_BLEND_OP_DIFFERENCE_EXT = 1000148021, + VK_BLEND_OP_EXCLUSION_EXT = 1000148022, + VK_BLEND_OP_INVERT_EXT = 1000148023, + VK_BLEND_OP_INVERT_RGB_EXT = 1000148024, + VK_BLEND_OP_LINEARDODGE_EXT = 1000148025, + VK_BLEND_OP_LINEARBURN_EXT = 1000148026, + VK_BLEND_OP_VIVIDLIGHT_EXT = 1000148027, + VK_BLEND_OP_LINEARLIGHT_EXT = 1000148028, + VK_BLEND_OP_PINLIGHT_EXT = 1000148029, + VK_BLEND_OP_HARDMIX_EXT = 1000148030, + VK_BLEND_OP_HSL_HUE_EXT = 1000148031, + VK_BLEND_OP_HSL_SATURATION_EXT = 1000148032, + VK_BLEND_OP_HSL_COLOR_EXT = 1000148033, + VK_BLEND_OP_HSL_LUMINOSITY_EXT = 1000148034, + VK_BLEND_OP_PLUS_EXT = 1000148035, + VK_BLEND_OP_PLUS_CLAMPED_EXT = 1000148036, + VK_BLEND_OP_PLUS_CLAMPED_ALPHA_EXT = 1000148037, + VK_BLEND_OP_PLUS_DARKER_EXT = 1000148038, + VK_BLEND_OP_MINUS_EXT = 1000148039, + VK_BLEND_OP_MINUS_CLAMPED_EXT = 1000148040, + VK_BLEND_OP_CONTRAST_EXT = 1000148041, + VK_BLEND_OP_INVERT_OVG_EXT = 1000148042, + VK_BLEND_OP_RED_EXT = 1000148043, + VK_BLEND_OP_GREEN_EXT = 1000148044, + VK_BLEND_OP_BLUE_EXT = 1000148045, + VK_BLEND_OP_MAX_ENUM = 0x7FFFFFFF +} VkBlendOp; + +typedef enum VkCompareOp { + VK_COMPARE_OP_NEVER = 0, + VK_COMPARE_OP_LESS = 1, + VK_COMPARE_OP_EQUAL = 2, + VK_COMPARE_OP_LESS_OR_EQUAL = 3, + VK_COMPARE_OP_GREATER = 4, + VK_COMPARE_OP_NOT_EQUAL = 5, + VK_COMPARE_OP_GREATER_OR_EQUAL = 6, + VK_COMPARE_OP_ALWAYS = 7, + VK_COMPARE_OP_MAX_ENUM = 0x7FFFFFFF +} VkCompareOp; + +typedef enum VkDynamicState { + VK_DYNAMIC_STATE_VIEWPORT = 0, + VK_DYNAMIC_STATE_SCISSOR = 1, + VK_DYNAMIC_STATE_LINE_WIDTH = 2, + VK_DYNAMIC_STATE_DEPTH_BIAS = 3, + VK_DYNAMIC_STATE_BLEND_CONSTANTS = 4, + VK_DYNAMIC_STATE_DEPTH_BOUNDS = 5, + VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK = 6, + VK_DYNAMIC_STATE_STENCIL_WRITE_MASK = 7, + VK_DYNAMIC_STATE_STENCIL_REFERENCE = 8, + VK_DYNAMIC_STATE_CULL_MODE = 1000267000, + VK_DYNAMIC_STATE_FRONT_FACE = 1000267001, + VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY = 1000267002, + VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT = 1000267003, + VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT = 1000267004, + VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE = 1000267005, + VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE = 1000267006, + VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE = 1000267007, + VK_DYNAMIC_STATE_DEPTH_COMPARE_OP = 1000267008, + VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE = 1000267009, + VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE = 1000267010, + VK_DYNAMIC_STATE_STENCIL_OP = 1000267011, + VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE = 1000377001, + VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE = 1000377002, + VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE = 1000377004, + VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV = 1000087000, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT = 1000099000, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_ENABLE_EXT = 1000099001, + VK_DYNAMIC_STATE_DISCARD_RECTANGLE_MODE_EXT = 1000099002, + VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT = 1000143000, + VK_DYNAMIC_STATE_RAY_TRACING_PIPELINE_STACK_SIZE_KHR = 1000347000, + VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV = 1000164004, + VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV = 1000164006, + VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_ENABLE_NV = 1000205000, + VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV = 1000205001, + VK_DYNAMIC_STATE_FRAGMENT_SHADING_RATE_KHR = 1000226000, + VK_DYNAMIC_STATE_VERTEX_INPUT_EXT = 1000352000, + VK_DYNAMIC_STATE_PATCH_CONTROL_POINTS_EXT = 1000377000, + VK_DYNAMIC_STATE_LOGIC_OP_EXT = 1000377003, + VK_DYNAMIC_STATE_COLOR_WRITE_ENABLE_EXT = 1000381000, + VK_DYNAMIC_STATE_DEPTH_CLAMP_ENABLE_EXT = 1000455003, + VK_DYNAMIC_STATE_POLYGON_MODE_EXT = 1000455004, + VK_DYNAMIC_STATE_RASTERIZATION_SAMPLES_EXT = 1000455005, + VK_DYNAMIC_STATE_SAMPLE_MASK_EXT = 1000455006, + VK_DYNAMIC_STATE_ALPHA_TO_COVERAGE_ENABLE_EXT = 1000455007, + VK_DYNAMIC_STATE_ALPHA_TO_ONE_ENABLE_EXT = 1000455008, + VK_DYNAMIC_STATE_LOGIC_OP_ENABLE_EXT = 1000455009, + VK_DYNAMIC_STATE_COLOR_BLEND_ENABLE_EXT = 1000455010, + VK_DYNAMIC_STATE_COLOR_BLEND_EQUATION_EXT = 1000455011, + VK_DYNAMIC_STATE_COLOR_WRITE_MASK_EXT = 1000455012, + VK_DYNAMIC_STATE_TESSELLATION_DOMAIN_ORIGIN_EXT = 1000455002, + VK_DYNAMIC_STATE_RASTERIZATION_STREAM_EXT = 1000455013, + VK_DYNAMIC_STATE_CONSERVATIVE_RASTERIZATION_MODE_EXT = 1000455014, + VK_DYNAMIC_STATE_EXTRA_PRIMITIVE_OVERESTIMATION_SIZE_EXT = 1000455015, + VK_DYNAMIC_STATE_DEPTH_CLIP_ENABLE_EXT = 1000455016, + VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_ENABLE_EXT = 1000455017, + VK_DYNAMIC_STATE_COLOR_BLEND_ADVANCED_EXT = 1000455018, + VK_DYNAMIC_STATE_PROVOKING_VERTEX_MODE_EXT = 1000455019, + VK_DYNAMIC_STATE_LINE_RASTERIZATION_MODE_EXT = 1000455020, + VK_DYNAMIC_STATE_LINE_STIPPLE_ENABLE_EXT = 1000455021, + VK_DYNAMIC_STATE_DEPTH_CLIP_NEGATIVE_ONE_TO_ONE_EXT = 1000455022, + VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_ENABLE_NV = 1000455023, + VK_DYNAMIC_STATE_VIEWPORT_SWIZZLE_NV = 1000455024, + VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_ENABLE_NV = 1000455025, + VK_DYNAMIC_STATE_COVERAGE_TO_COLOR_LOCATION_NV = 1000455026, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_MODE_NV = 1000455027, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_ENABLE_NV = 1000455028, + VK_DYNAMIC_STATE_COVERAGE_MODULATION_TABLE_NV = 1000455029, + VK_DYNAMIC_STATE_SHADING_RATE_IMAGE_ENABLE_NV = 1000455030, + VK_DYNAMIC_STATE_REPRESENTATIVE_FRAGMENT_TEST_ENABLE_NV = 1000455031, + VK_DYNAMIC_STATE_COVERAGE_REDUCTION_MODE_NV = 1000455032, + VK_DYNAMIC_STATE_ATTACHMENT_FEEDBACK_LOOP_ENABLE_EXT = 1000524000, + VK_DYNAMIC_STATE_LINE_STIPPLE_KHR = 1000259000, + VK_DYNAMIC_STATE_LINE_STIPPLE_EXT = VK_DYNAMIC_STATE_LINE_STIPPLE_KHR, + VK_DYNAMIC_STATE_CULL_MODE_EXT = VK_DYNAMIC_STATE_CULL_MODE, + VK_DYNAMIC_STATE_FRONT_FACE_EXT = VK_DYNAMIC_STATE_FRONT_FACE, + VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT = VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY, + VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT = VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT, + VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT = VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT, + VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT = VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE, + VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT = VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE, + VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT = VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE, + VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT = VK_DYNAMIC_STATE_DEPTH_COMPARE_OP, + VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT = VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE, + VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT = VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE, + VK_DYNAMIC_STATE_STENCIL_OP_EXT = VK_DYNAMIC_STATE_STENCIL_OP, + VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE_EXT = VK_DYNAMIC_STATE_RASTERIZER_DISCARD_ENABLE, + VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE_EXT = VK_DYNAMIC_STATE_DEPTH_BIAS_ENABLE, + VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE_EXT = VK_DYNAMIC_STATE_PRIMITIVE_RESTART_ENABLE, + VK_DYNAMIC_STATE_MAX_ENUM = 0x7FFFFFFF +} VkDynamicState; + +typedef enum VkFrontFace { + VK_FRONT_FACE_COUNTER_CLOCKWISE = 0, + VK_FRONT_FACE_CLOCKWISE = 1, + VK_FRONT_FACE_MAX_ENUM = 0x7FFFFFFF +} VkFrontFace; + +typedef enum VkVertexInputRate { + VK_VERTEX_INPUT_RATE_VERTEX = 0, + VK_VERTEX_INPUT_RATE_INSTANCE = 1, + VK_VERTEX_INPUT_RATE_MAX_ENUM = 0x7FFFFFFF +} VkVertexInputRate; + +typedef enum VkPrimitiveTopology { + VK_PRIMITIVE_TOPOLOGY_POINT_LIST = 0, + VK_PRIMITIVE_TOPOLOGY_LINE_LIST = 1, + VK_PRIMITIVE_TOPOLOGY_LINE_STRIP = 2, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST = 3, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP = 4, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN = 5, + VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY = 6, + VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY = 7, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY = 8, + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY = 9, + VK_PRIMITIVE_TOPOLOGY_PATCH_LIST = 10, + VK_PRIMITIVE_TOPOLOGY_MAX_ENUM = 0x7FFFFFFF +} VkPrimitiveTopology; + +typedef enum VkPolygonMode { + VK_POLYGON_MODE_FILL = 0, + VK_POLYGON_MODE_LINE = 1, + VK_POLYGON_MODE_POINT = 2, + VK_POLYGON_MODE_FILL_RECTANGLE_NV = 1000153000, + VK_POLYGON_MODE_MAX_ENUM = 0x7FFFFFFF +} VkPolygonMode; + +typedef enum VkStencilOp { + VK_STENCIL_OP_KEEP = 0, + VK_STENCIL_OP_ZERO = 1, + VK_STENCIL_OP_REPLACE = 2, + VK_STENCIL_OP_INCREMENT_AND_CLAMP = 3, + VK_STENCIL_OP_DECREMENT_AND_CLAMP = 4, + VK_STENCIL_OP_INVERT = 5, + VK_STENCIL_OP_INCREMENT_AND_WRAP = 6, + VK_STENCIL_OP_DECREMENT_AND_WRAP = 7, + VK_STENCIL_OP_MAX_ENUM = 0x7FFFFFFF +} VkStencilOp; + +typedef enum VkLogicOp { + VK_LOGIC_OP_CLEAR = 0, + VK_LOGIC_OP_AND = 1, + VK_LOGIC_OP_AND_REVERSE = 2, + VK_LOGIC_OP_COPY = 3, + VK_LOGIC_OP_AND_INVERTED = 4, + VK_LOGIC_OP_NO_OP = 5, + VK_LOGIC_OP_XOR = 6, + VK_LOGIC_OP_OR = 7, + VK_LOGIC_OP_NOR = 8, + VK_LOGIC_OP_EQUIVALENT = 9, + VK_LOGIC_OP_INVERT = 10, + VK_LOGIC_OP_OR_REVERSE = 11, + VK_LOGIC_OP_COPY_INVERTED = 12, + VK_LOGIC_OP_OR_INVERTED = 13, + VK_LOGIC_OP_NAND = 14, + VK_LOGIC_OP_SET = 15, + VK_LOGIC_OP_MAX_ENUM = 0x7FFFFFFF +} VkLogicOp; + +typedef enum VkBorderColor { + VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK = 0, + VK_BORDER_COLOR_INT_TRANSPARENT_BLACK = 1, + VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK = 2, + VK_BORDER_COLOR_INT_OPAQUE_BLACK = 3, + VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE = 4, + VK_BORDER_COLOR_INT_OPAQUE_WHITE = 5, + VK_BORDER_COLOR_FLOAT_CUSTOM_EXT = 1000287003, + VK_BORDER_COLOR_INT_CUSTOM_EXT = 1000287004, + VK_BORDER_COLOR_MAX_ENUM = 0x7FFFFFFF +} VkBorderColor; + +typedef enum VkFilter { + VK_FILTER_NEAREST = 0, + VK_FILTER_LINEAR = 1, + VK_FILTER_CUBIC_EXT = 1000015000, + VK_FILTER_CUBIC_IMG = VK_FILTER_CUBIC_EXT, + VK_FILTER_MAX_ENUM = 0x7FFFFFFF +} VkFilter; + +typedef enum VkSamplerAddressMode { + VK_SAMPLER_ADDRESS_MODE_REPEAT = 0, + VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT = 1, + VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE = 2, + VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER = 3, + VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE = 4, + VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE_KHR = VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, + VK_SAMPLER_ADDRESS_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerAddressMode; + +typedef enum VkSamplerMipmapMode { + VK_SAMPLER_MIPMAP_MODE_NEAREST = 0, + VK_SAMPLER_MIPMAP_MODE_LINEAR = 1, + VK_SAMPLER_MIPMAP_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerMipmapMode; + +typedef enum VkDescriptorType { + VK_DESCRIPTOR_TYPE_SAMPLER = 0, + VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER = 1, + VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE = 2, + VK_DESCRIPTOR_TYPE_STORAGE_IMAGE = 3, + VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER = 4, + VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER = 5, + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER = 6, + VK_DESCRIPTOR_TYPE_STORAGE_BUFFER = 7, + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC = 8, + VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC = 9, + VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT = 10, + VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK = 1000138000, + VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR = 1000150000, + VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV = 1000165000, + VK_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM = 1000440000, + VK_DESCRIPTOR_TYPE_BLOCK_MATCH_IMAGE_QCOM = 1000440001, + VK_DESCRIPTOR_TYPE_MUTABLE_EXT = 1000351000, + VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT = VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK, + VK_DESCRIPTOR_TYPE_MUTABLE_VALVE = VK_DESCRIPTOR_TYPE_MUTABLE_EXT, + VK_DESCRIPTOR_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorType; + +typedef enum VkAttachmentLoadOp { + VK_ATTACHMENT_LOAD_OP_LOAD = 0, + VK_ATTACHMENT_LOAD_OP_CLEAR = 1, + VK_ATTACHMENT_LOAD_OP_DONT_CARE = 2, + VK_ATTACHMENT_LOAD_OP_NONE_KHR = 1000400000, + VK_ATTACHMENT_LOAD_OP_NONE_EXT = VK_ATTACHMENT_LOAD_OP_NONE_KHR, + VK_ATTACHMENT_LOAD_OP_MAX_ENUM = 0x7FFFFFFF +} VkAttachmentLoadOp; + +typedef enum VkAttachmentStoreOp { + VK_ATTACHMENT_STORE_OP_STORE = 0, + VK_ATTACHMENT_STORE_OP_DONT_CARE = 1, + VK_ATTACHMENT_STORE_OP_NONE = 1000301000, + VK_ATTACHMENT_STORE_OP_NONE_KHR = VK_ATTACHMENT_STORE_OP_NONE, + VK_ATTACHMENT_STORE_OP_NONE_QCOM = VK_ATTACHMENT_STORE_OP_NONE, + VK_ATTACHMENT_STORE_OP_NONE_EXT = VK_ATTACHMENT_STORE_OP_NONE, + VK_ATTACHMENT_STORE_OP_MAX_ENUM = 0x7FFFFFFF +} VkAttachmentStoreOp; + +typedef enum VkPipelineBindPoint { + VK_PIPELINE_BIND_POINT_GRAPHICS = 0, + VK_PIPELINE_BIND_POINT_COMPUTE = 1, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_PIPELINE_BIND_POINT_EXECUTION_GRAPH_AMDX = 1000134000, +#endif + VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR = 1000165000, + VK_PIPELINE_BIND_POINT_SUBPASS_SHADING_HUAWEI = 1000369003, + VK_PIPELINE_BIND_POINT_RAY_TRACING_NV = VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR, + VK_PIPELINE_BIND_POINT_MAX_ENUM = 0x7FFFFFFF +} VkPipelineBindPoint; + +typedef enum VkCommandBufferLevel { + VK_COMMAND_BUFFER_LEVEL_PRIMARY = 0, + VK_COMMAND_BUFFER_LEVEL_SECONDARY = 1, + VK_COMMAND_BUFFER_LEVEL_MAX_ENUM = 0x7FFFFFFF +} VkCommandBufferLevel; + +typedef enum VkIndexType { + VK_INDEX_TYPE_UINT16 = 0, + VK_INDEX_TYPE_UINT32 = 1, + VK_INDEX_TYPE_NONE_KHR = 1000165000, + VK_INDEX_TYPE_UINT8_KHR = 1000265000, + VK_INDEX_TYPE_NONE_NV = VK_INDEX_TYPE_NONE_KHR, + VK_INDEX_TYPE_UINT8_EXT = VK_INDEX_TYPE_UINT8_KHR, + VK_INDEX_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkIndexType; + +typedef enum VkSubpassContents { + VK_SUBPASS_CONTENTS_INLINE = 0, + VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS = 1, + VK_SUBPASS_CONTENTS_INLINE_AND_SECONDARY_COMMAND_BUFFERS_EXT = 1000451000, + VK_SUBPASS_CONTENTS_MAX_ENUM = 0x7FFFFFFF +} VkSubpassContents; + +typedef enum VkAccessFlagBits { + VK_ACCESS_INDIRECT_COMMAND_READ_BIT = 0x00000001, + VK_ACCESS_INDEX_READ_BIT = 0x00000002, + VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004, + VK_ACCESS_UNIFORM_READ_BIT = 0x00000008, + VK_ACCESS_INPUT_ATTACHMENT_READ_BIT = 0x00000010, + VK_ACCESS_SHADER_READ_BIT = 0x00000020, + VK_ACCESS_SHADER_WRITE_BIT = 0x00000040, + VK_ACCESS_COLOR_ATTACHMENT_READ_BIT = 0x00000080, + VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT = 0x00000100, + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 0x00000200, + VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 0x00000400, + VK_ACCESS_TRANSFER_READ_BIT = 0x00000800, + VK_ACCESS_TRANSFER_WRITE_BIT = 0x00001000, + VK_ACCESS_HOST_READ_BIT = 0x00002000, + VK_ACCESS_HOST_WRITE_BIT = 0x00004000, + VK_ACCESS_MEMORY_READ_BIT = 0x00008000, + VK_ACCESS_MEMORY_WRITE_BIT = 0x00010000, + VK_ACCESS_NONE = 0, + VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT = 0x02000000, + VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT = 0x04000000, + VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT = 0x08000000, + VK_ACCESS_CONDITIONAL_RENDERING_READ_BIT_EXT = 0x00100000, + VK_ACCESS_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT = 0x00080000, + VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR = 0x00200000, + VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR = 0x00400000, + VK_ACCESS_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000, + VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR = 0x00800000, + VK_ACCESS_COMMAND_PREPROCESS_READ_BIT_NV = 0x00020000, + VK_ACCESS_COMMAND_PREPROCESS_WRITE_BIT_NV = 0x00040000, + VK_ACCESS_SHADING_RATE_IMAGE_READ_BIT_NV = VK_ACCESS_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR, + VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_NV = VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR, + VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_NV = VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR, + VK_ACCESS_NONE_KHR = VK_ACCESS_NONE, + VK_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkAccessFlagBits; +typedef VkFlags VkAccessFlags; + +typedef enum VkImageAspectFlagBits { + VK_IMAGE_ASPECT_COLOR_BIT = 0x00000001, + VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002, + VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004, + VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008, + VK_IMAGE_ASPECT_PLANE_0_BIT = 0x00000010, + VK_IMAGE_ASPECT_PLANE_1_BIT = 0x00000020, + VK_IMAGE_ASPECT_PLANE_2_BIT = 0x00000040, + VK_IMAGE_ASPECT_NONE = 0, + VK_IMAGE_ASPECT_MEMORY_PLANE_0_BIT_EXT = 0x00000080, + VK_IMAGE_ASPECT_MEMORY_PLANE_1_BIT_EXT = 0x00000100, + VK_IMAGE_ASPECT_MEMORY_PLANE_2_BIT_EXT = 0x00000200, + VK_IMAGE_ASPECT_MEMORY_PLANE_3_BIT_EXT = 0x00000400, + VK_IMAGE_ASPECT_PLANE_0_BIT_KHR = VK_IMAGE_ASPECT_PLANE_0_BIT, + VK_IMAGE_ASPECT_PLANE_1_BIT_KHR = VK_IMAGE_ASPECT_PLANE_1_BIT, + VK_IMAGE_ASPECT_PLANE_2_BIT_KHR = VK_IMAGE_ASPECT_PLANE_2_BIT, + VK_IMAGE_ASPECT_NONE_KHR = VK_IMAGE_ASPECT_NONE, + VK_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageAspectFlagBits; +typedef VkFlags VkImageAspectFlags; + +typedef enum VkFormatFeatureFlagBits { + VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT = 0x00000001, + VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT = 0x00000002, + VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004, + VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000008, + VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT = 0x00000010, + VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 0x00000020, + VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT = 0x00000040, + VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT = 0x00000080, + VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT = 0x00000100, + VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000200, + VK_FORMAT_FEATURE_BLIT_SRC_BIT = 0x00000400, + VK_FORMAT_FEATURE_BLIT_DST_BIT = 0x00000800, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000, + VK_FORMAT_FEATURE_TRANSFER_SRC_BIT = 0x00004000, + VK_FORMAT_FEATURE_TRANSFER_DST_BIT = 0x00008000, + VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT = 0x00020000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT = 0x00040000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT = 0x00080000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT = 0x00100000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT = 0x00200000, + VK_FORMAT_FEATURE_DISJOINT_BIT = 0x00400000, + VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT = 0x00800000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT = 0x00010000, + VK_FORMAT_FEATURE_VIDEO_DECODE_OUTPUT_BIT_KHR = 0x02000000, + VK_FORMAT_FEATURE_VIDEO_DECODE_DPB_BIT_KHR = 0x04000000, + VK_FORMAT_FEATURE_ACCELERATION_STRUCTURE_VERTEX_BUFFER_BIT_KHR = 0x20000000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = 0x00002000, + VK_FORMAT_FEATURE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x01000000, + VK_FORMAT_FEATURE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000, + VK_FORMAT_FEATURE_VIDEO_ENCODE_INPUT_BIT_KHR = 0x08000000, + VK_FORMAT_FEATURE_VIDEO_ENCODE_DPB_BIT_KHR = 0x10000000, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT, + VK_FORMAT_FEATURE_TRANSFER_SRC_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT, + VK_FORMAT_FEATURE_TRANSFER_DST_BIT_KHR = VK_FORMAT_FEATURE_TRANSFER_DST_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT_EXT = VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_MINMAX_BIT, + VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT_KHR = VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT, + VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR = VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT, + VK_FORMAT_FEATURE_DISJOINT_BIT_KHR = VK_FORMAT_FEATURE_DISJOINT_BIT, + VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT_KHR = VK_FORMAT_FEATURE_COSITED_CHROMA_SAMPLES_BIT, + VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFormatFeatureFlagBits; +typedef VkFlags VkFormatFeatureFlags; + +typedef enum VkImageCreateFlagBits { + VK_IMAGE_CREATE_SPARSE_BINDING_BIT = 0x00000001, + VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, + VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004, + VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008, + VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010, + VK_IMAGE_CREATE_ALIAS_BIT = 0x00000400, + VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT = 0x00000040, + VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT = 0x00000020, + VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT = 0x00000080, + VK_IMAGE_CREATE_EXTENDED_USAGE_BIT = 0x00000100, + VK_IMAGE_CREATE_PROTECTED_BIT = 0x00000800, + VK_IMAGE_CREATE_DISJOINT_BIT = 0x00000200, + VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV = 0x00002000, + VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT = 0x00001000, + VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT = 0x00004000, + VK_IMAGE_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00010000, + VK_IMAGE_CREATE_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_BIT_EXT = 0x00040000, + VK_IMAGE_CREATE_2D_VIEW_COMPATIBLE_BIT_EXT = 0x00020000, + VK_IMAGE_CREATE_FRAGMENT_DENSITY_MAP_OFFSET_BIT_QCOM = 0x00008000, + VK_IMAGE_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR = 0x00100000, + VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT, + VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT_KHR = VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT, + VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT_KHR = VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT, + VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR = VK_IMAGE_CREATE_EXTENDED_USAGE_BIT, + VK_IMAGE_CREATE_DISJOINT_BIT_KHR = VK_IMAGE_CREATE_DISJOINT_BIT, + VK_IMAGE_CREATE_ALIAS_BIT_KHR = VK_IMAGE_CREATE_ALIAS_BIT, + VK_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageCreateFlagBits; +typedef VkFlags VkImageCreateFlags; + +typedef enum VkSampleCountFlagBits { + VK_SAMPLE_COUNT_1_BIT = 0x00000001, + VK_SAMPLE_COUNT_2_BIT = 0x00000002, + VK_SAMPLE_COUNT_4_BIT = 0x00000004, + VK_SAMPLE_COUNT_8_BIT = 0x00000008, + VK_SAMPLE_COUNT_16_BIT = 0x00000010, + VK_SAMPLE_COUNT_32_BIT = 0x00000020, + VK_SAMPLE_COUNT_64_BIT = 0x00000040, + VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSampleCountFlagBits; +typedef VkFlags VkSampleCountFlags; + +typedef enum VkImageUsageFlagBits { + VK_IMAGE_USAGE_TRANSFER_SRC_BIT = 0x00000001, + VK_IMAGE_USAGE_TRANSFER_DST_BIT = 0x00000002, + VK_IMAGE_USAGE_SAMPLED_BIT = 0x00000004, + VK_IMAGE_USAGE_STORAGE_BIT = 0x00000008, + VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT = 0x00000010, + VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020, + VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040, + VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080, + VK_IMAGE_USAGE_VIDEO_DECODE_DST_BIT_KHR = 0x00000400, + VK_IMAGE_USAGE_VIDEO_DECODE_SRC_BIT_KHR = 0x00000800, + VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR = 0x00001000, + VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x00000200, + VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00000100, + VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT = 0x00400000, + VK_IMAGE_USAGE_VIDEO_ENCODE_DST_BIT_KHR = 0x00002000, + VK_IMAGE_USAGE_VIDEO_ENCODE_SRC_BIT_KHR = 0x00004000, + VK_IMAGE_USAGE_VIDEO_ENCODE_DPB_BIT_KHR = 0x00008000, + VK_IMAGE_USAGE_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x00080000, + VK_IMAGE_USAGE_INVOCATION_MASK_BIT_HUAWEI = 0x00040000, + VK_IMAGE_USAGE_SAMPLE_WEIGHT_BIT_QCOM = 0x00100000, + VK_IMAGE_USAGE_SAMPLE_BLOCK_MATCH_BIT_QCOM = 0x00200000, + VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV = VK_IMAGE_USAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, + VK_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageUsageFlagBits; +typedef VkFlags VkImageUsageFlags; + +typedef enum VkInstanceCreateFlagBits { + VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR = 0x00000001, + VK_INSTANCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkInstanceCreateFlagBits; +typedef VkFlags VkInstanceCreateFlags; + +typedef enum VkMemoryHeapFlagBits { + VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001, + VK_MEMORY_HEAP_MULTI_INSTANCE_BIT = 0x00000002, + VK_MEMORY_HEAP_MULTI_INSTANCE_BIT_KHR = VK_MEMORY_HEAP_MULTI_INSTANCE_BIT, + VK_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkMemoryHeapFlagBits; +typedef VkFlags VkMemoryHeapFlags; + +typedef enum VkMemoryPropertyFlagBits { + VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT = 0x00000001, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT = 0x00000002, + VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004, + VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008, + VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010, + VK_MEMORY_PROPERTY_PROTECTED_BIT = 0x00000020, + VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD = 0x00000040, + VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD = 0x00000080, + VK_MEMORY_PROPERTY_RDMA_CAPABLE_BIT_NV = 0x00000100, + VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkMemoryPropertyFlagBits; +typedef VkFlags VkMemoryPropertyFlags; + +typedef enum VkQueueFlagBits { + VK_QUEUE_GRAPHICS_BIT = 0x00000001, + VK_QUEUE_COMPUTE_BIT = 0x00000002, + VK_QUEUE_TRANSFER_BIT = 0x00000004, + VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008, + VK_QUEUE_PROTECTED_BIT = 0x00000010, + VK_QUEUE_VIDEO_DECODE_BIT_KHR = 0x00000020, + VK_QUEUE_VIDEO_ENCODE_BIT_KHR = 0x00000040, + VK_QUEUE_OPTICAL_FLOW_BIT_NV = 0x00000100, + VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueueFlagBits; +typedef VkFlags VkQueueFlags; +typedef VkFlags VkDeviceCreateFlags; + +typedef enum VkDeviceQueueCreateFlagBits { + VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT = 0x00000001, + VK_DEVICE_QUEUE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDeviceQueueCreateFlagBits; +typedef VkFlags VkDeviceQueueCreateFlags; + +typedef enum VkPipelineStageFlagBits { + VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT = 0x00000001, + VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT = 0x00000002, + VK_PIPELINE_STAGE_VERTEX_INPUT_BIT = 0x00000004, + VK_PIPELINE_STAGE_VERTEX_SHADER_BIT = 0x00000008, + VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT = 0x00000010, + VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT = 0x00000020, + VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT = 0x00000040, + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT = 0x00000080, + VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT = 0x00000100, + VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT = 0x00000200, + VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400, + VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT = 0x00000800, + VK_PIPELINE_STAGE_TRANSFER_BIT = 0x00001000, + VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT = 0x00002000, + VK_PIPELINE_STAGE_HOST_BIT = 0x00004000, + VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 0x00008000, + VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 0x00010000, + VK_PIPELINE_STAGE_NONE = 0, + VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT = 0x01000000, + VK_PIPELINE_STAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x00040000, + VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR = 0x02000000, + VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR = 0x00200000, + VK_PIPELINE_STAGE_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000, + VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00400000, + VK_PIPELINE_STAGE_COMMAND_PREPROCESS_BIT_NV = 0x00020000, + VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT = 0x00080000, + VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT = 0x00100000, + VK_PIPELINE_STAGE_SHADING_RATE_IMAGE_BIT_NV = VK_PIPELINE_STAGE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, + VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV = VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR, + VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_NV = VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR, + VK_PIPELINE_STAGE_TASK_SHADER_BIT_NV = VK_PIPELINE_STAGE_TASK_SHADER_BIT_EXT, + VK_PIPELINE_STAGE_MESH_SHADER_BIT_NV = VK_PIPELINE_STAGE_MESH_SHADER_BIT_EXT, + VK_PIPELINE_STAGE_NONE_KHR = VK_PIPELINE_STAGE_NONE, + VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineStageFlagBits; +typedef VkFlags VkPipelineStageFlags; + +typedef enum VkMemoryMapFlagBits { + VK_MEMORY_MAP_PLACED_BIT_EXT = 0x00000001, + VK_MEMORY_MAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkMemoryMapFlagBits; +typedef VkFlags VkMemoryMapFlags; + +typedef enum VkSparseMemoryBindFlagBits { + VK_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001, + VK_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSparseMemoryBindFlagBits; +typedef VkFlags VkSparseMemoryBindFlags; + +typedef enum VkSparseImageFormatFlagBits { + VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001, + VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002, + VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004, + VK_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSparseImageFormatFlagBits; +typedef VkFlags VkSparseImageFormatFlags; + +typedef enum VkFenceCreateFlagBits { + VK_FENCE_CREATE_SIGNALED_BIT = 0x00000001, + VK_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFenceCreateFlagBits; +typedef VkFlags VkFenceCreateFlags; +typedef VkFlags VkSemaphoreCreateFlags; + +typedef enum VkEventCreateFlagBits { + VK_EVENT_CREATE_DEVICE_ONLY_BIT = 0x00000001, + VK_EVENT_CREATE_DEVICE_ONLY_BIT_KHR = VK_EVENT_CREATE_DEVICE_ONLY_BIT, + VK_EVENT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkEventCreateFlagBits; +typedef VkFlags VkEventCreateFlags; + +typedef enum VkQueryPipelineStatisticFlagBits { + VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT = 0x00000001, + VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT = 0x00000002, + VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT = 0x00000004, + VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT = 0x00000008, + VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT = 0x00000010, + VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT = 0x00000020, + VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT = 0x00000040, + VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT = 0x00000080, + VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 0x00000100, + VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200, + VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400, + VK_QUERY_PIPELINE_STATISTIC_TASK_SHADER_INVOCATIONS_BIT_EXT = 0x00000800, + VK_QUERY_PIPELINE_STATISTIC_MESH_SHADER_INVOCATIONS_BIT_EXT = 0x00001000, + VK_QUERY_PIPELINE_STATISTIC_CLUSTER_CULLING_SHADER_INVOCATIONS_BIT_HUAWEI = 0x00002000, + VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueryPipelineStatisticFlagBits; +typedef VkFlags VkQueryPipelineStatisticFlags; +typedef VkFlags VkQueryPoolCreateFlags; + +typedef enum VkQueryResultFlagBits { + VK_QUERY_RESULT_64_BIT = 0x00000001, + VK_QUERY_RESULT_WAIT_BIT = 0x00000002, + VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004, + VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008, + VK_QUERY_RESULT_WITH_STATUS_BIT_KHR = 0x00000010, + VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueryResultFlagBits; +typedef VkFlags VkQueryResultFlags; + +typedef enum VkBufferCreateFlagBits { + VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001, + VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002, + VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004, + VK_BUFFER_CREATE_PROTECTED_BIT = 0x00000008, + VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 0x00000010, + VK_BUFFER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000020, + VK_BUFFER_CREATE_VIDEO_PROFILE_INDEPENDENT_BIT_KHR = 0x00000040, + VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, + VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = VK_BUFFER_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, + VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkBufferCreateFlagBits; +typedef VkFlags VkBufferCreateFlags; + +typedef enum VkBufferUsageFlagBits { + VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x00000001, + VK_BUFFER_USAGE_TRANSFER_DST_BIT = 0x00000002, + VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x00000004, + VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 0x00000008, + VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 0x00000010, + VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 0x00000020, + VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 0x00000040, + VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080, + VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100, + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT = 0x00020000, + VK_BUFFER_USAGE_VIDEO_DECODE_SRC_BIT_KHR = 0x00002000, + VK_BUFFER_USAGE_VIDEO_DECODE_DST_BIT_KHR = 0x00004000, + VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT = 0x00000800, + VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT = 0x00001000, + VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x00000200, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_BUFFER_USAGE_EXECUTION_GRAPH_SCRATCH_BIT_AMDX = 0x02000000, +#endif + VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR = 0x00080000, + VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR = 0x00100000, + VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR = 0x00000400, + VK_BUFFER_USAGE_VIDEO_ENCODE_DST_BIT_KHR = 0x00008000, + VK_BUFFER_USAGE_VIDEO_ENCODE_SRC_BIT_KHR = 0x00010000, + VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT = 0x00200000, + VK_BUFFER_USAGE_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00400000, + VK_BUFFER_USAGE_PUSH_DESCRIPTORS_DESCRIPTOR_BUFFER_BIT_EXT = 0x04000000, + VK_BUFFER_USAGE_MICROMAP_BUILD_INPUT_READ_ONLY_BIT_EXT = 0x00800000, + VK_BUFFER_USAGE_MICROMAP_STORAGE_BIT_EXT = 0x01000000, + VK_BUFFER_USAGE_RAY_TRACING_BIT_NV = VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR, + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, + VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_KHR = VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, + VK_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkBufferUsageFlagBits; +typedef VkFlags VkBufferUsageFlags; +typedef VkFlags VkBufferViewCreateFlags; + +typedef enum VkImageViewCreateFlagBits { + VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x00000001, + VK_IMAGE_VIEW_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000004, + VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DEFERRED_BIT_EXT = 0x00000002, + VK_IMAGE_VIEW_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkImageViewCreateFlagBits; +typedef VkFlags VkImageViewCreateFlags; +typedef VkFlags VkShaderModuleCreateFlags; + +typedef enum VkPipelineCacheCreateFlagBits { + VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT = 0x00000001, + VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT_EXT = VK_PIPELINE_CACHE_CREATE_EXTERNALLY_SYNCHRONIZED_BIT, + VK_PIPELINE_CACHE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineCacheCreateFlagBits; +typedef VkFlags VkPipelineCacheCreateFlags; + +typedef enum VkColorComponentFlagBits { + VK_COLOR_COMPONENT_R_BIT = 0x00000001, + VK_COLOR_COMPONENT_G_BIT = 0x00000002, + VK_COLOR_COMPONENT_B_BIT = 0x00000004, + VK_COLOR_COMPONENT_A_BIT = 0x00000008, + VK_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkColorComponentFlagBits; +typedef VkFlags VkColorComponentFlags; + +typedef enum VkPipelineCreateFlagBits { + VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001, + VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002, + VK_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004, + VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT = 0x00000008, + VK_PIPELINE_CREATE_DISPATCH_BASE_BIT = 0x00000010, + VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT = 0x00000100, + VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT = 0x00000200, + VK_PIPELINE_CREATE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00200000, + VK_PIPELINE_CREATE_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = 0x00400000, + VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR = 0x00004000, + VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR = 0x00008000, + VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR = 0x00010000, + VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR = 0x00020000, + VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR = 0x00001000, + VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR = 0x00002000, + VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR = 0x00080000, + VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV = 0x00000020, + VK_PIPELINE_CREATE_CAPTURE_STATISTICS_BIT_KHR = 0x00000040, + VK_PIPELINE_CREATE_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR = 0x00000080, + VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV = 0x00040000, + VK_PIPELINE_CREATE_LIBRARY_BIT_KHR = 0x00000800, + VK_PIPELINE_CREATE_DESCRIPTOR_BUFFER_BIT_EXT = 0x20000000, + VK_PIPELINE_CREATE_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT = 0x00800000, + VK_PIPELINE_CREATE_LINK_TIME_OPTIMIZATION_BIT_EXT = 0x00000400, + VK_PIPELINE_CREATE_RAY_TRACING_ALLOW_MOTION_BIT_NV = 0x00100000, + VK_PIPELINE_CREATE_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x02000000, + VK_PIPELINE_CREATE_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x04000000, + VK_PIPELINE_CREATE_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT = 0x01000000, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_PIPELINE_CREATE_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV = 0x10000000, +#endif + VK_PIPELINE_CREATE_NO_PROTECTED_ACCESS_BIT_EXT = 0x08000000, + VK_PIPELINE_CREATE_PROTECTED_ACCESS_ONLY_BIT_EXT = 0x40000000, + VK_PIPELINE_CREATE_DISPATCH_BASE = VK_PIPELINE_CREATE_DISPATCH_BASE_BIT, + VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = VK_PIPELINE_CREATE_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR, + VK_PIPELINE_RASTERIZATION_STATE_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = VK_PIPELINE_CREATE_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT, + VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR = VK_PIPELINE_CREATE_VIEW_INDEX_FROM_DEVICE_INDEX_BIT, + VK_PIPELINE_CREATE_DISPATCH_BASE_KHR = VK_PIPELINE_CREATE_DISPATCH_BASE, + VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT = VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT, + VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT = VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT, + VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineCreateFlagBits; +typedef VkFlags VkPipelineCreateFlags; + +typedef enum VkPipelineShaderStageCreateFlagBits { + VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT = 0x00000001, + VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT = 0x00000002, + VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT = VK_PIPELINE_SHADER_STAGE_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT, + VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT = VK_PIPELINE_SHADER_STAGE_CREATE_REQUIRE_FULL_SUBGROUPS_BIT, + VK_PIPELINE_SHADER_STAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineShaderStageCreateFlagBits; +typedef VkFlags VkPipelineShaderStageCreateFlags; + +typedef enum VkShaderStageFlagBits { + VK_SHADER_STAGE_VERTEX_BIT = 0x00000001, + VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x00000002, + VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x00000004, + VK_SHADER_STAGE_GEOMETRY_BIT = 0x00000008, + VK_SHADER_STAGE_FRAGMENT_BIT = 0x00000010, + VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020, + VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F, + VK_SHADER_STAGE_ALL = 0x7FFFFFFF, + VK_SHADER_STAGE_RAYGEN_BIT_KHR = 0x00000100, + VK_SHADER_STAGE_ANY_HIT_BIT_KHR = 0x00000200, + VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR = 0x00000400, + VK_SHADER_STAGE_MISS_BIT_KHR = 0x00000800, + VK_SHADER_STAGE_INTERSECTION_BIT_KHR = 0x00001000, + VK_SHADER_STAGE_CALLABLE_BIT_KHR = 0x00002000, + VK_SHADER_STAGE_TASK_BIT_EXT = 0x00000040, + VK_SHADER_STAGE_MESH_BIT_EXT = 0x00000080, + VK_SHADER_STAGE_SUBPASS_SHADING_BIT_HUAWEI = 0x00004000, + VK_SHADER_STAGE_CLUSTER_CULLING_BIT_HUAWEI = 0x00080000, + VK_SHADER_STAGE_RAYGEN_BIT_NV = VK_SHADER_STAGE_RAYGEN_BIT_KHR, + VK_SHADER_STAGE_ANY_HIT_BIT_NV = VK_SHADER_STAGE_ANY_HIT_BIT_KHR, + VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV = VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR, + VK_SHADER_STAGE_MISS_BIT_NV = VK_SHADER_STAGE_MISS_BIT_KHR, + VK_SHADER_STAGE_INTERSECTION_BIT_NV = VK_SHADER_STAGE_INTERSECTION_BIT_KHR, + VK_SHADER_STAGE_CALLABLE_BIT_NV = VK_SHADER_STAGE_CALLABLE_BIT_KHR, + VK_SHADER_STAGE_TASK_BIT_NV = VK_SHADER_STAGE_TASK_BIT_EXT, + VK_SHADER_STAGE_MESH_BIT_NV = VK_SHADER_STAGE_MESH_BIT_EXT, + VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkShaderStageFlagBits; + +typedef enum VkCullModeFlagBits { + VK_CULL_MODE_NONE = 0, + VK_CULL_MODE_FRONT_BIT = 0x00000001, + VK_CULL_MODE_BACK_BIT = 0x00000002, + VK_CULL_MODE_FRONT_AND_BACK = 0x00000003, + VK_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCullModeFlagBits; +typedef VkFlags VkCullModeFlags; +typedef VkFlags VkPipelineVertexInputStateCreateFlags; +typedef VkFlags VkPipelineInputAssemblyStateCreateFlags; +typedef VkFlags VkPipelineTessellationStateCreateFlags; +typedef VkFlags VkPipelineViewportStateCreateFlags; +typedef VkFlags VkPipelineRasterizationStateCreateFlags; +typedef VkFlags VkPipelineMultisampleStateCreateFlags; + +typedef enum VkPipelineDepthStencilStateCreateFlagBits { + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT = 0x00000001, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT = 0x00000002, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM = VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT, + VK_PIPELINE_DEPTH_STENCIL_STATE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineDepthStencilStateCreateFlagBits; +typedef VkFlags VkPipelineDepthStencilStateCreateFlags; + +typedef enum VkPipelineColorBlendStateCreateFlagBits { + VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT = 0x00000001, + VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_ARM = VK_PIPELINE_COLOR_BLEND_STATE_CREATE_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_BIT_EXT, + VK_PIPELINE_COLOR_BLEND_STATE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineColorBlendStateCreateFlagBits; +typedef VkFlags VkPipelineColorBlendStateCreateFlags; +typedef VkFlags VkPipelineDynamicStateCreateFlags; + +typedef enum VkPipelineLayoutCreateFlagBits { + VK_PIPELINE_LAYOUT_CREATE_INDEPENDENT_SETS_BIT_EXT = 0x00000002, + VK_PIPELINE_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineLayoutCreateFlagBits; +typedef VkFlags VkPipelineLayoutCreateFlags; +typedef VkFlags VkShaderStageFlags; + +typedef enum VkSamplerCreateFlagBits { + VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT = 0x00000001, + VK_SAMPLER_CREATE_SUBSAMPLED_COARSE_RECONSTRUCTION_BIT_EXT = 0x00000002, + VK_SAMPLER_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000008, + VK_SAMPLER_CREATE_NON_SEAMLESS_CUBE_MAP_BIT_EXT = 0x00000004, + VK_SAMPLER_CREATE_IMAGE_PROCESSING_BIT_QCOM = 0x00000010, + VK_SAMPLER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSamplerCreateFlagBits; +typedef VkFlags VkSamplerCreateFlags; + +typedef enum VkDescriptorPoolCreateFlagBits { + VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001, + VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT = 0x00000002, + VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT = 0x00000004, + VK_DESCRIPTOR_POOL_CREATE_ALLOW_OVERALLOCATION_SETS_BIT_NV = 0x00000008, + VK_DESCRIPTOR_POOL_CREATE_ALLOW_OVERALLOCATION_POOLS_BIT_NV = 0x00000010, + VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT_EXT = VK_DESCRIPTOR_POOL_CREATE_UPDATE_AFTER_BIND_BIT, + VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_VALVE = VK_DESCRIPTOR_POOL_CREATE_HOST_ONLY_BIT_EXT, + VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorPoolCreateFlagBits; +typedef VkFlags VkDescriptorPoolCreateFlags; +typedef VkFlags VkDescriptorPoolResetFlags; + +typedef enum VkDescriptorSetLayoutCreateFlagBits { + VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT = 0x00000002, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR = 0x00000001, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00000010, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_EMBEDDED_IMMUTABLE_SAMPLERS_BIT_EXT = 0x00000020, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_INDIRECT_BINDABLE_BIT_NV = 0x00000080, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT = 0x00000004, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_PER_STAGE_BIT_NV = 0x00000040, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT = VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_VALVE = VK_DESCRIPTOR_SET_LAYOUT_CREATE_HOST_ONLY_POOL_BIT_EXT, + VK_DESCRIPTOR_SET_LAYOUT_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorSetLayoutCreateFlagBits; +typedef VkFlags VkDescriptorSetLayoutCreateFlags; + +typedef enum VkAttachmentDescriptionFlagBits { + VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001, + VK_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkAttachmentDescriptionFlagBits; +typedef VkFlags VkAttachmentDescriptionFlags; + +typedef enum VkDependencyFlagBits { + VK_DEPENDENCY_BY_REGION_BIT = 0x00000001, + VK_DEPENDENCY_DEVICE_GROUP_BIT = 0x00000004, + VK_DEPENDENCY_VIEW_LOCAL_BIT = 0x00000002, + VK_DEPENDENCY_FEEDBACK_LOOP_BIT_EXT = 0x00000008, + VK_DEPENDENCY_VIEW_LOCAL_BIT_KHR = VK_DEPENDENCY_VIEW_LOCAL_BIT, + VK_DEPENDENCY_DEVICE_GROUP_BIT_KHR = VK_DEPENDENCY_DEVICE_GROUP_BIT, + VK_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDependencyFlagBits; +typedef VkFlags VkDependencyFlags; + +typedef enum VkFramebufferCreateFlagBits { + VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT = 0x00000001, + VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR = VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT, + VK_FRAMEBUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFramebufferCreateFlagBits; +typedef VkFlags VkFramebufferCreateFlags; + +typedef enum VkRenderPassCreateFlagBits { + VK_RENDER_PASS_CREATE_TRANSFORM_BIT_QCOM = 0x00000002, + VK_RENDER_PASS_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkRenderPassCreateFlagBits; +typedef VkFlags VkRenderPassCreateFlags; + +typedef enum VkSubpassDescriptionFlagBits { + VK_SUBPASS_DESCRIPTION_PER_VIEW_ATTRIBUTES_BIT_NVX = 0x00000001, + VK_SUBPASS_DESCRIPTION_PER_VIEW_POSITION_X_ONLY_BIT_NVX = 0x00000002, + VK_SUBPASS_DESCRIPTION_FRAGMENT_REGION_BIT_QCOM = 0x00000004, + VK_SUBPASS_DESCRIPTION_SHADER_RESOLVE_BIT_QCOM = 0x00000008, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_EXT = 0x00000010, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT = 0x00000020, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT = 0x00000040, + VK_SUBPASS_DESCRIPTION_ENABLE_LEGACY_DITHERING_BIT_EXT = 0x00000080, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_ARM = VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_COLOR_ACCESS_BIT_EXT, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_ARM = VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_DEPTH_ACCESS_BIT_EXT, + VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_ARM = VK_SUBPASS_DESCRIPTION_RASTERIZATION_ORDER_ATTACHMENT_STENCIL_ACCESS_BIT_EXT, + VK_SUBPASS_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSubpassDescriptionFlagBits; +typedef VkFlags VkSubpassDescriptionFlags; + +typedef enum VkCommandPoolCreateFlagBits { + VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001, + VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002, + VK_COMMAND_POOL_CREATE_PROTECTED_BIT = 0x00000004, + VK_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandPoolCreateFlagBits; +typedef VkFlags VkCommandPoolCreateFlags; + +typedef enum VkCommandPoolResetFlagBits { + VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001, + VK_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandPoolResetFlagBits; +typedef VkFlags VkCommandPoolResetFlags; + +typedef enum VkCommandBufferUsageFlagBits { + VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001, + VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002, + VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004, + VK_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandBufferUsageFlagBits; +typedef VkFlags VkCommandBufferUsageFlags; + +typedef enum VkQueryControlFlagBits { + VK_QUERY_CONTROL_PRECISE_BIT = 0x00000001, + VK_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkQueryControlFlagBits; +typedef VkFlags VkQueryControlFlags; + +typedef enum VkCommandBufferResetFlagBits { + VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001, + VK_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkCommandBufferResetFlagBits; +typedef VkFlags VkCommandBufferResetFlags; + +typedef enum VkStencilFaceFlagBits { + VK_STENCIL_FACE_FRONT_BIT = 0x00000001, + VK_STENCIL_FACE_BACK_BIT = 0x00000002, + VK_STENCIL_FACE_FRONT_AND_BACK = 0x00000003, + VK_STENCIL_FRONT_AND_BACK = VK_STENCIL_FACE_FRONT_AND_BACK, + VK_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkStencilFaceFlagBits; +typedef VkFlags VkStencilFaceFlags; +typedef struct VkExtent2D { + uint32_t width; + uint32_t height; +} VkExtent2D; + +typedef struct VkExtent3D { + uint32_t width; + uint32_t height; + uint32_t depth; +} VkExtent3D; + +typedef struct VkOffset2D { + int32_t x; + int32_t y; +} VkOffset2D; + +typedef struct VkOffset3D { + int32_t x; + int32_t y; + int32_t z; +} VkOffset3D; + +typedef struct VkRect2D { + VkOffset2D offset; + VkExtent2D extent; +} VkRect2D; + +typedef struct VkBaseInStructure { + VkStructureType sType; + const struct VkBaseInStructure* pNext; +} VkBaseInStructure; + +typedef struct VkBaseOutStructure { + VkStructureType sType; + struct VkBaseOutStructure* pNext; +} VkBaseOutStructure; + +typedef struct VkBufferMemoryBarrier { + VkStructureType sType; + const void* pNext; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + uint32_t srcQueueFamilyIndex; + uint32_t dstQueueFamilyIndex; + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize size; +} VkBufferMemoryBarrier; + +typedef struct VkDispatchIndirectCommand { + uint32_t x; + uint32_t y; + uint32_t z; +} VkDispatchIndirectCommand; + +typedef struct VkDrawIndexedIndirectCommand { + uint32_t indexCount; + uint32_t instanceCount; + uint32_t firstIndex; + int32_t vertexOffset; + uint32_t firstInstance; +} VkDrawIndexedIndirectCommand; + +typedef struct VkDrawIndirectCommand { + uint32_t vertexCount; + uint32_t instanceCount; + uint32_t firstVertex; + uint32_t firstInstance; +} VkDrawIndirectCommand; + +typedef struct VkImageSubresourceRange { + VkImageAspectFlags aspectMask; + uint32_t baseMipLevel; + uint32_t levelCount; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkImageSubresourceRange; + +typedef struct VkImageMemoryBarrier { + VkStructureType sType; + const void* pNext; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + VkImageLayout oldLayout; + VkImageLayout newLayout; + uint32_t srcQueueFamilyIndex; + uint32_t dstQueueFamilyIndex; + VkImage image; + VkImageSubresourceRange subresourceRange; +} VkImageMemoryBarrier; + +typedef struct VkMemoryBarrier { + VkStructureType sType; + const void* pNext; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; +} VkMemoryBarrier; + +typedef struct VkPipelineCacheHeaderVersionOne { + uint32_t headerSize; + VkPipelineCacheHeaderVersion headerVersion; + uint32_t vendorID; + uint32_t deviceID; + uint8_t pipelineCacheUUID[VK_UUID_SIZE]; +} VkPipelineCacheHeaderVersionOne; + +typedef void* (VKAPI_PTR *PFN_vkAllocationFunction)( + void* pUserData, + size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope); + +typedef void (VKAPI_PTR *PFN_vkFreeFunction)( + void* pUserData, + void* pMemory); + +typedef void (VKAPI_PTR *PFN_vkInternalAllocationNotification)( + void* pUserData, + size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + +typedef void (VKAPI_PTR *PFN_vkInternalFreeNotification)( + void* pUserData, + size_t size, + VkInternalAllocationType allocationType, + VkSystemAllocationScope allocationScope); + +typedef void* (VKAPI_PTR *PFN_vkReallocationFunction)( + void* pUserData, + void* pOriginal, + size_t size, + size_t alignment, + VkSystemAllocationScope allocationScope); + +typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void); +typedef struct VkAllocationCallbacks { + void* pUserData; + PFN_vkAllocationFunction pfnAllocation; + PFN_vkReallocationFunction pfnReallocation; + PFN_vkFreeFunction pfnFree; + PFN_vkInternalAllocationNotification pfnInternalAllocation; + PFN_vkInternalFreeNotification pfnInternalFree; +} VkAllocationCallbacks; + +typedef struct VkApplicationInfo { + VkStructureType sType; + const void* pNext; + const char* pApplicationName; + uint32_t applicationVersion; + const char* pEngineName; + uint32_t engineVersion; + uint32_t apiVersion; +} VkApplicationInfo; + +typedef struct VkFormatProperties { + VkFormatFeatureFlags linearTilingFeatures; + VkFormatFeatureFlags optimalTilingFeatures; + VkFormatFeatureFlags bufferFeatures; +} VkFormatProperties; + +typedef struct VkImageFormatProperties { + VkExtent3D maxExtent; + uint32_t maxMipLevels; + uint32_t maxArrayLayers; + VkSampleCountFlags sampleCounts; + VkDeviceSize maxResourceSize; +} VkImageFormatProperties; + +typedef struct VkInstanceCreateInfo { + VkStructureType sType; + const void* pNext; + VkInstanceCreateFlags flags; + const VkApplicationInfo* pApplicationInfo; + uint32_t enabledLayerCount; + const char* const* ppEnabledLayerNames; + uint32_t enabledExtensionCount; + const char* const* ppEnabledExtensionNames; +} VkInstanceCreateInfo; + +typedef struct VkMemoryHeap { + VkDeviceSize size; + VkMemoryHeapFlags flags; +} VkMemoryHeap; + +typedef struct VkMemoryType { + VkMemoryPropertyFlags propertyFlags; + uint32_t heapIndex; +} VkMemoryType; + +typedef struct VkPhysicalDeviceFeatures { + VkBool32 robustBufferAccess; + VkBool32 fullDrawIndexUint32; + VkBool32 imageCubeArray; + VkBool32 independentBlend; + VkBool32 geometryShader; + VkBool32 tessellationShader; + VkBool32 sampleRateShading; + VkBool32 dualSrcBlend; + VkBool32 logicOp; + VkBool32 multiDrawIndirect; + VkBool32 drawIndirectFirstInstance; + VkBool32 depthClamp; + VkBool32 depthBiasClamp; + VkBool32 fillModeNonSolid; + VkBool32 depthBounds; + VkBool32 wideLines; + VkBool32 largePoints; + VkBool32 alphaToOne; + VkBool32 multiViewport; + VkBool32 samplerAnisotropy; + VkBool32 textureCompressionETC2; + VkBool32 textureCompressionASTC_LDR; + VkBool32 textureCompressionBC; + VkBool32 occlusionQueryPrecise; + VkBool32 pipelineStatisticsQuery; + VkBool32 vertexPipelineStoresAndAtomics; + VkBool32 fragmentStoresAndAtomics; + VkBool32 shaderTessellationAndGeometryPointSize; + VkBool32 shaderImageGatherExtended; + VkBool32 shaderStorageImageExtendedFormats; + VkBool32 shaderStorageImageMultisample; + VkBool32 shaderStorageImageReadWithoutFormat; + VkBool32 shaderStorageImageWriteWithoutFormat; + VkBool32 shaderUniformBufferArrayDynamicIndexing; + VkBool32 shaderSampledImageArrayDynamicIndexing; + VkBool32 shaderStorageBufferArrayDynamicIndexing; + VkBool32 shaderStorageImageArrayDynamicIndexing; + VkBool32 shaderClipDistance; + VkBool32 shaderCullDistance; + VkBool32 shaderFloat64; + VkBool32 shaderInt64; + VkBool32 shaderInt16; + VkBool32 shaderResourceResidency; + VkBool32 shaderResourceMinLod; + VkBool32 sparseBinding; + VkBool32 sparseResidencyBuffer; + VkBool32 sparseResidencyImage2D; + VkBool32 sparseResidencyImage3D; + VkBool32 sparseResidency2Samples; + VkBool32 sparseResidency4Samples; + VkBool32 sparseResidency8Samples; + VkBool32 sparseResidency16Samples; + VkBool32 sparseResidencyAliased; + VkBool32 variableMultisampleRate; + VkBool32 inheritedQueries; +} VkPhysicalDeviceFeatures; + +typedef struct VkPhysicalDeviceLimits { + uint32_t maxImageDimension1D; + uint32_t maxImageDimension2D; + uint32_t maxImageDimension3D; + uint32_t maxImageDimensionCube; + uint32_t maxImageArrayLayers; + uint32_t maxTexelBufferElements; + uint32_t maxUniformBufferRange; + uint32_t maxStorageBufferRange; + uint32_t maxPushConstantsSize; + uint32_t maxMemoryAllocationCount; + uint32_t maxSamplerAllocationCount; + VkDeviceSize bufferImageGranularity; + VkDeviceSize sparseAddressSpaceSize; + uint32_t maxBoundDescriptorSets; + uint32_t maxPerStageDescriptorSamplers; + uint32_t maxPerStageDescriptorUniformBuffers; + uint32_t maxPerStageDescriptorStorageBuffers; + uint32_t maxPerStageDescriptorSampledImages; + uint32_t maxPerStageDescriptorStorageImages; + uint32_t maxPerStageDescriptorInputAttachments; + uint32_t maxPerStageResources; + uint32_t maxDescriptorSetSamplers; + uint32_t maxDescriptorSetUniformBuffers; + uint32_t maxDescriptorSetUniformBuffersDynamic; + uint32_t maxDescriptorSetStorageBuffers; + uint32_t maxDescriptorSetStorageBuffersDynamic; + uint32_t maxDescriptorSetSampledImages; + uint32_t maxDescriptorSetStorageImages; + uint32_t maxDescriptorSetInputAttachments; + uint32_t maxVertexInputAttributes; + uint32_t maxVertexInputBindings; + uint32_t maxVertexInputAttributeOffset; + uint32_t maxVertexInputBindingStride; + uint32_t maxVertexOutputComponents; + uint32_t maxTessellationGenerationLevel; + uint32_t maxTessellationPatchSize; + uint32_t maxTessellationControlPerVertexInputComponents; + uint32_t maxTessellationControlPerVertexOutputComponents; + uint32_t maxTessellationControlPerPatchOutputComponents; + uint32_t maxTessellationControlTotalOutputComponents; + uint32_t maxTessellationEvaluationInputComponents; + uint32_t maxTessellationEvaluationOutputComponents; + uint32_t maxGeometryShaderInvocations; + uint32_t maxGeometryInputComponents; + uint32_t maxGeometryOutputComponents; + uint32_t maxGeometryOutputVertices; + uint32_t maxGeometryTotalOutputComponents; + uint32_t maxFragmentInputComponents; + uint32_t maxFragmentOutputAttachments; + uint32_t maxFragmentDualSrcAttachments; + uint32_t maxFragmentCombinedOutputResources; + uint32_t maxComputeSharedMemorySize; + uint32_t maxComputeWorkGroupCount[3]; + uint32_t maxComputeWorkGroupInvocations; + uint32_t maxComputeWorkGroupSize[3]; + uint32_t subPixelPrecisionBits; + uint32_t subTexelPrecisionBits; + uint32_t mipmapPrecisionBits; + uint32_t maxDrawIndexedIndexValue; + uint32_t maxDrawIndirectCount; + float maxSamplerLodBias; + float maxSamplerAnisotropy; + uint32_t maxViewports; + uint32_t maxViewportDimensions[2]; + float viewportBoundsRange[2]; + uint32_t viewportSubPixelBits; + size_t minMemoryMapAlignment; + VkDeviceSize minTexelBufferOffsetAlignment; + VkDeviceSize minUniformBufferOffsetAlignment; + VkDeviceSize minStorageBufferOffsetAlignment; + int32_t minTexelOffset; + uint32_t maxTexelOffset; + int32_t minTexelGatherOffset; + uint32_t maxTexelGatherOffset; + float minInterpolationOffset; + float maxInterpolationOffset; + uint32_t subPixelInterpolationOffsetBits; + uint32_t maxFramebufferWidth; + uint32_t maxFramebufferHeight; + uint32_t maxFramebufferLayers; + VkSampleCountFlags framebufferColorSampleCounts; + VkSampleCountFlags framebufferDepthSampleCounts; + VkSampleCountFlags framebufferStencilSampleCounts; + VkSampleCountFlags framebufferNoAttachmentsSampleCounts; + uint32_t maxColorAttachments; + VkSampleCountFlags sampledImageColorSampleCounts; + VkSampleCountFlags sampledImageIntegerSampleCounts; + VkSampleCountFlags sampledImageDepthSampleCounts; + VkSampleCountFlags sampledImageStencilSampleCounts; + VkSampleCountFlags storageImageSampleCounts; + uint32_t maxSampleMaskWords; + VkBool32 timestampComputeAndGraphics; + float timestampPeriod; + uint32_t maxClipDistances; + uint32_t maxCullDistances; + uint32_t maxCombinedClipAndCullDistances; + uint32_t discreteQueuePriorities; + float pointSizeRange[2]; + float lineWidthRange[2]; + float pointSizeGranularity; + float lineWidthGranularity; + VkBool32 strictLines; + VkBool32 standardSampleLocations; + VkDeviceSize optimalBufferCopyOffsetAlignment; + VkDeviceSize optimalBufferCopyRowPitchAlignment; + VkDeviceSize nonCoherentAtomSize; +} VkPhysicalDeviceLimits; + +typedef struct VkPhysicalDeviceMemoryProperties { + uint32_t memoryTypeCount; + VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES]; + uint32_t memoryHeapCount; + VkMemoryHeap memoryHeaps[VK_MAX_MEMORY_HEAPS]; +} VkPhysicalDeviceMemoryProperties; + +typedef struct VkPhysicalDeviceSparseProperties { + VkBool32 residencyStandard2DBlockShape; + VkBool32 residencyStandard2DMultisampleBlockShape; + VkBool32 residencyStandard3DBlockShape; + VkBool32 residencyAlignedMipSize; + VkBool32 residencyNonResidentStrict; +} VkPhysicalDeviceSparseProperties; + +typedef struct VkPhysicalDeviceProperties { + uint32_t apiVersion; + uint32_t driverVersion; + uint32_t vendorID; + uint32_t deviceID; + VkPhysicalDeviceType deviceType; + char deviceName[VK_MAX_PHYSICAL_DEVICE_NAME_SIZE]; + uint8_t pipelineCacheUUID[VK_UUID_SIZE]; + VkPhysicalDeviceLimits limits; + VkPhysicalDeviceSparseProperties sparseProperties; +} VkPhysicalDeviceProperties; + +typedef struct VkQueueFamilyProperties { + VkQueueFlags queueFlags; + uint32_t queueCount; + uint32_t timestampValidBits; + VkExtent3D minImageTransferGranularity; +} VkQueueFamilyProperties; + +typedef struct VkDeviceQueueCreateInfo { + VkStructureType sType; + const void* pNext; + VkDeviceQueueCreateFlags flags; + uint32_t queueFamilyIndex; + uint32_t queueCount; + const float* pQueuePriorities; +} VkDeviceQueueCreateInfo; + +typedef struct VkDeviceCreateInfo { + VkStructureType sType; + const void* pNext; + VkDeviceCreateFlags flags; + uint32_t queueCreateInfoCount; + const VkDeviceQueueCreateInfo* pQueueCreateInfos; + uint32_t enabledLayerCount; + const char* const* ppEnabledLayerNames; + uint32_t enabledExtensionCount; + const char* const* ppEnabledExtensionNames; + const VkPhysicalDeviceFeatures* pEnabledFeatures; +} VkDeviceCreateInfo; + +typedef struct VkExtensionProperties { + char extensionName[VK_MAX_EXTENSION_NAME_SIZE]; + uint32_t specVersion; +} VkExtensionProperties; + +typedef struct VkLayerProperties { + char layerName[VK_MAX_EXTENSION_NAME_SIZE]; + uint32_t specVersion; + uint32_t implementationVersion; + char description[VK_MAX_DESCRIPTION_SIZE]; +} VkLayerProperties; + +typedef struct VkSubmitInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const VkSemaphore* pWaitSemaphores; + const VkPipelineStageFlags* pWaitDstStageMask; + uint32_t commandBufferCount; + const VkCommandBuffer* pCommandBuffers; + uint32_t signalSemaphoreCount; + const VkSemaphore* pSignalSemaphores; +} VkSubmitInfo; + +typedef struct VkMappedMemoryRange { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkDeviceSize offset; + VkDeviceSize size; +} VkMappedMemoryRange; + +typedef struct VkMemoryAllocateInfo { + VkStructureType sType; + const void* pNext; + VkDeviceSize allocationSize; + uint32_t memoryTypeIndex; +} VkMemoryAllocateInfo; + +typedef struct VkMemoryRequirements { + VkDeviceSize size; + VkDeviceSize alignment; + uint32_t memoryTypeBits; +} VkMemoryRequirements; + +typedef struct VkSparseMemoryBind { + VkDeviceSize resourceOffset; + VkDeviceSize size; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + VkSparseMemoryBindFlags flags; +} VkSparseMemoryBind; + +typedef struct VkSparseBufferMemoryBindInfo { + VkBuffer buffer; + uint32_t bindCount; + const VkSparseMemoryBind* pBinds; +} VkSparseBufferMemoryBindInfo; + +typedef struct VkSparseImageOpaqueMemoryBindInfo { + VkImage image; + uint32_t bindCount; + const VkSparseMemoryBind* pBinds; +} VkSparseImageOpaqueMemoryBindInfo; + +typedef struct VkImageSubresource { + VkImageAspectFlags aspectMask; + uint32_t mipLevel; + uint32_t arrayLayer; +} VkImageSubresource; + +typedef struct VkSparseImageMemoryBind { + VkImageSubresource subresource; + VkOffset3D offset; + VkExtent3D extent; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + VkSparseMemoryBindFlags flags; +} VkSparseImageMemoryBind; + +typedef struct VkSparseImageMemoryBindInfo { + VkImage image; + uint32_t bindCount; + const VkSparseImageMemoryBind* pBinds; +} VkSparseImageMemoryBindInfo; + +typedef struct VkBindSparseInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const VkSemaphore* pWaitSemaphores; + uint32_t bufferBindCount; + const VkSparseBufferMemoryBindInfo* pBufferBinds; + uint32_t imageOpaqueBindCount; + const VkSparseImageOpaqueMemoryBindInfo* pImageOpaqueBinds; + uint32_t imageBindCount; + const VkSparseImageMemoryBindInfo* pImageBinds; + uint32_t signalSemaphoreCount; + const VkSemaphore* pSignalSemaphores; +} VkBindSparseInfo; + +typedef struct VkSparseImageFormatProperties { + VkImageAspectFlags aspectMask; + VkExtent3D imageGranularity; + VkSparseImageFormatFlags flags; +} VkSparseImageFormatProperties; + +typedef struct VkSparseImageMemoryRequirements { + VkSparseImageFormatProperties formatProperties; + uint32_t imageMipTailFirstLod; + VkDeviceSize imageMipTailSize; + VkDeviceSize imageMipTailOffset; + VkDeviceSize imageMipTailStride; +} VkSparseImageMemoryRequirements; + +typedef struct VkFenceCreateInfo { + VkStructureType sType; + const void* pNext; + VkFenceCreateFlags flags; +} VkFenceCreateInfo; + +typedef struct VkSemaphoreCreateInfo { + VkStructureType sType; + const void* pNext; + VkSemaphoreCreateFlags flags; +} VkSemaphoreCreateInfo; + +typedef struct VkEventCreateInfo { + VkStructureType sType; + const void* pNext; + VkEventCreateFlags flags; +} VkEventCreateInfo; + +typedef struct VkQueryPoolCreateInfo { + VkStructureType sType; + const void* pNext; + VkQueryPoolCreateFlags flags; + VkQueryType queryType; + uint32_t queryCount; + VkQueryPipelineStatisticFlags pipelineStatistics; +} VkQueryPoolCreateInfo; + +typedef struct VkBufferCreateInfo { + VkStructureType sType; + const void* pNext; + VkBufferCreateFlags flags; + VkDeviceSize size; + VkBufferUsageFlags usage; + VkSharingMode sharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; +} VkBufferCreateInfo; + +typedef struct VkBufferViewCreateInfo { + VkStructureType sType; + const void* pNext; + VkBufferViewCreateFlags flags; + VkBuffer buffer; + VkFormat format; + VkDeviceSize offset; + VkDeviceSize range; +} VkBufferViewCreateInfo; + +typedef struct VkImageCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageCreateFlags flags; + VkImageType imageType; + VkFormat format; + VkExtent3D extent; + uint32_t mipLevels; + uint32_t arrayLayers; + VkSampleCountFlagBits samples; + VkImageTiling tiling; + VkImageUsageFlags usage; + VkSharingMode sharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; + VkImageLayout initialLayout; +} VkImageCreateInfo; + +typedef struct VkSubresourceLayout { + VkDeviceSize offset; + VkDeviceSize size; + VkDeviceSize rowPitch; + VkDeviceSize arrayPitch; + VkDeviceSize depthPitch; +} VkSubresourceLayout; + +typedef struct VkComponentMapping { + VkComponentSwizzle r; + VkComponentSwizzle g; + VkComponentSwizzle b; + VkComponentSwizzle a; +} VkComponentMapping; + +typedef struct VkImageViewCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageViewCreateFlags flags; + VkImage image; + VkImageViewType viewType; + VkFormat format; + VkComponentMapping components; + VkImageSubresourceRange subresourceRange; +} VkImageViewCreateInfo; + +typedef struct VkShaderModuleCreateInfo { + VkStructureType sType; + const void* pNext; + VkShaderModuleCreateFlags flags; + size_t codeSize; + const uint32_t* pCode; +} VkShaderModuleCreateInfo; + +typedef struct VkPipelineCacheCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineCacheCreateFlags flags; + size_t initialDataSize; + const void* pInitialData; +} VkPipelineCacheCreateInfo; + +typedef struct VkSpecializationMapEntry { + uint32_t constantID; + uint32_t offset; + size_t size; +} VkSpecializationMapEntry; + +typedef struct VkSpecializationInfo { + uint32_t mapEntryCount; + const VkSpecializationMapEntry* pMapEntries; + size_t dataSize; + const void* pData; +} VkSpecializationInfo; + +typedef struct VkPipelineShaderStageCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineShaderStageCreateFlags flags; + VkShaderStageFlagBits stage; + VkShaderModule module; + const char* pName; + const VkSpecializationInfo* pSpecializationInfo; +} VkPipelineShaderStageCreateInfo; + +typedef struct VkComputePipelineCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + VkPipelineShaderStageCreateInfo stage; + VkPipelineLayout layout; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkComputePipelineCreateInfo; + +typedef struct VkVertexInputBindingDescription { + uint32_t binding; + uint32_t stride; + VkVertexInputRate inputRate; +} VkVertexInputBindingDescription; + +typedef struct VkVertexInputAttributeDescription { + uint32_t location; + uint32_t binding; + VkFormat format; + uint32_t offset; +} VkVertexInputAttributeDescription; + +typedef struct VkPipelineVertexInputStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineVertexInputStateCreateFlags flags; + uint32_t vertexBindingDescriptionCount; + const VkVertexInputBindingDescription* pVertexBindingDescriptions; + uint32_t vertexAttributeDescriptionCount; + const VkVertexInputAttributeDescription* pVertexAttributeDescriptions; +} VkPipelineVertexInputStateCreateInfo; + +typedef struct VkPipelineInputAssemblyStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineInputAssemblyStateCreateFlags flags; + VkPrimitiveTopology topology; + VkBool32 primitiveRestartEnable; +} VkPipelineInputAssemblyStateCreateInfo; + +typedef struct VkPipelineTessellationStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineTessellationStateCreateFlags flags; + uint32_t patchControlPoints; +} VkPipelineTessellationStateCreateInfo; + +typedef struct VkViewport { + float x; + float y; + float width; + float height; + float minDepth; + float maxDepth; +} VkViewport; + +typedef struct VkPipelineViewportStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineViewportStateCreateFlags flags; + uint32_t viewportCount; + const VkViewport* pViewports; + uint32_t scissorCount; + const VkRect2D* pScissors; +} VkPipelineViewportStateCreateInfo; + +typedef struct VkPipelineRasterizationStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationStateCreateFlags flags; + VkBool32 depthClampEnable; + VkBool32 rasterizerDiscardEnable; + VkPolygonMode polygonMode; + VkCullModeFlags cullMode; + VkFrontFace frontFace; + VkBool32 depthBiasEnable; + float depthBiasConstantFactor; + float depthBiasClamp; + float depthBiasSlopeFactor; + float lineWidth; +} VkPipelineRasterizationStateCreateInfo; + +typedef struct VkPipelineMultisampleStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineMultisampleStateCreateFlags flags; + VkSampleCountFlagBits rasterizationSamples; + VkBool32 sampleShadingEnable; + float minSampleShading; + const VkSampleMask* pSampleMask; + VkBool32 alphaToCoverageEnable; + VkBool32 alphaToOneEnable; +} VkPipelineMultisampleStateCreateInfo; + +typedef struct VkStencilOpState { + VkStencilOp failOp; + VkStencilOp passOp; + VkStencilOp depthFailOp; + VkCompareOp compareOp; + uint32_t compareMask; + uint32_t writeMask; + uint32_t reference; +} VkStencilOpState; + +typedef struct VkPipelineDepthStencilStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineDepthStencilStateCreateFlags flags; + VkBool32 depthTestEnable; + VkBool32 depthWriteEnable; + VkCompareOp depthCompareOp; + VkBool32 depthBoundsTestEnable; + VkBool32 stencilTestEnable; + VkStencilOpState front; + VkStencilOpState back; + float minDepthBounds; + float maxDepthBounds; +} VkPipelineDepthStencilStateCreateInfo; + +typedef struct VkPipelineColorBlendAttachmentState { + VkBool32 blendEnable; + VkBlendFactor srcColorBlendFactor; + VkBlendFactor dstColorBlendFactor; + VkBlendOp colorBlendOp; + VkBlendFactor srcAlphaBlendFactor; + VkBlendFactor dstAlphaBlendFactor; + VkBlendOp alphaBlendOp; + VkColorComponentFlags colorWriteMask; +} VkPipelineColorBlendAttachmentState; + +typedef struct VkPipelineColorBlendStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineColorBlendStateCreateFlags flags; + VkBool32 logicOpEnable; + VkLogicOp logicOp; + uint32_t attachmentCount; + const VkPipelineColorBlendAttachmentState* pAttachments; + float blendConstants[4]; +} VkPipelineColorBlendStateCreateInfo; + +typedef struct VkPipelineDynamicStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineDynamicStateCreateFlags flags; + uint32_t dynamicStateCount; + const VkDynamicState* pDynamicStates; +} VkPipelineDynamicStateCreateInfo; + +typedef struct VkGraphicsPipelineCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + const VkPipelineVertexInputStateCreateInfo* pVertexInputState; + const VkPipelineInputAssemblyStateCreateInfo* pInputAssemblyState; + const VkPipelineTessellationStateCreateInfo* pTessellationState; + const VkPipelineViewportStateCreateInfo* pViewportState; + const VkPipelineRasterizationStateCreateInfo* pRasterizationState; + const VkPipelineMultisampleStateCreateInfo* pMultisampleState; + const VkPipelineDepthStencilStateCreateInfo* pDepthStencilState; + const VkPipelineColorBlendStateCreateInfo* pColorBlendState; + const VkPipelineDynamicStateCreateInfo* pDynamicState; + VkPipelineLayout layout; + VkRenderPass renderPass; + uint32_t subpass; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkGraphicsPipelineCreateInfo; + +typedef struct VkPushConstantRange { + VkShaderStageFlags stageFlags; + uint32_t offset; + uint32_t size; +} VkPushConstantRange; + +typedef struct VkPipelineLayoutCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineLayoutCreateFlags flags; + uint32_t setLayoutCount; + const VkDescriptorSetLayout* pSetLayouts; + uint32_t pushConstantRangeCount; + const VkPushConstantRange* pPushConstantRanges; +} VkPipelineLayoutCreateInfo; + +typedef struct VkSamplerCreateInfo { + VkStructureType sType; + const void* pNext; + VkSamplerCreateFlags flags; + VkFilter magFilter; + VkFilter minFilter; + VkSamplerMipmapMode mipmapMode; + VkSamplerAddressMode addressModeU; + VkSamplerAddressMode addressModeV; + VkSamplerAddressMode addressModeW; + float mipLodBias; + VkBool32 anisotropyEnable; + float maxAnisotropy; + VkBool32 compareEnable; + VkCompareOp compareOp; + float minLod; + float maxLod; + VkBorderColor borderColor; + VkBool32 unnormalizedCoordinates; +} VkSamplerCreateInfo; + +typedef struct VkCopyDescriptorSet { + VkStructureType sType; + const void* pNext; + VkDescriptorSet srcSet; + uint32_t srcBinding; + uint32_t srcArrayElement; + VkDescriptorSet dstSet; + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; +} VkCopyDescriptorSet; + +typedef struct VkDescriptorBufferInfo { + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize range; +} VkDescriptorBufferInfo; + +typedef struct VkDescriptorImageInfo { + VkSampler sampler; + VkImageView imageView; + VkImageLayout imageLayout; +} VkDescriptorImageInfo; + +typedef struct VkDescriptorPoolSize { + VkDescriptorType type; + uint32_t descriptorCount; +} VkDescriptorPoolSize; + +typedef struct VkDescriptorPoolCreateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorPoolCreateFlags flags; + uint32_t maxSets; + uint32_t poolSizeCount; + const VkDescriptorPoolSize* pPoolSizes; +} VkDescriptorPoolCreateInfo; + +typedef struct VkDescriptorSetAllocateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorPool descriptorPool; + uint32_t descriptorSetCount; + const VkDescriptorSetLayout* pSetLayouts; +} VkDescriptorSetAllocateInfo; + +typedef struct VkDescriptorSetLayoutBinding { + uint32_t binding; + VkDescriptorType descriptorType; + uint32_t descriptorCount; + VkShaderStageFlags stageFlags; + const VkSampler* pImmutableSamplers; +} VkDescriptorSetLayoutBinding; + +typedef struct VkDescriptorSetLayoutCreateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorSetLayoutCreateFlags flags; + uint32_t bindingCount; + const VkDescriptorSetLayoutBinding* pBindings; +} VkDescriptorSetLayoutCreateInfo; + +typedef struct VkWriteDescriptorSet { + VkStructureType sType; + const void* pNext; + VkDescriptorSet dstSet; + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; + VkDescriptorType descriptorType; + const VkDescriptorImageInfo* pImageInfo; + const VkDescriptorBufferInfo* pBufferInfo; + const VkBufferView* pTexelBufferView; +} VkWriteDescriptorSet; + +typedef struct VkAttachmentDescription { + VkAttachmentDescriptionFlags flags; + VkFormat format; + VkSampleCountFlagBits samples; + VkAttachmentLoadOp loadOp; + VkAttachmentStoreOp storeOp; + VkAttachmentLoadOp stencilLoadOp; + VkAttachmentStoreOp stencilStoreOp; + VkImageLayout initialLayout; + VkImageLayout finalLayout; +} VkAttachmentDescription; + +typedef struct VkAttachmentReference { + uint32_t attachment; + VkImageLayout layout; +} VkAttachmentReference; + +typedef struct VkFramebufferCreateInfo { + VkStructureType sType; + const void* pNext; + VkFramebufferCreateFlags flags; + VkRenderPass renderPass; + uint32_t attachmentCount; + const VkImageView* pAttachments; + uint32_t width; + uint32_t height; + uint32_t layers; +} VkFramebufferCreateInfo; + +typedef struct VkSubpassDescription { + VkSubpassDescriptionFlags flags; + VkPipelineBindPoint pipelineBindPoint; + uint32_t inputAttachmentCount; + const VkAttachmentReference* pInputAttachments; + uint32_t colorAttachmentCount; + const VkAttachmentReference* pColorAttachments; + const VkAttachmentReference* pResolveAttachments; + const VkAttachmentReference* pDepthStencilAttachment; + uint32_t preserveAttachmentCount; + const uint32_t* pPreserveAttachments; +} VkSubpassDescription; + +typedef struct VkSubpassDependency { + uint32_t srcSubpass; + uint32_t dstSubpass; + VkPipelineStageFlags srcStageMask; + VkPipelineStageFlags dstStageMask; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + VkDependencyFlags dependencyFlags; +} VkSubpassDependency; + +typedef struct VkRenderPassCreateInfo { + VkStructureType sType; + const void* pNext; + VkRenderPassCreateFlags flags; + uint32_t attachmentCount; + const VkAttachmentDescription* pAttachments; + uint32_t subpassCount; + const VkSubpassDescription* pSubpasses; + uint32_t dependencyCount; + const VkSubpassDependency* pDependencies; +} VkRenderPassCreateInfo; + +typedef struct VkCommandPoolCreateInfo { + VkStructureType sType; + const void* pNext; + VkCommandPoolCreateFlags flags; + uint32_t queueFamilyIndex; +} VkCommandPoolCreateInfo; + +typedef struct VkCommandBufferAllocateInfo { + VkStructureType sType; + const void* pNext; + VkCommandPool commandPool; + VkCommandBufferLevel level; + uint32_t commandBufferCount; +} VkCommandBufferAllocateInfo; + +typedef struct VkCommandBufferInheritanceInfo { + VkStructureType sType; + const void* pNext; + VkRenderPass renderPass; + uint32_t subpass; + VkFramebuffer framebuffer; + VkBool32 occlusionQueryEnable; + VkQueryControlFlags queryFlags; + VkQueryPipelineStatisticFlags pipelineStatistics; +} VkCommandBufferInheritanceInfo; + +typedef struct VkCommandBufferBeginInfo { + VkStructureType sType; + const void* pNext; + VkCommandBufferUsageFlags flags; + const VkCommandBufferInheritanceInfo* pInheritanceInfo; +} VkCommandBufferBeginInfo; + +typedef struct VkBufferCopy { + VkDeviceSize srcOffset; + VkDeviceSize dstOffset; + VkDeviceSize size; +} VkBufferCopy; + +typedef struct VkImageSubresourceLayers { + VkImageAspectFlags aspectMask; + uint32_t mipLevel; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkImageSubresourceLayers; + +typedef struct VkBufferImageCopy { + VkDeviceSize bufferOffset; + uint32_t bufferRowLength; + uint32_t bufferImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkBufferImageCopy; + +typedef union VkClearColorValue { + float float32[4]; + int32_t int32[4]; + uint32_t uint32[4]; +} VkClearColorValue; + +typedef struct VkClearDepthStencilValue { + float depth; + uint32_t stencil; +} VkClearDepthStencilValue; + +typedef union VkClearValue { + VkClearColorValue color; + VkClearDepthStencilValue depthStencil; +} VkClearValue; + +typedef struct VkClearAttachment { + VkImageAspectFlags aspectMask; + uint32_t colorAttachment; + VkClearValue clearValue; +} VkClearAttachment; + +typedef struct VkClearRect { + VkRect2D rect; + uint32_t baseArrayLayer; + uint32_t layerCount; +} VkClearRect; + +typedef struct VkImageBlit { + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffsets[2]; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffsets[2]; +} VkImageBlit; + +typedef struct VkImageCopy { + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; + VkExtent3D extent; +} VkImageCopy; + +typedef struct VkImageResolve { + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; + VkExtent3D extent; +} VkImageResolve; + +typedef struct VkRenderPassBeginInfo { + VkStructureType sType; + const void* pNext; + VkRenderPass renderPass; + VkFramebuffer framebuffer; + VkRect2D renderArea; + uint32_t clearValueCount; + const VkClearValue* pClearValues; +} VkRenderPassBeginInfo; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateInstance)(const VkInstanceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkInstance* pInstance); +typedef void (VKAPI_PTR *PFN_vkDestroyInstance)(VkInstance instance, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDevices)(VkInstance instance, uint32_t* pPhysicalDeviceCount, VkPhysicalDevice* pPhysicalDevices); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures* pFeatures); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties* pFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties* pImageFormatProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties* pQueueFamilyProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties* pMemoryProperties); +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddr)(VkInstance instance, const char* pName); +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetDeviceProcAddr)(VkDevice device, const char* pName); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDevice)(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDevice* pDevice); +typedef void (VKAPI_PTR *PFN_vkDestroyDevice)(VkDevice device, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceExtensionProperties)(const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceExtensionProperties)(VkPhysicalDevice physicalDevice, const char* pLayerName, uint32_t* pPropertyCount, VkExtensionProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceLayerProperties)(uint32_t* pPropertyCount, VkLayerProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateDeviceLayerProperties)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkLayerProperties* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetDeviceQueue)(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue* pQueue); +typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo* pSubmits, VkFence fence); +typedef VkResult (VKAPI_PTR *PFN_vkQueueWaitIdle)(VkQueue queue); +typedef VkResult (VKAPI_PTR *PFN_vkDeviceWaitIdle)(VkDevice device); +typedef VkResult (VKAPI_PTR *PFN_vkAllocateMemory)(VkDevice device, const VkMemoryAllocateInfo* pAllocateInfo, const VkAllocationCallbacks* pAllocator, VkDeviceMemory* pMemory); +typedef void (VKAPI_PTR *PFN_vkFreeMemory)(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkMapMemory)(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void** ppData); +typedef void (VKAPI_PTR *PFN_vkUnmapMemory)(VkDevice device, VkDeviceMemory memory); +typedef VkResult (VKAPI_PTR *PFN_vkFlushMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges); +typedef VkResult (VKAPI_PTR *PFN_vkInvalidateMappedMemoryRanges)(VkDevice device, uint32_t memoryRangeCount, const VkMappedMemoryRange* pMemoryRanges); +typedef void (VKAPI_PTR *PFN_vkGetDeviceMemoryCommitment)(VkDevice device, VkDeviceMemory memory, VkDeviceSize* pCommittedMemoryInBytes); +typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory)(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset); +typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory)(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset); +typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements)(VkDevice device, VkBuffer buffer, VkMemoryRequirements* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements)(VkDevice device, VkImage image, VkMemoryRequirements* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements)(VkDevice device, VkImage image, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements* pSparseMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t* pPropertyCount, VkSparseImageFormatProperties* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkQueueBindSparse)(VkQueue queue, uint32_t bindInfoCount, const VkBindSparseInfo* pBindInfo, VkFence fence); +typedef VkResult (VKAPI_PTR *PFN_vkCreateFence)(VkDevice device, const VkFenceCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); +typedef void (VKAPI_PTR *PFN_vkDestroyFence)(VkDevice device, VkFence fence, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkResetFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences); +typedef VkResult (VKAPI_PTR *PFN_vkGetFenceStatus)(VkDevice device, VkFence fence); +typedef VkResult (VKAPI_PTR *PFN_vkWaitForFences)(VkDevice device, uint32_t fenceCount, const VkFence* pFences, VkBool32 waitAll, uint64_t timeout); +typedef VkResult (VKAPI_PTR *PFN_vkCreateSemaphore)(VkDevice device, const VkSemaphoreCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSemaphore* pSemaphore); +typedef void (VKAPI_PTR *PFN_vkDestroySemaphore)(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateEvent)(VkDevice device, const VkEventCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkEvent* pEvent); +typedef void (VKAPI_PTR *PFN_vkDestroyEvent)(VkDevice device, VkEvent event, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetEventStatus)(VkDevice device, VkEvent event); +typedef VkResult (VKAPI_PTR *PFN_vkSetEvent)(VkDevice device, VkEvent event); +typedef VkResult (VKAPI_PTR *PFN_vkResetEvent)(VkDevice device, VkEvent event); +typedef VkResult (VKAPI_PTR *PFN_vkCreateQueryPool)(VkDevice device, const VkQueryPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkQueryPool* pQueryPool); +typedef void (VKAPI_PTR *PFN_vkDestroyQueryPool)(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetQueryPoolResults)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void* pData, VkDeviceSize stride, VkQueryResultFlags flags); +typedef VkResult (VKAPI_PTR *PFN_vkCreateBuffer)(VkDevice device, const VkBufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBuffer* pBuffer); +typedef void (VKAPI_PTR *PFN_vkDestroyBuffer)(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferView)(VkDevice device, const VkBufferViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferView* pView); +typedef void (VKAPI_PTR *PFN_vkDestroyBufferView)(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateImage)(VkDevice device, const VkImageCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImage* pImage); +typedef void (VKAPI_PTR *PFN_vkDestroyImage)(VkDevice device, VkImage image, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout)(VkDevice device, VkImage image, const VkImageSubresource* pSubresource, VkSubresourceLayout* pLayout); +typedef VkResult (VKAPI_PTR *PFN_vkCreateImageView)(VkDevice device, const VkImageViewCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkImageView* pView); +typedef void (VKAPI_PTR *PFN_vkDestroyImageView)(VkDevice device, VkImageView imageView, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateShaderModule)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkShaderModule* pShaderModule); +typedef void (VKAPI_PTR *PFN_vkDestroyShaderModule)(VkDevice device, VkShaderModule shaderModule, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineCache)(VkDevice device, const VkPipelineCacheCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineCache* pPipelineCache); +typedef void (VKAPI_PTR *PFN_vkDestroyPipelineCache)(VkDevice device, VkPipelineCache pipelineCache, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineCacheData)(VkDevice device, VkPipelineCache pipelineCache, size_t* pDataSize, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkMergePipelineCaches)(VkDevice device, VkPipelineCache dstCache, uint32_t srcCacheCount, const VkPipelineCache* pSrcCaches); +typedef VkResult (VKAPI_PTR *PFN_vkCreateGraphicsPipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef VkResult (VKAPI_PTR *PFN_vkCreateComputePipelines)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkComputePipelineCreateInfo* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef void (VKAPI_PTR *PFN_vkDestroyPipeline)(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreatePipelineLayout)(VkDevice device, const VkPipelineLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPipelineLayout* pPipelineLayout); +typedef void (VKAPI_PTR *PFN_vkDestroyPipelineLayout)(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateSampler)(VkDevice device, const VkSamplerCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSampler* pSampler); +typedef void (VKAPI_PTR *PFN_vkDestroySampler)(VkDevice device, VkSampler sampler, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorSetLayout)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorSetLayout* pSetLayout); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorSetLayout)(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorPool)(VkDevice device, const VkDescriptorPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorPool* pDescriptorPool); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkResetDescriptorPool)(VkDevice device, VkDescriptorPool descriptorPool, VkDescriptorPoolResetFlags flags); +typedef VkResult (VKAPI_PTR *PFN_vkAllocateDescriptorSets)(VkDevice device, const VkDescriptorSetAllocateInfo* pAllocateInfo, VkDescriptorSet* pDescriptorSets); +typedef VkResult (VKAPI_PTR *PFN_vkFreeDescriptorSets)(VkDevice device, VkDescriptorPool descriptorPool, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets); +typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSets)(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet* pDescriptorCopies); +typedef VkResult (VKAPI_PTR *PFN_vkCreateFramebuffer)(VkDevice device, const VkFramebufferCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkFramebuffer* pFramebuffer); +typedef void (VKAPI_PTR *PFN_vkDestroyFramebuffer)(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass)(VkDevice device, const VkRenderPassCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass); +typedef void (VKAPI_PTR *PFN_vkDestroyRenderPass)(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkGetRenderAreaGranularity)(VkDevice device, VkRenderPass renderPass, VkExtent2D* pGranularity); +typedef VkResult (VKAPI_PTR *PFN_vkCreateCommandPool)(VkDevice device, const VkCommandPoolCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCommandPool* pCommandPool); +typedef void (VKAPI_PTR *PFN_vkDestroyCommandPool)(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkResetCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolResetFlags flags); +typedef VkResult (VKAPI_PTR *PFN_vkAllocateCommandBuffers)(VkDevice device, const VkCommandBufferAllocateInfo* pAllocateInfo, VkCommandBuffer* pCommandBuffers); +typedef void (VKAPI_PTR *PFN_vkFreeCommandBuffers)(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers); +typedef VkResult (VKAPI_PTR *PFN_vkBeginCommandBuffer)(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo* pBeginInfo); +typedef VkResult (VKAPI_PTR *PFN_vkEndCommandBuffer)(VkCommandBuffer commandBuffer); +typedef VkResult (VKAPI_PTR *PFN_vkResetCommandBuffer)(VkCommandBuffer commandBuffer, VkCommandBufferResetFlags flags); +typedef void (VKAPI_PTR *PFN_vkCmdBindPipeline)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewport)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport* pViewports); +typedef void (VKAPI_PTR *PFN_vkCmdSetScissor)(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D* pScissors); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineWidth)(VkCommandBuffer commandBuffer, float lineWidth); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias)(VkCommandBuffer commandBuffer, float depthBiasConstantFactor, float depthBiasClamp, float depthBiasSlopeFactor); +typedef void (VKAPI_PTR *PFN_vkCmdSetBlendConstants)(VkCommandBuffer commandBuffer, const float blendConstants[4]); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBounds)(VkCommandBuffer commandBuffer, float minDepthBounds, float maxDepthBounds); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilCompareMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilWriteMask)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilReference)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorSets)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet* pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t* pDynamicOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdBindIndexBuffer)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType); +typedef void (VKAPI_PTR *PFN_vkCmdBindVertexBuffers)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdDraw)(VkCommandBuffer commandBuffer, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexed)(VkCommandBuffer commandBuffer, uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDispatch)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchIndirect)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); +typedef void (VKAPI_PTR *PFN_vkCmdCopyBuffer)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdBlitImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit* pRegions, VkFilter filter); +typedef void (VKAPI_PTR *PFN_vkCmdCopyBufferToImage)(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkBufferImageCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImageToBuffer)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferImageCopy* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdUpdateBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize dataSize, const void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdFillBuffer)(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data); +typedef void (VKAPI_PTR *PFN_vkCmdClearColorImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearColorValue* pColor, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); +typedef void (VKAPI_PTR *PFN_vkCmdClearDepthStencilImage)(VkCommandBuffer commandBuffer, VkImage image, VkImageLayout imageLayout, const VkClearDepthStencilValue* pDepthStencil, uint32_t rangeCount, const VkImageSubresourceRange* pRanges); +typedef void (VKAPI_PTR *PFN_vkCmdClearAttachments)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkClearAttachment* pAttachments, uint32_t rectCount, const VkClearRect* pRects); +typedef void (VKAPI_PTR *PFN_vkCmdResolveImage)(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageResolve* pRegions); +typedef void (VKAPI_PTR *PFN_vkCmdSetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); +typedef void (VKAPI_PTR *PFN_vkCmdResetEvent)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask); +typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers); +typedef void (VKAPI_PTR *PFN_vkCmdPipelineBarrier)(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier* pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier* pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier* pImageMemoryBarriers); +typedef void (VKAPI_PTR *PFN_vkCmdBeginQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags); +typedef void (VKAPI_PTR *PFN_vkCmdEndQuery)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query); +typedef void (VKAPI_PTR *PFN_vkCmdResetQueryPool)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); +typedef void (VKAPI_PTR *PFN_vkCmdWriteTimestamp)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkQueryPool queryPool, uint32_t query); +typedef void (VKAPI_PTR *PFN_vkCmdCopyQueryPoolResults)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize stride, VkQueryResultFlags flags); +typedef void (VKAPI_PTR *PFN_vkCmdPushConstants)(VkCommandBuffer commandBuffer, VkPipelineLayout layout, VkShaderStageFlags stageFlags, uint32_t offset, uint32_t size, const void* pValues); +typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, VkSubpassContents contents); +typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass)(VkCommandBuffer commandBuffer, VkSubpassContents contents); +typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass)(VkCommandBuffer commandBuffer); +typedef void (VKAPI_PTR *PFN_vkCmdExecuteCommands)(VkCommandBuffer commandBuffer, uint32_t commandBufferCount, const VkCommandBuffer* pCommandBuffers); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateInstance( + const VkInstanceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkInstance* pInstance); + +VKAPI_ATTR void VKAPI_CALL vkDestroyInstance( + VkInstance instance, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDevices( + VkInstance instance, + uint32_t* pPhysicalDeviceCount, + VkPhysicalDevice* pPhysicalDevices); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceFeatures* pFeatures); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkFormatProperties* pFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkImageTiling tiling, + VkImageUsageFlags usage, + VkImageCreateFlags flags, + VkImageFormatProperties* pImageFormatProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties( + VkPhysicalDevice physicalDevice, + uint32_t* pQueueFamilyPropertyCount, + VkQueueFamilyProperties* pQueueFamilyProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties* pMemoryProperties); + +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr( + VkInstance instance, + const char* pName); + +VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr( + VkDevice device, + const char* pName); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDevice( + VkPhysicalDevice physicalDevice, + const VkDeviceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDevice* pDevice); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDevice( + VkDevice device, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties( + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties( + VkPhysicalDevice physicalDevice, + const char* pLayerName, + uint32_t* pPropertyCount, + VkExtensionProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceLayerProperties( + uint32_t* pPropertyCount, + VkLayerProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkLayerProperties* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue( + VkDevice device, + uint32_t queueFamilyIndex, + uint32_t queueIndex, + VkQueue* pQueue); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit( + VkQueue queue, + uint32_t submitCount, + const VkSubmitInfo* pSubmits, + VkFence fence); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueWaitIdle( + VkQueue queue); + +VKAPI_ATTR VkResult VKAPI_CALL vkDeviceWaitIdle( + VkDevice device); + +VKAPI_ATTR VkResult VKAPI_CALL vkAllocateMemory( + VkDevice device, + const VkMemoryAllocateInfo* pAllocateInfo, + const VkAllocationCallbacks* pAllocator, + VkDeviceMemory* pMemory); + +VKAPI_ATTR void VKAPI_CALL vkFreeMemory( + VkDevice device, + VkDeviceMemory memory, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory( + VkDevice device, + VkDeviceMemory memory, + VkDeviceSize offset, + VkDeviceSize size, + VkMemoryMapFlags flags, + void** ppData); + +VKAPI_ATTR void VKAPI_CALL vkUnmapMemory( + VkDevice device, + VkDeviceMemory memory); + +VKAPI_ATTR VkResult VKAPI_CALL vkFlushMappedMemoryRanges( + VkDevice device, + uint32_t memoryRangeCount, + const VkMappedMemoryRange* pMemoryRanges); + +VKAPI_ATTR VkResult VKAPI_CALL vkInvalidateMappedMemoryRanges( + VkDevice device, + uint32_t memoryRangeCount, + const VkMappedMemoryRange* pMemoryRanges); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceMemoryCommitment( + VkDevice device, + VkDeviceMemory memory, + VkDeviceSize* pCommittedMemoryInBytes); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory( + VkDevice device, + VkBuffer buffer, + VkDeviceMemory memory, + VkDeviceSize memoryOffset); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory( + VkDevice device, + VkImage image, + VkDeviceMemory memory, + VkDeviceSize memoryOffset); + +VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements( + VkDevice device, + VkBuffer buffer, + VkMemoryRequirements* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements( + VkDevice device, + VkImage image, + VkMemoryRequirements* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements( + VkDevice device, + VkImage image, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements* pSparseMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkSampleCountFlagBits samples, + VkImageUsageFlags usage, + VkImageTiling tiling, + uint32_t* pPropertyCount, + VkSparseImageFormatProperties* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueBindSparse( + VkQueue queue, + uint32_t bindInfoCount, + const VkBindSparseInfo* pBindInfo, + VkFence fence); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateFence( + VkDevice device, + const VkFenceCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkFence* pFence); + +VKAPI_ATTR void VKAPI_CALL vkDestroyFence( + VkDevice device, + VkFence fence, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetFences( + VkDevice device, + uint32_t fenceCount, + const VkFence* pFences); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceStatus( + VkDevice device, + VkFence fence); + +VKAPI_ATTR VkResult VKAPI_CALL vkWaitForFences( + VkDevice device, + uint32_t fenceCount, + const VkFence* pFences, + VkBool32 waitAll, + uint64_t timeout); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSemaphore( + VkDevice device, + const VkSemaphoreCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSemaphore* pSemaphore); + +VKAPI_ATTR void VKAPI_CALL vkDestroySemaphore( + VkDevice device, + VkSemaphore semaphore, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateEvent( + VkDevice device, + const VkEventCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkEvent* pEvent); + +VKAPI_ATTR void VKAPI_CALL vkDestroyEvent( + VkDevice device, + VkEvent event, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetEventStatus( + VkDevice device, + VkEvent event); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetEvent( + VkDevice device, + VkEvent event); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetEvent( + VkDevice device, + VkEvent event); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateQueryPool( + VkDevice device, + const VkQueryPoolCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkQueryPool* pQueryPool); + +VKAPI_ATTR void VKAPI_CALL vkDestroyQueryPool( + VkDevice device, + VkQueryPool queryPool, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetQueryPoolResults( + VkDevice device, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount, + size_t dataSize, + void* pData, + VkDeviceSize stride, + VkQueryResultFlags flags); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateBuffer( + VkDevice device, + const VkBufferCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkBuffer* pBuffer); + +VKAPI_ATTR void VKAPI_CALL vkDestroyBuffer( + VkDevice device, + VkBuffer buffer, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferView( + VkDevice device, + const VkBufferViewCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkBufferView* pView); + +VKAPI_ATTR void VKAPI_CALL vkDestroyBufferView( + VkDevice device, + VkBufferView bufferView, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateImage( + VkDevice device, + const VkImageCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkImage* pImage); + +VKAPI_ATTR void VKAPI_CALL vkDestroyImage( + VkDevice device, + VkImage image, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout( + VkDevice device, + VkImage image, + const VkImageSubresource* pSubresource, + VkSubresourceLayout* pLayout); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateImageView( + VkDevice device, + const VkImageViewCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkImageView* pView); + +VKAPI_ATTR void VKAPI_CALL vkDestroyImageView( + VkDevice device, + VkImageView imageView, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateShaderModule( + VkDevice device, + const VkShaderModuleCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkShaderModule* pShaderModule); + +VKAPI_ATTR void VKAPI_CALL vkDestroyShaderModule( + VkDevice device, + VkShaderModule shaderModule, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineCache( + VkDevice device, + const VkPipelineCacheCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkPipelineCache* pPipelineCache); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineCache( + VkDevice device, + VkPipelineCache pipelineCache, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineCacheData( + VkDevice device, + VkPipelineCache pipelineCache, + size_t* pDataSize, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkMergePipelineCaches( + VkDevice device, + VkPipelineCache dstCache, + uint32_t srcCacheCount, + const VkPipelineCache* pSrcCaches); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateGraphicsPipelines( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkGraphicsPipelineCreateInfo* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateComputePipelines( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkComputePipelineCreateInfo* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPipeline( + VkDevice device, + VkPipeline pipeline, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreatePipelineLayout( + VkDevice device, + const VkPipelineLayoutCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkPipelineLayout* pPipelineLayout); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPipelineLayout( + VkDevice device, + VkPipelineLayout pipelineLayout, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSampler( + VkDevice device, + const VkSamplerCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSampler* pSampler); + +VKAPI_ATTR void VKAPI_CALL vkDestroySampler( + VkDevice device, + VkSampler sampler, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorSetLayout( + VkDevice device, + const VkDescriptorSetLayoutCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorSetLayout* pSetLayout); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorSetLayout( + VkDevice device, + VkDescriptorSetLayout descriptorSetLayout, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorPool( + VkDevice device, + const VkDescriptorPoolCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorPool* pDescriptorPool); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorPool( + VkDevice device, + VkDescriptorPool descriptorPool, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetDescriptorPool( + VkDevice device, + VkDescriptorPool descriptorPool, + VkDescriptorPoolResetFlags flags); + +VKAPI_ATTR VkResult VKAPI_CALL vkAllocateDescriptorSets( + VkDevice device, + const VkDescriptorSetAllocateInfo* pAllocateInfo, + VkDescriptorSet* pDescriptorSets); + +VKAPI_ATTR VkResult VKAPI_CALL vkFreeDescriptorSets( + VkDevice device, + VkDescriptorPool descriptorPool, + uint32_t descriptorSetCount, + const VkDescriptorSet* pDescriptorSets); + +VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSets( + VkDevice device, + uint32_t descriptorWriteCount, + const VkWriteDescriptorSet* pDescriptorWrites, + uint32_t descriptorCopyCount, + const VkCopyDescriptorSet* pDescriptorCopies); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateFramebuffer( + VkDevice device, + const VkFramebufferCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkFramebuffer* pFramebuffer); + +VKAPI_ATTR void VKAPI_CALL vkDestroyFramebuffer( + VkDevice device, + VkFramebuffer framebuffer, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass( + VkDevice device, + const VkRenderPassCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkRenderPass* pRenderPass); + +VKAPI_ATTR void VKAPI_CALL vkDestroyRenderPass( + VkDevice device, + VkRenderPass renderPass, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkGetRenderAreaGranularity( + VkDevice device, + VkRenderPass renderPass, + VkExtent2D* pGranularity); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCommandPool( + VkDevice device, + const VkCommandPoolCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCommandPool* pCommandPool); + +VKAPI_ATTR void VKAPI_CALL vkDestroyCommandPool( + VkDevice device, + VkCommandPool commandPool, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandPool( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolResetFlags flags); + +VKAPI_ATTR VkResult VKAPI_CALL vkAllocateCommandBuffers( + VkDevice device, + const VkCommandBufferAllocateInfo* pAllocateInfo, + VkCommandBuffer* pCommandBuffers); + +VKAPI_ATTR void VKAPI_CALL vkFreeCommandBuffers( + VkDevice device, + VkCommandPool commandPool, + uint32_t commandBufferCount, + const VkCommandBuffer* pCommandBuffers); + +VKAPI_ATTR VkResult VKAPI_CALL vkBeginCommandBuffer( + VkCommandBuffer commandBuffer, + const VkCommandBufferBeginInfo* pBeginInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkEndCommandBuffer( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR VkResult VKAPI_CALL vkResetCommandBuffer( + VkCommandBuffer commandBuffer, + VkCommandBufferResetFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindPipeline( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipeline pipeline); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewport( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewport* pViewports); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetScissor( + VkCommandBuffer commandBuffer, + uint32_t firstScissor, + uint32_t scissorCount, + const VkRect2D* pScissors); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineWidth( + VkCommandBuffer commandBuffer, + float lineWidth); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias( + VkCommandBuffer commandBuffer, + float depthBiasConstantFactor, + float depthBiasClamp, + float depthBiasSlopeFactor); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetBlendConstants( + VkCommandBuffer commandBuffer, + const float blendConstants[4]); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBounds( + VkCommandBuffer commandBuffer, + float minDepthBounds, + float maxDepthBounds); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilCompareMask( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t compareMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilWriteMask( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t writeMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilReference( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + uint32_t reference); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t firstSet, + uint32_t descriptorSetCount, + const VkDescriptorSet* pDescriptorSets, + uint32_t dynamicOffsetCount, + const uint32_t* pDynamicOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkIndexType indexType); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers( + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBuffer* pBuffers, + const VkDeviceSize* pOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdDraw( + VkCommandBuffer commandBuffer, + uint32_t vertexCount, + uint32_t instanceCount, + uint32_t firstVertex, + uint32_t firstInstance); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexed( + VkCommandBuffer commandBuffer, + uint32_t indexCount, + uint32_t instanceCount, + uint32_t firstIndex, + int32_t vertexOffset, + uint32_t firstInstance); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirect( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirect( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatch( + VkCommandBuffer commandBuffer, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchIndirect( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer( + VkCommandBuffer commandBuffer, + VkBuffer srcBuffer, + VkBuffer dstBuffer, + uint32_t regionCount, + const VkBufferCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkImageCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkImageBlit* pRegions, + VkFilter filter); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage( + VkCommandBuffer commandBuffer, + VkBuffer srcBuffer, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkBufferImageCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkBuffer dstBuffer, + uint32_t regionCount, + const VkBufferImageCopy* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdUpdateBuffer( + VkCommandBuffer commandBuffer, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + VkDeviceSize dataSize, + const void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdFillBuffer( + VkCommandBuffer commandBuffer, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + VkDeviceSize size, + uint32_t data); + +VKAPI_ATTR void VKAPI_CALL vkCmdClearColorImage( + VkCommandBuffer commandBuffer, + VkImage image, + VkImageLayout imageLayout, + const VkClearColorValue* pColor, + uint32_t rangeCount, + const VkImageSubresourceRange* pRanges); + +VKAPI_ATTR void VKAPI_CALL vkCmdClearDepthStencilImage( + VkCommandBuffer commandBuffer, + VkImage image, + VkImageLayout imageLayout, + const VkClearDepthStencilValue* pDepthStencil, + uint32_t rangeCount, + const VkImageSubresourceRange* pRanges); + +VKAPI_ATTR void VKAPI_CALL vkCmdClearAttachments( + VkCommandBuffer commandBuffer, + uint32_t attachmentCount, + const VkClearAttachment* pAttachments, + uint32_t rectCount, + const VkClearRect* pRects); + +VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage( + VkCommandBuffer commandBuffer, + VkImage srcImage, + VkImageLayout srcImageLayout, + VkImage dstImage, + VkImageLayout dstImageLayout, + uint32_t regionCount, + const VkImageResolve* pRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent( + VkCommandBuffer commandBuffer, + VkEvent event, + VkPipelineStageFlags stageMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent( + VkCommandBuffer commandBuffer, + VkEvent event, + VkPipelineStageFlags stageMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents( + VkCommandBuffer commandBuffer, + uint32_t eventCount, + const VkEvent* pEvents, + VkPipelineStageFlags srcStageMask, + VkPipelineStageFlags dstStageMask, + uint32_t memoryBarrierCount, + const VkMemoryBarrier* pMemoryBarriers, + uint32_t bufferMemoryBarrierCount, + const VkBufferMemoryBarrier* pBufferMemoryBarriers, + uint32_t imageMemoryBarrierCount, + const VkImageMemoryBarrier* pImageMemoryBarriers); + +VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier( + VkCommandBuffer commandBuffer, + VkPipelineStageFlags srcStageMask, + VkPipelineStageFlags dstStageMask, + VkDependencyFlags dependencyFlags, + uint32_t memoryBarrierCount, + const VkMemoryBarrier* pMemoryBarriers, + uint32_t bufferMemoryBarrierCount, + const VkBufferMemoryBarrier* pBufferMemoryBarriers, + uint32_t imageMemoryBarrierCount, + const VkImageMemoryBarrier* pImageMemoryBarriers); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginQuery( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query, + VkQueryControlFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndQuery( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query); + +VKAPI_ATTR void VKAPI_CALL vkCmdResetQueryPool( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp( + VkCommandBuffer commandBuffer, + VkPipelineStageFlagBits pipelineStage, + VkQueryPool queryPool, + uint32_t query); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyQueryPoolResults( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + VkDeviceSize stride, + VkQueryResultFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants( + VkCommandBuffer commandBuffer, + VkPipelineLayout layout, + VkShaderStageFlags stageFlags, + uint32_t offset, + uint32_t size, + const void* pValues); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass( + VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + VkSubpassContents contents); + +VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass( + VkCommandBuffer commandBuffer, + VkSubpassContents contents); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR void VKAPI_CALL vkCmdExecuteCommands( + VkCommandBuffer commandBuffer, + uint32_t commandBufferCount, + const VkCommandBuffer* pCommandBuffers); +#endif + + +// VK_VERSION_1_1 is a preprocessor guard. Do not pass it to API calls. +#define VK_VERSION_1_1 1 +// Vulkan 1.1 version number +#define VK_API_VERSION_1_1 VK_MAKE_API_VERSION(0, 1, 1, 0)// Patch version should always be set to 0 + +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSamplerYcbcrConversion) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDescriptorUpdateTemplate) +#define VK_MAX_DEVICE_GROUP_SIZE 32U +#define VK_LUID_SIZE 8U +#define VK_QUEUE_FAMILY_EXTERNAL (~1U) + +typedef enum VkPointClippingBehavior { + VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES = 0, + VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY = 1, + VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES_KHR = VK_POINT_CLIPPING_BEHAVIOR_ALL_CLIP_PLANES, + VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY_KHR = VK_POINT_CLIPPING_BEHAVIOR_USER_CLIP_PLANES_ONLY, + VK_POINT_CLIPPING_BEHAVIOR_MAX_ENUM = 0x7FFFFFFF +} VkPointClippingBehavior; + +typedef enum VkTessellationDomainOrigin { + VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT = 0, + VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT = 1, + VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT_KHR = VK_TESSELLATION_DOMAIN_ORIGIN_UPPER_LEFT, + VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT_KHR = VK_TESSELLATION_DOMAIN_ORIGIN_LOWER_LEFT, + VK_TESSELLATION_DOMAIN_ORIGIN_MAX_ENUM = 0x7FFFFFFF +} VkTessellationDomainOrigin; + +typedef enum VkSamplerYcbcrModelConversion { + VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY = 0, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY = 1, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709 = 2, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601 = 3, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020 = 4, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_IDENTITY, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_709, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_601, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020_KHR = VK_SAMPLER_YCBCR_MODEL_CONVERSION_YCBCR_2020, + VK_SAMPLER_YCBCR_MODEL_CONVERSION_MAX_ENUM = 0x7FFFFFFF +} VkSamplerYcbcrModelConversion; + +typedef enum VkSamplerYcbcrRange { + VK_SAMPLER_YCBCR_RANGE_ITU_FULL = 0, + VK_SAMPLER_YCBCR_RANGE_ITU_NARROW = 1, + VK_SAMPLER_YCBCR_RANGE_ITU_FULL_KHR = VK_SAMPLER_YCBCR_RANGE_ITU_FULL, + VK_SAMPLER_YCBCR_RANGE_ITU_NARROW_KHR = VK_SAMPLER_YCBCR_RANGE_ITU_NARROW, + VK_SAMPLER_YCBCR_RANGE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerYcbcrRange; + +typedef enum VkChromaLocation { + VK_CHROMA_LOCATION_COSITED_EVEN = 0, + VK_CHROMA_LOCATION_MIDPOINT = 1, + VK_CHROMA_LOCATION_COSITED_EVEN_KHR = VK_CHROMA_LOCATION_COSITED_EVEN, + VK_CHROMA_LOCATION_MIDPOINT_KHR = VK_CHROMA_LOCATION_MIDPOINT, + VK_CHROMA_LOCATION_MAX_ENUM = 0x7FFFFFFF +} VkChromaLocation; + +typedef enum VkDescriptorUpdateTemplateType { + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET = 0, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_PUSH_DESCRIPTORS_KHR = 1, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET_KHR = VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_DESCRIPTOR_SET, + VK_DESCRIPTOR_UPDATE_TEMPLATE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorUpdateTemplateType; + +typedef enum VkSubgroupFeatureFlagBits { + VK_SUBGROUP_FEATURE_BASIC_BIT = 0x00000001, + VK_SUBGROUP_FEATURE_VOTE_BIT = 0x00000002, + VK_SUBGROUP_FEATURE_ARITHMETIC_BIT = 0x00000004, + VK_SUBGROUP_FEATURE_BALLOT_BIT = 0x00000008, + VK_SUBGROUP_FEATURE_SHUFFLE_BIT = 0x00000010, + VK_SUBGROUP_FEATURE_SHUFFLE_RELATIVE_BIT = 0x00000020, + VK_SUBGROUP_FEATURE_CLUSTERED_BIT = 0x00000040, + VK_SUBGROUP_FEATURE_QUAD_BIT = 0x00000080, + VK_SUBGROUP_FEATURE_PARTITIONED_BIT_NV = 0x00000100, + VK_SUBGROUP_FEATURE_ROTATE_BIT_KHR = 0x00000200, + VK_SUBGROUP_FEATURE_ROTATE_CLUSTERED_BIT_KHR = 0x00000400, + VK_SUBGROUP_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSubgroupFeatureFlagBits; +typedef VkFlags VkSubgroupFeatureFlags; + +typedef enum VkPeerMemoryFeatureFlagBits { + VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT = 0x00000001, + VK_PEER_MEMORY_FEATURE_COPY_DST_BIT = 0x00000002, + VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT = 0x00000004, + VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT = 0x00000008, + VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT_KHR = VK_PEER_MEMORY_FEATURE_COPY_SRC_BIT, + VK_PEER_MEMORY_FEATURE_COPY_DST_BIT_KHR = VK_PEER_MEMORY_FEATURE_COPY_DST_BIT, + VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT_KHR = VK_PEER_MEMORY_FEATURE_GENERIC_SRC_BIT, + VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT_KHR = VK_PEER_MEMORY_FEATURE_GENERIC_DST_BIT, + VK_PEER_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPeerMemoryFeatureFlagBits; +typedef VkFlags VkPeerMemoryFeatureFlags; + +typedef enum VkMemoryAllocateFlagBits { + VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT = 0x00000001, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT = 0x00000002, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT = 0x00000004, + VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT_KHR = VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT, + VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT, + VK_MEMORY_ALLOCATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkMemoryAllocateFlagBits; +typedef VkFlags VkMemoryAllocateFlags; +typedef VkFlags VkCommandPoolTrimFlags; +typedef VkFlags VkDescriptorUpdateTemplateCreateFlags; + +typedef enum VkExternalMemoryHandleTypeFlagBits { + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT = 0x00000001, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT = 0x00000002, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 0x00000004, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT = 0x00000008, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT = 0x00000010, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT = 0x00000020, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT = 0x00000040, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT = 0x00000200, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID = 0x00000400, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT = 0x00000080, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_MAPPED_FOREIGN_MEMORY_BIT_EXT = 0x00000100, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_ZIRCON_VMO_BIT_FUCHSIA = 0x00000800, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_RDMA_ADDRESS_BIT_NV = 0x00001000, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_SCREEN_BUFFER_BIT_QNX = 0x00004000, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_KMT_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_HEAP_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT_KHR = VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE_BIT, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalMemoryHandleTypeFlagBits; +typedef VkFlags VkExternalMemoryHandleTypeFlags; + +typedef enum VkExternalMemoryFeatureFlagBits { + VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT = 0x00000001, + VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT = 0x00000002, + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT = 0x00000004, + VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_KHR = VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT, + VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_KHR = VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT, + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_KHR = VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT, + VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalMemoryFeatureFlagBits; +typedef VkFlags VkExternalMemoryFeatureFlags; + +typedef enum VkExternalFenceHandleTypeFlagBits { + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT = 0x00000001, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 0x00000002, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 0x00000004, + VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT = 0x00000008, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT_KHR = VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT, + VK_EXTERNAL_FENCE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalFenceHandleTypeFlagBits; +typedef VkFlags VkExternalFenceHandleTypeFlags; + +typedef enum VkExternalFenceFeatureFlagBits { + VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT = 0x00000001, + VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT = 0x00000002, + VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT_KHR = VK_EXTERNAL_FENCE_FEATURE_EXPORTABLE_BIT, + VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT_KHR = VK_EXTERNAL_FENCE_FEATURE_IMPORTABLE_BIT, + VK_EXTERNAL_FENCE_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalFenceFeatureFlagBits; +typedef VkFlags VkExternalFenceFeatureFlags; + +typedef enum VkFenceImportFlagBits { + VK_FENCE_IMPORT_TEMPORARY_BIT = 0x00000001, + VK_FENCE_IMPORT_TEMPORARY_BIT_KHR = VK_FENCE_IMPORT_TEMPORARY_BIT, + VK_FENCE_IMPORT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkFenceImportFlagBits; +typedef VkFlags VkFenceImportFlags; + +typedef enum VkSemaphoreImportFlagBits { + VK_SEMAPHORE_IMPORT_TEMPORARY_BIT = 0x00000001, + VK_SEMAPHORE_IMPORT_TEMPORARY_BIT_KHR = VK_SEMAPHORE_IMPORT_TEMPORARY_BIT, + VK_SEMAPHORE_IMPORT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSemaphoreImportFlagBits; +typedef VkFlags VkSemaphoreImportFlags; + +typedef enum VkExternalSemaphoreHandleTypeFlagBits { + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT = 0x00000001, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT = 0x00000002, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT = 0x00000004, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT = 0x00000008, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT = 0x00000010, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_ZIRCON_EVENT_BIT_FUCHSIA = 0x00000080, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE_BIT = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D12_FENCE_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT_KHR = VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT, + VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalSemaphoreHandleTypeFlagBits; +typedef VkFlags VkExternalSemaphoreHandleTypeFlags; + +typedef enum VkExternalSemaphoreFeatureFlagBits { + VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT = 0x00000001, + VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT = 0x00000002, + VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT_KHR = VK_EXTERNAL_SEMAPHORE_FEATURE_EXPORTABLE_BIT, + VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT_KHR = VK_EXTERNAL_SEMAPHORE_FEATURE_IMPORTABLE_BIT, + VK_EXTERNAL_SEMAPHORE_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkExternalSemaphoreFeatureFlagBits; +typedef VkFlags VkExternalSemaphoreFeatureFlags; +typedef struct VkPhysicalDeviceSubgroupProperties { + VkStructureType sType; + void* pNext; + uint32_t subgroupSize; + VkShaderStageFlags supportedStages; + VkSubgroupFeatureFlags supportedOperations; + VkBool32 quadOperationsInAllStages; +} VkPhysicalDeviceSubgroupProperties; + +typedef struct VkBindBufferMemoryInfo { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; +} VkBindBufferMemoryInfo; + +typedef struct VkBindImageMemoryInfo { + VkStructureType sType; + const void* pNext; + VkImage image; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; +} VkBindImageMemoryInfo; + +typedef struct VkPhysicalDevice16BitStorageFeatures { + VkStructureType sType; + void* pNext; + VkBool32 storageBuffer16BitAccess; + VkBool32 uniformAndStorageBuffer16BitAccess; + VkBool32 storagePushConstant16; + VkBool32 storageInputOutput16; +} VkPhysicalDevice16BitStorageFeatures; + +typedef struct VkMemoryDedicatedRequirements { + VkStructureType sType; + void* pNext; + VkBool32 prefersDedicatedAllocation; + VkBool32 requiresDedicatedAllocation; +} VkMemoryDedicatedRequirements; + +typedef struct VkMemoryDedicatedAllocateInfo { + VkStructureType sType; + const void* pNext; + VkImage image; + VkBuffer buffer; +} VkMemoryDedicatedAllocateInfo; + +typedef struct VkMemoryAllocateFlagsInfo { + VkStructureType sType; + const void* pNext; + VkMemoryAllocateFlags flags; + uint32_t deviceMask; +} VkMemoryAllocateFlagsInfo; + +typedef struct VkDeviceGroupRenderPassBeginInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceMask; + uint32_t deviceRenderAreaCount; + const VkRect2D* pDeviceRenderAreas; +} VkDeviceGroupRenderPassBeginInfo; + +typedef struct VkDeviceGroupCommandBufferBeginInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceMask; +} VkDeviceGroupCommandBufferBeginInfo; + +typedef struct VkDeviceGroupSubmitInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const uint32_t* pWaitSemaphoreDeviceIndices; + uint32_t commandBufferCount; + const uint32_t* pCommandBufferDeviceMasks; + uint32_t signalSemaphoreCount; + const uint32_t* pSignalSemaphoreDeviceIndices; +} VkDeviceGroupSubmitInfo; + +typedef struct VkDeviceGroupBindSparseInfo { + VkStructureType sType; + const void* pNext; + uint32_t resourceDeviceIndex; + uint32_t memoryDeviceIndex; +} VkDeviceGroupBindSparseInfo; + +typedef struct VkBindBufferMemoryDeviceGroupInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceIndexCount; + const uint32_t* pDeviceIndices; +} VkBindBufferMemoryDeviceGroupInfo; + +typedef struct VkBindImageMemoryDeviceGroupInfo { + VkStructureType sType; + const void* pNext; + uint32_t deviceIndexCount; + const uint32_t* pDeviceIndices; + uint32_t splitInstanceBindRegionCount; + const VkRect2D* pSplitInstanceBindRegions; +} VkBindImageMemoryDeviceGroupInfo; + +typedef struct VkPhysicalDeviceGroupProperties { + VkStructureType sType; + void* pNext; + uint32_t physicalDeviceCount; + VkPhysicalDevice physicalDevices[VK_MAX_DEVICE_GROUP_SIZE]; + VkBool32 subsetAllocation; +} VkPhysicalDeviceGroupProperties; + +typedef struct VkDeviceGroupDeviceCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t physicalDeviceCount; + const VkPhysicalDevice* pPhysicalDevices; +} VkDeviceGroupDeviceCreateInfo; + +typedef struct VkBufferMemoryRequirementsInfo2 { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; +} VkBufferMemoryRequirementsInfo2; + +typedef struct VkImageMemoryRequirementsInfo2 { + VkStructureType sType; + const void* pNext; + VkImage image; +} VkImageMemoryRequirementsInfo2; + +typedef struct VkImageSparseMemoryRequirementsInfo2 { + VkStructureType sType; + const void* pNext; + VkImage image; +} VkImageSparseMemoryRequirementsInfo2; + +typedef struct VkMemoryRequirements2 { + VkStructureType sType; + void* pNext; + VkMemoryRequirements memoryRequirements; +} VkMemoryRequirements2; + +typedef struct VkSparseImageMemoryRequirements2 { + VkStructureType sType; + void* pNext; + VkSparseImageMemoryRequirements memoryRequirements; +} VkSparseImageMemoryRequirements2; + +typedef struct VkPhysicalDeviceFeatures2 { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceFeatures features; +} VkPhysicalDeviceFeatures2; + +typedef struct VkPhysicalDeviceProperties2 { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceProperties properties; +} VkPhysicalDeviceProperties2; + +typedef struct VkFormatProperties2 { + VkStructureType sType; + void* pNext; + VkFormatProperties formatProperties; +} VkFormatProperties2; + +typedef struct VkImageFormatProperties2 { + VkStructureType sType; + void* pNext; + VkImageFormatProperties imageFormatProperties; +} VkImageFormatProperties2; + +typedef struct VkPhysicalDeviceImageFormatInfo2 { + VkStructureType sType; + const void* pNext; + VkFormat format; + VkImageType type; + VkImageTiling tiling; + VkImageUsageFlags usage; + VkImageCreateFlags flags; +} VkPhysicalDeviceImageFormatInfo2; + +typedef struct VkQueueFamilyProperties2 { + VkStructureType sType; + void* pNext; + VkQueueFamilyProperties queueFamilyProperties; +} VkQueueFamilyProperties2; + +typedef struct VkPhysicalDeviceMemoryProperties2 { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceMemoryProperties memoryProperties; +} VkPhysicalDeviceMemoryProperties2; + +typedef struct VkSparseImageFormatProperties2 { + VkStructureType sType; + void* pNext; + VkSparseImageFormatProperties properties; +} VkSparseImageFormatProperties2; + +typedef struct VkPhysicalDeviceSparseImageFormatInfo2 { + VkStructureType sType; + const void* pNext; + VkFormat format; + VkImageType type; + VkSampleCountFlagBits samples; + VkImageUsageFlags usage; + VkImageTiling tiling; +} VkPhysicalDeviceSparseImageFormatInfo2; + +typedef struct VkPhysicalDevicePointClippingProperties { + VkStructureType sType; + void* pNext; + VkPointClippingBehavior pointClippingBehavior; +} VkPhysicalDevicePointClippingProperties; + +typedef struct VkInputAttachmentAspectReference { + uint32_t subpass; + uint32_t inputAttachmentIndex; + VkImageAspectFlags aspectMask; +} VkInputAttachmentAspectReference; + +typedef struct VkRenderPassInputAttachmentAspectCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t aspectReferenceCount; + const VkInputAttachmentAspectReference* pAspectReferences; +} VkRenderPassInputAttachmentAspectCreateInfo; + +typedef struct VkImageViewUsageCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageUsageFlags usage; +} VkImageViewUsageCreateInfo; + +typedef struct VkPipelineTessellationDomainOriginStateCreateInfo { + VkStructureType sType; + const void* pNext; + VkTessellationDomainOrigin domainOrigin; +} VkPipelineTessellationDomainOriginStateCreateInfo; + +typedef struct VkRenderPassMultiviewCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t subpassCount; + const uint32_t* pViewMasks; + uint32_t dependencyCount; + const int32_t* pViewOffsets; + uint32_t correlationMaskCount; + const uint32_t* pCorrelationMasks; +} VkRenderPassMultiviewCreateInfo; + +typedef struct VkPhysicalDeviceMultiviewFeatures { + VkStructureType sType; + void* pNext; + VkBool32 multiview; + VkBool32 multiviewGeometryShader; + VkBool32 multiviewTessellationShader; +} VkPhysicalDeviceMultiviewFeatures; + +typedef struct VkPhysicalDeviceMultiviewProperties { + VkStructureType sType; + void* pNext; + uint32_t maxMultiviewViewCount; + uint32_t maxMultiviewInstanceIndex; +} VkPhysicalDeviceMultiviewProperties; + +typedef struct VkPhysicalDeviceVariablePointersFeatures { + VkStructureType sType; + void* pNext; + VkBool32 variablePointersStorageBuffer; + VkBool32 variablePointers; +} VkPhysicalDeviceVariablePointersFeatures; + +typedef VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointerFeatures; + +typedef struct VkPhysicalDeviceProtectedMemoryFeatures { + VkStructureType sType; + void* pNext; + VkBool32 protectedMemory; +} VkPhysicalDeviceProtectedMemoryFeatures; + +typedef struct VkPhysicalDeviceProtectedMemoryProperties { + VkStructureType sType; + void* pNext; + VkBool32 protectedNoFault; +} VkPhysicalDeviceProtectedMemoryProperties; + +typedef struct VkDeviceQueueInfo2 { + VkStructureType sType; + const void* pNext; + VkDeviceQueueCreateFlags flags; + uint32_t queueFamilyIndex; + uint32_t queueIndex; +} VkDeviceQueueInfo2; + +typedef struct VkProtectedSubmitInfo { + VkStructureType sType; + const void* pNext; + VkBool32 protectedSubmit; +} VkProtectedSubmitInfo; + +typedef struct VkSamplerYcbcrConversionCreateInfo { + VkStructureType sType; + const void* pNext; + VkFormat format; + VkSamplerYcbcrModelConversion ycbcrModel; + VkSamplerYcbcrRange ycbcrRange; + VkComponentMapping components; + VkChromaLocation xChromaOffset; + VkChromaLocation yChromaOffset; + VkFilter chromaFilter; + VkBool32 forceExplicitReconstruction; +} VkSamplerYcbcrConversionCreateInfo; + +typedef struct VkSamplerYcbcrConversionInfo { + VkStructureType sType; + const void* pNext; + VkSamplerYcbcrConversion conversion; +} VkSamplerYcbcrConversionInfo; + +typedef struct VkBindImagePlaneMemoryInfo { + VkStructureType sType; + const void* pNext; + VkImageAspectFlagBits planeAspect; +} VkBindImagePlaneMemoryInfo; + +typedef struct VkImagePlaneMemoryRequirementsInfo { + VkStructureType sType; + const void* pNext; + VkImageAspectFlagBits planeAspect; +} VkImagePlaneMemoryRequirementsInfo; + +typedef struct VkPhysicalDeviceSamplerYcbcrConversionFeatures { + VkStructureType sType; + void* pNext; + VkBool32 samplerYcbcrConversion; +} VkPhysicalDeviceSamplerYcbcrConversionFeatures; + +typedef struct VkSamplerYcbcrConversionImageFormatProperties { + VkStructureType sType; + void* pNext; + uint32_t combinedImageSamplerDescriptorCount; +} VkSamplerYcbcrConversionImageFormatProperties; + +typedef struct VkDescriptorUpdateTemplateEntry { + uint32_t dstBinding; + uint32_t dstArrayElement; + uint32_t descriptorCount; + VkDescriptorType descriptorType; + size_t offset; + size_t stride; +} VkDescriptorUpdateTemplateEntry; + +typedef struct VkDescriptorUpdateTemplateCreateInfo { + VkStructureType sType; + const void* pNext; + VkDescriptorUpdateTemplateCreateFlags flags; + uint32_t descriptorUpdateEntryCount; + const VkDescriptorUpdateTemplateEntry* pDescriptorUpdateEntries; + VkDescriptorUpdateTemplateType templateType; + VkDescriptorSetLayout descriptorSetLayout; + VkPipelineBindPoint pipelineBindPoint; + VkPipelineLayout pipelineLayout; + uint32_t set; +} VkDescriptorUpdateTemplateCreateInfo; + +typedef struct VkExternalMemoryProperties { + VkExternalMemoryFeatureFlags externalMemoryFeatures; + VkExternalMemoryHandleTypeFlags exportFromImportedHandleTypes; + VkExternalMemoryHandleTypeFlags compatibleHandleTypes; +} VkExternalMemoryProperties; + +typedef struct VkPhysicalDeviceExternalImageFormatInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalImageFormatInfo; + +typedef struct VkExternalImageFormatProperties { + VkStructureType sType; + void* pNext; + VkExternalMemoryProperties externalMemoryProperties; +} VkExternalImageFormatProperties; + +typedef struct VkPhysicalDeviceExternalBufferInfo { + VkStructureType sType; + const void* pNext; + VkBufferCreateFlags flags; + VkBufferUsageFlags usage; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalBufferInfo; + +typedef struct VkExternalBufferProperties { + VkStructureType sType; + void* pNext; + VkExternalMemoryProperties externalMemoryProperties; +} VkExternalBufferProperties; + +typedef struct VkPhysicalDeviceIDProperties { + VkStructureType sType; + void* pNext; + uint8_t deviceUUID[VK_UUID_SIZE]; + uint8_t driverUUID[VK_UUID_SIZE]; + uint8_t deviceLUID[VK_LUID_SIZE]; + uint32_t deviceNodeMask; + VkBool32 deviceLUIDValid; +} VkPhysicalDeviceIDProperties; + +typedef struct VkExternalMemoryImageCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlags handleTypes; +} VkExternalMemoryImageCreateInfo; + +typedef struct VkExternalMemoryBufferCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlags handleTypes; +} VkExternalMemoryBufferCreateInfo; + +typedef struct VkExportMemoryAllocateInfo { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlags handleTypes; +} VkExportMemoryAllocateInfo; + +typedef struct VkPhysicalDeviceExternalFenceInfo { + VkStructureType sType; + const void* pNext; + VkExternalFenceHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalFenceInfo; + +typedef struct VkExternalFenceProperties { + VkStructureType sType; + void* pNext; + VkExternalFenceHandleTypeFlags exportFromImportedHandleTypes; + VkExternalFenceHandleTypeFlags compatibleHandleTypes; + VkExternalFenceFeatureFlags externalFenceFeatures; +} VkExternalFenceProperties; + +typedef struct VkExportFenceCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalFenceHandleTypeFlags handleTypes; +} VkExportFenceCreateInfo; + +typedef struct VkExportSemaphoreCreateInfo { + VkStructureType sType; + const void* pNext; + VkExternalSemaphoreHandleTypeFlags handleTypes; +} VkExportSemaphoreCreateInfo; + +typedef struct VkPhysicalDeviceExternalSemaphoreInfo { + VkStructureType sType; + const void* pNext; + VkExternalSemaphoreHandleTypeFlagBits handleType; +} VkPhysicalDeviceExternalSemaphoreInfo; + +typedef struct VkExternalSemaphoreProperties { + VkStructureType sType; + void* pNext; + VkExternalSemaphoreHandleTypeFlags exportFromImportedHandleTypes; + VkExternalSemaphoreHandleTypeFlags compatibleHandleTypes; + VkExternalSemaphoreFeatureFlags externalSemaphoreFeatures; +} VkExternalSemaphoreProperties; + +typedef struct VkPhysicalDeviceMaintenance3Properties { + VkStructureType sType; + void* pNext; + uint32_t maxPerSetDescriptors; + VkDeviceSize maxMemoryAllocationSize; +} VkPhysicalDeviceMaintenance3Properties; + +typedef struct VkDescriptorSetLayoutSupport { + VkStructureType sType; + void* pNext; + VkBool32 supported; +} VkDescriptorSetLayoutSupport; + +typedef struct VkPhysicalDeviceShaderDrawParametersFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderDrawParameters; +} VkPhysicalDeviceShaderDrawParametersFeatures; + +typedef VkPhysicalDeviceShaderDrawParametersFeatures VkPhysicalDeviceShaderDrawParameterFeatures; + +typedef VkResult (VKAPI_PTR *PFN_vkEnumerateInstanceVersion)(uint32_t* pApiVersion); +typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos); +typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory2)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos); +typedef void (VKAPI_PTR *PFN_vkGetDeviceGroupPeerMemoryFeatures)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); +typedef void (VKAPI_PTR *PFN_vkCmdSetDeviceMask)(VkCommandBuffer commandBuffer, uint32_t deviceMask); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchBase)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroups)(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); +typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements2)(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements2)(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements2)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties2)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties); +typedef void (VKAPI_PTR *PFN_vkTrimCommandPool)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags); +typedef void (VKAPI_PTR *PFN_vkGetDeviceQueue2)(VkDevice device, const VkDeviceQueueInfo2* pQueueInfo, VkQueue* pQueue); +typedef VkResult (VKAPI_PTR *PFN_vkCreateSamplerYcbcrConversion)(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion); +typedef void (VKAPI_PTR *PFN_vkDestroySamplerYcbcrConversion)(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorUpdateTemplate)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorUpdateTemplate)(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSetWithTemplate)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalBufferProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalFenceProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalSemaphoreProperties)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutSupport)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceVersion( + uint32_t* pApiVersion); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2( + VkDevice device, + uint32_t bindInfoCount, + const VkBindBufferMemoryInfo* pBindInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2( + VkDevice device, + uint32_t bindInfoCount, + const VkBindImageMemoryInfo* pBindInfos); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeatures( + VkDevice device, + uint32_t heapIndex, + uint32_t localDeviceIndex, + uint32_t remoteDeviceIndex, + VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMask( + VkCommandBuffer commandBuffer, + uint32_t deviceMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBase( + VkCommandBuffer commandBuffer, + uint32_t baseGroupX, + uint32_t baseGroupY, + uint32_t baseGroupZ, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroups( + VkInstance instance, + uint32_t* pPhysicalDeviceGroupCount, + VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2( + VkDevice device, + const VkImageMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2( + VkDevice device, + const VkBufferMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2( + VkDevice device, + const VkImageSparseMemoryRequirementsInfo2* pInfo, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceFeatures2* pFeatures); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties2* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkFormatProperties2* pFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, + VkImageFormatProperties2* pImageFormatProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2( + VkPhysicalDevice physicalDevice, + uint32_t* pQueueFamilyPropertyCount, + VkQueueFamilyProperties2* pQueueFamilyProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties2* pMemoryProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, + uint32_t* pPropertyCount, + VkSparseImageFormatProperties2* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkTrimCommandPool( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolTrimFlags flags); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2( + VkDevice device, + const VkDeviceQueueInfo2* pQueueInfo, + VkQueue* pQueue); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversion( + VkDevice device, + const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSamplerYcbcrConversion* pYcbcrConversion); + +VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversion( + VkDevice device, + VkSamplerYcbcrConversion ycbcrConversion, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplate( + VkDevice device, + const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplate( + VkDevice device, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplate( + VkDevice device, + VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const void* pData); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFenceProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, + VkExternalFenceProperties* pExternalFenceProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphoreProperties( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, + VkExternalSemaphoreProperties* pExternalSemaphoreProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupport( + VkDevice device, + const VkDescriptorSetLayoutCreateInfo* pCreateInfo, + VkDescriptorSetLayoutSupport* pSupport); +#endif + + +// VK_VERSION_1_2 is a preprocessor guard. Do not pass it to API calls. +#define VK_VERSION_1_2 1 +// Vulkan 1.2 version number +#define VK_API_VERSION_1_2 VK_MAKE_API_VERSION(0, 1, 2, 0)// Patch version should always be set to 0 + +#define VK_MAX_DRIVER_NAME_SIZE 256U +#define VK_MAX_DRIVER_INFO_SIZE 256U + +typedef enum VkDriverId { + VK_DRIVER_ID_AMD_PROPRIETARY = 1, + VK_DRIVER_ID_AMD_OPEN_SOURCE = 2, + VK_DRIVER_ID_MESA_RADV = 3, + VK_DRIVER_ID_NVIDIA_PROPRIETARY = 4, + VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS = 5, + VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA = 6, + VK_DRIVER_ID_IMAGINATION_PROPRIETARY = 7, + VK_DRIVER_ID_QUALCOMM_PROPRIETARY = 8, + VK_DRIVER_ID_ARM_PROPRIETARY = 9, + VK_DRIVER_ID_GOOGLE_SWIFTSHADER = 10, + VK_DRIVER_ID_GGP_PROPRIETARY = 11, + VK_DRIVER_ID_BROADCOM_PROPRIETARY = 12, + VK_DRIVER_ID_MESA_LLVMPIPE = 13, + VK_DRIVER_ID_MOLTENVK = 14, + VK_DRIVER_ID_COREAVI_PROPRIETARY = 15, + VK_DRIVER_ID_JUICE_PROPRIETARY = 16, + VK_DRIVER_ID_VERISILICON_PROPRIETARY = 17, + VK_DRIVER_ID_MESA_TURNIP = 18, + VK_DRIVER_ID_MESA_V3DV = 19, + VK_DRIVER_ID_MESA_PANVK = 20, + VK_DRIVER_ID_SAMSUNG_PROPRIETARY = 21, + VK_DRIVER_ID_MESA_VENUS = 22, + VK_DRIVER_ID_MESA_DOZEN = 23, + VK_DRIVER_ID_MESA_NVK = 24, + VK_DRIVER_ID_IMAGINATION_OPEN_SOURCE_MESA = 25, + VK_DRIVER_ID_MESA_AGXV = 26, + VK_DRIVER_ID_AMD_PROPRIETARY_KHR = VK_DRIVER_ID_AMD_PROPRIETARY, + VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR = VK_DRIVER_ID_AMD_OPEN_SOURCE, + VK_DRIVER_ID_MESA_RADV_KHR = VK_DRIVER_ID_MESA_RADV, + VK_DRIVER_ID_NVIDIA_PROPRIETARY_KHR = VK_DRIVER_ID_NVIDIA_PROPRIETARY, + VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS_KHR = VK_DRIVER_ID_INTEL_PROPRIETARY_WINDOWS, + VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA_KHR = VK_DRIVER_ID_INTEL_OPEN_SOURCE_MESA, + VK_DRIVER_ID_IMAGINATION_PROPRIETARY_KHR = VK_DRIVER_ID_IMAGINATION_PROPRIETARY, + VK_DRIVER_ID_QUALCOMM_PROPRIETARY_KHR = VK_DRIVER_ID_QUALCOMM_PROPRIETARY, + VK_DRIVER_ID_ARM_PROPRIETARY_KHR = VK_DRIVER_ID_ARM_PROPRIETARY, + VK_DRIVER_ID_GOOGLE_SWIFTSHADER_KHR = VK_DRIVER_ID_GOOGLE_SWIFTSHADER, + VK_DRIVER_ID_GGP_PROPRIETARY_KHR = VK_DRIVER_ID_GGP_PROPRIETARY, + VK_DRIVER_ID_BROADCOM_PROPRIETARY_KHR = VK_DRIVER_ID_BROADCOM_PROPRIETARY, + VK_DRIVER_ID_MAX_ENUM = 0x7FFFFFFF +} VkDriverId; + +typedef enum VkShaderFloatControlsIndependence { + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY = 0, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL = 1, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE = 2, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY_KHR = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_32_BIT_ONLY, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL_KHR = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_ALL, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE_KHR = VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_NONE, + VK_SHADER_FLOAT_CONTROLS_INDEPENDENCE_MAX_ENUM = 0x7FFFFFFF +} VkShaderFloatControlsIndependence; + +typedef enum VkSamplerReductionMode { + VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE = 0, + VK_SAMPLER_REDUCTION_MODE_MIN = 1, + VK_SAMPLER_REDUCTION_MODE_MAX = 2, + VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_RANGECLAMP_QCOM = 1000521000, + VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE_EXT = VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE, + VK_SAMPLER_REDUCTION_MODE_MIN_EXT = VK_SAMPLER_REDUCTION_MODE_MIN, + VK_SAMPLER_REDUCTION_MODE_MAX_EXT = VK_SAMPLER_REDUCTION_MODE_MAX, + VK_SAMPLER_REDUCTION_MODE_MAX_ENUM = 0x7FFFFFFF +} VkSamplerReductionMode; + +typedef enum VkSemaphoreType { + VK_SEMAPHORE_TYPE_BINARY = 0, + VK_SEMAPHORE_TYPE_TIMELINE = 1, + VK_SEMAPHORE_TYPE_BINARY_KHR = VK_SEMAPHORE_TYPE_BINARY, + VK_SEMAPHORE_TYPE_TIMELINE_KHR = VK_SEMAPHORE_TYPE_TIMELINE, + VK_SEMAPHORE_TYPE_MAX_ENUM = 0x7FFFFFFF +} VkSemaphoreType; + +typedef enum VkResolveModeFlagBits { + VK_RESOLVE_MODE_NONE = 0, + VK_RESOLVE_MODE_SAMPLE_ZERO_BIT = 0x00000001, + VK_RESOLVE_MODE_AVERAGE_BIT = 0x00000002, + VK_RESOLVE_MODE_MIN_BIT = 0x00000004, + VK_RESOLVE_MODE_MAX_BIT = 0x00000008, + VK_RESOLVE_MODE_EXTERNAL_FORMAT_DOWNSAMPLE_ANDROID = 0x00000010, + VK_RESOLVE_MODE_NONE_KHR = VK_RESOLVE_MODE_NONE, + VK_RESOLVE_MODE_SAMPLE_ZERO_BIT_KHR = VK_RESOLVE_MODE_SAMPLE_ZERO_BIT, + VK_RESOLVE_MODE_AVERAGE_BIT_KHR = VK_RESOLVE_MODE_AVERAGE_BIT, + VK_RESOLVE_MODE_MIN_BIT_KHR = VK_RESOLVE_MODE_MIN_BIT, + VK_RESOLVE_MODE_MAX_BIT_KHR = VK_RESOLVE_MODE_MAX_BIT, + VK_RESOLVE_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkResolveModeFlagBits; +typedef VkFlags VkResolveModeFlags; + +typedef enum VkDescriptorBindingFlagBits { + VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT = 0x00000001, + VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT = 0x00000002, + VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT = 0x00000004, + VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT = 0x00000008, + VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT_EXT = VK_DESCRIPTOR_BINDING_UPDATE_AFTER_BIND_BIT, + VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT_EXT = VK_DESCRIPTOR_BINDING_UPDATE_UNUSED_WHILE_PENDING_BIT, + VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT_EXT = VK_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT, + VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT = VK_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT, + VK_DESCRIPTOR_BINDING_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkDescriptorBindingFlagBits; +typedef VkFlags VkDescriptorBindingFlags; + +typedef enum VkSemaphoreWaitFlagBits { + VK_SEMAPHORE_WAIT_ANY_BIT = 0x00000001, + VK_SEMAPHORE_WAIT_ANY_BIT_KHR = VK_SEMAPHORE_WAIT_ANY_BIT, + VK_SEMAPHORE_WAIT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSemaphoreWaitFlagBits; +typedef VkFlags VkSemaphoreWaitFlags; +typedef struct VkPhysicalDeviceVulkan11Features { + VkStructureType sType; + void* pNext; + VkBool32 storageBuffer16BitAccess; + VkBool32 uniformAndStorageBuffer16BitAccess; + VkBool32 storagePushConstant16; + VkBool32 storageInputOutput16; + VkBool32 multiview; + VkBool32 multiviewGeometryShader; + VkBool32 multiviewTessellationShader; + VkBool32 variablePointersStorageBuffer; + VkBool32 variablePointers; + VkBool32 protectedMemory; + VkBool32 samplerYcbcrConversion; + VkBool32 shaderDrawParameters; +} VkPhysicalDeviceVulkan11Features; + +typedef struct VkPhysicalDeviceVulkan11Properties { + VkStructureType sType; + void* pNext; + uint8_t deviceUUID[VK_UUID_SIZE]; + uint8_t driverUUID[VK_UUID_SIZE]; + uint8_t deviceLUID[VK_LUID_SIZE]; + uint32_t deviceNodeMask; + VkBool32 deviceLUIDValid; + uint32_t subgroupSize; + VkShaderStageFlags subgroupSupportedStages; + VkSubgroupFeatureFlags subgroupSupportedOperations; + VkBool32 subgroupQuadOperationsInAllStages; + VkPointClippingBehavior pointClippingBehavior; + uint32_t maxMultiviewViewCount; + uint32_t maxMultiviewInstanceIndex; + VkBool32 protectedNoFault; + uint32_t maxPerSetDescriptors; + VkDeviceSize maxMemoryAllocationSize; +} VkPhysicalDeviceVulkan11Properties; + +typedef struct VkPhysicalDeviceVulkan12Features { + VkStructureType sType; + void* pNext; + VkBool32 samplerMirrorClampToEdge; + VkBool32 drawIndirectCount; + VkBool32 storageBuffer8BitAccess; + VkBool32 uniformAndStorageBuffer8BitAccess; + VkBool32 storagePushConstant8; + VkBool32 shaderBufferInt64Atomics; + VkBool32 shaderSharedInt64Atomics; + VkBool32 shaderFloat16; + VkBool32 shaderInt8; + VkBool32 descriptorIndexing; + VkBool32 shaderInputAttachmentArrayDynamicIndexing; + VkBool32 shaderUniformTexelBufferArrayDynamicIndexing; + VkBool32 shaderStorageTexelBufferArrayDynamicIndexing; + VkBool32 shaderUniformBufferArrayNonUniformIndexing; + VkBool32 shaderSampledImageArrayNonUniformIndexing; + VkBool32 shaderStorageBufferArrayNonUniformIndexing; + VkBool32 shaderStorageImageArrayNonUniformIndexing; + VkBool32 shaderInputAttachmentArrayNonUniformIndexing; + VkBool32 shaderUniformTexelBufferArrayNonUniformIndexing; + VkBool32 shaderStorageTexelBufferArrayNonUniformIndexing; + VkBool32 descriptorBindingUniformBufferUpdateAfterBind; + VkBool32 descriptorBindingSampledImageUpdateAfterBind; + VkBool32 descriptorBindingStorageImageUpdateAfterBind; + VkBool32 descriptorBindingStorageBufferUpdateAfterBind; + VkBool32 descriptorBindingUniformTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingStorageTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingUpdateUnusedWhilePending; + VkBool32 descriptorBindingPartiallyBound; + VkBool32 descriptorBindingVariableDescriptorCount; + VkBool32 runtimeDescriptorArray; + VkBool32 samplerFilterMinmax; + VkBool32 scalarBlockLayout; + VkBool32 imagelessFramebuffer; + VkBool32 uniformBufferStandardLayout; + VkBool32 shaderSubgroupExtendedTypes; + VkBool32 separateDepthStencilLayouts; + VkBool32 hostQueryReset; + VkBool32 timelineSemaphore; + VkBool32 bufferDeviceAddress; + VkBool32 bufferDeviceAddressCaptureReplay; + VkBool32 bufferDeviceAddressMultiDevice; + VkBool32 vulkanMemoryModel; + VkBool32 vulkanMemoryModelDeviceScope; + VkBool32 vulkanMemoryModelAvailabilityVisibilityChains; + VkBool32 shaderOutputViewportIndex; + VkBool32 shaderOutputLayer; + VkBool32 subgroupBroadcastDynamicId; +} VkPhysicalDeviceVulkan12Features; + +typedef struct VkConformanceVersion { + uint8_t major; + uint8_t minor; + uint8_t subminor; + uint8_t patch; +} VkConformanceVersion; + +typedef struct VkPhysicalDeviceVulkan12Properties { + VkStructureType sType; + void* pNext; + VkDriverId driverID; + char driverName[VK_MAX_DRIVER_NAME_SIZE]; + char driverInfo[VK_MAX_DRIVER_INFO_SIZE]; + VkConformanceVersion conformanceVersion; + VkShaderFloatControlsIndependence denormBehaviorIndependence; + VkShaderFloatControlsIndependence roundingModeIndependence; + VkBool32 shaderSignedZeroInfNanPreserveFloat16; + VkBool32 shaderSignedZeroInfNanPreserveFloat32; + VkBool32 shaderSignedZeroInfNanPreserveFloat64; + VkBool32 shaderDenormPreserveFloat16; + VkBool32 shaderDenormPreserveFloat32; + VkBool32 shaderDenormPreserveFloat64; + VkBool32 shaderDenormFlushToZeroFloat16; + VkBool32 shaderDenormFlushToZeroFloat32; + VkBool32 shaderDenormFlushToZeroFloat64; + VkBool32 shaderRoundingModeRTEFloat16; + VkBool32 shaderRoundingModeRTEFloat32; + VkBool32 shaderRoundingModeRTEFloat64; + VkBool32 shaderRoundingModeRTZFloat16; + VkBool32 shaderRoundingModeRTZFloat32; + VkBool32 shaderRoundingModeRTZFloat64; + uint32_t maxUpdateAfterBindDescriptorsInAllPools; + VkBool32 shaderUniformBufferArrayNonUniformIndexingNative; + VkBool32 shaderSampledImageArrayNonUniformIndexingNative; + VkBool32 shaderStorageBufferArrayNonUniformIndexingNative; + VkBool32 shaderStorageImageArrayNonUniformIndexingNative; + VkBool32 shaderInputAttachmentArrayNonUniformIndexingNative; + VkBool32 robustBufferAccessUpdateAfterBind; + VkBool32 quadDivergentImplicitLod; + uint32_t maxPerStageDescriptorUpdateAfterBindSamplers; + uint32_t maxPerStageDescriptorUpdateAfterBindUniformBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindSampledImages; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageImages; + uint32_t maxPerStageDescriptorUpdateAfterBindInputAttachments; + uint32_t maxPerStageUpdateAfterBindResources; + uint32_t maxDescriptorSetUpdateAfterBindSamplers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffers; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindSampledImages; + uint32_t maxDescriptorSetUpdateAfterBindStorageImages; + uint32_t maxDescriptorSetUpdateAfterBindInputAttachments; + VkResolveModeFlags supportedDepthResolveModes; + VkResolveModeFlags supportedStencilResolveModes; + VkBool32 independentResolveNone; + VkBool32 independentResolve; + VkBool32 filterMinmaxSingleComponentFormats; + VkBool32 filterMinmaxImageComponentMapping; + uint64_t maxTimelineSemaphoreValueDifference; + VkSampleCountFlags framebufferIntegerColorSampleCounts; +} VkPhysicalDeviceVulkan12Properties; + +typedef struct VkImageFormatListCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t viewFormatCount; + const VkFormat* pViewFormats; +} VkImageFormatListCreateInfo; + +typedef struct VkAttachmentDescription2 { + VkStructureType sType; + const void* pNext; + VkAttachmentDescriptionFlags flags; + VkFormat format; + VkSampleCountFlagBits samples; + VkAttachmentLoadOp loadOp; + VkAttachmentStoreOp storeOp; + VkAttachmentLoadOp stencilLoadOp; + VkAttachmentStoreOp stencilStoreOp; + VkImageLayout initialLayout; + VkImageLayout finalLayout; +} VkAttachmentDescription2; + +typedef struct VkAttachmentReference2 { + VkStructureType sType; + const void* pNext; + uint32_t attachment; + VkImageLayout layout; + VkImageAspectFlags aspectMask; +} VkAttachmentReference2; + +typedef struct VkSubpassDescription2 { + VkStructureType sType; + const void* pNext; + VkSubpassDescriptionFlags flags; + VkPipelineBindPoint pipelineBindPoint; + uint32_t viewMask; + uint32_t inputAttachmentCount; + const VkAttachmentReference2* pInputAttachments; + uint32_t colorAttachmentCount; + const VkAttachmentReference2* pColorAttachments; + const VkAttachmentReference2* pResolveAttachments; + const VkAttachmentReference2* pDepthStencilAttachment; + uint32_t preserveAttachmentCount; + const uint32_t* pPreserveAttachments; +} VkSubpassDescription2; + +typedef struct VkSubpassDependency2 { + VkStructureType sType; + const void* pNext; + uint32_t srcSubpass; + uint32_t dstSubpass; + VkPipelineStageFlags srcStageMask; + VkPipelineStageFlags dstStageMask; + VkAccessFlags srcAccessMask; + VkAccessFlags dstAccessMask; + VkDependencyFlags dependencyFlags; + int32_t viewOffset; +} VkSubpassDependency2; + +typedef struct VkRenderPassCreateInfo2 { + VkStructureType sType; + const void* pNext; + VkRenderPassCreateFlags flags; + uint32_t attachmentCount; + const VkAttachmentDescription2* pAttachments; + uint32_t subpassCount; + const VkSubpassDescription2* pSubpasses; + uint32_t dependencyCount; + const VkSubpassDependency2* pDependencies; + uint32_t correlatedViewMaskCount; + const uint32_t* pCorrelatedViewMasks; +} VkRenderPassCreateInfo2; + +typedef struct VkSubpassBeginInfo { + VkStructureType sType; + const void* pNext; + VkSubpassContents contents; +} VkSubpassBeginInfo; + +typedef struct VkSubpassEndInfo { + VkStructureType sType; + const void* pNext; +} VkSubpassEndInfo; + +typedef struct VkPhysicalDevice8BitStorageFeatures { + VkStructureType sType; + void* pNext; + VkBool32 storageBuffer8BitAccess; + VkBool32 uniformAndStorageBuffer8BitAccess; + VkBool32 storagePushConstant8; +} VkPhysicalDevice8BitStorageFeatures; + +typedef struct VkPhysicalDeviceDriverProperties { + VkStructureType sType; + void* pNext; + VkDriverId driverID; + char driverName[VK_MAX_DRIVER_NAME_SIZE]; + char driverInfo[VK_MAX_DRIVER_INFO_SIZE]; + VkConformanceVersion conformanceVersion; +} VkPhysicalDeviceDriverProperties; + +typedef struct VkPhysicalDeviceShaderAtomicInt64Features { + VkStructureType sType; + void* pNext; + VkBool32 shaderBufferInt64Atomics; + VkBool32 shaderSharedInt64Atomics; +} VkPhysicalDeviceShaderAtomicInt64Features; + +typedef struct VkPhysicalDeviceShaderFloat16Int8Features { + VkStructureType sType; + void* pNext; + VkBool32 shaderFloat16; + VkBool32 shaderInt8; +} VkPhysicalDeviceShaderFloat16Int8Features; + +typedef struct VkPhysicalDeviceFloatControlsProperties { + VkStructureType sType; + void* pNext; + VkShaderFloatControlsIndependence denormBehaviorIndependence; + VkShaderFloatControlsIndependence roundingModeIndependence; + VkBool32 shaderSignedZeroInfNanPreserveFloat16; + VkBool32 shaderSignedZeroInfNanPreserveFloat32; + VkBool32 shaderSignedZeroInfNanPreserveFloat64; + VkBool32 shaderDenormPreserveFloat16; + VkBool32 shaderDenormPreserveFloat32; + VkBool32 shaderDenormPreserveFloat64; + VkBool32 shaderDenormFlushToZeroFloat16; + VkBool32 shaderDenormFlushToZeroFloat32; + VkBool32 shaderDenormFlushToZeroFloat64; + VkBool32 shaderRoundingModeRTEFloat16; + VkBool32 shaderRoundingModeRTEFloat32; + VkBool32 shaderRoundingModeRTEFloat64; + VkBool32 shaderRoundingModeRTZFloat16; + VkBool32 shaderRoundingModeRTZFloat32; + VkBool32 shaderRoundingModeRTZFloat64; +} VkPhysicalDeviceFloatControlsProperties; + +typedef struct VkDescriptorSetLayoutBindingFlagsCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t bindingCount; + const VkDescriptorBindingFlags* pBindingFlags; +} VkDescriptorSetLayoutBindingFlagsCreateInfo; + +typedef struct VkPhysicalDeviceDescriptorIndexingFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderInputAttachmentArrayDynamicIndexing; + VkBool32 shaderUniformTexelBufferArrayDynamicIndexing; + VkBool32 shaderStorageTexelBufferArrayDynamicIndexing; + VkBool32 shaderUniformBufferArrayNonUniformIndexing; + VkBool32 shaderSampledImageArrayNonUniformIndexing; + VkBool32 shaderStorageBufferArrayNonUniformIndexing; + VkBool32 shaderStorageImageArrayNonUniformIndexing; + VkBool32 shaderInputAttachmentArrayNonUniformIndexing; + VkBool32 shaderUniformTexelBufferArrayNonUniformIndexing; + VkBool32 shaderStorageTexelBufferArrayNonUniformIndexing; + VkBool32 descriptorBindingUniformBufferUpdateAfterBind; + VkBool32 descriptorBindingSampledImageUpdateAfterBind; + VkBool32 descriptorBindingStorageImageUpdateAfterBind; + VkBool32 descriptorBindingStorageBufferUpdateAfterBind; + VkBool32 descriptorBindingUniformTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingStorageTexelBufferUpdateAfterBind; + VkBool32 descriptorBindingUpdateUnusedWhilePending; + VkBool32 descriptorBindingPartiallyBound; + VkBool32 descriptorBindingVariableDescriptorCount; + VkBool32 runtimeDescriptorArray; +} VkPhysicalDeviceDescriptorIndexingFeatures; + +typedef struct VkPhysicalDeviceDescriptorIndexingProperties { + VkStructureType sType; + void* pNext; + uint32_t maxUpdateAfterBindDescriptorsInAllPools; + VkBool32 shaderUniformBufferArrayNonUniformIndexingNative; + VkBool32 shaderSampledImageArrayNonUniformIndexingNative; + VkBool32 shaderStorageBufferArrayNonUniformIndexingNative; + VkBool32 shaderStorageImageArrayNonUniformIndexingNative; + VkBool32 shaderInputAttachmentArrayNonUniformIndexingNative; + VkBool32 robustBufferAccessUpdateAfterBind; + VkBool32 quadDivergentImplicitLod; + uint32_t maxPerStageDescriptorUpdateAfterBindSamplers; + uint32_t maxPerStageDescriptorUpdateAfterBindUniformBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageBuffers; + uint32_t maxPerStageDescriptorUpdateAfterBindSampledImages; + uint32_t maxPerStageDescriptorUpdateAfterBindStorageImages; + uint32_t maxPerStageDescriptorUpdateAfterBindInputAttachments; + uint32_t maxPerStageUpdateAfterBindResources; + uint32_t maxDescriptorSetUpdateAfterBindSamplers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffers; + uint32_t maxDescriptorSetUpdateAfterBindUniformBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffers; + uint32_t maxDescriptorSetUpdateAfterBindStorageBuffersDynamic; + uint32_t maxDescriptorSetUpdateAfterBindSampledImages; + uint32_t maxDescriptorSetUpdateAfterBindStorageImages; + uint32_t maxDescriptorSetUpdateAfterBindInputAttachments; +} VkPhysicalDeviceDescriptorIndexingProperties; + +typedef struct VkDescriptorSetVariableDescriptorCountAllocateInfo { + VkStructureType sType; + const void* pNext; + uint32_t descriptorSetCount; + const uint32_t* pDescriptorCounts; +} VkDescriptorSetVariableDescriptorCountAllocateInfo; + +typedef struct VkDescriptorSetVariableDescriptorCountLayoutSupport { + VkStructureType sType; + void* pNext; + uint32_t maxVariableDescriptorCount; +} VkDescriptorSetVariableDescriptorCountLayoutSupport; + +typedef struct VkSubpassDescriptionDepthStencilResolve { + VkStructureType sType; + const void* pNext; + VkResolveModeFlagBits depthResolveMode; + VkResolveModeFlagBits stencilResolveMode; + const VkAttachmentReference2* pDepthStencilResolveAttachment; +} VkSubpassDescriptionDepthStencilResolve; + +typedef struct VkPhysicalDeviceDepthStencilResolveProperties { + VkStructureType sType; + void* pNext; + VkResolveModeFlags supportedDepthResolveModes; + VkResolveModeFlags supportedStencilResolveModes; + VkBool32 independentResolveNone; + VkBool32 independentResolve; +} VkPhysicalDeviceDepthStencilResolveProperties; + +typedef struct VkPhysicalDeviceScalarBlockLayoutFeatures { + VkStructureType sType; + void* pNext; + VkBool32 scalarBlockLayout; +} VkPhysicalDeviceScalarBlockLayoutFeatures; + +typedef struct VkImageStencilUsageCreateInfo { + VkStructureType sType; + const void* pNext; + VkImageUsageFlags stencilUsage; +} VkImageStencilUsageCreateInfo; + +typedef struct VkSamplerReductionModeCreateInfo { + VkStructureType sType; + const void* pNext; + VkSamplerReductionMode reductionMode; +} VkSamplerReductionModeCreateInfo; + +typedef struct VkPhysicalDeviceSamplerFilterMinmaxProperties { + VkStructureType sType; + void* pNext; + VkBool32 filterMinmaxSingleComponentFormats; + VkBool32 filterMinmaxImageComponentMapping; +} VkPhysicalDeviceSamplerFilterMinmaxProperties; + +typedef struct VkPhysicalDeviceVulkanMemoryModelFeatures { + VkStructureType sType; + void* pNext; + VkBool32 vulkanMemoryModel; + VkBool32 vulkanMemoryModelDeviceScope; + VkBool32 vulkanMemoryModelAvailabilityVisibilityChains; +} VkPhysicalDeviceVulkanMemoryModelFeatures; + +typedef struct VkPhysicalDeviceImagelessFramebufferFeatures { + VkStructureType sType; + void* pNext; + VkBool32 imagelessFramebuffer; +} VkPhysicalDeviceImagelessFramebufferFeatures; + +typedef struct VkFramebufferAttachmentImageInfo { + VkStructureType sType; + const void* pNext; + VkImageCreateFlags flags; + VkImageUsageFlags usage; + uint32_t width; + uint32_t height; + uint32_t layerCount; + uint32_t viewFormatCount; + const VkFormat* pViewFormats; +} VkFramebufferAttachmentImageInfo; + +typedef struct VkFramebufferAttachmentsCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t attachmentImageInfoCount; + const VkFramebufferAttachmentImageInfo* pAttachmentImageInfos; +} VkFramebufferAttachmentsCreateInfo; + +typedef struct VkRenderPassAttachmentBeginInfo { + VkStructureType sType; + const void* pNext; + uint32_t attachmentCount; + const VkImageView* pAttachments; +} VkRenderPassAttachmentBeginInfo; + +typedef struct VkPhysicalDeviceUniformBufferStandardLayoutFeatures { + VkStructureType sType; + void* pNext; + VkBool32 uniformBufferStandardLayout; +} VkPhysicalDeviceUniformBufferStandardLayoutFeatures; + +typedef struct VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderSubgroupExtendedTypes; +} VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures; + +typedef struct VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures { + VkStructureType sType; + void* pNext; + VkBool32 separateDepthStencilLayouts; +} VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures; + +typedef struct VkAttachmentReferenceStencilLayout { + VkStructureType sType; + void* pNext; + VkImageLayout stencilLayout; +} VkAttachmentReferenceStencilLayout; + +typedef struct VkAttachmentDescriptionStencilLayout { + VkStructureType sType; + void* pNext; + VkImageLayout stencilInitialLayout; + VkImageLayout stencilFinalLayout; +} VkAttachmentDescriptionStencilLayout; + +typedef struct VkPhysicalDeviceHostQueryResetFeatures { + VkStructureType sType; + void* pNext; + VkBool32 hostQueryReset; +} VkPhysicalDeviceHostQueryResetFeatures; + +typedef struct VkPhysicalDeviceTimelineSemaphoreFeatures { + VkStructureType sType; + void* pNext; + VkBool32 timelineSemaphore; +} VkPhysicalDeviceTimelineSemaphoreFeatures; + +typedef struct VkPhysicalDeviceTimelineSemaphoreProperties { + VkStructureType sType; + void* pNext; + uint64_t maxTimelineSemaphoreValueDifference; +} VkPhysicalDeviceTimelineSemaphoreProperties; + +typedef struct VkSemaphoreTypeCreateInfo { + VkStructureType sType; + const void* pNext; + VkSemaphoreType semaphoreType; + uint64_t initialValue; +} VkSemaphoreTypeCreateInfo; + +typedef struct VkTimelineSemaphoreSubmitInfo { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreValueCount; + const uint64_t* pWaitSemaphoreValues; + uint32_t signalSemaphoreValueCount; + const uint64_t* pSignalSemaphoreValues; +} VkTimelineSemaphoreSubmitInfo; + +typedef struct VkSemaphoreWaitInfo { + VkStructureType sType; + const void* pNext; + VkSemaphoreWaitFlags flags; + uint32_t semaphoreCount; + const VkSemaphore* pSemaphores; + const uint64_t* pValues; +} VkSemaphoreWaitInfo; + +typedef struct VkSemaphoreSignalInfo { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + uint64_t value; +} VkSemaphoreSignalInfo; + +typedef struct VkPhysicalDeviceBufferDeviceAddressFeatures { + VkStructureType sType; + void* pNext; + VkBool32 bufferDeviceAddress; + VkBool32 bufferDeviceAddressCaptureReplay; + VkBool32 bufferDeviceAddressMultiDevice; +} VkPhysicalDeviceBufferDeviceAddressFeatures; + +typedef struct VkBufferDeviceAddressInfo { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; +} VkBufferDeviceAddressInfo; + +typedef struct VkBufferOpaqueCaptureAddressCreateInfo { + VkStructureType sType; + const void* pNext; + uint64_t opaqueCaptureAddress; +} VkBufferOpaqueCaptureAddressCreateInfo; + +typedef struct VkMemoryOpaqueCaptureAddressAllocateInfo { + VkStructureType sType; + const void* pNext; + uint64_t opaqueCaptureAddress; +} VkMemoryOpaqueCaptureAddressAllocateInfo; + +typedef struct VkDeviceMemoryOpaqueCaptureAddressInfo { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; +} VkDeviceMemoryOpaqueCaptureAddressInfo; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCount)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCount)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass2)(VkDevice device, const VkRenderPassCreateInfo2* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass); +typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass2)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassBeginInfo* pSubpassBeginInfo); +typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass2)(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo, const VkSubpassEndInfo* pSubpassEndInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass2)(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo); +typedef void (VKAPI_PTR *PFN_vkResetQueryPool)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreCounterValue)(VkDevice device, VkSemaphore semaphore, uint64_t* pValue); +typedef VkResult (VKAPI_PTR *PFN_vkWaitSemaphores)(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout); +typedef VkResult (VKAPI_PTR *PFN_vkSignalSemaphore)(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo); +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetBufferDeviceAddress)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetBufferOpaqueCaptureAddress)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetDeviceMemoryOpaqueCaptureAddress)(VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCount( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCount( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2( + VkDevice device, + const VkRenderPassCreateInfo2* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkRenderPass* pRenderPass); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2( + VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + const VkSubpassBeginInfo* pSubpassBeginInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2( + VkCommandBuffer commandBuffer, + const VkSubpassBeginInfo* pSubpassBeginInfo, + const VkSubpassEndInfo* pSubpassEndInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2( + VkCommandBuffer commandBuffer, + const VkSubpassEndInfo* pSubpassEndInfo); + +VKAPI_ATTR void VKAPI_CALL vkResetQueryPool( + VkDevice device, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreCounterValue( + VkDevice device, + VkSemaphore semaphore, + uint64_t* pValue); + +VKAPI_ATTR VkResult VKAPI_CALL vkWaitSemaphores( + VkDevice device, + const VkSemaphoreWaitInfo* pWaitInfo, + uint64_t timeout); + +VKAPI_ATTR VkResult VKAPI_CALL vkSignalSemaphore( + VkDevice device, + const VkSemaphoreSignalInfo* pSignalInfo); + +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddress( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferOpaqueCaptureAddress( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddress( + VkDevice device, + const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); +#endif + + +// VK_VERSION_1_3 is a preprocessor guard. Do not pass it to API calls. +#define VK_VERSION_1_3 1 +// Vulkan 1.3 version number +#define VK_API_VERSION_1_3 VK_MAKE_API_VERSION(0, 1, 3, 0)// Patch version should always be set to 0 + +typedef uint64_t VkFlags64; +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPrivateDataSlot) + +typedef enum VkPipelineCreationFeedbackFlagBits { + VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT = 0x00000001, + VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT = 0x00000002, + VK_PIPELINE_CREATION_FEEDBACK_BASE_PIPELINE_ACCELERATION_BIT = 0x00000004, + VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT_EXT = VK_PIPELINE_CREATION_FEEDBACK_VALID_BIT, + VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT_EXT = VK_PIPELINE_CREATION_FEEDBACK_APPLICATION_PIPELINE_CACHE_HIT_BIT, + VK_PIPELINE_CREATION_FEEDBACK_BASE_PIPELINE_ACCELERATION_BIT_EXT = VK_PIPELINE_CREATION_FEEDBACK_BASE_PIPELINE_ACCELERATION_BIT, + VK_PIPELINE_CREATION_FEEDBACK_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkPipelineCreationFeedbackFlagBits; +typedef VkFlags VkPipelineCreationFeedbackFlags; + +typedef enum VkToolPurposeFlagBits { + VK_TOOL_PURPOSE_VALIDATION_BIT = 0x00000001, + VK_TOOL_PURPOSE_PROFILING_BIT = 0x00000002, + VK_TOOL_PURPOSE_TRACING_BIT = 0x00000004, + VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT = 0x00000008, + VK_TOOL_PURPOSE_MODIFYING_FEATURES_BIT = 0x00000010, + VK_TOOL_PURPOSE_DEBUG_REPORTING_BIT_EXT = 0x00000020, + VK_TOOL_PURPOSE_DEBUG_MARKERS_BIT_EXT = 0x00000040, + VK_TOOL_PURPOSE_VALIDATION_BIT_EXT = VK_TOOL_PURPOSE_VALIDATION_BIT, + VK_TOOL_PURPOSE_PROFILING_BIT_EXT = VK_TOOL_PURPOSE_PROFILING_BIT, + VK_TOOL_PURPOSE_TRACING_BIT_EXT = VK_TOOL_PURPOSE_TRACING_BIT, + VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT_EXT = VK_TOOL_PURPOSE_ADDITIONAL_FEATURES_BIT, + VK_TOOL_PURPOSE_MODIFYING_FEATURES_BIT_EXT = VK_TOOL_PURPOSE_MODIFYING_FEATURES_BIT, + VK_TOOL_PURPOSE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkToolPurposeFlagBits; +typedef VkFlags VkToolPurposeFlags; +typedef VkFlags VkPrivateDataSlotCreateFlags; +typedef VkFlags64 VkPipelineStageFlags2; + +// Flag bits for VkPipelineStageFlagBits2 +typedef VkFlags64 VkPipelineStageFlagBits2; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_NONE = 0ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_NONE_KHR = 0ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT = 0x00000001ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TOP_OF_PIPE_BIT_KHR = 0x00000001ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT = 0x00000002ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_DRAW_INDIRECT_BIT_KHR = 0x00000002ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT = 0x00000004ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_INPUT_BIT_KHR = 0x00000004ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT = 0x00000008ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR = 0x00000008ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_CONTROL_SHADER_BIT = 0x00000010ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_CONTROL_SHADER_BIT_KHR = 0x00000010ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_EVALUATION_SHADER_BIT = 0x00000020ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TESSELLATION_EVALUATION_SHADER_BIT_KHR = 0x00000020ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT = 0x00000040ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_GEOMETRY_SHADER_BIT_KHR = 0x00000040ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT = 0x00000080ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_FRAGMENT_SHADER_BIT_KHR = 0x00000080ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT = 0x00000100ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_EARLY_FRAGMENT_TESTS_BIT_KHR = 0x00000100ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT = 0x00000200ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_LATE_FRAGMENT_TESTS_BIT_KHR = 0x00000200ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT = 0x00000400ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COLOR_ATTACHMENT_OUTPUT_BIT_KHR = 0x00000400ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT = 0x00000800ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COMPUTE_SHADER_BIT_KHR = 0x00000800ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT = 0x00001000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_TRANSFER_BIT_KHR = 0x00001000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TRANSFER_BIT = 0x00001000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TRANSFER_BIT_KHR = 0x00001000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT = 0x00002000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BOTTOM_OF_PIPE_BIT_KHR = 0x00002000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_HOST_BIT = 0x00004000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_HOST_BIT_KHR = 0x00004000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT = 0x00008000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_GRAPHICS_BIT_KHR = 0x00008000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT = 0x00010000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ALL_COMMANDS_BIT_KHR = 0x00010000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COPY_BIT = 0x100000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COPY_BIT_KHR = 0x100000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_RESOLVE_BIT = 0x200000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_RESOLVE_BIT_KHR = 0x200000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BLIT_BIT = 0x400000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_BLIT_BIT_KHR = 0x400000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CLEAR_BIT = 0x800000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CLEAR_BIT_KHR = 0x800000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT = 0x1000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_INDEX_INPUT_BIT_KHR = 0x1000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT = 0x2000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VERTEX_ATTRIBUTE_INPUT_BIT_KHR = 0x2000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT = 0x4000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_PRE_RASTERIZATION_SHADERS_BIT_KHR = 0x4000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VIDEO_DECODE_BIT_KHR = 0x04000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_VIDEO_ENCODE_BIT_KHR = 0x08000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TRANSFORM_FEEDBACK_BIT_EXT = 0x01000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CONDITIONAL_RENDERING_BIT_EXT = 0x00040000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_COMMAND_PREPROCESS_BIT_NV = 0x00020000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00400000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_SHADING_RATE_IMAGE_BIT_NV = 0x00400000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_KHR = 0x02000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_KHR = 0x00200000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_RAY_TRACING_SHADER_BIT_NV = 0x00200000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_BUILD_BIT_NV = 0x02000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_FRAGMENT_DENSITY_PROCESS_BIT_EXT = 0x00800000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_NV = 0x00080000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_NV = 0x00100000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_TASK_SHADER_BIT_EXT = 0x00080000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MESH_SHADER_BIT_EXT = 0x00100000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_SUBPASS_SHADER_BIT_HUAWEI = 0x8000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_SUBPASS_SHADING_BIT_HUAWEI = 0x8000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_INVOCATION_MASK_BIT_HUAWEI = 0x10000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_ACCELERATION_STRUCTURE_COPY_BIT_KHR = 0x10000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_MICROMAP_BUILD_BIT_EXT = 0x40000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_CLUSTER_CULLING_SHADER_BIT_HUAWEI = 0x20000000000ULL; +static const VkPipelineStageFlagBits2 VK_PIPELINE_STAGE_2_OPTICAL_FLOW_BIT_NV = 0x20000000ULL; + +typedef VkFlags64 VkAccessFlags2; + +// Flag bits for VkAccessFlagBits2 +typedef VkFlags64 VkAccessFlagBits2; +static const VkAccessFlagBits2 VK_ACCESS_2_NONE = 0ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_NONE_KHR = 0ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT = 0x00000001ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_INDIRECT_COMMAND_READ_BIT_KHR = 0x00000001ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_INDEX_READ_BIT = 0x00000002ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_INDEX_READ_BIT_KHR = 0x00000002ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT = 0x00000004ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_VERTEX_ATTRIBUTE_READ_BIT_KHR = 0x00000004ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_UNIFORM_READ_BIT = 0x00000008ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_UNIFORM_READ_BIT_KHR = 0x00000008ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT = 0x00000010ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_INPUT_ATTACHMENT_READ_BIT_KHR = 0x00000010ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_READ_BIT = 0x00000020ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_READ_BIT_KHR = 0x00000020ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_WRITE_BIT = 0x00000040ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_WRITE_BIT_KHR = 0x00000040ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT = 0x00000080ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_READ_BIT_KHR = 0x00000080ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT = 0x00000100ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_WRITE_BIT_KHR = 0x00000100ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT = 0x00000200ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_READ_BIT_KHR = 0x00000200ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT = 0x00000400ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT_KHR = 0x00000400ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_READ_BIT = 0x00000800ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_READ_BIT_KHR = 0x00000800ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_WRITE_BIT = 0x00001000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFER_WRITE_BIT_KHR = 0x00001000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_HOST_READ_BIT = 0x00002000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_HOST_READ_BIT_KHR = 0x00002000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_HOST_WRITE_BIT = 0x00004000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_HOST_WRITE_BIT_KHR = 0x00004000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_READ_BIT = 0x00008000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_READ_BIT_KHR = 0x00008000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_WRITE_BIT = 0x00010000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MEMORY_WRITE_BIT_KHR = 0x00010000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_SAMPLED_READ_BIT = 0x100000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_SAMPLED_READ_BIT_KHR = 0x100000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT = 0x200000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_READ_BIT_KHR = 0x200000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT = 0x400000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_STORAGE_WRITE_BIT_KHR = 0x400000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_DECODE_READ_BIT_KHR = 0x800000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_DECODE_WRITE_BIT_KHR = 0x1000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_ENCODE_READ_BIT_KHR = 0x2000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_VIDEO_ENCODE_WRITE_BIT_KHR = 0x4000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFORM_FEEDBACK_WRITE_BIT_EXT = 0x02000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT = 0x04000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT = 0x08000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_CONDITIONAL_RENDERING_READ_BIT_EXT = 0x00100000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_COMMAND_PREPROCESS_READ_BIT_NV = 0x00020000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_COMMAND_PREPROCESS_WRITE_BIT_NV = 0x00040000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_FRAGMENT_SHADING_RATE_ATTACHMENT_READ_BIT_KHR = 0x00800000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADING_RATE_IMAGE_READ_BIT_NV = 0x00800000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_KHR = 0x00200000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_KHR = 0x00400000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_READ_BIT_NV = 0x00200000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_ACCELERATION_STRUCTURE_WRITE_BIT_NV = 0x00400000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_FRAGMENT_DENSITY_MAP_READ_BIT_EXT = 0x01000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_COLOR_ATTACHMENT_READ_NONCOHERENT_BIT_EXT = 0x00080000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_DESCRIPTOR_BUFFER_READ_BIT_EXT = 0x20000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_INVOCATION_MASK_READ_BIT_HUAWEI = 0x8000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_SHADER_BINDING_TABLE_READ_BIT_KHR = 0x10000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MICROMAP_READ_BIT_EXT = 0x100000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_MICROMAP_WRITE_BIT_EXT = 0x200000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_OPTICAL_FLOW_READ_BIT_NV = 0x40000000000ULL; +static const VkAccessFlagBits2 VK_ACCESS_2_OPTICAL_FLOW_WRITE_BIT_NV = 0x80000000000ULL; + + +typedef enum VkSubmitFlagBits { + VK_SUBMIT_PROTECTED_BIT = 0x00000001, + VK_SUBMIT_PROTECTED_BIT_KHR = VK_SUBMIT_PROTECTED_BIT, + VK_SUBMIT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkSubmitFlagBits; +typedef VkFlags VkSubmitFlags; + +typedef enum VkRenderingFlagBits { + VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT = 0x00000001, + VK_RENDERING_SUSPENDING_BIT = 0x00000002, + VK_RENDERING_RESUMING_BIT = 0x00000004, + VK_RENDERING_CONTENTS_INLINE_BIT_EXT = 0x00000010, + VK_RENDERING_ENABLE_LEGACY_DITHERING_BIT_EXT = 0x00000008, + VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT_KHR = VK_RENDERING_CONTENTS_SECONDARY_COMMAND_BUFFERS_BIT, + VK_RENDERING_SUSPENDING_BIT_KHR = VK_RENDERING_SUSPENDING_BIT, + VK_RENDERING_RESUMING_BIT_KHR = VK_RENDERING_RESUMING_BIT, + VK_RENDERING_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF +} VkRenderingFlagBits; +typedef VkFlags VkRenderingFlags; +typedef VkFlags64 VkFormatFeatureFlags2; + +// Flag bits for VkFormatFeatureFlagBits2 +typedef VkFlags64 VkFormatFeatureFlagBits2; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT = 0x00000001ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT_KHR = 0x00000001ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT = 0x00000002ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_BIT_KHR = 0x00000002ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT = 0x00000004ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_IMAGE_ATOMIC_BIT_KHR = 0x00000004ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT = 0x00000008ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT_KHR = 0x00000008ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT = 0x00000010ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_BIT_KHR = 0x00000010ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT = 0x00000020ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_TEXEL_BUFFER_ATOMIC_BIT_KHR = 0x00000020ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT = 0x00000040ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT_KHR = 0x00000040ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT = 0x00000080ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BIT_KHR = 0x00000080ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT = 0x00000100ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COLOR_ATTACHMENT_BLEND_BIT_KHR = 0x00000100ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000200ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DEPTH_STENCIL_ATTACHMENT_BIT_KHR = 0x00000200ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_SRC_BIT = 0x00000400ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_SRC_BIT_KHR = 0x00000400ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_DST_BIT = 0x00000800ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLIT_DST_BIT_KHR = 0x00000800ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT_KHR = 0x00001000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_CUBIC_BIT = 0x00002000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_CUBIC_BIT_EXT = 0x00002000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT = 0x00004000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_SRC_BIT_KHR = 0x00004000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT = 0x00008000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_TRANSFER_DST_BIT_KHR = 0x00008000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT = 0x00010000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_MINMAX_BIT_KHR = 0x00010000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_MIDPOINT_CHROMA_SAMPLES_BIT = 0x00020000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_MIDPOINT_CHROMA_SAMPLES_BIT_KHR = 0x00020000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT = 0x00040000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT_KHR = 0x00040000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT = 0x00080000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_SEPARATE_RECONSTRUCTION_FILTER_BIT_KHR = 0x00080000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT = 0x00100000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_BIT_KHR = 0x00100000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT = 0x00200000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_YCBCR_CONVERSION_CHROMA_RECONSTRUCTION_EXPLICIT_FORCEABLE_BIT_KHR = 0x00200000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DISJOINT_BIT = 0x00400000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_DISJOINT_BIT_KHR = 0x00400000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COSITED_CHROMA_SAMPLES_BIT = 0x00800000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_COSITED_CHROMA_SAMPLES_BIT_KHR = 0x00800000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT = 0x80000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_READ_WITHOUT_FORMAT_BIT_KHR = 0x80000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT = 0x100000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_STORAGE_WRITE_WITHOUT_FORMAT_BIT_KHR = 0x100000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT = 0x200000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_DEPTH_COMPARISON_BIT_KHR = 0x200000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_DECODE_OUTPUT_BIT_KHR = 0x02000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_DECODE_DPB_BIT_KHR = 0x04000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_ACCELERATION_STRUCTURE_VERTEX_BUFFER_BIT_KHR = 0x20000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_FRAGMENT_DENSITY_MAP_BIT_EXT = 0x01000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x40000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_HOST_IMAGE_TRANSFER_BIT_EXT = 0x400000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_ENCODE_INPUT_BIT_KHR = 0x08000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_VIDEO_ENCODE_DPB_BIT_KHR = 0x10000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_LINEAR_COLOR_ATTACHMENT_BIT_NV = 0x4000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_WEIGHT_IMAGE_BIT_QCOM = 0x400000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_WEIGHT_SAMPLED_IMAGE_BIT_QCOM = 0x800000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BLOCK_MATCHING_BIT_QCOM = 0x1000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_BOX_FILTER_SAMPLED_BIT_QCOM = 0x2000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_IMAGE_BIT_NV = 0x10000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_VECTOR_BIT_NV = 0x20000000000ULL; +static const VkFormatFeatureFlagBits2 VK_FORMAT_FEATURE_2_OPTICAL_FLOW_COST_BIT_NV = 0x40000000000ULL; + +typedef struct VkPhysicalDeviceVulkan13Features { + VkStructureType sType; + void* pNext; + VkBool32 robustImageAccess; + VkBool32 inlineUniformBlock; + VkBool32 descriptorBindingInlineUniformBlockUpdateAfterBind; + VkBool32 pipelineCreationCacheControl; + VkBool32 privateData; + VkBool32 shaderDemoteToHelperInvocation; + VkBool32 shaderTerminateInvocation; + VkBool32 subgroupSizeControl; + VkBool32 computeFullSubgroups; + VkBool32 synchronization2; + VkBool32 textureCompressionASTC_HDR; + VkBool32 shaderZeroInitializeWorkgroupMemory; + VkBool32 dynamicRendering; + VkBool32 shaderIntegerDotProduct; + VkBool32 maintenance4; +} VkPhysicalDeviceVulkan13Features; + +typedef struct VkPhysicalDeviceVulkan13Properties { + VkStructureType sType; + void* pNext; + uint32_t minSubgroupSize; + uint32_t maxSubgroupSize; + uint32_t maxComputeWorkgroupSubgroups; + VkShaderStageFlags requiredSubgroupSizeStages; + uint32_t maxInlineUniformBlockSize; + uint32_t maxPerStageDescriptorInlineUniformBlocks; + uint32_t maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks; + uint32_t maxDescriptorSetInlineUniformBlocks; + uint32_t maxDescriptorSetUpdateAfterBindInlineUniformBlocks; + uint32_t maxInlineUniformTotalSize; + VkBool32 integerDotProduct8BitUnsignedAccelerated; + VkBool32 integerDotProduct8BitSignedAccelerated; + VkBool32 integerDotProduct8BitMixedSignednessAccelerated; + VkBool32 integerDotProduct4x8BitPackedUnsignedAccelerated; + VkBool32 integerDotProduct4x8BitPackedSignedAccelerated; + VkBool32 integerDotProduct4x8BitPackedMixedSignednessAccelerated; + VkBool32 integerDotProduct16BitUnsignedAccelerated; + VkBool32 integerDotProduct16BitSignedAccelerated; + VkBool32 integerDotProduct16BitMixedSignednessAccelerated; + VkBool32 integerDotProduct32BitUnsignedAccelerated; + VkBool32 integerDotProduct32BitSignedAccelerated; + VkBool32 integerDotProduct32BitMixedSignednessAccelerated; + VkBool32 integerDotProduct64BitUnsignedAccelerated; + VkBool32 integerDotProduct64BitSignedAccelerated; + VkBool32 integerDotProduct64BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating8BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating8BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating16BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating16BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating32BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating32BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating64BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating64BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated; + VkDeviceSize storageTexelBufferOffsetAlignmentBytes; + VkBool32 storageTexelBufferOffsetSingleTexelAlignment; + VkDeviceSize uniformTexelBufferOffsetAlignmentBytes; + VkBool32 uniformTexelBufferOffsetSingleTexelAlignment; + VkDeviceSize maxBufferSize; +} VkPhysicalDeviceVulkan13Properties; + +typedef struct VkPipelineCreationFeedback { + VkPipelineCreationFeedbackFlags flags; + uint64_t duration; +} VkPipelineCreationFeedback; + +typedef struct VkPipelineCreationFeedbackCreateInfo { + VkStructureType sType; + const void* pNext; + VkPipelineCreationFeedback* pPipelineCreationFeedback; + uint32_t pipelineStageCreationFeedbackCount; + VkPipelineCreationFeedback* pPipelineStageCreationFeedbacks; +} VkPipelineCreationFeedbackCreateInfo; + +typedef struct VkPhysicalDeviceShaderTerminateInvocationFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderTerminateInvocation; +} VkPhysicalDeviceShaderTerminateInvocationFeatures; + +typedef struct VkPhysicalDeviceToolProperties { + VkStructureType sType; + void* pNext; + char name[VK_MAX_EXTENSION_NAME_SIZE]; + char version[VK_MAX_EXTENSION_NAME_SIZE]; + VkToolPurposeFlags purposes; + char description[VK_MAX_DESCRIPTION_SIZE]; + char layer[VK_MAX_EXTENSION_NAME_SIZE]; +} VkPhysicalDeviceToolProperties; + +typedef struct VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderDemoteToHelperInvocation; +} VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures; + +typedef struct VkPhysicalDevicePrivateDataFeatures { + VkStructureType sType; + void* pNext; + VkBool32 privateData; +} VkPhysicalDevicePrivateDataFeatures; + +typedef struct VkDevicePrivateDataCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t privateDataSlotRequestCount; +} VkDevicePrivateDataCreateInfo; + +typedef struct VkPrivateDataSlotCreateInfo { + VkStructureType sType; + const void* pNext; + VkPrivateDataSlotCreateFlags flags; +} VkPrivateDataSlotCreateInfo; + +typedef struct VkPhysicalDevicePipelineCreationCacheControlFeatures { + VkStructureType sType; + void* pNext; + VkBool32 pipelineCreationCacheControl; +} VkPhysicalDevicePipelineCreationCacheControlFeatures; + +typedef struct VkMemoryBarrier2 { + VkStructureType sType; + const void* pNext; + VkPipelineStageFlags2 srcStageMask; + VkAccessFlags2 srcAccessMask; + VkPipelineStageFlags2 dstStageMask; + VkAccessFlags2 dstAccessMask; +} VkMemoryBarrier2; + +typedef struct VkBufferMemoryBarrier2 { + VkStructureType sType; + const void* pNext; + VkPipelineStageFlags2 srcStageMask; + VkAccessFlags2 srcAccessMask; + VkPipelineStageFlags2 dstStageMask; + VkAccessFlags2 dstAccessMask; + uint32_t srcQueueFamilyIndex; + uint32_t dstQueueFamilyIndex; + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize size; +} VkBufferMemoryBarrier2; + +typedef struct VkImageMemoryBarrier2 { + VkStructureType sType; + const void* pNext; + VkPipelineStageFlags2 srcStageMask; + VkAccessFlags2 srcAccessMask; + VkPipelineStageFlags2 dstStageMask; + VkAccessFlags2 dstAccessMask; + VkImageLayout oldLayout; + VkImageLayout newLayout; + uint32_t srcQueueFamilyIndex; + uint32_t dstQueueFamilyIndex; + VkImage image; + VkImageSubresourceRange subresourceRange; +} VkImageMemoryBarrier2; + +typedef struct VkDependencyInfo { + VkStructureType sType; + const void* pNext; + VkDependencyFlags dependencyFlags; + uint32_t memoryBarrierCount; + const VkMemoryBarrier2* pMemoryBarriers; + uint32_t bufferMemoryBarrierCount; + const VkBufferMemoryBarrier2* pBufferMemoryBarriers; + uint32_t imageMemoryBarrierCount; + const VkImageMemoryBarrier2* pImageMemoryBarriers; +} VkDependencyInfo; + +typedef struct VkSemaphoreSubmitInfo { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + uint64_t value; + VkPipelineStageFlags2 stageMask; + uint32_t deviceIndex; +} VkSemaphoreSubmitInfo; + +typedef struct VkCommandBufferSubmitInfo { + VkStructureType sType; + const void* pNext; + VkCommandBuffer commandBuffer; + uint32_t deviceMask; +} VkCommandBufferSubmitInfo; + +typedef struct VkSubmitInfo2 { + VkStructureType sType; + const void* pNext; + VkSubmitFlags flags; + uint32_t waitSemaphoreInfoCount; + const VkSemaphoreSubmitInfo* pWaitSemaphoreInfos; + uint32_t commandBufferInfoCount; + const VkCommandBufferSubmitInfo* pCommandBufferInfos; + uint32_t signalSemaphoreInfoCount; + const VkSemaphoreSubmitInfo* pSignalSemaphoreInfos; +} VkSubmitInfo2; + +typedef struct VkPhysicalDeviceSynchronization2Features { + VkStructureType sType; + void* pNext; + VkBool32 synchronization2; +} VkPhysicalDeviceSynchronization2Features; + +typedef struct VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderZeroInitializeWorkgroupMemory; +} VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures; + +typedef struct VkPhysicalDeviceImageRobustnessFeatures { + VkStructureType sType; + void* pNext; + VkBool32 robustImageAccess; +} VkPhysicalDeviceImageRobustnessFeatures; + +typedef struct VkBufferCopy2 { + VkStructureType sType; + const void* pNext; + VkDeviceSize srcOffset; + VkDeviceSize dstOffset; + VkDeviceSize size; +} VkBufferCopy2; + +typedef struct VkCopyBufferInfo2 { + VkStructureType sType; + const void* pNext; + VkBuffer srcBuffer; + VkBuffer dstBuffer; + uint32_t regionCount; + const VkBufferCopy2* pRegions; +} VkCopyBufferInfo2; + +typedef struct VkImageCopy2 { + VkStructureType sType; + const void* pNext; + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; + VkExtent3D extent; +} VkImageCopy2; + +typedef struct VkCopyImageInfo2 { + VkStructureType sType; + const void* pNext; + VkImage srcImage; + VkImageLayout srcImageLayout; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkImageCopy2* pRegions; +} VkCopyImageInfo2; + +typedef struct VkBufferImageCopy2 { + VkStructureType sType; + const void* pNext; + VkDeviceSize bufferOffset; + uint32_t bufferRowLength; + uint32_t bufferImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkBufferImageCopy2; + +typedef struct VkCopyBufferToImageInfo2 { + VkStructureType sType; + const void* pNext; + VkBuffer srcBuffer; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkBufferImageCopy2* pRegions; +} VkCopyBufferToImageInfo2; + +typedef struct VkCopyImageToBufferInfo2 { + VkStructureType sType; + const void* pNext; + VkImage srcImage; + VkImageLayout srcImageLayout; + VkBuffer dstBuffer; + uint32_t regionCount; + const VkBufferImageCopy2* pRegions; +} VkCopyImageToBufferInfo2; + +typedef struct VkImageBlit2 { + VkStructureType sType; + const void* pNext; + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffsets[2]; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffsets[2]; +} VkImageBlit2; + +typedef struct VkBlitImageInfo2 { + VkStructureType sType; + const void* pNext; + VkImage srcImage; + VkImageLayout srcImageLayout; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkImageBlit2* pRegions; + VkFilter filter; +} VkBlitImageInfo2; + +typedef struct VkImageResolve2 { + VkStructureType sType; + const void* pNext; + VkImageSubresourceLayers srcSubresource; + VkOffset3D srcOffset; + VkImageSubresourceLayers dstSubresource; + VkOffset3D dstOffset; + VkExtent3D extent; +} VkImageResolve2; + +typedef struct VkResolveImageInfo2 { + VkStructureType sType; + const void* pNext; + VkImage srcImage; + VkImageLayout srcImageLayout; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkImageResolve2* pRegions; +} VkResolveImageInfo2; + +typedef struct VkPhysicalDeviceSubgroupSizeControlFeatures { + VkStructureType sType; + void* pNext; + VkBool32 subgroupSizeControl; + VkBool32 computeFullSubgroups; +} VkPhysicalDeviceSubgroupSizeControlFeatures; + +typedef struct VkPhysicalDeviceSubgroupSizeControlProperties { + VkStructureType sType; + void* pNext; + uint32_t minSubgroupSize; + uint32_t maxSubgroupSize; + uint32_t maxComputeWorkgroupSubgroups; + VkShaderStageFlags requiredSubgroupSizeStages; +} VkPhysicalDeviceSubgroupSizeControlProperties; + +typedef struct VkPipelineShaderStageRequiredSubgroupSizeCreateInfo { + VkStructureType sType; + void* pNext; + uint32_t requiredSubgroupSize; +} VkPipelineShaderStageRequiredSubgroupSizeCreateInfo; + +typedef struct VkPhysicalDeviceInlineUniformBlockFeatures { + VkStructureType sType; + void* pNext; + VkBool32 inlineUniformBlock; + VkBool32 descriptorBindingInlineUniformBlockUpdateAfterBind; +} VkPhysicalDeviceInlineUniformBlockFeatures; + +typedef struct VkPhysicalDeviceInlineUniformBlockProperties { + VkStructureType sType; + void* pNext; + uint32_t maxInlineUniformBlockSize; + uint32_t maxPerStageDescriptorInlineUniformBlocks; + uint32_t maxPerStageDescriptorUpdateAfterBindInlineUniformBlocks; + uint32_t maxDescriptorSetInlineUniformBlocks; + uint32_t maxDescriptorSetUpdateAfterBindInlineUniformBlocks; +} VkPhysicalDeviceInlineUniformBlockProperties; + +typedef struct VkWriteDescriptorSetInlineUniformBlock { + VkStructureType sType; + const void* pNext; + uint32_t dataSize; + const void* pData; +} VkWriteDescriptorSetInlineUniformBlock; + +typedef struct VkDescriptorPoolInlineUniformBlockCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t maxInlineUniformBlockBindings; +} VkDescriptorPoolInlineUniformBlockCreateInfo; + +typedef struct VkPhysicalDeviceTextureCompressionASTCHDRFeatures { + VkStructureType sType; + void* pNext; + VkBool32 textureCompressionASTC_HDR; +} VkPhysicalDeviceTextureCompressionASTCHDRFeatures; + +typedef struct VkRenderingAttachmentInfo { + VkStructureType sType; + const void* pNext; + VkImageView imageView; + VkImageLayout imageLayout; + VkResolveModeFlagBits resolveMode; + VkImageView resolveImageView; + VkImageLayout resolveImageLayout; + VkAttachmentLoadOp loadOp; + VkAttachmentStoreOp storeOp; + VkClearValue clearValue; +} VkRenderingAttachmentInfo; + +typedef struct VkRenderingInfo { + VkStructureType sType; + const void* pNext; + VkRenderingFlags flags; + VkRect2D renderArea; + uint32_t layerCount; + uint32_t viewMask; + uint32_t colorAttachmentCount; + const VkRenderingAttachmentInfo* pColorAttachments; + const VkRenderingAttachmentInfo* pDepthAttachment; + const VkRenderingAttachmentInfo* pStencilAttachment; +} VkRenderingInfo; + +typedef struct VkPipelineRenderingCreateInfo { + VkStructureType sType; + const void* pNext; + uint32_t viewMask; + uint32_t colorAttachmentCount; + const VkFormat* pColorAttachmentFormats; + VkFormat depthAttachmentFormat; + VkFormat stencilAttachmentFormat; +} VkPipelineRenderingCreateInfo; + +typedef struct VkPhysicalDeviceDynamicRenderingFeatures { + VkStructureType sType; + void* pNext; + VkBool32 dynamicRendering; +} VkPhysicalDeviceDynamicRenderingFeatures; + +typedef struct VkCommandBufferInheritanceRenderingInfo { + VkStructureType sType; + const void* pNext; + VkRenderingFlags flags; + uint32_t viewMask; + uint32_t colorAttachmentCount; + const VkFormat* pColorAttachmentFormats; + VkFormat depthAttachmentFormat; + VkFormat stencilAttachmentFormat; + VkSampleCountFlagBits rasterizationSamples; +} VkCommandBufferInheritanceRenderingInfo; + +typedef struct VkPhysicalDeviceShaderIntegerDotProductFeatures { + VkStructureType sType; + void* pNext; + VkBool32 shaderIntegerDotProduct; +} VkPhysicalDeviceShaderIntegerDotProductFeatures; + +typedef struct VkPhysicalDeviceShaderIntegerDotProductProperties { + VkStructureType sType; + void* pNext; + VkBool32 integerDotProduct8BitUnsignedAccelerated; + VkBool32 integerDotProduct8BitSignedAccelerated; + VkBool32 integerDotProduct8BitMixedSignednessAccelerated; + VkBool32 integerDotProduct4x8BitPackedUnsignedAccelerated; + VkBool32 integerDotProduct4x8BitPackedSignedAccelerated; + VkBool32 integerDotProduct4x8BitPackedMixedSignednessAccelerated; + VkBool32 integerDotProduct16BitUnsignedAccelerated; + VkBool32 integerDotProduct16BitSignedAccelerated; + VkBool32 integerDotProduct16BitMixedSignednessAccelerated; + VkBool32 integerDotProduct32BitUnsignedAccelerated; + VkBool32 integerDotProduct32BitSignedAccelerated; + VkBool32 integerDotProduct32BitMixedSignednessAccelerated; + VkBool32 integerDotProduct64BitUnsignedAccelerated; + VkBool32 integerDotProduct64BitSignedAccelerated; + VkBool32 integerDotProduct64BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating8BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating8BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating8BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating4x8BitPackedMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating16BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating16BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating16BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating32BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating32BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating32BitMixedSignednessAccelerated; + VkBool32 integerDotProductAccumulatingSaturating64BitUnsignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating64BitSignedAccelerated; + VkBool32 integerDotProductAccumulatingSaturating64BitMixedSignednessAccelerated; +} VkPhysicalDeviceShaderIntegerDotProductProperties; + +typedef struct VkPhysicalDeviceTexelBufferAlignmentProperties { + VkStructureType sType; + void* pNext; + VkDeviceSize storageTexelBufferOffsetAlignmentBytes; + VkBool32 storageTexelBufferOffsetSingleTexelAlignment; + VkDeviceSize uniformTexelBufferOffsetAlignmentBytes; + VkBool32 uniformTexelBufferOffsetSingleTexelAlignment; +} VkPhysicalDeviceTexelBufferAlignmentProperties; + +typedef struct VkFormatProperties3 { + VkStructureType sType; + void* pNext; + VkFormatFeatureFlags2 linearTilingFeatures; + VkFormatFeatureFlags2 optimalTilingFeatures; + VkFormatFeatureFlags2 bufferFeatures; +} VkFormatProperties3; + +typedef struct VkPhysicalDeviceMaintenance4Features { + VkStructureType sType; + void* pNext; + VkBool32 maintenance4; +} VkPhysicalDeviceMaintenance4Features; + +typedef struct VkPhysicalDeviceMaintenance4Properties { + VkStructureType sType; + void* pNext; + VkDeviceSize maxBufferSize; +} VkPhysicalDeviceMaintenance4Properties; + +typedef struct VkDeviceBufferMemoryRequirements { + VkStructureType sType; + const void* pNext; + const VkBufferCreateInfo* pCreateInfo; +} VkDeviceBufferMemoryRequirements; + +typedef struct VkDeviceImageMemoryRequirements { + VkStructureType sType; + const void* pNext; + const VkImageCreateInfo* pCreateInfo; + VkImageAspectFlagBits planeAspect; +} VkDeviceImageMemoryRequirements; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceToolProperties)(VkPhysicalDevice physicalDevice, uint32_t* pToolCount, VkPhysicalDeviceToolProperties* pToolProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreatePrivateDataSlot)(VkDevice device, const VkPrivateDataSlotCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPrivateDataSlot* pPrivateDataSlot); +typedef void (VKAPI_PTR *PFN_vkDestroyPrivateDataSlot)(VkDevice device, VkPrivateDataSlot privateDataSlot, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkSetPrivateData)(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t data); +typedef void (VKAPI_PTR *PFN_vkGetPrivateData)(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t* pData); +typedef void (VKAPI_PTR *PFN_vkCmdSetEvent2)(VkCommandBuffer commandBuffer, VkEvent event, const VkDependencyInfo* pDependencyInfo); +typedef void (VKAPI_PTR *PFN_vkCmdResetEvent2)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags2 stageMask); +typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents2)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, const VkDependencyInfo* pDependencyInfos); +typedef void (VKAPI_PTR *PFN_vkCmdPipelineBarrier2)(VkCommandBuffer commandBuffer, const VkDependencyInfo* pDependencyInfo); +typedef void (VKAPI_PTR *PFN_vkCmdWriteTimestamp2)(VkCommandBuffer commandBuffer, VkPipelineStageFlags2 stage, VkQueryPool queryPool, uint32_t query); +typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit2)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence); +typedef void (VKAPI_PTR *PFN_vkCmdCopyBuffer2)(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2* pCopyBufferInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImage2)(VkCommandBuffer commandBuffer, const VkCopyImageInfo2* pCopyImageInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyBufferToImage2)(VkCommandBuffer commandBuffer, const VkCopyBufferToImageInfo2* pCopyBufferToImageInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImageToBuffer2)(VkCommandBuffer commandBuffer, const VkCopyImageToBufferInfo2* pCopyImageToBufferInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBlitImage2)(VkCommandBuffer commandBuffer, const VkBlitImageInfo2* pBlitImageInfo); +typedef void (VKAPI_PTR *PFN_vkCmdResolveImage2)(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBeginRendering)(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndRendering)(VkCommandBuffer commandBuffer); +typedef void (VKAPI_PTR *PFN_vkCmdSetCullMode)(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetFrontFace)(VkCommandBuffer commandBuffer, VkFrontFace frontFace); +typedef void (VKAPI_PTR *PFN_vkCmdSetPrimitiveTopology)(VkCommandBuffer commandBuffer, VkPrimitiveTopology primitiveTopology); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWithCount)(VkCommandBuffer commandBuffer, uint32_t viewportCount, const VkViewport* pViewports); +typedef void (VKAPI_PTR *PFN_vkCmdSetScissorWithCount)(VkCommandBuffer commandBuffer, uint32_t scissorCount, const VkRect2D* pScissors); +typedef void (VKAPI_PTR *PFN_vkCmdBindVertexBuffers2)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets, const VkDeviceSize* pSizes, const VkDeviceSize* pStrides); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthTestEnable)(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthWriteEnable)(VkCommandBuffer commandBuffer, VkBool32 depthWriteEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthCompareOp)(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBoundsTestEnable)(VkCommandBuffer commandBuffer, VkBool32 depthBoundsTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilTestEnable)(VkCommandBuffer commandBuffer, VkBool32 stencilTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilOp)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizerDiscardEnable)(VkCommandBuffer commandBuffer, VkBool32 rasterizerDiscardEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBiasEnable)(VkCommandBuffer commandBuffer, VkBool32 depthBiasEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetPrimitiveRestartEnable)(VkCommandBuffer commandBuffer, VkBool32 primitiveRestartEnable); +typedef void (VKAPI_PTR *PFN_vkGetDeviceBufferMemoryRequirements)(VkDevice device, const VkDeviceBufferMemoryRequirements* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetDeviceImageMemoryRequirements)(VkDevice device, const VkDeviceImageMemoryRequirements* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetDeviceImageSparseMemoryRequirements)(VkDevice device, const VkDeviceImageMemoryRequirements* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceToolProperties( + VkPhysicalDevice physicalDevice, + uint32_t* pToolCount, + VkPhysicalDeviceToolProperties* pToolProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreatePrivateDataSlot( + VkDevice device, + const VkPrivateDataSlotCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkPrivateDataSlot* pPrivateDataSlot); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPrivateDataSlot( + VkDevice device, + VkPrivateDataSlot privateDataSlot, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetPrivateData( + VkDevice device, + VkObjectType objectType, + uint64_t objectHandle, + VkPrivateDataSlot privateDataSlot, + uint64_t data); + +VKAPI_ATTR void VKAPI_CALL vkGetPrivateData( + VkDevice device, + VkObjectType objectType, + uint64_t objectHandle, + VkPrivateDataSlot privateDataSlot, + uint64_t* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent2( + VkCommandBuffer commandBuffer, + VkEvent event, + const VkDependencyInfo* pDependencyInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent2( + VkCommandBuffer commandBuffer, + VkEvent event, + VkPipelineStageFlags2 stageMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents2( + VkCommandBuffer commandBuffer, + uint32_t eventCount, + const VkEvent* pEvents, + const VkDependencyInfo* pDependencyInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier2( + VkCommandBuffer commandBuffer, + const VkDependencyInfo* pDependencyInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp2( + VkCommandBuffer commandBuffer, + VkPipelineStageFlags2 stage, + VkQueryPool queryPool, + uint32_t query); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit2( + VkQueue queue, + uint32_t submitCount, + const VkSubmitInfo2* pSubmits, + VkFence fence); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer2( + VkCommandBuffer commandBuffer, + const VkCopyBufferInfo2* pCopyBufferInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage2( + VkCommandBuffer commandBuffer, + const VkCopyImageInfo2* pCopyImageInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage2( + VkCommandBuffer commandBuffer, + const VkCopyBufferToImageInfo2* pCopyBufferToImageInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer2( + VkCommandBuffer commandBuffer, + const VkCopyImageToBufferInfo2* pCopyImageToBufferInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage2( + VkCommandBuffer commandBuffer, + const VkBlitImageInfo2* pBlitImageInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage2( + VkCommandBuffer commandBuffer, + const VkResolveImageInfo2* pResolveImageInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRendering( + VkCommandBuffer commandBuffer, + const VkRenderingInfo* pRenderingInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRendering( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCullMode( + VkCommandBuffer commandBuffer, + VkCullModeFlags cullMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetFrontFace( + VkCommandBuffer commandBuffer, + VkFrontFace frontFace); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetPrimitiveTopology( + VkCommandBuffer commandBuffer, + VkPrimitiveTopology primitiveTopology); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWithCount( + VkCommandBuffer commandBuffer, + uint32_t viewportCount, + const VkViewport* pViewports); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetScissorWithCount( + VkCommandBuffer commandBuffer, + uint32_t scissorCount, + const VkRect2D* pScissors); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers2( + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBuffer* pBuffers, + const VkDeviceSize* pOffsets, + const VkDeviceSize* pSizes, + const VkDeviceSize* pStrides); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthTestEnable( + VkCommandBuffer commandBuffer, + VkBool32 depthTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthWriteEnable( + VkCommandBuffer commandBuffer, + VkBool32 depthWriteEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthCompareOp( + VkCommandBuffer commandBuffer, + VkCompareOp depthCompareOp); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBoundsTestEnable( + VkCommandBuffer commandBuffer, + VkBool32 depthBoundsTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilTestEnable( + VkCommandBuffer commandBuffer, + VkBool32 stencilTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilOp( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + VkStencilOp failOp, + VkStencilOp passOp, + VkStencilOp depthFailOp, + VkCompareOp compareOp); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizerDiscardEnable( + VkCommandBuffer commandBuffer, + VkBool32 rasterizerDiscardEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBiasEnable( + VkCommandBuffer commandBuffer, + VkBool32 depthBiasEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetPrimitiveRestartEnable( + VkCommandBuffer commandBuffer, + VkBool32 primitiveRestartEnable); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceBufferMemoryRequirements( + VkDevice device, + const VkDeviceBufferMemoryRequirements* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageMemoryRequirements( + VkDevice device, + const VkDeviceImageMemoryRequirements* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSparseMemoryRequirements( + VkDevice device, + const VkDeviceImageMemoryRequirements* pInfo, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); +#endif + + +// VK_KHR_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_surface 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR) +#define VK_KHR_SURFACE_SPEC_VERSION 25 +#define VK_KHR_SURFACE_EXTENSION_NAME "VK_KHR_surface" + +typedef enum VkPresentModeKHR { + VK_PRESENT_MODE_IMMEDIATE_KHR = 0, + VK_PRESENT_MODE_MAILBOX_KHR = 1, + VK_PRESENT_MODE_FIFO_KHR = 2, + VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3, + VK_PRESENT_MODE_SHARED_DEMAND_REFRESH_KHR = 1000111000, + VK_PRESENT_MODE_SHARED_CONTINUOUS_REFRESH_KHR = 1000111001, + VK_PRESENT_MODE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPresentModeKHR; + +typedef enum VkColorSpaceKHR { + VK_COLOR_SPACE_SRGB_NONLINEAR_KHR = 0, + VK_COLOR_SPACE_DISPLAY_P3_NONLINEAR_EXT = 1000104001, + VK_COLOR_SPACE_EXTENDED_SRGB_LINEAR_EXT = 1000104002, + VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT = 1000104003, + VK_COLOR_SPACE_DCI_P3_NONLINEAR_EXT = 1000104004, + VK_COLOR_SPACE_BT709_LINEAR_EXT = 1000104005, + VK_COLOR_SPACE_BT709_NONLINEAR_EXT = 1000104006, + VK_COLOR_SPACE_BT2020_LINEAR_EXT = 1000104007, + VK_COLOR_SPACE_HDR10_ST2084_EXT = 1000104008, + VK_COLOR_SPACE_DOLBYVISION_EXT = 1000104009, + VK_COLOR_SPACE_HDR10_HLG_EXT = 1000104010, + VK_COLOR_SPACE_ADOBERGB_LINEAR_EXT = 1000104011, + VK_COLOR_SPACE_ADOBERGB_NONLINEAR_EXT = 1000104012, + VK_COLOR_SPACE_PASS_THROUGH_EXT = 1000104013, + VK_COLOR_SPACE_EXTENDED_SRGB_NONLINEAR_EXT = 1000104014, + VK_COLOR_SPACE_DISPLAY_NATIVE_AMD = 1000213000, + VK_COLORSPACE_SRGB_NONLINEAR_KHR = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR, + VK_COLOR_SPACE_DCI_P3_LINEAR_EXT = VK_COLOR_SPACE_DISPLAY_P3_LINEAR_EXT, + VK_COLOR_SPACE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkColorSpaceKHR; + +typedef enum VkSurfaceTransformFlagBitsKHR { + VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR = 0x00000001, + VK_SURFACE_TRANSFORM_ROTATE_90_BIT_KHR = 0x00000002, + VK_SURFACE_TRANSFORM_ROTATE_180_BIT_KHR = 0x00000004, + VK_SURFACE_TRANSFORM_ROTATE_270_BIT_KHR = 0x00000008, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_BIT_KHR = 0x00000010, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_90_BIT_KHR = 0x00000020, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 0x00000040, + VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 0x00000080, + VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100, + VK_SURFACE_TRANSFORM_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkSurfaceTransformFlagBitsKHR; + +typedef enum VkCompositeAlphaFlagBitsKHR { + VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, + VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 0x00000002, + VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 0x00000004, + VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 0x00000008, + VK_COMPOSITE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkCompositeAlphaFlagBitsKHR; +typedef VkFlags VkCompositeAlphaFlagsKHR; +typedef VkFlags VkSurfaceTransformFlagsKHR; +typedef struct VkSurfaceCapabilitiesKHR { + uint32_t minImageCount; + uint32_t maxImageCount; + VkExtent2D currentExtent; + VkExtent2D minImageExtent; + VkExtent2D maxImageExtent; + uint32_t maxImageArrayLayers; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkSurfaceTransformFlagBitsKHR currentTransform; + VkCompositeAlphaFlagsKHR supportedCompositeAlpha; + VkImageUsageFlags supportedUsageFlags; +} VkSurfaceCapabilitiesKHR; + +typedef struct VkSurfaceFormatKHR { + VkFormat format; + VkColorSpaceKHR colorSpace; +} VkSurfaceFormatKHR; + +typedef void (VKAPI_PTR *PFN_vkDestroySurfaceKHR)(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32* pSupported); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormatsKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pSurfaceFormatCount, VkSurfaceFormatKHR* pSurfaceFormats); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkDestroySurfaceKHR( + VkInstance instance, + VkSurfaceKHR surface, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + VkSurfaceKHR surface, + VkBool32* pSupported); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceCapabilitiesKHR* pSurfaceCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormatKHR* pSurfaceFormats); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes); +#endif + + +// VK_KHR_swapchain is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_swapchain 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSwapchainKHR) +#define VK_KHR_SWAPCHAIN_SPEC_VERSION 70 +#define VK_KHR_SWAPCHAIN_EXTENSION_NAME "VK_KHR_swapchain" + +typedef enum VkSwapchainCreateFlagBitsKHR { + VK_SWAPCHAIN_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT_KHR = 0x00000001, + VK_SWAPCHAIN_CREATE_PROTECTED_BIT_KHR = 0x00000002, + VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR = 0x00000004, + VK_SWAPCHAIN_CREATE_DEFERRED_MEMORY_ALLOCATION_BIT_EXT = 0x00000008, + VK_SWAPCHAIN_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkSwapchainCreateFlagBitsKHR; +typedef VkFlags VkSwapchainCreateFlagsKHR; + +typedef enum VkDeviceGroupPresentModeFlagBitsKHR { + VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_BIT_KHR = 0x00000001, + VK_DEVICE_GROUP_PRESENT_MODE_REMOTE_BIT_KHR = 0x00000002, + VK_DEVICE_GROUP_PRESENT_MODE_SUM_BIT_KHR = 0x00000004, + VK_DEVICE_GROUP_PRESENT_MODE_LOCAL_MULTI_DEVICE_BIT_KHR = 0x00000008, + VK_DEVICE_GROUP_PRESENT_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkDeviceGroupPresentModeFlagBitsKHR; +typedef VkFlags VkDeviceGroupPresentModeFlagsKHR; +typedef struct VkSwapchainCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainCreateFlagsKHR flags; + VkSurfaceKHR surface; + uint32_t minImageCount; + VkFormat imageFormat; + VkColorSpaceKHR imageColorSpace; + VkExtent2D imageExtent; + uint32_t imageArrayLayers; + VkImageUsageFlags imageUsage; + VkSharingMode imageSharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; + VkSurfaceTransformFlagBitsKHR preTransform; + VkCompositeAlphaFlagBitsKHR compositeAlpha; + VkPresentModeKHR presentMode; + VkBool32 clipped; + VkSwapchainKHR oldSwapchain; +} VkSwapchainCreateInfoKHR; + +typedef struct VkPresentInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreCount; + const VkSemaphore* pWaitSemaphores; + uint32_t swapchainCount; + const VkSwapchainKHR* pSwapchains; + const uint32_t* pImageIndices; + VkResult* pResults; +} VkPresentInfoKHR; + +typedef struct VkImageSwapchainCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; +} VkImageSwapchainCreateInfoKHR; + +typedef struct VkBindImageMemorySwapchainInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; + uint32_t imageIndex; +} VkBindImageMemorySwapchainInfoKHR; + +typedef struct VkAcquireNextImageInfoKHR { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; + uint64_t timeout; + VkSemaphore semaphore; + VkFence fence; + uint32_t deviceMask; +} VkAcquireNextImageInfoKHR; + +typedef struct VkDeviceGroupPresentCapabilitiesKHR { + VkStructureType sType; + void* pNext; + uint32_t presentMask[VK_MAX_DEVICE_GROUP_SIZE]; + VkDeviceGroupPresentModeFlagsKHR modes; +} VkDeviceGroupPresentCapabilitiesKHR; + +typedef struct VkDeviceGroupPresentInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const uint32_t* pDeviceMasks; + VkDeviceGroupPresentModeFlagBitsKHR mode; +} VkDeviceGroupPresentInfoKHR; + +typedef struct VkDeviceGroupSwapchainCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceGroupPresentModeFlagsKHR modes; +} VkDeviceGroupSwapchainCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSwapchainKHR)(VkDevice device, const VkSwapchainCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchain); +typedef void (VKAPI_PTR *PFN_vkDestroySwapchainKHR)(VkDevice device, VkSwapchainKHR swapchain, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainImagesKHR)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pSwapchainImageCount, VkImage* pSwapchainImages); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImageKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, VkSemaphore semaphore, VkFence fence, uint32_t* pImageIndex); +typedef VkResult (VKAPI_PTR *PFN_vkQueuePresentKHR)(VkQueue queue, const VkPresentInfoKHR* pPresentInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupPresentCapabilitiesKHR)(VkDevice device, VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModesKHR)(VkDevice device, VkSurfaceKHR surface, VkDeviceGroupPresentModeFlagsKHR* pModes); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDevicePresentRectanglesKHR)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t* pRectCount, VkRect2D* pRects); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireNextImage2KHR)(VkDevice device, const VkAcquireNextImageInfoKHR* pAcquireInfo, uint32_t* pImageIndex); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSwapchainKHR( + VkDevice device, + const VkSwapchainCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSwapchainKHR* pSwapchain); + +VKAPI_ATTR void VKAPI_CALL vkDestroySwapchainKHR( + VkDevice device, + VkSwapchainKHR swapchain, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint32_t* pSwapchainImageCount, + VkImage* pSwapchainImages); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImageKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint64_t timeout, + VkSemaphore semaphore, + VkFence fence, + uint32_t* pImageIndex); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueuePresentKHR( + VkQueue queue, + const VkPresentInfoKHR* pPresentInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupPresentCapabilitiesKHR( + VkDevice device, + VkDeviceGroupPresentCapabilitiesKHR* pDeviceGroupPresentCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModesKHR( + VkDevice device, + VkSurfaceKHR surface, + VkDeviceGroupPresentModeFlagsKHR* pModes); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDevicePresentRectanglesKHR( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + uint32_t* pRectCount, + VkRect2D* pRects); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireNextImage2KHR( + VkDevice device, + const VkAcquireNextImageInfoKHR* pAcquireInfo, + uint32_t* pImageIndex); +#endif + + +// VK_KHR_display is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_display 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayKHR) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDisplayModeKHR) +#define VK_KHR_DISPLAY_SPEC_VERSION 23 +#define VK_KHR_DISPLAY_EXTENSION_NAME "VK_KHR_display" +typedef VkFlags VkDisplayModeCreateFlagsKHR; + +typedef enum VkDisplayPlaneAlphaFlagBitsKHR { + VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR = 0x00000001, + VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR = 0x00000002, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR = 0x00000004, + VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR = 0x00000008, + VK_DISPLAY_PLANE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkDisplayPlaneAlphaFlagBitsKHR; +typedef VkFlags VkDisplayPlaneAlphaFlagsKHR; +typedef VkFlags VkDisplaySurfaceCreateFlagsKHR; +typedef struct VkDisplayModeParametersKHR { + VkExtent2D visibleRegion; + uint32_t refreshRate; +} VkDisplayModeParametersKHR; + +typedef struct VkDisplayModeCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDisplayModeCreateFlagsKHR flags; + VkDisplayModeParametersKHR parameters; +} VkDisplayModeCreateInfoKHR; + +typedef struct VkDisplayModePropertiesKHR { + VkDisplayModeKHR displayMode; + VkDisplayModeParametersKHR parameters; +} VkDisplayModePropertiesKHR; + +typedef struct VkDisplayPlaneCapabilitiesKHR { + VkDisplayPlaneAlphaFlagsKHR supportedAlpha; + VkOffset2D minSrcPosition; + VkOffset2D maxSrcPosition; + VkExtent2D minSrcExtent; + VkExtent2D maxSrcExtent; + VkOffset2D minDstPosition; + VkOffset2D maxDstPosition; + VkExtent2D minDstExtent; + VkExtent2D maxDstExtent; +} VkDisplayPlaneCapabilitiesKHR; + +typedef struct VkDisplayPlanePropertiesKHR { + VkDisplayKHR currentDisplay; + uint32_t currentStackIndex; +} VkDisplayPlanePropertiesKHR; + +typedef struct VkDisplayPropertiesKHR { + VkDisplayKHR display; + const char* displayName; + VkExtent2D physicalDimensions; + VkExtent2D physicalResolution; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkBool32 planeReorderPossible; + VkBool32 persistentContent; +} VkDisplayPropertiesKHR; + +typedef struct VkDisplaySurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDisplaySurfaceCreateFlagsKHR flags; + VkDisplayModeKHR displayMode; + uint32_t planeIndex; + uint32_t planeStackIndex; + VkSurfaceTransformFlagBitsKHR transform; + float globalAlpha; + VkDisplayPlaneAlphaFlagBitsKHR alphaMode; + VkExtent2D imageExtent; +} VkDisplaySurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlanePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneSupportedDisplaysKHR)(VkPhysicalDevice physicalDevice, uint32_t planeIndex, uint32_t* pDisplayCount, VkDisplayKHR* pDisplays); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModePropertiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayModeKHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, const VkDisplayModeCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDisplayModeKHR* pMode); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilitiesKHR)(VkPhysicalDevice physicalDevice, VkDisplayModeKHR mode, uint32_t planeIndex, VkDisplayPlaneCapabilitiesKHR* pCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDisplayPlaneSurfaceKHR)(VkInstance instance, const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlanePropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPlanePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneSupportedDisplaysKHR( + VkPhysicalDevice physicalDevice, + uint32_t planeIndex, + uint32_t* pDisplayCount, + VkDisplayKHR* pDisplays); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModePropertiesKHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + uint32_t* pPropertyCount, + VkDisplayModePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayModeKHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + const VkDisplayModeCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDisplayModeKHR* pMode); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + VkDisplayModeKHR mode, + uint32_t planeIndex, + VkDisplayPlaneCapabilitiesKHR* pCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDisplayPlaneSurfaceKHR( + VkInstance instance, + const VkDisplaySurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +// VK_KHR_display_swapchain is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_display_swapchain 1 +#define VK_KHR_DISPLAY_SWAPCHAIN_SPEC_VERSION 10 +#define VK_KHR_DISPLAY_SWAPCHAIN_EXTENSION_NAME "VK_KHR_display_swapchain" +typedef struct VkDisplayPresentInfoKHR { + VkStructureType sType; + const void* pNext; + VkRect2D srcRect; + VkRect2D dstRect; + VkBool32 persistent; +} VkDisplayPresentInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSharedSwapchainsKHR)(VkDevice device, uint32_t swapchainCount, const VkSwapchainCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkSwapchainKHR* pSwapchains); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSharedSwapchainsKHR( + VkDevice device, + uint32_t swapchainCount, + const VkSwapchainCreateInfoKHR* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkSwapchainKHR* pSwapchains); +#endif + + +// VK_KHR_sampler_mirror_clamp_to_edge is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_sampler_mirror_clamp_to_edge 1 +#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_SPEC_VERSION 3 +#define VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME "VK_KHR_sampler_mirror_clamp_to_edge" + + +// VK_KHR_video_queue is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_queue 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionKHR) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkVideoSessionParametersKHR) +#define VK_KHR_VIDEO_QUEUE_SPEC_VERSION 8 +#define VK_KHR_VIDEO_QUEUE_EXTENSION_NAME "VK_KHR_video_queue" + +typedef enum VkQueryResultStatusKHR { + VK_QUERY_RESULT_STATUS_ERROR_KHR = -1, + VK_QUERY_RESULT_STATUS_NOT_READY_KHR = 0, + VK_QUERY_RESULT_STATUS_COMPLETE_KHR = 1, + VK_QUERY_RESULT_STATUS_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_KHR = -1000299000, + VK_QUERY_RESULT_STATUS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkQueryResultStatusKHR; + +typedef enum VkVideoCodecOperationFlagBitsKHR { + VK_VIDEO_CODEC_OPERATION_NONE_KHR = 0, + VK_VIDEO_CODEC_OPERATION_ENCODE_H264_BIT_KHR = 0x00010000, + VK_VIDEO_CODEC_OPERATION_ENCODE_H265_BIT_KHR = 0x00020000, + VK_VIDEO_CODEC_OPERATION_DECODE_H264_BIT_KHR = 0x00000001, + VK_VIDEO_CODEC_OPERATION_DECODE_H265_BIT_KHR = 0x00000002, + VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR = 0x00000004, + VK_VIDEO_CODEC_OPERATION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCodecOperationFlagBitsKHR; +typedef VkFlags VkVideoCodecOperationFlagsKHR; + +typedef enum VkVideoChromaSubsamplingFlagBitsKHR { + VK_VIDEO_CHROMA_SUBSAMPLING_INVALID_KHR = 0, + VK_VIDEO_CHROMA_SUBSAMPLING_MONOCHROME_BIT_KHR = 0x00000001, + VK_VIDEO_CHROMA_SUBSAMPLING_420_BIT_KHR = 0x00000002, + VK_VIDEO_CHROMA_SUBSAMPLING_422_BIT_KHR = 0x00000004, + VK_VIDEO_CHROMA_SUBSAMPLING_444_BIT_KHR = 0x00000008, + VK_VIDEO_CHROMA_SUBSAMPLING_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoChromaSubsamplingFlagBitsKHR; +typedef VkFlags VkVideoChromaSubsamplingFlagsKHR; + +typedef enum VkVideoComponentBitDepthFlagBitsKHR { + VK_VIDEO_COMPONENT_BIT_DEPTH_INVALID_KHR = 0, + VK_VIDEO_COMPONENT_BIT_DEPTH_8_BIT_KHR = 0x00000001, + VK_VIDEO_COMPONENT_BIT_DEPTH_10_BIT_KHR = 0x00000004, + VK_VIDEO_COMPONENT_BIT_DEPTH_12_BIT_KHR = 0x00000010, + VK_VIDEO_COMPONENT_BIT_DEPTH_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoComponentBitDepthFlagBitsKHR; +typedef VkFlags VkVideoComponentBitDepthFlagsKHR; + +typedef enum VkVideoCapabilityFlagBitsKHR { + VK_VIDEO_CAPABILITY_PROTECTED_CONTENT_BIT_KHR = 0x00000001, + VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR = 0x00000002, + VK_VIDEO_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCapabilityFlagBitsKHR; +typedef VkFlags VkVideoCapabilityFlagsKHR; + +typedef enum VkVideoSessionCreateFlagBitsKHR { + VK_VIDEO_SESSION_CREATE_PROTECTED_CONTENT_BIT_KHR = 0x00000001, + VK_VIDEO_SESSION_CREATE_ALLOW_ENCODE_PARAMETER_OPTIMIZATIONS_BIT_KHR = 0x00000002, + VK_VIDEO_SESSION_CREATE_INLINE_QUERIES_BIT_KHR = 0x00000004, + VK_VIDEO_SESSION_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoSessionCreateFlagBitsKHR; +typedef VkFlags VkVideoSessionCreateFlagsKHR; +typedef VkFlags VkVideoSessionParametersCreateFlagsKHR; +typedef VkFlags VkVideoBeginCodingFlagsKHR; +typedef VkFlags VkVideoEndCodingFlagsKHR; + +typedef enum VkVideoCodingControlFlagBitsKHR { + VK_VIDEO_CODING_CONTROL_RESET_BIT_KHR = 0x00000001, + VK_VIDEO_CODING_CONTROL_ENCODE_RATE_CONTROL_BIT_KHR = 0x00000002, + VK_VIDEO_CODING_CONTROL_ENCODE_QUALITY_LEVEL_BIT_KHR = 0x00000004, + VK_VIDEO_CODING_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoCodingControlFlagBitsKHR; +typedef VkFlags VkVideoCodingControlFlagsKHR; +typedef struct VkQueueFamilyQueryResultStatusPropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 queryResultStatusSupport; +} VkQueueFamilyQueryResultStatusPropertiesKHR; + +typedef struct VkQueueFamilyVideoPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoCodecOperationFlagsKHR videoCodecOperations; +} VkQueueFamilyVideoPropertiesKHR; + +typedef struct VkVideoProfileInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoCodecOperationFlagBitsKHR videoCodecOperation; + VkVideoChromaSubsamplingFlagsKHR chromaSubsampling; + VkVideoComponentBitDepthFlagsKHR lumaBitDepth; + VkVideoComponentBitDepthFlagsKHR chromaBitDepth; +} VkVideoProfileInfoKHR; + +typedef struct VkVideoProfileListInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t profileCount; + const VkVideoProfileInfoKHR* pProfiles; +} VkVideoProfileListInfoKHR; + +typedef struct VkVideoCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoCapabilityFlagsKHR flags; + VkDeviceSize minBitstreamBufferOffsetAlignment; + VkDeviceSize minBitstreamBufferSizeAlignment; + VkExtent2D pictureAccessGranularity; + VkExtent2D minCodedExtent; + VkExtent2D maxCodedExtent; + uint32_t maxDpbSlots; + uint32_t maxActiveReferencePictures; + VkExtensionProperties stdHeaderVersion; +} VkVideoCapabilitiesKHR; + +typedef struct VkPhysicalDeviceVideoFormatInfoKHR { + VkStructureType sType; + const void* pNext; + VkImageUsageFlags imageUsage; +} VkPhysicalDeviceVideoFormatInfoKHR; + +typedef struct VkVideoFormatPropertiesKHR { + VkStructureType sType; + void* pNext; + VkFormat format; + VkComponentMapping componentMapping; + VkImageCreateFlags imageCreateFlags; + VkImageType imageType; + VkImageTiling imageTiling; + VkImageUsageFlags imageUsageFlags; +} VkVideoFormatPropertiesKHR; + +typedef struct VkVideoPictureResourceInfoKHR { + VkStructureType sType; + const void* pNext; + VkOffset2D codedOffset; + VkExtent2D codedExtent; + uint32_t baseArrayLayer; + VkImageView imageViewBinding; +} VkVideoPictureResourceInfoKHR; + +typedef struct VkVideoReferenceSlotInfoKHR { + VkStructureType sType; + const void* pNext; + int32_t slotIndex; + const VkVideoPictureResourceInfoKHR* pPictureResource; +} VkVideoReferenceSlotInfoKHR; + +typedef struct VkVideoSessionMemoryRequirementsKHR { + VkStructureType sType; + void* pNext; + uint32_t memoryBindIndex; + VkMemoryRequirements memoryRequirements; +} VkVideoSessionMemoryRequirementsKHR; + +typedef struct VkBindVideoSessionMemoryInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t memoryBindIndex; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + VkDeviceSize memorySize; +} VkBindVideoSessionMemoryInfoKHR; + +typedef struct VkVideoSessionCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t queueFamilyIndex; + VkVideoSessionCreateFlagsKHR flags; + const VkVideoProfileInfoKHR* pVideoProfile; + VkFormat pictureFormat; + VkExtent2D maxCodedExtent; + VkFormat referencePictureFormat; + uint32_t maxDpbSlots; + uint32_t maxActiveReferencePictures; + const VkExtensionProperties* pStdHeaderVersion; +} VkVideoSessionCreateInfoKHR; + +typedef struct VkVideoSessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoSessionParametersCreateFlagsKHR flags; + VkVideoSessionParametersKHR videoSessionParametersTemplate; + VkVideoSessionKHR videoSession; +} VkVideoSessionParametersCreateInfoKHR; + +typedef struct VkVideoSessionParametersUpdateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t updateSequenceCount; +} VkVideoSessionParametersUpdateInfoKHR; + +typedef struct VkVideoBeginCodingInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoBeginCodingFlagsKHR flags; + VkVideoSessionKHR videoSession; + VkVideoSessionParametersKHR videoSessionParameters; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; +} VkVideoBeginCodingInfoKHR; + +typedef struct VkVideoEndCodingInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEndCodingFlagsKHR flags; +} VkVideoEndCodingInfoKHR; + +typedef struct VkVideoCodingControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoCodingControlFlagsKHR flags; +} VkVideoCodingControlInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoCapabilitiesKHR)(VkPhysicalDevice physicalDevice, const VkVideoProfileInfoKHR* pVideoProfile, VkVideoCapabilitiesKHR* pCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoFormatPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, uint32_t* pVideoFormatPropertyCount, VkVideoFormatPropertiesKHR* pVideoFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionKHR)(VkDevice device, const VkVideoSessionCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionKHR* pVideoSession); +typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionKHR)(VkDevice device, VkVideoSessionKHR videoSession, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetVideoSessionMemoryRequirementsKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t* pMemoryRequirementsCount, VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); +typedef VkResult (VKAPI_PTR *PFN_vkBindVideoSessionMemoryKHR)(VkDevice device, VkVideoSessionKHR videoSession, uint32_t bindSessionMemoryInfoCount, const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); +typedef VkResult (VKAPI_PTR *PFN_vkCreateVideoSessionParametersKHR)(VkDevice device, const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkVideoSessionParametersKHR* pVideoSessionParameters); +typedef VkResult (VKAPI_PTR *PFN_vkUpdateVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); +typedef void (VKAPI_PTR *PFN_vkDestroyVideoSessionParametersKHR)(VkDevice device, VkVideoSessionParametersKHR videoSessionParameters, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdBeginVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoBeginCodingInfoKHR* pBeginInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoEndCodingInfoKHR* pEndCodingInfo); +typedef void (VKAPI_PTR *PFN_vkCmdControlVideoCodingKHR)(VkCommandBuffer commandBuffer, const VkVideoCodingControlInfoKHR* pCodingControlInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoCapabilitiesKHR( + VkPhysicalDevice physicalDevice, + const VkVideoProfileInfoKHR* pVideoProfile, + VkVideoCapabilitiesKHR* pCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoFormatPropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceVideoFormatInfoKHR* pVideoFormatInfo, + uint32_t* pVideoFormatPropertyCount, + VkVideoFormatPropertiesKHR* pVideoFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionKHR( + VkDevice device, + const VkVideoSessionCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkVideoSessionKHR* pVideoSession); + +VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetVideoSessionMemoryRequirementsKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + uint32_t* pMemoryRequirementsCount, + VkVideoSessionMemoryRequirementsKHR* pMemoryRequirements); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindVideoSessionMemoryKHR( + VkDevice device, + VkVideoSessionKHR videoSession, + uint32_t bindSessionMemoryInfoCount, + const VkBindVideoSessionMemoryInfoKHR* pBindSessionMemoryInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateVideoSessionParametersKHR( + VkDevice device, + const VkVideoSessionParametersCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkVideoSessionParametersKHR* pVideoSessionParameters); + +VKAPI_ATTR VkResult VKAPI_CALL vkUpdateVideoSessionParametersKHR( + VkDevice device, + VkVideoSessionParametersKHR videoSessionParameters, + const VkVideoSessionParametersUpdateInfoKHR* pUpdateInfo); + +VKAPI_ATTR void VKAPI_CALL vkDestroyVideoSessionParametersKHR( + VkDevice device, + VkVideoSessionParametersKHR videoSessionParameters, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoBeginCodingInfoKHR* pBeginInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoEndCodingInfoKHR* pEndCodingInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdControlVideoCodingKHR( + VkCommandBuffer commandBuffer, + const VkVideoCodingControlInfoKHR* pCodingControlInfo); +#endif + + +// VK_KHR_video_decode_queue is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_decode_queue 1 +#define VK_KHR_VIDEO_DECODE_QUEUE_SPEC_VERSION 8 +#define VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME "VK_KHR_video_decode_queue" + +typedef enum VkVideoDecodeCapabilityFlagBitsKHR { + VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeCapabilityFlagBitsKHR; +typedef VkFlags VkVideoDecodeCapabilityFlagsKHR; + +typedef enum VkVideoDecodeUsageFlagBitsKHR { + VK_VIDEO_DECODE_USAGE_DEFAULT_KHR = 0, + VK_VIDEO_DECODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_USAGE_OFFLINE_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_USAGE_STREAMING_BIT_KHR = 0x00000004, + VK_VIDEO_DECODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeUsageFlagBitsKHR; +typedef VkFlags VkVideoDecodeUsageFlagsKHR; +typedef VkFlags VkVideoDecodeFlagsKHR; +typedef struct VkVideoDecodeCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoDecodeCapabilityFlagsKHR flags; +} VkVideoDecodeCapabilitiesKHR; + +typedef struct VkVideoDecodeUsageInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoDecodeUsageFlagsKHR videoUsageHints; +} VkVideoDecodeUsageInfoKHR; + +typedef struct VkVideoDecodeInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoDecodeFlagsKHR flags; + VkBuffer srcBuffer; + VkDeviceSize srcBufferOffset; + VkDeviceSize srcBufferRange; + VkVideoPictureResourceInfoKHR dstPictureResource; + const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; +} VkVideoDecodeInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdDecodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoDecodeInfoKHR* pDecodeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDecodeVideoKHR( + VkCommandBuffer commandBuffer, + const VkVideoDecodeInfoKHR* pDecodeInfo); +#endif + + +// VK_KHR_video_encode_h264 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_encode_h264 1 +#include "../vk_video/vulkan_video_codec_h264std.h" +#include "../vk_video/vulkan_video_codec_h264std_encode.h" +#define VK_KHR_VIDEO_ENCODE_H264_SPEC_VERSION 14 +#define VK_KHR_VIDEO_ENCODE_H264_EXTENSION_NAME "VK_KHR_video_encode_h264" + +typedef enum VkVideoEncodeH264CapabilityFlagBitsKHR { + VK_VIDEO_ENCODE_H264_CAPABILITY_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H264_CAPABILITY_PREDICTION_WEIGHT_TABLE_GENERATED_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H264_CAPABILITY_ROW_UNALIGNED_SLICE_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H264_CAPABILITY_DIFFERENT_SLICE_TYPE_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H264_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H264_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H264_CAPABILITY_PER_SLICE_CONSTANT_QP_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H264_CAPABILITY_GENERATE_PREFIX_NALU_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H264_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH264CapabilityFlagBitsKHR; +typedef VkFlags VkVideoEncodeH264CapabilityFlagsKHR; + +typedef enum VkVideoEncodeH264StdFlagBitsKHR { + VK_VIDEO_ENCODE_H264_STD_SEPARATE_COLOR_PLANE_FLAG_SET_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H264_STD_QPPRIME_Y_ZERO_TRANSFORM_BYPASS_FLAG_SET_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H264_STD_SCALING_MATRIX_PRESENT_FLAG_SET_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H264_STD_CHROMA_QP_INDEX_OFFSET_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H264_STD_SECOND_CHROMA_QP_INDEX_OFFSET_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H264_STD_PIC_INIT_QP_MINUS26_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H264_STD_WEIGHTED_PRED_FLAG_SET_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H264_STD_WEIGHTED_BIPRED_IDC_EXPLICIT_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H264_STD_WEIGHTED_BIPRED_IDC_IMPLICIT_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H264_STD_TRANSFORM_8X8_MODE_FLAG_SET_BIT_KHR = 0x00000200, + VK_VIDEO_ENCODE_H264_STD_DIRECT_SPATIAL_MV_PRED_FLAG_UNSET_BIT_KHR = 0x00000400, + VK_VIDEO_ENCODE_H264_STD_ENTROPY_CODING_MODE_FLAG_UNSET_BIT_KHR = 0x00000800, + VK_VIDEO_ENCODE_H264_STD_ENTROPY_CODING_MODE_FLAG_SET_BIT_KHR = 0x00001000, + VK_VIDEO_ENCODE_H264_STD_DIRECT_8X8_INFERENCE_FLAG_UNSET_BIT_KHR = 0x00002000, + VK_VIDEO_ENCODE_H264_STD_CONSTRAINED_INTRA_PRED_FLAG_SET_BIT_KHR = 0x00004000, + VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_DISABLED_BIT_KHR = 0x00008000, + VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_ENABLED_BIT_KHR = 0x00010000, + VK_VIDEO_ENCODE_H264_STD_DEBLOCKING_FILTER_PARTIAL_BIT_KHR = 0x00020000, + VK_VIDEO_ENCODE_H264_STD_SLICE_QP_DELTA_BIT_KHR = 0x00080000, + VK_VIDEO_ENCODE_H264_STD_DIFFERENT_SLICE_QP_DELTA_BIT_KHR = 0x00100000, + VK_VIDEO_ENCODE_H264_STD_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH264StdFlagBitsKHR; +typedef VkFlags VkVideoEncodeH264StdFlagsKHR; + +typedef enum VkVideoEncodeH264RateControlFlagBitsKHR { + VK_VIDEO_ENCODE_H264_RATE_CONTROL_ATTEMPT_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_REGULAR_GOP_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_REFERENCE_PATTERN_FLAT_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_REFERENCE_PATTERN_DYADIC_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_TEMPORAL_LAYER_PATTERN_DYADIC_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H264_RATE_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH264RateControlFlagBitsKHR; +typedef VkFlags VkVideoEncodeH264RateControlFlagsKHR; +typedef struct VkVideoEncodeH264CapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH264CapabilityFlagsKHR flags; + StdVideoH264LevelIdc maxLevelIdc; + uint32_t maxSliceCount; + uint32_t maxPPictureL0ReferenceCount; + uint32_t maxBPictureL0ReferenceCount; + uint32_t maxL1ReferenceCount; + uint32_t maxTemporalLayerCount; + VkBool32 expectDyadicTemporalLayerPattern; + int32_t minQp; + int32_t maxQp; + VkBool32 prefersGopRemainingFrames; + VkBool32 requiresGopRemainingFrames; + VkVideoEncodeH264StdFlagsKHR stdSyntaxFlags; +} VkVideoEncodeH264CapabilitiesKHR; + +typedef struct VkVideoEncodeH264QpKHR { + int32_t qpI; + int32_t qpP; + int32_t qpB; +} VkVideoEncodeH264QpKHR; + +typedef struct VkVideoEncodeH264QualityLevelPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH264RateControlFlagsKHR preferredRateControlFlags; + uint32_t preferredGopFrameCount; + uint32_t preferredIdrPeriod; + uint32_t preferredConsecutiveBFrameCount; + uint32_t preferredTemporalLayerCount; + VkVideoEncodeH264QpKHR preferredConstantQp; + uint32_t preferredMaxL0ReferenceCount; + uint32_t preferredMaxL1ReferenceCount; + VkBool32 preferredStdEntropyCodingModeFlag; +} VkVideoEncodeH264QualityLevelPropertiesKHR; + +typedef struct VkVideoEncodeH264SessionCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMaxLevelIdc; + StdVideoH264LevelIdc maxLevelIdc; +} VkVideoEncodeH264SessionCreateInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdSPSCount; + const StdVideoH264SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH264PictureParameterSet* pStdPPSs; +} VkVideoEncodeH264SessionParametersAddInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoEncodeH264SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoEncodeH264SessionParametersCreateInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersGetInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 writeStdSPS; + VkBool32 writeStdPPS; + uint32_t stdSPSId; + uint32_t stdPPSId; +} VkVideoEncodeH264SessionParametersGetInfoKHR; + +typedef struct VkVideoEncodeH264SessionParametersFeedbackInfoKHR { + VkStructureType sType; + void* pNext; + VkBool32 hasStdSPSOverrides; + VkBool32 hasStdPPSOverrides; +} VkVideoEncodeH264SessionParametersFeedbackInfoKHR; + +typedef struct VkVideoEncodeH264NaluSliceInfoKHR { + VkStructureType sType; + const void* pNext; + int32_t constantQp; + const StdVideoEncodeH264SliceHeader* pStdSliceHeader; +} VkVideoEncodeH264NaluSliceInfoKHR; + +typedef struct VkVideoEncodeH264PictureInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t naluSliceEntryCount; + const VkVideoEncodeH264NaluSliceInfoKHR* pNaluSliceEntries; + const StdVideoEncodeH264PictureInfo* pStdPictureInfo; + VkBool32 generatePrefixNalu; +} VkVideoEncodeH264PictureInfoKHR; + +typedef struct VkVideoEncodeH264DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoEncodeH264ReferenceInfo* pStdReferenceInfo; +} VkVideoEncodeH264DpbSlotInfoKHR; + +typedef struct VkVideoEncodeH264ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH264ProfileIdc stdProfileIdc; +} VkVideoEncodeH264ProfileInfoKHR; + +typedef struct VkVideoEncodeH264RateControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeH264RateControlFlagsKHR flags; + uint32_t gopFrameCount; + uint32_t idrPeriod; + uint32_t consecutiveBFrameCount; + uint32_t temporalLayerCount; +} VkVideoEncodeH264RateControlInfoKHR; + +typedef struct VkVideoEncodeH264FrameSizeKHR { + uint32_t frameISize; + uint32_t framePSize; + uint32_t frameBSize; +} VkVideoEncodeH264FrameSizeKHR; + +typedef struct VkVideoEncodeH264RateControlLayerInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMinQp; + VkVideoEncodeH264QpKHR minQp; + VkBool32 useMaxQp; + VkVideoEncodeH264QpKHR maxQp; + VkBool32 useMaxFrameSize; + VkVideoEncodeH264FrameSizeKHR maxFrameSize; +} VkVideoEncodeH264RateControlLayerInfoKHR; + +typedef struct VkVideoEncodeH264GopRemainingFrameInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useGopRemainingFrames; + uint32_t gopRemainingI; + uint32_t gopRemainingP; + uint32_t gopRemainingB; +} VkVideoEncodeH264GopRemainingFrameInfoKHR; + + + +// VK_KHR_video_encode_h265 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_encode_h265 1 +#include "../vk_video/vulkan_video_codec_h265std.h" +#include "../vk_video/vulkan_video_codec_h265std_encode.h" +#define VK_KHR_VIDEO_ENCODE_H265_SPEC_VERSION 14 +#define VK_KHR_VIDEO_ENCODE_H265_EXTENSION_NAME "VK_KHR_video_encode_h265" + +typedef enum VkVideoEncodeH265CapabilityFlagBitsKHR { + VK_VIDEO_ENCODE_H265_CAPABILITY_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_CAPABILITY_PREDICTION_WEIGHT_TABLE_GENERATED_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_CAPABILITY_ROW_UNALIGNED_SLICE_SEGMENT_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_CAPABILITY_DIFFERENT_SLICE_SEGMENT_TYPE_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L0_LIST_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H265_CAPABILITY_B_FRAME_IN_L1_LIST_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H265_CAPABILITY_PER_PICTURE_TYPE_MIN_MAX_QP_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H265_CAPABILITY_PER_SLICE_SEGMENT_CONSTANT_QP_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_TILES_PER_SLICE_SEGMENT_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H265_CAPABILITY_MULTIPLE_SLICE_SEGMENTS_PER_TILE_BIT_KHR = 0x00000200, + VK_VIDEO_ENCODE_H265_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265CapabilityFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265CapabilityFlagsKHR; + +typedef enum VkVideoEncodeH265StdFlagBitsKHR { + VK_VIDEO_ENCODE_H265_STD_SEPARATE_COLOR_PLANE_FLAG_SET_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_STD_SAMPLE_ADAPTIVE_OFFSET_ENABLED_FLAG_SET_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_STD_SCALING_LIST_DATA_PRESENT_FLAG_SET_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_STD_PCM_ENABLED_FLAG_SET_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_STD_SPS_TEMPORAL_MVP_ENABLED_FLAG_SET_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H265_STD_INIT_QP_MINUS26_BIT_KHR = 0x00000020, + VK_VIDEO_ENCODE_H265_STD_WEIGHTED_PRED_FLAG_SET_BIT_KHR = 0x00000040, + VK_VIDEO_ENCODE_H265_STD_WEIGHTED_BIPRED_FLAG_SET_BIT_KHR = 0x00000080, + VK_VIDEO_ENCODE_H265_STD_LOG2_PARALLEL_MERGE_LEVEL_MINUS2_BIT_KHR = 0x00000100, + VK_VIDEO_ENCODE_H265_STD_SIGN_DATA_HIDING_ENABLED_FLAG_SET_BIT_KHR = 0x00000200, + VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_SET_BIT_KHR = 0x00000400, + VK_VIDEO_ENCODE_H265_STD_TRANSFORM_SKIP_ENABLED_FLAG_UNSET_BIT_KHR = 0x00000800, + VK_VIDEO_ENCODE_H265_STD_PPS_SLICE_CHROMA_QP_OFFSETS_PRESENT_FLAG_SET_BIT_KHR = 0x00001000, + VK_VIDEO_ENCODE_H265_STD_TRANSQUANT_BYPASS_ENABLED_FLAG_SET_BIT_KHR = 0x00002000, + VK_VIDEO_ENCODE_H265_STD_CONSTRAINED_INTRA_PRED_FLAG_SET_BIT_KHR = 0x00004000, + VK_VIDEO_ENCODE_H265_STD_ENTROPY_CODING_SYNC_ENABLED_FLAG_SET_BIT_KHR = 0x00008000, + VK_VIDEO_ENCODE_H265_STD_DEBLOCKING_FILTER_OVERRIDE_ENABLED_FLAG_SET_BIT_KHR = 0x00010000, + VK_VIDEO_ENCODE_H265_STD_DEPENDENT_SLICE_SEGMENTS_ENABLED_FLAG_SET_BIT_KHR = 0x00020000, + VK_VIDEO_ENCODE_H265_STD_DEPENDENT_SLICE_SEGMENT_FLAG_SET_BIT_KHR = 0x00040000, + VK_VIDEO_ENCODE_H265_STD_SLICE_QP_DELTA_BIT_KHR = 0x00080000, + VK_VIDEO_ENCODE_H265_STD_DIFFERENT_SLICE_QP_DELTA_BIT_KHR = 0x00100000, + VK_VIDEO_ENCODE_H265_STD_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265StdFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265StdFlagsKHR; + +typedef enum VkVideoEncodeH265CtbSizeFlagBitsKHR { + VK_VIDEO_ENCODE_H265_CTB_SIZE_16_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_CTB_SIZE_32_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_CTB_SIZE_64_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_CTB_SIZE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265CtbSizeFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265CtbSizeFlagsKHR; + +typedef enum VkVideoEncodeH265TransformBlockSizeFlagBitsKHR { + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_4_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_8_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_16_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_32_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_TRANSFORM_BLOCK_SIZE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265TransformBlockSizeFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265TransformBlockSizeFlagsKHR; + +typedef enum VkVideoEncodeH265RateControlFlagBitsKHR { + VK_VIDEO_ENCODE_H265_RATE_CONTROL_ATTEMPT_HRD_COMPLIANCE_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_REGULAR_GOP_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_REFERENCE_PATTERN_FLAT_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_REFERENCE_PATTERN_DYADIC_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_TEMPORAL_SUB_LAYER_PATTERN_DYADIC_BIT_KHR = 0x00000010, + VK_VIDEO_ENCODE_H265_RATE_CONTROL_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeH265RateControlFlagBitsKHR; +typedef VkFlags VkVideoEncodeH265RateControlFlagsKHR; +typedef struct VkVideoEncodeH265CapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH265CapabilityFlagsKHR flags; + StdVideoH265LevelIdc maxLevelIdc; + uint32_t maxSliceSegmentCount; + VkExtent2D maxTiles; + VkVideoEncodeH265CtbSizeFlagsKHR ctbSizes; + VkVideoEncodeH265TransformBlockSizeFlagsKHR transformBlockSizes; + uint32_t maxPPictureL0ReferenceCount; + uint32_t maxBPictureL0ReferenceCount; + uint32_t maxL1ReferenceCount; + uint32_t maxSubLayerCount; + VkBool32 expectDyadicTemporalSubLayerPattern; + int32_t minQp; + int32_t maxQp; + VkBool32 prefersGopRemainingFrames; + VkBool32 requiresGopRemainingFrames; + VkVideoEncodeH265StdFlagsKHR stdSyntaxFlags; +} VkVideoEncodeH265CapabilitiesKHR; + +typedef struct VkVideoEncodeH265SessionCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMaxLevelIdc; + StdVideoH265LevelIdc maxLevelIdc; +} VkVideoEncodeH265SessionCreateInfoKHR; + +typedef struct VkVideoEncodeH265QpKHR { + int32_t qpI; + int32_t qpP; + int32_t qpB; +} VkVideoEncodeH265QpKHR; + +typedef struct VkVideoEncodeH265QualityLevelPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeH265RateControlFlagsKHR preferredRateControlFlags; + uint32_t preferredGopFrameCount; + uint32_t preferredIdrPeriod; + uint32_t preferredConsecutiveBFrameCount; + uint32_t preferredSubLayerCount; + VkVideoEncodeH265QpKHR preferredConstantQp; + uint32_t preferredMaxL0ReferenceCount; + uint32_t preferredMaxL1ReferenceCount; +} VkVideoEncodeH265QualityLevelPropertiesKHR; + +typedef struct VkVideoEncodeH265SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdVPSCount; + const StdVideoH265VideoParameterSet* pStdVPSs; + uint32_t stdSPSCount; + const StdVideoH265SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH265PictureParameterSet* pStdPPSs; +} VkVideoEncodeH265SessionParametersAddInfoKHR; + +typedef struct VkVideoEncodeH265SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdVPSCount; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoEncodeH265SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoEncodeH265SessionParametersCreateInfoKHR; + +typedef struct VkVideoEncodeH265SessionParametersGetInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 writeStdVPS; + VkBool32 writeStdSPS; + VkBool32 writeStdPPS; + uint32_t stdVPSId; + uint32_t stdSPSId; + uint32_t stdPPSId; +} VkVideoEncodeH265SessionParametersGetInfoKHR; + +typedef struct VkVideoEncodeH265SessionParametersFeedbackInfoKHR { + VkStructureType sType; + void* pNext; + VkBool32 hasStdVPSOverrides; + VkBool32 hasStdSPSOverrides; + VkBool32 hasStdPPSOverrides; +} VkVideoEncodeH265SessionParametersFeedbackInfoKHR; + +typedef struct VkVideoEncodeH265NaluSliceSegmentInfoKHR { + VkStructureType sType; + const void* pNext; + int32_t constantQp; + const StdVideoEncodeH265SliceSegmentHeader* pStdSliceSegmentHeader; +} VkVideoEncodeH265NaluSliceSegmentInfoKHR; + +typedef struct VkVideoEncodeH265PictureInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t naluSliceSegmentEntryCount; + const VkVideoEncodeH265NaluSliceSegmentInfoKHR* pNaluSliceSegmentEntries; + const StdVideoEncodeH265PictureInfo* pStdPictureInfo; +} VkVideoEncodeH265PictureInfoKHR; + +typedef struct VkVideoEncodeH265DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoEncodeH265ReferenceInfo* pStdReferenceInfo; +} VkVideoEncodeH265DpbSlotInfoKHR; + +typedef struct VkVideoEncodeH265ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH265ProfileIdc stdProfileIdc; +} VkVideoEncodeH265ProfileInfoKHR; + +typedef struct VkVideoEncodeH265RateControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeH265RateControlFlagsKHR flags; + uint32_t gopFrameCount; + uint32_t idrPeriod; + uint32_t consecutiveBFrameCount; + uint32_t subLayerCount; +} VkVideoEncodeH265RateControlInfoKHR; + +typedef struct VkVideoEncodeH265FrameSizeKHR { + uint32_t frameISize; + uint32_t framePSize; + uint32_t frameBSize; +} VkVideoEncodeH265FrameSizeKHR; + +typedef struct VkVideoEncodeH265RateControlLayerInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useMinQp; + VkVideoEncodeH265QpKHR minQp; + VkBool32 useMaxQp; + VkVideoEncodeH265QpKHR maxQp; + VkBool32 useMaxFrameSize; + VkVideoEncodeH265FrameSizeKHR maxFrameSize; +} VkVideoEncodeH265RateControlLayerInfoKHR; + +typedef struct VkVideoEncodeH265GopRemainingFrameInfoKHR { + VkStructureType sType; + const void* pNext; + VkBool32 useGopRemainingFrames; + uint32_t gopRemainingI; + uint32_t gopRemainingP; + uint32_t gopRemainingB; +} VkVideoEncodeH265GopRemainingFrameInfoKHR; + + + +// VK_KHR_video_decode_h264 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_decode_h264 1 +#include "../vk_video/vulkan_video_codec_h264std_decode.h" +#define VK_KHR_VIDEO_DECODE_H264_SPEC_VERSION 9 +#define VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME "VK_KHR_video_decode_h264" + +typedef enum VkVideoDecodeH264PictureLayoutFlagBitsKHR { + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_PROGRESSIVE_KHR = 0, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_INTERLEAVED_LINES_BIT_KHR = 0x00000001, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_INTERLACED_SEPARATE_PLANES_BIT_KHR = 0x00000002, + VK_VIDEO_DECODE_H264_PICTURE_LAYOUT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoDecodeH264PictureLayoutFlagBitsKHR; +typedef VkFlags VkVideoDecodeH264PictureLayoutFlagsKHR; +typedef struct VkVideoDecodeH264ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH264ProfileIdc stdProfileIdc; + VkVideoDecodeH264PictureLayoutFlagBitsKHR pictureLayout; +} VkVideoDecodeH264ProfileInfoKHR; + +typedef struct VkVideoDecodeH264CapabilitiesKHR { + VkStructureType sType; + void* pNext; + StdVideoH264LevelIdc maxLevelIdc; + VkOffset2D fieldOffsetGranularity; +} VkVideoDecodeH264CapabilitiesKHR; + +typedef struct VkVideoDecodeH264SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdSPSCount; + const StdVideoH264SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH264PictureParameterSet* pStdPPSs; +} VkVideoDecodeH264SessionParametersAddInfoKHR; + +typedef struct VkVideoDecodeH264SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoDecodeH264SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoDecodeH264SessionParametersCreateInfoKHR; + +typedef struct VkVideoDecodeH264PictureInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH264PictureInfo* pStdPictureInfo; + uint32_t sliceCount; + const uint32_t* pSliceOffsets; +} VkVideoDecodeH264PictureInfoKHR; + +typedef struct VkVideoDecodeH264DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH264ReferenceInfo* pStdReferenceInfo; +} VkVideoDecodeH264DpbSlotInfoKHR; + + + +// VK_KHR_dynamic_rendering is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_dynamic_rendering 1 +#define VK_KHR_DYNAMIC_RENDERING_SPEC_VERSION 1 +#define VK_KHR_DYNAMIC_RENDERING_EXTENSION_NAME "VK_KHR_dynamic_rendering" +typedef VkRenderingFlags VkRenderingFlagsKHR; + +typedef VkRenderingFlagBits VkRenderingFlagBitsKHR; + +typedef VkRenderingInfo VkRenderingInfoKHR; + +typedef VkRenderingAttachmentInfo VkRenderingAttachmentInfoKHR; + +typedef VkPipelineRenderingCreateInfo VkPipelineRenderingCreateInfoKHR; + +typedef VkPhysicalDeviceDynamicRenderingFeatures VkPhysicalDeviceDynamicRenderingFeaturesKHR; + +typedef VkCommandBufferInheritanceRenderingInfo VkCommandBufferInheritanceRenderingInfoKHR; + +typedef struct VkRenderingFragmentShadingRateAttachmentInfoKHR { + VkStructureType sType; + const void* pNext; + VkImageView imageView; + VkImageLayout imageLayout; + VkExtent2D shadingRateAttachmentTexelSize; +} VkRenderingFragmentShadingRateAttachmentInfoKHR; + +typedef struct VkRenderingFragmentDensityMapAttachmentInfoEXT { + VkStructureType sType; + const void* pNext; + VkImageView imageView; + VkImageLayout imageLayout; +} VkRenderingFragmentDensityMapAttachmentInfoEXT; + +typedef struct VkAttachmentSampleCountInfoAMD { + VkStructureType sType; + const void* pNext; + uint32_t colorAttachmentCount; + const VkSampleCountFlagBits* pColorAttachmentSamples; + VkSampleCountFlagBits depthStencilAttachmentSamples; +} VkAttachmentSampleCountInfoAMD; + +typedef VkAttachmentSampleCountInfoAMD VkAttachmentSampleCountInfoNV; + +typedef struct VkMultiviewPerViewAttributesInfoNVX { + VkStructureType sType; + const void* pNext; + VkBool32 perViewAttributes; + VkBool32 perViewAttributesPositionXOnly; +} VkMultiviewPerViewAttributesInfoNVX; + +typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderingKHR)(VkCommandBuffer commandBuffer, const VkRenderingInfo* pRenderingInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndRenderingKHR)(VkCommandBuffer commandBuffer); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderingKHR( + VkCommandBuffer commandBuffer, + const VkRenderingInfo* pRenderingInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderingKHR( + VkCommandBuffer commandBuffer); +#endif + + +// VK_KHR_multiview is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_multiview 1 +#define VK_KHR_MULTIVIEW_SPEC_VERSION 1 +#define VK_KHR_MULTIVIEW_EXTENSION_NAME "VK_KHR_multiview" +typedef VkRenderPassMultiviewCreateInfo VkRenderPassMultiviewCreateInfoKHR; + +typedef VkPhysicalDeviceMultiviewFeatures VkPhysicalDeviceMultiviewFeaturesKHR; + +typedef VkPhysicalDeviceMultiviewProperties VkPhysicalDeviceMultiviewPropertiesKHR; + + + +// VK_KHR_get_physical_device_properties2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_get_physical_device_properties2 1 +#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_SPEC_VERSION 2 +#define VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_physical_device_properties2" +typedef VkPhysicalDeviceFeatures2 VkPhysicalDeviceFeatures2KHR; + +typedef VkPhysicalDeviceProperties2 VkPhysicalDeviceProperties2KHR; + +typedef VkFormatProperties2 VkFormatProperties2KHR; + +typedef VkImageFormatProperties2 VkImageFormatProperties2KHR; + +typedef VkPhysicalDeviceImageFormatInfo2 VkPhysicalDeviceImageFormatInfo2KHR; + +typedef VkQueueFamilyProperties2 VkQueueFamilyProperties2KHR; + +typedef VkPhysicalDeviceMemoryProperties2 VkPhysicalDeviceMemoryProperties2KHR; + +typedef VkSparseImageFormatProperties2 VkSparseImageFormatProperties2KHR; + +typedef VkPhysicalDeviceSparseImageFormatInfo2 VkPhysicalDeviceSparseImageFormatInfo2KHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFeatures2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2* pFeatures); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2* pProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceFormatProperties2KHR)(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties2* pFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, VkImageFormatProperties2* pImageFormatProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pQueueFamilyPropertyCount, VkQueueFamilyProperties2* pQueueFamilyProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMemoryProperties2KHR)(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties2* pMemoryProperties); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceSparseImageFormatProperties2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, uint32_t* pPropertyCount, VkSparseImageFormatProperties2* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFeatures2KHR( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceFeatures2* pFeatures); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceProperties2KHR( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceProperties2* pProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceFormatProperties2KHR( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkFormatProperties2* pFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceImageFormatInfo2* pImageFormatInfo, + VkImageFormatProperties2* pImageFormatProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties2KHR( + VkPhysicalDevice physicalDevice, + uint32_t* pQueueFamilyPropertyCount, + VkQueueFamilyProperties2* pQueueFamilyProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties2KHR( + VkPhysicalDevice physicalDevice, + VkPhysicalDeviceMemoryProperties2* pMemoryProperties); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSparseImageFormatInfo2* pFormatInfo, + uint32_t* pPropertyCount, + VkSparseImageFormatProperties2* pProperties); +#endif + + +// VK_KHR_device_group is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_device_group 1 +#define VK_KHR_DEVICE_GROUP_SPEC_VERSION 4 +#define VK_KHR_DEVICE_GROUP_EXTENSION_NAME "VK_KHR_device_group" +typedef VkPeerMemoryFeatureFlags VkPeerMemoryFeatureFlagsKHR; + +typedef VkPeerMemoryFeatureFlagBits VkPeerMemoryFeatureFlagBitsKHR; + +typedef VkMemoryAllocateFlags VkMemoryAllocateFlagsKHR; + +typedef VkMemoryAllocateFlagBits VkMemoryAllocateFlagBitsKHR; + +typedef VkMemoryAllocateFlagsInfo VkMemoryAllocateFlagsInfoKHR; + +typedef VkDeviceGroupRenderPassBeginInfo VkDeviceGroupRenderPassBeginInfoKHR; + +typedef VkDeviceGroupCommandBufferBeginInfo VkDeviceGroupCommandBufferBeginInfoKHR; + +typedef VkDeviceGroupSubmitInfo VkDeviceGroupSubmitInfoKHR; + +typedef VkDeviceGroupBindSparseInfo VkDeviceGroupBindSparseInfoKHR; + +typedef VkBindBufferMemoryDeviceGroupInfo VkBindBufferMemoryDeviceGroupInfoKHR; + +typedef VkBindImageMemoryDeviceGroupInfo VkBindImageMemoryDeviceGroupInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkGetDeviceGroupPeerMemoryFeaturesKHR)(VkDevice device, uint32_t heapIndex, uint32_t localDeviceIndex, uint32_t remoteDeviceIndex, VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); +typedef void (VKAPI_PTR *PFN_vkCmdSetDeviceMaskKHR)(VkCommandBuffer commandBuffer, uint32_t deviceMask); +typedef void (VKAPI_PTR *PFN_vkCmdDispatchBaseKHR)(VkCommandBuffer commandBuffer, uint32_t baseGroupX, uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDeviceGroupPeerMemoryFeaturesKHR( + VkDevice device, + uint32_t heapIndex, + uint32_t localDeviceIndex, + uint32_t remoteDeviceIndex, + VkPeerMemoryFeatureFlags* pPeerMemoryFeatures); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDeviceMaskKHR( + VkCommandBuffer commandBuffer, + uint32_t deviceMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdDispatchBaseKHR( + VkCommandBuffer commandBuffer, + uint32_t baseGroupX, + uint32_t baseGroupY, + uint32_t baseGroupZ, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); +#endif + + +// VK_KHR_shader_draw_parameters is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_draw_parameters 1 +#define VK_KHR_SHADER_DRAW_PARAMETERS_SPEC_VERSION 1 +#define VK_KHR_SHADER_DRAW_PARAMETERS_EXTENSION_NAME "VK_KHR_shader_draw_parameters" + + +// VK_KHR_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance1 1 +#define VK_KHR_MAINTENANCE_1_SPEC_VERSION 2 +#define VK_KHR_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_maintenance1" +#define VK_KHR_MAINTENANCE1_SPEC_VERSION VK_KHR_MAINTENANCE_1_SPEC_VERSION +#define VK_KHR_MAINTENANCE1_EXTENSION_NAME VK_KHR_MAINTENANCE_1_EXTENSION_NAME +typedef VkCommandPoolTrimFlags VkCommandPoolTrimFlagsKHR; + +typedef void (VKAPI_PTR *PFN_vkTrimCommandPoolKHR)(VkDevice device, VkCommandPool commandPool, VkCommandPoolTrimFlags flags); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkTrimCommandPoolKHR( + VkDevice device, + VkCommandPool commandPool, + VkCommandPoolTrimFlags flags); +#endif + + +// VK_KHR_device_group_creation is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_device_group_creation 1 +#define VK_KHR_DEVICE_GROUP_CREATION_SPEC_VERSION 1 +#define VK_KHR_DEVICE_GROUP_CREATION_EXTENSION_NAME "VK_KHR_device_group_creation" +#define VK_MAX_DEVICE_GROUP_SIZE_KHR VK_MAX_DEVICE_GROUP_SIZE +typedef VkPhysicalDeviceGroupProperties VkPhysicalDeviceGroupPropertiesKHR; + +typedef VkDeviceGroupDeviceCreateInfo VkDeviceGroupDeviceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceGroupsKHR)(VkInstance instance, uint32_t* pPhysicalDeviceGroupCount, VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceGroupsKHR( + VkInstance instance, + uint32_t* pPhysicalDeviceGroupCount, + VkPhysicalDeviceGroupProperties* pPhysicalDeviceGroupProperties); +#endif + + +// VK_KHR_external_memory_capabilities is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_memory_capabilities 1 +#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_memory_capabilities" +#define VK_LUID_SIZE_KHR VK_LUID_SIZE +typedef VkExternalMemoryHandleTypeFlags VkExternalMemoryHandleTypeFlagsKHR; + +typedef VkExternalMemoryHandleTypeFlagBits VkExternalMemoryHandleTypeFlagBitsKHR; + +typedef VkExternalMemoryFeatureFlags VkExternalMemoryFeatureFlagsKHR; + +typedef VkExternalMemoryFeatureFlagBits VkExternalMemoryFeatureFlagBitsKHR; + +typedef VkExternalMemoryProperties VkExternalMemoryPropertiesKHR; + +typedef VkPhysicalDeviceExternalImageFormatInfo VkPhysicalDeviceExternalImageFormatInfoKHR; + +typedef VkExternalImageFormatProperties VkExternalImageFormatPropertiesKHR; + +typedef VkPhysicalDeviceExternalBufferInfo VkPhysicalDeviceExternalBufferInfoKHR; + +typedef VkExternalBufferProperties VkExternalBufferPropertiesKHR; + +typedef VkPhysicalDeviceIDProperties VkPhysicalDeviceIDPropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalBufferPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, VkExternalBufferProperties* pExternalBufferProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalBufferPropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalBufferInfo* pExternalBufferInfo, + VkExternalBufferProperties* pExternalBufferProperties); +#endif + + +// VK_KHR_external_memory is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_memory 1 +#define VK_KHR_EXTERNAL_MEMORY_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME "VK_KHR_external_memory" +#define VK_QUEUE_FAMILY_EXTERNAL_KHR VK_QUEUE_FAMILY_EXTERNAL +typedef VkExternalMemoryImageCreateInfo VkExternalMemoryImageCreateInfoKHR; + +typedef VkExternalMemoryBufferCreateInfo VkExternalMemoryBufferCreateInfoKHR; + +typedef VkExportMemoryAllocateInfo VkExportMemoryAllocateInfoKHR; + + + +// VK_KHR_external_memory_fd is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_memory_fd 1 +#define VK_KHR_EXTERNAL_MEMORY_FD_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME "VK_KHR_external_memory_fd" +typedef struct VkImportMemoryFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; + int fd; +} VkImportMemoryFdInfoKHR; + +typedef struct VkMemoryFdPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; +} VkMemoryFdPropertiesKHR; + +typedef struct VkMemoryGetFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkMemoryGetFdInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdKHR)(VkDevice device, const VkMemoryGetFdInfoKHR* pGetFdInfo, int* pFd); +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryFdPropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, int fd, VkMemoryFdPropertiesKHR* pMemoryFdProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdKHR( + VkDevice device, + const VkMemoryGetFdInfoKHR* pGetFdInfo, + int* pFd); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryFdPropertiesKHR( + VkDevice device, + VkExternalMemoryHandleTypeFlagBits handleType, + int fd, + VkMemoryFdPropertiesKHR* pMemoryFdProperties); +#endif + + +// VK_KHR_external_semaphore_capabilities is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_semaphore_capabilities 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_semaphore_capabilities" +typedef VkExternalSemaphoreHandleTypeFlags VkExternalSemaphoreHandleTypeFlagsKHR; + +typedef VkExternalSemaphoreHandleTypeFlagBits VkExternalSemaphoreHandleTypeFlagBitsKHR; + +typedef VkExternalSemaphoreFeatureFlags VkExternalSemaphoreFeatureFlagsKHR; + +typedef VkExternalSemaphoreFeatureFlagBits VkExternalSemaphoreFeatureFlagBitsKHR; + +typedef VkPhysicalDeviceExternalSemaphoreInfo VkPhysicalDeviceExternalSemaphoreInfoKHR; + +typedef VkExternalSemaphoreProperties VkExternalSemaphorePropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalSemaphorePropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, VkExternalSemaphoreProperties* pExternalSemaphoreProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalSemaphorePropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalSemaphoreInfo* pExternalSemaphoreInfo, + VkExternalSemaphoreProperties* pExternalSemaphoreProperties); +#endif + + +// VK_KHR_external_semaphore is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_semaphore 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_KHR_external_semaphore" +typedef VkSemaphoreImportFlags VkSemaphoreImportFlagsKHR; + +typedef VkSemaphoreImportFlagBits VkSemaphoreImportFlagBitsKHR; + +typedef VkExportSemaphoreCreateInfo VkExportSemaphoreCreateInfoKHR; + + + +// VK_KHR_external_semaphore_fd is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_semaphore_fd 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_FD_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME "VK_KHR_external_semaphore_fd" +typedef struct VkImportSemaphoreFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkSemaphoreImportFlags flags; + VkExternalSemaphoreHandleTypeFlagBits handleType; + int fd; +} VkImportSemaphoreFdInfoKHR; + +typedef struct VkSemaphoreGetFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkExternalSemaphoreHandleTypeFlagBits handleType; +} VkSemaphoreGetFdInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreFdKHR)(VkDevice device, const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreFdKHR)(VkDevice device, const VkSemaphoreGetFdInfoKHR* pGetFdInfo, int* pFd); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreFdKHR( + VkDevice device, + const VkImportSemaphoreFdInfoKHR* pImportSemaphoreFdInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreFdKHR( + VkDevice device, + const VkSemaphoreGetFdInfoKHR* pGetFdInfo, + int* pFd); +#endif + + +// VK_KHR_push_descriptor is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_push_descriptor 1 +#define VK_KHR_PUSH_DESCRIPTOR_SPEC_VERSION 2 +#define VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME "VK_KHR_push_descriptor" +typedef struct VkPhysicalDevicePushDescriptorPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t maxPushDescriptors; +} VkPhysicalDevicePushDescriptorPropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetKHR)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set, uint32_t descriptorWriteCount, const VkWriteDescriptorSet* pDescriptorWrites); +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetWithTemplateKHR)(VkCommandBuffer commandBuffer, VkDescriptorUpdateTemplate descriptorUpdateTemplate, VkPipelineLayout layout, uint32_t set, const void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetKHR( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t set, + uint32_t descriptorWriteCount, + const VkWriteDescriptorSet* pDescriptorWrites); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplateKHR( + VkCommandBuffer commandBuffer, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + VkPipelineLayout layout, + uint32_t set, + const void* pData); +#endif + + +// VK_KHR_shader_float16_int8 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_float16_int8 1 +#define VK_KHR_SHADER_FLOAT16_INT8_SPEC_VERSION 1 +#define VK_KHR_SHADER_FLOAT16_INT8_EXTENSION_NAME "VK_KHR_shader_float16_int8" +typedef VkPhysicalDeviceShaderFloat16Int8Features VkPhysicalDeviceShaderFloat16Int8FeaturesKHR; + +typedef VkPhysicalDeviceShaderFloat16Int8Features VkPhysicalDeviceFloat16Int8FeaturesKHR; + + + +// VK_KHR_16bit_storage is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_16bit_storage 1 +#define VK_KHR_16BIT_STORAGE_SPEC_VERSION 1 +#define VK_KHR_16BIT_STORAGE_EXTENSION_NAME "VK_KHR_16bit_storage" +typedef VkPhysicalDevice16BitStorageFeatures VkPhysicalDevice16BitStorageFeaturesKHR; + + + +// VK_KHR_incremental_present is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_incremental_present 1 +#define VK_KHR_INCREMENTAL_PRESENT_SPEC_VERSION 2 +#define VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME "VK_KHR_incremental_present" +typedef struct VkRectLayerKHR { + VkOffset2D offset; + VkExtent2D extent; + uint32_t layer; +} VkRectLayerKHR; + +typedef struct VkPresentRegionKHR { + uint32_t rectangleCount; + const VkRectLayerKHR* pRectangles; +} VkPresentRegionKHR; + +typedef struct VkPresentRegionsKHR { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkPresentRegionKHR* pRegions; +} VkPresentRegionsKHR; + + + +// VK_KHR_descriptor_update_template is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_descriptor_update_template 1 +typedef VkDescriptorUpdateTemplate VkDescriptorUpdateTemplateKHR; + +#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_SPEC_VERSION 1 +#define VK_KHR_DESCRIPTOR_UPDATE_TEMPLATE_EXTENSION_NAME "VK_KHR_descriptor_update_template" +typedef VkDescriptorUpdateTemplateType VkDescriptorUpdateTemplateTypeKHR; + +typedef VkDescriptorUpdateTemplateCreateFlags VkDescriptorUpdateTemplateCreateFlagsKHR; + +typedef VkDescriptorUpdateTemplateEntry VkDescriptorUpdateTemplateEntryKHR; + +typedef VkDescriptorUpdateTemplateCreateInfo VkDescriptorUpdateTemplateCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateDescriptorUpdateTemplateKHR)(VkDevice device, const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); +typedef void (VKAPI_PTR *PFN_vkDestroyDescriptorUpdateTemplateKHR)(VkDevice device, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkUpdateDescriptorSetWithTemplateKHR)(VkDevice device, VkDescriptorSet descriptorSet, VkDescriptorUpdateTemplate descriptorUpdateTemplate, const void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDescriptorUpdateTemplateKHR( + VkDevice device, + const VkDescriptorUpdateTemplateCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDescriptorUpdateTemplate* pDescriptorUpdateTemplate); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDescriptorUpdateTemplateKHR( + VkDevice device, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkUpdateDescriptorSetWithTemplateKHR( + VkDevice device, + VkDescriptorSet descriptorSet, + VkDescriptorUpdateTemplate descriptorUpdateTemplate, + const void* pData); +#endif + + +// VK_KHR_imageless_framebuffer is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_imageless_framebuffer 1 +#define VK_KHR_IMAGELESS_FRAMEBUFFER_SPEC_VERSION 1 +#define VK_KHR_IMAGELESS_FRAMEBUFFER_EXTENSION_NAME "VK_KHR_imageless_framebuffer" +typedef VkPhysicalDeviceImagelessFramebufferFeatures VkPhysicalDeviceImagelessFramebufferFeaturesKHR; + +typedef VkFramebufferAttachmentsCreateInfo VkFramebufferAttachmentsCreateInfoKHR; + +typedef VkFramebufferAttachmentImageInfo VkFramebufferAttachmentImageInfoKHR; + +typedef VkRenderPassAttachmentBeginInfo VkRenderPassAttachmentBeginInfoKHR; + + + +// VK_KHR_create_renderpass2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_create_renderpass2 1 +#define VK_KHR_CREATE_RENDERPASS_2_SPEC_VERSION 1 +#define VK_KHR_CREATE_RENDERPASS_2_EXTENSION_NAME "VK_KHR_create_renderpass2" +typedef VkRenderPassCreateInfo2 VkRenderPassCreateInfo2KHR; + +typedef VkAttachmentDescription2 VkAttachmentDescription2KHR; + +typedef VkAttachmentReference2 VkAttachmentReference2KHR; + +typedef VkSubpassDescription2 VkSubpassDescription2KHR; + +typedef VkSubpassDependency2 VkSubpassDependency2KHR; + +typedef VkSubpassBeginInfo VkSubpassBeginInfoKHR; + +typedef VkSubpassEndInfo VkSubpassEndInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateRenderPass2KHR)(VkDevice device, const VkRenderPassCreateInfo2* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkRenderPass* pRenderPass); +typedef void (VKAPI_PTR *PFN_vkCmdBeginRenderPass2KHR)(VkCommandBuffer commandBuffer, const VkRenderPassBeginInfo* pRenderPassBegin, const VkSubpassBeginInfo* pSubpassBeginInfo); +typedef void (VKAPI_PTR *PFN_vkCmdNextSubpass2KHR)(VkCommandBuffer commandBuffer, const VkSubpassBeginInfo* pSubpassBeginInfo, const VkSubpassEndInfo* pSubpassEndInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndRenderPass2KHR)(VkCommandBuffer commandBuffer, const VkSubpassEndInfo* pSubpassEndInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRenderPass2KHR( + VkDevice device, + const VkRenderPassCreateInfo2* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkRenderPass* pRenderPass); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginRenderPass2KHR( + VkCommandBuffer commandBuffer, + const VkRenderPassBeginInfo* pRenderPassBegin, + const VkSubpassBeginInfo* pSubpassBeginInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdNextSubpass2KHR( + VkCommandBuffer commandBuffer, + const VkSubpassBeginInfo* pSubpassBeginInfo, + const VkSubpassEndInfo* pSubpassEndInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndRenderPass2KHR( + VkCommandBuffer commandBuffer, + const VkSubpassEndInfo* pSubpassEndInfo); +#endif + + +// VK_KHR_shared_presentable_image is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shared_presentable_image 1 +#define VK_KHR_SHARED_PRESENTABLE_IMAGE_SPEC_VERSION 1 +#define VK_KHR_SHARED_PRESENTABLE_IMAGE_EXTENSION_NAME "VK_KHR_shared_presentable_image" +typedef struct VkSharedPresentSurfaceCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkImageUsageFlags sharedPresentSupportedUsageFlags; +} VkSharedPresentSurfaceCapabilitiesKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainStatusKHR)(VkDevice device, VkSwapchainKHR swapchain); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainStatusKHR( + VkDevice device, + VkSwapchainKHR swapchain); +#endif + + +// VK_KHR_external_fence_capabilities is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_fence_capabilities 1 +#define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_CAPABILITIES_EXTENSION_NAME "VK_KHR_external_fence_capabilities" +typedef VkExternalFenceHandleTypeFlags VkExternalFenceHandleTypeFlagsKHR; + +typedef VkExternalFenceHandleTypeFlagBits VkExternalFenceHandleTypeFlagBitsKHR; + +typedef VkExternalFenceFeatureFlags VkExternalFenceFeatureFlagsKHR; + +typedef VkExternalFenceFeatureFlagBits VkExternalFenceFeatureFlagBitsKHR; + +typedef VkPhysicalDeviceExternalFenceInfo VkPhysicalDeviceExternalFenceInfoKHR; + +typedef VkExternalFenceProperties VkExternalFencePropertiesKHR; + +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalFencePropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, VkExternalFenceProperties* pExternalFenceProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceExternalFencePropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceExternalFenceInfo* pExternalFenceInfo, + VkExternalFenceProperties* pExternalFenceProperties); +#endif + + +// VK_KHR_external_fence is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_fence 1 +#define VK_KHR_EXTERNAL_FENCE_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_EXTENSION_NAME "VK_KHR_external_fence" +typedef VkFenceImportFlags VkFenceImportFlagsKHR; + +typedef VkFenceImportFlagBits VkFenceImportFlagBitsKHR; + +typedef VkExportFenceCreateInfo VkExportFenceCreateInfoKHR; + + + +// VK_KHR_external_fence_fd is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_fence_fd 1 +#define VK_KHR_EXTERNAL_FENCE_FD_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_FD_EXTENSION_NAME "VK_KHR_external_fence_fd" +typedef struct VkImportFenceFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkFenceImportFlags flags; + VkExternalFenceHandleTypeFlagBits handleType; + int fd; +} VkImportFenceFdInfoKHR; + +typedef struct VkFenceGetFdInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkExternalFenceHandleTypeFlagBits handleType; +} VkFenceGetFdInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportFenceFdKHR)(VkDevice device, const VkImportFenceFdInfoKHR* pImportFenceFdInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetFenceFdKHR)(VkDevice device, const VkFenceGetFdInfoKHR* pGetFdInfo, int* pFd); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceFdKHR( + VkDevice device, + const VkImportFenceFdInfoKHR* pImportFenceFdInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceFdKHR( + VkDevice device, + const VkFenceGetFdInfoKHR* pGetFdInfo, + int* pFd); +#endif + + +// VK_KHR_performance_query is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_performance_query 1 +#define VK_KHR_PERFORMANCE_QUERY_SPEC_VERSION 1 +#define VK_KHR_PERFORMANCE_QUERY_EXTENSION_NAME "VK_KHR_performance_query" + +typedef enum VkPerformanceCounterUnitKHR { + VK_PERFORMANCE_COUNTER_UNIT_GENERIC_KHR = 0, + VK_PERFORMANCE_COUNTER_UNIT_PERCENTAGE_KHR = 1, + VK_PERFORMANCE_COUNTER_UNIT_NANOSECONDS_KHR = 2, + VK_PERFORMANCE_COUNTER_UNIT_BYTES_KHR = 3, + VK_PERFORMANCE_COUNTER_UNIT_BYTES_PER_SECOND_KHR = 4, + VK_PERFORMANCE_COUNTER_UNIT_KELVIN_KHR = 5, + VK_PERFORMANCE_COUNTER_UNIT_WATTS_KHR = 6, + VK_PERFORMANCE_COUNTER_UNIT_VOLTS_KHR = 7, + VK_PERFORMANCE_COUNTER_UNIT_AMPS_KHR = 8, + VK_PERFORMANCE_COUNTER_UNIT_HERTZ_KHR = 9, + VK_PERFORMANCE_COUNTER_UNIT_CYCLES_KHR = 10, + VK_PERFORMANCE_COUNTER_UNIT_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterUnitKHR; + +typedef enum VkPerformanceCounterScopeKHR { + VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR = 0, + VK_PERFORMANCE_COUNTER_SCOPE_RENDER_PASS_KHR = 1, + VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR = 2, + VK_QUERY_SCOPE_COMMAND_BUFFER_KHR = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_BUFFER_KHR, + VK_QUERY_SCOPE_RENDER_PASS_KHR = VK_PERFORMANCE_COUNTER_SCOPE_RENDER_PASS_KHR, + VK_QUERY_SCOPE_COMMAND_KHR = VK_PERFORMANCE_COUNTER_SCOPE_COMMAND_KHR, + VK_PERFORMANCE_COUNTER_SCOPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterScopeKHR; + +typedef enum VkPerformanceCounterStorageKHR { + VK_PERFORMANCE_COUNTER_STORAGE_INT32_KHR = 0, + VK_PERFORMANCE_COUNTER_STORAGE_INT64_KHR = 1, + VK_PERFORMANCE_COUNTER_STORAGE_UINT32_KHR = 2, + VK_PERFORMANCE_COUNTER_STORAGE_UINT64_KHR = 3, + VK_PERFORMANCE_COUNTER_STORAGE_FLOAT32_KHR = 4, + VK_PERFORMANCE_COUNTER_STORAGE_FLOAT64_KHR = 5, + VK_PERFORMANCE_COUNTER_STORAGE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterStorageKHR; + +typedef enum VkPerformanceCounterDescriptionFlagBitsKHR { + VK_PERFORMANCE_COUNTER_DESCRIPTION_PERFORMANCE_IMPACTING_BIT_KHR = 0x00000001, + VK_PERFORMANCE_COUNTER_DESCRIPTION_CONCURRENTLY_IMPACTED_BIT_KHR = 0x00000002, + VK_PERFORMANCE_COUNTER_DESCRIPTION_PERFORMANCE_IMPACTING_KHR = VK_PERFORMANCE_COUNTER_DESCRIPTION_PERFORMANCE_IMPACTING_BIT_KHR, + VK_PERFORMANCE_COUNTER_DESCRIPTION_CONCURRENTLY_IMPACTED_KHR = VK_PERFORMANCE_COUNTER_DESCRIPTION_CONCURRENTLY_IMPACTED_BIT_KHR, + VK_PERFORMANCE_COUNTER_DESCRIPTION_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPerformanceCounterDescriptionFlagBitsKHR; +typedef VkFlags VkPerformanceCounterDescriptionFlagsKHR; + +typedef enum VkAcquireProfilingLockFlagBitsKHR { + VK_ACQUIRE_PROFILING_LOCK_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAcquireProfilingLockFlagBitsKHR; +typedef VkFlags VkAcquireProfilingLockFlagsKHR; +typedef struct VkPhysicalDevicePerformanceQueryFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 performanceCounterQueryPools; + VkBool32 performanceCounterMultipleQueryPools; +} VkPhysicalDevicePerformanceQueryFeaturesKHR; + +typedef struct VkPhysicalDevicePerformanceQueryPropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 allowCommandBufferQueryCopies; +} VkPhysicalDevicePerformanceQueryPropertiesKHR; + +typedef struct VkPerformanceCounterKHR { + VkStructureType sType; + void* pNext; + VkPerformanceCounterUnitKHR unit; + VkPerformanceCounterScopeKHR scope; + VkPerformanceCounterStorageKHR storage; + uint8_t uuid[VK_UUID_SIZE]; +} VkPerformanceCounterKHR; + +typedef struct VkPerformanceCounterDescriptionKHR { + VkStructureType sType; + void* pNext; + VkPerformanceCounterDescriptionFlagsKHR flags; + char name[VK_MAX_DESCRIPTION_SIZE]; + char category[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; +} VkPerformanceCounterDescriptionKHR; + +typedef struct VkQueryPoolPerformanceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t queueFamilyIndex; + uint32_t counterIndexCount; + const uint32_t* pCounterIndices; +} VkQueryPoolPerformanceCreateInfoKHR; + +typedef union VkPerformanceCounterResultKHR { + int32_t int32; + int64_t int64; + uint32_t uint32; + uint64_t uint64; + float float32; + double float64; +} VkPerformanceCounterResultKHR; + +typedef struct VkAcquireProfilingLockInfoKHR { + VkStructureType sType; + const void* pNext; + VkAcquireProfilingLockFlagsKHR flags; + uint64_t timeout; +} VkAcquireProfilingLockInfoKHR; + +typedef struct VkPerformanceQuerySubmitInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t counterPassIndex; +} VkPerformanceQuerySubmitInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, uint32_t* pCounterCount, VkPerformanceCounterKHR* pCounters, VkPerformanceCounterDescriptionKHR* pCounterDescriptions); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR)(VkPhysicalDevice physicalDevice, const VkQueryPoolPerformanceCreateInfoKHR* pPerformanceQueryCreateInfo, uint32_t* pNumPasses); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireProfilingLockKHR)(VkDevice device, const VkAcquireProfilingLockInfoKHR* pInfo); +typedef void (VKAPI_PTR *PFN_vkReleaseProfilingLockKHR)(VkDevice device); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkEnumeratePhysicalDeviceQueueFamilyPerformanceQueryCountersKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + uint32_t* pCounterCount, + VkPerformanceCounterKHR* pCounters, + VkPerformanceCounterDescriptionKHR* pCounterDescriptions); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyPerformanceQueryPassesKHR( + VkPhysicalDevice physicalDevice, + const VkQueryPoolPerformanceCreateInfoKHR* pPerformanceQueryCreateInfo, + uint32_t* pNumPasses); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireProfilingLockKHR( + VkDevice device, + const VkAcquireProfilingLockInfoKHR* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkReleaseProfilingLockKHR( + VkDevice device); +#endif + + +// VK_KHR_maintenance2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance2 1 +#define VK_KHR_MAINTENANCE_2_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE_2_EXTENSION_NAME "VK_KHR_maintenance2" +#define VK_KHR_MAINTENANCE2_SPEC_VERSION VK_KHR_MAINTENANCE_2_SPEC_VERSION +#define VK_KHR_MAINTENANCE2_EXTENSION_NAME VK_KHR_MAINTENANCE_2_EXTENSION_NAME +typedef VkPointClippingBehavior VkPointClippingBehaviorKHR; + +typedef VkTessellationDomainOrigin VkTessellationDomainOriginKHR; + +typedef VkPhysicalDevicePointClippingProperties VkPhysicalDevicePointClippingPropertiesKHR; + +typedef VkRenderPassInputAttachmentAspectCreateInfo VkRenderPassInputAttachmentAspectCreateInfoKHR; + +typedef VkInputAttachmentAspectReference VkInputAttachmentAspectReferenceKHR; + +typedef VkImageViewUsageCreateInfo VkImageViewUsageCreateInfoKHR; + +typedef VkPipelineTessellationDomainOriginStateCreateInfo VkPipelineTessellationDomainOriginStateCreateInfoKHR; + + + +// VK_KHR_get_surface_capabilities2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_get_surface_capabilities2 1 +#define VK_KHR_GET_SURFACE_CAPABILITIES_2_SPEC_VERSION 1 +#define VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME "VK_KHR_get_surface_capabilities2" +typedef struct VkPhysicalDeviceSurfaceInfo2KHR { + VkStructureType sType; + const void* pNext; + VkSurfaceKHR surface; +} VkPhysicalDeviceSurfaceInfo2KHR; + +typedef struct VkSurfaceCapabilities2KHR { + VkStructureType sType; + void* pNext; + VkSurfaceCapabilitiesKHR surfaceCapabilities; +} VkSurfaceCapabilities2KHR; + +typedef struct VkSurfaceFormat2KHR { + VkStructureType sType; + void* pNext; + VkSurfaceFormatKHR surfaceFormat; +} VkSurfaceFormat2KHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkSurfaceCapabilities2KHR* pSurfaceCapabilities); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceFormats2KHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pSurfaceFormatCount, VkSurfaceFormat2KHR* pSurfaceFormats); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + VkSurfaceCapabilities2KHR* pSurfaceCapabilities); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormats2KHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + uint32_t* pSurfaceFormatCount, + VkSurfaceFormat2KHR* pSurfaceFormats); +#endif + + +// VK_KHR_variable_pointers is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_variable_pointers 1 +#define VK_KHR_VARIABLE_POINTERS_SPEC_VERSION 1 +#define VK_KHR_VARIABLE_POINTERS_EXTENSION_NAME "VK_KHR_variable_pointers" +typedef VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointerFeaturesKHR; + +typedef VkPhysicalDeviceVariablePointersFeatures VkPhysicalDeviceVariablePointersFeaturesKHR; + + + +// VK_KHR_get_display_properties2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_get_display_properties2 1 +#define VK_KHR_GET_DISPLAY_PROPERTIES_2_SPEC_VERSION 1 +#define VK_KHR_GET_DISPLAY_PROPERTIES_2_EXTENSION_NAME "VK_KHR_get_display_properties2" +typedef struct VkDisplayProperties2KHR { + VkStructureType sType; + void* pNext; + VkDisplayPropertiesKHR displayProperties; +} VkDisplayProperties2KHR; + +typedef struct VkDisplayPlaneProperties2KHR { + VkStructureType sType; + void* pNext; + VkDisplayPlanePropertiesKHR displayPlaneProperties; +} VkDisplayPlaneProperties2KHR; + +typedef struct VkDisplayModeProperties2KHR { + VkStructureType sType; + void* pNext; + VkDisplayModePropertiesKHR displayModeProperties; +} VkDisplayModeProperties2KHR; + +typedef struct VkDisplayPlaneInfo2KHR { + VkStructureType sType; + const void* pNext; + VkDisplayModeKHR mode; + uint32_t planeIndex; +} VkDisplayPlaneInfo2KHR; + +typedef struct VkDisplayPlaneCapabilities2KHR { + VkStructureType sType; + void* pNext; + VkDisplayPlaneCapabilitiesKHR capabilities; +} VkDisplayPlaneCapabilities2KHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayProperties2KHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceDisplayPlaneProperties2KHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkDisplayPlaneProperties2KHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayModeProperties2KHR)(VkPhysicalDevice physicalDevice, VkDisplayKHR display, uint32_t* pPropertyCount, VkDisplayModeProperties2KHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDisplayPlaneCapabilities2KHR)(VkPhysicalDevice physicalDevice, const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo, VkDisplayPlaneCapabilities2KHR* pCapabilities); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayProperties2KHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayProperties2KHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceDisplayPlaneProperties2KHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkDisplayPlaneProperties2KHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayModeProperties2KHR( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display, + uint32_t* pPropertyCount, + VkDisplayModeProperties2KHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDisplayPlaneCapabilities2KHR( + VkPhysicalDevice physicalDevice, + const VkDisplayPlaneInfo2KHR* pDisplayPlaneInfo, + VkDisplayPlaneCapabilities2KHR* pCapabilities); +#endif + + +// VK_KHR_dedicated_allocation is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_dedicated_allocation 1 +#define VK_KHR_DEDICATED_ALLOCATION_SPEC_VERSION 3 +#define VK_KHR_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_KHR_dedicated_allocation" +typedef VkMemoryDedicatedRequirements VkMemoryDedicatedRequirementsKHR; + +typedef VkMemoryDedicatedAllocateInfo VkMemoryDedicatedAllocateInfoKHR; + + + +// VK_KHR_storage_buffer_storage_class is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_storage_buffer_storage_class 1 +#define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_SPEC_VERSION 1 +#define VK_KHR_STORAGE_BUFFER_STORAGE_CLASS_EXTENSION_NAME "VK_KHR_storage_buffer_storage_class" + + +// VK_KHR_relaxed_block_layout is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_relaxed_block_layout 1 +#define VK_KHR_RELAXED_BLOCK_LAYOUT_SPEC_VERSION 1 +#define VK_KHR_RELAXED_BLOCK_LAYOUT_EXTENSION_NAME "VK_KHR_relaxed_block_layout" + + +// VK_KHR_get_memory_requirements2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_get_memory_requirements2 1 +#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_SPEC_VERSION 1 +#define VK_KHR_GET_MEMORY_REQUIREMENTS_2_EXTENSION_NAME "VK_KHR_get_memory_requirements2" +typedef VkBufferMemoryRequirementsInfo2 VkBufferMemoryRequirementsInfo2KHR; + +typedef VkImageMemoryRequirementsInfo2 VkImageMemoryRequirementsInfo2KHR; + +typedef VkImageSparseMemoryRequirementsInfo2 VkImageSparseMemoryRequirementsInfo2KHR; + +typedef VkMemoryRequirements2 VkMemoryRequirements2KHR; + +typedef VkSparseImageMemoryRequirements2 VkSparseImageMemoryRequirements2KHR; + +typedef void (VKAPI_PTR *PFN_vkGetImageMemoryRequirements2KHR)(VkDevice device, const VkImageMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetBufferMemoryRequirements2KHR)(VkDevice device, const VkBufferMemoryRequirementsInfo2* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetImageSparseMemoryRequirements2KHR)(VkDevice device, const VkImageSparseMemoryRequirementsInfo2* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetImageMemoryRequirements2KHR( + VkDevice device, + const VkImageMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetBufferMemoryRequirements2KHR( + VkDevice device, + const VkBufferMemoryRequirementsInfo2* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSparseMemoryRequirements2KHR( + VkDevice device, + const VkImageSparseMemoryRequirementsInfo2* pInfo, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); +#endif + + +// VK_KHR_image_format_list is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_image_format_list 1 +#define VK_KHR_IMAGE_FORMAT_LIST_SPEC_VERSION 1 +#define VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME "VK_KHR_image_format_list" +typedef VkImageFormatListCreateInfo VkImageFormatListCreateInfoKHR; + + + +// VK_KHR_sampler_ycbcr_conversion is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_sampler_ycbcr_conversion 1 +typedef VkSamplerYcbcrConversion VkSamplerYcbcrConversionKHR; + +#define VK_KHR_SAMPLER_YCBCR_CONVERSION_SPEC_VERSION 14 +#define VK_KHR_SAMPLER_YCBCR_CONVERSION_EXTENSION_NAME "VK_KHR_sampler_ycbcr_conversion" +typedef VkSamplerYcbcrModelConversion VkSamplerYcbcrModelConversionKHR; + +typedef VkSamplerYcbcrRange VkSamplerYcbcrRangeKHR; + +typedef VkChromaLocation VkChromaLocationKHR; + +typedef VkSamplerYcbcrConversionCreateInfo VkSamplerYcbcrConversionCreateInfoKHR; + +typedef VkSamplerYcbcrConversionInfo VkSamplerYcbcrConversionInfoKHR; + +typedef VkBindImagePlaneMemoryInfo VkBindImagePlaneMemoryInfoKHR; + +typedef VkImagePlaneMemoryRequirementsInfo VkImagePlaneMemoryRequirementsInfoKHR; + +typedef VkPhysicalDeviceSamplerYcbcrConversionFeatures VkPhysicalDeviceSamplerYcbcrConversionFeaturesKHR; + +typedef VkSamplerYcbcrConversionImageFormatProperties VkSamplerYcbcrConversionImageFormatPropertiesKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateSamplerYcbcrConversionKHR)(VkDevice device, const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSamplerYcbcrConversion* pYcbcrConversion); +typedef void (VKAPI_PTR *PFN_vkDestroySamplerYcbcrConversionKHR)(VkDevice device, VkSamplerYcbcrConversion ycbcrConversion, const VkAllocationCallbacks* pAllocator); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateSamplerYcbcrConversionKHR( + VkDevice device, + const VkSamplerYcbcrConversionCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSamplerYcbcrConversion* pYcbcrConversion); + +VKAPI_ATTR void VKAPI_CALL vkDestroySamplerYcbcrConversionKHR( + VkDevice device, + VkSamplerYcbcrConversion ycbcrConversion, + const VkAllocationCallbacks* pAllocator); +#endif + + +// VK_KHR_bind_memory2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_bind_memory2 1 +#define VK_KHR_BIND_MEMORY_2_SPEC_VERSION 1 +#define VK_KHR_BIND_MEMORY_2_EXTENSION_NAME "VK_KHR_bind_memory2" +typedef VkBindBufferMemoryInfo VkBindBufferMemoryInfoKHR; + +typedef VkBindImageMemoryInfo VkBindImageMemoryInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkBindBufferMemory2KHR)(VkDevice device, uint32_t bindInfoCount, const VkBindBufferMemoryInfo* pBindInfos); +typedef VkResult (VKAPI_PTR *PFN_vkBindImageMemory2KHR)(VkDevice device, uint32_t bindInfoCount, const VkBindImageMemoryInfo* pBindInfos); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkBindBufferMemory2KHR( + VkDevice device, + uint32_t bindInfoCount, + const VkBindBufferMemoryInfo* pBindInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindImageMemory2KHR( + VkDevice device, + uint32_t bindInfoCount, + const VkBindImageMemoryInfo* pBindInfos); +#endif + + +// VK_KHR_maintenance3 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance3 1 +#define VK_KHR_MAINTENANCE_3_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE_3_EXTENSION_NAME "VK_KHR_maintenance3" +#define VK_KHR_MAINTENANCE3_SPEC_VERSION VK_KHR_MAINTENANCE_3_SPEC_VERSION +#define VK_KHR_MAINTENANCE3_EXTENSION_NAME VK_KHR_MAINTENANCE_3_EXTENSION_NAME +typedef VkPhysicalDeviceMaintenance3Properties VkPhysicalDeviceMaintenance3PropertiesKHR; + +typedef VkDescriptorSetLayoutSupport VkDescriptorSetLayoutSupportKHR; + +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutSupportKHR)(VkDevice device, const VkDescriptorSetLayoutCreateInfo* pCreateInfo, VkDescriptorSetLayoutSupport* pSupport); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSupportKHR( + VkDevice device, + const VkDescriptorSetLayoutCreateInfo* pCreateInfo, + VkDescriptorSetLayoutSupport* pSupport); +#endif + + +// VK_KHR_draw_indirect_count is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_draw_indirect_count 1 +#define VK_KHR_DRAW_INDIRECT_COUNT_SPEC_VERSION 1 +#define VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_KHR_draw_indirect_count" +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCountKHR)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCountKHR)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountKHR( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountKHR( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + + +// VK_KHR_shader_subgroup_extended_types is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_subgroup_extended_types 1 +#define VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_SPEC_VERSION 1 +#define VK_KHR_SHADER_SUBGROUP_EXTENDED_TYPES_EXTENSION_NAME "VK_KHR_shader_subgroup_extended_types" +typedef VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures VkPhysicalDeviceShaderSubgroupExtendedTypesFeaturesKHR; + + + +// VK_KHR_8bit_storage is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_8bit_storage 1 +#define VK_KHR_8BIT_STORAGE_SPEC_VERSION 1 +#define VK_KHR_8BIT_STORAGE_EXTENSION_NAME "VK_KHR_8bit_storage" +typedef VkPhysicalDevice8BitStorageFeatures VkPhysicalDevice8BitStorageFeaturesKHR; + + + +// VK_KHR_shader_atomic_int64 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_atomic_int64 1 +#define VK_KHR_SHADER_ATOMIC_INT64_SPEC_VERSION 1 +#define VK_KHR_SHADER_ATOMIC_INT64_EXTENSION_NAME "VK_KHR_shader_atomic_int64" +typedef VkPhysicalDeviceShaderAtomicInt64Features VkPhysicalDeviceShaderAtomicInt64FeaturesKHR; + + + +// VK_KHR_shader_clock is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_clock 1 +#define VK_KHR_SHADER_CLOCK_SPEC_VERSION 1 +#define VK_KHR_SHADER_CLOCK_EXTENSION_NAME "VK_KHR_shader_clock" +typedef struct VkPhysicalDeviceShaderClockFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderSubgroupClock; + VkBool32 shaderDeviceClock; +} VkPhysicalDeviceShaderClockFeaturesKHR; + + + +// VK_KHR_video_decode_h265 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_decode_h265 1 +#include "../vk_video/vulkan_video_codec_h265std_decode.h" +#define VK_KHR_VIDEO_DECODE_H265_SPEC_VERSION 8 +#define VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME "VK_KHR_video_decode_h265" +typedef struct VkVideoDecodeH265ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoH265ProfileIdc stdProfileIdc; +} VkVideoDecodeH265ProfileInfoKHR; + +typedef struct VkVideoDecodeH265CapabilitiesKHR { + VkStructureType sType; + void* pNext; + StdVideoH265LevelIdc maxLevelIdc; +} VkVideoDecodeH265CapabilitiesKHR; + +typedef struct VkVideoDecodeH265SessionParametersAddInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t stdVPSCount; + const StdVideoH265VideoParameterSet* pStdVPSs; + uint32_t stdSPSCount; + const StdVideoH265SequenceParameterSet* pStdSPSs; + uint32_t stdPPSCount; + const StdVideoH265PictureParameterSet* pStdPPSs; +} VkVideoDecodeH265SessionParametersAddInfoKHR; + +typedef struct VkVideoDecodeH265SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxStdVPSCount; + uint32_t maxStdSPSCount; + uint32_t maxStdPPSCount; + const VkVideoDecodeH265SessionParametersAddInfoKHR* pParametersAddInfo; +} VkVideoDecodeH265SessionParametersCreateInfoKHR; + +typedef struct VkVideoDecodeH265PictureInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH265PictureInfo* pStdPictureInfo; + uint32_t sliceSegmentCount; + const uint32_t* pSliceSegmentOffsets; +} VkVideoDecodeH265PictureInfoKHR; + +typedef struct VkVideoDecodeH265DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeH265ReferenceInfo* pStdReferenceInfo; +} VkVideoDecodeH265DpbSlotInfoKHR; + + + +// VK_KHR_global_priority is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_global_priority 1 +#define VK_MAX_GLOBAL_PRIORITY_SIZE_KHR 16U +#define VK_KHR_GLOBAL_PRIORITY_SPEC_VERSION 1 +#define VK_KHR_GLOBAL_PRIORITY_EXTENSION_NAME "VK_KHR_global_priority" + +typedef enum VkQueueGlobalPriorityKHR { + VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR = 128, + VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR = 256, + VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR = 512, + VK_QUEUE_GLOBAL_PRIORITY_REALTIME_KHR = 1024, + VK_QUEUE_GLOBAL_PRIORITY_LOW_EXT = VK_QUEUE_GLOBAL_PRIORITY_LOW_KHR, + VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT = VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_KHR, + VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT = VK_QUEUE_GLOBAL_PRIORITY_HIGH_KHR, + VK_QUEUE_GLOBAL_PRIORITY_REALTIME_EXT = VK_QUEUE_GLOBAL_PRIORITY_REALTIME_KHR, + VK_QUEUE_GLOBAL_PRIORITY_MAX_ENUM_KHR = 0x7FFFFFFF +} VkQueueGlobalPriorityKHR; +typedef struct VkDeviceQueueGlobalPriorityCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkQueueGlobalPriorityKHR globalPriority; +} VkDeviceQueueGlobalPriorityCreateInfoKHR; + +typedef struct VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 globalPriorityQuery; +} VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR; + +typedef struct VkQueueFamilyGlobalPriorityPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t priorityCount; + VkQueueGlobalPriorityKHR priorities[VK_MAX_GLOBAL_PRIORITY_SIZE_KHR]; +} VkQueueFamilyGlobalPriorityPropertiesKHR; + + + +// VK_KHR_driver_properties is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_driver_properties 1 +#define VK_KHR_DRIVER_PROPERTIES_SPEC_VERSION 1 +#define VK_KHR_DRIVER_PROPERTIES_EXTENSION_NAME "VK_KHR_driver_properties" +#define VK_MAX_DRIVER_NAME_SIZE_KHR VK_MAX_DRIVER_NAME_SIZE +#define VK_MAX_DRIVER_INFO_SIZE_KHR VK_MAX_DRIVER_INFO_SIZE +typedef VkDriverId VkDriverIdKHR; + +typedef VkConformanceVersion VkConformanceVersionKHR; + +typedef VkPhysicalDeviceDriverProperties VkPhysicalDeviceDriverPropertiesKHR; + + + +// VK_KHR_shader_float_controls is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_float_controls 1 +#define VK_KHR_SHADER_FLOAT_CONTROLS_SPEC_VERSION 4 +#define VK_KHR_SHADER_FLOAT_CONTROLS_EXTENSION_NAME "VK_KHR_shader_float_controls" +typedef VkShaderFloatControlsIndependence VkShaderFloatControlsIndependenceKHR; + +typedef VkPhysicalDeviceFloatControlsProperties VkPhysicalDeviceFloatControlsPropertiesKHR; + + + +// VK_KHR_depth_stencil_resolve is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_depth_stencil_resolve 1 +#define VK_KHR_DEPTH_STENCIL_RESOLVE_SPEC_VERSION 1 +#define VK_KHR_DEPTH_STENCIL_RESOLVE_EXTENSION_NAME "VK_KHR_depth_stencil_resolve" +typedef VkResolveModeFlagBits VkResolveModeFlagBitsKHR; + +typedef VkResolveModeFlags VkResolveModeFlagsKHR; + +typedef VkSubpassDescriptionDepthStencilResolve VkSubpassDescriptionDepthStencilResolveKHR; + +typedef VkPhysicalDeviceDepthStencilResolveProperties VkPhysicalDeviceDepthStencilResolvePropertiesKHR; + + + +// VK_KHR_swapchain_mutable_format is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_swapchain_mutable_format 1 +#define VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_SPEC_VERSION 1 +#define VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME "VK_KHR_swapchain_mutable_format" + + +// VK_KHR_timeline_semaphore is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_timeline_semaphore 1 +#define VK_KHR_TIMELINE_SEMAPHORE_SPEC_VERSION 2 +#define VK_KHR_TIMELINE_SEMAPHORE_EXTENSION_NAME "VK_KHR_timeline_semaphore" +typedef VkSemaphoreType VkSemaphoreTypeKHR; + +typedef VkSemaphoreWaitFlagBits VkSemaphoreWaitFlagBitsKHR; + +typedef VkSemaphoreWaitFlags VkSemaphoreWaitFlagsKHR; + +typedef VkPhysicalDeviceTimelineSemaphoreFeatures VkPhysicalDeviceTimelineSemaphoreFeaturesKHR; + +typedef VkPhysicalDeviceTimelineSemaphoreProperties VkPhysicalDeviceTimelineSemaphorePropertiesKHR; + +typedef VkSemaphoreTypeCreateInfo VkSemaphoreTypeCreateInfoKHR; + +typedef VkTimelineSemaphoreSubmitInfo VkTimelineSemaphoreSubmitInfoKHR; + +typedef VkSemaphoreWaitInfo VkSemaphoreWaitInfoKHR; + +typedef VkSemaphoreSignalInfo VkSemaphoreSignalInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreCounterValueKHR)(VkDevice device, VkSemaphore semaphore, uint64_t* pValue); +typedef VkResult (VKAPI_PTR *PFN_vkWaitSemaphoresKHR)(VkDevice device, const VkSemaphoreWaitInfo* pWaitInfo, uint64_t timeout); +typedef VkResult (VKAPI_PTR *PFN_vkSignalSemaphoreKHR)(VkDevice device, const VkSemaphoreSignalInfo* pSignalInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreCounterValueKHR( + VkDevice device, + VkSemaphore semaphore, + uint64_t* pValue); + +VKAPI_ATTR VkResult VKAPI_CALL vkWaitSemaphoresKHR( + VkDevice device, + const VkSemaphoreWaitInfo* pWaitInfo, + uint64_t timeout); + +VKAPI_ATTR VkResult VKAPI_CALL vkSignalSemaphoreKHR( + VkDevice device, + const VkSemaphoreSignalInfo* pSignalInfo); +#endif + + +// VK_KHR_vulkan_memory_model is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_vulkan_memory_model 1 +#define VK_KHR_VULKAN_MEMORY_MODEL_SPEC_VERSION 3 +#define VK_KHR_VULKAN_MEMORY_MODEL_EXTENSION_NAME "VK_KHR_vulkan_memory_model" +typedef VkPhysicalDeviceVulkanMemoryModelFeatures VkPhysicalDeviceVulkanMemoryModelFeaturesKHR; + + + +// VK_KHR_shader_terminate_invocation is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_terminate_invocation 1 +#define VK_KHR_SHADER_TERMINATE_INVOCATION_SPEC_VERSION 1 +#define VK_KHR_SHADER_TERMINATE_INVOCATION_EXTENSION_NAME "VK_KHR_shader_terminate_invocation" +typedef VkPhysicalDeviceShaderTerminateInvocationFeatures VkPhysicalDeviceShaderTerminateInvocationFeaturesKHR; + + + +// VK_KHR_fragment_shading_rate is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_fragment_shading_rate 1 +#define VK_KHR_FRAGMENT_SHADING_RATE_SPEC_VERSION 2 +#define VK_KHR_FRAGMENT_SHADING_RATE_EXTENSION_NAME "VK_KHR_fragment_shading_rate" + +typedef enum VkFragmentShadingRateCombinerOpKHR { + VK_FRAGMENT_SHADING_RATE_COMBINER_OP_KEEP_KHR = 0, + VK_FRAGMENT_SHADING_RATE_COMBINER_OP_REPLACE_KHR = 1, + VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MIN_KHR = 2, + VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_KHR = 3, + VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MUL_KHR = 4, + VK_FRAGMENT_SHADING_RATE_COMBINER_OP_MAX_ENUM_KHR = 0x7FFFFFFF +} VkFragmentShadingRateCombinerOpKHR; +typedef struct VkFragmentShadingRateAttachmentInfoKHR { + VkStructureType sType; + const void* pNext; + const VkAttachmentReference2* pFragmentShadingRateAttachment; + VkExtent2D shadingRateAttachmentTexelSize; +} VkFragmentShadingRateAttachmentInfoKHR; + +typedef struct VkPipelineFragmentShadingRateStateCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkExtent2D fragmentSize; + VkFragmentShadingRateCombinerOpKHR combinerOps[2]; +} VkPipelineFragmentShadingRateStateCreateInfoKHR; + +typedef struct VkPhysicalDeviceFragmentShadingRateFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 pipelineFragmentShadingRate; + VkBool32 primitiveFragmentShadingRate; + VkBool32 attachmentFragmentShadingRate; +} VkPhysicalDeviceFragmentShadingRateFeaturesKHR; + +typedef struct VkPhysicalDeviceFragmentShadingRatePropertiesKHR { + VkStructureType sType; + void* pNext; + VkExtent2D minFragmentShadingRateAttachmentTexelSize; + VkExtent2D maxFragmentShadingRateAttachmentTexelSize; + uint32_t maxFragmentShadingRateAttachmentTexelSizeAspectRatio; + VkBool32 primitiveFragmentShadingRateWithMultipleViewports; + VkBool32 layeredShadingRateAttachments; + VkBool32 fragmentShadingRateNonTrivialCombinerOps; + VkExtent2D maxFragmentSize; + uint32_t maxFragmentSizeAspectRatio; + uint32_t maxFragmentShadingRateCoverageSamples; + VkSampleCountFlagBits maxFragmentShadingRateRasterizationSamples; + VkBool32 fragmentShadingRateWithShaderDepthStencilWrites; + VkBool32 fragmentShadingRateWithSampleMask; + VkBool32 fragmentShadingRateWithShaderSampleMask; + VkBool32 fragmentShadingRateWithConservativeRasterization; + VkBool32 fragmentShadingRateWithFragmentShaderInterlock; + VkBool32 fragmentShadingRateWithCustomSampleLocations; + VkBool32 fragmentShadingRateStrictMultiplyCombiner; +} VkPhysicalDeviceFragmentShadingRatePropertiesKHR; + +typedef struct VkPhysicalDeviceFragmentShadingRateKHR { + VkStructureType sType; + void* pNext; + VkSampleCountFlags sampleCounts; + VkExtent2D fragmentSize; +} VkPhysicalDeviceFragmentShadingRateKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceFragmentShadingRatesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pFragmentShadingRateCount, VkPhysicalDeviceFragmentShadingRateKHR* pFragmentShadingRates); +typedef void (VKAPI_PTR *PFN_vkCmdSetFragmentShadingRateKHR)(VkCommandBuffer commandBuffer, const VkExtent2D* pFragmentSize, const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceFragmentShadingRatesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pFragmentShadingRateCount, + VkPhysicalDeviceFragmentShadingRateKHR* pFragmentShadingRates); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetFragmentShadingRateKHR( + VkCommandBuffer commandBuffer, + const VkExtent2D* pFragmentSize, + const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); +#endif + + +// VK_KHR_dynamic_rendering_local_read is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_dynamic_rendering_local_read 1 +#define VK_KHR_DYNAMIC_RENDERING_LOCAL_READ_SPEC_VERSION 1 +#define VK_KHR_DYNAMIC_RENDERING_LOCAL_READ_EXTENSION_NAME "VK_KHR_dynamic_rendering_local_read" +typedef struct VkPhysicalDeviceDynamicRenderingLocalReadFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 dynamicRenderingLocalRead; +} VkPhysicalDeviceDynamicRenderingLocalReadFeaturesKHR; + +typedef struct VkRenderingAttachmentLocationInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t colorAttachmentCount; + const uint32_t* pColorAttachmentLocations; +} VkRenderingAttachmentLocationInfoKHR; + +typedef struct VkRenderingInputAttachmentIndexInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t colorAttachmentCount; + const uint32_t* pColorAttachmentInputIndices; + const uint32_t* pDepthInputAttachmentIndex; + const uint32_t* pStencilInputAttachmentIndex; +} VkRenderingInputAttachmentIndexInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdSetRenderingAttachmentLocationsKHR)(VkCommandBuffer commandBuffer, const VkRenderingAttachmentLocationInfoKHR* pLocationInfo); +typedef void (VKAPI_PTR *PFN_vkCmdSetRenderingInputAttachmentIndicesKHR)(VkCommandBuffer commandBuffer, const VkRenderingInputAttachmentIndexInfoKHR* pLocationInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetRenderingAttachmentLocationsKHR( + VkCommandBuffer commandBuffer, + const VkRenderingAttachmentLocationInfoKHR* pLocationInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRenderingInputAttachmentIndicesKHR( + VkCommandBuffer commandBuffer, + const VkRenderingInputAttachmentIndexInfoKHR* pLocationInfo); +#endif + + +// VK_KHR_shader_quad_control is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_quad_control 1 +#define VK_KHR_SHADER_QUAD_CONTROL_SPEC_VERSION 1 +#define VK_KHR_SHADER_QUAD_CONTROL_EXTENSION_NAME "VK_KHR_shader_quad_control" +typedef struct VkPhysicalDeviceShaderQuadControlFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderQuadControl; +} VkPhysicalDeviceShaderQuadControlFeaturesKHR; + + + +// VK_KHR_spirv_1_4 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_spirv_1_4 1 +#define VK_KHR_SPIRV_1_4_SPEC_VERSION 1 +#define VK_KHR_SPIRV_1_4_EXTENSION_NAME "VK_KHR_spirv_1_4" + + +// VK_KHR_surface_protected_capabilities is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_surface_protected_capabilities 1 +#define VK_KHR_SURFACE_PROTECTED_CAPABILITIES_SPEC_VERSION 1 +#define VK_KHR_SURFACE_PROTECTED_CAPABILITIES_EXTENSION_NAME "VK_KHR_surface_protected_capabilities" +typedef struct VkSurfaceProtectedCapabilitiesKHR { + VkStructureType sType; + const void* pNext; + VkBool32 supportsProtected; +} VkSurfaceProtectedCapabilitiesKHR; + + + +// VK_KHR_separate_depth_stencil_layouts is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_separate_depth_stencil_layouts 1 +#define VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_SPEC_VERSION 1 +#define VK_KHR_SEPARATE_DEPTH_STENCIL_LAYOUTS_EXTENSION_NAME "VK_KHR_separate_depth_stencil_layouts" +typedef VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures VkPhysicalDeviceSeparateDepthStencilLayoutsFeaturesKHR; + +typedef VkAttachmentReferenceStencilLayout VkAttachmentReferenceStencilLayoutKHR; + +typedef VkAttachmentDescriptionStencilLayout VkAttachmentDescriptionStencilLayoutKHR; + + + +// VK_KHR_present_wait is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_present_wait 1 +#define VK_KHR_PRESENT_WAIT_SPEC_VERSION 1 +#define VK_KHR_PRESENT_WAIT_EXTENSION_NAME "VK_KHR_present_wait" +typedef struct VkPhysicalDevicePresentWaitFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 presentWait; +} VkPhysicalDevicePresentWaitFeaturesKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkWaitForPresentKHR)(VkDevice device, VkSwapchainKHR swapchain, uint64_t presentId, uint64_t timeout); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkWaitForPresentKHR( + VkDevice device, + VkSwapchainKHR swapchain, + uint64_t presentId, + uint64_t timeout); +#endif + + +// VK_KHR_uniform_buffer_standard_layout is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_uniform_buffer_standard_layout 1 +#define VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_SPEC_VERSION 1 +#define VK_KHR_UNIFORM_BUFFER_STANDARD_LAYOUT_EXTENSION_NAME "VK_KHR_uniform_buffer_standard_layout" +typedef VkPhysicalDeviceUniformBufferStandardLayoutFeatures VkPhysicalDeviceUniformBufferStandardLayoutFeaturesKHR; + + + +// VK_KHR_buffer_device_address is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_buffer_device_address 1 +#define VK_KHR_BUFFER_DEVICE_ADDRESS_SPEC_VERSION 1 +#define VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME "VK_KHR_buffer_device_address" +typedef VkPhysicalDeviceBufferDeviceAddressFeatures VkPhysicalDeviceBufferDeviceAddressFeaturesKHR; + +typedef VkBufferDeviceAddressInfo VkBufferDeviceAddressInfoKHR; + +typedef VkBufferOpaqueCaptureAddressCreateInfo VkBufferOpaqueCaptureAddressCreateInfoKHR; + +typedef VkMemoryOpaqueCaptureAddressAllocateInfo VkMemoryOpaqueCaptureAddressAllocateInfoKHR; + +typedef VkDeviceMemoryOpaqueCaptureAddressInfo VkDeviceMemoryOpaqueCaptureAddressInfoKHR; + +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetBufferDeviceAddressKHR)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetBufferOpaqueCaptureAddressKHR)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); +typedef uint64_t (VKAPI_PTR *PFN_vkGetDeviceMemoryOpaqueCaptureAddressKHR)(VkDevice device, const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressKHR( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetBufferOpaqueCaptureAddressKHR( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); + +VKAPI_ATTR uint64_t VKAPI_CALL vkGetDeviceMemoryOpaqueCaptureAddressKHR( + VkDevice device, + const VkDeviceMemoryOpaqueCaptureAddressInfo* pInfo); +#endif + + +// VK_KHR_deferred_host_operations is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_deferred_host_operations 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDeferredOperationKHR) +#define VK_KHR_DEFERRED_HOST_OPERATIONS_SPEC_VERSION 4 +#define VK_KHR_DEFERRED_HOST_OPERATIONS_EXTENSION_NAME "VK_KHR_deferred_host_operations" +typedef VkResult (VKAPI_PTR *PFN_vkCreateDeferredOperationKHR)(VkDevice device, const VkAllocationCallbacks* pAllocator, VkDeferredOperationKHR* pDeferredOperation); +typedef void (VKAPI_PTR *PFN_vkDestroyDeferredOperationKHR)(VkDevice device, VkDeferredOperationKHR operation, const VkAllocationCallbacks* pAllocator); +typedef uint32_t (VKAPI_PTR *PFN_vkGetDeferredOperationMaxConcurrencyKHR)(VkDevice device, VkDeferredOperationKHR operation); +typedef VkResult (VKAPI_PTR *PFN_vkGetDeferredOperationResultKHR)(VkDevice device, VkDeferredOperationKHR operation); +typedef VkResult (VKAPI_PTR *PFN_vkDeferredOperationJoinKHR)(VkDevice device, VkDeferredOperationKHR operation); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDeferredOperationKHR( + VkDevice device, + const VkAllocationCallbacks* pAllocator, + VkDeferredOperationKHR* pDeferredOperation); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDeferredOperationKHR( + VkDevice device, + VkDeferredOperationKHR operation, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR uint32_t VKAPI_CALL vkGetDeferredOperationMaxConcurrencyKHR( + VkDevice device, + VkDeferredOperationKHR operation); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeferredOperationResultKHR( + VkDevice device, + VkDeferredOperationKHR operation); + +VKAPI_ATTR VkResult VKAPI_CALL vkDeferredOperationJoinKHR( + VkDevice device, + VkDeferredOperationKHR operation); +#endif + + +// VK_KHR_pipeline_executable_properties is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_pipeline_executable_properties 1 +#define VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_SPEC_VERSION 1 +#define VK_KHR_PIPELINE_EXECUTABLE_PROPERTIES_EXTENSION_NAME "VK_KHR_pipeline_executable_properties" + +typedef enum VkPipelineExecutableStatisticFormatKHR { + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_BOOL32_KHR = 0, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_INT64_KHR = 1, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_UINT64_KHR = 2, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_FLOAT64_KHR = 3, + VK_PIPELINE_EXECUTABLE_STATISTIC_FORMAT_MAX_ENUM_KHR = 0x7FFFFFFF +} VkPipelineExecutableStatisticFormatKHR; +typedef struct VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 pipelineExecutableInfo; +} VkPhysicalDevicePipelineExecutablePropertiesFeaturesKHR; + +typedef struct VkPipelineInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipeline pipeline; +} VkPipelineInfoKHR; + +typedef struct VkPipelineExecutablePropertiesKHR { + VkStructureType sType; + void* pNext; + VkShaderStageFlags stages; + char name[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; + uint32_t subgroupSize; +} VkPipelineExecutablePropertiesKHR; + +typedef struct VkPipelineExecutableInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipeline pipeline; + uint32_t executableIndex; +} VkPipelineExecutableInfoKHR; + +typedef union VkPipelineExecutableStatisticValueKHR { + VkBool32 b32; + int64_t i64; + uint64_t u64; + double f64; +} VkPipelineExecutableStatisticValueKHR; + +typedef struct VkPipelineExecutableStatisticKHR { + VkStructureType sType; + void* pNext; + char name[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; + VkPipelineExecutableStatisticFormatKHR format; + VkPipelineExecutableStatisticValueKHR value; +} VkPipelineExecutableStatisticKHR; + +typedef struct VkPipelineExecutableInternalRepresentationKHR { + VkStructureType sType; + void* pNext; + char name[VK_MAX_DESCRIPTION_SIZE]; + char description[VK_MAX_DESCRIPTION_SIZE]; + VkBool32 isText; + size_t dataSize; + void* pData; +} VkPipelineExecutableInternalRepresentationKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineExecutablePropertiesKHR)(VkDevice device, const VkPipelineInfoKHR* pPipelineInfo, uint32_t* pExecutableCount, VkPipelineExecutablePropertiesKHR* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineExecutableStatisticsKHR)(VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pStatisticCount, VkPipelineExecutableStatisticKHR* pStatistics); +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelineExecutableInternalRepresentationsKHR)(VkDevice device, const VkPipelineExecutableInfoKHR* pExecutableInfo, uint32_t* pInternalRepresentationCount, VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutablePropertiesKHR( + VkDevice device, + const VkPipelineInfoKHR* pPipelineInfo, + uint32_t* pExecutableCount, + VkPipelineExecutablePropertiesKHR* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableStatisticsKHR( + VkDevice device, + const VkPipelineExecutableInfoKHR* pExecutableInfo, + uint32_t* pStatisticCount, + VkPipelineExecutableStatisticKHR* pStatistics); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelineExecutableInternalRepresentationsKHR( + VkDevice device, + const VkPipelineExecutableInfoKHR* pExecutableInfo, + uint32_t* pInternalRepresentationCount, + VkPipelineExecutableInternalRepresentationKHR* pInternalRepresentations); +#endif + + +// VK_KHR_map_memory2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_map_memory2 1 +#define VK_KHR_MAP_MEMORY_2_SPEC_VERSION 1 +#define VK_KHR_MAP_MEMORY_2_EXTENSION_NAME "VK_KHR_map_memory2" + +typedef enum VkMemoryUnmapFlagBitsKHR { + VK_MEMORY_UNMAP_RESERVE_BIT_EXT = 0x00000001, + VK_MEMORY_UNMAP_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkMemoryUnmapFlagBitsKHR; +typedef VkFlags VkMemoryUnmapFlagsKHR; +typedef struct VkMemoryMapInfoKHR { + VkStructureType sType; + const void* pNext; + VkMemoryMapFlags flags; + VkDeviceMemory memory; + VkDeviceSize offset; + VkDeviceSize size; +} VkMemoryMapInfoKHR; + +typedef struct VkMemoryUnmapInfoKHR { + VkStructureType sType; + const void* pNext; + VkMemoryUnmapFlagsKHR flags; + VkDeviceMemory memory; +} VkMemoryUnmapInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkMapMemory2KHR)(VkDevice device, const VkMemoryMapInfoKHR* pMemoryMapInfo, void** ppData); +typedef VkResult (VKAPI_PTR *PFN_vkUnmapMemory2KHR)(VkDevice device, const VkMemoryUnmapInfoKHR* pMemoryUnmapInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkMapMemory2KHR( + VkDevice device, + const VkMemoryMapInfoKHR* pMemoryMapInfo, + void** ppData); + +VKAPI_ATTR VkResult VKAPI_CALL vkUnmapMemory2KHR( + VkDevice device, + const VkMemoryUnmapInfoKHR* pMemoryUnmapInfo); +#endif + + +// VK_KHR_shader_integer_dot_product is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_integer_dot_product 1 +#define VK_KHR_SHADER_INTEGER_DOT_PRODUCT_SPEC_VERSION 1 +#define VK_KHR_SHADER_INTEGER_DOT_PRODUCT_EXTENSION_NAME "VK_KHR_shader_integer_dot_product" +typedef VkPhysicalDeviceShaderIntegerDotProductFeatures VkPhysicalDeviceShaderIntegerDotProductFeaturesKHR; + +typedef VkPhysicalDeviceShaderIntegerDotProductProperties VkPhysicalDeviceShaderIntegerDotProductPropertiesKHR; + + + +// VK_KHR_pipeline_library is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_pipeline_library 1 +#define VK_KHR_PIPELINE_LIBRARY_SPEC_VERSION 1 +#define VK_KHR_PIPELINE_LIBRARY_EXTENSION_NAME "VK_KHR_pipeline_library" +typedef struct VkPipelineLibraryCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t libraryCount; + const VkPipeline* pLibraries; +} VkPipelineLibraryCreateInfoKHR; + + + +// VK_KHR_shader_non_semantic_info is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_non_semantic_info 1 +#define VK_KHR_SHADER_NON_SEMANTIC_INFO_SPEC_VERSION 1 +#define VK_KHR_SHADER_NON_SEMANTIC_INFO_EXTENSION_NAME "VK_KHR_shader_non_semantic_info" + + +// VK_KHR_present_id is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_present_id 1 +#define VK_KHR_PRESENT_ID_SPEC_VERSION 1 +#define VK_KHR_PRESENT_ID_EXTENSION_NAME "VK_KHR_present_id" +typedef struct VkPresentIdKHR { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const uint64_t* pPresentIds; +} VkPresentIdKHR; + +typedef struct VkPhysicalDevicePresentIdFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 presentId; +} VkPhysicalDevicePresentIdFeaturesKHR; + + + +// VK_KHR_video_encode_queue is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_encode_queue 1 +#define VK_KHR_VIDEO_ENCODE_QUEUE_SPEC_VERSION 12 +#define VK_KHR_VIDEO_ENCODE_QUEUE_EXTENSION_NAME "VK_KHR_video_encode_queue" + +typedef enum VkVideoEncodeTuningModeKHR { + VK_VIDEO_ENCODE_TUNING_MODE_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_TUNING_MODE_HIGH_QUALITY_KHR = 1, + VK_VIDEO_ENCODE_TUNING_MODE_LOW_LATENCY_KHR = 2, + VK_VIDEO_ENCODE_TUNING_MODE_ULTRA_LOW_LATENCY_KHR = 3, + VK_VIDEO_ENCODE_TUNING_MODE_LOSSLESS_KHR = 4, + VK_VIDEO_ENCODE_TUNING_MODE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeTuningModeKHR; + +typedef enum VkVideoEncodeFlagBitsKHR { + VK_VIDEO_ENCODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeFlagBitsKHR; +typedef VkFlags VkVideoEncodeFlagsKHR; + +typedef enum VkVideoEncodeCapabilityFlagBitsKHR { + VK_VIDEO_ENCODE_CAPABILITY_PRECEDING_EXTERNALLY_ENCODED_BYTES_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_CAPABILITY_INSUFFICIENT_BITSTREAM_BUFFER_RANGE_DETECTION_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_CAPABILITY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeCapabilityFlagBitsKHR; +typedef VkFlags VkVideoEncodeCapabilityFlagsKHR; + +typedef enum VkVideoEncodeRateControlModeFlagBitsKHR { + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_DISABLED_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_CBR_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_VBR_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_RATE_CONTROL_MODE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeRateControlModeFlagBitsKHR; +typedef VkFlags VkVideoEncodeRateControlModeFlagsKHR; + +typedef enum VkVideoEncodeFeedbackFlagBitsKHR { + VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BUFFER_OFFSET_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_BYTES_WRITTEN_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_FEEDBACK_BITSTREAM_HAS_OVERRIDES_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_FEEDBACK_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeFeedbackFlagBitsKHR; +typedef VkFlags VkVideoEncodeFeedbackFlagsKHR; + +typedef enum VkVideoEncodeUsageFlagBitsKHR { + VK_VIDEO_ENCODE_USAGE_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_USAGE_TRANSCODING_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_USAGE_STREAMING_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_USAGE_RECORDING_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_USAGE_CONFERENCING_BIT_KHR = 0x00000008, + VK_VIDEO_ENCODE_USAGE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeUsageFlagBitsKHR; +typedef VkFlags VkVideoEncodeUsageFlagsKHR; + +typedef enum VkVideoEncodeContentFlagBitsKHR { + VK_VIDEO_ENCODE_CONTENT_DEFAULT_KHR = 0, + VK_VIDEO_ENCODE_CONTENT_CAMERA_BIT_KHR = 0x00000001, + VK_VIDEO_ENCODE_CONTENT_DESKTOP_BIT_KHR = 0x00000002, + VK_VIDEO_ENCODE_CONTENT_RENDERED_BIT_KHR = 0x00000004, + VK_VIDEO_ENCODE_CONTENT_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkVideoEncodeContentFlagBitsKHR; +typedef VkFlags VkVideoEncodeContentFlagsKHR; +typedef VkFlags VkVideoEncodeRateControlFlagsKHR; +typedef struct VkVideoEncodeInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeFlagsKHR flags; + VkBuffer dstBuffer; + VkDeviceSize dstBufferOffset; + VkDeviceSize dstBufferRange; + VkVideoPictureResourceInfoKHR srcPictureResource; + const VkVideoReferenceSlotInfoKHR* pSetupReferenceSlot; + uint32_t referenceSlotCount; + const VkVideoReferenceSlotInfoKHR* pReferenceSlots; + uint32_t precedingExternallyEncodedBytes; +} VkVideoEncodeInfoKHR; + +typedef struct VkVideoEncodeCapabilitiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeCapabilityFlagsKHR flags; + VkVideoEncodeRateControlModeFlagsKHR rateControlModes; + uint32_t maxRateControlLayers; + uint64_t maxBitrate; + uint32_t maxQualityLevels; + VkExtent2D encodeInputPictureGranularity; + VkVideoEncodeFeedbackFlagsKHR supportedEncodeFeedbackFlags; +} VkVideoEncodeCapabilitiesKHR; + +typedef struct VkQueryPoolVideoEncodeFeedbackCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeFeedbackFlagsKHR encodeFeedbackFlags; +} VkQueryPoolVideoEncodeFeedbackCreateInfoKHR; + +typedef struct VkVideoEncodeUsageInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeUsageFlagsKHR videoUsageHints; + VkVideoEncodeContentFlagsKHR videoContentHints; + VkVideoEncodeTuningModeKHR tuningMode; +} VkVideoEncodeUsageInfoKHR; + +typedef struct VkVideoEncodeRateControlLayerInfoKHR { + VkStructureType sType; + const void* pNext; + uint64_t averageBitrate; + uint64_t maxBitrate; + uint32_t frameRateNumerator; + uint32_t frameRateDenominator; +} VkVideoEncodeRateControlLayerInfoKHR; + +typedef struct VkVideoEncodeRateControlInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoEncodeRateControlFlagsKHR flags; + VkVideoEncodeRateControlModeFlagBitsKHR rateControlMode; + uint32_t layerCount; + const VkVideoEncodeRateControlLayerInfoKHR* pLayers; + uint32_t virtualBufferSizeInMs; + uint32_t initialVirtualBufferSizeInMs; +} VkVideoEncodeRateControlInfoKHR; + +typedef struct VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR { + VkStructureType sType; + const void* pNext; + const VkVideoProfileInfoKHR* pVideoProfile; + uint32_t qualityLevel; +} VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR; + +typedef struct VkVideoEncodeQualityLevelPropertiesKHR { + VkStructureType sType; + void* pNext; + VkVideoEncodeRateControlModeFlagBitsKHR preferredRateControlMode; + uint32_t preferredRateControlLayerCount; +} VkVideoEncodeQualityLevelPropertiesKHR; + +typedef struct VkVideoEncodeQualityLevelInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t qualityLevel; +} VkVideoEncodeQualityLevelInfoKHR; + +typedef struct VkVideoEncodeSessionParametersGetInfoKHR { + VkStructureType sType; + const void* pNext; + VkVideoSessionParametersKHR videoSessionParameters; +} VkVideoEncodeSessionParametersGetInfoKHR; + +typedef struct VkVideoEncodeSessionParametersFeedbackInfoKHR { + VkStructureType sType; + void* pNext; + VkBool32 hasOverrides; +} VkVideoEncodeSessionParametersFeedbackInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR* pQualityLevelInfo, VkVideoEncodeQualityLevelPropertiesKHR* pQualityLevelProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetEncodedVideoSessionParametersKHR)(VkDevice device, const VkVideoEncodeSessionParametersGetInfoKHR* pVideoSessionParametersInfo, VkVideoEncodeSessionParametersFeedbackInfoKHR* pFeedbackInfo, size_t* pDataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdEncodeVideoKHR)(VkCommandBuffer commandBuffer, const VkVideoEncodeInfoKHR* pEncodeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceVideoEncodeQualityLevelPropertiesKHR( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceVideoEncodeQualityLevelInfoKHR* pQualityLevelInfo, + VkVideoEncodeQualityLevelPropertiesKHR* pQualityLevelProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetEncodedVideoSessionParametersKHR( + VkDevice device, + const VkVideoEncodeSessionParametersGetInfoKHR* pVideoSessionParametersInfo, + VkVideoEncodeSessionParametersFeedbackInfoKHR* pFeedbackInfo, + size_t* pDataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdEncodeVideoKHR( + VkCommandBuffer commandBuffer, + const VkVideoEncodeInfoKHR* pEncodeInfo); +#endif + + +// VK_KHR_synchronization2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_synchronization2 1 +#define VK_KHR_SYNCHRONIZATION_2_SPEC_VERSION 1 +#define VK_KHR_SYNCHRONIZATION_2_EXTENSION_NAME "VK_KHR_synchronization2" +typedef VkPipelineStageFlags2 VkPipelineStageFlags2KHR; + +typedef VkPipelineStageFlagBits2 VkPipelineStageFlagBits2KHR; + +typedef VkAccessFlags2 VkAccessFlags2KHR; + +typedef VkAccessFlagBits2 VkAccessFlagBits2KHR; + +typedef VkSubmitFlagBits VkSubmitFlagBitsKHR; + +typedef VkSubmitFlags VkSubmitFlagsKHR; + +typedef VkMemoryBarrier2 VkMemoryBarrier2KHR; + +typedef VkBufferMemoryBarrier2 VkBufferMemoryBarrier2KHR; + +typedef VkImageMemoryBarrier2 VkImageMemoryBarrier2KHR; + +typedef VkDependencyInfo VkDependencyInfoKHR; + +typedef VkSubmitInfo2 VkSubmitInfo2KHR; + +typedef VkSemaphoreSubmitInfo VkSemaphoreSubmitInfoKHR; + +typedef VkCommandBufferSubmitInfo VkCommandBufferSubmitInfoKHR; + +typedef VkPhysicalDeviceSynchronization2Features VkPhysicalDeviceSynchronization2FeaturesKHR; + +typedef struct VkQueueFamilyCheckpointProperties2NV { + VkStructureType sType; + void* pNext; + VkPipelineStageFlags2 checkpointExecutionStageMask; +} VkQueueFamilyCheckpointProperties2NV; + +typedef struct VkCheckpointData2NV { + VkStructureType sType; + void* pNext; + VkPipelineStageFlags2 stage; + void* pCheckpointMarker; +} VkCheckpointData2NV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetEvent2KHR)(VkCommandBuffer commandBuffer, VkEvent event, const VkDependencyInfo* pDependencyInfo); +typedef void (VKAPI_PTR *PFN_vkCmdResetEvent2KHR)(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags2 stageMask); +typedef void (VKAPI_PTR *PFN_vkCmdWaitEvents2KHR)(VkCommandBuffer commandBuffer, uint32_t eventCount, const VkEvent* pEvents, const VkDependencyInfo* pDependencyInfos); +typedef void (VKAPI_PTR *PFN_vkCmdPipelineBarrier2KHR)(VkCommandBuffer commandBuffer, const VkDependencyInfo* pDependencyInfo); +typedef void (VKAPI_PTR *PFN_vkCmdWriteTimestamp2KHR)(VkCommandBuffer commandBuffer, VkPipelineStageFlags2 stage, VkQueryPool queryPool, uint32_t query); +typedef VkResult (VKAPI_PTR *PFN_vkQueueSubmit2KHR)(VkQueue queue, uint32_t submitCount, const VkSubmitInfo2* pSubmits, VkFence fence); +typedef void (VKAPI_PTR *PFN_vkCmdWriteBufferMarker2AMD)(VkCommandBuffer commandBuffer, VkPipelineStageFlags2 stage, VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker); +typedef void (VKAPI_PTR *PFN_vkGetQueueCheckpointData2NV)(VkQueue queue, uint32_t* pCheckpointDataCount, VkCheckpointData2NV* pCheckpointData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetEvent2KHR( + VkCommandBuffer commandBuffer, + VkEvent event, + const VkDependencyInfo* pDependencyInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdResetEvent2KHR( + VkCommandBuffer commandBuffer, + VkEvent event, + VkPipelineStageFlags2 stageMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdWaitEvents2KHR( + VkCommandBuffer commandBuffer, + uint32_t eventCount, + const VkEvent* pEvents, + const VkDependencyInfo* pDependencyInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdPipelineBarrier2KHR( + VkCommandBuffer commandBuffer, + const VkDependencyInfo* pDependencyInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteTimestamp2KHR( + VkCommandBuffer commandBuffer, + VkPipelineStageFlags2 stage, + VkQueryPool queryPool, + uint32_t query); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueSubmit2KHR( + VkQueue queue, + uint32_t submitCount, + const VkSubmitInfo2* pSubmits, + VkFence fence); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteBufferMarker2AMD( + VkCommandBuffer commandBuffer, + VkPipelineStageFlags2 stage, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + uint32_t marker); + +VKAPI_ATTR void VKAPI_CALL vkGetQueueCheckpointData2NV( + VkQueue queue, + uint32_t* pCheckpointDataCount, + VkCheckpointData2NV* pCheckpointData); +#endif + + +// VK_KHR_fragment_shader_barycentric is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_fragment_shader_barycentric 1 +#define VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION 1 +#define VK_KHR_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME "VK_KHR_fragment_shader_barycentric" +typedef struct VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 fragmentShaderBarycentric; +} VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR; + +typedef struct VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 triStripVertexOrderIndependentOfProvokingVertex; +} VkPhysicalDeviceFragmentShaderBarycentricPropertiesKHR; + + + +// VK_KHR_shader_subgroup_uniform_control_flow is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_subgroup_uniform_control_flow 1 +#define VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_SPEC_VERSION 1 +#define VK_KHR_SHADER_SUBGROUP_UNIFORM_CONTROL_FLOW_EXTENSION_NAME "VK_KHR_shader_subgroup_uniform_control_flow" +typedef struct VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderSubgroupUniformControlFlow; +} VkPhysicalDeviceShaderSubgroupUniformControlFlowFeaturesKHR; + + + +// VK_KHR_zero_initialize_workgroup_memory is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_zero_initialize_workgroup_memory 1 +#define VK_KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_SPEC_VERSION 1 +#define VK_KHR_ZERO_INITIALIZE_WORKGROUP_MEMORY_EXTENSION_NAME "VK_KHR_zero_initialize_workgroup_memory" +typedef VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeatures VkPhysicalDeviceZeroInitializeWorkgroupMemoryFeaturesKHR; + + + +// VK_KHR_workgroup_memory_explicit_layout is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_workgroup_memory_explicit_layout 1 +#define VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_SPEC_VERSION 1 +#define VK_KHR_WORKGROUP_MEMORY_EXPLICIT_LAYOUT_EXTENSION_NAME "VK_KHR_workgroup_memory_explicit_layout" +typedef struct VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 workgroupMemoryExplicitLayout; + VkBool32 workgroupMemoryExplicitLayoutScalarBlockLayout; + VkBool32 workgroupMemoryExplicitLayout8BitAccess; + VkBool32 workgroupMemoryExplicitLayout16BitAccess; +} VkPhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR; + + + +// VK_KHR_copy_commands2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_copy_commands2 1 +#define VK_KHR_COPY_COMMANDS_2_SPEC_VERSION 1 +#define VK_KHR_COPY_COMMANDS_2_EXTENSION_NAME "VK_KHR_copy_commands2" +typedef VkCopyBufferInfo2 VkCopyBufferInfo2KHR; + +typedef VkCopyImageInfo2 VkCopyImageInfo2KHR; + +typedef VkCopyBufferToImageInfo2 VkCopyBufferToImageInfo2KHR; + +typedef VkCopyImageToBufferInfo2 VkCopyImageToBufferInfo2KHR; + +typedef VkBlitImageInfo2 VkBlitImageInfo2KHR; + +typedef VkResolveImageInfo2 VkResolveImageInfo2KHR; + +typedef VkBufferCopy2 VkBufferCopy2KHR; + +typedef VkImageCopy2 VkImageCopy2KHR; + +typedef VkImageBlit2 VkImageBlit2KHR; + +typedef VkBufferImageCopy2 VkBufferImageCopy2KHR; + +typedef VkImageResolve2 VkImageResolve2KHR; + +typedef void (VKAPI_PTR *PFN_vkCmdCopyBuffer2KHR)(VkCommandBuffer commandBuffer, const VkCopyBufferInfo2* pCopyBufferInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImage2KHR)(VkCommandBuffer commandBuffer, const VkCopyImageInfo2* pCopyImageInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyBufferToImage2KHR)(VkCommandBuffer commandBuffer, const VkCopyBufferToImageInfo2* pCopyBufferToImageInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyImageToBuffer2KHR)(VkCommandBuffer commandBuffer, const VkCopyImageToBufferInfo2* pCopyImageToBufferInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBlitImage2KHR)(VkCommandBuffer commandBuffer, const VkBlitImageInfo2* pBlitImageInfo); +typedef void (VKAPI_PTR *PFN_vkCmdResolveImage2KHR)(VkCommandBuffer commandBuffer, const VkResolveImageInfo2* pResolveImageInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBuffer2KHR( + VkCommandBuffer commandBuffer, + const VkCopyBufferInfo2* pCopyBufferInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImage2KHR( + VkCommandBuffer commandBuffer, + const VkCopyImageInfo2* pCopyImageInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyBufferToImage2KHR( + VkCommandBuffer commandBuffer, + const VkCopyBufferToImageInfo2* pCopyBufferToImageInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyImageToBuffer2KHR( + VkCommandBuffer commandBuffer, + const VkCopyImageToBufferInfo2* pCopyImageToBufferInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBlitImage2KHR( + VkCommandBuffer commandBuffer, + const VkBlitImageInfo2* pBlitImageInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdResolveImage2KHR( + VkCommandBuffer commandBuffer, + const VkResolveImageInfo2* pResolveImageInfo); +#endif + + +// VK_KHR_format_feature_flags2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_format_feature_flags2 1 +#define VK_KHR_FORMAT_FEATURE_FLAGS_2_SPEC_VERSION 2 +#define VK_KHR_FORMAT_FEATURE_FLAGS_2_EXTENSION_NAME "VK_KHR_format_feature_flags2" +typedef VkFormatFeatureFlags2 VkFormatFeatureFlags2KHR; + +typedef VkFormatFeatureFlagBits2 VkFormatFeatureFlagBits2KHR; + +typedef VkFormatProperties3 VkFormatProperties3KHR; + + + +// VK_KHR_ray_tracing_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_ray_tracing_maintenance1 1 +#define VK_KHR_RAY_TRACING_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_KHR_RAY_TRACING_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_ray_tracing_maintenance1" +typedef struct VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingMaintenance1; + VkBool32 rayTracingPipelineTraceRaysIndirect2; +} VkPhysicalDeviceRayTracingMaintenance1FeaturesKHR; + +typedef struct VkTraceRaysIndirectCommand2KHR { + VkDeviceAddress raygenShaderRecordAddress; + VkDeviceSize raygenShaderRecordSize; + VkDeviceAddress missShaderBindingTableAddress; + VkDeviceSize missShaderBindingTableSize; + VkDeviceSize missShaderBindingTableStride; + VkDeviceAddress hitShaderBindingTableAddress; + VkDeviceSize hitShaderBindingTableSize; + VkDeviceSize hitShaderBindingTableStride; + VkDeviceAddress callableShaderBindingTableAddress; + VkDeviceSize callableShaderBindingTableSize; + VkDeviceSize callableShaderBindingTableStride; + uint32_t width; + uint32_t height; + uint32_t depth; +} VkTraceRaysIndirectCommand2KHR; + +typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysIndirect2KHR)(VkCommandBuffer commandBuffer, VkDeviceAddress indirectDeviceAddress); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysIndirect2KHR( + VkCommandBuffer commandBuffer, + VkDeviceAddress indirectDeviceAddress); +#endif + + +// VK_KHR_portability_enumeration is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_portability_enumeration 1 +#define VK_KHR_PORTABILITY_ENUMERATION_SPEC_VERSION 1 +#define VK_KHR_PORTABILITY_ENUMERATION_EXTENSION_NAME "VK_KHR_portability_enumeration" + + +// VK_KHR_maintenance4 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance4 1 +#define VK_KHR_MAINTENANCE_4_SPEC_VERSION 2 +#define VK_KHR_MAINTENANCE_4_EXTENSION_NAME "VK_KHR_maintenance4" +typedef VkPhysicalDeviceMaintenance4Features VkPhysicalDeviceMaintenance4FeaturesKHR; + +typedef VkPhysicalDeviceMaintenance4Properties VkPhysicalDeviceMaintenance4PropertiesKHR; + +typedef VkDeviceBufferMemoryRequirements VkDeviceBufferMemoryRequirementsKHR; + +typedef VkDeviceImageMemoryRequirements VkDeviceImageMemoryRequirementsKHR; + +typedef void (VKAPI_PTR *PFN_vkGetDeviceBufferMemoryRequirementsKHR)(VkDevice device, const VkDeviceBufferMemoryRequirements* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetDeviceImageMemoryRequirementsKHR)(VkDevice device, const VkDeviceImageMemoryRequirements* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkGetDeviceImageSparseMemoryRequirementsKHR)(VkDevice device, const VkDeviceImageMemoryRequirements* pInfo, uint32_t* pSparseMemoryRequirementCount, VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDeviceBufferMemoryRequirementsKHR( + VkDevice device, + const VkDeviceBufferMemoryRequirements* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageMemoryRequirementsKHR( + VkDevice device, + const VkDeviceImageMemoryRequirements* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSparseMemoryRequirementsKHR( + VkDevice device, + const VkDeviceImageMemoryRequirements* pInfo, + uint32_t* pSparseMemoryRequirementCount, + VkSparseImageMemoryRequirements2* pSparseMemoryRequirements); +#endif + + +// VK_KHR_shader_subgroup_rotate is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_subgroup_rotate 1 +#define VK_KHR_SHADER_SUBGROUP_ROTATE_SPEC_VERSION 2 +#define VK_KHR_SHADER_SUBGROUP_ROTATE_EXTENSION_NAME "VK_KHR_shader_subgroup_rotate" +typedef struct VkPhysicalDeviceShaderSubgroupRotateFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderSubgroupRotate; + VkBool32 shaderSubgroupRotateClustered; +} VkPhysicalDeviceShaderSubgroupRotateFeaturesKHR; + + + +// VK_KHR_shader_maximal_reconvergence is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_maximal_reconvergence 1 +#define VK_KHR_SHADER_MAXIMAL_RECONVERGENCE_SPEC_VERSION 1 +#define VK_KHR_SHADER_MAXIMAL_RECONVERGENCE_EXTENSION_NAME "VK_KHR_shader_maximal_reconvergence" +typedef struct VkPhysicalDeviceShaderMaximalReconvergenceFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderMaximalReconvergence; +} VkPhysicalDeviceShaderMaximalReconvergenceFeaturesKHR; + + + +// VK_KHR_maintenance5 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance5 1 +#define VK_KHR_MAINTENANCE_5_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE_5_EXTENSION_NAME "VK_KHR_maintenance5" +typedef VkFlags64 VkPipelineCreateFlags2KHR; + +// Flag bits for VkPipelineCreateFlagBits2KHR +typedef VkFlags64 VkPipelineCreateFlagBits2KHR; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DISABLE_OPTIMIZATION_BIT_KHR = 0x00000001ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_ALLOW_DERIVATIVES_BIT_KHR = 0x00000002ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DERIVATIVE_BIT_KHR = 0x00000004ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_VIEW_INDEX_FROM_DEVICE_INDEX_BIT_KHR = 0x00000008ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DISPATCH_BASE_BIT_KHR = 0x00000010ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DEFER_COMPILE_BIT_NV = 0x00000020ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_CAPTURE_STATISTICS_BIT_KHR = 0x00000040ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_CAPTURE_INTERNAL_REPRESENTATIONS_BIT_KHR = 0x00000080ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_KHR = 0x00000100ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_EARLY_RETURN_ON_FAILURE_BIT_KHR = 0x00000200ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_LINK_TIME_OPTIMIZATION_BIT_EXT = 0x00000400ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RETAIN_LINK_TIME_OPTIMIZATION_INFO_BIT_EXT = 0x00800000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_LIBRARY_BIT_KHR = 0x00000800ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR = 0x00001000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_SKIP_AABBS_BIT_KHR = 0x00002000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR = 0x00004000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR = 0x00008000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR = 0x00010000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR = 0x00020000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR = 0x00080000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_INDIRECT_BINDABLE_BIT_NV = 0x00040000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_ALLOW_MOTION_BIT_NV = 0x00100000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RENDERING_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_KHR = 0x00200000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RENDERING_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = 0x00400000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_OPACITY_MICROMAP_BIT_EXT = 0x01000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_COLOR_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x02000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DEPTH_STENCIL_ATTACHMENT_FEEDBACK_LOOP_BIT_EXT = 0x04000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_NO_PROTECTED_ACCESS_BIT_EXT = 0x08000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_PROTECTED_ACCESS_ONLY_BIT_EXT = 0x40000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_RAY_TRACING_DISPLACEMENT_MICROMAP_BIT_NV = 0x10000000ULL; +static const VkPipelineCreateFlagBits2KHR VK_PIPELINE_CREATE_2_DESCRIPTOR_BUFFER_BIT_EXT = 0x20000000ULL; + +typedef VkFlags64 VkBufferUsageFlags2KHR; + +// Flag bits for VkBufferUsageFlagBits2KHR +typedef VkFlags64 VkBufferUsageFlagBits2KHR; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFER_SRC_BIT_KHR = 0x00000001ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFER_DST_BIT_KHR = 0x00000002ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_UNIFORM_TEXEL_BUFFER_BIT_KHR = 0x00000004ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_STORAGE_TEXEL_BUFFER_BIT_KHR = 0x00000008ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_UNIFORM_BUFFER_BIT_KHR = 0x00000010ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_STORAGE_BUFFER_BIT_KHR = 0x00000020ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_INDEX_BUFFER_BIT_KHR = 0x00000040ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VERTEX_BUFFER_BIT_KHR = 0x00000080ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_INDIRECT_BUFFER_BIT_KHR = 0x00000100ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_EXECUTION_GRAPH_SCRATCH_BIT_AMDX = 0x02000000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_CONDITIONAL_RENDERING_BIT_EXT = 0x00000200ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_SHADER_BINDING_TABLE_BIT_KHR = 0x00000400ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_RAY_TRACING_BIT_NV = 0x00000400ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT = 0x00000800ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT = 0x00001000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_DECODE_SRC_BIT_KHR = 0x00002000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_DECODE_DST_BIT_KHR = 0x00004000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_ENCODE_DST_BIT_KHR = 0x00008000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_VIDEO_ENCODE_SRC_BIT_KHR = 0x00010000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_SHADER_DEVICE_ADDRESS_BIT_KHR = 0x00020000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR = 0x00080000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR = 0x00100000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT = 0x00200000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_RESOURCE_DESCRIPTOR_BUFFER_BIT_EXT = 0x00400000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_PUSH_DESCRIPTORS_DESCRIPTOR_BUFFER_BIT_EXT = 0x04000000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_MICROMAP_BUILD_INPUT_READ_ONLY_BIT_EXT = 0x00800000ULL; +static const VkBufferUsageFlagBits2KHR VK_BUFFER_USAGE_2_MICROMAP_STORAGE_BIT_EXT = 0x01000000ULL; + +typedef struct VkPhysicalDeviceMaintenance5FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 maintenance5; +} VkPhysicalDeviceMaintenance5FeaturesKHR; + +typedef struct VkPhysicalDeviceMaintenance5PropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 earlyFragmentMultisampleCoverageAfterSampleCounting; + VkBool32 earlyFragmentSampleMaskTestBeforeSampleCounting; + VkBool32 depthStencilSwizzleOneSupport; + VkBool32 polygonModePointSize; + VkBool32 nonStrictSinglePixelWideLinesUseParallelogram; + VkBool32 nonStrictWideLinesUseParallelogram; +} VkPhysicalDeviceMaintenance5PropertiesKHR; + +typedef struct VkRenderingAreaInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t viewMask; + uint32_t colorAttachmentCount; + const VkFormat* pColorAttachmentFormats; + VkFormat depthAttachmentFormat; + VkFormat stencilAttachmentFormat; +} VkRenderingAreaInfoKHR; + +typedef struct VkImageSubresource2KHR { + VkStructureType sType; + void* pNext; + VkImageSubresource imageSubresource; +} VkImageSubresource2KHR; + +typedef struct VkDeviceImageSubresourceInfoKHR { + VkStructureType sType; + const void* pNext; + const VkImageCreateInfo* pCreateInfo; + const VkImageSubresource2KHR* pSubresource; +} VkDeviceImageSubresourceInfoKHR; + +typedef struct VkSubresourceLayout2KHR { + VkStructureType sType; + void* pNext; + VkSubresourceLayout subresourceLayout; +} VkSubresourceLayout2KHR; + +typedef struct VkPipelineCreateFlags2CreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags2KHR flags; +} VkPipelineCreateFlags2CreateInfoKHR; + +typedef struct VkBufferUsageFlags2CreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkBufferUsageFlags2KHR usage; +} VkBufferUsageFlags2CreateInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdBindIndexBuffer2KHR)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkDeviceSize size, VkIndexType indexType); +typedef void (VKAPI_PTR *PFN_vkGetRenderingAreaGranularityKHR)(VkDevice device, const VkRenderingAreaInfoKHR* pRenderingAreaInfo, VkExtent2D* pGranularity); +typedef void (VKAPI_PTR *PFN_vkGetDeviceImageSubresourceLayoutKHR)(VkDevice device, const VkDeviceImageSubresourceInfoKHR* pInfo, VkSubresourceLayout2KHR* pLayout); +typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout2KHR)(VkDevice device, VkImage image, const VkImageSubresource2KHR* pSubresource, VkSubresourceLayout2KHR* pLayout); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindIndexBuffer2KHR( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkDeviceSize size, + VkIndexType indexType); + +VKAPI_ATTR void VKAPI_CALL vkGetRenderingAreaGranularityKHR( + VkDevice device, + const VkRenderingAreaInfoKHR* pRenderingAreaInfo, + VkExtent2D* pGranularity); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceImageSubresourceLayoutKHR( + VkDevice device, + const VkDeviceImageSubresourceInfoKHR* pInfo, + VkSubresourceLayout2KHR* pLayout); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout2KHR( + VkDevice device, + VkImage image, + const VkImageSubresource2KHR* pSubresource, + VkSubresourceLayout2KHR* pLayout); +#endif + + +// VK_KHR_ray_tracing_position_fetch is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_ray_tracing_position_fetch 1 +#define VK_KHR_RAY_TRACING_POSITION_FETCH_SPEC_VERSION 1 +#define VK_KHR_RAY_TRACING_POSITION_FETCH_EXTENSION_NAME "VK_KHR_ray_tracing_position_fetch" +typedef struct VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingPositionFetch; +} VkPhysicalDeviceRayTracingPositionFetchFeaturesKHR; + + + +// VK_KHR_cooperative_matrix is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_cooperative_matrix 1 +#define VK_KHR_COOPERATIVE_MATRIX_SPEC_VERSION 2 +#define VK_KHR_COOPERATIVE_MATRIX_EXTENSION_NAME "VK_KHR_cooperative_matrix" + +typedef enum VkComponentTypeKHR { + VK_COMPONENT_TYPE_FLOAT16_KHR = 0, + VK_COMPONENT_TYPE_FLOAT32_KHR = 1, + VK_COMPONENT_TYPE_FLOAT64_KHR = 2, + VK_COMPONENT_TYPE_SINT8_KHR = 3, + VK_COMPONENT_TYPE_SINT16_KHR = 4, + VK_COMPONENT_TYPE_SINT32_KHR = 5, + VK_COMPONENT_TYPE_SINT64_KHR = 6, + VK_COMPONENT_TYPE_UINT8_KHR = 7, + VK_COMPONENT_TYPE_UINT16_KHR = 8, + VK_COMPONENT_TYPE_UINT32_KHR = 9, + VK_COMPONENT_TYPE_UINT64_KHR = 10, + VK_COMPONENT_TYPE_FLOAT16_NV = VK_COMPONENT_TYPE_FLOAT16_KHR, + VK_COMPONENT_TYPE_FLOAT32_NV = VK_COMPONENT_TYPE_FLOAT32_KHR, + VK_COMPONENT_TYPE_FLOAT64_NV = VK_COMPONENT_TYPE_FLOAT64_KHR, + VK_COMPONENT_TYPE_SINT8_NV = VK_COMPONENT_TYPE_SINT8_KHR, + VK_COMPONENT_TYPE_SINT16_NV = VK_COMPONENT_TYPE_SINT16_KHR, + VK_COMPONENT_TYPE_SINT32_NV = VK_COMPONENT_TYPE_SINT32_KHR, + VK_COMPONENT_TYPE_SINT64_NV = VK_COMPONENT_TYPE_SINT64_KHR, + VK_COMPONENT_TYPE_UINT8_NV = VK_COMPONENT_TYPE_UINT8_KHR, + VK_COMPONENT_TYPE_UINT16_NV = VK_COMPONENT_TYPE_UINT16_KHR, + VK_COMPONENT_TYPE_UINT32_NV = VK_COMPONENT_TYPE_UINT32_KHR, + VK_COMPONENT_TYPE_UINT64_NV = VK_COMPONENT_TYPE_UINT64_KHR, + VK_COMPONENT_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkComponentTypeKHR; + +typedef enum VkScopeKHR { + VK_SCOPE_DEVICE_KHR = 1, + VK_SCOPE_WORKGROUP_KHR = 2, + VK_SCOPE_SUBGROUP_KHR = 3, + VK_SCOPE_QUEUE_FAMILY_KHR = 5, + VK_SCOPE_DEVICE_NV = VK_SCOPE_DEVICE_KHR, + VK_SCOPE_WORKGROUP_NV = VK_SCOPE_WORKGROUP_KHR, + VK_SCOPE_SUBGROUP_NV = VK_SCOPE_SUBGROUP_KHR, + VK_SCOPE_QUEUE_FAMILY_NV = VK_SCOPE_QUEUE_FAMILY_KHR, + VK_SCOPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkScopeKHR; +typedef struct VkCooperativeMatrixPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t MSize; + uint32_t NSize; + uint32_t KSize; + VkComponentTypeKHR AType; + VkComponentTypeKHR BType; + VkComponentTypeKHR CType; + VkComponentTypeKHR ResultType; + VkBool32 saturatingAccumulation; + VkScopeKHR scope; +} VkCooperativeMatrixPropertiesKHR; + +typedef struct VkPhysicalDeviceCooperativeMatrixFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 cooperativeMatrix; + VkBool32 cooperativeMatrixRobustBufferAccess; +} VkPhysicalDeviceCooperativeMatrixFeaturesKHR; + +typedef struct VkPhysicalDeviceCooperativeMatrixPropertiesKHR { + VkStructureType sType; + void* pNext; + VkShaderStageFlags cooperativeMatrixSupportedStages; +} VkPhysicalDeviceCooperativeMatrixPropertiesKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkCooperativeMatrixPropertiesKHR* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCooperativeMatrixPropertiesKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkCooperativeMatrixPropertiesKHR* pProperties); +#endif + + +// VK_KHR_video_decode_av1 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_decode_av1 1 +#include "../vk_video/vulkan_video_codec_av1std.h" +#include "../vk_video/vulkan_video_codec_av1std_decode.h" +#define VK_MAX_VIDEO_AV1_REFERENCES_PER_FRAME_KHR 7U +#define VK_KHR_VIDEO_DECODE_AV1_SPEC_VERSION 1 +#define VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME "VK_KHR_video_decode_av1" +typedef struct VkVideoDecodeAV1ProfileInfoKHR { + VkStructureType sType; + const void* pNext; + StdVideoAV1Profile stdProfile; + VkBool32 filmGrainSupport; +} VkVideoDecodeAV1ProfileInfoKHR; + +typedef struct VkVideoDecodeAV1CapabilitiesKHR { + VkStructureType sType; + void* pNext; + StdVideoAV1Level maxLevel; +} VkVideoDecodeAV1CapabilitiesKHR; + +typedef struct VkVideoDecodeAV1SessionParametersCreateInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoAV1SequenceHeader* pStdSequenceHeader; +} VkVideoDecodeAV1SessionParametersCreateInfoKHR; + +typedef struct VkVideoDecodeAV1PictureInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeAV1PictureInfo* pStdPictureInfo; + int32_t referenceNameSlotIndices[VK_MAX_VIDEO_AV1_REFERENCES_PER_FRAME_KHR]; + uint32_t frameHeaderOffset; + uint32_t tileCount; + const uint32_t* pTileOffsets; + const uint32_t* pTileSizes; +} VkVideoDecodeAV1PictureInfoKHR; + +typedef struct VkVideoDecodeAV1DpbSlotInfoKHR { + VkStructureType sType; + const void* pNext; + const StdVideoDecodeAV1ReferenceInfo* pStdReferenceInfo; +} VkVideoDecodeAV1DpbSlotInfoKHR; + + + +// VK_KHR_video_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_video_maintenance1 1 +#define VK_KHR_VIDEO_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_KHR_VIDEO_MAINTENANCE_1_EXTENSION_NAME "VK_KHR_video_maintenance1" +typedef struct VkPhysicalDeviceVideoMaintenance1FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 videoMaintenance1; +} VkPhysicalDeviceVideoMaintenance1FeaturesKHR; + +typedef struct VkVideoInlineQueryInfoKHR { + VkStructureType sType; + const void* pNext; + VkQueryPool queryPool; + uint32_t firstQuery; + uint32_t queryCount; +} VkVideoInlineQueryInfoKHR; + + + +// VK_KHR_vertex_attribute_divisor is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_vertex_attribute_divisor 1 +#define VK_KHR_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION 1 +#define VK_KHR_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME "VK_KHR_vertex_attribute_divisor" +typedef struct VkPhysicalDeviceVertexAttributeDivisorPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t maxVertexAttribDivisor; + VkBool32 supportsNonZeroFirstInstance; +} VkPhysicalDeviceVertexAttributeDivisorPropertiesKHR; + +typedef struct VkVertexInputBindingDivisorDescriptionKHR { + uint32_t binding; + uint32_t divisor; +} VkVertexInputBindingDivisorDescriptionKHR; + +typedef struct VkPipelineVertexInputDivisorStateCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t vertexBindingDivisorCount; + const VkVertexInputBindingDivisorDescriptionKHR* pVertexBindingDivisors; +} VkPipelineVertexInputDivisorStateCreateInfoKHR; + +typedef struct VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 vertexAttributeInstanceRateDivisor; + VkBool32 vertexAttributeInstanceRateZeroDivisor; +} VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR; + + + +// VK_KHR_load_store_op_none is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_load_store_op_none 1 +#define VK_KHR_LOAD_STORE_OP_NONE_SPEC_VERSION 1 +#define VK_KHR_LOAD_STORE_OP_NONE_EXTENSION_NAME "VK_KHR_load_store_op_none" + + +// VK_KHR_shader_float_controls2 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_float_controls2 1 +#define VK_KHR_SHADER_FLOAT_CONTROLS_2_SPEC_VERSION 1 +#define VK_KHR_SHADER_FLOAT_CONTROLS_2_EXTENSION_NAME "VK_KHR_shader_float_controls2" +typedef struct VkPhysicalDeviceShaderFloatControls2FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderFloatControls2; +} VkPhysicalDeviceShaderFloatControls2FeaturesKHR; + + + +// VK_KHR_index_type_uint8 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_index_type_uint8 1 +#define VK_KHR_INDEX_TYPE_UINT8_SPEC_VERSION 1 +#define VK_KHR_INDEX_TYPE_UINT8_EXTENSION_NAME "VK_KHR_index_type_uint8" +typedef struct VkPhysicalDeviceIndexTypeUint8FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 indexTypeUint8; +} VkPhysicalDeviceIndexTypeUint8FeaturesKHR; + + + +// VK_KHR_line_rasterization is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_line_rasterization 1 +#define VK_KHR_LINE_RASTERIZATION_SPEC_VERSION 1 +#define VK_KHR_LINE_RASTERIZATION_EXTENSION_NAME "VK_KHR_line_rasterization" + +typedef enum VkLineRasterizationModeKHR { + VK_LINE_RASTERIZATION_MODE_DEFAULT_KHR = 0, + VK_LINE_RASTERIZATION_MODE_RECTANGULAR_KHR = 1, + VK_LINE_RASTERIZATION_MODE_BRESENHAM_KHR = 2, + VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_KHR = 3, + VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT = VK_LINE_RASTERIZATION_MODE_DEFAULT_KHR, + VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT = VK_LINE_RASTERIZATION_MODE_RECTANGULAR_KHR, + VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT = VK_LINE_RASTERIZATION_MODE_BRESENHAM_KHR, + VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT = VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_KHR, + VK_LINE_RASTERIZATION_MODE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkLineRasterizationModeKHR; +typedef struct VkPhysicalDeviceLineRasterizationFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rectangularLines; + VkBool32 bresenhamLines; + VkBool32 smoothLines; + VkBool32 stippledRectangularLines; + VkBool32 stippledBresenhamLines; + VkBool32 stippledSmoothLines; +} VkPhysicalDeviceLineRasterizationFeaturesKHR; + +typedef struct VkPhysicalDeviceLineRasterizationPropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t lineSubPixelPrecisionBits; +} VkPhysicalDeviceLineRasterizationPropertiesKHR; + +typedef struct VkPipelineRasterizationLineStateCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkLineRasterizationModeKHR lineRasterizationMode; + VkBool32 stippledLineEnable; + uint32_t lineStippleFactor; + uint16_t lineStipplePattern; +} VkPipelineRasterizationLineStateCreateInfoKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdSetLineStippleKHR)(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, uint16_t lineStipplePattern); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleKHR( + VkCommandBuffer commandBuffer, + uint32_t lineStippleFactor, + uint16_t lineStipplePattern); +#endif + + +// VK_KHR_calibrated_timestamps is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_calibrated_timestamps 1 +#define VK_KHR_CALIBRATED_TIMESTAMPS_SPEC_VERSION 1 +#define VK_KHR_CALIBRATED_TIMESTAMPS_EXTENSION_NAME "VK_KHR_calibrated_timestamps" + +typedef enum VkTimeDomainKHR { + VK_TIME_DOMAIN_DEVICE_KHR = 0, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR = 1, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR = 2, + VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR = 3, + VK_TIME_DOMAIN_DEVICE_EXT = VK_TIME_DOMAIN_DEVICE_KHR, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_EXT = VK_TIME_DOMAIN_CLOCK_MONOTONIC_KHR, + VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_EXT = VK_TIME_DOMAIN_CLOCK_MONOTONIC_RAW_KHR, + VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_EXT = VK_TIME_DOMAIN_QUERY_PERFORMANCE_COUNTER_KHR, + VK_TIME_DOMAIN_MAX_ENUM_KHR = 0x7FFFFFFF +} VkTimeDomainKHR; +typedef struct VkCalibratedTimestampInfoKHR { + VkStructureType sType; + const void* pNext; + VkTimeDomainKHR timeDomain; +} VkCalibratedTimestampInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsKHR)(VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainKHR* pTimeDomains); +typedef VkResult (VKAPI_PTR *PFN_vkGetCalibratedTimestampsKHR)(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoKHR* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCalibrateableTimeDomainsKHR( + VkPhysicalDevice physicalDevice, + uint32_t* pTimeDomainCount, + VkTimeDomainKHR* pTimeDomains); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetCalibratedTimestampsKHR( + VkDevice device, + uint32_t timestampCount, + const VkCalibratedTimestampInfoKHR* pTimestampInfos, + uint64_t* pTimestamps, + uint64_t* pMaxDeviation); +#endif + + +// VK_KHR_shader_expect_assume is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_shader_expect_assume 1 +#define VK_KHR_SHADER_EXPECT_ASSUME_SPEC_VERSION 1 +#define VK_KHR_SHADER_EXPECT_ASSUME_EXTENSION_NAME "VK_KHR_shader_expect_assume" +typedef struct VkPhysicalDeviceShaderExpectAssumeFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 shaderExpectAssume; +} VkPhysicalDeviceShaderExpectAssumeFeaturesKHR; + + + +// VK_KHR_maintenance6 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_maintenance6 1 +#define VK_KHR_MAINTENANCE_6_SPEC_VERSION 1 +#define VK_KHR_MAINTENANCE_6_EXTENSION_NAME "VK_KHR_maintenance6" +typedef struct VkPhysicalDeviceMaintenance6FeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 maintenance6; +} VkPhysicalDeviceMaintenance6FeaturesKHR; + +typedef struct VkPhysicalDeviceMaintenance6PropertiesKHR { + VkStructureType sType; + void* pNext; + VkBool32 blockTexelViewCompatibleMultipleLayers; + uint32_t maxCombinedImageSamplerDescriptorCount; + VkBool32 fragmentShadingRateClampCombinerInputs; +} VkPhysicalDeviceMaintenance6PropertiesKHR; + +typedef struct VkBindMemoryStatusKHR { + VkStructureType sType; + const void* pNext; + VkResult* pResult; +} VkBindMemoryStatusKHR; + +typedef struct VkBindDescriptorSetsInfoKHR { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t firstSet; + uint32_t descriptorSetCount; + const VkDescriptorSet* pDescriptorSets; + uint32_t dynamicOffsetCount; + const uint32_t* pDynamicOffsets; +} VkBindDescriptorSetsInfoKHR; + +typedef struct VkPushConstantsInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipelineLayout layout; + VkShaderStageFlags stageFlags; + uint32_t offset; + uint32_t size; + const void* pValues; +} VkPushConstantsInfoKHR; + +typedef struct VkPushDescriptorSetInfoKHR { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t set; + uint32_t descriptorWriteCount; + const VkWriteDescriptorSet* pDescriptorWrites; +} VkPushDescriptorSetInfoKHR; + +typedef struct VkPushDescriptorSetWithTemplateInfoKHR { + VkStructureType sType; + const void* pNext; + VkDescriptorUpdateTemplate descriptorUpdateTemplate; + VkPipelineLayout layout; + uint32_t set; + const void* pData; +} VkPushDescriptorSetWithTemplateInfoKHR; + +typedef struct VkSetDescriptorBufferOffsetsInfoEXT { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t firstSet; + uint32_t setCount; + const uint32_t* pBufferIndices; + const VkDeviceSize* pOffsets; +} VkSetDescriptorBufferOffsetsInfoEXT; + +typedef struct VkBindDescriptorBufferEmbeddedSamplersInfoEXT { + VkStructureType sType; + const void* pNext; + VkShaderStageFlags stageFlags; + VkPipelineLayout layout; + uint32_t set; +} VkBindDescriptorBufferEmbeddedSamplersInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorSets2KHR)(VkCommandBuffer commandBuffer, const VkBindDescriptorSetsInfoKHR* pBindDescriptorSetsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdPushConstants2KHR)(VkCommandBuffer commandBuffer, const VkPushConstantsInfoKHR* pPushConstantsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSet2KHR)(VkCommandBuffer commandBuffer, const VkPushDescriptorSetInfoKHR* pPushDescriptorSetInfo); +typedef void (VKAPI_PTR *PFN_vkCmdPushDescriptorSetWithTemplate2KHR)(VkCommandBuffer commandBuffer, const VkPushDescriptorSetWithTemplateInfoKHR* pPushDescriptorSetWithTemplateInfo); +typedef void (VKAPI_PTR *PFN_vkCmdSetDescriptorBufferOffsets2EXT)(VkCommandBuffer commandBuffer, const VkSetDescriptorBufferOffsetsInfoEXT* pSetDescriptorBufferOffsetsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBufferEmbeddedSamplers2EXT)(VkCommandBuffer commandBuffer, const VkBindDescriptorBufferEmbeddedSamplersInfoEXT* pBindDescriptorBufferEmbeddedSamplersInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorSets2KHR( + VkCommandBuffer commandBuffer, + const VkBindDescriptorSetsInfoKHR* pBindDescriptorSetsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushConstants2KHR( + VkCommandBuffer commandBuffer, + const VkPushConstantsInfoKHR* pPushConstantsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSet2KHR( + VkCommandBuffer commandBuffer, + const VkPushDescriptorSetInfoKHR* pPushDescriptorSetInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdPushDescriptorSetWithTemplate2KHR( + VkCommandBuffer commandBuffer, + const VkPushDescriptorSetWithTemplateInfoKHR* pPushDescriptorSetWithTemplateInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDescriptorBufferOffsets2EXT( + VkCommandBuffer commandBuffer, + const VkSetDescriptorBufferOffsetsInfoEXT* pSetDescriptorBufferOffsetsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBufferEmbeddedSamplers2EXT( + VkCommandBuffer commandBuffer, + const VkBindDescriptorBufferEmbeddedSamplersInfoEXT* pBindDescriptorBufferEmbeddedSamplersInfo); +#endif + + +// VK_EXT_debug_report is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_debug_report 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugReportCallbackEXT) +#define VK_EXT_DEBUG_REPORT_SPEC_VERSION 10 +#define VK_EXT_DEBUG_REPORT_EXTENSION_NAME "VK_EXT_debug_report" + +typedef enum VkDebugReportObjectTypeEXT { + VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT = 0, + VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT = 1, + VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT = 2, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT = 3, + VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT = 4, + VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT = 5, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT = 6, + VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT = 7, + VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT = 8, + VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT = 9, + VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT = 10, + VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT = 11, + VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT = 12, + VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT = 13, + VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT = 14, + VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT = 15, + VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT = 16, + VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT = 17, + VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT = 18, + VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT = 19, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT = 20, + VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT = 21, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT = 22, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT = 23, + VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT = 24, + VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT = 25, + VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26, + VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27, + VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT = 28, + VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_KHR_EXT = 29, + VK_DEBUG_REPORT_OBJECT_TYPE_DISPLAY_MODE_KHR_EXT = 30, + VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT = 33, + VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT = 1000156000, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT = 1000085000, + VK_DEBUG_REPORT_OBJECT_TYPE_CU_MODULE_NVX_EXT = 1000029000, + VK_DEBUG_REPORT_OBJECT_TYPE_CU_FUNCTION_NVX_EXT = 1000029001, + VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_KHR_EXT = 1000150000, + VK_DEBUG_REPORT_OBJECT_TYPE_ACCELERATION_STRUCTURE_NV_EXT = 1000165000, + VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_MODULE_NV_EXT = 1000307000, + VK_DEBUG_REPORT_OBJECT_TYPE_CUDA_FUNCTION_NV_EXT = 1000307001, + VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_COLLECTION_FUCHSIA_EXT = 1000366000, + VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_VALIDATION_CACHE_EXT_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_KHR_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_KHR_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION_EXT, + VK_DEBUG_REPORT_OBJECT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugReportObjectTypeEXT; + +typedef enum VkDebugReportFlagBitsEXT { + VK_DEBUG_REPORT_INFORMATION_BIT_EXT = 0x00000001, + VK_DEBUG_REPORT_WARNING_BIT_EXT = 0x00000002, + VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 0x00000004, + VK_DEBUG_REPORT_ERROR_BIT_EXT = 0x00000008, + VK_DEBUG_REPORT_DEBUG_BIT_EXT = 0x00000010, + VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugReportFlagBitsEXT; +typedef VkFlags VkDebugReportFlagsEXT; +typedef VkBool32 (VKAPI_PTR *PFN_vkDebugReportCallbackEXT)( + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage, + void* pUserData); + +typedef struct VkDebugReportCallbackCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugReportFlagsEXT flags; + PFN_vkDebugReportCallbackEXT pfnCallback; + void* pUserData; +} VkDebugReportCallbackCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateDebugReportCallbackEXT)(VkInstance instance, const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugReportCallbackEXT* pCallback); +typedef void (VKAPI_PTR *PFN_vkDestroyDebugReportCallbackEXT)(VkInstance instance, VkDebugReportCallbackEXT callback, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkDebugReportMessageEXT)(VkInstance instance, VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugReportCallbackEXT( + VkInstance instance, + const VkDebugReportCallbackCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugReportCallbackEXT* pCallback); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugReportCallbackEXT( + VkInstance instance, + VkDebugReportCallbackEXT callback, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT( + VkInstance instance, + VkDebugReportFlagsEXT flags, + VkDebugReportObjectTypeEXT objectType, + uint64_t object, + size_t location, + int32_t messageCode, + const char* pLayerPrefix, + const char* pMessage); +#endif + + +// VK_NV_glsl_shader is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_glsl_shader 1 +#define VK_NV_GLSL_SHADER_SPEC_VERSION 1 +#define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader" + + +// VK_EXT_depth_range_unrestricted is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_depth_range_unrestricted 1 +#define VK_EXT_DEPTH_RANGE_UNRESTRICTED_SPEC_VERSION 1 +#define VK_EXT_DEPTH_RANGE_UNRESTRICTED_EXTENSION_NAME "VK_EXT_depth_range_unrestricted" + + +// VK_IMG_filter_cubic is a preprocessor guard. Do not pass it to API calls. +#define VK_IMG_filter_cubic 1 +#define VK_IMG_FILTER_CUBIC_SPEC_VERSION 1 +#define VK_IMG_FILTER_CUBIC_EXTENSION_NAME "VK_IMG_filter_cubic" + + +// VK_AMD_rasterization_order is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_rasterization_order 1 +#define VK_AMD_RASTERIZATION_ORDER_SPEC_VERSION 1 +#define VK_AMD_RASTERIZATION_ORDER_EXTENSION_NAME "VK_AMD_rasterization_order" + +typedef enum VkRasterizationOrderAMD { + VK_RASTERIZATION_ORDER_STRICT_AMD = 0, + VK_RASTERIZATION_ORDER_RELAXED_AMD = 1, + VK_RASTERIZATION_ORDER_MAX_ENUM_AMD = 0x7FFFFFFF +} VkRasterizationOrderAMD; +typedef struct VkPipelineRasterizationStateRasterizationOrderAMD { + VkStructureType sType; + const void* pNext; + VkRasterizationOrderAMD rasterizationOrder; +} VkPipelineRasterizationStateRasterizationOrderAMD; + + + +// VK_AMD_shader_trinary_minmax is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_trinary_minmax 1 +#define VK_AMD_SHADER_TRINARY_MINMAX_SPEC_VERSION 1 +#define VK_AMD_SHADER_TRINARY_MINMAX_EXTENSION_NAME "VK_AMD_shader_trinary_minmax" + + +// VK_AMD_shader_explicit_vertex_parameter is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_explicit_vertex_parameter 1 +#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_SPEC_VERSION 1 +#define VK_AMD_SHADER_EXPLICIT_VERTEX_PARAMETER_EXTENSION_NAME "VK_AMD_shader_explicit_vertex_parameter" + + +// VK_EXT_debug_marker is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_debug_marker 1 +#define VK_EXT_DEBUG_MARKER_SPEC_VERSION 4 +#define VK_EXT_DEBUG_MARKER_EXTENSION_NAME "VK_EXT_debug_marker" +typedef struct VkDebugMarkerObjectNameInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugReportObjectTypeEXT objectType; + uint64_t object; + const char* pObjectName; +} VkDebugMarkerObjectNameInfoEXT; + +typedef struct VkDebugMarkerObjectTagInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugReportObjectTypeEXT objectType; + uint64_t object; + uint64_t tagName; + size_t tagSize; + const void* pTag; +} VkDebugMarkerObjectTagInfoEXT; + +typedef struct VkDebugMarkerMarkerInfoEXT { + VkStructureType sType; + const void* pNext; + const char* pMarkerName; + float color[4]; +} VkDebugMarkerMarkerInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectTagEXT)(VkDevice device, const VkDebugMarkerObjectTagInfoEXT* pTagInfo); +typedef VkResult (VKAPI_PTR *PFN_vkDebugMarkerSetObjectNameEXT)(VkDevice device, const VkDebugMarkerObjectNameInfoEXT* pNameInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerBeginEXT)(VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); +typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerEndEXT)(VkCommandBuffer commandBuffer); +typedef void (VKAPI_PTR *PFN_vkCmdDebugMarkerInsertEXT)(VkCommandBuffer commandBuffer, const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectTagEXT( + VkDevice device, + const VkDebugMarkerObjectTagInfoEXT* pTagInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT( + VkDevice device, + const VkDebugMarkerObjectNameInfoEXT* pNameInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerBeginEXT( + VkCommandBuffer commandBuffer, + const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerEndEXT( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR void VKAPI_CALL vkCmdDebugMarkerInsertEXT( + VkCommandBuffer commandBuffer, + const VkDebugMarkerMarkerInfoEXT* pMarkerInfo); +#endif + + +// VK_AMD_gcn_shader is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_gcn_shader 1 +#define VK_AMD_GCN_SHADER_SPEC_VERSION 1 +#define VK_AMD_GCN_SHADER_EXTENSION_NAME "VK_AMD_gcn_shader" + + +// VK_NV_dedicated_allocation is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_dedicated_allocation 1 +#define VK_NV_DEDICATED_ALLOCATION_SPEC_VERSION 1 +#define VK_NV_DEDICATED_ALLOCATION_EXTENSION_NAME "VK_NV_dedicated_allocation" +typedef struct VkDedicatedAllocationImageCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 dedicatedAllocation; +} VkDedicatedAllocationImageCreateInfoNV; + +typedef struct VkDedicatedAllocationBufferCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 dedicatedAllocation; +} VkDedicatedAllocationBufferCreateInfoNV; + +typedef struct VkDedicatedAllocationMemoryAllocateInfoNV { + VkStructureType sType; + const void* pNext; + VkImage image; + VkBuffer buffer; +} VkDedicatedAllocationMemoryAllocateInfoNV; + + + +// VK_EXT_transform_feedback is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_transform_feedback 1 +#define VK_EXT_TRANSFORM_FEEDBACK_SPEC_VERSION 1 +#define VK_EXT_TRANSFORM_FEEDBACK_EXTENSION_NAME "VK_EXT_transform_feedback" +typedef VkFlags VkPipelineRasterizationStateStreamCreateFlagsEXT; +typedef struct VkPhysicalDeviceTransformFeedbackFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 transformFeedback; + VkBool32 geometryStreams; +} VkPhysicalDeviceTransformFeedbackFeaturesEXT; + +typedef struct VkPhysicalDeviceTransformFeedbackPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxTransformFeedbackStreams; + uint32_t maxTransformFeedbackBuffers; + VkDeviceSize maxTransformFeedbackBufferSize; + uint32_t maxTransformFeedbackStreamDataSize; + uint32_t maxTransformFeedbackBufferDataSize; + uint32_t maxTransformFeedbackBufferDataStride; + VkBool32 transformFeedbackQueries; + VkBool32 transformFeedbackStreamsLinesTriangles; + VkBool32 transformFeedbackRasterizationStreamSelect; + VkBool32 transformFeedbackDraw; +} VkPhysicalDeviceTransformFeedbackPropertiesEXT; + +typedef struct VkPipelineRasterizationStateStreamCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationStateStreamCreateFlagsEXT flags; + uint32_t rasterizationStream; +} VkPipelineRasterizationStateStreamCreateInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdBindTransformFeedbackBuffersEXT)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets, const VkDeviceSize* pSizes); +typedef void (VKAPI_PTR *PFN_vkCmdBeginTransformFeedbackEXT)(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, uint32_t counterBufferCount, const VkBuffer* pCounterBuffers, const VkDeviceSize* pCounterBufferOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdEndTransformFeedbackEXT)(VkCommandBuffer commandBuffer, uint32_t firstCounterBuffer, uint32_t counterBufferCount, const VkBuffer* pCounterBuffers, const VkDeviceSize* pCounterBufferOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdBeginQueryIndexedEXT)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, VkQueryControlFlags flags, uint32_t index); +typedef void (VKAPI_PTR *PFN_vkCmdEndQueryIndexedEXT)(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t query, uint32_t index); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectByteCountEXT)(VkCommandBuffer commandBuffer, uint32_t instanceCount, uint32_t firstInstance, VkBuffer counterBuffer, VkDeviceSize counterBufferOffset, uint32_t counterOffset, uint32_t vertexStride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindTransformFeedbackBuffersEXT( + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBuffer* pBuffers, + const VkDeviceSize* pOffsets, + const VkDeviceSize* pSizes); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginTransformFeedbackEXT( + VkCommandBuffer commandBuffer, + uint32_t firstCounterBuffer, + uint32_t counterBufferCount, + const VkBuffer* pCounterBuffers, + const VkDeviceSize* pCounterBufferOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndTransformFeedbackEXT( + VkCommandBuffer commandBuffer, + uint32_t firstCounterBuffer, + uint32_t counterBufferCount, + const VkBuffer* pCounterBuffers, + const VkDeviceSize* pCounterBufferOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginQueryIndexedEXT( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query, + VkQueryControlFlags flags, + uint32_t index); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndQueryIndexedEXT( + VkCommandBuffer commandBuffer, + VkQueryPool queryPool, + uint32_t query, + uint32_t index); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectByteCountEXT( + VkCommandBuffer commandBuffer, + uint32_t instanceCount, + uint32_t firstInstance, + VkBuffer counterBuffer, + VkDeviceSize counterBufferOffset, + uint32_t counterOffset, + uint32_t vertexStride); +#endif + + +// VK_NVX_binary_import is a preprocessor guard. Do not pass it to API calls. +#define VK_NVX_binary_import 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCuModuleNVX) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCuFunctionNVX) +#define VK_NVX_BINARY_IMPORT_SPEC_VERSION 1 +#define VK_NVX_BINARY_IMPORT_EXTENSION_NAME "VK_NVX_binary_import" +typedef struct VkCuModuleCreateInfoNVX { + VkStructureType sType; + const void* pNext; + size_t dataSize; + const void* pData; +} VkCuModuleCreateInfoNVX; + +typedef struct VkCuFunctionCreateInfoNVX { + VkStructureType sType; + const void* pNext; + VkCuModuleNVX module; + const char* pName; +} VkCuFunctionCreateInfoNVX; + +typedef struct VkCuLaunchInfoNVX { + VkStructureType sType; + const void* pNext; + VkCuFunctionNVX function; + uint32_t gridDimX; + uint32_t gridDimY; + uint32_t gridDimZ; + uint32_t blockDimX; + uint32_t blockDimY; + uint32_t blockDimZ; + uint32_t sharedMemBytes; + size_t paramCount; + const void* const * pParams; + size_t extraCount; + const void* const * pExtras; +} VkCuLaunchInfoNVX; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateCuModuleNVX)(VkDevice device, const VkCuModuleCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCuModuleNVX* pModule); +typedef VkResult (VKAPI_PTR *PFN_vkCreateCuFunctionNVX)(VkDevice device, const VkCuFunctionCreateInfoNVX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCuFunctionNVX* pFunction); +typedef void (VKAPI_PTR *PFN_vkDestroyCuModuleNVX)(VkDevice device, VkCuModuleNVX module, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkDestroyCuFunctionNVX)(VkDevice device, VkCuFunctionNVX function, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdCuLaunchKernelNVX)(VkCommandBuffer commandBuffer, const VkCuLaunchInfoNVX* pLaunchInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCuModuleNVX( + VkDevice device, + const VkCuModuleCreateInfoNVX* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCuModuleNVX* pModule); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCuFunctionNVX( + VkDevice device, + const VkCuFunctionCreateInfoNVX* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCuFunctionNVX* pFunction); + +VKAPI_ATTR void VKAPI_CALL vkDestroyCuModuleNVX( + VkDevice device, + VkCuModuleNVX module, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkDestroyCuFunctionNVX( + VkDevice device, + VkCuFunctionNVX function, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdCuLaunchKernelNVX( + VkCommandBuffer commandBuffer, + const VkCuLaunchInfoNVX* pLaunchInfo); +#endif + + +// VK_NVX_image_view_handle is a preprocessor guard. Do not pass it to API calls. +#define VK_NVX_image_view_handle 1 +#define VK_NVX_IMAGE_VIEW_HANDLE_SPEC_VERSION 2 +#define VK_NVX_IMAGE_VIEW_HANDLE_EXTENSION_NAME "VK_NVX_image_view_handle" +typedef struct VkImageViewHandleInfoNVX { + VkStructureType sType; + const void* pNext; + VkImageView imageView; + VkDescriptorType descriptorType; + VkSampler sampler; +} VkImageViewHandleInfoNVX; + +typedef struct VkImageViewAddressPropertiesNVX { + VkStructureType sType; + void* pNext; + VkDeviceAddress deviceAddress; + VkDeviceSize size; +} VkImageViewAddressPropertiesNVX; + +typedef uint32_t (VKAPI_PTR *PFN_vkGetImageViewHandleNVX)(VkDevice device, const VkImageViewHandleInfoNVX* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetImageViewAddressNVX)(VkDevice device, VkImageView imageView, VkImageViewAddressPropertiesNVX* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR uint32_t VKAPI_CALL vkGetImageViewHandleNVX( + VkDevice device, + const VkImageViewHandleInfoNVX* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageViewAddressNVX( + VkDevice device, + VkImageView imageView, + VkImageViewAddressPropertiesNVX* pProperties); +#endif + + +// VK_AMD_draw_indirect_count is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_draw_indirect_count 1 +#define VK_AMD_DRAW_INDIRECT_COUNT_SPEC_VERSION 2 +#define VK_AMD_DRAW_INDIRECT_COUNT_EXTENSION_NAME "VK_AMD_draw_indirect_count" +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawIndexedIndirectCountAMD)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndirectCountAMD( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawIndexedIndirectCountAMD( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + + +// VK_AMD_negative_viewport_height is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_negative_viewport_height 1 +#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_SPEC_VERSION 1 +#define VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME "VK_AMD_negative_viewport_height" + + +// VK_AMD_gpu_shader_half_float is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_gpu_shader_half_float 1 +#define VK_AMD_GPU_SHADER_HALF_FLOAT_SPEC_VERSION 2 +#define VK_AMD_GPU_SHADER_HALF_FLOAT_EXTENSION_NAME "VK_AMD_gpu_shader_half_float" + + +// VK_AMD_shader_ballot is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_ballot 1 +#define VK_AMD_SHADER_BALLOT_SPEC_VERSION 1 +#define VK_AMD_SHADER_BALLOT_EXTENSION_NAME "VK_AMD_shader_ballot" + + +// VK_AMD_texture_gather_bias_lod is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_texture_gather_bias_lod 1 +#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_SPEC_VERSION 1 +#define VK_AMD_TEXTURE_GATHER_BIAS_LOD_EXTENSION_NAME "VK_AMD_texture_gather_bias_lod" +typedef struct VkTextureLODGatherFormatPropertiesAMD { + VkStructureType sType; + void* pNext; + VkBool32 supportsTextureGatherLODBiasAMD; +} VkTextureLODGatherFormatPropertiesAMD; + + + +// VK_AMD_shader_info is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_info 1 +#define VK_AMD_SHADER_INFO_SPEC_VERSION 1 +#define VK_AMD_SHADER_INFO_EXTENSION_NAME "VK_AMD_shader_info" + +typedef enum VkShaderInfoTypeAMD { + VK_SHADER_INFO_TYPE_STATISTICS_AMD = 0, + VK_SHADER_INFO_TYPE_BINARY_AMD = 1, + VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD = 2, + VK_SHADER_INFO_TYPE_MAX_ENUM_AMD = 0x7FFFFFFF +} VkShaderInfoTypeAMD; +typedef struct VkShaderResourceUsageAMD { + uint32_t numUsedVgprs; + uint32_t numUsedSgprs; + uint32_t ldsSizePerLocalWorkGroup; + size_t ldsUsageSizeInBytes; + size_t scratchMemUsageInBytes; +} VkShaderResourceUsageAMD; + +typedef struct VkShaderStatisticsInfoAMD { + VkShaderStageFlags shaderStageMask; + VkShaderResourceUsageAMD resourceUsage; + uint32_t numPhysicalVgprs; + uint32_t numPhysicalSgprs; + uint32_t numAvailableVgprs; + uint32_t numAvailableSgprs; + uint32_t computeWorkGroupSize[3]; +} VkShaderStatisticsInfoAMD; + +typedef VkResult (VKAPI_PTR *PFN_vkGetShaderInfoAMD)(VkDevice device, VkPipeline pipeline, VkShaderStageFlagBits shaderStage, VkShaderInfoTypeAMD infoType, size_t* pInfoSize, void* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetShaderInfoAMD( + VkDevice device, + VkPipeline pipeline, + VkShaderStageFlagBits shaderStage, + VkShaderInfoTypeAMD infoType, + size_t* pInfoSize, + void* pInfo); +#endif + + +// VK_AMD_shader_image_load_store_lod is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_image_load_store_lod 1 +#define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_SPEC_VERSION 1 +#define VK_AMD_SHADER_IMAGE_LOAD_STORE_LOD_EXTENSION_NAME "VK_AMD_shader_image_load_store_lod" + + +// VK_NV_corner_sampled_image is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_corner_sampled_image 1 +#define VK_NV_CORNER_SAMPLED_IMAGE_SPEC_VERSION 2 +#define VK_NV_CORNER_SAMPLED_IMAGE_EXTENSION_NAME "VK_NV_corner_sampled_image" +typedef struct VkPhysicalDeviceCornerSampledImageFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 cornerSampledImage; +} VkPhysicalDeviceCornerSampledImageFeaturesNV; + + + +// VK_IMG_format_pvrtc is a preprocessor guard. Do not pass it to API calls. +#define VK_IMG_format_pvrtc 1 +#define VK_IMG_FORMAT_PVRTC_SPEC_VERSION 1 +#define VK_IMG_FORMAT_PVRTC_EXTENSION_NAME "VK_IMG_format_pvrtc" + + +// VK_NV_external_memory_capabilities is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_external_memory_capabilities 1 +#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME "VK_NV_external_memory_capabilities" + +typedef enum VkExternalMemoryHandleTypeFlagBitsNV { + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_BIT_NV = 0x00000001, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32_KMT_BIT_NV = 0x00000002, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_BIT_NV = 0x00000004, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_IMAGE_KMT_BIT_NV = 0x00000008, + VK_EXTERNAL_MEMORY_HANDLE_TYPE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkExternalMemoryHandleTypeFlagBitsNV; +typedef VkFlags VkExternalMemoryHandleTypeFlagsNV; + +typedef enum VkExternalMemoryFeatureFlagBitsNV { + VK_EXTERNAL_MEMORY_FEATURE_DEDICATED_ONLY_BIT_NV = 0x00000001, + VK_EXTERNAL_MEMORY_FEATURE_EXPORTABLE_BIT_NV = 0x00000002, + VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT_NV = 0x00000004, + VK_EXTERNAL_MEMORY_FEATURE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkExternalMemoryFeatureFlagBitsNV; +typedef VkFlags VkExternalMemoryFeatureFlagsNV; +typedef struct VkExternalImageFormatPropertiesNV { + VkImageFormatProperties imageFormatProperties; + VkExternalMemoryFeatureFlagsNV externalMemoryFeatures; + VkExternalMemoryHandleTypeFlagsNV exportFromImportedHandleTypes; + VkExternalMemoryHandleTypeFlagsNV compatibleHandleTypes; +} VkExternalImageFormatPropertiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceExternalImageFormatPropertiesNV)(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkExternalMemoryHandleTypeFlagsNV externalHandleType, VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceExternalImageFormatPropertiesNV( + VkPhysicalDevice physicalDevice, + VkFormat format, + VkImageType type, + VkImageTiling tiling, + VkImageUsageFlags usage, + VkImageCreateFlags flags, + VkExternalMemoryHandleTypeFlagsNV externalHandleType, + VkExternalImageFormatPropertiesNV* pExternalImageFormatProperties); +#endif + + +// VK_NV_external_memory is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_external_memory 1 +#define VK_NV_EXTERNAL_MEMORY_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_EXTENSION_NAME "VK_NV_external_memory" +typedef struct VkExternalMemoryImageCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleTypes; +} VkExternalMemoryImageCreateInfoNV; + +typedef struct VkExportMemoryAllocateInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleTypes; +} VkExportMemoryAllocateInfoNV; + + + +// VK_EXT_validation_flags is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_validation_flags 1 +#define VK_EXT_VALIDATION_FLAGS_SPEC_VERSION 3 +#define VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME "VK_EXT_validation_flags" + +typedef enum VkValidationCheckEXT { + VK_VALIDATION_CHECK_ALL_EXT = 0, + VK_VALIDATION_CHECK_SHADERS_EXT = 1, + VK_VALIDATION_CHECK_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationCheckEXT; +typedef struct VkValidationFlagsEXT { + VkStructureType sType; + const void* pNext; + uint32_t disabledValidationCheckCount; + const VkValidationCheckEXT* pDisabledValidationChecks; +} VkValidationFlagsEXT; + + + +// VK_EXT_shader_subgroup_ballot is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_subgroup_ballot 1 +#define VK_EXT_SHADER_SUBGROUP_BALLOT_SPEC_VERSION 1 +#define VK_EXT_SHADER_SUBGROUP_BALLOT_EXTENSION_NAME "VK_EXT_shader_subgroup_ballot" + + +// VK_EXT_shader_subgroup_vote is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_subgroup_vote 1 +#define VK_EXT_SHADER_SUBGROUP_VOTE_SPEC_VERSION 1 +#define VK_EXT_SHADER_SUBGROUP_VOTE_EXTENSION_NAME "VK_EXT_shader_subgroup_vote" + + +// VK_EXT_texture_compression_astc_hdr is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_texture_compression_astc_hdr 1 +#define VK_EXT_TEXTURE_COMPRESSION_ASTC_HDR_SPEC_VERSION 1 +#define VK_EXT_TEXTURE_COMPRESSION_ASTC_HDR_EXTENSION_NAME "VK_EXT_texture_compression_astc_hdr" +typedef VkPhysicalDeviceTextureCompressionASTCHDRFeatures VkPhysicalDeviceTextureCompressionASTCHDRFeaturesEXT; + + + +// VK_EXT_astc_decode_mode is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_astc_decode_mode 1 +#define VK_EXT_ASTC_DECODE_MODE_SPEC_VERSION 1 +#define VK_EXT_ASTC_DECODE_MODE_EXTENSION_NAME "VK_EXT_astc_decode_mode" +typedef struct VkImageViewASTCDecodeModeEXT { + VkStructureType sType; + const void* pNext; + VkFormat decodeMode; +} VkImageViewASTCDecodeModeEXT; + +typedef struct VkPhysicalDeviceASTCDecodeFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 decodeModeSharedExponent; +} VkPhysicalDeviceASTCDecodeFeaturesEXT; + + + +// VK_EXT_pipeline_robustness is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_robustness 1 +#define VK_EXT_PIPELINE_ROBUSTNESS_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_ROBUSTNESS_EXTENSION_NAME "VK_EXT_pipeline_robustness" + +typedef enum VkPipelineRobustnessBufferBehaviorEXT { + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DEVICE_DEFAULT_EXT = 0, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT = 1, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_EXT = 2, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_ROBUST_BUFFER_ACCESS_2_EXT = 3, + VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPipelineRobustnessBufferBehaviorEXT; + +typedef enum VkPipelineRobustnessImageBehaviorEXT { + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DEVICE_DEFAULT_EXT = 0, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_DISABLED_EXT = 1, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_EXT = 2, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_ROBUST_IMAGE_ACCESS_2_EXT = 3, + VK_PIPELINE_ROBUSTNESS_IMAGE_BEHAVIOR_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPipelineRobustnessImageBehaviorEXT; +typedef struct VkPhysicalDevicePipelineRobustnessFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineRobustness; +} VkPhysicalDevicePipelineRobustnessFeaturesEXT; + +typedef struct VkPhysicalDevicePipelineRobustnessPropertiesEXT { + VkStructureType sType; + void* pNext; + VkPipelineRobustnessBufferBehaviorEXT defaultRobustnessStorageBuffers; + VkPipelineRobustnessBufferBehaviorEXT defaultRobustnessUniformBuffers; + VkPipelineRobustnessBufferBehaviorEXT defaultRobustnessVertexInputs; + VkPipelineRobustnessImageBehaviorEXT defaultRobustnessImages; +} VkPhysicalDevicePipelineRobustnessPropertiesEXT; + +typedef struct VkPipelineRobustnessCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRobustnessBufferBehaviorEXT storageBuffers; + VkPipelineRobustnessBufferBehaviorEXT uniformBuffers; + VkPipelineRobustnessBufferBehaviorEXT vertexInputs; + VkPipelineRobustnessImageBehaviorEXT images; +} VkPipelineRobustnessCreateInfoEXT; + + + +// VK_EXT_conditional_rendering is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_conditional_rendering 1 +#define VK_EXT_CONDITIONAL_RENDERING_SPEC_VERSION 2 +#define VK_EXT_CONDITIONAL_RENDERING_EXTENSION_NAME "VK_EXT_conditional_rendering" + +typedef enum VkConditionalRenderingFlagBitsEXT { + VK_CONDITIONAL_RENDERING_INVERTED_BIT_EXT = 0x00000001, + VK_CONDITIONAL_RENDERING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkConditionalRenderingFlagBitsEXT; +typedef VkFlags VkConditionalRenderingFlagsEXT; +typedef struct VkConditionalRenderingBeginInfoEXT { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; + VkDeviceSize offset; + VkConditionalRenderingFlagsEXT flags; +} VkConditionalRenderingBeginInfoEXT; + +typedef struct VkPhysicalDeviceConditionalRenderingFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 conditionalRendering; + VkBool32 inheritedConditionalRendering; +} VkPhysicalDeviceConditionalRenderingFeaturesEXT; + +typedef struct VkCommandBufferInheritanceConditionalRenderingInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 conditionalRenderingEnable; +} VkCommandBufferInheritanceConditionalRenderingInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdBeginConditionalRenderingEXT)(VkCommandBuffer commandBuffer, const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin); +typedef void (VKAPI_PTR *PFN_vkCmdEndConditionalRenderingEXT)(VkCommandBuffer commandBuffer); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBeginConditionalRenderingEXT( + VkCommandBuffer commandBuffer, + const VkConditionalRenderingBeginInfoEXT* pConditionalRenderingBegin); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndConditionalRenderingEXT( + VkCommandBuffer commandBuffer); +#endif + + +// VK_NV_clip_space_w_scaling is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_clip_space_w_scaling 1 +#define VK_NV_CLIP_SPACE_W_SCALING_SPEC_VERSION 1 +#define VK_NV_CLIP_SPACE_W_SCALING_EXTENSION_NAME "VK_NV_clip_space_w_scaling" +typedef struct VkViewportWScalingNV { + float xcoeff; + float ycoeff; +} VkViewportWScalingNV; + +typedef struct VkPipelineViewportWScalingStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 viewportWScalingEnable; + uint32_t viewportCount; + const VkViewportWScalingNV* pViewportWScalings; +} VkPipelineViewportWScalingStateCreateInfoNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWScalingNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportWScalingNV* pViewportWScalings); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingNV( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewportWScalingNV* pViewportWScalings); +#endif + + +// VK_EXT_direct_mode_display is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_direct_mode_display 1 +#define VK_EXT_DIRECT_MODE_DISPLAY_SPEC_VERSION 1 +#define VK_EXT_DIRECT_MODE_DISPLAY_EXTENSION_NAME "VK_EXT_direct_mode_display" +typedef VkResult (VKAPI_PTR *PFN_vkReleaseDisplayEXT)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkReleaseDisplayEXT( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display); +#endif + + +// VK_EXT_display_surface_counter is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_display_surface_counter 1 +#define VK_EXT_DISPLAY_SURFACE_COUNTER_SPEC_VERSION 1 +#define VK_EXT_DISPLAY_SURFACE_COUNTER_EXTENSION_NAME "VK_EXT_display_surface_counter" + +typedef enum VkSurfaceCounterFlagBitsEXT { + VK_SURFACE_COUNTER_VBLANK_BIT_EXT = 0x00000001, + VK_SURFACE_COUNTER_VBLANK_EXT = VK_SURFACE_COUNTER_VBLANK_BIT_EXT, + VK_SURFACE_COUNTER_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkSurfaceCounterFlagBitsEXT; +typedef VkFlags VkSurfaceCounterFlagsEXT; +typedef struct VkSurfaceCapabilities2EXT { + VkStructureType sType; + void* pNext; + uint32_t minImageCount; + uint32_t maxImageCount; + VkExtent2D currentExtent; + VkExtent2D minImageExtent; + VkExtent2D maxImageExtent; + uint32_t maxImageArrayLayers; + VkSurfaceTransformFlagsKHR supportedTransforms; + VkSurfaceTransformFlagBitsKHR currentTransform; + VkCompositeAlphaFlagsKHR supportedCompositeAlpha; + VkImageUsageFlags supportedUsageFlags; + VkSurfaceCounterFlagsEXT supportedSurfaceCounters; +} VkSurfaceCapabilities2EXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfaceCapabilities2EXT)(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilities2EXT* pSurfaceCapabilities); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilities2EXT( + VkPhysicalDevice physicalDevice, + VkSurfaceKHR surface, + VkSurfaceCapabilities2EXT* pSurfaceCapabilities); +#endif + + +// VK_EXT_display_control is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_display_control 1 +#define VK_EXT_DISPLAY_CONTROL_SPEC_VERSION 1 +#define VK_EXT_DISPLAY_CONTROL_EXTENSION_NAME "VK_EXT_display_control" + +typedef enum VkDisplayPowerStateEXT { + VK_DISPLAY_POWER_STATE_OFF_EXT = 0, + VK_DISPLAY_POWER_STATE_SUSPEND_EXT = 1, + VK_DISPLAY_POWER_STATE_ON_EXT = 2, + VK_DISPLAY_POWER_STATE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDisplayPowerStateEXT; + +typedef enum VkDeviceEventTypeEXT { + VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT = 0, + VK_DEVICE_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceEventTypeEXT; + +typedef enum VkDisplayEventTypeEXT { + VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT = 0, + VK_DISPLAY_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDisplayEventTypeEXT; +typedef struct VkDisplayPowerInfoEXT { + VkStructureType sType; + const void* pNext; + VkDisplayPowerStateEXT powerState; +} VkDisplayPowerInfoEXT; + +typedef struct VkDeviceEventInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceEventTypeEXT deviceEvent; +} VkDeviceEventInfoEXT; + +typedef struct VkDisplayEventInfoEXT { + VkStructureType sType; + const void* pNext; + VkDisplayEventTypeEXT displayEvent; +} VkDisplayEventInfoEXT; + +typedef struct VkSwapchainCounterCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkSurfaceCounterFlagsEXT surfaceCounters; +} VkSwapchainCounterCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkDisplayPowerControlEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayPowerInfoEXT* pDisplayPowerInfo); +typedef VkResult (VKAPI_PTR *PFN_vkRegisterDeviceEventEXT)(VkDevice device, const VkDeviceEventInfoEXT* pDeviceEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); +typedef VkResult (VKAPI_PTR *PFN_vkRegisterDisplayEventEXT)(VkDevice device, VkDisplayKHR display, const VkDisplayEventInfoEXT* pDisplayEventInfo, const VkAllocationCallbacks* pAllocator, VkFence* pFence); +typedef VkResult (VKAPI_PTR *PFN_vkGetSwapchainCounterEXT)(VkDevice device, VkSwapchainKHR swapchain, VkSurfaceCounterFlagBitsEXT counter, uint64_t* pCounterValue); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkDisplayPowerControlEXT( + VkDevice device, + VkDisplayKHR display, + const VkDisplayPowerInfoEXT* pDisplayPowerInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDeviceEventEXT( + VkDevice device, + const VkDeviceEventInfoEXT* pDeviceEventInfo, + const VkAllocationCallbacks* pAllocator, + VkFence* pFence); + +VKAPI_ATTR VkResult VKAPI_CALL vkRegisterDisplayEventEXT( + VkDevice device, + VkDisplayKHR display, + const VkDisplayEventInfoEXT* pDisplayEventInfo, + const VkAllocationCallbacks* pAllocator, + VkFence* pFence); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainCounterEXT( + VkDevice device, + VkSwapchainKHR swapchain, + VkSurfaceCounterFlagBitsEXT counter, + uint64_t* pCounterValue); +#endif + + +// VK_GOOGLE_display_timing is a preprocessor guard. Do not pass it to API calls. +#define VK_GOOGLE_display_timing 1 +#define VK_GOOGLE_DISPLAY_TIMING_SPEC_VERSION 1 +#define VK_GOOGLE_DISPLAY_TIMING_EXTENSION_NAME "VK_GOOGLE_display_timing" +typedef struct VkRefreshCycleDurationGOOGLE { + uint64_t refreshDuration; +} VkRefreshCycleDurationGOOGLE; + +typedef struct VkPastPresentationTimingGOOGLE { + uint32_t presentID; + uint64_t desiredPresentTime; + uint64_t actualPresentTime; + uint64_t earliestPresentTime; + uint64_t presentMargin; +} VkPastPresentationTimingGOOGLE; + +typedef struct VkPresentTimeGOOGLE { + uint32_t presentID; + uint64_t desiredPresentTime; +} VkPresentTimeGOOGLE; + +typedef struct VkPresentTimesInfoGOOGLE { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkPresentTimeGOOGLE* pTimes; +} VkPresentTimesInfoGOOGLE; + +typedef VkResult (VKAPI_PTR *PFN_vkGetRefreshCycleDurationGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetPastPresentationTimingGOOGLE)(VkDevice device, VkSwapchainKHR swapchain, uint32_t* pPresentationTimingCount, VkPastPresentationTimingGOOGLE* pPresentationTimings); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetRefreshCycleDurationGOOGLE( + VkDevice device, + VkSwapchainKHR swapchain, + VkRefreshCycleDurationGOOGLE* pDisplayTimingProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPastPresentationTimingGOOGLE( + VkDevice device, + VkSwapchainKHR swapchain, + uint32_t* pPresentationTimingCount, + VkPastPresentationTimingGOOGLE* pPresentationTimings); +#endif + + +// VK_NV_sample_mask_override_coverage is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_sample_mask_override_coverage 1 +#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_SPEC_VERSION 1 +#define VK_NV_SAMPLE_MASK_OVERRIDE_COVERAGE_EXTENSION_NAME "VK_NV_sample_mask_override_coverage" + + +// VK_NV_geometry_shader_passthrough is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_geometry_shader_passthrough 1 +#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_SPEC_VERSION 1 +#define VK_NV_GEOMETRY_SHADER_PASSTHROUGH_EXTENSION_NAME "VK_NV_geometry_shader_passthrough" + + +// VK_NV_viewport_array2 is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_viewport_array2 1 +#define VK_NV_VIEWPORT_ARRAY_2_SPEC_VERSION 1 +#define VK_NV_VIEWPORT_ARRAY_2_EXTENSION_NAME "VK_NV_viewport_array2" +#define VK_NV_VIEWPORT_ARRAY2_SPEC_VERSION VK_NV_VIEWPORT_ARRAY_2_SPEC_VERSION +#define VK_NV_VIEWPORT_ARRAY2_EXTENSION_NAME VK_NV_VIEWPORT_ARRAY_2_EXTENSION_NAME + + +// VK_NVX_multiview_per_view_attributes is a preprocessor guard. Do not pass it to API calls. +#define VK_NVX_multiview_per_view_attributes 1 +#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_SPEC_VERSION 1 +#define VK_NVX_MULTIVIEW_PER_VIEW_ATTRIBUTES_EXTENSION_NAME "VK_NVX_multiview_per_view_attributes" +typedef struct VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX { + VkStructureType sType; + void* pNext; + VkBool32 perViewPositionAllComponents; +} VkPhysicalDeviceMultiviewPerViewAttributesPropertiesNVX; + + + +// VK_NV_viewport_swizzle is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_viewport_swizzle 1 +#define VK_NV_VIEWPORT_SWIZZLE_SPEC_VERSION 1 +#define VK_NV_VIEWPORT_SWIZZLE_EXTENSION_NAME "VK_NV_viewport_swizzle" + +typedef enum VkViewportCoordinateSwizzleNV { + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_X_NV = 0, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_X_NV = 1, + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Y_NV = 2, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Y_NV = 3, + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_Z_NV = 4, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_Z_NV = 5, + VK_VIEWPORT_COORDINATE_SWIZZLE_POSITIVE_W_NV = 6, + VK_VIEWPORT_COORDINATE_SWIZZLE_NEGATIVE_W_NV = 7, + VK_VIEWPORT_COORDINATE_SWIZZLE_MAX_ENUM_NV = 0x7FFFFFFF +} VkViewportCoordinateSwizzleNV; +typedef VkFlags VkPipelineViewportSwizzleStateCreateFlagsNV; +typedef struct VkViewportSwizzleNV { + VkViewportCoordinateSwizzleNV x; + VkViewportCoordinateSwizzleNV y; + VkViewportCoordinateSwizzleNV z; + VkViewportCoordinateSwizzleNV w; +} VkViewportSwizzleNV; + +typedef struct VkPipelineViewportSwizzleStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineViewportSwizzleStateCreateFlagsNV flags; + uint32_t viewportCount; + const VkViewportSwizzleNV* pViewportSwizzles; +} VkPipelineViewportSwizzleStateCreateInfoNV; + + + +// VK_EXT_discard_rectangles is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_discard_rectangles 1 +#define VK_EXT_DISCARD_RECTANGLES_SPEC_VERSION 2 +#define VK_EXT_DISCARD_RECTANGLES_EXTENSION_NAME "VK_EXT_discard_rectangles" + +typedef enum VkDiscardRectangleModeEXT { + VK_DISCARD_RECTANGLE_MODE_INCLUSIVE_EXT = 0, + VK_DISCARD_RECTANGLE_MODE_EXCLUSIVE_EXT = 1, + VK_DISCARD_RECTANGLE_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDiscardRectangleModeEXT; +typedef VkFlags VkPipelineDiscardRectangleStateCreateFlagsEXT; +typedef struct VkPhysicalDeviceDiscardRectanglePropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxDiscardRectangles; +} VkPhysicalDeviceDiscardRectanglePropertiesEXT; + +typedef struct VkPipelineDiscardRectangleStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineDiscardRectangleStateCreateFlagsEXT flags; + VkDiscardRectangleModeEXT discardRectangleMode; + uint32_t discardRectangleCount; + const VkRect2D* pDiscardRectangles; +} VkPipelineDiscardRectangleStateCreateInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEXT)(VkCommandBuffer commandBuffer, uint32_t firstDiscardRectangle, uint32_t discardRectangleCount, const VkRect2D* pDiscardRectangles); +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 discardRectangleEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDiscardRectangleModeEXT)(VkCommandBuffer commandBuffer, VkDiscardRectangleModeEXT discardRectangleMode); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEXT( + VkCommandBuffer commandBuffer, + uint32_t firstDiscardRectangle, + uint32_t discardRectangleCount, + const VkRect2D* pDiscardRectangles); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 discardRectangleEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDiscardRectangleModeEXT( + VkCommandBuffer commandBuffer, + VkDiscardRectangleModeEXT discardRectangleMode); +#endif + + +// VK_EXT_conservative_rasterization is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_conservative_rasterization 1 +#define VK_EXT_CONSERVATIVE_RASTERIZATION_SPEC_VERSION 1 +#define VK_EXT_CONSERVATIVE_RASTERIZATION_EXTENSION_NAME "VK_EXT_conservative_rasterization" + +typedef enum VkConservativeRasterizationModeEXT { + VK_CONSERVATIVE_RASTERIZATION_MODE_DISABLED_EXT = 0, + VK_CONSERVATIVE_RASTERIZATION_MODE_OVERESTIMATE_EXT = 1, + VK_CONSERVATIVE_RASTERIZATION_MODE_UNDERESTIMATE_EXT = 2, + VK_CONSERVATIVE_RASTERIZATION_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkConservativeRasterizationModeEXT; +typedef VkFlags VkPipelineRasterizationConservativeStateCreateFlagsEXT; +typedef struct VkPhysicalDeviceConservativeRasterizationPropertiesEXT { + VkStructureType sType; + void* pNext; + float primitiveOverestimationSize; + float maxExtraPrimitiveOverestimationSize; + float extraPrimitiveOverestimationSizeGranularity; + VkBool32 primitiveUnderestimation; + VkBool32 conservativePointAndLineRasterization; + VkBool32 degenerateTrianglesRasterized; + VkBool32 degenerateLinesRasterized; + VkBool32 fullyCoveredFragmentShaderInputVariable; + VkBool32 conservativeRasterizationPostDepthCoverage; +} VkPhysicalDeviceConservativeRasterizationPropertiesEXT; + +typedef struct VkPipelineRasterizationConservativeStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationConservativeStateCreateFlagsEXT flags; + VkConservativeRasterizationModeEXT conservativeRasterizationMode; + float extraPrimitiveOverestimationSize; +} VkPipelineRasterizationConservativeStateCreateInfoEXT; + + + +// VK_EXT_depth_clip_enable is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_depth_clip_enable 1 +#define VK_EXT_DEPTH_CLIP_ENABLE_SPEC_VERSION 1 +#define VK_EXT_DEPTH_CLIP_ENABLE_EXTENSION_NAME "VK_EXT_depth_clip_enable" +typedef VkFlags VkPipelineRasterizationDepthClipStateCreateFlagsEXT; +typedef struct VkPhysicalDeviceDepthClipEnableFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 depthClipEnable; +} VkPhysicalDeviceDepthClipEnableFeaturesEXT; + +typedef struct VkPipelineRasterizationDepthClipStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPipelineRasterizationDepthClipStateCreateFlagsEXT flags; + VkBool32 depthClipEnable; +} VkPipelineRasterizationDepthClipStateCreateInfoEXT; + + + +// VK_EXT_swapchain_colorspace is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_swapchain_colorspace 1 +#define VK_EXT_SWAPCHAIN_COLOR_SPACE_SPEC_VERSION 4 +#define VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME "VK_EXT_swapchain_colorspace" + + +// VK_EXT_hdr_metadata is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_hdr_metadata 1 +#define VK_EXT_HDR_METADATA_SPEC_VERSION 2 +#define VK_EXT_HDR_METADATA_EXTENSION_NAME "VK_EXT_hdr_metadata" +typedef struct VkXYColorEXT { + float x; + float y; +} VkXYColorEXT; + +typedef struct VkHdrMetadataEXT { + VkStructureType sType; + const void* pNext; + VkXYColorEXT displayPrimaryRed; + VkXYColorEXT displayPrimaryGreen; + VkXYColorEXT displayPrimaryBlue; + VkXYColorEXT whitePoint; + float maxLuminance; + float minLuminance; + float maxContentLightLevel; + float maxFrameAverageLightLevel; +} VkHdrMetadataEXT; + +typedef void (VKAPI_PTR *PFN_vkSetHdrMetadataEXT)(VkDevice device, uint32_t swapchainCount, const VkSwapchainKHR* pSwapchains, const VkHdrMetadataEXT* pMetadata); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkSetHdrMetadataEXT( + VkDevice device, + uint32_t swapchainCount, + const VkSwapchainKHR* pSwapchains, + const VkHdrMetadataEXT* pMetadata); +#endif + + +// VK_IMG_relaxed_line_rasterization is a preprocessor guard. Do not pass it to API calls. +#define VK_IMG_relaxed_line_rasterization 1 +#define VK_IMG_RELAXED_LINE_RASTERIZATION_SPEC_VERSION 1 +#define VK_IMG_RELAXED_LINE_RASTERIZATION_EXTENSION_NAME "VK_IMG_relaxed_line_rasterization" +typedef struct VkPhysicalDeviceRelaxedLineRasterizationFeaturesIMG { + VkStructureType sType; + void* pNext; + VkBool32 relaxedLineRasterization; +} VkPhysicalDeviceRelaxedLineRasterizationFeaturesIMG; + + + +// VK_EXT_external_memory_dma_buf is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_external_memory_dma_buf 1 +#define VK_EXT_EXTERNAL_MEMORY_DMA_BUF_SPEC_VERSION 1 +#define VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME "VK_EXT_external_memory_dma_buf" + + +// VK_EXT_queue_family_foreign is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_queue_family_foreign 1 +#define VK_EXT_QUEUE_FAMILY_FOREIGN_SPEC_VERSION 1 +#define VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME "VK_EXT_queue_family_foreign" +#define VK_QUEUE_FAMILY_FOREIGN_EXT (~2U) + + +// VK_EXT_debug_utils is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_debug_utils 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkDebugUtilsMessengerEXT) +#define VK_EXT_DEBUG_UTILS_SPEC_VERSION 2 +#define VK_EXT_DEBUG_UTILS_EXTENSION_NAME "VK_EXT_debug_utils" +typedef VkFlags VkDebugUtilsMessengerCallbackDataFlagsEXT; + +typedef enum VkDebugUtilsMessageSeverityFlagBitsEXT { + VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT = 0x00000001, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT = 0x00000010, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT = 0x00000100, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT = 0x00001000, + VK_DEBUG_UTILS_MESSAGE_SEVERITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugUtilsMessageSeverityFlagBitsEXT; + +typedef enum VkDebugUtilsMessageTypeFlagBitsEXT { + VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT = 0x00000001, + VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT = 0x00000002, + VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT = 0x00000004, + VK_DEBUG_UTILS_MESSAGE_TYPE_DEVICE_ADDRESS_BINDING_BIT_EXT = 0x00000008, + VK_DEBUG_UTILS_MESSAGE_TYPE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDebugUtilsMessageTypeFlagBitsEXT; +typedef VkFlags VkDebugUtilsMessageTypeFlagsEXT; +typedef VkFlags VkDebugUtilsMessageSeverityFlagsEXT; +typedef VkFlags VkDebugUtilsMessengerCreateFlagsEXT; +typedef struct VkDebugUtilsLabelEXT { + VkStructureType sType; + const void* pNext; + const char* pLabelName; + float color[4]; +} VkDebugUtilsLabelEXT; + +typedef struct VkDebugUtilsObjectNameInfoEXT { + VkStructureType sType; + const void* pNext; + VkObjectType objectType; + uint64_t objectHandle; + const char* pObjectName; +} VkDebugUtilsObjectNameInfoEXT; + +typedef struct VkDebugUtilsMessengerCallbackDataEXT { + VkStructureType sType; + const void* pNext; + VkDebugUtilsMessengerCallbackDataFlagsEXT flags; + const char* pMessageIdName; + int32_t messageIdNumber; + const char* pMessage; + uint32_t queueLabelCount; + const VkDebugUtilsLabelEXT* pQueueLabels; + uint32_t cmdBufLabelCount; + const VkDebugUtilsLabelEXT* pCmdBufLabels; + uint32_t objectCount; + const VkDebugUtilsObjectNameInfoEXT* pObjects; +} VkDebugUtilsMessengerCallbackDataEXT; + +typedef VkBool32 (VKAPI_PTR *PFN_vkDebugUtilsMessengerCallbackEXT)( + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageTypes, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData, + void* pUserData); + +typedef struct VkDebugUtilsMessengerCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDebugUtilsMessengerCreateFlagsEXT flags; + VkDebugUtilsMessageSeverityFlagsEXT messageSeverity; + VkDebugUtilsMessageTypeFlagsEXT messageType; + PFN_vkDebugUtilsMessengerCallbackEXT pfnUserCallback; + void* pUserData; +} VkDebugUtilsMessengerCreateInfoEXT; + +typedef struct VkDebugUtilsObjectTagInfoEXT { + VkStructureType sType; + const void* pNext; + VkObjectType objectType; + uint64_t objectHandle; + uint64_t tagName; + size_t tagSize; + const void* pTag; +} VkDebugUtilsObjectTagInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkSetDebugUtilsObjectNameEXT)(VkDevice device, const VkDebugUtilsObjectNameInfoEXT* pNameInfo); +typedef VkResult (VKAPI_PTR *PFN_vkSetDebugUtilsObjectTagEXT)(VkDevice device, const VkDebugUtilsObjectTagInfoEXT* pTagInfo); +typedef void (VKAPI_PTR *PFN_vkQueueBeginDebugUtilsLabelEXT)(VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef void (VKAPI_PTR *PFN_vkQueueEndDebugUtilsLabelEXT)(VkQueue queue); +typedef void (VKAPI_PTR *PFN_vkQueueInsertDebugUtilsLabelEXT)(VkQueue queue, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBeginDebugUtilsLabelEXT)(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef void (VKAPI_PTR *PFN_vkCmdEndDebugUtilsLabelEXT)(VkCommandBuffer commandBuffer); +typedef void (VKAPI_PTR *PFN_vkCmdInsertDebugUtilsLabelEXT)(VkCommandBuffer commandBuffer, const VkDebugUtilsLabelEXT* pLabelInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCreateDebugUtilsMessengerEXT)(VkInstance instance, const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkDebugUtilsMessengerEXT* pMessenger); +typedef void (VKAPI_PTR *PFN_vkDestroyDebugUtilsMessengerEXT)(VkInstance instance, VkDebugUtilsMessengerEXT messenger, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkSubmitDebugUtilsMessageEXT)(VkInstance instance, VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectNameEXT( + VkDevice device, + const VkDebugUtilsObjectNameInfoEXT* pNameInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetDebugUtilsObjectTagEXT( + VkDevice device, + const VkDebugUtilsObjectTagInfoEXT* pTagInfo); + +VKAPI_ATTR void VKAPI_CALL vkQueueBeginDebugUtilsLabelEXT( + VkQueue queue, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR void VKAPI_CALL vkQueueEndDebugUtilsLabelEXT( + VkQueue queue); + +VKAPI_ATTR void VKAPI_CALL vkQueueInsertDebugUtilsLabelEXT( + VkQueue queue, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBeginDebugUtilsLabelEXT( + VkCommandBuffer commandBuffer, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdEndDebugUtilsLabelEXT( + VkCommandBuffer commandBuffer); + +VKAPI_ATTR void VKAPI_CALL vkCmdInsertDebugUtilsLabelEXT( + VkCommandBuffer commandBuffer, + const VkDebugUtilsLabelEXT* pLabelInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDebugUtilsMessengerEXT( + VkInstance instance, + const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkDebugUtilsMessengerEXT* pMessenger); + +VKAPI_ATTR void VKAPI_CALL vkDestroyDebugUtilsMessengerEXT( + VkInstance instance, + VkDebugUtilsMessengerEXT messenger, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkSubmitDebugUtilsMessageEXT( + VkInstance instance, + VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, + VkDebugUtilsMessageTypeFlagsEXT messageTypes, + const VkDebugUtilsMessengerCallbackDataEXT* pCallbackData); +#endif + + +// VK_EXT_sampler_filter_minmax is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_sampler_filter_minmax 1 +#define VK_EXT_SAMPLER_FILTER_MINMAX_SPEC_VERSION 2 +#define VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME "VK_EXT_sampler_filter_minmax" +typedef VkSamplerReductionMode VkSamplerReductionModeEXT; + +typedef VkSamplerReductionModeCreateInfo VkSamplerReductionModeCreateInfoEXT; + +typedef VkPhysicalDeviceSamplerFilterMinmaxProperties VkPhysicalDeviceSamplerFilterMinmaxPropertiesEXT; + + + +// VK_AMD_gpu_shader_int16 is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_gpu_shader_int16 1 +#define VK_AMD_GPU_SHADER_INT16_SPEC_VERSION 2 +#define VK_AMD_GPU_SHADER_INT16_EXTENSION_NAME "VK_AMD_gpu_shader_int16" + + +// VK_AMD_mixed_attachment_samples is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_mixed_attachment_samples 1 +#define VK_AMD_MIXED_ATTACHMENT_SAMPLES_SPEC_VERSION 1 +#define VK_AMD_MIXED_ATTACHMENT_SAMPLES_EXTENSION_NAME "VK_AMD_mixed_attachment_samples" + + +// VK_AMD_shader_fragment_mask is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_fragment_mask 1 +#define VK_AMD_SHADER_FRAGMENT_MASK_SPEC_VERSION 1 +#define VK_AMD_SHADER_FRAGMENT_MASK_EXTENSION_NAME "VK_AMD_shader_fragment_mask" + + +// VK_EXT_inline_uniform_block is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_inline_uniform_block 1 +#define VK_EXT_INLINE_UNIFORM_BLOCK_SPEC_VERSION 1 +#define VK_EXT_INLINE_UNIFORM_BLOCK_EXTENSION_NAME "VK_EXT_inline_uniform_block" +typedef VkPhysicalDeviceInlineUniformBlockFeatures VkPhysicalDeviceInlineUniformBlockFeaturesEXT; + +typedef VkPhysicalDeviceInlineUniformBlockProperties VkPhysicalDeviceInlineUniformBlockPropertiesEXT; + +typedef VkWriteDescriptorSetInlineUniformBlock VkWriteDescriptorSetInlineUniformBlockEXT; + +typedef VkDescriptorPoolInlineUniformBlockCreateInfo VkDescriptorPoolInlineUniformBlockCreateInfoEXT; + + + +// VK_EXT_shader_stencil_export is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_stencil_export 1 +#define VK_EXT_SHADER_STENCIL_EXPORT_SPEC_VERSION 1 +#define VK_EXT_SHADER_STENCIL_EXPORT_EXTENSION_NAME "VK_EXT_shader_stencil_export" + + +// VK_EXT_sample_locations is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_sample_locations 1 +#define VK_EXT_SAMPLE_LOCATIONS_SPEC_VERSION 1 +#define VK_EXT_SAMPLE_LOCATIONS_EXTENSION_NAME "VK_EXT_sample_locations" +typedef struct VkSampleLocationEXT { + float x; + float y; +} VkSampleLocationEXT; + +typedef struct VkSampleLocationsInfoEXT { + VkStructureType sType; + const void* pNext; + VkSampleCountFlagBits sampleLocationsPerPixel; + VkExtent2D sampleLocationGridSize; + uint32_t sampleLocationsCount; + const VkSampleLocationEXT* pSampleLocations; +} VkSampleLocationsInfoEXT; + +typedef struct VkAttachmentSampleLocationsEXT { + uint32_t attachmentIndex; + VkSampleLocationsInfoEXT sampleLocationsInfo; +} VkAttachmentSampleLocationsEXT; + +typedef struct VkSubpassSampleLocationsEXT { + uint32_t subpassIndex; + VkSampleLocationsInfoEXT sampleLocationsInfo; +} VkSubpassSampleLocationsEXT; + +typedef struct VkRenderPassSampleLocationsBeginInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t attachmentInitialSampleLocationsCount; + const VkAttachmentSampleLocationsEXT* pAttachmentInitialSampleLocations; + uint32_t postSubpassSampleLocationsCount; + const VkSubpassSampleLocationsEXT* pPostSubpassSampleLocations; +} VkRenderPassSampleLocationsBeginInfoEXT; + +typedef struct VkPipelineSampleLocationsStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 sampleLocationsEnable; + VkSampleLocationsInfoEXT sampleLocationsInfo; +} VkPipelineSampleLocationsStateCreateInfoEXT; + +typedef struct VkPhysicalDeviceSampleLocationsPropertiesEXT { + VkStructureType sType; + void* pNext; + VkSampleCountFlags sampleLocationSampleCounts; + VkExtent2D maxSampleLocationGridSize; + float sampleLocationCoordinateRange[2]; + uint32_t sampleLocationSubPixelBits; + VkBool32 variableSampleLocations; +} VkPhysicalDeviceSampleLocationsPropertiesEXT; + +typedef struct VkMultisamplePropertiesEXT { + VkStructureType sType; + void* pNext; + VkExtent2D maxSampleLocationGridSize; +} VkMultisamplePropertiesEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleLocationsEXT)(VkCommandBuffer commandBuffer, const VkSampleLocationsInfoEXT* pSampleLocationsInfo); +typedef void (VKAPI_PTR *PFN_vkGetPhysicalDeviceMultisamplePropertiesEXT)(VkPhysicalDevice physicalDevice, VkSampleCountFlagBits samples, VkMultisamplePropertiesEXT* pMultisampleProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEXT( + VkCommandBuffer commandBuffer, + const VkSampleLocationsInfoEXT* pSampleLocationsInfo); + +VKAPI_ATTR void VKAPI_CALL vkGetPhysicalDeviceMultisamplePropertiesEXT( + VkPhysicalDevice physicalDevice, + VkSampleCountFlagBits samples, + VkMultisamplePropertiesEXT* pMultisampleProperties); +#endif + + +// VK_EXT_blend_operation_advanced is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_blend_operation_advanced 1 +#define VK_EXT_BLEND_OPERATION_ADVANCED_SPEC_VERSION 2 +#define VK_EXT_BLEND_OPERATION_ADVANCED_EXTENSION_NAME "VK_EXT_blend_operation_advanced" + +typedef enum VkBlendOverlapEXT { + VK_BLEND_OVERLAP_UNCORRELATED_EXT = 0, + VK_BLEND_OVERLAP_DISJOINT_EXT = 1, + VK_BLEND_OVERLAP_CONJOINT_EXT = 2, + VK_BLEND_OVERLAP_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBlendOverlapEXT; +typedef struct VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 advancedBlendCoherentOperations; +} VkPhysicalDeviceBlendOperationAdvancedFeaturesEXT; + +typedef struct VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t advancedBlendMaxColorAttachments; + VkBool32 advancedBlendIndependentBlend; + VkBool32 advancedBlendNonPremultipliedSrcColor; + VkBool32 advancedBlendNonPremultipliedDstColor; + VkBool32 advancedBlendCorrelatedOverlap; + VkBool32 advancedBlendAllOperations; +} VkPhysicalDeviceBlendOperationAdvancedPropertiesEXT; + +typedef struct VkPipelineColorBlendAdvancedStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 srcPremultiplied; + VkBool32 dstPremultiplied; + VkBlendOverlapEXT blendOverlap; +} VkPipelineColorBlendAdvancedStateCreateInfoEXT; + + + +// VK_NV_fragment_coverage_to_color is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_fragment_coverage_to_color 1 +#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_SPEC_VERSION 1 +#define VK_NV_FRAGMENT_COVERAGE_TO_COLOR_EXTENSION_NAME "VK_NV_fragment_coverage_to_color" +typedef VkFlags VkPipelineCoverageToColorStateCreateFlagsNV; +typedef struct VkPipelineCoverageToColorStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCoverageToColorStateCreateFlagsNV flags; + VkBool32 coverageToColorEnable; + uint32_t coverageToColorLocation; +} VkPipelineCoverageToColorStateCreateInfoNV; + + + +// VK_NV_framebuffer_mixed_samples is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_framebuffer_mixed_samples 1 +#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_SPEC_VERSION 1 +#define VK_NV_FRAMEBUFFER_MIXED_SAMPLES_EXTENSION_NAME "VK_NV_framebuffer_mixed_samples" + +typedef enum VkCoverageModulationModeNV { + VK_COVERAGE_MODULATION_MODE_NONE_NV = 0, + VK_COVERAGE_MODULATION_MODE_RGB_NV = 1, + VK_COVERAGE_MODULATION_MODE_ALPHA_NV = 2, + VK_COVERAGE_MODULATION_MODE_RGBA_NV = 3, + VK_COVERAGE_MODULATION_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkCoverageModulationModeNV; +typedef VkFlags VkPipelineCoverageModulationStateCreateFlagsNV; +typedef struct VkPipelineCoverageModulationStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCoverageModulationStateCreateFlagsNV flags; + VkCoverageModulationModeNV coverageModulationMode; + VkBool32 coverageModulationTableEnable; + uint32_t coverageModulationTableCount; + const float* pCoverageModulationTable; +} VkPipelineCoverageModulationStateCreateInfoNV; + + + +// VK_NV_fill_rectangle is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_fill_rectangle 1 +#define VK_NV_FILL_RECTANGLE_SPEC_VERSION 1 +#define VK_NV_FILL_RECTANGLE_EXTENSION_NAME "VK_NV_fill_rectangle" + + +// VK_NV_shader_sm_builtins is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_shader_sm_builtins 1 +#define VK_NV_SHADER_SM_BUILTINS_SPEC_VERSION 1 +#define VK_NV_SHADER_SM_BUILTINS_EXTENSION_NAME "VK_NV_shader_sm_builtins" +typedef struct VkPhysicalDeviceShaderSMBuiltinsPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t shaderSMCount; + uint32_t shaderWarpsPerSM; +} VkPhysicalDeviceShaderSMBuiltinsPropertiesNV; + +typedef struct VkPhysicalDeviceShaderSMBuiltinsFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 shaderSMBuiltins; +} VkPhysicalDeviceShaderSMBuiltinsFeaturesNV; + + + +// VK_EXT_post_depth_coverage is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_post_depth_coverage 1 +#define VK_EXT_POST_DEPTH_COVERAGE_SPEC_VERSION 1 +#define VK_EXT_POST_DEPTH_COVERAGE_EXTENSION_NAME "VK_EXT_post_depth_coverage" + + +// VK_EXT_image_drm_format_modifier is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_drm_format_modifier 1 +#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION 2 +#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME "VK_EXT_image_drm_format_modifier" +typedef struct VkDrmFormatModifierPropertiesEXT { + uint64_t drmFormatModifier; + uint32_t drmFormatModifierPlaneCount; + VkFormatFeatureFlags drmFormatModifierTilingFeatures; +} VkDrmFormatModifierPropertiesEXT; + +typedef struct VkDrmFormatModifierPropertiesListEXT { + VkStructureType sType; + void* pNext; + uint32_t drmFormatModifierCount; + VkDrmFormatModifierPropertiesEXT* pDrmFormatModifierProperties; +} VkDrmFormatModifierPropertiesListEXT; + +typedef struct VkPhysicalDeviceImageDrmFormatModifierInfoEXT { + VkStructureType sType; + const void* pNext; + uint64_t drmFormatModifier; + VkSharingMode sharingMode; + uint32_t queueFamilyIndexCount; + const uint32_t* pQueueFamilyIndices; +} VkPhysicalDeviceImageDrmFormatModifierInfoEXT; + +typedef struct VkImageDrmFormatModifierListCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t drmFormatModifierCount; + const uint64_t* pDrmFormatModifiers; +} VkImageDrmFormatModifierListCreateInfoEXT; + +typedef struct VkImageDrmFormatModifierExplicitCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint64_t drmFormatModifier; + uint32_t drmFormatModifierPlaneCount; + const VkSubresourceLayout* pPlaneLayouts; +} VkImageDrmFormatModifierExplicitCreateInfoEXT; + +typedef struct VkImageDrmFormatModifierPropertiesEXT { + VkStructureType sType; + void* pNext; + uint64_t drmFormatModifier; +} VkImageDrmFormatModifierPropertiesEXT; + +typedef struct VkDrmFormatModifierProperties2EXT { + uint64_t drmFormatModifier; + uint32_t drmFormatModifierPlaneCount; + VkFormatFeatureFlags2 drmFormatModifierTilingFeatures; +} VkDrmFormatModifierProperties2EXT; + +typedef struct VkDrmFormatModifierPropertiesList2EXT { + VkStructureType sType; + void* pNext; + uint32_t drmFormatModifierCount; + VkDrmFormatModifierProperties2EXT* pDrmFormatModifierProperties; +} VkDrmFormatModifierPropertiesList2EXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetImageDrmFormatModifierPropertiesEXT)(VkDevice device, VkImage image, VkImageDrmFormatModifierPropertiesEXT* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageDrmFormatModifierPropertiesEXT( + VkDevice device, + VkImage image, + VkImageDrmFormatModifierPropertiesEXT* pProperties); +#endif + + +// VK_EXT_validation_cache is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_validation_cache 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkValidationCacheEXT) +#define VK_EXT_VALIDATION_CACHE_SPEC_VERSION 1 +#define VK_EXT_VALIDATION_CACHE_EXTENSION_NAME "VK_EXT_validation_cache" + +typedef enum VkValidationCacheHeaderVersionEXT { + VK_VALIDATION_CACHE_HEADER_VERSION_ONE_EXT = 1, + VK_VALIDATION_CACHE_HEADER_VERSION_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationCacheHeaderVersionEXT; +typedef VkFlags VkValidationCacheCreateFlagsEXT; +typedef struct VkValidationCacheCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkValidationCacheCreateFlagsEXT flags; + size_t initialDataSize; + const void* pInitialData; +} VkValidationCacheCreateInfoEXT; + +typedef struct VkShaderModuleValidationCacheCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkValidationCacheEXT validationCache; +} VkShaderModuleValidationCacheCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateValidationCacheEXT)(VkDevice device, const VkValidationCacheCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkValidationCacheEXT* pValidationCache); +typedef void (VKAPI_PTR *PFN_vkDestroyValidationCacheEXT)(VkDevice device, VkValidationCacheEXT validationCache, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkMergeValidationCachesEXT)(VkDevice device, VkValidationCacheEXT dstCache, uint32_t srcCacheCount, const VkValidationCacheEXT* pSrcCaches); +typedef VkResult (VKAPI_PTR *PFN_vkGetValidationCacheDataEXT)(VkDevice device, VkValidationCacheEXT validationCache, size_t* pDataSize, void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateValidationCacheEXT( + VkDevice device, + const VkValidationCacheCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkValidationCacheEXT* pValidationCache); + +VKAPI_ATTR void VKAPI_CALL vkDestroyValidationCacheEXT( + VkDevice device, + VkValidationCacheEXT validationCache, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkMergeValidationCachesEXT( + VkDevice device, + VkValidationCacheEXT dstCache, + uint32_t srcCacheCount, + const VkValidationCacheEXT* pSrcCaches); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetValidationCacheDataEXT( + VkDevice device, + VkValidationCacheEXT validationCache, + size_t* pDataSize, + void* pData); +#endif + + +// VK_EXT_descriptor_indexing is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_descriptor_indexing 1 +#define VK_EXT_DESCRIPTOR_INDEXING_SPEC_VERSION 2 +#define VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME "VK_EXT_descriptor_indexing" +typedef VkDescriptorBindingFlagBits VkDescriptorBindingFlagBitsEXT; + +typedef VkDescriptorBindingFlags VkDescriptorBindingFlagsEXT; + +typedef VkDescriptorSetLayoutBindingFlagsCreateInfo VkDescriptorSetLayoutBindingFlagsCreateInfoEXT; + +typedef VkPhysicalDeviceDescriptorIndexingFeatures VkPhysicalDeviceDescriptorIndexingFeaturesEXT; + +typedef VkPhysicalDeviceDescriptorIndexingProperties VkPhysicalDeviceDescriptorIndexingPropertiesEXT; + +typedef VkDescriptorSetVariableDescriptorCountAllocateInfo VkDescriptorSetVariableDescriptorCountAllocateInfoEXT; + +typedef VkDescriptorSetVariableDescriptorCountLayoutSupport VkDescriptorSetVariableDescriptorCountLayoutSupportEXT; + + + +// VK_EXT_shader_viewport_index_layer is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_viewport_index_layer 1 +#define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_SPEC_VERSION 1 +#define VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME "VK_EXT_shader_viewport_index_layer" + + +// VK_NV_shading_rate_image is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_shading_rate_image 1 +#define VK_NV_SHADING_RATE_IMAGE_SPEC_VERSION 3 +#define VK_NV_SHADING_RATE_IMAGE_EXTENSION_NAME "VK_NV_shading_rate_image" + +typedef enum VkShadingRatePaletteEntryNV { + VK_SHADING_RATE_PALETTE_ENTRY_NO_INVOCATIONS_NV = 0, + VK_SHADING_RATE_PALETTE_ENTRY_16_INVOCATIONS_PER_PIXEL_NV = 1, + VK_SHADING_RATE_PALETTE_ENTRY_8_INVOCATIONS_PER_PIXEL_NV = 2, + VK_SHADING_RATE_PALETTE_ENTRY_4_INVOCATIONS_PER_PIXEL_NV = 3, + VK_SHADING_RATE_PALETTE_ENTRY_2_INVOCATIONS_PER_PIXEL_NV = 4, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_PIXEL_NV = 5, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV = 6, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV = 7, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV = 8, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV = 9, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV = 10, + VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV = 11, + VK_SHADING_RATE_PALETTE_ENTRY_MAX_ENUM_NV = 0x7FFFFFFF +} VkShadingRatePaletteEntryNV; + +typedef enum VkCoarseSampleOrderTypeNV { + VK_COARSE_SAMPLE_ORDER_TYPE_DEFAULT_NV = 0, + VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV = 1, + VK_COARSE_SAMPLE_ORDER_TYPE_PIXEL_MAJOR_NV = 2, + VK_COARSE_SAMPLE_ORDER_TYPE_SAMPLE_MAJOR_NV = 3, + VK_COARSE_SAMPLE_ORDER_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkCoarseSampleOrderTypeNV; +typedef struct VkShadingRatePaletteNV { + uint32_t shadingRatePaletteEntryCount; + const VkShadingRatePaletteEntryNV* pShadingRatePaletteEntries; +} VkShadingRatePaletteNV; + +typedef struct VkPipelineViewportShadingRateImageStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 shadingRateImageEnable; + uint32_t viewportCount; + const VkShadingRatePaletteNV* pShadingRatePalettes; +} VkPipelineViewportShadingRateImageStateCreateInfoNV; + +typedef struct VkPhysicalDeviceShadingRateImageFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 shadingRateImage; + VkBool32 shadingRateCoarseSampleOrder; +} VkPhysicalDeviceShadingRateImageFeaturesNV; + +typedef struct VkPhysicalDeviceShadingRateImagePropertiesNV { + VkStructureType sType; + void* pNext; + VkExtent2D shadingRateTexelSize; + uint32_t shadingRatePaletteSize; + uint32_t shadingRateMaxCoarseSamples; +} VkPhysicalDeviceShadingRateImagePropertiesNV; + +typedef struct VkCoarseSampleLocationNV { + uint32_t pixelX; + uint32_t pixelY; + uint32_t sample; +} VkCoarseSampleLocationNV; + +typedef struct VkCoarseSampleOrderCustomNV { + VkShadingRatePaletteEntryNV shadingRate; + uint32_t sampleCount; + uint32_t sampleLocationCount; + const VkCoarseSampleLocationNV* pSampleLocations; +} VkCoarseSampleOrderCustomNV; + +typedef struct VkPipelineViewportCoarseSampleOrderStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkCoarseSampleOrderTypeNV sampleOrderType; + uint32_t customSampleOrderCount; + const VkCoarseSampleOrderCustomNV* pCustomSampleOrders; +} VkPipelineViewportCoarseSampleOrderStateCreateInfoNV; + +typedef void (VKAPI_PTR *PFN_vkCmdBindShadingRateImageNV)(VkCommandBuffer commandBuffer, VkImageView imageView, VkImageLayout imageLayout); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportShadingRatePaletteNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkShadingRatePaletteNV* pShadingRatePalettes); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoarseSampleOrderNV)(VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, const VkCoarseSampleOrderCustomNV* pCustomSampleOrders); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindShadingRateImageNV( + VkCommandBuffer commandBuffer, + VkImageView imageView, + VkImageLayout imageLayout); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportShadingRatePaletteNV( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkShadingRatePaletteNV* pShadingRatePalettes); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoarseSampleOrderNV( + VkCommandBuffer commandBuffer, + VkCoarseSampleOrderTypeNV sampleOrderType, + uint32_t customSampleOrderCount, + const VkCoarseSampleOrderCustomNV* pCustomSampleOrders); +#endif + + +// VK_NV_ray_tracing is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_ray_tracing 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureNV) +#define VK_NV_RAY_TRACING_SPEC_VERSION 3 +#define VK_NV_RAY_TRACING_EXTENSION_NAME "VK_NV_ray_tracing" +#define VK_SHADER_UNUSED_KHR (~0U) +#define VK_SHADER_UNUSED_NV VK_SHADER_UNUSED_KHR + +typedef enum VkRayTracingShaderGroupTypeKHR { + VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_KHR = 0, + VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR = 1, + VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR = 2, + VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV = VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_KHR, + VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV = VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR, + VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_NV = VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, + VK_RAY_TRACING_SHADER_GROUP_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkRayTracingShaderGroupTypeKHR; +typedef VkRayTracingShaderGroupTypeKHR VkRayTracingShaderGroupTypeNV; + + +typedef enum VkGeometryTypeKHR { + VK_GEOMETRY_TYPE_TRIANGLES_KHR = 0, + VK_GEOMETRY_TYPE_AABBS_KHR = 1, + VK_GEOMETRY_TYPE_INSTANCES_KHR = 2, + VK_GEOMETRY_TYPE_TRIANGLES_NV = VK_GEOMETRY_TYPE_TRIANGLES_KHR, + VK_GEOMETRY_TYPE_AABBS_NV = VK_GEOMETRY_TYPE_AABBS_KHR, + VK_GEOMETRY_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkGeometryTypeKHR; +typedef VkGeometryTypeKHR VkGeometryTypeNV; + + +typedef enum VkAccelerationStructureTypeKHR { + VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR = 0, + VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR = 1, + VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR = 2, + VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV = VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, + VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV = VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR, + VK_ACCELERATION_STRUCTURE_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureTypeKHR; +typedef VkAccelerationStructureTypeKHR VkAccelerationStructureTypeNV; + + +typedef enum VkCopyAccelerationStructureModeKHR { + VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR = 0, + VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR = 1, + VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR = 2, + VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR = 3, + VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_NV = VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR, + VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_NV = VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR, + VK_COPY_ACCELERATION_STRUCTURE_MODE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkCopyAccelerationStructureModeKHR; +typedef VkCopyAccelerationStructureModeKHR VkCopyAccelerationStructureModeNV; + + +typedef enum VkAccelerationStructureMemoryRequirementsTypeNV { + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV = 0, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV = 1, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV = 2, + VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkAccelerationStructureMemoryRequirementsTypeNV; + +typedef enum VkGeometryFlagBitsKHR { + VK_GEOMETRY_OPAQUE_BIT_KHR = 0x00000001, + VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR = 0x00000002, + VK_GEOMETRY_OPAQUE_BIT_NV = VK_GEOMETRY_OPAQUE_BIT_KHR, + VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_NV = VK_GEOMETRY_NO_DUPLICATE_ANY_HIT_INVOCATION_BIT_KHR, + VK_GEOMETRY_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkGeometryFlagBitsKHR; +typedef VkFlags VkGeometryFlagsKHR; +typedef VkGeometryFlagsKHR VkGeometryFlagsNV; + +typedef VkGeometryFlagBitsKHR VkGeometryFlagBitsNV; + + +typedef enum VkGeometryInstanceFlagBitsKHR { + VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR = 0x00000001, + VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR = 0x00000002, + VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR = 0x00000004, + VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR = 0x00000008, + VK_GEOMETRY_INSTANCE_FORCE_OPACITY_MICROMAP_2_STATE_EXT = 0x00000010, + VK_GEOMETRY_INSTANCE_DISABLE_OPACITY_MICROMAPS_EXT = 0x00000020, + VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR = VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR, + VK_GEOMETRY_INSTANCE_TRIANGLE_CULL_DISABLE_BIT_NV = VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR, + VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_NV = VK_GEOMETRY_INSTANCE_TRIANGLE_FRONT_COUNTERCLOCKWISE_BIT_KHR, + VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_NV = VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR, + VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_NV = VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR, + VK_GEOMETRY_INSTANCE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkGeometryInstanceFlagBitsKHR; +typedef VkFlags VkGeometryInstanceFlagsKHR; +typedef VkGeometryInstanceFlagsKHR VkGeometryInstanceFlagsNV; + +typedef VkGeometryInstanceFlagBitsKHR VkGeometryInstanceFlagBitsNV; + + +typedef enum VkBuildAccelerationStructureFlagBitsKHR { + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR = 0x00000001, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR = 0x00000002, + VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR = 0x00000004, + VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR = 0x00000008, + VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR = 0x00000010, + VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV = 0x00000020, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_OPACITY_MICROMAP_UPDATE_EXT = 0x00000040, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISABLE_OPACITY_MICROMAPS_EXT = 0x00000080, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_OPACITY_MICROMAP_DATA_UPDATE_EXT = 0x00000100, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DISPLACEMENT_MICROMAP_UPDATE_NV = 0x00000200, +#endif + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_DATA_ACCESS_KHR = 0x00000800, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_KHR, + VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR, + VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR, + VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR, + VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_NV = VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_KHR, + VK_BUILD_ACCELERATION_STRUCTURE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkBuildAccelerationStructureFlagBitsKHR; +typedef VkFlags VkBuildAccelerationStructureFlagsKHR; +typedef VkBuildAccelerationStructureFlagsKHR VkBuildAccelerationStructureFlagsNV; + +typedef VkBuildAccelerationStructureFlagBitsKHR VkBuildAccelerationStructureFlagBitsNV; + +typedef struct VkRayTracingShaderGroupCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkRayTracingShaderGroupTypeKHR type; + uint32_t generalShader; + uint32_t closestHitShader; + uint32_t anyHitShader; + uint32_t intersectionShader; +} VkRayTracingShaderGroupCreateInfoNV; + +typedef struct VkRayTracingPipelineCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + uint32_t groupCount; + const VkRayTracingShaderGroupCreateInfoNV* pGroups; + uint32_t maxRecursionDepth; + VkPipelineLayout layout; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkRayTracingPipelineCreateInfoNV; + +typedef struct VkGeometryTrianglesNV { + VkStructureType sType; + const void* pNext; + VkBuffer vertexData; + VkDeviceSize vertexOffset; + uint32_t vertexCount; + VkDeviceSize vertexStride; + VkFormat vertexFormat; + VkBuffer indexData; + VkDeviceSize indexOffset; + uint32_t indexCount; + VkIndexType indexType; + VkBuffer transformData; + VkDeviceSize transformOffset; +} VkGeometryTrianglesNV; + +typedef struct VkGeometryAABBNV { + VkStructureType sType; + const void* pNext; + VkBuffer aabbData; + uint32_t numAABBs; + uint32_t stride; + VkDeviceSize offset; +} VkGeometryAABBNV; + +typedef struct VkGeometryDataNV { + VkGeometryTrianglesNV triangles; + VkGeometryAABBNV aabbs; +} VkGeometryDataNV; + +typedef struct VkGeometryNV { + VkStructureType sType; + const void* pNext; + VkGeometryTypeKHR geometryType; + VkGeometryDataNV geometry; + VkGeometryFlagsKHR flags; +} VkGeometryNV; + +typedef struct VkAccelerationStructureInfoNV { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureTypeNV type; + VkBuildAccelerationStructureFlagsNV flags; + uint32_t instanceCount; + uint32_t geometryCount; + const VkGeometryNV* pGeometries; +} VkAccelerationStructureInfoNV; + +typedef struct VkAccelerationStructureCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkDeviceSize compactedSize; + VkAccelerationStructureInfoNV info; +} VkAccelerationStructureCreateInfoNV; + +typedef struct VkBindAccelerationStructureMemoryInfoNV { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureNV accelerationStructure; + VkDeviceMemory memory; + VkDeviceSize memoryOffset; + uint32_t deviceIndexCount; + const uint32_t* pDeviceIndices; +} VkBindAccelerationStructureMemoryInfoNV; + +typedef struct VkWriteDescriptorSetAccelerationStructureNV { + VkStructureType sType; + const void* pNext; + uint32_t accelerationStructureCount; + const VkAccelerationStructureNV* pAccelerationStructures; +} VkWriteDescriptorSetAccelerationStructureNV; + +typedef struct VkAccelerationStructureMemoryRequirementsInfoNV { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureMemoryRequirementsTypeNV type; + VkAccelerationStructureNV accelerationStructure; +} VkAccelerationStructureMemoryRequirementsInfoNV; + +typedef struct VkPhysicalDeviceRayTracingPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t shaderGroupHandleSize; + uint32_t maxRecursionDepth; + uint32_t maxShaderGroupStride; + uint32_t shaderGroupBaseAlignment; + uint64_t maxGeometryCount; + uint64_t maxInstanceCount; + uint64_t maxTriangleCount; + uint32_t maxDescriptorSetAccelerationStructures; +} VkPhysicalDeviceRayTracingPropertiesNV; + +typedef struct VkTransformMatrixKHR { + float matrix[3][4]; +} VkTransformMatrixKHR; + +typedef VkTransformMatrixKHR VkTransformMatrixNV; + +typedef struct VkAabbPositionsKHR { + float minX; + float minY; + float minZ; + float maxX; + float maxY; + float maxZ; +} VkAabbPositionsKHR; + +typedef VkAabbPositionsKHR VkAabbPositionsNV; + +typedef struct VkAccelerationStructureInstanceKHR { + VkTransformMatrixKHR transform; + uint32_t instanceCustomIndex:24; + uint32_t mask:8; + uint32_t instanceShaderBindingTableRecordOffset:24; + VkGeometryInstanceFlagsKHR flags:8; + uint64_t accelerationStructureReference; +} VkAccelerationStructureInstanceKHR; + +typedef VkAccelerationStructureInstanceKHR VkAccelerationStructureInstanceNV; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateAccelerationStructureNV)(VkDevice device, const VkAccelerationStructureCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureNV* pAccelerationStructure); +typedef void (VKAPI_PTR *PFN_vkDestroyAccelerationStructureNV)(VkDevice device, VkAccelerationStructureNV accelerationStructure, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkGetAccelerationStructureMemoryRequirementsNV)(VkDevice device, const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo, VkMemoryRequirements2KHR* pMemoryRequirements); +typedef VkResult (VKAPI_PTR *PFN_vkBindAccelerationStructureMemoryNV)(VkDevice device, uint32_t bindInfoCount, const VkBindAccelerationStructureMemoryInfoNV* pBindInfos); +typedef void (VKAPI_PTR *PFN_vkCmdBuildAccelerationStructureNV)(VkCommandBuffer commandBuffer, const VkAccelerationStructureInfoNV* pInfo, VkBuffer instanceData, VkDeviceSize instanceOffset, VkBool32 update, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkBuffer scratch, VkDeviceSize scratchOffset); +typedef void (VKAPI_PTR *PFN_vkCmdCopyAccelerationStructureNV)(VkCommandBuffer commandBuffer, VkAccelerationStructureNV dst, VkAccelerationStructureNV src, VkCopyAccelerationStructureModeKHR mode); +typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysNV)(VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, uint32_t width, uint32_t height, uint32_t depth); +typedef VkResult (VKAPI_PTR *PFN_vkCreateRayTracingPipelinesNV)(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoNV* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef VkResult (VKAPI_PTR *PFN_vkGetRayTracingShaderGroupHandlesKHR)(VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetRayTracingShaderGroupHandlesNV)(VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetAccelerationStructureHandleNV)(VkDevice device, VkAccelerationStructureNV accelerationStructure, size_t dataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdWriteAccelerationStructuresPropertiesNV)(VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV* pAccelerationStructures, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery); +typedef VkResult (VKAPI_PTR *PFN_vkCompileDeferredNV)(VkDevice device, VkPipeline pipeline, uint32_t shader); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureNV( + VkDevice device, + const VkAccelerationStructureCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkAccelerationStructureNV* pAccelerationStructure); + +VKAPI_ATTR void VKAPI_CALL vkDestroyAccelerationStructureNV( + VkDevice device, + VkAccelerationStructureNV accelerationStructure, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureMemoryRequirementsNV( + VkDevice device, + const VkAccelerationStructureMemoryRequirementsInfoNV* pInfo, + VkMemoryRequirements2KHR* pMemoryRequirements); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindAccelerationStructureMemoryNV( + VkDevice device, + uint32_t bindInfoCount, + const VkBindAccelerationStructureMemoryInfoNV* pBindInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructureNV( + VkCommandBuffer commandBuffer, + const VkAccelerationStructureInfoNV* pInfo, + VkBuffer instanceData, + VkDeviceSize instanceOffset, + VkBool32 update, + VkAccelerationStructureNV dst, + VkAccelerationStructureNV src, + VkBuffer scratch, + VkDeviceSize scratchOffset); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureNV( + VkCommandBuffer commandBuffer, + VkAccelerationStructureNV dst, + VkAccelerationStructureNV src, + VkCopyAccelerationStructureModeKHR mode); + +VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysNV( + VkCommandBuffer commandBuffer, + VkBuffer raygenShaderBindingTableBuffer, + VkDeviceSize raygenShaderBindingOffset, + VkBuffer missShaderBindingTableBuffer, + VkDeviceSize missShaderBindingOffset, + VkDeviceSize missShaderBindingStride, + VkBuffer hitShaderBindingTableBuffer, + VkDeviceSize hitShaderBindingOffset, + VkDeviceSize hitShaderBindingStride, + VkBuffer callableShaderBindingTableBuffer, + VkDeviceSize callableShaderBindingOffset, + VkDeviceSize callableShaderBindingStride, + uint32_t width, + uint32_t height, + uint32_t depth); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesNV( + VkDevice device, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkRayTracingPipelineCreateInfoNV* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingShaderGroupHandlesKHR( + VkDevice device, + VkPipeline pipeline, + uint32_t firstGroup, + uint32_t groupCount, + size_t dataSize, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingShaderGroupHandlesNV( + VkDevice device, + VkPipeline pipeline, + uint32_t firstGroup, + uint32_t groupCount, + size_t dataSize, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetAccelerationStructureHandleNV( + VkDevice device, + VkAccelerationStructureNV accelerationStructure, + size_t dataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteAccelerationStructuresPropertiesNV( + VkCommandBuffer commandBuffer, + uint32_t accelerationStructureCount, + const VkAccelerationStructureNV* pAccelerationStructures, + VkQueryType queryType, + VkQueryPool queryPool, + uint32_t firstQuery); + +VKAPI_ATTR VkResult VKAPI_CALL vkCompileDeferredNV( + VkDevice device, + VkPipeline pipeline, + uint32_t shader); +#endif + + +// VK_NV_representative_fragment_test is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_representative_fragment_test 1 +#define VK_NV_REPRESENTATIVE_FRAGMENT_TEST_SPEC_VERSION 2 +#define VK_NV_REPRESENTATIVE_FRAGMENT_TEST_EXTENSION_NAME "VK_NV_representative_fragment_test" +typedef struct VkPhysicalDeviceRepresentativeFragmentTestFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 representativeFragmentTest; +} VkPhysicalDeviceRepresentativeFragmentTestFeaturesNV; + +typedef struct VkPipelineRepresentativeFragmentTestStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 representativeFragmentTestEnable; +} VkPipelineRepresentativeFragmentTestStateCreateInfoNV; + + + +// VK_EXT_filter_cubic is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_filter_cubic 1 +#define VK_EXT_FILTER_CUBIC_SPEC_VERSION 3 +#define VK_EXT_FILTER_CUBIC_EXTENSION_NAME "VK_EXT_filter_cubic" +typedef struct VkPhysicalDeviceImageViewImageFormatInfoEXT { + VkStructureType sType; + void* pNext; + VkImageViewType imageViewType; +} VkPhysicalDeviceImageViewImageFormatInfoEXT; + +typedef struct VkFilterCubicImageViewImageFormatPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 filterCubic; + VkBool32 filterCubicMinmax; +} VkFilterCubicImageViewImageFormatPropertiesEXT; + + + +// VK_QCOM_render_pass_shader_resolve is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_render_pass_shader_resolve 1 +#define VK_QCOM_RENDER_PASS_SHADER_RESOLVE_SPEC_VERSION 4 +#define VK_QCOM_RENDER_PASS_SHADER_RESOLVE_EXTENSION_NAME "VK_QCOM_render_pass_shader_resolve" + + +// VK_EXT_global_priority is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_global_priority 1 +#define VK_EXT_GLOBAL_PRIORITY_SPEC_VERSION 2 +#define VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME "VK_EXT_global_priority" +typedef VkQueueGlobalPriorityKHR VkQueueGlobalPriorityEXT; + +typedef VkDeviceQueueGlobalPriorityCreateInfoKHR VkDeviceQueueGlobalPriorityCreateInfoEXT; + + + +// VK_EXT_external_memory_host is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_external_memory_host 1 +#define VK_EXT_EXTERNAL_MEMORY_HOST_SPEC_VERSION 1 +#define VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME "VK_EXT_external_memory_host" +typedef struct VkImportMemoryHostPointerInfoEXT { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; + void* pHostPointer; +} VkImportMemoryHostPointerInfoEXT; + +typedef struct VkMemoryHostPointerPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; +} VkMemoryHostPointerPropertiesEXT; + +typedef struct VkPhysicalDeviceExternalMemoryHostPropertiesEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize minImportedHostPointerAlignment; +} VkPhysicalDeviceExternalMemoryHostPropertiesEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryHostPointerPropertiesEXT)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, const void* pHostPointer, VkMemoryHostPointerPropertiesEXT* pMemoryHostPointerProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryHostPointerPropertiesEXT( + VkDevice device, + VkExternalMemoryHandleTypeFlagBits handleType, + const void* pHostPointer, + VkMemoryHostPointerPropertiesEXT* pMemoryHostPointerProperties); +#endif + + +// VK_AMD_buffer_marker is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_buffer_marker 1 +#define VK_AMD_BUFFER_MARKER_SPEC_VERSION 1 +#define VK_AMD_BUFFER_MARKER_EXTENSION_NAME "VK_AMD_buffer_marker" +typedef void (VKAPI_PTR *PFN_vkCmdWriteBufferMarkerAMD)(VkCommandBuffer commandBuffer, VkPipelineStageFlagBits pipelineStage, VkBuffer dstBuffer, VkDeviceSize dstOffset, uint32_t marker); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdWriteBufferMarkerAMD( + VkCommandBuffer commandBuffer, + VkPipelineStageFlagBits pipelineStage, + VkBuffer dstBuffer, + VkDeviceSize dstOffset, + uint32_t marker); +#endif + + +// VK_AMD_pipeline_compiler_control is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_pipeline_compiler_control 1 +#define VK_AMD_PIPELINE_COMPILER_CONTROL_SPEC_VERSION 1 +#define VK_AMD_PIPELINE_COMPILER_CONTROL_EXTENSION_NAME "VK_AMD_pipeline_compiler_control" + +typedef enum VkPipelineCompilerControlFlagBitsAMD { + VK_PIPELINE_COMPILER_CONTROL_FLAG_BITS_MAX_ENUM_AMD = 0x7FFFFFFF +} VkPipelineCompilerControlFlagBitsAMD; +typedef VkFlags VkPipelineCompilerControlFlagsAMD; +typedef struct VkPipelineCompilerControlCreateInfoAMD { + VkStructureType sType; + const void* pNext; + VkPipelineCompilerControlFlagsAMD compilerControlFlags; +} VkPipelineCompilerControlCreateInfoAMD; + + + +// VK_EXT_calibrated_timestamps is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_calibrated_timestamps 1 +#define VK_EXT_CALIBRATED_TIMESTAMPS_SPEC_VERSION 2 +#define VK_EXT_CALIBRATED_TIMESTAMPS_EXTENSION_NAME "VK_EXT_calibrated_timestamps" +typedef VkTimeDomainKHR VkTimeDomainEXT; + +typedef VkCalibratedTimestampInfoKHR VkCalibratedTimestampInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)(VkPhysicalDevice physicalDevice, uint32_t* pTimeDomainCount, VkTimeDomainKHR* pTimeDomains); +typedef VkResult (VKAPI_PTR *PFN_vkGetCalibratedTimestampsEXT)(VkDevice device, uint32_t timestampCount, const VkCalibratedTimestampInfoKHR* pTimestampInfos, uint64_t* pTimestamps, uint64_t* pMaxDeviation); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCalibrateableTimeDomainsEXT( + VkPhysicalDevice physicalDevice, + uint32_t* pTimeDomainCount, + VkTimeDomainKHR* pTimeDomains); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetCalibratedTimestampsEXT( + VkDevice device, + uint32_t timestampCount, + const VkCalibratedTimestampInfoKHR* pTimestampInfos, + uint64_t* pTimestamps, + uint64_t* pMaxDeviation); +#endif + + +// VK_AMD_shader_core_properties is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_core_properties 1 +#define VK_AMD_SHADER_CORE_PROPERTIES_SPEC_VERSION 2 +#define VK_AMD_SHADER_CORE_PROPERTIES_EXTENSION_NAME "VK_AMD_shader_core_properties" +typedef struct VkPhysicalDeviceShaderCorePropertiesAMD { + VkStructureType sType; + void* pNext; + uint32_t shaderEngineCount; + uint32_t shaderArraysPerEngineCount; + uint32_t computeUnitsPerShaderArray; + uint32_t simdPerComputeUnit; + uint32_t wavefrontsPerSimd; + uint32_t wavefrontSize; + uint32_t sgprsPerSimd; + uint32_t minSgprAllocation; + uint32_t maxSgprAllocation; + uint32_t sgprAllocationGranularity; + uint32_t vgprsPerSimd; + uint32_t minVgprAllocation; + uint32_t maxVgprAllocation; + uint32_t vgprAllocationGranularity; +} VkPhysicalDeviceShaderCorePropertiesAMD; + + + +// VK_AMD_memory_overallocation_behavior is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_memory_overallocation_behavior 1 +#define VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_SPEC_VERSION 1 +#define VK_AMD_MEMORY_OVERALLOCATION_BEHAVIOR_EXTENSION_NAME "VK_AMD_memory_overallocation_behavior" + +typedef enum VkMemoryOverallocationBehaviorAMD { + VK_MEMORY_OVERALLOCATION_BEHAVIOR_DEFAULT_AMD = 0, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_ALLOWED_AMD = 1, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_DISALLOWED_AMD = 2, + VK_MEMORY_OVERALLOCATION_BEHAVIOR_MAX_ENUM_AMD = 0x7FFFFFFF +} VkMemoryOverallocationBehaviorAMD; +typedef struct VkDeviceMemoryOverallocationCreateInfoAMD { + VkStructureType sType; + const void* pNext; + VkMemoryOverallocationBehaviorAMD overallocationBehavior; +} VkDeviceMemoryOverallocationCreateInfoAMD; + + + +// VK_EXT_vertex_attribute_divisor is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_vertex_attribute_divisor 1 +#define VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_SPEC_VERSION 3 +#define VK_EXT_VERTEX_ATTRIBUTE_DIVISOR_EXTENSION_NAME "VK_EXT_vertex_attribute_divisor" +typedef struct VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxVertexAttribDivisor; +} VkPhysicalDeviceVertexAttributeDivisorPropertiesEXT; + +typedef VkVertexInputBindingDivisorDescriptionKHR VkVertexInputBindingDivisorDescriptionEXT; + +typedef VkPipelineVertexInputDivisorStateCreateInfoKHR VkPipelineVertexInputDivisorStateCreateInfoEXT; + +typedef VkPhysicalDeviceVertexAttributeDivisorFeaturesKHR VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT; + + + +// VK_EXT_pipeline_creation_feedback is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_creation_feedback 1 +#define VK_EXT_PIPELINE_CREATION_FEEDBACK_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_CREATION_FEEDBACK_EXTENSION_NAME "VK_EXT_pipeline_creation_feedback" +typedef VkPipelineCreationFeedbackFlagBits VkPipelineCreationFeedbackFlagBitsEXT; + +typedef VkPipelineCreationFeedbackFlags VkPipelineCreationFeedbackFlagsEXT; + +typedef VkPipelineCreationFeedbackCreateInfo VkPipelineCreationFeedbackCreateInfoEXT; + +typedef VkPipelineCreationFeedback VkPipelineCreationFeedbackEXT; + + + +// VK_NV_shader_subgroup_partitioned is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_shader_subgroup_partitioned 1 +#define VK_NV_SHADER_SUBGROUP_PARTITIONED_SPEC_VERSION 1 +#define VK_NV_SHADER_SUBGROUP_PARTITIONED_EXTENSION_NAME "VK_NV_shader_subgroup_partitioned" + + +// VK_NV_compute_shader_derivatives is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_compute_shader_derivatives 1 +#define VK_NV_COMPUTE_SHADER_DERIVATIVES_SPEC_VERSION 1 +#define VK_NV_COMPUTE_SHADER_DERIVATIVES_EXTENSION_NAME "VK_NV_compute_shader_derivatives" +typedef struct VkPhysicalDeviceComputeShaderDerivativesFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 computeDerivativeGroupQuads; + VkBool32 computeDerivativeGroupLinear; +} VkPhysicalDeviceComputeShaderDerivativesFeaturesNV; + + + +// VK_NV_mesh_shader is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_mesh_shader 1 +#define VK_NV_MESH_SHADER_SPEC_VERSION 1 +#define VK_NV_MESH_SHADER_EXTENSION_NAME "VK_NV_mesh_shader" +typedef struct VkPhysicalDeviceMeshShaderFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 taskShader; + VkBool32 meshShader; +} VkPhysicalDeviceMeshShaderFeaturesNV; + +typedef struct VkPhysicalDeviceMeshShaderPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t maxDrawMeshTasksCount; + uint32_t maxTaskWorkGroupInvocations; + uint32_t maxTaskWorkGroupSize[3]; + uint32_t maxTaskTotalMemorySize; + uint32_t maxTaskOutputCount; + uint32_t maxMeshWorkGroupInvocations; + uint32_t maxMeshWorkGroupSize[3]; + uint32_t maxMeshTotalMemorySize; + uint32_t maxMeshOutputVertices; + uint32_t maxMeshOutputPrimitives; + uint32_t maxMeshMultiviewViewCount; + uint32_t meshOutputPerVertexGranularity; + uint32_t meshOutputPerPrimitiveGranularity; +} VkPhysicalDeviceMeshShaderPropertiesNV; + +typedef struct VkDrawMeshTasksIndirectCommandNV { + uint32_t taskCount; + uint32_t firstTask; +} VkDrawMeshTasksIndirectCommandNV; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksNV)(VkCommandBuffer commandBuffer, uint32_t taskCount, uint32_t firstTask); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectNV)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectCountNV)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksNV( + VkCommandBuffer commandBuffer, + uint32_t taskCount, + uint32_t firstTask); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectNV( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountNV( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + + +// VK_NV_fragment_shader_barycentric is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_fragment_shader_barycentric 1 +#define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_SPEC_VERSION 1 +#define VK_NV_FRAGMENT_SHADER_BARYCENTRIC_EXTENSION_NAME "VK_NV_fragment_shader_barycentric" +typedef VkPhysicalDeviceFragmentShaderBarycentricFeaturesKHR VkPhysicalDeviceFragmentShaderBarycentricFeaturesNV; + + + +// VK_NV_shader_image_footprint is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_shader_image_footprint 1 +#define VK_NV_SHADER_IMAGE_FOOTPRINT_SPEC_VERSION 2 +#define VK_NV_SHADER_IMAGE_FOOTPRINT_EXTENSION_NAME "VK_NV_shader_image_footprint" +typedef struct VkPhysicalDeviceShaderImageFootprintFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 imageFootprint; +} VkPhysicalDeviceShaderImageFootprintFeaturesNV; + + + +// VK_NV_scissor_exclusive is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_scissor_exclusive 1 +#define VK_NV_SCISSOR_EXCLUSIVE_SPEC_VERSION 2 +#define VK_NV_SCISSOR_EXCLUSIVE_EXTENSION_NAME "VK_NV_scissor_exclusive" +typedef struct VkPipelineViewportExclusiveScissorStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t exclusiveScissorCount; + const VkRect2D* pExclusiveScissors; +} VkPipelineViewportExclusiveScissorStateCreateInfoNV; + +typedef struct VkPhysicalDeviceExclusiveScissorFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 exclusiveScissor; +} VkPhysicalDeviceExclusiveScissorFeaturesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetExclusiveScissorEnableNV)(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkBool32* pExclusiveScissorEnables); +typedef void (VKAPI_PTR *PFN_vkCmdSetExclusiveScissorNV)(VkCommandBuffer commandBuffer, uint32_t firstExclusiveScissor, uint32_t exclusiveScissorCount, const VkRect2D* pExclusiveScissors); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorEnableNV( + VkCommandBuffer commandBuffer, + uint32_t firstExclusiveScissor, + uint32_t exclusiveScissorCount, + const VkBool32* pExclusiveScissorEnables); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetExclusiveScissorNV( + VkCommandBuffer commandBuffer, + uint32_t firstExclusiveScissor, + uint32_t exclusiveScissorCount, + const VkRect2D* pExclusiveScissors); +#endif + + +// VK_NV_device_diagnostic_checkpoints is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_device_diagnostic_checkpoints 1 +#define VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_SPEC_VERSION 2 +#define VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME "VK_NV_device_diagnostic_checkpoints" +typedef struct VkQueueFamilyCheckpointPropertiesNV { + VkStructureType sType; + void* pNext; + VkPipelineStageFlags checkpointExecutionStageMask; +} VkQueueFamilyCheckpointPropertiesNV; + +typedef struct VkCheckpointDataNV { + VkStructureType sType; + void* pNext; + VkPipelineStageFlagBits stage; + void* pCheckpointMarker; +} VkCheckpointDataNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetCheckpointNV)(VkCommandBuffer commandBuffer, const void* pCheckpointMarker); +typedef void (VKAPI_PTR *PFN_vkGetQueueCheckpointDataNV)(VkQueue queue, uint32_t* pCheckpointDataCount, VkCheckpointDataNV* pCheckpointData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetCheckpointNV( + VkCommandBuffer commandBuffer, + const void* pCheckpointMarker); + +VKAPI_ATTR void VKAPI_CALL vkGetQueueCheckpointDataNV( + VkQueue queue, + uint32_t* pCheckpointDataCount, + VkCheckpointDataNV* pCheckpointData); +#endif + + +// VK_INTEL_shader_integer_functions2 is a preprocessor guard. Do not pass it to API calls. +#define VK_INTEL_shader_integer_functions2 1 +#define VK_INTEL_SHADER_INTEGER_FUNCTIONS_2_SPEC_VERSION 1 +#define VK_INTEL_SHADER_INTEGER_FUNCTIONS_2_EXTENSION_NAME "VK_INTEL_shader_integer_functions2" +typedef struct VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL { + VkStructureType sType; + void* pNext; + VkBool32 shaderIntegerFunctions2; +} VkPhysicalDeviceShaderIntegerFunctions2FeaturesINTEL; + + + +// VK_INTEL_performance_query is a preprocessor guard. Do not pass it to API calls. +#define VK_INTEL_performance_query 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkPerformanceConfigurationINTEL) +#define VK_INTEL_PERFORMANCE_QUERY_SPEC_VERSION 2 +#define VK_INTEL_PERFORMANCE_QUERY_EXTENSION_NAME "VK_INTEL_performance_query" + +typedef enum VkPerformanceConfigurationTypeINTEL { + VK_PERFORMANCE_CONFIGURATION_TYPE_COMMAND_QUEUE_METRICS_DISCOVERY_ACTIVATED_INTEL = 0, + VK_PERFORMANCE_CONFIGURATION_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceConfigurationTypeINTEL; + +typedef enum VkQueryPoolSamplingModeINTEL { + VK_QUERY_POOL_SAMPLING_MODE_MANUAL_INTEL = 0, + VK_QUERY_POOL_SAMPLING_MODE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkQueryPoolSamplingModeINTEL; + +typedef enum VkPerformanceOverrideTypeINTEL { + VK_PERFORMANCE_OVERRIDE_TYPE_NULL_HARDWARE_INTEL = 0, + VK_PERFORMANCE_OVERRIDE_TYPE_FLUSH_GPU_CACHES_INTEL = 1, + VK_PERFORMANCE_OVERRIDE_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceOverrideTypeINTEL; + +typedef enum VkPerformanceParameterTypeINTEL { + VK_PERFORMANCE_PARAMETER_TYPE_HW_COUNTERS_SUPPORTED_INTEL = 0, + VK_PERFORMANCE_PARAMETER_TYPE_STREAM_MARKER_VALID_BITS_INTEL = 1, + VK_PERFORMANCE_PARAMETER_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceParameterTypeINTEL; + +typedef enum VkPerformanceValueTypeINTEL { + VK_PERFORMANCE_VALUE_TYPE_UINT32_INTEL = 0, + VK_PERFORMANCE_VALUE_TYPE_UINT64_INTEL = 1, + VK_PERFORMANCE_VALUE_TYPE_FLOAT_INTEL = 2, + VK_PERFORMANCE_VALUE_TYPE_BOOL_INTEL = 3, + VK_PERFORMANCE_VALUE_TYPE_STRING_INTEL = 4, + VK_PERFORMANCE_VALUE_TYPE_MAX_ENUM_INTEL = 0x7FFFFFFF +} VkPerformanceValueTypeINTEL; +typedef union VkPerformanceValueDataINTEL { + uint32_t value32; + uint64_t value64; + float valueFloat; + VkBool32 valueBool; + const char* valueString; +} VkPerformanceValueDataINTEL; + +typedef struct VkPerformanceValueINTEL { + VkPerformanceValueTypeINTEL type; + VkPerformanceValueDataINTEL data; +} VkPerformanceValueINTEL; + +typedef struct VkInitializePerformanceApiInfoINTEL { + VkStructureType sType; + const void* pNext; + void* pUserData; +} VkInitializePerformanceApiInfoINTEL; + +typedef struct VkQueryPoolPerformanceQueryCreateInfoINTEL { + VkStructureType sType; + const void* pNext; + VkQueryPoolSamplingModeINTEL performanceCountersSampling; +} VkQueryPoolPerformanceQueryCreateInfoINTEL; + +typedef VkQueryPoolPerformanceQueryCreateInfoINTEL VkQueryPoolCreateInfoINTEL; + +typedef struct VkPerformanceMarkerInfoINTEL { + VkStructureType sType; + const void* pNext; + uint64_t marker; +} VkPerformanceMarkerInfoINTEL; + +typedef struct VkPerformanceStreamMarkerInfoINTEL { + VkStructureType sType; + const void* pNext; + uint32_t marker; +} VkPerformanceStreamMarkerInfoINTEL; + +typedef struct VkPerformanceOverrideInfoINTEL { + VkStructureType sType; + const void* pNext; + VkPerformanceOverrideTypeINTEL type; + VkBool32 enable; + uint64_t parameter; +} VkPerformanceOverrideInfoINTEL; + +typedef struct VkPerformanceConfigurationAcquireInfoINTEL { + VkStructureType sType; + const void* pNext; + VkPerformanceConfigurationTypeINTEL type; +} VkPerformanceConfigurationAcquireInfoINTEL; + +typedef VkResult (VKAPI_PTR *PFN_vkInitializePerformanceApiINTEL)(VkDevice device, const VkInitializePerformanceApiInfoINTEL* pInitializeInfo); +typedef void (VKAPI_PTR *PFN_vkUninitializePerformanceApiINTEL)(VkDevice device); +typedef VkResult (VKAPI_PTR *PFN_vkCmdSetPerformanceMarkerINTEL)(VkCommandBuffer commandBuffer, const VkPerformanceMarkerInfoINTEL* pMarkerInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCmdSetPerformanceStreamMarkerINTEL)(VkCommandBuffer commandBuffer, const VkPerformanceStreamMarkerInfoINTEL* pMarkerInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCmdSetPerformanceOverrideINTEL)(VkCommandBuffer commandBuffer, const VkPerformanceOverrideInfoINTEL* pOverrideInfo); +typedef VkResult (VKAPI_PTR *PFN_vkAcquirePerformanceConfigurationINTEL)(VkDevice device, const VkPerformanceConfigurationAcquireInfoINTEL* pAcquireInfo, VkPerformanceConfigurationINTEL* pConfiguration); +typedef VkResult (VKAPI_PTR *PFN_vkReleasePerformanceConfigurationINTEL)(VkDevice device, VkPerformanceConfigurationINTEL configuration); +typedef VkResult (VKAPI_PTR *PFN_vkQueueSetPerformanceConfigurationINTEL)(VkQueue queue, VkPerformanceConfigurationINTEL configuration); +typedef VkResult (VKAPI_PTR *PFN_vkGetPerformanceParameterINTEL)(VkDevice device, VkPerformanceParameterTypeINTEL parameter, VkPerformanceValueINTEL* pValue); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkInitializePerformanceApiINTEL( + VkDevice device, + const VkInitializePerformanceApiInfoINTEL* pInitializeInfo); + +VKAPI_ATTR void VKAPI_CALL vkUninitializePerformanceApiINTEL( + VkDevice device); + +VKAPI_ATTR VkResult VKAPI_CALL vkCmdSetPerformanceMarkerINTEL( + VkCommandBuffer commandBuffer, + const VkPerformanceMarkerInfoINTEL* pMarkerInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCmdSetPerformanceStreamMarkerINTEL( + VkCommandBuffer commandBuffer, + const VkPerformanceStreamMarkerInfoINTEL* pMarkerInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCmdSetPerformanceOverrideINTEL( + VkCommandBuffer commandBuffer, + const VkPerformanceOverrideInfoINTEL* pOverrideInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquirePerformanceConfigurationINTEL( + VkDevice device, + const VkPerformanceConfigurationAcquireInfoINTEL* pAcquireInfo, + VkPerformanceConfigurationINTEL* pConfiguration); + +VKAPI_ATTR VkResult VKAPI_CALL vkReleasePerformanceConfigurationINTEL( + VkDevice device, + VkPerformanceConfigurationINTEL configuration); + +VKAPI_ATTR VkResult VKAPI_CALL vkQueueSetPerformanceConfigurationINTEL( + VkQueue queue, + VkPerformanceConfigurationINTEL configuration); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetPerformanceParameterINTEL( + VkDevice device, + VkPerformanceParameterTypeINTEL parameter, + VkPerformanceValueINTEL* pValue); +#endif + + +// VK_EXT_pci_bus_info is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pci_bus_info 1 +#define VK_EXT_PCI_BUS_INFO_SPEC_VERSION 2 +#define VK_EXT_PCI_BUS_INFO_EXTENSION_NAME "VK_EXT_pci_bus_info" +typedef struct VkPhysicalDevicePCIBusInfoPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t pciDomain; + uint32_t pciBus; + uint32_t pciDevice; + uint32_t pciFunction; +} VkPhysicalDevicePCIBusInfoPropertiesEXT; + + + +// VK_AMD_display_native_hdr is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_display_native_hdr 1 +#define VK_AMD_DISPLAY_NATIVE_HDR_SPEC_VERSION 1 +#define VK_AMD_DISPLAY_NATIVE_HDR_EXTENSION_NAME "VK_AMD_display_native_hdr" +typedef struct VkDisplayNativeHdrSurfaceCapabilitiesAMD { + VkStructureType sType; + void* pNext; + VkBool32 localDimmingSupport; +} VkDisplayNativeHdrSurfaceCapabilitiesAMD; + +typedef struct VkSwapchainDisplayNativeHdrCreateInfoAMD { + VkStructureType sType; + const void* pNext; + VkBool32 localDimmingEnable; +} VkSwapchainDisplayNativeHdrCreateInfoAMD; + +typedef void (VKAPI_PTR *PFN_vkSetLocalDimmingAMD)(VkDevice device, VkSwapchainKHR swapChain, VkBool32 localDimmingEnable); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkSetLocalDimmingAMD( + VkDevice device, + VkSwapchainKHR swapChain, + VkBool32 localDimmingEnable); +#endif + + +// VK_EXT_fragment_density_map is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_fragment_density_map 1 +#define VK_EXT_FRAGMENT_DENSITY_MAP_SPEC_VERSION 2 +#define VK_EXT_FRAGMENT_DENSITY_MAP_EXTENSION_NAME "VK_EXT_fragment_density_map" +typedef struct VkPhysicalDeviceFragmentDensityMapFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 fragmentDensityMap; + VkBool32 fragmentDensityMapDynamic; + VkBool32 fragmentDensityMapNonSubsampledImages; +} VkPhysicalDeviceFragmentDensityMapFeaturesEXT; + +typedef struct VkPhysicalDeviceFragmentDensityMapPropertiesEXT { + VkStructureType sType; + void* pNext; + VkExtent2D minFragmentDensityTexelSize; + VkExtent2D maxFragmentDensityTexelSize; + VkBool32 fragmentDensityInvocations; +} VkPhysicalDeviceFragmentDensityMapPropertiesEXT; + +typedef struct VkRenderPassFragmentDensityMapCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkAttachmentReference fragmentDensityMapAttachment; +} VkRenderPassFragmentDensityMapCreateInfoEXT; + + + +// VK_EXT_scalar_block_layout is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_scalar_block_layout 1 +#define VK_EXT_SCALAR_BLOCK_LAYOUT_SPEC_VERSION 1 +#define VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME "VK_EXT_scalar_block_layout" +typedef VkPhysicalDeviceScalarBlockLayoutFeatures VkPhysicalDeviceScalarBlockLayoutFeaturesEXT; + + + +// VK_GOOGLE_hlsl_functionality1 is a preprocessor guard. Do not pass it to API calls. +#define VK_GOOGLE_hlsl_functionality1 1 +#define VK_GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION 1 +#define VK_GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME "VK_GOOGLE_hlsl_functionality1" +#define VK_GOOGLE_HLSL_FUNCTIONALITY1_SPEC_VERSION VK_GOOGLE_HLSL_FUNCTIONALITY_1_SPEC_VERSION +#define VK_GOOGLE_HLSL_FUNCTIONALITY1_EXTENSION_NAME VK_GOOGLE_HLSL_FUNCTIONALITY_1_EXTENSION_NAME + + +// VK_GOOGLE_decorate_string is a preprocessor guard. Do not pass it to API calls. +#define VK_GOOGLE_decorate_string 1 +#define VK_GOOGLE_DECORATE_STRING_SPEC_VERSION 1 +#define VK_GOOGLE_DECORATE_STRING_EXTENSION_NAME "VK_GOOGLE_decorate_string" + + +// VK_EXT_subgroup_size_control is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_subgroup_size_control 1 +#define VK_EXT_SUBGROUP_SIZE_CONTROL_SPEC_VERSION 2 +#define VK_EXT_SUBGROUP_SIZE_CONTROL_EXTENSION_NAME "VK_EXT_subgroup_size_control" +typedef VkPhysicalDeviceSubgroupSizeControlFeatures VkPhysicalDeviceSubgroupSizeControlFeaturesEXT; + +typedef VkPhysicalDeviceSubgroupSizeControlProperties VkPhysicalDeviceSubgroupSizeControlPropertiesEXT; + +typedef VkPipelineShaderStageRequiredSubgroupSizeCreateInfo VkPipelineShaderStageRequiredSubgroupSizeCreateInfoEXT; + + + +// VK_AMD_shader_core_properties2 is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_core_properties2 1 +#define VK_AMD_SHADER_CORE_PROPERTIES_2_SPEC_VERSION 1 +#define VK_AMD_SHADER_CORE_PROPERTIES_2_EXTENSION_NAME "VK_AMD_shader_core_properties2" + +typedef enum VkShaderCorePropertiesFlagBitsAMD { + VK_SHADER_CORE_PROPERTIES_FLAG_BITS_MAX_ENUM_AMD = 0x7FFFFFFF +} VkShaderCorePropertiesFlagBitsAMD; +typedef VkFlags VkShaderCorePropertiesFlagsAMD; +typedef struct VkPhysicalDeviceShaderCoreProperties2AMD { + VkStructureType sType; + void* pNext; + VkShaderCorePropertiesFlagsAMD shaderCoreFeatures; + uint32_t activeComputeUnitCount; +} VkPhysicalDeviceShaderCoreProperties2AMD; + + + +// VK_AMD_device_coherent_memory is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_device_coherent_memory 1 +#define VK_AMD_DEVICE_COHERENT_MEMORY_SPEC_VERSION 1 +#define VK_AMD_DEVICE_COHERENT_MEMORY_EXTENSION_NAME "VK_AMD_device_coherent_memory" +typedef struct VkPhysicalDeviceCoherentMemoryFeaturesAMD { + VkStructureType sType; + void* pNext; + VkBool32 deviceCoherentMemory; +} VkPhysicalDeviceCoherentMemoryFeaturesAMD; + + + +// VK_EXT_shader_image_atomic_int64 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_image_atomic_int64 1 +#define VK_EXT_SHADER_IMAGE_ATOMIC_INT64_SPEC_VERSION 1 +#define VK_EXT_SHADER_IMAGE_ATOMIC_INT64_EXTENSION_NAME "VK_EXT_shader_image_atomic_int64" +typedef struct VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderImageInt64Atomics; + VkBool32 sparseImageInt64Atomics; +} VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT; + + + +// VK_EXT_memory_budget is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_memory_budget 1 +#define VK_EXT_MEMORY_BUDGET_SPEC_VERSION 1 +#define VK_EXT_MEMORY_BUDGET_EXTENSION_NAME "VK_EXT_memory_budget" +typedef struct VkPhysicalDeviceMemoryBudgetPropertiesEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize heapBudget[VK_MAX_MEMORY_HEAPS]; + VkDeviceSize heapUsage[VK_MAX_MEMORY_HEAPS]; +} VkPhysicalDeviceMemoryBudgetPropertiesEXT; + + + +// VK_EXT_memory_priority is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_memory_priority 1 +#define VK_EXT_MEMORY_PRIORITY_SPEC_VERSION 1 +#define VK_EXT_MEMORY_PRIORITY_EXTENSION_NAME "VK_EXT_memory_priority" +typedef struct VkPhysicalDeviceMemoryPriorityFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 memoryPriority; +} VkPhysicalDeviceMemoryPriorityFeaturesEXT; + +typedef struct VkMemoryPriorityAllocateInfoEXT { + VkStructureType sType; + const void* pNext; + float priority; +} VkMemoryPriorityAllocateInfoEXT; + + + +// VK_NV_dedicated_allocation_image_aliasing is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_dedicated_allocation_image_aliasing 1 +#define VK_NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_SPEC_VERSION 1 +#define VK_NV_DEDICATED_ALLOCATION_IMAGE_ALIASING_EXTENSION_NAME "VK_NV_dedicated_allocation_image_aliasing" +typedef struct VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 dedicatedAllocationImageAliasing; +} VkPhysicalDeviceDedicatedAllocationImageAliasingFeaturesNV; + + + +// VK_EXT_buffer_device_address is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_buffer_device_address 1 +#define VK_EXT_BUFFER_DEVICE_ADDRESS_SPEC_VERSION 2 +#define VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME "VK_EXT_buffer_device_address" +typedef struct VkPhysicalDeviceBufferDeviceAddressFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 bufferDeviceAddress; + VkBool32 bufferDeviceAddressCaptureReplay; + VkBool32 bufferDeviceAddressMultiDevice; +} VkPhysicalDeviceBufferDeviceAddressFeaturesEXT; + +typedef VkPhysicalDeviceBufferDeviceAddressFeaturesEXT VkPhysicalDeviceBufferAddressFeaturesEXT; + +typedef VkBufferDeviceAddressInfo VkBufferDeviceAddressInfoEXT; + +typedef struct VkBufferDeviceAddressCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceAddress deviceAddress; +} VkBufferDeviceAddressCreateInfoEXT; + +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetBufferDeviceAddressEXT)(VkDevice device, const VkBufferDeviceAddressInfo* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetBufferDeviceAddressEXT( + VkDevice device, + const VkBufferDeviceAddressInfo* pInfo); +#endif + + +// VK_EXT_tooling_info is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_tooling_info 1 +#define VK_EXT_TOOLING_INFO_SPEC_VERSION 1 +#define VK_EXT_TOOLING_INFO_EXTENSION_NAME "VK_EXT_tooling_info" +typedef VkToolPurposeFlagBits VkToolPurposeFlagBitsEXT; + +typedef VkToolPurposeFlags VkToolPurposeFlagsEXT; + +typedef VkPhysicalDeviceToolProperties VkPhysicalDeviceToolPropertiesEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceToolPropertiesEXT)(VkPhysicalDevice physicalDevice, uint32_t* pToolCount, VkPhysicalDeviceToolProperties* pToolProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceToolPropertiesEXT( + VkPhysicalDevice physicalDevice, + uint32_t* pToolCount, + VkPhysicalDeviceToolProperties* pToolProperties); +#endif + + +// VK_EXT_separate_stencil_usage is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_separate_stencil_usage 1 +#define VK_EXT_SEPARATE_STENCIL_USAGE_SPEC_VERSION 1 +#define VK_EXT_SEPARATE_STENCIL_USAGE_EXTENSION_NAME "VK_EXT_separate_stencil_usage" +typedef VkImageStencilUsageCreateInfo VkImageStencilUsageCreateInfoEXT; + + + +// VK_EXT_validation_features is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_validation_features 1 +#define VK_EXT_VALIDATION_FEATURES_SPEC_VERSION 6 +#define VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME "VK_EXT_validation_features" + +typedef enum VkValidationFeatureEnableEXT { + VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT = 0, + VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT = 1, + VK_VALIDATION_FEATURE_ENABLE_BEST_PRACTICES_EXT = 2, + VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT = 3, + VK_VALIDATION_FEATURE_ENABLE_SYNCHRONIZATION_VALIDATION_EXT = 4, + VK_VALIDATION_FEATURE_ENABLE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationFeatureEnableEXT; + +typedef enum VkValidationFeatureDisableEXT { + VK_VALIDATION_FEATURE_DISABLE_ALL_EXT = 0, + VK_VALIDATION_FEATURE_DISABLE_SHADERS_EXT = 1, + VK_VALIDATION_FEATURE_DISABLE_THREAD_SAFETY_EXT = 2, + VK_VALIDATION_FEATURE_DISABLE_API_PARAMETERS_EXT = 3, + VK_VALIDATION_FEATURE_DISABLE_OBJECT_LIFETIMES_EXT = 4, + VK_VALIDATION_FEATURE_DISABLE_CORE_CHECKS_EXT = 5, + VK_VALIDATION_FEATURE_DISABLE_UNIQUE_HANDLES_EXT = 6, + VK_VALIDATION_FEATURE_DISABLE_SHADER_VALIDATION_CACHE_EXT = 7, + VK_VALIDATION_FEATURE_DISABLE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkValidationFeatureDisableEXT; +typedef struct VkValidationFeaturesEXT { + VkStructureType sType; + const void* pNext; + uint32_t enabledValidationFeatureCount; + const VkValidationFeatureEnableEXT* pEnabledValidationFeatures; + uint32_t disabledValidationFeatureCount; + const VkValidationFeatureDisableEXT* pDisabledValidationFeatures; +} VkValidationFeaturesEXT; + + + +// VK_NV_cooperative_matrix is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_cooperative_matrix 1 +#define VK_NV_COOPERATIVE_MATRIX_SPEC_VERSION 1 +#define VK_NV_COOPERATIVE_MATRIX_EXTENSION_NAME "VK_NV_cooperative_matrix" +typedef VkComponentTypeKHR VkComponentTypeNV; + +typedef VkScopeKHR VkScopeNV; + +typedef struct VkCooperativeMatrixPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t MSize; + uint32_t NSize; + uint32_t KSize; + VkComponentTypeNV AType; + VkComponentTypeNV BType; + VkComponentTypeNV CType; + VkComponentTypeNV DType; + VkScopeNV scope; +} VkCooperativeMatrixPropertiesNV; + +typedef struct VkPhysicalDeviceCooperativeMatrixFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 cooperativeMatrix; + VkBool32 cooperativeMatrixRobustBufferAccess; +} VkPhysicalDeviceCooperativeMatrixFeaturesNV; + +typedef struct VkPhysicalDeviceCooperativeMatrixPropertiesNV { + VkStructureType sType; + void* pNext; + VkShaderStageFlags cooperativeMatrixSupportedStages; +} VkPhysicalDeviceCooperativeMatrixPropertiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceCooperativeMatrixPropertiesNV)(VkPhysicalDevice physicalDevice, uint32_t* pPropertyCount, VkCooperativeMatrixPropertiesNV* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceCooperativeMatrixPropertiesNV( + VkPhysicalDevice physicalDevice, + uint32_t* pPropertyCount, + VkCooperativeMatrixPropertiesNV* pProperties); +#endif + + +// VK_NV_coverage_reduction_mode is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_coverage_reduction_mode 1 +#define VK_NV_COVERAGE_REDUCTION_MODE_SPEC_VERSION 1 +#define VK_NV_COVERAGE_REDUCTION_MODE_EXTENSION_NAME "VK_NV_coverage_reduction_mode" + +typedef enum VkCoverageReductionModeNV { + VK_COVERAGE_REDUCTION_MODE_MERGE_NV = 0, + VK_COVERAGE_REDUCTION_MODE_TRUNCATE_NV = 1, + VK_COVERAGE_REDUCTION_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkCoverageReductionModeNV; +typedef VkFlags VkPipelineCoverageReductionStateCreateFlagsNV; +typedef struct VkPhysicalDeviceCoverageReductionModeFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 coverageReductionMode; +} VkPhysicalDeviceCoverageReductionModeFeaturesNV; + +typedef struct VkPipelineCoverageReductionStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineCoverageReductionStateCreateFlagsNV flags; + VkCoverageReductionModeNV coverageReductionMode; +} VkPipelineCoverageReductionStateCreateInfoNV; + +typedef struct VkFramebufferMixedSamplesCombinationNV { + VkStructureType sType; + void* pNext; + VkCoverageReductionModeNV coverageReductionMode; + VkSampleCountFlagBits rasterizationSamples; + VkSampleCountFlags depthStencilSamples; + VkSampleCountFlags colorSamples; +} VkFramebufferMixedSamplesCombinationNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV)(VkPhysicalDevice physicalDevice, uint32_t* pCombinationCount, VkFramebufferMixedSamplesCombinationNV* pCombinations); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSupportedFramebufferMixedSamplesCombinationsNV( + VkPhysicalDevice physicalDevice, + uint32_t* pCombinationCount, + VkFramebufferMixedSamplesCombinationNV* pCombinations); +#endif + + +// VK_EXT_fragment_shader_interlock is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_fragment_shader_interlock 1 +#define VK_EXT_FRAGMENT_SHADER_INTERLOCK_SPEC_VERSION 1 +#define VK_EXT_FRAGMENT_SHADER_INTERLOCK_EXTENSION_NAME "VK_EXT_fragment_shader_interlock" +typedef struct VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 fragmentShaderSampleInterlock; + VkBool32 fragmentShaderPixelInterlock; + VkBool32 fragmentShaderShadingRateInterlock; +} VkPhysicalDeviceFragmentShaderInterlockFeaturesEXT; + + + +// VK_EXT_ycbcr_image_arrays is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_ycbcr_image_arrays 1 +#define VK_EXT_YCBCR_IMAGE_ARRAYS_SPEC_VERSION 1 +#define VK_EXT_YCBCR_IMAGE_ARRAYS_EXTENSION_NAME "VK_EXT_ycbcr_image_arrays" +typedef struct VkPhysicalDeviceYcbcrImageArraysFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 ycbcrImageArrays; +} VkPhysicalDeviceYcbcrImageArraysFeaturesEXT; + + + +// VK_EXT_provoking_vertex is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_provoking_vertex 1 +#define VK_EXT_PROVOKING_VERTEX_SPEC_VERSION 1 +#define VK_EXT_PROVOKING_VERTEX_EXTENSION_NAME "VK_EXT_provoking_vertex" + +typedef enum VkProvokingVertexModeEXT { + VK_PROVOKING_VERTEX_MODE_FIRST_VERTEX_EXT = 0, + VK_PROVOKING_VERTEX_MODE_LAST_VERTEX_EXT = 1, + VK_PROVOKING_VERTEX_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkProvokingVertexModeEXT; +typedef struct VkPhysicalDeviceProvokingVertexFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 provokingVertexLast; + VkBool32 transformFeedbackPreservesProvokingVertex; +} VkPhysicalDeviceProvokingVertexFeaturesEXT; + +typedef struct VkPhysicalDeviceProvokingVertexPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 provokingVertexModePerPipeline; + VkBool32 transformFeedbackPreservesTriangleFanProvokingVertex; +} VkPhysicalDeviceProvokingVertexPropertiesEXT; + +typedef struct VkPipelineRasterizationProvokingVertexStateCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkProvokingVertexModeEXT provokingVertexMode; +} VkPipelineRasterizationProvokingVertexStateCreateInfoEXT; + + + +// VK_EXT_headless_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_headless_surface 1 +#define VK_EXT_HEADLESS_SURFACE_SPEC_VERSION 1 +#define VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME "VK_EXT_headless_surface" +typedef VkFlags VkHeadlessSurfaceCreateFlagsEXT; +typedef struct VkHeadlessSurfaceCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkHeadlessSurfaceCreateFlagsEXT flags; +} VkHeadlessSurfaceCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateHeadlessSurfaceEXT)(VkInstance instance, const VkHeadlessSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateHeadlessSurfaceEXT( + VkInstance instance, + const VkHeadlessSurfaceCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +// VK_EXT_line_rasterization is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_line_rasterization 1 +#define VK_EXT_LINE_RASTERIZATION_SPEC_VERSION 1 +#define VK_EXT_LINE_RASTERIZATION_EXTENSION_NAME "VK_EXT_line_rasterization" +typedef VkLineRasterizationModeKHR VkLineRasterizationModeEXT; + +typedef VkPhysicalDeviceLineRasterizationFeaturesKHR VkPhysicalDeviceLineRasterizationFeaturesEXT; + +typedef VkPhysicalDeviceLineRasterizationPropertiesKHR VkPhysicalDeviceLineRasterizationPropertiesEXT; + +typedef VkPipelineRasterizationLineStateCreateInfoKHR VkPipelineRasterizationLineStateCreateInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetLineStippleEXT)(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, uint16_t lineStipplePattern); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEXT( + VkCommandBuffer commandBuffer, + uint32_t lineStippleFactor, + uint16_t lineStipplePattern); +#endif + + +// VK_EXT_shader_atomic_float is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_atomic_float 1 +#define VK_EXT_SHADER_ATOMIC_FLOAT_SPEC_VERSION 1 +#define VK_EXT_SHADER_ATOMIC_FLOAT_EXTENSION_NAME "VK_EXT_shader_atomic_float" +typedef struct VkPhysicalDeviceShaderAtomicFloatFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderBufferFloat32Atomics; + VkBool32 shaderBufferFloat32AtomicAdd; + VkBool32 shaderBufferFloat64Atomics; + VkBool32 shaderBufferFloat64AtomicAdd; + VkBool32 shaderSharedFloat32Atomics; + VkBool32 shaderSharedFloat32AtomicAdd; + VkBool32 shaderSharedFloat64Atomics; + VkBool32 shaderSharedFloat64AtomicAdd; + VkBool32 shaderImageFloat32Atomics; + VkBool32 shaderImageFloat32AtomicAdd; + VkBool32 sparseImageFloat32Atomics; + VkBool32 sparseImageFloat32AtomicAdd; +} VkPhysicalDeviceShaderAtomicFloatFeaturesEXT; + + + +// VK_EXT_host_query_reset is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_host_query_reset 1 +#define VK_EXT_HOST_QUERY_RESET_SPEC_VERSION 1 +#define VK_EXT_HOST_QUERY_RESET_EXTENSION_NAME "VK_EXT_host_query_reset" +typedef VkPhysicalDeviceHostQueryResetFeatures VkPhysicalDeviceHostQueryResetFeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkResetQueryPoolEXT)(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkResetQueryPoolEXT( + VkDevice device, + VkQueryPool queryPool, + uint32_t firstQuery, + uint32_t queryCount); +#endif + + +// VK_EXT_index_type_uint8 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_index_type_uint8 1 +#define VK_EXT_INDEX_TYPE_UINT8_SPEC_VERSION 1 +#define VK_EXT_INDEX_TYPE_UINT8_EXTENSION_NAME "VK_EXT_index_type_uint8" +typedef VkPhysicalDeviceIndexTypeUint8FeaturesKHR VkPhysicalDeviceIndexTypeUint8FeaturesEXT; + + + +// VK_EXT_extended_dynamic_state is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_extended_dynamic_state 1 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_SPEC_VERSION 1 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_EXTENSION_NAME "VK_EXT_extended_dynamic_state" +typedef struct VkPhysicalDeviceExtendedDynamicStateFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 extendedDynamicState; +} VkPhysicalDeviceExtendedDynamicStateFeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetCullModeEXT)(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetFrontFaceEXT)(VkCommandBuffer commandBuffer, VkFrontFace frontFace); +typedef void (VKAPI_PTR *PFN_vkCmdSetPrimitiveTopologyEXT)(VkCommandBuffer commandBuffer, VkPrimitiveTopology primitiveTopology); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWithCountEXT)(VkCommandBuffer commandBuffer, uint32_t viewportCount, const VkViewport* pViewports); +typedef void (VKAPI_PTR *PFN_vkCmdSetScissorWithCountEXT)(VkCommandBuffer commandBuffer, uint32_t scissorCount, const VkRect2D* pScissors); +typedef void (VKAPI_PTR *PFN_vkCmdBindVertexBuffers2EXT)(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer* pBuffers, const VkDeviceSize* pOffsets, const VkDeviceSize* pSizes, const VkDeviceSize* pStrides); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthTestEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthWriteEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthWriteEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthCompareOpEXT)(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBoundsTestEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthBoundsTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilTestEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 stencilTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetStencilOpEXT)(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetCullModeEXT( + VkCommandBuffer commandBuffer, + VkCullModeFlags cullMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetFrontFaceEXT( + VkCommandBuffer commandBuffer, + VkFrontFace frontFace); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetPrimitiveTopologyEXT( + VkCommandBuffer commandBuffer, + VkPrimitiveTopology primitiveTopology); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWithCountEXT( + VkCommandBuffer commandBuffer, + uint32_t viewportCount, + const VkViewport* pViewports); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetScissorWithCountEXT( + VkCommandBuffer commandBuffer, + uint32_t scissorCount, + const VkRect2D* pScissors); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindVertexBuffers2EXT( + VkCommandBuffer commandBuffer, + uint32_t firstBinding, + uint32_t bindingCount, + const VkBuffer* pBuffers, + const VkDeviceSize* pOffsets, + const VkDeviceSize* pSizes, + const VkDeviceSize* pStrides); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthTestEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthWriteEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthWriteEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthCompareOpEXT( + VkCommandBuffer commandBuffer, + VkCompareOp depthCompareOp); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBoundsTestEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthBoundsTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilTestEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 stencilTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetStencilOpEXT( + VkCommandBuffer commandBuffer, + VkStencilFaceFlags faceMask, + VkStencilOp failOp, + VkStencilOp passOp, + VkStencilOp depthFailOp, + VkCompareOp compareOp); +#endif + + +// VK_EXT_host_image_copy is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_host_image_copy 1 +#define VK_EXT_HOST_IMAGE_COPY_SPEC_VERSION 1 +#define VK_EXT_HOST_IMAGE_COPY_EXTENSION_NAME "VK_EXT_host_image_copy" + +typedef enum VkHostImageCopyFlagBitsEXT { + VK_HOST_IMAGE_COPY_MEMCPY_EXT = 0x00000001, + VK_HOST_IMAGE_COPY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkHostImageCopyFlagBitsEXT; +typedef VkFlags VkHostImageCopyFlagsEXT; +typedef struct VkPhysicalDeviceHostImageCopyFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 hostImageCopy; +} VkPhysicalDeviceHostImageCopyFeaturesEXT; + +typedef struct VkPhysicalDeviceHostImageCopyPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t copySrcLayoutCount; + VkImageLayout* pCopySrcLayouts; + uint32_t copyDstLayoutCount; + VkImageLayout* pCopyDstLayouts; + uint8_t optimalTilingLayoutUUID[VK_UUID_SIZE]; + VkBool32 identicalMemoryTypeRequirements; +} VkPhysicalDeviceHostImageCopyPropertiesEXT; + +typedef struct VkMemoryToImageCopyEXT { + VkStructureType sType; + const void* pNext; + const void* pHostPointer; + uint32_t memoryRowLength; + uint32_t memoryImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkMemoryToImageCopyEXT; + +typedef struct VkImageToMemoryCopyEXT { + VkStructureType sType; + const void* pNext; + void* pHostPointer; + uint32_t memoryRowLength; + uint32_t memoryImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkImageToMemoryCopyEXT; + +typedef struct VkCopyMemoryToImageInfoEXT { + VkStructureType sType; + const void* pNext; + VkHostImageCopyFlagsEXT flags; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkMemoryToImageCopyEXT* pRegions; +} VkCopyMemoryToImageInfoEXT; + +typedef struct VkCopyImageToMemoryInfoEXT { + VkStructureType sType; + const void* pNext; + VkHostImageCopyFlagsEXT flags; + VkImage srcImage; + VkImageLayout srcImageLayout; + uint32_t regionCount; + const VkImageToMemoryCopyEXT* pRegions; +} VkCopyImageToMemoryInfoEXT; + +typedef struct VkCopyImageToImageInfoEXT { + VkStructureType sType; + const void* pNext; + VkHostImageCopyFlagsEXT flags; + VkImage srcImage; + VkImageLayout srcImageLayout; + VkImage dstImage; + VkImageLayout dstImageLayout; + uint32_t regionCount; + const VkImageCopy2* pRegions; +} VkCopyImageToImageInfoEXT; + +typedef struct VkHostImageLayoutTransitionInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; + VkImageLayout oldLayout; + VkImageLayout newLayout; + VkImageSubresourceRange subresourceRange; +} VkHostImageLayoutTransitionInfoEXT; + +typedef struct VkSubresourceHostMemcpySizeEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize size; +} VkSubresourceHostMemcpySizeEXT; + +typedef struct VkHostImageCopyDevicePerformanceQueryEXT { + VkStructureType sType; + void* pNext; + VkBool32 optimalDeviceAccess; + VkBool32 identicalMemoryLayout; +} VkHostImageCopyDevicePerformanceQueryEXT; + +typedef VkSubresourceLayout2KHR VkSubresourceLayout2EXT; + +typedef VkImageSubresource2KHR VkImageSubresource2EXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCopyMemoryToImageEXT)(VkDevice device, const VkCopyMemoryToImageInfoEXT* pCopyMemoryToImageInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyImageToMemoryEXT)(VkDevice device, const VkCopyImageToMemoryInfoEXT* pCopyImageToMemoryInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyImageToImageEXT)(VkDevice device, const VkCopyImageToImageInfoEXT* pCopyImageToImageInfo); +typedef VkResult (VKAPI_PTR *PFN_vkTransitionImageLayoutEXT)(VkDevice device, uint32_t transitionCount, const VkHostImageLayoutTransitionInfoEXT* pTransitions); +typedef void (VKAPI_PTR *PFN_vkGetImageSubresourceLayout2EXT)(VkDevice device, VkImage image, const VkImageSubresource2KHR* pSubresource, VkSubresourceLayout2KHR* pLayout); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToImageEXT( + VkDevice device, + const VkCopyMemoryToImageInfoEXT* pCopyMemoryToImageInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyImageToMemoryEXT( + VkDevice device, + const VkCopyImageToMemoryInfoEXT* pCopyImageToMemoryInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyImageToImageEXT( + VkDevice device, + const VkCopyImageToImageInfoEXT* pCopyImageToImageInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkTransitionImageLayoutEXT( + VkDevice device, + uint32_t transitionCount, + const VkHostImageLayoutTransitionInfoEXT* pTransitions); + +VKAPI_ATTR void VKAPI_CALL vkGetImageSubresourceLayout2EXT( + VkDevice device, + VkImage image, + const VkImageSubresource2KHR* pSubresource, + VkSubresourceLayout2KHR* pLayout); +#endif + + +// VK_EXT_map_memory_placed is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_map_memory_placed 1 +#define VK_EXT_MAP_MEMORY_PLACED_SPEC_VERSION 1 +#define VK_EXT_MAP_MEMORY_PLACED_EXTENSION_NAME "VK_EXT_map_memory_placed" +typedef struct VkPhysicalDeviceMapMemoryPlacedFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 memoryMapPlaced; + VkBool32 memoryMapRangePlaced; + VkBool32 memoryUnmapReserve; +} VkPhysicalDeviceMapMemoryPlacedFeaturesEXT; + +typedef struct VkPhysicalDeviceMapMemoryPlacedPropertiesEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize minPlacedMemoryMapAlignment; +} VkPhysicalDeviceMapMemoryPlacedPropertiesEXT; + +typedef struct VkMemoryMapPlacedInfoEXT { + VkStructureType sType; + const void* pNext; + void* pPlacedAddress; +} VkMemoryMapPlacedInfoEXT; + + + +// VK_EXT_shader_atomic_float2 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_atomic_float2 1 +#define VK_EXT_SHADER_ATOMIC_FLOAT_2_SPEC_VERSION 1 +#define VK_EXT_SHADER_ATOMIC_FLOAT_2_EXTENSION_NAME "VK_EXT_shader_atomic_float2" +typedef struct VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderBufferFloat16Atomics; + VkBool32 shaderBufferFloat16AtomicAdd; + VkBool32 shaderBufferFloat16AtomicMinMax; + VkBool32 shaderBufferFloat32AtomicMinMax; + VkBool32 shaderBufferFloat64AtomicMinMax; + VkBool32 shaderSharedFloat16Atomics; + VkBool32 shaderSharedFloat16AtomicAdd; + VkBool32 shaderSharedFloat16AtomicMinMax; + VkBool32 shaderSharedFloat32AtomicMinMax; + VkBool32 shaderSharedFloat64AtomicMinMax; + VkBool32 shaderImageFloat32AtomicMinMax; + VkBool32 sparseImageFloat32AtomicMinMax; +} VkPhysicalDeviceShaderAtomicFloat2FeaturesEXT; + + + +// VK_EXT_surface_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_surface_maintenance1 1 +#define VK_EXT_SURFACE_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_EXT_SURFACE_MAINTENANCE_1_EXTENSION_NAME "VK_EXT_surface_maintenance1" + +typedef enum VkPresentScalingFlagBitsEXT { + VK_PRESENT_SCALING_ONE_TO_ONE_BIT_EXT = 0x00000001, + VK_PRESENT_SCALING_ASPECT_RATIO_STRETCH_BIT_EXT = 0x00000002, + VK_PRESENT_SCALING_STRETCH_BIT_EXT = 0x00000004, + VK_PRESENT_SCALING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPresentScalingFlagBitsEXT; +typedef VkFlags VkPresentScalingFlagsEXT; + +typedef enum VkPresentGravityFlagBitsEXT { + VK_PRESENT_GRAVITY_MIN_BIT_EXT = 0x00000001, + VK_PRESENT_GRAVITY_MAX_BIT_EXT = 0x00000002, + VK_PRESENT_GRAVITY_CENTERED_BIT_EXT = 0x00000004, + VK_PRESENT_GRAVITY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkPresentGravityFlagBitsEXT; +typedef VkFlags VkPresentGravityFlagsEXT; +typedef struct VkSurfacePresentModeEXT { + VkStructureType sType; + void* pNext; + VkPresentModeKHR presentMode; +} VkSurfacePresentModeEXT; + +typedef struct VkSurfacePresentScalingCapabilitiesEXT { + VkStructureType sType; + void* pNext; + VkPresentScalingFlagsEXT supportedPresentScaling; + VkPresentGravityFlagsEXT supportedPresentGravityX; + VkPresentGravityFlagsEXT supportedPresentGravityY; + VkExtent2D minScaledImageExtent; + VkExtent2D maxScaledImageExtent; +} VkSurfacePresentScalingCapabilitiesEXT; + +typedef struct VkSurfacePresentModeCompatibilityEXT { + VkStructureType sType; + void* pNext; + uint32_t presentModeCount; + VkPresentModeKHR* pPresentModes; +} VkSurfacePresentModeCompatibilityEXT; + + + +// VK_EXT_swapchain_maintenance1 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_swapchain_maintenance1 1 +#define VK_EXT_SWAPCHAIN_MAINTENANCE_1_SPEC_VERSION 1 +#define VK_EXT_SWAPCHAIN_MAINTENANCE_1_EXTENSION_NAME "VK_EXT_swapchain_maintenance1" +typedef struct VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 swapchainMaintenance1; +} VkPhysicalDeviceSwapchainMaintenance1FeaturesEXT; + +typedef struct VkSwapchainPresentFenceInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkFence* pFences; +} VkSwapchainPresentFenceInfoEXT; + +typedef struct VkSwapchainPresentModesCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t presentModeCount; + const VkPresentModeKHR* pPresentModes; +} VkSwapchainPresentModesCreateInfoEXT; + +typedef struct VkSwapchainPresentModeInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t swapchainCount; + const VkPresentModeKHR* pPresentModes; +} VkSwapchainPresentModeInfoEXT; + +typedef struct VkSwapchainPresentScalingCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkPresentScalingFlagsEXT scalingBehavior; + VkPresentGravityFlagsEXT presentGravityX; + VkPresentGravityFlagsEXT presentGravityY; +} VkSwapchainPresentScalingCreateInfoEXT; + +typedef struct VkReleaseSwapchainImagesInfoEXT { + VkStructureType sType; + const void* pNext; + VkSwapchainKHR swapchain; + uint32_t imageIndexCount; + const uint32_t* pImageIndices; +} VkReleaseSwapchainImagesInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkReleaseSwapchainImagesEXT)(VkDevice device, const VkReleaseSwapchainImagesInfoEXT* pReleaseInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkReleaseSwapchainImagesEXT( + VkDevice device, + const VkReleaseSwapchainImagesInfoEXT* pReleaseInfo); +#endif + + +// VK_EXT_shader_demote_to_helper_invocation is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_demote_to_helper_invocation 1 +#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_SPEC_VERSION 1 +#define VK_EXT_SHADER_DEMOTE_TO_HELPER_INVOCATION_EXTENSION_NAME "VK_EXT_shader_demote_to_helper_invocation" +typedef VkPhysicalDeviceShaderDemoteToHelperInvocationFeatures VkPhysicalDeviceShaderDemoteToHelperInvocationFeaturesEXT; + + + +// VK_NV_device_generated_commands is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_device_generated_commands 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkIndirectCommandsLayoutNV) +#define VK_NV_DEVICE_GENERATED_COMMANDS_SPEC_VERSION 3 +#define VK_NV_DEVICE_GENERATED_COMMANDS_EXTENSION_NAME "VK_NV_device_generated_commands" + +typedef enum VkIndirectCommandsTokenTypeNV { + VK_INDIRECT_COMMANDS_TOKEN_TYPE_SHADER_GROUP_NV = 0, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_STATE_FLAGS_NV = 1, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_INDEX_BUFFER_NV = 2, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_VERTEX_BUFFER_NV = 3, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_PUSH_CONSTANT_NV = 4, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_INDEXED_NV = 5, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_NV = 6, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_TASKS_NV = 7, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_MESH_TASKS_NV = 1000328000, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_PIPELINE_NV = 1000428003, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_DISPATCH_NV = 1000428004, + VK_INDIRECT_COMMANDS_TOKEN_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkIndirectCommandsTokenTypeNV; + +typedef enum VkIndirectStateFlagBitsNV { + VK_INDIRECT_STATE_FLAG_FRONTFACE_BIT_NV = 0x00000001, + VK_INDIRECT_STATE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkIndirectStateFlagBitsNV; +typedef VkFlags VkIndirectStateFlagsNV; + +typedef enum VkIndirectCommandsLayoutUsageFlagBitsNV { + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_EXPLICIT_PREPROCESS_BIT_NV = 0x00000001, + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_INDEXED_SEQUENCES_BIT_NV = 0x00000002, + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_UNORDERED_SEQUENCES_BIT_NV = 0x00000004, + VK_INDIRECT_COMMANDS_LAYOUT_USAGE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkIndirectCommandsLayoutUsageFlagBitsNV; +typedef VkFlags VkIndirectCommandsLayoutUsageFlagsNV; +typedef struct VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t maxGraphicsShaderGroupCount; + uint32_t maxIndirectSequenceCount; + uint32_t maxIndirectCommandsTokenCount; + uint32_t maxIndirectCommandsStreamCount; + uint32_t maxIndirectCommandsTokenOffset; + uint32_t maxIndirectCommandsStreamStride; + uint32_t minSequencesCountBufferOffsetAlignment; + uint32_t minSequencesIndexBufferOffsetAlignment; + uint32_t minIndirectCommandsBufferOffsetAlignment; +} VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV; + +typedef struct VkPhysicalDeviceDeviceGeneratedCommandsFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 deviceGeneratedCommands; +} VkPhysicalDeviceDeviceGeneratedCommandsFeaturesNV; + +typedef struct VkGraphicsShaderGroupCreateInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + const VkPipelineVertexInputStateCreateInfo* pVertexInputState; + const VkPipelineTessellationStateCreateInfo* pTessellationState; +} VkGraphicsShaderGroupCreateInfoNV; + +typedef struct VkGraphicsPipelineShaderGroupsCreateInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t groupCount; + const VkGraphicsShaderGroupCreateInfoNV* pGroups; + uint32_t pipelineCount; + const VkPipeline* pPipelines; +} VkGraphicsPipelineShaderGroupsCreateInfoNV; + +typedef struct VkBindShaderGroupIndirectCommandNV { + uint32_t groupIndex; +} VkBindShaderGroupIndirectCommandNV; + +typedef struct VkBindIndexBufferIndirectCommandNV { + VkDeviceAddress bufferAddress; + uint32_t size; + VkIndexType indexType; +} VkBindIndexBufferIndirectCommandNV; + +typedef struct VkBindVertexBufferIndirectCommandNV { + VkDeviceAddress bufferAddress; + uint32_t size; + uint32_t stride; +} VkBindVertexBufferIndirectCommandNV; + +typedef struct VkSetStateFlagsIndirectCommandNV { + uint32_t data; +} VkSetStateFlagsIndirectCommandNV; + +typedef struct VkIndirectCommandsStreamNV { + VkBuffer buffer; + VkDeviceSize offset; +} VkIndirectCommandsStreamNV; + +typedef struct VkIndirectCommandsLayoutTokenNV { + VkStructureType sType; + const void* pNext; + VkIndirectCommandsTokenTypeNV tokenType; + uint32_t stream; + uint32_t offset; + uint32_t vertexBindingUnit; + VkBool32 vertexDynamicStride; + VkPipelineLayout pushconstantPipelineLayout; + VkShaderStageFlags pushconstantShaderStageFlags; + uint32_t pushconstantOffset; + uint32_t pushconstantSize; + VkIndirectStateFlagsNV indirectStateFlags; + uint32_t indexTypeCount; + const VkIndexType* pIndexTypes; + const uint32_t* pIndexTypeValues; +} VkIndirectCommandsLayoutTokenNV; + +typedef struct VkIndirectCommandsLayoutCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkIndirectCommandsLayoutUsageFlagsNV flags; + VkPipelineBindPoint pipelineBindPoint; + uint32_t tokenCount; + const VkIndirectCommandsLayoutTokenNV* pTokens; + uint32_t streamCount; + const uint32_t* pStreamStrides; +} VkIndirectCommandsLayoutCreateInfoNV; + +typedef struct VkGeneratedCommandsInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineBindPoint pipelineBindPoint; + VkPipeline pipeline; + VkIndirectCommandsLayoutNV indirectCommandsLayout; + uint32_t streamCount; + const VkIndirectCommandsStreamNV* pStreams; + uint32_t sequencesCount; + VkBuffer preprocessBuffer; + VkDeviceSize preprocessOffset; + VkDeviceSize preprocessSize; + VkBuffer sequencesCountBuffer; + VkDeviceSize sequencesCountOffset; + VkBuffer sequencesIndexBuffer; + VkDeviceSize sequencesIndexOffset; +} VkGeneratedCommandsInfoNV; + +typedef struct VkGeneratedCommandsMemoryRequirementsInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineBindPoint pipelineBindPoint; + VkPipeline pipeline; + VkIndirectCommandsLayoutNV indirectCommandsLayout; + uint32_t maxSequencesCount; +} VkGeneratedCommandsMemoryRequirementsInfoNV; + +typedef void (VKAPI_PTR *PFN_vkGetGeneratedCommandsMemoryRequirementsNV)(VkDevice device, const VkGeneratedCommandsMemoryRequirementsInfoNV* pInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkCmdPreprocessGeneratedCommandsNV)(VkCommandBuffer commandBuffer, const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdExecuteGeneratedCommandsNV)(VkCommandBuffer commandBuffer, VkBool32 isPreprocessed, const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo); +typedef void (VKAPI_PTR *PFN_vkCmdBindPipelineShaderGroupNV)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline, uint32_t groupIndex); +typedef VkResult (VKAPI_PTR *PFN_vkCreateIndirectCommandsLayoutNV)(VkDevice device, const VkIndirectCommandsLayoutCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkIndirectCommandsLayoutNV* pIndirectCommandsLayout); +typedef void (VKAPI_PTR *PFN_vkDestroyIndirectCommandsLayoutNV)(VkDevice device, VkIndirectCommandsLayoutNV indirectCommandsLayout, const VkAllocationCallbacks* pAllocator); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetGeneratedCommandsMemoryRequirementsNV( + VkDevice device, + const VkGeneratedCommandsMemoryRequirementsInfoNV* pInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkCmdPreprocessGeneratedCommandsNV( + VkCommandBuffer commandBuffer, + const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdExecuteGeneratedCommandsNV( + VkCommandBuffer commandBuffer, + VkBool32 isPreprocessed, + const VkGeneratedCommandsInfoNV* pGeneratedCommandsInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindPipelineShaderGroupNV( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipeline pipeline, + uint32_t groupIndex); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateIndirectCommandsLayoutNV( + VkDevice device, + const VkIndirectCommandsLayoutCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkIndirectCommandsLayoutNV* pIndirectCommandsLayout); + +VKAPI_ATTR void VKAPI_CALL vkDestroyIndirectCommandsLayoutNV( + VkDevice device, + VkIndirectCommandsLayoutNV indirectCommandsLayout, + const VkAllocationCallbacks* pAllocator); +#endif + + +// VK_NV_inherited_viewport_scissor is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_inherited_viewport_scissor 1 +#define VK_NV_INHERITED_VIEWPORT_SCISSOR_SPEC_VERSION 1 +#define VK_NV_INHERITED_VIEWPORT_SCISSOR_EXTENSION_NAME "VK_NV_inherited_viewport_scissor" +typedef struct VkPhysicalDeviceInheritedViewportScissorFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 inheritedViewportScissor2D; +} VkPhysicalDeviceInheritedViewportScissorFeaturesNV; + +typedef struct VkCommandBufferInheritanceViewportScissorInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 viewportScissor2D; + uint32_t viewportDepthCount; + const VkViewport* pViewportDepths; +} VkCommandBufferInheritanceViewportScissorInfoNV; + + + +// VK_EXT_texel_buffer_alignment is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_texel_buffer_alignment 1 +#define VK_EXT_TEXEL_BUFFER_ALIGNMENT_SPEC_VERSION 1 +#define VK_EXT_TEXEL_BUFFER_ALIGNMENT_EXTENSION_NAME "VK_EXT_texel_buffer_alignment" +typedef struct VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 texelBufferAlignment; +} VkPhysicalDeviceTexelBufferAlignmentFeaturesEXT; + +typedef VkPhysicalDeviceTexelBufferAlignmentProperties VkPhysicalDeviceTexelBufferAlignmentPropertiesEXT; + + + +// VK_QCOM_render_pass_transform is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_render_pass_transform 1 +#define VK_QCOM_RENDER_PASS_TRANSFORM_SPEC_VERSION 4 +#define VK_QCOM_RENDER_PASS_TRANSFORM_EXTENSION_NAME "VK_QCOM_render_pass_transform" +typedef struct VkRenderPassTransformBeginInfoQCOM { + VkStructureType sType; + void* pNext; + VkSurfaceTransformFlagBitsKHR transform; +} VkRenderPassTransformBeginInfoQCOM; + +typedef struct VkCommandBufferInheritanceRenderPassTransformInfoQCOM { + VkStructureType sType; + void* pNext; + VkSurfaceTransformFlagBitsKHR transform; + VkRect2D renderArea; +} VkCommandBufferInheritanceRenderPassTransformInfoQCOM; + + + +// VK_EXT_depth_bias_control is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_depth_bias_control 1 +#define VK_EXT_DEPTH_BIAS_CONTROL_SPEC_VERSION 1 +#define VK_EXT_DEPTH_BIAS_CONTROL_EXTENSION_NAME "VK_EXT_depth_bias_control" + +typedef enum VkDepthBiasRepresentationEXT { + VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORMAT_EXT = 0, + VK_DEPTH_BIAS_REPRESENTATION_LEAST_REPRESENTABLE_VALUE_FORCE_UNORM_EXT = 1, + VK_DEPTH_BIAS_REPRESENTATION_FLOAT_EXT = 2, + VK_DEPTH_BIAS_REPRESENTATION_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDepthBiasRepresentationEXT; +typedef struct VkPhysicalDeviceDepthBiasControlFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 depthBiasControl; + VkBool32 leastRepresentableValueForceUnormRepresentation; + VkBool32 floatRepresentation; + VkBool32 depthBiasExact; +} VkPhysicalDeviceDepthBiasControlFeaturesEXT; + +typedef struct VkDepthBiasInfoEXT { + VkStructureType sType; + const void* pNext; + float depthBiasConstantFactor; + float depthBiasClamp; + float depthBiasSlopeFactor; +} VkDepthBiasInfoEXT; + +typedef struct VkDepthBiasRepresentationInfoEXT { + VkStructureType sType; + const void* pNext; + VkDepthBiasRepresentationEXT depthBiasRepresentation; + VkBool32 depthBiasExact; +} VkDepthBiasRepresentationInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBias2EXT)(VkCommandBuffer commandBuffer, const VkDepthBiasInfoEXT* pDepthBiasInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBias2EXT( + VkCommandBuffer commandBuffer, + const VkDepthBiasInfoEXT* pDepthBiasInfo); +#endif + + +// VK_EXT_device_memory_report is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_device_memory_report 1 +#define VK_EXT_DEVICE_MEMORY_REPORT_SPEC_VERSION 2 +#define VK_EXT_DEVICE_MEMORY_REPORT_EXTENSION_NAME "VK_EXT_device_memory_report" + +typedef enum VkDeviceMemoryReportEventTypeEXT { + VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATE_EXT = 0, + VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_FREE_EXT = 1, + VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_IMPORT_EXT = 2, + VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_UNIMPORT_EXT = 3, + VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_ALLOCATION_FAILED_EXT = 4, + VK_DEVICE_MEMORY_REPORT_EVENT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceMemoryReportEventTypeEXT; +typedef VkFlags VkDeviceMemoryReportFlagsEXT; +typedef struct VkPhysicalDeviceDeviceMemoryReportFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 deviceMemoryReport; +} VkPhysicalDeviceDeviceMemoryReportFeaturesEXT; + +typedef struct VkDeviceMemoryReportCallbackDataEXT { + VkStructureType sType; + void* pNext; + VkDeviceMemoryReportFlagsEXT flags; + VkDeviceMemoryReportEventTypeEXT type; + uint64_t memoryObjectId; + VkDeviceSize size; + VkObjectType objectType; + uint64_t objectHandle; + uint32_t heapIndex; +} VkDeviceMemoryReportCallbackDataEXT; + +typedef void (VKAPI_PTR *PFN_vkDeviceMemoryReportCallbackEXT)( + const VkDeviceMemoryReportCallbackDataEXT* pCallbackData, + void* pUserData); + +typedef struct VkDeviceDeviceMemoryReportCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceMemoryReportFlagsEXT flags; + PFN_vkDeviceMemoryReportCallbackEXT pfnUserCallback; + void* pUserData; +} VkDeviceDeviceMemoryReportCreateInfoEXT; + + + +// VK_EXT_acquire_drm_display is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_acquire_drm_display 1 +#define VK_EXT_ACQUIRE_DRM_DISPLAY_SPEC_VERSION 1 +#define VK_EXT_ACQUIRE_DRM_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_drm_display" +typedef VkResult (VKAPI_PTR *PFN_vkAcquireDrmDisplayEXT)(VkPhysicalDevice physicalDevice, int32_t drmFd, VkDisplayKHR display); +typedef VkResult (VKAPI_PTR *PFN_vkGetDrmDisplayEXT)(VkPhysicalDevice physicalDevice, int32_t drmFd, uint32_t connectorId, VkDisplayKHR* display); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireDrmDisplayEXT( + VkPhysicalDevice physicalDevice, + int32_t drmFd, + VkDisplayKHR display); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDrmDisplayEXT( + VkPhysicalDevice physicalDevice, + int32_t drmFd, + uint32_t connectorId, + VkDisplayKHR* display); +#endif + + +// VK_EXT_robustness2 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_robustness2 1 +#define VK_EXT_ROBUSTNESS_2_SPEC_VERSION 1 +#define VK_EXT_ROBUSTNESS_2_EXTENSION_NAME "VK_EXT_robustness2" +typedef struct VkPhysicalDeviceRobustness2FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 robustBufferAccess2; + VkBool32 robustImageAccess2; + VkBool32 nullDescriptor; +} VkPhysicalDeviceRobustness2FeaturesEXT; + +typedef struct VkPhysicalDeviceRobustness2PropertiesEXT { + VkStructureType sType; + void* pNext; + VkDeviceSize robustStorageBufferAccessSizeAlignment; + VkDeviceSize robustUniformBufferAccessSizeAlignment; +} VkPhysicalDeviceRobustness2PropertiesEXT; + + + +// VK_EXT_custom_border_color is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_custom_border_color 1 +#define VK_EXT_CUSTOM_BORDER_COLOR_SPEC_VERSION 12 +#define VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME "VK_EXT_custom_border_color" +typedef struct VkSamplerCustomBorderColorCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkClearColorValue customBorderColor; + VkFormat format; +} VkSamplerCustomBorderColorCreateInfoEXT; + +typedef struct VkPhysicalDeviceCustomBorderColorPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxCustomBorderColorSamplers; +} VkPhysicalDeviceCustomBorderColorPropertiesEXT; + +typedef struct VkPhysicalDeviceCustomBorderColorFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 customBorderColors; + VkBool32 customBorderColorWithoutFormat; +} VkPhysicalDeviceCustomBorderColorFeaturesEXT; + + + +// VK_GOOGLE_user_type is a preprocessor guard. Do not pass it to API calls. +#define VK_GOOGLE_user_type 1 +#define VK_GOOGLE_USER_TYPE_SPEC_VERSION 1 +#define VK_GOOGLE_USER_TYPE_EXTENSION_NAME "VK_GOOGLE_user_type" + + +// VK_NV_present_barrier is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_present_barrier 1 +#define VK_NV_PRESENT_BARRIER_SPEC_VERSION 1 +#define VK_NV_PRESENT_BARRIER_EXTENSION_NAME "VK_NV_present_barrier" +typedef struct VkPhysicalDevicePresentBarrierFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrier; +} VkPhysicalDevicePresentBarrierFeaturesNV; + +typedef struct VkSurfaceCapabilitiesPresentBarrierNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrierSupported; +} VkSurfaceCapabilitiesPresentBarrierNV; + +typedef struct VkSwapchainPresentBarrierCreateInfoNV { + VkStructureType sType; + void* pNext; + VkBool32 presentBarrierEnable; +} VkSwapchainPresentBarrierCreateInfoNV; + + + +// VK_EXT_private_data is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_private_data 1 +typedef VkPrivateDataSlot VkPrivateDataSlotEXT; + +#define VK_EXT_PRIVATE_DATA_SPEC_VERSION 1 +#define VK_EXT_PRIVATE_DATA_EXTENSION_NAME "VK_EXT_private_data" +typedef VkPrivateDataSlotCreateFlags VkPrivateDataSlotCreateFlagsEXT; + +typedef VkPhysicalDevicePrivateDataFeatures VkPhysicalDevicePrivateDataFeaturesEXT; + +typedef VkDevicePrivateDataCreateInfo VkDevicePrivateDataCreateInfoEXT; + +typedef VkPrivateDataSlotCreateInfo VkPrivateDataSlotCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreatePrivateDataSlotEXT)(VkDevice device, const VkPrivateDataSlotCreateInfo* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkPrivateDataSlot* pPrivateDataSlot); +typedef void (VKAPI_PTR *PFN_vkDestroyPrivateDataSlotEXT)(VkDevice device, VkPrivateDataSlot privateDataSlot, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkSetPrivateDataEXT)(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t data); +typedef void (VKAPI_PTR *PFN_vkGetPrivateDataEXT)(VkDevice device, VkObjectType objectType, uint64_t objectHandle, VkPrivateDataSlot privateDataSlot, uint64_t* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreatePrivateDataSlotEXT( + VkDevice device, + const VkPrivateDataSlotCreateInfo* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkPrivateDataSlot* pPrivateDataSlot); + +VKAPI_ATTR void VKAPI_CALL vkDestroyPrivateDataSlotEXT( + VkDevice device, + VkPrivateDataSlot privateDataSlot, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetPrivateDataEXT( + VkDevice device, + VkObjectType objectType, + uint64_t objectHandle, + VkPrivateDataSlot privateDataSlot, + uint64_t data); + +VKAPI_ATTR void VKAPI_CALL vkGetPrivateDataEXT( + VkDevice device, + VkObjectType objectType, + uint64_t objectHandle, + VkPrivateDataSlot privateDataSlot, + uint64_t* pData); +#endif + + +// VK_EXT_pipeline_creation_cache_control is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_creation_cache_control 1 +#define VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_SPEC_VERSION 3 +#define VK_EXT_PIPELINE_CREATION_CACHE_CONTROL_EXTENSION_NAME "VK_EXT_pipeline_creation_cache_control" +typedef VkPhysicalDevicePipelineCreationCacheControlFeatures VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT; + + + +// VK_NV_device_diagnostics_config is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_device_diagnostics_config 1 +#define VK_NV_DEVICE_DIAGNOSTICS_CONFIG_SPEC_VERSION 2 +#define VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME "VK_NV_device_diagnostics_config" + +typedef enum VkDeviceDiagnosticsConfigFlagBitsNV { + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV = 0x00000001, + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV = 0x00000002, + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV = 0x00000004, + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV = 0x00000008, + VK_DEVICE_DIAGNOSTICS_CONFIG_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkDeviceDiagnosticsConfigFlagBitsNV; +typedef VkFlags VkDeviceDiagnosticsConfigFlagsNV; +typedef struct VkPhysicalDeviceDiagnosticsConfigFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 diagnosticsConfig; +} VkPhysicalDeviceDiagnosticsConfigFeaturesNV; + +typedef struct VkDeviceDiagnosticsConfigCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkDeviceDiagnosticsConfigFlagsNV flags; +} VkDeviceDiagnosticsConfigCreateInfoNV; + + + +// VK_QCOM_render_pass_store_ops is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_render_pass_store_ops 1 +#define VK_QCOM_RENDER_PASS_STORE_OPS_SPEC_VERSION 2 +#define VK_QCOM_RENDER_PASS_STORE_OPS_EXTENSION_NAME "VK_QCOM_render_pass_store_ops" + + +// VK_NV_cuda_kernel_launch is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_cuda_kernel_launch 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCudaModuleNV) +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkCudaFunctionNV) +#define VK_NV_CUDA_KERNEL_LAUNCH_SPEC_VERSION 2 +#define VK_NV_CUDA_KERNEL_LAUNCH_EXTENSION_NAME "VK_NV_cuda_kernel_launch" +typedef struct VkCudaModuleCreateInfoNV { + VkStructureType sType; + const void* pNext; + size_t dataSize; + const void* pData; +} VkCudaModuleCreateInfoNV; + +typedef struct VkCudaFunctionCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkCudaModuleNV module; + const char* pName; +} VkCudaFunctionCreateInfoNV; + +typedef struct VkCudaLaunchInfoNV { + VkStructureType sType; + const void* pNext; + VkCudaFunctionNV function; + uint32_t gridDimX; + uint32_t gridDimY; + uint32_t gridDimZ; + uint32_t blockDimX; + uint32_t blockDimY; + uint32_t blockDimZ; + uint32_t sharedMemBytes; + size_t paramCount; + const void* const * pParams; + size_t extraCount; + const void* const * pExtras; +} VkCudaLaunchInfoNV; + +typedef struct VkPhysicalDeviceCudaKernelLaunchFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 cudaKernelLaunchFeatures; +} VkPhysicalDeviceCudaKernelLaunchFeaturesNV; + +typedef struct VkPhysicalDeviceCudaKernelLaunchPropertiesNV { + VkStructureType sType; + void* pNext; + uint32_t computeCapabilityMinor; + uint32_t computeCapabilityMajor; +} VkPhysicalDeviceCudaKernelLaunchPropertiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateCudaModuleNV)(VkDevice device, const VkCudaModuleCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCudaModuleNV* pModule); +typedef VkResult (VKAPI_PTR *PFN_vkGetCudaModuleCacheNV)(VkDevice device, VkCudaModuleNV module, size_t* pCacheSize, void* pCacheData); +typedef VkResult (VKAPI_PTR *PFN_vkCreateCudaFunctionNV)(VkDevice device, const VkCudaFunctionCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkCudaFunctionNV* pFunction); +typedef void (VKAPI_PTR *PFN_vkDestroyCudaModuleNV)(VkDevice device, VkCudaModuleNV module, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkDestroyCudaFunctionNV)(VkDevice device, VkCudaFunctionNV function, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdCudaLaunchKernelNV)(VkCommandBuffer commandBuffer, const VkCudaLaunchInfoNV* pLaunchInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCudaModuleNV( + VkDevice device, + const VkCudaModuleCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCudaModuleNV* pModule); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetCudaModuleCacheNV( + VkDevice device, + VkCudaModuleNV module, + size_t* pCacheSize, + void* pCacheData); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateCudaFunctionNV( + VkDevice device, + const VkCudaFunctionCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkCudaFunctionNV* pFunction); + +VKAPI_ATTR void VKAPI_CALL vkDestroyCudaModuleNV( + VkDevice device, + VkCudaModuleNV module, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkDestroyCudaFunctionNV( + VkDevice device, + VkCudaFunctionNV function, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdCudaLaunchKernelNV( + VkCommandBuffer commandBuffer, + const VkCudaLaunchInfoNV* pLaunchInfo); +#endif + + +// VK_NV_low_latency is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_low_latency 1 +#define VK_NV_LOW_LATENCY_SPEC_VERSION 1 +#define VK_NV_LOW_LATENCY_EXTENSION_NAME "VK_NV_low_latency" +typedef struct VkQueryLowLatencySupportNV { + VkStructureType sType; + const void* pNext; + void* pQueriedLowLatencyData; +} VkQueryLowLatencySupportNV; + + + +// VK_EXT_descriptor_buffer is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_descriptor_buffer 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkAccelerationStructureKHR) +#define VK_EXT_DESCRIPTOR_BUFFER_SPEC_VERSION 1 +#define VK_EXT_DESCRIPTOR_BUFFER_EXTENSION_NAME "VK_EXT_descriptor_buffer" +typedef struct VkPhysicalDeviceDescriptorBufferPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 combinedImageSamplerDescriptorSingleArray; + VkBool32 bufferlessPushDescriptors; + VkBool32 allowSamplerImageViewPostSubmitCreation; + VkDeviceSize descriptorBufferOffsetAlignment; + uint32_t maxDescriptorBufferBindings; + uint32_t maxResourceDescriptorBufferBindings; + uint32_t maxSamplerDescriptorBufferBindings; + uint32_t maxEmbeddedImmutableSamplerBindings; + uint32_t maxEmbeddedImmutableSamplers; + size_t bufferCaptureReplayDescriptorDataSize; + size_t imageCaptureReplayDescriptorDataSize; + size_t imageViewCaptureReplayDescriptorDataSize; + size_t samplerCaptureReplayDescriptorDataSize; + size_t accelerationStructureCaptureReplayDescriptorDataSize; + size_t samplerDescriptorSize; + size_t combinedImageSamplerDescriptorSize; + size_t sampledImageDescriptorSize; + size_t storageImageDescriptorSize; + size_t uniformTexelBufferDescriptorSize; + size_t robustUniformTexelBufferDescriptorSize; + size_t storageTexelBufferDescriptorSize; + size_t robustStorageTexelBufferDescriptorSize; + size_t uniformBufferDescriptorSize; + size_t robustUniformBufferDescriptorSize; + size_t storageBufferDescriptorSize; + size_t robustStorageBufferDescriptorSize; + size_t inputAttachmentDescriptorSize; + size_t accelerationStructureDescriptorSize; + VkDeviceSize maxSamplerDescriptorBufferRange; + VkDeviceSize maxResourceDescriptorBufferRange; + VkDeviceSize samplerDescriptorBufferAddressSpaceSize; + VkDeviceSize resourceDescriptorBufferAddressSpaceSize; + VkDeviceSize descriptorBufferAddressSpaceSize; +} VkPhysicalDeviceDescriptorBufferPropertiesEXT; + +typedef struct VkPhysicalDeviceDescriptorBufferDensityMapPropertiesEXT { + VkStructureType sType; + void* pNext; + size_t combinedImageSamplerDensityMapDescriptorSize; +} VkPhysicalDeviceDescriptorBufferDensityMapPropertiesEXT; + +typedef struct VkPhysicalDeviceDescriptorBufferFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 descriptorBuffer; + VkBool32 descriptorBufferCaptureReplay; + VkBool32 descriptorBufferImageLayoutIgnored; + VkBool32 descriptorBufferPushDescriptors; +} VkPhysicalDeviceDescriptorBufferFeaturesEXT; + +typedef struct VkDescriptorAddressInfoEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddress address; + VkDeviceSize range; + VkFormat format; +} VkDescriptorAddressInfoEXT; + +typedef struct VkDescriptorBufferBindingInfoEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddress address; + VkBufferUsageFlags usage; +} VkDescriptorBufferBindingInfoEXT; + +typedef struct VkDescriptorBufferBindingPushDescriptorBufferHandleEXT { + VkStructureType sType; + void* pNext; + VkBuffer buffer; +} VkDescriptorBufferBindingPushDescriptorBufferHandleEXT; + +typedef union VkDescriptorDataEXT { + const VkSampler* pSampler; + const VkDescriptorImageInfo* pCombinedImageSampler; + const VkDescriptorImageInfo* pInputAttachmentImage; + const VkDescriptorImageInfo* pSampledImage; + const VkDescriptorImageInfo* pStorageImage; + const VkDescriptorAddressInfoEXT* pUniformTexelBuffer; + const VkDescriptorAddressInfoEXT* pStorageTexelBuffer; + const VkDescriptorAddressInfoEXT* pUniformBuffer; + const VkDescriptorAddressInfoEXT* pStorageBuffer; + VkDeviceAddress accelerationStructure; +} VkDescriptorDataEXT; + +typedef struct VkDescriptorGetInfoEXT { + VkStructureType sType; + const void* pNext; + VkDescriptorType type; + VkDescriptorDataEXT data; +} VkDescriptorGetInfoEXT; + +typedef struct VkBufferCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkBuffer buffer; +} VkBufferCaptureDescriptorDataInfoEXT; + +typedef struct VkImageCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; +} VkImageCaptureDescriptorDataInfoEXT; + +typedef struct VkImageViewCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkImageView imageView; +} VkImageViewCaptureDescriptorDataInfoEXT; + +typedef struct VkSamplerCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkSampler sampler; +} VkSamplerCaptureDescriptorDataInfoEXT; + +typedef struct VkOpaqueCaptureDescriptorDataCreateInfoEXT { + VkStructureType sType; + const void* pNext; + const void* opaqueCaptureDescriptorData; +} VkOpaqueCaptureDescriptorDataCreateInfoEXT; + +typedef struct VkAccelerationStructureCaptureDescriptorDataInfoEXT { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureKHR accelerationStructure; + VkAccelerationStructureNV accelerationStructureNV; +} VkAccelerationStructureCaptureDescriptorDataInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutSizeEXT)(VkDevice device, VkDescriptorSetLayout layout, VkDeviceSize* pLayoutSizeInBytes); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutBindingOffsetEXT)(VkDevice device, VkDescriptorSetLayout layout, uint32_t binding, VkDeviceSize* pOffset); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorEXT)(VkDevice device, const VkDescriptorGetInfoEXT* pDescriptorInfo, size_t dataSize, void* pDescriptor); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBuffersEXT)(VkCommandBuffer commandBuffer, uint32_t bufferCount, const VkDescriptorBufferBindingInfoEXT* pBindingInfos); +typedef void (VKAPI_PTR *PFN_vkCmdSetDescriptorBufferOffsetsEXT)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const uint32_t* pBufferIndices, const VkDeviceSize* pOffsets); +typedef void (VKAPI_PTR *PFN_vkCmdBindDescriptorBufferEmbeddedSamplersEXT)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t set); +typedef VkResult (VKAPI_PTR *PFN_vkGetBufferOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkBufferCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetImageOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkImageCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetImageViewOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkImageViewCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetSamplerOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, void* pData); +typedef VkResult (VKAPI_PTR *PFN_vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT)(VkDevice device, const VkAccelerationStructureCaptureDescriptorDataInfoEXT* pInfo, void* pData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutSizeEXT( + VkDevice device, + VkDescriptorSetLayout layout, + VkDeviceSize* pLayoutSizeInBytes); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutBindingOffsetEXT( + VkDevice device, + VkDescriptorSetLayout layout, + uint32_t binding, + VkDeviceSize* pOffset); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorEXT( + VkDevice device, + const VkDescriptorGetInfoEXT* pDescriptorInfo, + size_t dataSize, + void* pDescriptor); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBuffersEXT( + VkCommandBuffer commandBuffer, + uint32_t bufferCount, + const VkDescriptorBufferBindingInfoEXT* pBindingInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDescriptorBufferOffsetsEXT( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t firstSet, + uint32_t setCount, + const uint32_t* pBufferIndices, + const VkDeviceSize* pOffsets); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindDescriptorBufferEmbeddedSamplersEXT( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipelineLayout layout, + uint32_t set); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetBufferOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkBufferCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkImageCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetImageViewOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkImageViewCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSamplerOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkSamplerCaptureDescriptorDataInfoEXT* pInfo, + void* pData); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetAccelerationStructureOpaqueCaptureDescriptorDataEXT( + VkDevice device, + const VkAccelerationStructureCaptureDescriptorDataInfoEXT* pInfo, + void* pData); +#endif + + +// VK_EXT_graphics_pipeline_library is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_graphics_pipeline_library 1 +#define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_SPEC_VERSION 1 +#define VK_EXT_GRAPHICS_PIPELINE_LIBRARY_EXTENSION_NAME "VK_EXT_graphics_pipeline_library" + +typedef enum VkGraphicsPipelineLibraryFlagBitsEXT { + VK_GRAPHICS_PIPELINE_LIBRARY_VERTEX_INPUT_INTERFACE_BIT_EXT = 0x00000001, + VK_GRAPHICS_PIPELINE_LIBRARY_PRE_RASTERIZATION_SHADERS_BIT_EXT = 0x00000002, + VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_SHADER_BIT_EXT = 0x00000004, + VK_GRAPHICS_PIPELINE_LIBRARY_FRAGMENT_OUTPUT_INTERFACE_BIT_EXT = 0x00000008, + VK_GRAPHICS_PIPELINE_LIBRARY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkGraphicsPipelineLibraryFlagBitsEXT; +typedef VkFlags VkGraphicsPipelineLibraryFlagsEXT; +typedef struct VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 graphicsPipelineLibrary; +} VkPhysicalDeviceGraphicsPipelineLibraryFeaturesEXT; + +typedef struct VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 graphicsPipelineLibraryFastLinking; + VkBool32 graphicsPipelineLibraryIndependentInterpolationDecoration; +} VkPhysicalDeviceGraphicsPipelineLibraryPropertiesEXT; + +typedef struct VkGraphicsPipelineLibraryCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkGraphicsPipelineLibraryFlagsEXT flags; +} VkGraphicsPipelineLibraryCreateInfoEXT; + + + +// VK_AMD_shader_early_and_late_fragment_tests is a preprocessor guard. Do not pass it to API calls. +#define VK_AMD_shader_early_and_late_fragment_tests 1 +#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_SPEC_VERSION 1 +#define VK_AMD_SHADER_EARLY_AND_LATE_FRAGMENT_TESTS_EXTENSION_NAME "VK_AMD_shader_early_and_late_fragment_tests" +typedef struct VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD { + VkStructureType sType; + void* pNext; + VkBool32 shaderEarlyAndLateFragmentTests; +} VkPhysicalDeviceShaderEarlyAndLateFragmentTestsFeaturesAMD; + + + +// VK_NV_fragment_shading_rate_enums is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_fragment_shading_rate_enums 1 +#define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_SPEC_VERSION 1 +#define VK_NV_FRAGMENT_SHADING_RATE_ENUMS_EXTENSION_NAME "VK_NV_fragment_shading_rate_enums" + +typedef enum VkFragmentShadingRateTypeNV { + VK_FRAGMENT_SHADING_RATE_TYPE_FRAGMENT_SIZE_NV = 0, + VK_FRAGMENT_SHADING_RATE_TYPE_ENUMS_NV = 1, + VK_FRAGMENT_SHADING_RATE_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkFragmentShadingRateTypeNV; + +typedef enum VkFragmentShadingRateNV { + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_PIXEL_NV = 0, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_1X2_PIXELS_NV = 1, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X1_PIXELS_NV = 4, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X2_PIXELS_NV = 5, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_2X4_PIXELS_NV = 6, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X2_PIXELS_NV = 9, + VK_FRAGMENT_SHADING_RATE_1_INVOCATION_PER_4X4_PIXELS_NV = 10, + VK_FRAGMENT_SHADING_RATE_2_INVOCATIONS_PER_PIXEL_NV = 11, + VK_FRAGMENT_SHADING_RATE_4_INVOCATIONS_PER_PIXEL_NV = 12, + VK_FRAGMENT_SHADING_RATE_8_INVOCATIONS_PER_PIXEL_NV = 13, + VK_FRAGMENT_SHADING_RATE_16_INVOCATIONS_PER_PIXEL_NV = 14, + VK_FRAGMENT_SHADING_RATE_NO_INVOCATIONS_NV = 15, + VK_FRAGMENT_SHADING_RATE_MAX_ENUM_NV = 0x7FFFFFFF +} VkFragmentShadingRateNV; +typedef struct VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 fragmentShadingRateEnums; + VkBool32 supersampleFragmentShadingRates; + VkBool32 noInvocationFragmentShadingRates; +} VkPhysicalDeviceFragmentShadingRateEnumsFeaturesNV; + +typedef struct VkPhysicalDeviceFragmentShadingRateEnumsPropertiesNV { + VkStructureType sType; + void* pNext; + VkSampleCountFlagBits maxFragmentShadingRateInvocationCount; +} VkPhysicalDeviceFragmentShadingRateEnumsPropertiesNV; + +typedef struct VkPipelineFragmentShadingRateEnumStateCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkFragmentShadingRateTypeNV shadingRateType; + VkFragmentShadingRateNV shadingRate; + VkFragmentShadingRateCombinerOpKHR combinerOps[2]; +} VkPipelineFragmentShadingRateEnumStateCreateInfoNV; + +typedef void (VKAPI_PTR *PFN_vkCmdSetFragmentShadingRateEnumNV)(VkCommandBuffer commandBuffer, VkFragmentShadingRateNV shadingRate, const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetFragmentShadingRateEnumNV( + VkCommandBuffer commandBuffer, + VkFragmentShadingRateNV shadingRate, + const VkFragmentShadingRateCombinerOpKHR combinerOps[2]); +#endif + + +// VK_NV_ray_tracing_motion_blur is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_ray_tracing_motion_blur 1 +#define VK_NV_RAY_TRACING_MOTION_BLUR_SPEC_VERSION 1 +#define VK_NV_RAY_TRACING_MOTION_BLUR_EXTENSION_NAME "VK_NV_ray_tracing_motion_blur" + +typedef enum VkAccelerationStructureMotionInstanceTypeNV { + VK_ACCELERATION_STRUCTURE_MOTION_INSTANCE_TYPE_STATIC_NV = 0, + VK_ACCELERATION_STRUCTURE_MOTION_INSTANCE_TYPE_MATRIX_MOTION_NV = 1, + VK_ACCELERATION_STRUCTURE_MOTION_INSTANCE_TYPE_SRT_MOTION_NV = 2, + VK_ACCELERATION_STRUCTURE_MOTION_INSTANCE_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkAccelerationStructureMotionInstanceTypeNV; +typedef VkFlags VkAccelerationStructureMotionInfoFlagsNV; +typedef VkFlags VkAccelerationStructureMotionInstanceFlagsNV; +typedef union VkDeviceOrHostAddressConstKHR { + VkDeviceAddress deviceAddress; + const void* hostAddress; +} VkDeviceOrHostAddressConstKHR; + +typedef struct VkAccelerationStructureGeometryMotionTrianglesDataNV { + VkStructureType sType; + const void* pNext; + VkDeviceOrHostAddressConstKHR vertexData; +} VkAccelerationStructureGeometryMotionTrianglesDataNV; + +typedef struct VkAccelerationStructureMotionInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t maxInstances; + VkAccelerationStructureMotionInfoFlagsNV flags; +} VkAccelerationStructureMotionInfoNV; + +typedef struct VkAccelerationStructureMatrixMotionInstanceNV { + VkTransformMatrixKHR transformT0; + VkTransformMatrixKHR transformT1; + uint32_t instanceCustomIndex:24; + uint32_t mask:8; + uint32_t instanceShaderBindingTableRecordOffset:24; + VkGeometryInstanceFlagsKHR flags:8; + uint64_t accelerationStructureReference; +} VkAccelerationStructureMatrixMotionInstanceNV; + +typedef struct VkSRTDataNV { + float sx; + float a; + float b; + float pvx; + float sy; + float c; + float pvy; + float sz; + float pvz; + float qx; + float qy; + float qz; + float qw; + float tx; + float ty; + float tz; +} VkSRTDataNV; + +typedef struct VkAccelerationStructureSRTMotionInstanceNV { + VkSRTDataNV transformT0; + VkSRTDataNV transformT1; + uint32_t instanceCustomIndex:24; + uint32_t mask:8; + uint32_t instanceShaderBindingTableRecordOffset:24; + VkGeometryInstanceFlagsKHR flags:8; + uint64_t accelerationStructureReference; +} VkAccelerationStructureSRTMotionInstanceNV; + +typedef union VkAccelerationStructureMotionInstanceDataNV { + VkAccelerationStructureInstanceKHR staticInstance; + VkAccelerationStructureMatrixMotionInstanceNV matrixMotionInstance; + VkAccelerationStructureSRTMotionInstanceNV srtMotionInstance; +} VkAccelerationStructureMotionInstanceDataNV; + +typedef struct VkAccelerationStructureMotionInstanceNV { + VkAccelerationStructureMotionInstanceTypeNV type; + VkAccelerationStructureMotionInstanceFlagsNV flags; + VkAccelerationStructureMotionInstanceDataNV data; +} VkAccelerationStructureMotionInstanceNV; + +typedef struct VkPhysicalDeviceRayTracingMotionBlurFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingMotionBlur; + VkBool32 rayTracingMotionBlurPipelineTraceRaysIndirect; +} VkPhysicalDeviceRayTracingMotionBlurFeaturesNV; + + + +// VK_EXT_ycbcr_2plane_444_formats is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_ycbcr_2plane_444_formats 1 +#define VK_EXT_YCBCR_2PLANE_444_FORMATS_SPEC_VERSION 1 +#define VK_EXT_YCBCR_2PLANE_444_FORMATS_EXTENSION_NAME "VK_EXT_ycbcr_2plane_444_formats" +typedef struct VkPhysicalDeviceYcbcr2Plane444FormatsFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 ycbcr2plane444Formats; +} VkPhysicalDeviceYcbcr2Plane444FormatsFeaturesEXT; + + + +// VK_EXT_fragment_density_map2 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_fragment_density_map2 1 +#define VK_EXT_FRAGMENT_DENSITY_MAP_2_SPEC_VERSION 1 +#define VK_EXT_FRAGMENT_DENSITY_MAP_2_EXTENSION_NAME "VK_EXT_fragment_density_map2" +typedef struct VkPhysicalDeviceFragmentDensityMap2FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 fragmentDensityMapDeferred; +} VkPhysicalDeviceFragmentDensityMap2FeaturesEXT; + +typedef struct VkPhysicalDeviceFragmentDensityMap2PropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 subsampledLoads; + VkBool32 subsampledCoarseReconstructionEarlyAccess; + uint32_t maxSubsampledArrayLayers; + uint32_t maxDescriptorSetSubsampledSamplers; +} VkPhysicalDeviceFragmentDensityMap2PropertiesEXT; + + + +// VK_QCOM_rotated_copy_commands is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_rotated_copy_commands 1 +#define VK_QCOM_ROTATED_COPY_COMMANDS_SPEC_VERSION 2 +#define VK_QCOM_ROTATED_COPY_COMMANDS_EXTENSION_NAME "VK_QCOM_rotated_copy_commands" +typedef struct VkCopyCommandTransformInfoQCOM { + VkStructureType sType; + const void* pNext; + VkSurfaceTransformFlagBitsKHR transform; +} VkCopyCommandTransformInfoQCOM; + + + +// VK_EXT_image_robustness is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_robustness 1 +#define VK_EXT_IMAGE_ROBUSTNESS_SPEC_VERSION 1 +#define VK_EXT_IMAGE_ROBUSTNESS_EXTENSION_NAME "VK_EXT_image_robustness" +typedef VkPhysicalDeviceImageRobustnessFeatures VkPhysicalDeviceImageRobustnessFeaturesEXT; + + + +// VK_EXT_image_compression_control is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_compression_control 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_SPEC_VERSION 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_EXTENSION_NAME "VK_EXT_image_compression_control" + +typedef enum VkImageCompressionFlagBitsEXT { + VK_IMAGE_COMPRESSION_DEFAULT_EXT = 0, + VK_IMAGE_COMPRESSION_FIXED_RATE_DEFAULT_EXT = 0x00000001, + VK_IMAGE_COMPRESSION_FIXED_RATE_EXPLICIT_EXT = 0x00000002, + VK_IMAGE_COMPRESSION_DISABLED_EXT = 0x00000004, + VK_IMAGE_COMPRESSION_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkImageCompressionFlagBitsEXT; +typedef VkFlags VkImageCompressionFlagsEXT; + +typedef enum VkImageCompressionFixedRateFlagBitsEXT { + VK_IMAGE_COMPRESSION_FIXED_RATE_NONE_EXT = 0, + VK_IMAGE_COMPRESSION_FIXED_RATE_1BPC_BIT_EXT = 0x00000001, + VK_IMAGE_COMPRESSION_FIXED_RATE_2BPC_BIT_EXT = 0x00000002, + VK_IMAGE_COMPRESSION_FIXED_RATE_3BPC_BIT_EXT = 0x00000004, + VK_IMAGE_COMPRESSION_FIXED_RATE_4BPC_BIT_EXT = 0x00000008, + VK_IMAGE_COMPRESSION_FIXED_RATE_5BPC_BIT_EXT = 0x00000010, + VK_IMAGE_COMPRESSION_FIXED_RATE_6BPC_BIT_EXT = 0x00000020, + VK_IMAGE_COMPRESSION_FIXED_RATE_7BPC_BIT_EXT = 0x00000040, + VK_IMAGE_COMPRESSION_FIXED_RATE_8BPC_BIT_EXT = 0x00000080, + VK_IMAGE_COMPRESSION_FIXED_RATE_9BPC_BIT_EXT = 0x00000100, + VK_IMAGE_COMPRESSION_FIXED_RATE_10BPC_BIT_EXT = 0x00000200, + VK_IMAGE_COMPRESSION_FIXED_RATE_11BPC_BIT_EXT = 0x00000400, + VK_IMAGE_COMPRESSION_FIXED_RATE_12BPC_BIT_EXT = 0x00000800, + VK_IMAGE_COMPRESSION_FIXED_RATE_13BPC_BIT_EXT = 0x00001000, + VK_IMAGE_COMPRESSION_FIXED_RATE_14BPC_BIT_EXT = 0x00002000, + VK_IMAGE_COMPRESSION_FIXED_RATE_15BPC_BIT_EXT = 0x00004000, + VK_IMAGE_COMPRESSION_FIXED_RATE_16BPC_BIT_EXT = 0x00008000, + VK_IMAGE_COMPRESSION_FIXED_RATE_17BPC_BIT_EXT = 0x00010000, + VK_IMAGE_COMPRESSION_FIXED_RATE_18BPC_BIT_EXT = 0x00020000, + VK_IMAGE_COMPRESSION_FIXED_RATE_19BPC_BIT_EXT = 0x00040000, + VK_IMAGE_COMPRESSION_FIXED_RATE_20BPC_BIT_EXT = 0x00080000, + VK_IMAGE_COMPRESSION_FIXED_RATE_21BPC_BIT_EXT = 0x00100000, + VK_IMAGE_COMPRESSION_FIXED_RATE_22BPC_BIT_EXT = 0x00200000, + VK_IMAGE_COMPRESSION_FIXED_RATE_23BPC_BIT_EXT = 0x00400000, + VK_IMAGE_COMPRESSION_FIXED_RATE_24BPC_BIT_EXT = 0x00800000, + VK_IMAGE_COMPRESSION_FIXED_RATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkImageCompressionFixedRateFlagBitsEXT; +typedef VkFlags VkImageCompressionFixedRateFlagsEXT; +typedef struct VkPhysicalDeviceImageCompressionControlFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 imageCompressionControl; +} VkPhysicalDeviceImageCompressionControlFeaturesEXT; + +typedef struct VkImageCompressionControlEXT { + VkStructureType sType; + const void* pNext; + VkImageCompressionFlagsEXT flags; + uint32_t compressionControlPlaneCount; + VkImageCompressionFixedRateFlagsEXT* pFixedRateFlags; +} VkImageCompressionControlEXT; + +typedef struct VkImageCompressionPropertiesEXT { + VkStructureType sType; + void* pNext; + VkImageCompressionFlagsEXT imageCompressionFlags; + VkImageCompressionFixedRateFlagsEXT imageCompressionFixedRateFlags; +} VkImageCompressionPropertiesEXT; + + + +// VK_EXT_attachment_feedback_loop_layout is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_attachment_feedback_loop_layout 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_SPEC_VERSION 2 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_LAYOUT_EXTENSION_NAME "VK_EXT_attachment_feedback_loop_layout" +typedef struct VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 attachmentFeedbackLoopLayout; +} VkPhysicalDeviceAttachmentFeedbackLoopLayoutFeaturesEXT; + + + +// VK_EXT_4444_formats is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_4444_formats 1 +#define VK_EXT_4444_FORMATS_SPEC_VERSION 1 +#define VK_EXT_4444_FORMATS_EXTENSION_NAME "VK_EXT_4444_formats" +typedef struct VkPhysicalDevice4444FormatsFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 formatA4R4G4B4; + VkBool32 formatA4B4G4R4; +} VkPhysicalDevice4444FormatsFeaturesEXT; + + + +// VK_EXT_device_fault is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_device_fault 1 +#define VK_EXT_DEVICE_FAULT_SPEC_VERSION 2 +#define VK_EXT_DEVICE_FAULT_EXTENSION_NAME "VK_EXT_device_fault" + +typedef enum VkDeviceFaultAddressTypeEXT { + VK_DEVICE_FAULT_ADDRESS_TYPE_NONE_EXT = 0, + VK_DEVICE_FAULT_ADDRESS_TYPE_READ_INVALID_EXT = 1, + VK_DEVICE_FAULT_ADDRESS_TYPE_WRITE_INVALID_EXT = 2, + VK_DEVICE_FAULT_ADDRESS_TYPE_EXECUTE_INVALID_EXT = 3, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_UNKNOWN_EXT = 4, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_INVALID_EXT = 5, + VK_DEVICE_FAULT_ADDRESS_TYPE_INSTRUCTION_POINTER_FAULT_EXT = 6, + VK_DEVICE_FAULT_ADDRESS_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceFaultAddressTypeEXT; + +typedef enum VkDeviceFaultVendorBinaryHeaderVersionEXT { + VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_ONE_EXT = 1, + VK_DEVICE_FAULT_VENDOR_BINARY_HEADER_VERSION_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceFaultVendorBinaryHeaderVersionEXT; +typedef struct VkPhysicalDeviceFaultFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 deviceFault; + VkBool32 deviceFaultVendorBinary; +} VkPhysicalDeviceFaultFeaturesEXT; + +typedef struct VkDeviceFaultCountsEXT { + VkStructureType sType; + void* pNext; + uint32_t addressInfoCount; + uint32_t vendorInfoCount; + VkDeviceSize vendorBinarySize; +} VkDeviceFaultCountsEXT; + +typedef struct VkDeviceFaultAddressInfoEXT { + VkDeviceFaultAddressTypeEXT addressType; + VkDeviceAddress reportedAddress; + VkDeviceSize addressPrecision; +} VkDeviceFaultAddressInfoEXT; + +typedef struct VkDeviceFaultVendorInfoEXT { + char description[VK_MAX_DESCRIPTION_SIZE]; + uint64_t vendorFaultCode; + uint64_t vendorFaultData; +} VkDeviceFaultVendorInfoEXT; + +typedef struct VkDeviceFaultInfoEXT { + VkStructureType sType; + void* pNext; + char description[VK_MAX_DESCRIPTION_SIZE]; + VkDeviceFaultAddressInfoEXT* pAddressInfos; + VkDeviceFaultVendorInfoEXT* pVendorInfos; + void* pVendorBinaryData; +} VkDeviceFaultInfoEXT; + +typedef struct VkDeviceFaultVendorBinaryHeaderVersionOneEXT { + uint32_t headerSize; + VkDeviceFaultVendorBinaryHeaderVersionEXT headerVersion; + uint32_t vendorID; + uint32_t deviceID; + uint32_t driverVersion; + uint8_t pipelineCacheUUID[VK_UUID_SIZE]; + uint32_t applicationNameOffset; + uint32_t applicationVersion; + uint32_t engineNameOffset; + uint32_t engineVersion; + uint32_t apiVersion; +} VkDeviceFaultVendorBinaryHeaderVersionOneEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceFaultInfoEXT)(VkDevice device, VkDeviceFaultCountsEXT* pFaultCounts, VkDeviceFaultInfoEXT* pFaultInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceFaultInfoEXT( + VkDevice device, + VkDeviceFaultCountsEXT* pFaultCounts, + VkDeviceFaultInfoEXT* pFaultInfo); +#endif + + +// VK_ARM_rasterization_order_attachment_access is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_rasterization_order_attachment_access 1 +#define VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION 1 +#define VK_ARM_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME "VK_ARM_rasterization_order_attachment_access" +typedef struct VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 rasterizationOrderColorAttachmentAccess; + VkBool32 rasterizationOrderDepthAttachmentAccess; + VkBool32 rasterizationOrderStencilAttachmentAccess; +} VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT; + +typedef VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesEXT VkPhysicalDeviceRasterizationOrderAttachmentAccessFeaturesARM; + + + +// VK_EXT_rgba10x6_formats is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_rgba10x6_formats 1 +#define VK_EXT_RGBA10X6_FORMATS_SPEC_VERSION 1 +#define VK_EXT_RGBA10X6_FORMATS_EXTENSION_NAME "VK_EXT_rgba10x6_formats" +typedef struct VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 formatRgba10x6WithoutYCbCrSampler; +} VkPhysicalDeviceRGBA10X6FormatsFeaturesEXT; + + + +// VK_VALVE_mutable_descriptor_type is a preprocessor guard. Do not pass it to API calls. +#define VK_VALVE_mutable_descriptor_type 1 +#define VK_VALVE_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION 1 +#define VK_VALVE_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME "VK_VALVE_mutable_descriptor_type" +typedef struct VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 mutableDescriptorType; +} VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT; + +typedef VkPhysicalDeviceMutableDescriptorTypeFeaturesEXT VkPhysicalDeviceMutableDescriptorTypeFeaturesVALVE; + +typedef struct VkMutableDescriptorTypeListEXT { + uint32_t descriptorTypeCount; + const VkDescriptorType* pDescriptorTypes; +} VkMutableDescriptorTypeListEXT; + +typedef VkMutableDescriptorTypeListEXT VkMutableDescriptorTypeListVALVE; + +typedef struct VkMutableDescriptorTypeCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t mutableDescriptorTypeListCount; + const VkMutableDescriptorTypeListEXT* pMutableDescriptorTypeLists; +} VkMutableDescriptorTypeCreateInfoEXT; + +typedef VkMutableDescriptorTypeCreateInfoEXT VkMutableDescriptorTypeCreateInfoVALVE; + + + +// VK_EXT_vertex_input_dynamic_state is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_vertex_input_dynamic_state 1 +#define VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_SPEC_VERSION 2 +#define VK_EXT_VERTEX_INPUT_DYNAMIC_STATE_EXTENSION_NAME "VK_EXT_vertex_input_dynamic_state" +typedef struct VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 vertexInputDynamicState; +} VkPhysicalDeviceVertexInputDynamicStateFeaturesEXT; + +typedef struct VkVertexInputBindingDescription2EXT { + VkStructureType sType; + void* pNext; + uint32_t binding; + uint32_t stride; + VkVertexInputRate inputRate; + uint32_t divisor; +} VkVertexInputBindingDescription2EXT; + +typedef struct VkVertexInputAttributeDescription2EXT { + VkStructureType sType; + void* pNext; + uint32_t location; + uint32_t binding; + VkFormat format; + uint32_t offset; +} VkVertexInputAttributeDescription2EXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetVertexInputEXT)(VkCommandBuffer commandBuffer, uint32_t vertexBindingDescriptionCount, const VkVertexInputBindingDescription2EXT* pVertexBindingDescriptions, uint32_t vertexAttributeDescriptionCount, const VkVertexInputAttributeDescription2EXT* pVertexAttributeDescriptions); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetVertexInputEXT( + VkCommandBuffer commandBuffer, + uint32_t vertexBindingDescriptionCount, + const VkVertexInputBindingDescription2EXT* pVertexBindingDescriptions, + uint32_t vertexAttributeDescriptionCount, + const VkVertexInputAttributeDescription2EXT* pVertexAttributeDescriptions); +#endif + + +// VK_EXT_physical_device_drm is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_physical_device_drm 1 +#define VK_EXT_PHYSICAL_DEVICE_DRM_SPEC_VERSION 1 +#define VK_EXT_PHYSICAL_DEVICE_DRM_EXTENSION_NAME "VK_EXT_physical_device_drm" +typedef struct VkPhysicalDeviceDrmPropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 hasPrimary; + VkBool32 hasRender; + int64_t primaryMajor; + int64_t primaryMinor; + int64_t renderMajor; + int64_t renderMinor; +} VkPhysicalDeviceDrmPropertiesEXT; + + + +// VK_EXT_device_address_binding_report is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_device_address_binding_report 1 +#define VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_SPEC_VERSION 1 +#define VK_EXT_DEVICE_ADDRESS_BINDING_REPORT_EXTENSION_NAME "VK_EXT_device_address_binding_report" + +typedef enum VkDeviceAddressBindingTypeEXT { + VK_DEVICE_ADDRESS_BINDING_TYPE_BIND_EXT = 0, + VK_DEVICE_ADDRESS_BINDING_TYPE_UNBIND_EXT = 1, + VK_DEVICE_ADDRESS_BINDING_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceAddressBindingTypeEXT; + +typedef enum VkDeviceAddressBindingFlagBitsEXT { + VK_DEVICE_ADDRESS_BINDING_INTERNAL_OBJECT_BIT_EXT = 0x00000001, + VK_DEVICE_ADDRESS_BINDING_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkDeviceAddressBindingFlagBitsEXT; +typedef VkFlags VkDeviceAddressBindingFlagsEXT; +typedef struct VkPhysicalDeviceAddressBindingReportFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 reportAddressBinding; +} VkPhysicalDeviceAddressBindingReportFeaturesEXT; + +typedef struct VkDeviceAddressBindingCallbackDataEXT { + VkStructureType sType; + void* pNext; + VkDeviceAddressBindingFlagsEXT flags; + VkDeviceAddress baseAddress; + VkDeviceSize size; + VkDeviceAddressBindingTypeEXT bindingType; +} VkDeviceAddressBindingCallbackDataEXT; + + + +// VK_EXT_depth_clip_control is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_depth_clip_control 1 +#define VK_EXT_DEPTH_CLIP_CONTROL_SPEC_VERSION 1 +#define VK_EXT_DEPTH_CLIP_CONTROL_EXTENSION_NAME "VK_EXT_depth_clip_control" +typedef struct VkPhysicalDeviceDepthClipControlFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 depthClipControl; +} VkPhysicalDeviceDepthClipControlFeaturesEXT; + +typedef struct VkPipelineViewportDepthClipControlCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 negativeOneToOne; +} VkPipelineViewportDepthClipControlCreateInfoEXT; + + + +// VK_EXT_primitive_topology_list_restart is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_primitive_topology_list_restart 1 +#define VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_SPEC_VERSION 1 +#define VK_EXT_PRIMITIVE_TOPOLOGY_LIST_RESTART_EXTENSION_NAME "VK_EXT_primitive_topology_list_restart" +typedef struct VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 primitiveTopologyListRestart; + VkBool32 primitiveTopologyPatchListRestart; +} VkPhysicalDevicePrimitiveTopologyListRestartFeaturesEXT; + + + +// VK_HUAWEI_subpass_shading is a preprocessor guard. Do not pass it to API calls. +#define VK_HUAWEI_subpass_shading 1 +#define VK_HUAWEI_SUBPASS_SHADING_SPEC_VERSION 3 +#define VK_HUAWEI_SUBPASS_SHADING_EXTENSION_NAME "VK_HUAWEI_subpass_shading" +typedef struct VkSubpassShadingPipelineCreateInfoHUAWEI { + VkStructureType sType; + void* pNext; + VkRenderPass renderPass; + uint32_t subpass; +} VkSubpassShadingPipelineCreateInfoHUAWEI; + +typedef struct VkPhysicalDeviceSubpassShadingFeaturesHUAWEI { + VkStructureType sType; + void* pNext; + VkBool32 subpassShading; +} VkPhysicalDeviceSubpassShadingFeaturesHUAWEI; + +typedef struct VkPhysicalDeviceSubpassShadingPropertiesHUAWEI { + VkStructureType sType; + void* pNext; + uint32_t maxSubpassShadingWorkgroupSizeAspectRatio; +} VkPhysicalDeviceSubpassShadingPropertiesHUAWEI; + +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI)(VkDevice device, VkRenderPass renderpass, VkExtent2D* pMaxWorkgroupSize); +typedef void (VKAPI_PTR *PFN_vkCmdSubpassShadingHUAWEI)(VkCommandBuffer commandBuffer); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceSubpassShadingMaxWorkgroupSizeHUAWEI( + VkDevice device, + VkRenderPass renderpass, + VkExtent2D* pMaxWorkgroupSize); + +VKAPI_ATTR void VKAPI_CALL vkCmdSubpassShadingHUAWEI( + VkCommandBuffer commandBuffer); +#endif + + +// VK_HUAWEI_invocation_mask is a preprocessor guard. Do not pass it to API calls. +#define VK_HUAWEI_invocation_mask 1 +#define VK_HUAWEI_INVOCATION_MASK_SPEC_VERSION 1 +#define VK_HUAWEI_INVOCATION_MASK_EXTENSION_NAME "VK_HUAWEI_invocation_mask" +typedef struct VkPhysicalDeviceInvocationMaskFeaturesHUAWEI { + VkStructureType sType; + void* pNext; + VkBool32 invocationMask; +} VkPhysicalDeviceInvocationMaskFeaturesHUAWEI; + +typedef void (VKAPI_PTR *PFN_vkCmdBindInvocationMaskHUAWEI)(VkCommandBuffer commandBuffer, VkImageView imageView, VkImageLayout imageLayout); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdBindInvocationMaskHUAWEI( + VkCommandBuffer commandBuffer, + VkImageView imageView, + VkImageLayout imageLayout); +#endif + + +// VK_NV_external_memory_rdma is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_external_memory_rdma 1 +typedef void* VkRemoteAddressNV; +#define VK_NV_EXTERNAL_MEMORY_RDMA_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_RDMA_EXTENSION_NAME "VK_NV_external_memory_rdma" +typedef struct VkMemoryGetRemoteAddressInfoNV { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkMemoryGetRemoteAddressInfoNV; + +typedef struct VkPhysicalDeviceExternalMemoryRDMAFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 externalMemoryRDMA; +} VkPhysicalDeviceExternalMemoryRDMAFeaturesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryRemoteAddressNV)(VkDevice device, const VkMemoryGetRemoteAddressInfoNV* pMemoryGetRemoteAddressInfo, VkRemoteAddressNV* pAddress); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryRemoteAddressNV( + VkDevice device, + const VkMemoryGetRemoteAddressInfoNV* pMemoryGetRemoteAddressInfo, + VkRemoteAddressNV* pAddress); +#endif + + +// VK_EXT_pipeline_properties is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_properties 1 +#define VK_EXT_PIPELINE_PROPERTIES_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_PROPERTIES_EXTENSION_NAME "VK_EXT_pipeline_properties" +typedef VkPipelineInfoKHR VkPipelineInfoEXT; + +typedef struct VkPipelinePropertiesIdentifierEXT { + VkStructureType sType; + void* pNext; + uint8_t pipelineIdentifier[VK_UUID_SIZE]; +} VkPipelinePropertiesIdentifierEXT; + +typedef struct VkPhysicalDevicePipelinePropertiesFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelinePropertiesIdentifier; +} VkPhysicalDevicePipelinePropertiesFeaturesEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPipelinePropertiesEXT)(VkDevice device, const VkPipelineInfoEXT* pPipelineInfo, VkBaseOutStructure* pPipelineProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPipelinePropertiesEXT( + VkDevice device, + const VkPipelineInfoEXT* pPipelineInfo, + VkBaseOutStructure* pPipelineProperties); +#endif + + +// VK_EXT_frame_boundary is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_frame_boundary 1 +#define VK_EXT_FRAME_BOUNDARY_SPEC_VERSION 1 +#define VK_EXT_FRAME_BOUNDARY_EXTENSION_NAME "VK_EXT_frame_boundary" + +typedef enum VkFrameBoundaryFlagBitsEXT { + VK_FRAME_BOUNDARY_FRAME_END_BIT_EXT = 0x00000001, + VK_FRAME_BOUNDARY_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkFrameBoundaryFlagBitsEXT; +typedef VkFlags VkFrameBoundaryFlagsEXT; +typedef struct VkPhysicalDeviceFrameBoundaryFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 frameBoundary; +} VkPhysicalDeviceFrameBoundaryFeaturesEXT; + +typedef struct VkFrameBoundaryEXT { + VkStructureType sType; + const void* pNext; + VkFrameBoundaryFlagsEXT flags; + uint64_t frameID; + uint32_t imageCount; + const VkImage* pImages; + uint32_t bufferCount; + const VkBuffer* pBuffers; + uint64_t tagName; + size_t tagSize; + const void* pTag; +} VkFrameBoundaryEXT; + + + +// VK_EXT_multisampled_render_to_single_sampled is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_multisampled_render_to_single_sampled 1 +#define VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_SPEC_VERSION 1 +#define VK_EXT_MULTISAMPLED_RENDER_TO_SINGLE_SAMPLED_EXTENSION_NAME "VK_EXT_multisampled_render_to_single_sampled" +typedef struct VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 multisampledRenderToSingleSampled; +} VkPhysicalDeviceMultisampledRenderToSingleSampledFeaturesEXT; + +typedef struct VkSubpassResolvePerformanceQueryEXT { + VkStructureType sType; + void* pNext; + VkBool32 optimal; +} VkSubpassResolvePerformanceQueryEXT; + +typedef struct VkMultisampledRenderToSingleSampledInfoEXT { + VkStructureType sType; + const void* pNext; + VkBool32 multisampledRenderToSingleSampledEnable; + VkSampleCountFlagBits rasterizationSamples; +} VkMultisampledRenderToSingleSampledInfoEXT; + + + +// VK_EXT_extended_dynamic_state2 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_extended_dynamic_state2 1 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_2_SPEC_VERSION 1 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_2_EXTENSION_NAME "VK_EXT_extended_dynamic_state2" +typedef struct VkPhysicalDeviceExtendedDynamicState2FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 extendedDynamicState2; + VkBool32 extendedDynamicState2LogicOp; + VkBool32 extendedDynamicState2PatchControlPoints; +} VkPhysicalDeviceExtendedDynamicState2FeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetPatchControlPointsEXT)(VkCommandBuffer commandBuffer, uint32_t patchControlPoints); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizerDiscardEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 rasterizerDiscardEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthBiasEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthBiasEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetLogicOpEXT)(VkCommandBuffer commandBuffer, VkLogicOp logicOp); +typedef void (VKAPI_PTR *PFN_vkCmdSetPrimitiveRestartEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 primitiveRestartEnable); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetPatchControlPointsEXT( + VkCommandBuffer commandBuffer, + uint32_t patchControlPoints); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizerDiscardEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 rasterizerDiscardEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthBiasEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthBiasEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLogicOpEXT( + VkCommandBuffer commandBuffer, + VkLogicOp logicOp); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetPrimitiveRestartEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 primitiveRestartEnable); +#endif + + +// VK_EXT_color_write_enable is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_color_write_enable 1 +#define VK_EXT_COLOR_WRITE_ENABLE_SPEC_VERSION 1 +#define VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME "VK_EXT_color_write_enable" +typedef struct VkPhysicalDeviceColorWriteEnableFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 colorWriteEnable; +} VkPhysicalDeviceColorWriteEnableFeaturesEXT; + +typedef struct VkPipelineColorWriteCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t attachmentCount; + const VkBool32* pColorWriteEnables; +} VkPipelineColorWriteCreateInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetColorWriteEnableEXT)(VkCommandBuffer commandBuffer, uint32_t attachmentCount, const VkBool32* pColorWriteEnables); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorWriteEnableEXT( + VkCommandBuffer commandBuffer, + uint32_t attachmentCount, + const VkBool32* pColorWriteEnables); +#endif + + +// VK_EXT_primitives_generated_query is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_primitives_generated_query 1 +#define VK_EXT_PRIMITIVES_GENERATED_QUERY_SPEC_VERSION 1 +#define VK_EXT_PRIMITIVES_GENERATED_QUERY_EXTENSION_NAME "VK_EXT_primitives_generated_query" +typedef struct VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 primitivesGeneratedQuery; + VkBool32 primitivesGeneratedQueryWithRasterizerDiscard; + VkBool32 primitivesGeneratedQueryWithNonZeroStreams; +} VkPhysicalDevicePrimitivesGeneratedQueryFeaturesEXT; + + + +// VK_EXT_global_priority_query is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_global_priority_query 1 +#define VK_EXT_GLOBAL_PRIORITY_QUERY_SPEC_VERSION 1 +#define VK_EXT_GLOBAL_PRIORITY_QUERY_EXTENSION_NAME "VK_EXT_global_priority_query" +#define VK_MAX_GLOBAL_PRIORITY_SIZE_EXT VK_MAX_GLOBAL_PRIORITY_SIZE_KHR +typedef VkPhysicalDeviceGlobalPriorityQueryFeaturesKHR VkPhysicalDeviceGlobalPriorityQueryFeaturesEXT; + +typedef VkQueueFamilyGlobalPriorityPropertiesKHR VkQueueFamilyGlobalPriorityPropertiesEXT; + + + +// VK_EXT_image_view_min_lod is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_view_min_lod 1 +#define VK_EXT_IMAGE_VIEW_MIN_LOD_SPEC_VERSION 1 +#define VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME "VK_EXT_image_view_min_lod" +typedef struct VkPhysicalDeviceImageViewMinLodFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 minLod; +} VkPhysicalDeviceImageViewMinLodFeaturesEXT; + +typedef struct VkImageViewMinLodCreateInfoEXT { + VkStructureType sType; + const void* pNext; + float minLod; +} VkImageViewMinLodCreateInfoEXT; + + + +// VK_EXT_multi_draw is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_multi_draw 1 +#define VK_EXT_MULTI_DRAW_SPEC_VERSION 1 +#define VK_EXT_MULTI_DRAW_EXTENSION_NAME "VK_EXT_multi_draw" +typedef struct VkPhysicalDeviceMultiDrawFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 multiDraw; +} VkPhysicalDeviceMultiDrawFeaturesEXT; + +typedef struct VkPhysicalDeviceMultiDrawPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxMultiDrawCount; +} VkPhysicalDeviceMultiDrawPropertiesEXT; + +typedef struct VkMultiDrawInfoEXT { + uint32_t firstVertex; + uint32_t vertexCount; +} VkMultiDrawInfoEXT; + +typedef struct VkMultiDrawIndexedInfoEXT { + uint32_t firstIndex; + uint32_t indexCount; + int32_t vertexOffset; +} VkMultiDrawIndexedInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawMultiEXT)(VkCommandBuffer commandBuffer, uint32_t drawCount, const VkMultiDrawInfoEXT* pVertexInfo, uint32_t instanceCount, uint32_t firstInstance, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMultiIndexedEXT)(VkCommandBuffer commandBuffer, uint32_t drawCount, const VkMultiDrawIndexedInfoEXT* pIndexInfo, uint32_t instanceCount, uint32_t firstInstance, uint32_t stride, const int32_t* pVertexOffset); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMultiEXT( + VkCommandBuffer commandBuffer, + uint32_t drawCount, + const VkMultiDrawInfoEXT* pVertexInfo, + uint32_t instanceCount, + uint32_t firstInstance, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMultiIndexedEXT( + VkCommandBuffer commandBuffer, + uint32_t drawCount, + const VkMultiDrawIndexedInfoEXT* pIndexInfo, + uint32_t instanceCount, + uint32_t firstInstance, + uint32_t stride, + const int32_t* pVertexOffset); +#endif + + +// VK_EXT_image_2d_view_of_3d is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_2d_view_of_3d 1 +#define VK_EXT_IMAGE_2D_VIEW_OF_3D_SPEC_VERSION 1 +#define VK_EXT_IMAGE_2D_VIEW_OF_3D_EXTENSION_NAME "VK_EXT_image_2d_view_of_3d" +typedef struct VkPhysicalDeviceImage2DViewOf3DFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 image2DViewOf3D; + VkBool32 sampler2DViewOf3D; +} VkPhysicalDeviceImage2DViewOf3DFeaturesEXT; + + + +// VK_EXT_shader_tile_image is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_tile_image 1 +#define VK_EXT_SHADER_TILE_IMAGE_SPEC_VERSION 1 +#define VK_EXT_SHADER_TILE_IMAGE_EXTENSION_NAME "VK_EXT_shader_tile_image" +typedef struct VkPhysicalDeviceShaderTileImageFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderTileImageColorReadAccess; + VkBool32 shaderTileImageDepthReadAccess; + VkBool32 shaderTileImageStencilReadAccess; +} VkPhysicalDeviceShaderTileImageFeaturesEXT; + +typedef struct VkPhysicalDeviceShaderTileImagePropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderTileImageCoherentReadAccelerated; + VkBool32 shaderTileImageReadSampleFromPixelRateInvocation; + VkBool32 shaderTileImageReadFromHelperInvocation; +} VkPhysicalDeviceShaderTileImagePropertiesEXT; + + + +// VK_EXT_opacity_micromap is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_opacity_micromap 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkMicromapEXT) +#define VK_EXT_OPACITY_MICROMAP_SPEC_VERSION 2 +#define VK_EXT_OPACITY_MICROMAP_EXTENSION_NAME "VK_EXT_opacity_micromap" + +typedef enum VkMicromapTypeEXT { + VK_MICROMAP_TYPE_OPACITY_MICROMAP_EXT = 0, +#ifdef VK_ENABLE_BETA_EXTENSIONS + VK_MICROMAP_TYPE_DISPLACEMENT_MICROMAP_NV = 1000397000, +#endif + VK_MICROMAP_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkMicromapTypeEXT; + +typedef enum VkBuildMicromapModeEXT { + VK_BUILD_MICROMAP_MODE_BUILD_EXT = 0, + VK_BUILD_MICROMAP_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBuildMicromapModeEXT; + +typedef enum VkCopyMicromapModeEXT { + VK_COPY_MICROMAP_MODE_CLONE_EXT = 0, + VK_COPY_MICROMAP_MODE_SERIALIZE_EXT = 1, + VK_COPY_MICROMAP_MODE_DESERIALIZE_EXT = 2, + VK_COPY_MICROMAP_MODE_COMPACT_EXT = 3, + VK_COPY_MICROMAP_MODE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkCopyMicromapModeEXT; + +typedef enum VkOpacityMicromapFormatEXT { + VK_OPACITY_MICROMAP_FORMAT_2_STATE_EXT = 1, + VK_OPACITY_MICROMAP_FORMAT_4_STATE_EXT = 2, + VK_OPACITY_MICROMAP_FORMAT_MAX_ENUM_EXT = 0x7FFFFFFF +} VkOpacityMicromapFormatEXT; + +typedef enum VkOpacityMicromapSpecialIndexEXT { + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_TRANSPARENT_EXT = -1, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_OPAQUE_EXT = -2, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_TRANSPARENT_EXT = -3, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_FULLY_UNKNOWN_OPAQUE_EXT = -4, + VK_OPACITY_MICROMAP_SPECIAL_INDEX_MAX_ENUM_EXT = 0x7FFFFFFF +} VkOpacityMicromapSpecialIndexEXT; + +typedef enum VkAccelerationStructureCompatibilityKHR { + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_COMPATIBLE_KHR = 0, + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_INCOMPATIBLE_KHR = 1, + VK_ACCELERATION_STRUCTURE_COMPATIBILITY_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureCompatibilityKHR; + +typedef enum VkAccelerationStructureBuildTypeKHR { + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_KHR = 0, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_DEVICE_KHR = 1, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_HOST_OR_DEVICE_KHR = 2, + VK_ACCELERATION_STRUCTURE_BUILD_TYPE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureBuildTypeKHR; + +typedef enum VkBuildMicromapFlagBitsEXT { + VK_BUILD_MICROMAP_PREFER_FAST_TRACE_BIT_EXT = 0x00000001, + VK_BUILD_MICROMAP_PREFER_FAST_BUILD_BIT_EXT = 0x00000002, + VK_BUILD_MICROMAP_ALLOW_COMPACTION_BIT_EXT = 0x00000004, + VK_BUILD_MICROMAP_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkBuildMicromapFlagBitsEXT; +typedef VkFlags VkBuildMicromapFlagsEXT; + +typedef enum VkMicromapCreateFlagBitsEXT { + VK_MICROMAP_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_EXT = 0x00000001, + VK_MICROMAP_CREATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkMicromapCreateFlagBitsEXT; +typedef VkFlags VkMicromapCreateFlagsEXT; +typedef struct VkMicromapUsageEXT { + uint32_t count; + uint32_t subdivisionLevel; + uint32_t format; +} VkMicromapUsageEXT; + +typedef union VkDeviceOrHostAddressKHR { + VkDeviceAddress deviceAddress; + void* hostAddress; +} VkDeviceOrHostAddressKHR; + +typedef struct VkMicromapBuildInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapTypeEXT type; + VkBuildMicromapFlagsEXT flags; + VkBuildMicromapModeEXT mode; + VkMicromapEXT dstMicromap; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkDeviceOrHostAddressConstKHR data; + VkDeviceOrHostAddressKHR scratchData; + VkDeviceOrHostAddressConstKHR triangleArray; + VkDeviceSize triangleArrayStride; +} VkMicromapBuildInfoEXT; + +typedef struct VkMicromapCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapCreateFlagsEXT createFlags; + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize size; + VkMicromapTypeEXT type; + VkDeviceAddress deviceAddress; +} VkMicromapCreateInfoEXT; + +typedef struct VkPhysicalDeviceOpacityMicromapFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 micromap; + VkBool32 micromapCaptureReplay; + VkBool32 micromapHostCommands; +} VkPhysicalDeviceOpacityMicromapFeaturesEXT; + +typedef struct VkPhysicalDeviceOpacityMicromapPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxOpacity2StateSubdivisionLevel; + uint32_t maxOpacity4StateSubdivisionLevel; +} VkPhysicalDeviceOpacityMicromapPropertiesEXT; + +typedef struct VkMicromapVersionInfoEXT { + VkStructureType sType; + const void* pNext; + const uint8_t* pVersionData; +} VkMicromapVersionInfoEXT; + +typedef struct VkCopyMicromapToMemoryInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapEXT src; + VkDeviceOrHostAddressKHR dst; + VkCopyMicromapModeEXT mode; +} VkCopyMicromapToMemoryInfoEXT; + +typedef struct VkCopyMemoryToMicromapInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceOrHostAddressConstKHR src; + VkMicromapEXT dst; + VkCopyMicromapModeEXT mode; +} VkCopyMemoryToMicromapInfoEXT; + +typedef struct VkCopyMicromapInfoEXT { + VkStructureType sType; + const void* pNext; + VkMicromapEXT src; + VkMicromapEXT dst; + VkCopyMicromapModeEXT mode; +} VkCopyMicromapInfoEXT; + +typedef struct VkMicromapBuildSizesInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceSize micromapSize; + VkDeviceSize buildScratchSize; + VkBool32 discardable; +} VkMicromapBuildSizesInfoEXT; + +typedef struct VkAccelerationStructureTrianglesOpacityMicromapEXT { + VkStructureType sType; + void* pNext; + VkIndexType indexType; + VkDeviceOrHostAddressConstKHR indexBuffer; + VkDeviceSize indexStride; + uint32_t baseTriangle; + uint32_t usageCountsCount; + const VkMicromapUsageEXT* pUsageCounts; + const VkMicromapUsageEXT* const* ppUsageCounts; + VkMicromapEXT micromap; +} VkAccelerationStructureTrianglesOpacityMicromapEXT; + +typedef struct VkMicromapTriangleEXT { + uint32_t dataOffset; + uint16_t subdivisionLevel; + uint16_t format; +} VkMicromapTriangleEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMicromapEXT)(VkDevice device, const VkMicromapCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkMicromapEXT* pMicromap); +typedef void (VKAPI_PTR *PFN_vkDestroyMicromapEXT)(VkDevice device, VkMicromapEXT micromap, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdBuildMicromapsEXT)(VkCommandBuffer commandBuffer, uint32_t infoCount, const VkMicromapBuildInfoEXT* pInfos); +typedef VkResult (VKAPI_PTR *PFN_vkBuildMicromapsEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, const VkMicromapBuildInfoEXT* pInfos); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMicromapEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMicromapInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMicromapToMemoryEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMicromapToMemoryInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMemoryToMicromapEXT)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToMicromapInfoEXT* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkWriteMicromapsPropertiesEXT)(VkDevice device, uint32_t micromapCount, const VkMicromapEXT* pMicromaps, VkQueryType queryType, size_t dataSize, void* pData, size_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMicromapEXT)(VkCommandBuffer commandBuffer, const VkCopyMicromapInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMicromapToMemoryEXT)(VkCommandBuffer commandBuffer, const VkCopyMicromapToMemoryInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToMicromapEXT)(VkCommandBuffer commandBuffer, const VkCopyMemoryToMicromapInfoEXT* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdWriteMicromapsPropertiesEXT)(VkCommandBuffer commandBuffer, uint32_t micromapCount, const VkMicromapEXT* pMicromaps, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery); +typedef void (VKAPI_PTR *PFN_vkGetDeviceMicromapCompatibilityEXT)(VkDevice device, const VkMicromapVersionInfoEXT* pVersionInfo, VkAccelerationStructureCompatibilityKHR* pCompatibility); +typedef void (VKAPI_PTR *PFN_vkGetMicromapBuildSizesEXT)(VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkMicromapBuildInfoEXT* pBuildInfo, VkMicromapBuildSizesInfoEXT* pSizeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMicromapEXT( + VkDevice device, + const VkMicromapCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkMicromapEXT* pMicromap); + +VKAPI_ATTR void VKAPI_CALL vkDestroyMicromapEXT( + VkDevice device, + VkMicromapEXT micromap, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdBuildMicromapsEXT( + VkCommandBuffer commandBuffer, + uint32_t infoCount, + const VkMicromapBuildInfoEXT* pInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkBuildMicromapsEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + uint32_t infoCount, + const VkMicromapBuildInfoEXT* pInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMicromapEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMicromapInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMicromapToMemoryEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMicromapToMemoryInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToMicromapEXT( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMemoryToMicromapInfoEXT* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkWriteMicromapsPropertiesEXT( + VkDevice device, + uint32_t micromapCount, + const VkMicromapEXT* pMicromaps, + VkQueryType queryType, + size_t dataSize, + void* pData, + size_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMicromapEXT( + VkCommandBuffer commandBuffer, + const VkCopyMicromapInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMicromapToMemoryEXT( + VkCommandBuffer commandBuffer, + const VkCopyMicromapToMemoryInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToMicromapEXT( + VkCommandBuffer commandBuffer, + const VkCopyMemoryToMicromapInfoEXT* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteMicromapsPropertiesEXT( + VkCommandBuffer commandBuffer, + uint32_t micromapCount, + const VkMicromapEXT* pMicromaps, + VkQueryType queryType, + VkQueryPool queryPool, + uint32_t firstQuery); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceMicromapCompatibilityEXT( + VkDevice device, + const VkMicromapVersionInfoEXT* pVersionInfo, + VkAccelerationStructureCompatibilityKHR* pCompatibility); + +VKAPI_ATTR void VKAPI_CALL vkGetMicromapBuildSizesEXT( + VkDevice device, + VkAccelerationStructureBuildTypeKHR buildType, + const VkMicromapBuildInfoEXT* pBuildInfo, + VkMicromapBuildSizesInfoEXT* pSizeInfo); +#endif + + +// VK_EXT_load_store_op_none is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_load_store_op_none 1 +#define VK_EXT_LOAD_STORE_OP_NONE_SPEC_VERSION 1 +#define VK_EXT_LOAD_STORE_OP_NONE_EXTENSION_NAME "VK_EXT_load_store_op_none" + + +// VK_HUAWEI_cluster_culling_shader is a preprocessor guard. Do not pass it to API calls. +#define VK_HUAWEI_cluster_culling_shader 1 +#define VK_HUAWEI_CLUSTER_CULLING_SHADER_SPEC_VERSION 3 +#define VK_HUAWEI_CLUSTER_CULLING_SHADER_EXTENSION_NAME "VK_HUAWEI_cluster_culling_shader" +typedef struct VkPhysicalDeviceClusterCullingShaderFeaturesHUAWEI { + VkStructureType sType; + void* pNext; + VkBool32 clustercullingShader; + VkBool32 multiviewClusterCullingShader; +} VkPhysicalDeviceClusterCullingShaderFeaturesHUAWEI; + +typedef struct VkPhysicalDeviceClusterCullingShaderPropertiesHUAWEI { + VkStructureType sType; + void* pNext; + uint32_t maxWorkGroupCount[3]; + uint32_t maxWorkGroupSize[3]; + uint32_t maxOutputClusterCount; + VkDeviceSize indirectBufferOffsetAlignment; +} VkPhysicalDeviceClusterCullingShaderPropertiesHUAWEI; + +typedef struct VkPhysicalDeviceClusterCullingShaderVrsFeaturesHUAWEI { + VkStructureType sType; + void* pNext; + VkBool32 clusterShadingRate; +} VkPhysicalDeviceClusterCullingShaderVrsFeaturesHUAWEI; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawClusterHUAWEI)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (VKAPI_PTR *PFN_vkCmdDrawClusterIndirectHUAWEI)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawClusterHUAWEI( + VkCommandBuffer commandBuffer, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawClusterIndirectHUAWEI( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset); +#endif + + +// VK_EXT_border_color_swizzle is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_border_color_swizzle 1 +#define VK_EXT_BORDER_COLOR_SWIZZLE_SPEC_VERSION 1 +#define VK_EXT_BORDER_COLOR_SWIZZLE_EXTENSION_NAME "VK_EXT_border_color_swizzle" +typedef struct VkPhysicalDeviceBorderColorSwizzleFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 borderColorSwizzle; + VkBool32 borderColorSwizzleFromImage; +} VkPhysicalDeviceBorderColorSwizzleFeaturesEXT; + +typedef struct VkSamplerBorderColorComponentMappingCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkComponentMapping components; + VkBool32 srgb; +} VkSamplerBorderColorComponentMappingCreateInfoEXT; + + + +// VK_EXT_pageable_device_local_memory is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pageable_device_local_memory 1 +#define VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_SPEC_VERSION 1 +#define VK_EXT_PAGEABLE_DEVICE_LOCAL_MEMORY_EXTENSION_NAME "VK_EXT_pageable_device_local_memory" +typedef struct VkPhysicalDevicePageableDeviceLocalMemoryFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pageableDeviceLocalMemory; +} VkPhysicalDevicePageableDeviceLocalMemoryFeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkSetDeviceMemoryPriorityEXT)(VkDevice device, VkDeviceMemory memory, float priority); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkSetDeviceMemoryPriorityEXT( + VkDevice device, + VkDeviceMemory memory, + float priority); +#endif + + +// VK_ARM_shader_core_properties is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_shader_core_properties 1 +#define VK_ARM_SHADER_CORE_PROPERTIES_SPEC_VERSION 1 +#define VK_ARM_SHADER_CORE_PROPERTIES_EXTENSION_NAME "VK_ARM_shader_core_properties" +typedef struct VkPhysicalDeviceShaderCorePropertiesARM { + VkStructureType sType; + void* pNext; + uint32_t pixelRate; + uint32_t texelRate; + uint32_t fmaRate; +} VkPhysicalDeviceShaderCorePropertiesARM; + + + +// VK_ARM_scheduling_controls is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_scheduling_controls 1 +#define VK_ARM_SCHEDULING_CONTROLS_SPEC_VERSION 1 +#define VK_ARM_SCHEDULING_CONTROLS_EXTENSION_NAME "VK_ARM_scheduling_controls" +typedef VkFlags64 VkPhysicalDeviceSchedulingControlsFlagsARM; + +// Flag bits for VkPhysicalDeviceSchedulingControlsFlagBitsARM +typedef VkFlags64 VkPhysicalDeviceSchedulingControlsFlagBitsARM; +static const VkPhysicalDeviceSchedulingControlsFlagBitsARM VK_PHYSICAL_DEVICE_SCHEDULING_CONTROLS_SHADER_CORE_COUNT_ARM = 0x00000001ULL; + +typedef struct VkDeviceQueueShaderCoreControlCreateInfoARM { + VkStructureType sType; + void* pNext; + uint32_t shaderCoreCount; +} VkDeviceQueueShaderCoreControlCreateInfoARM; + +typedef struct VkPhysicalDeviceSchedulingControlsFeaturesARM { + VkStructureType sType; + void* pNext; + VkBool32 schedulingControls; +} VkPhysicalDeviceSchedulingControlsFeaturesARM; + +typedef struct VkPhysicalDeviceSchedulingControlsPropertiesARM { + VkStructureType sType; + void* pNext; + VkPhysicalDeviceSchedulingControlsFlagsARM schedulingControlsFlags; +} VkPhysicalDeviceSchedulingControlsPropertiesARM; + + + +// VK_EXT_image_sliced_view_of_3d is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_sliced_view_of_3d 1 +#define VK_EXT_IMAGE_SLICED_VIEW_OF_3D_SPEC_VERSION 1 +#define VK_EXT_IMAGE_SLICED_VIEW_OF_3D_EXTENSION_NAME "VK_EXT_image_sliced_view_of_3d" +#define VK_REMAINING_3D_SLICES_EXT (~0U) +typedef struct VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 imageSlicedViewOf3D; +} VkPhysicalDeviceImageSlicedViewOf3DFeaturesEXT; + +typedef struct VkImageViewSlicedCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t sliceOffset; + uint32_t sliceCount; +} VkImageViewSlicedCreateInfoEXT; + + + +// VK_VALVE_descriptor_set_host_mapping is a preprocessor guard. Do not pass it to API calls. +#define VK_VALVE_descriptor_set_host_mapping 1 +#define VK_VALVE_DESCRIPTOR_SET_HOST_MAPPING_SPEC_VERSION 1 +#define VK_VALVE_DESCRIPTOR_SET_HOST_MAPPING_EXTENSION_NAME "VK_VALVE_descriptor_set_host_mapping" +typedef struct VkPhysicalDeviceDescriptorSetHostMappingFeaturesVALVE { + VkStructureType sType; + void* pNext; + VkBool32 descriptorSetHostMapping; +} VkPhysicalDeviceDescriptorSetHostMappingFeaturesVALVE; + +typedef struct VkDescriptorSetBindingReferenceVALVE { + VkStructureType sType; + const void* pNext; + VkDescriptorSetLayout descriptorSetLayout; + uint32_t binding; +} VkDescriptorSetBindingReferenceVALVE; + +typedef struct VkDescriptorSetLayoutHostMappingInfoVALVE { + VkStructureType sType; + void* pNext; + size_t descriptorOffset; + uint32_t descriptorSize; +} VkDescriptorSetLayoutHostMappingInfoVALVE; + +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetLayoutHostMappingInfoVALVE)(VkDevice device, const VkDescriptorSetBindingReferenceVALVE* pBindingReference, VkDescriptorSetLayoutHostMappingInfoVALVE* pHostMapping); +typedef void (VKAPI_PTR *PFN_vkGetDescriptorSetHostMappingVALVE)(VkDevice device, VkDescriptorSet descriptorSet, void** ppData); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetLayoutHostMappingInfoVALVE( + VkDevice device, + const VkDescriptorSetBindingReferenceVALVE* pBindingReference, + VkDescriptorSetLayoutHostMappingInfoVALVE* pHostMapping); + +VKAPI_ATTR void VKAPI_CALL vkGetDescriptorSetHostMappingVALVE( + VkDevice device, + VkDescriptorSet descriptorSet, + void** ppData); +#endif + + +// VK_EXT_depth_clamp_zero_one is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_depth_clamp_zero_one 1 +#define VK_EXT_DEPTH_CLAMP_ZERO_ONE_SPEC_VERSION 1 +#define VK_EXT_DEPTH_CLAMP_ZERO_ONE_EXTENSION_NAME "VK_EXT_depth_clamp_zero_one" +typedef struct VkPhysicalDeviceDepthClampZeroOneFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 depthClampZeroOne; +} VkPhysicalDeviceDepthClampZeroOneFeaturesEXT; + + + +// VK_EXT_non_seamless_cube_map is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_non_seamless_cube_map 1 +#define VK_EXT_NON_SEAMLESS_CUBE_MAP_SPEC_VERSION 1 +#define VK_EXT_NON_SEAMLESS_CUBE_MAP_EXTENSION_NAME "VK_EXT_non_seamless_cube_map" +typedef struct VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 nonSeamlessCubeMap; +} VkPhysicalDeviceNonSeamlessCubeMapFeaturesEXT; + + + +// VK_ARM_render_pass_striped is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_render_pass_striped 1 +#define VK_ARM_RENDER_PASS_STRIPED_SPEC_VERSION 1 +#define VK_ARM_RENDER_PASS_STRIPED_EXTENSION_NAME "VK_ARM_render_pass_striped" +typedef struct VkPhysicalDeviceRenderPassStripedFeaturesARM { + VkStructureType sType; + void* pNext; + VkBool32 renderPassStriped; +} VkPhysicalDeviceRenderPassStripedFeaturesARM; + +typedef struct VkPhysicalDeviceRenderPassStripedPropertiesARM { + VkStructureType sType; + void* pNext; + VkExtent2D renderPassStripeGranularity; + uint32_t maxRenderPassStripes; +} VkPhysicalDeviceRenderPassStripedPropertiesARM; + +typedef struct VkRenderPassStripeInfoARM { + VkStructureType sType; + const void* pNext; + VkRect2D stripeArea; +} VkRenderPassStripeInfoARM; + +typedef struct VkRenderPassStripeBeginInfoARM { + VkStructureType sType; + const void* pNext; + uint32_t stripeInfoCount; + const VkRenderPassStripeInfoARM* pStripeInfos; +} VkRenderPassStripeBeginInfoARM; + +typedef struct VkRenderPassStripeSubmitInfoARM { + VkStructureType sType; + const void* pNext; + uint32_t stripeSemaphoreInfoCount; + const VkSemaphoreSubmitInfo* pStripeSemaphoreInfos; +} VkRenderPassStripeSubmitInfoARM; + + + +// VK_QCOM_fragment_density_map_offset is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_fragment_density_map_offset 1 +#define VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_SPEC_VERSION 1 +#define VK_QCOM_FRAGMENT_DENSITY_MAP_OFFSET_EXTENSION_NAME "VK_QCOM_fragment_density_map_offset" +typedef struct VkPhysicalDeviceFragmentDensityMapOffsetFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 fragmentDensityMapOffset; +} VkPhysicalDeviceFragmentDensityMapOffsetFeaturesQCOM; + +typedef struct VkPhysicalDeviceFragmentDensityMapOffsetPropertiesQCOM { + VkStructureType sType; + void* pNext; + VkExtent2D fragmentDensityOffsetGranularity; +} VkPhysicalDeviceFragmentDensityMapOffsetPropertiesQCOM; + +typedef struct VkSubpassFragmentDensityMapOffsetEndInfoQCOM { + VkStructureType sType; + const void* pNext; + uint32_t fragmentDensityOffsetCount; + const VkOffset2D* pFragmentDensityOffsets; +} VkSubpassFragmentDensityMapOffsetEndInfoQCOM; + + + +// VK_NV_copy_memory_indirect is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_copy_memory_indirect 1 +#define VK_NV_COPY_MEMORY_INDIRECT_SPEC_VERSION 1 +#define VK_NV_COPY_MEMORY_INDIRECT_EXTENSION_NAME "VK_NV_copy_memory_indirect" +typedef struct VkCopyMemoryIndirectCommandNV { + VkDeviceAddress srcAddress; + VkDeviceAddress dstAddress; + VkDeviceSize size; +} VkCopyMemoryIndirectCommandNV; + +typedef struct VkCopyMemoryToImageIndirectCommandNV { + VkDeviceAddress srcAddress; + uint32_t bufferRowLength; + uint32_t bufferImageHeight; + VkImageSubresourceLayers imageSubresource; + VkOffset3D imageOffset; + VkExtent3D imageExtent; +} VkCopyMemoryToImageIndirectCommandNV; + +typedef struct VkPhysicalDeviceCopyMemoryIndirectFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 indirectCopy; +} VkPhysicalDeviceCopyMemoryIndirectFeaturesNV; + +typedef struct VkPhysicalDeviceCopyMemoryIndirectPropertiesNV { + VkStructureType sType; + void* pNext; + VkQueueFlags supportedQueues; +} VkPhysicalDeviceCopyMemoryIndirectPropertiesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryIndirectNV)(VkCommandBuffer commandBuffer, VkDeviceAddress copyBufferAddress, uint32_t copyCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToImageIndirectNV)(VkCommandBuffer commandBuffer, VkDeviceAddress copyBufferAddress, uint32_t copyCount, uint32_t stride, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageSubresourceLayers* pImageSubresources); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryIndirectNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress copyBufferAddress, + uint32_t copyCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToImageIndirectNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress copyBufferAddress, + uint32_t copyCount, + uint32_t stride, + VkImage dstImage, + VkImageLayout dstImageLayout, + const VkImageSubresourceLayers* pImageSubresources); +#endif + + +// VK_NV_memory_decompression is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_memory_decompression 1 +#define VK_NV_MEMORY_DECOMPRESSION_SPEC_VERSION 1 +#define VK_NV_MEMORY_DECOMPRESSION_EXTENSION_NAME "VK_NV_memory_decompression" + +// Flag bits for VkMemoryDecompressionMethodFlagBitsNV +typedef VkFlags64 VkMemoryDecompressionMethodFlagBitsNV; +static const VkMemoryDecompressionMethodFlagBitsNV VK_MEMORY_DECOMPRESSION_METHOD_GDEFLATE_1_0_BIT_NV = 0x00000001ULL; + +typedef VkFlags64 VkMemoryDecompressionMethodFlagsNV; +typedef struct VkDecompressMemoryRegionNV { + VkDeviceAddress srcAddress; + VkDeviceAddress dstAddress; + VkDeviceSize compressedSize; + VkDeviceSize decompressedSize; + VkMemoryDecompressionMethodFlagsNV decompressionMethod; +} VkDecompressMemoryRegionNV; + +typedef struct VkPhysicalDeviceMemoryDecompressionFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 memoryDecompression; +} VkPhysicalDeviceMemoryDecompressionFeaturesNV; + +typedef struct VkPhysicalDeviceMemoryDecompressionPropertiesNV { + VkStructureType sType; + void* pNext; + VkMemoryDecompressionMethodFlagsNV decompressionMethods; + uint64_t maxDecompressionIndirectCount; +} VkPhysicalDeviceMemoryDecompressionPropertiesNV; + +typedef void (VKAPI_PTR *PFN_vkCmdDecompressMemoryNV)(VkCommandBuffer commandBuffer, uint32_t decompressRegionCount, const VkDecompressMemoryRegionNV* pDecompressMemoryRegions); +typedef void (VKAPI_PTR *PFN_vkCmdDecompressMemoryIndirectCountNV)(VkCommandBuffer commandBuffer, VkDeviceAddress indirectCommandsAddress, VkDeviceAddress indirectCommandsCountAddress, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDecompressMemoryNV( + VkCommandBuffer commandBuffer, + uint32_t decompressRegionCount, + const VkDecompressMemoryRegionNV* pDecompressMemoryRegions); + +VKAPI_ATTR void VKAPI_CALL vkCmdDecompressMemoryIndirectCountNV( + VkCommandBuffer commandBuffer, + VkDeviceAddress indirectCommandsAddress, + VkDeviceAddress indirectCommandsCountAddress, + uint32_t stride); +#endif + + +// VK_NV_device_generated_commands_compute is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_device_generated_commands_compute 1 +#define VK_NV_DEVICE_GENERATED_COMMANDS_COMPUTE_SPEC_VERSION 2 +#define VK_NV_DEVICE_GENERATED_COMMANDS_COMPUTE_EXTENSION_NAME "VK_NV_device_generated_commands_compute" +typedef struct VkPhysicalDeviceDeviceGeneratedCommandsComputeFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 deviceGeneratedCompute; + VkBool32 deviceGeneratedComputePipelines; + VkBool32 deviceGeneratedComputeCaptureReplay; +} VkPhysicalDeviceDeviceGeneratedCommandsComputeFeaturesNV; + +typedef struct VkComputePipelineIndirectBufferInfoNV { + VkStructureType sType; + const void* pNext; + VkDeviceAddress deviceAddress; + VkDeviceSize size; + VkDeviceAddress pipelineDeviceAddressCaptureReplay; +} VkComputePipelineIndirectBufferInfoNV; + +typedef struct VkPipelineIndirectDeviceAddressInfoNV { + VkStructureType sType; + const void* pNext; + VkPipelineBindPoint pipelineBindPoint; + VkPipeline pipeline; +} VkPipelineIndirectDeviceAddressInfoNV; + +typedef struct VkBindPipelineIndirectCommandNV { + VkDeviceAddress pipelineAddress; +} VkBindPipelineIndirectCommandNV; + +typedef void (VKAPI_PTR *PFN_vkGetPipelineIndirectMemoryRequirementsNV)(VkDevice device, const VkComputePipelineCreateInfo* pCreateInfo, VkMemoryRequirements2* pMemoryRequirements); +typedef void (VKAPI_PTR *PFN_vkCmdUpdatePipelineIndirectBufferNV)(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline); +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetPipelineIndirectDeviceAddressNV)(VkDevice device, const VkPipelineIndirectDeviceAddressInfoNV* pInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetPipelineIndirectMemoryRequirementsNV( + VkDevice device, + const VkComputePipelineCreateInfo* pCreateInfo, + VkMemoryRequirements2* pMemoryRequirements); + +VKAPI_ATTR void VKAPI_CALL vkCmdUpdatePipelineIndirectBufferNV( + VkCommandBuffer commandBuffer, + VkPipelineBindPoint pipelineBindPoint, + VkPipeline pipeline); + +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetPipelineIndirectDeviceAddressNV( + VkDevice device, + const VkPipelineIndirectDeviceAddressInfoNV* pInfo); +#endif + + +// VK_NV_linear_color_attachment is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_linear_color_attachment 1 +#define VK_NV_LINEAR_COLOR_ATTACHMENT_SPEC_VERSION 1 +#define VK_NV_LINEAR_COLOR_ATTACHMENT_EXTENSION_NAME "VK_NV_linear_color_attachment" +typedef struct VkPhysicalDeviceLinearColorAttachmentFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 linearColorAttachment; +} VkPhysicalDeviceLinearColorAttachmentFeaturesNV; + + + +// VK_GOOGLE_surfaceless_query is a preprocessor guard. Do not pass it to API calls. +#define VK_GOOGLE_surfaceless_query 1 +#define VK_GOOGLE_SURFACELESS_QUERY_SPEC_VERSION 2 +#define VK_GOOGLE_SURFACELESS_QUERY_EXTENSION_NAME "VK_GOOGLE_surfaceless_query" + + +// VK_EXT_image_compression_control_swapchain is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_image_compression_control_swapchain 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_SPEC_VERSION 1 +#define VK_EXT_IMAGE_COMPRESSION_CONTROL_SWAPCHAIN_EXTENSION_NAME "VK_EXT_image_compression_control_swapchain" +typedef struct VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 imageCompressionControlSwapchain; +} VkPhysicalDeviceImageCompressionControlSwapchainFeaturesEXT; + + + +// VK_QCOM_image_processing is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_image_processing 1 +#define VK_QCOM_IMAGE_PROCESSING_SPEC_VERSION 1 +#define VK_QCOM_IMAGE_PROCESSING_EXTENSION_NAME "VK_QCOM_image_processing" +typedef struct VkImageViewSampleWeightCreateInfoQCOM { + VkStructureType sType; + const void* pNext; + VkOffset2D filterCenter; + VkExtent2D filterSize; + uint32_t numPhases; +} VkImageViewSampleWeightCreateInfoQCOM; + +typedef struct VkPhysicalDeviceImageProcessingFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 textureSampleWeighted; + VkBool32 textureBoxFilter; + VkBool32 textureBlockMatch; +} VkPhysicalDeviceImageProcessingFeaturesQCOM; + +typedef struct VkPhysicalDeviceImageProcessingPropertiesQCOM { + VkStructureType sType; + void* pNext; + uint32_t maxWeightFilterPhases; + VkExtent2D maxWeightFilterDimension; + VkExtent2D maxBlockMatchRegion; + VkExtent2D maxBoxFilterBlockSize; +} VkPhysicalDeviceImageProcessingPropertiesQCOM; + + + +// VK_EXT_nested_command_buffer is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_nested_command_buffer 1 +#define VK_EXT_NESTED_COMMAND_BUFFER_SPEC_VERSION 1 +#define VK_EXT_NESTED_COMMAND_BUFFER_EXTENSION_NAME "VK_EXT_nested_command_buffer" +typedef struct VkPhysicalDeviceNestedCommandBufferFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 nestedCommandBuffer; + VkBool32 nestedCommandBufferRendering; + VkBool32 nestedCommandBufferSimultaneousUse; +} VkPhysicalDeviceNestedCommandBufferFeaturesEXT; + +typedef struct VkPhysicalDeviceNestedCommandBufferPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxCommandBufferNestingLevel; +} VkPhysicalDeviceNestedCommandBufferPropertiesEXT; + + + +// VK_EXT_external_memory_acquire_unmodified is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_external_memory_acquire_unmodified 1 +#define VK_EXT_EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_SPEC_VERSION 1 +#define VK_EXT_EXTERNAL_MEMORY_ACQUIRE_UNMODIFIED_EXTENSION_NAME "VK_EXT_external_memory_acquire_unmodified" +typedef struct VkExternalMemoryAcquireUnmodifiedEXT { + VkStructureType sType; + const void* pNext; + VkBool32 acquireUnmodifiedMemory; +} VkExternalMemoryAcquireUnmodifiedEXT; + + + +// VK_EXT_extended_dynamic_state3 is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_extended_dynamic_state3 1 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_3_SPEC_VERSION 2 +#define VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME "VK_EXT_extended_dynamic_state3" +typedef struct VkPhysicalDeviceExtendedDynamicState3FeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 extendedDynamicState3TessellationDomainOrigin; + VkBool32 extendedDynamicState3DepthClampEnable; + VkBool32 extendedDynamicState3PolygonMode; + VkBool32 extendedDynamicState3RasterizationSamples; + VkBool32 extendedDynamicState3SampleMask; + VkBool32 extendedDynamicState3AlphaToCoverageEnable; + VkBool32 extendedDynamicState3AlphaToOneEnable; + VkBool32 extendedDynamicState3LogicOpEnable; + VkBool32 extendedDynamicState3ColorBlendEnable; + VkBool32 extendedDynamicState3ColorBlendEquation; + VkBool32 extendedDynamicState3ColorWriteMask; + VkBool32 extendedDynamicState3RasterizationStream; + VkBool32 extendedDynamicState3ConservativeRasterizationMode; + VkBool32 extendedDynamicState3ExtraPrimitiveOverestimationSize; + VkBool32 extendedDynamicState3DepthClipEnable; + VkBool32 extendedDynamicState3SampleLocationsEnable; + VkBool32 extendedDynamicState3ColorBlendAdvanced; + VkBool32 extendedDynamicState3ProvokingVertexMode; + VkBool32 extendedDynamicState3LineRasterizationMode; + VkBool32 extendedDynamicState3LineStippleEnable; + VkBool32 extendedDynamicState3DepthClipNegativeOneToOne; + VkBool32 extendedDynamicState3ViewportWScalingEnable; + VkBool32 extendedDynamicState3ViewportSwizzle; + VkBool32 extendedDynamicState3CoverageToColorEnable; + VkBool32 extendedDynamicState3CoverageToColorLocation; + VkBool32 extendedDynamicState3CoverageModulationMode; + VkBool32 extendedDynamicState3CoverageModulationTableEnable; + VkBool32 extendedDynamicState3CoverageModulationTable; + VkBool32 extendedDynamicState3CoverageReductionMode; + VkBool32 extendedDynamicState3RepresentativeFragmentTestEnable; + VkBool32 extendedDynamicState3ShadingRateImageEnable; +} VkPhysicalDeviceExtendedDynamicState3FeaturesEXT; + +typedef struct VkPhysicalDeviceExtendedDynamicState3PropertiesEXT { + VkStructureType sType; + void* pNext; + VkBool32 dynamicPrimitiveTopologyUnrestricted; +} VkPhysicalDeviceExtendedDynamicState3PropertiesEXT; + +typedef struct VkColorBlendEquationEXT { + VkBlendFactor srcColorBlendFactor; + VkBlendFactor dstColorBlendFactor; + VkBlendOp colorBlendOp; + VkBlendFactor srcAlphaBlendFactor; + VkBlendFactor dstAlphaBlendFactor; + VkBlendOp alphaBlendOp; +} VkColorBlendEquationEXT; + +typedef struct VkColorBlendAdvancedEXT { + VkBlendOp advancedBlendOp; + VkBool32 srcPremultiplied; + VkBool32 dstPremultiplied; + VkBlendOverlapEXT blendOverlap; + VkBool32 clampResults; +} VkColorBlendAdvancedEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClampEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthClampEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetPolygonModeEXT)(VkCommandBuffer commandBuffer, VkPolygonMode polygonMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizationSamplesEXT)(VkCommandBuffer commandBuffer, VkSampleCountFlagBits rasterizationSamples); +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleMaskEXT)(VkCommandBuffer commandBuffer, VkSampleCountFlagBits samples, const VkSampleMask* pSampleMask); +typedef void (VKAPI_PTR *PFN_vkCmdSetAlphaToCoverageEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 alphaToCoverageEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetAlphaToOneEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 alphaToOneEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetLogicOpEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 logicOpEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendEnableEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkBool32* pColorBlendEnables); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendEquationEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorBlendEquationEXT* pColorBlendEquations); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorWriteMaskEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorComponentFlags* pColorWriteMasks); +typedef void (VKAPI_PTR *PFN_vkCmdSetTessellationDomainOriginEXT)(VkCommandBuffer commandBuffer, VkTessellationDomainOrigin domainOrigin); +typedef void (VKAPI_PTR *PFN_vkCmdSetRasterizationStreamEXT)(VkCommandBuffer commandBuffer, uint32_t rasterizationStream); +typedef void (VKAPI_PTR *PFN_vkCmdSetConservativeRasterizationModeEXT)(VkCommandBuffer commandBuffer, VkConservativeRasterizationModeEXT conservativeRasterizationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetExtraPrimitiveOverestimationSizeEXT)(VkCommandBuffer commandBuffer, float extraPrimitiveOverestimationSize); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClipEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 depthClipEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetSampleLocationsEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 sampleLocationsEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetColorBlendAdvancedEXT)(VkCommandBuffer commandBuffer, uint32_t firstAttachment, uint32_t attachmentCount, const VkColorBlendAdvancedEXT* pColorBlendAdvanced); +typedef void (VKAPI_PTR *PFN_vkCmdSetProvokingVertexModeEXT)(VkCommandBuffer commandBuffer, VkProvokingVertexModeEXT provokingVertexMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineRasterizationModeEXT)(VkCommandBuffer commandBuffer, VkLineRasterizationModeEXT lineRasterizationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetLineStippleEnableEXT)(VkCommandBuffer commandBuffer, VkBool32 stippledLineEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetDepthClipNegativeOneToOneEXT)(VkCommandBuffer commandBuffer, VkBool32 negativeOneToOne); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportWScalingEnableNV)(VkCommandBuffer commandBuffer, VkBool32 viewportWScalingEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetViewportSwizzleNV)(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewportSwizzleNV* pViewportSwizzles); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageToColorEnableNV)(VkCommandBuffer commandBuffer, VkBool32 coverageToColorEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageToColorLocationNV)(VkCommandBuffer commandBuffer, uint32_t coverageToColorLocation); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationModeNV)(VkCommandBuffer commandBuffer, VkCoverageModulationModeNV coverageModulationMode); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationTableEnableNV)(VkCommandBuffer commandBuffer, VkBool32 coverageModulationTableEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageModulationTableNV)(VkCommandBuffer commandBuffer, uint32_t coverageModulationTableCount, const float* pCoverageModulationTable); +typedef void (VKAPI_PTR *PFN_vkCmdSetShadingRateImageEnableNV)(VkCommandBuffer commandBuffer, VkBool32 shadingRateImageEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetRepresentativeFragmentTestEnableNV)(VkCommandBuffer commandBuffer, VkBool32 representativeFragmentTestEnable); +typedef void (VKAPI_PTR *PFN_vkCmdSetCoverageReductionModeNV)(VkCommandBuffer commandBuffer, VkCoverageReductionModeNV coverageReductionMode); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClampEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthClampEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetPolygonModeEXT( + VkCommandBuffer commandBuffer, + VkPolygonMode polygonMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizationSamplesEXT( + VkCommandBuffer commandBuffer, + VkSampleCountFlagBits rasterizationSamples); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleMaskEXT( + VkCommandBuffer commandBuffer, + VkSampleCountFlagBits samples, + const VkSampleMask* pSampleMask); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToCoverageEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 alphaToCoverageEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetAlphaToOneEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 alphaToOneEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLogicOpEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 logicOpEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendEnableEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkBool32* pColorBlendEnables); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendEquationEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorBlendEquationEXT* pColorBlendEquations); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorWriteMaskEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorComponentFlags* pColorWriteMasks); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetTessellationDomainOriginEXT( + VkCommandBuffer commandBuffer, + VkTessellationDomainOrigin domainOrigin); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRasterizationStreamEXT( + VkCommandBuffer commandBuffer, + uint32_t rasterizationStream); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetConservativeRasterizationModeEXT( + VkCommandBuffer commandBuffer, + VkConservativeRasterizationModeEXT conservativeRasterizationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetExtraPrimitiveOverestimationSizeEXT( + VkCommandBuffer commandBuffer, + float extraPrimitiveOverestimationSize); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClipEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 depthClipEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetSampleLocationsEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 sampleLocationsEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetColorBlendAdvancedEXT( + VkCommandBuffer commandBuffer, + uint32_t firstAttachment, + uint32_t attachmentCount, + const VkColorBlendAdvancedEXT* pColorBlendAdvanced); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetProvokingVertexModeEXT( + VkCommandBuffer commandBuffer, + VkProvokingVertexModeEXT provokingVertexMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineRasterizationModeEXT( + VkCommandBuffer commandBuffer, + VkLineRasterizationModeEXT lineRasterizationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetLineStippleEnableEXT( + VkCommandBuffer commandBuffer, + VkBool32 stippledLineEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetDepthClipNegativeOneToOneEXT( + VkCommandBuffer commandBuffer, + VkBool32 negativeOneToOne); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportWScalingEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 viewportWScalingEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetViewportSwizzleNV( + VkCommandBuffer commandBuffer, + uint32_t firstViewport, + uint32_t viewportCount, + const VkViewportSwizzleNV* pViewportSwizzles); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageToColorEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 coverageToColorEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageToColorLocationNV( + VkCommandBuffer commandBuffer, + uint32_t coverageToColorLocation); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationModeNV( + VkCommandBuffer commandBuffer, + VkCoverageModulationModeNV coverageModulationMode); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationTableEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 coverageModulationTableEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageModulationTableNV( + VkCommandBuffer commandBuffer, + uint32_t coverageModulationTableCount, + const float* pCoverageModulationTable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetShadingRateImageEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 shadingRateImageEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRepresentativeFragmentTestEnableNV( + VkCommandBuffer commandBuffer, + VkBool32 representativeFragmentTestEnable); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetCoverageReductionModeNV( + VkCommandBuffer commandBuffer, + VkCoverageReductionModeNV coverageReductionMode); +#endif + + +// VK_EXT_subpass_merge_feedback is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_subpass_merge_feedback 1 +#define VK_EXT_SUBPASS_MERGE_FEEDBACK_SPEC_VERSION 2 +#define VK_EXT_SUBPASS_MERGE_FEEDBACK_EXTENSION_NAME "VK_EXT_subpass_merge_feedback" + +typedef enum VkSubpassMergeStatusEXT { + VK_SUBPASS_MERGE_STATUS_MERGED_EXT = 0, + VK_SUBPASS_MERGE_STATUS_DISALLOWED_EXT = 1, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_SIDE_EFFECTS_EXT = 2, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_SAMPLES_MISMATCH_EXT = 3, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_VIEWS_MISMATCH_EXT = 4, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_ALIASING_EXT = 5, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_DEPENDENCIES_EXT = 6, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_INCOMPATIBLE_INPUT_ATTACHMENT_EXT = 7, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_TOO_MANY_ATTACHMENTS_EXT = 8, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_INSUFFICIENT_STORAGE_EXT = 9, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_DEPTH_STENCIL_COUNT_EXT = 10, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_RESOLVE_ATTACHMENT_REUSE_EXT = 11, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_SINGLE_SUBPASS_EXT = 12, + VK_SUBPASS_MERGE_STATUS_NOT_MERGED_UNSPECIFIED_EXT = 13, + VK_SUBPASS_MERGE_STATUS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkSubpassMergeStatusEXT; +typedef struct VkPhysicalDeviceSubpassMergeFeedbackFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 subpassMergeFeedback; +} VkPhysicalDeviceSubpassMergeFeedbackFeaturesEXT; + +typedef struct VkRenderPassCreationControlEXT { + VkStructureType sType; + const void* pNext; + VkBool32 disallowMerging; +} VkRenderPassCreationControlEXT; + +typedef struct VkRenderPassCreationFeedbackInfoEXT { + uint32_t postMergeSubpassCount; +} VkRenderPassCreationFeedbackInfoEXT; + +typedef struct VkRenderPassCreationFeedbackCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkRenderPassCreationFeedbackInfoEXT* pRenderPassFeedback; +} VkRenderPassCreationFeedbackCreateInfoEXT; + +typedef struct VkRenderPassSubpassFeedbackInfoEXT { + VkSubpassMergeStatusEXT subpassMergeStatus; + char description[VK_MAX_DESCRIPTION_SIZE]; + uint32_t postMergeIndex; +} VkRenderPassSubpassFeedbackInfoEXT; + +typedef struct VkRenderPassSubpassFeedbackCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkRenderPassSubpassFeedbackInfoEXT* pSubpassFeedback; +} VkRenderPassSubpassFeedbackCreateInfoEXT; + + + +// VK_LUNARG_direct_driver_loading is a preprocessor guard. Do not pass it to API calls. +#define VK_LUNARG_direct_driver_loading 1 +#define VK_LUNARG_DIRECT_DRIVER_LOADING_SPEC_VERSION 1 +#define VK_LUNARG_DIRECT_DRIVER_LOADING_EXTENSION_NAME "VK_LUNARG_direct_driver_loading" + +typedef enum VkDirectDriverLoadingModeLUNARG { + VK_DIRECT_DRIVER_LOADING_MODE_EXCLUSIVE_LUNARG = 0, + VK_DIRECT_DRIVER_LOADING_MODE_INCLUSIVE_LUNARG = 1, + VK_DIRECT_DRIVER_LOADING_MODE_MAX_ENUM_LUNARG = 0x7FFFFFFF +} VkDirectDriverLoadingModeLUNARG; +typedef VkFlags VkDirectDriverLoadingFlagsLUNARG; +typedef PFN_vkVoidFunction (VKAPI_PTR *PFN_vkGetInstanceProcAddrLUNARG)( + VkInstance instance, const char* pName); + +typedef struct VkDirectDriverLoadingInfoLUNARG { + VkStructureType sType; + void* pNext; + VkDirectDriverLoadingFlagsLUNARG flags; + PFN_vkGetInstanceProcAddrLUNARG pfnGetInstanceProcAddr; +} VkDirectDriverLoadingInfoLUNARG; + +typedef struct VkDirectDriverLoadingListLUNARG { + VkStructureType sType; + const void* pNext; + VkDirectDriverLoadingModeLUNARG mode; + uint32_t driverCount; + const VkDirectDriverLoadingInfoLUNARG* pDrivers; +} VkDirectDriverLoadingListLUNARG; + + + +// VK_EXT_shader_module_identifier is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_module_identifier 1 +#define VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT 32U +#define VK_EXT_SHADER_MODULE_IDENTIFIER_SPEC_VERSION 1 +#define VK_EXT_SHADER_MODULE_IDENTIFIER_EXTENSION_NAME "VK_EXT_shader_module_identifier" +typedef struct VkPhysicalDeviceShaderModuleIdentifierFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderModuleIdentifier; +} VkPhysicalDeviceShaderModuleIdentifierFeaturesEXT; + +typedef struct VkPhysicalDeviceShaderModuleIdentifierPropertiesEXT { + VkStructureType sType; + void* pNext; + uint8_t shaderModuleIdentifierAlgorithmUUID[VK_UUID_SIZE]; +} VkPhysicalDeviceShaderModuleIdentifierPropertiesEXT; + +typedef struct VkPipelineShaderStageModuleIdentifierCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t identifierSize; + const uint8_t* pIdentifier; +} VkPipelineShaderStageModuleIdentifierCreateInfoEXT; + +typedef struct VkShaderModuleIdentifierEXT { + VkStructureType sType; + void* pNext; + uint32_t identifierSize; + uint8_t identifier[VK_MAX_SHADER_MODULE_IDENTIFIER_SIZE_EXT]; +} VkShaderModuleIdentifierEXT; + +typedef void (VKAPI_PTR *PFN_vkGetShaderModuleIdentifierEXT)(VkDevice device, VkShaderModule shaderModule, VkShaderModuleIdentifierEXT* pIdentifier); +typedef void (VKAPI_PTR *PFN_vkGetShaderModuleCreateInfoIdentifierEXT)(VkDevice device, const VkShaderModuleCreateInfo* pCreateInfo, VkShaderModuleIdentifierEXT* pIdentifier); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkGetShaderModuleIdentifierEXT( + VkDevice device, + VkShaderModule shaderModule, + VkShaderModuleIdentifierEXT* pIdentifier); + +VKAPI_ATTR void VKAPI_CALL vkGetShaderModuleCreateInfoIdentifierEXT( + VkDevice device, + const VkShaderModuleCreateInfo* pCreateInfo, + VkShaderModuleIdentifierEXT* pIdentifier); +#endif + + +// VK_EXT_rasterization_order_attachment_access is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_rasterization_order_attachment_access 1 +#define VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_SPEC_VERSION 1 +#define VK_EXT_RASTERIZATION_ORDER_ATTACHMENT_ACCESS_EXTENSION_NAME "VK_EXT_rasterization_order_attachment_access" + + +// VK_NV_optical_flow is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_optical_flow 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkOpticalFlowSessionNV) +#define VK_NV_OPTICAL_FLOW_SPEC_VERSION 1 +#define VK_NV_OPTICAL_FLOW_EXTENSION_NAME "VK_NV_optical_flow" + +typedef enum VkOpticalFlowPerformanceLevelNV { + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_SLOW_NV = 1, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_MEDIUM_NV = 2, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_FAST_NV = 3, + VK_OPTICAL_FLOW_PERFORMANCE_LEVEL_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowPerformanceLevelNV; + +typedef enum VkOpticalFlowSessionBindingPointNV { + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_INPUT_NV = 1, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_REFERENCE_NV = 2, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_HINT_NV = 3, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_FLOW_VECTOR_NV = 4, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_BACKWARD_FLOW_VECTOR_NV = 5, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_COST_NV = 6, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_BACKWARD_COST_NV = 7, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_GLOBAL_FLOW_NV = 8, + VK_OPTICAL_FLOW_SESSION_BINDING_POINT_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowSessionBindingPointNV; + +typedef enum VkOpticalFlowGridSizeFlagBitsNV { + VK_OPTICAL_FLOW_GRID_SIZE_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_GRID_SIZE_1X1_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_GRID_SIZE_2X2_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_GRID_SIZE_4X4_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_GRID_SIZE_8X8_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_GRID_SIZE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowGridSizeFlagBitsNV; +typedef VkFlags VkOpticalFlowGridSizeFlagsNV; + +typedef enum VkOpticalFlowUsageFlagBitsNV { + VK_OPTICAL_FLOW_USAGE_UNKNOWN_NV = 0, + VK_OPTICAL_FLOW_USAGE_INPUT_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_USAGE_OUTPUT_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_USAGE_HINT_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_USAGE_COST_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_USAGE_GLOBAL_FLOW_BIT_NV = 0x00000010, + VK_OPTICAL_FLOW_USAGE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowUsageFlagBitsNV; +typedef VkFlags VkOpticalFlowUsageFlagsNV; + +typedef enum VkOpticalFlowSessionCreateFlagBitsNV { + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_HINT_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_COST_BIT_NV = 0x00000002, + VK_OPTICAL_FLOW_SESSION_CREATE_ENABLE_GLOBAL_FLOW_BIT_NV = 0x00000004, + VK_OPTICAL_FLOW_SESSION_CREATE_ALLOW_REGIONS_BIT_NV = 0x00000008, + VK_OPTICAL_FLOW_SESSION_CREATE_BOTH_DIRECTIONS_BIT_NV = 0x00000010, + VK_OPTICAL_FLOW_SESSION_CREATE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowSessionCreateFlagBitsNV; +typedef VkFlags VkOpticalFlowSessionCreateFlagsNV; + +typedef enum VkOpticalFlowExecuteFlagBitsNV { + VK_OPTICAL_FLOW_EXECUTE_DISABLE_TEMPORAL_HINTS_BIT_NV = 0x00000001, + VK_OPTICAL_FLOW_EXECUTE_FLAG_BITS_MAX_ENUM_NV = 0x7FFFFFFF +} VkOpticalFlowExecuteFlagBitsNV; +typedef VkFlags VkOpticalFlowExecuteFlagsNV; +typedef struct VkPhysicalDeviceOpticalFlowFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 opticalFlow; +} VkPhysicalDeviceOpticalFlowFeaturesNV; + +typedef struct VkPhysicalDeviceOpticalFlowPropertiesNV { + VkStructureType sType; + void* pNext; + VkOpticalFlowGridSizeFlagsNV supportedOutputGridSizes; + VkOpticalFlowGridSizeFlagsNV supportedHintGridSizes; + VkBool32 hintSupported; + VkBool32 costSupported; + VkBool32 bidirectionalFlowSupported; + VkBool32 globalFlowSupported; + uint32_t minWidth; + uint32_t minHeight; + uint32_t maxWidth; + uint32_t maxHeight; + uint32_t maxNumRegionsOfInterest; +} VkPhysicalDeviceOpticalFlowPropertiesNV; + +typedef struct VkOpticalFlowImageFormatInfoNV { + VkStructureType sType; + const void* pNext; + VkOpticalFlowUsageFlagsNV usage; +} VkOpticalFlowImageFormatInfoNV; + +typedef struct VkOpticalFlowImageFormatPropertiesNV { + VkStructureType sType; + const void* pNext; + VkFormat format; +} VkOpticalFlowImageFormatPropertiesNV; + +typedef struct VkOpticalFlowSessionCreateInfoNV { + VkStructureType sType; + void* pNext; + uint32_t width; + uint32_t height; + VkFormat imageFormat; + VkFormat flowVectorFormat; + VkFormat costFormat; + VkOpticalFlowGridSizeFlagsNV outputGridSize; + VkOpticalFlowGridSizeFlagsNV hintGridSize; + VkOpticalFlowPerformanceLevelNV performanceLevel; + VkOpticalFlowSessionCreateFlagsNV flags; +} VkOpticalFlowSessionCreateInfoNV; + +typedef struct VkOpticalFlowSessionCreatePrivateDataInfoNV { + VkStructureType sType; + void* pNext; + uint32_t id; + uint32_t size; + const void* pPrivateData; +} VkOpticalFlowSessionCreatePrivateDataInfoNV; + +typedef struct VkOpticalFlowExecuteInfoNV { + VkStructureType sType; + void* pNext; + VkOpticalFlowExecuteFlagsNV flags; + uint32_t regionCount; + const VkRect2D* pRegions; +} VkOpticalFlowExecuteInfoNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceOpticalFlowImageFormatsNV)(VkPhysicalDevice physicalDevice, const VkOpticalFlowImageFormatInfoNV* pOpticalFlowImageFormatInfo, uint32_t* pFormatCount, VkOpticalFlowImageFormatPropertiesNV* pImageFormatProperties); +typedef VkResult (VKAPI_PTR *PFN_vkCreateOpticalFlowSessionNV)(VkDevice device, const VkOpticalFlowSessionCreateInfoNV* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkOpticalFlowSessionNV* pSession); +typedef void (VKAPI_PTR *PFN_vkDestroyOpticalFlowSessionNV)(VkDevice device, VkOpticalFlowSessionNV session, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkBindOpticalFlowSessionImageNV)(VkDevice device, VkOpticalFlowSessionNV session, VkOpticalFlowSessionBindingPointNV bindingPoint, VkImageView view, VkImageLayout layout); +typedef void (VKAPI_PTR *PFN_vkCmdOpticalFlowExecuteNV)(VkCommandBuffer commandBuffer, VkOpticalFlowSessionNV session, const VkOpticalFlowExecuteInfoNV* pExecuteInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceOpticalFlowImageFormatsNV( + VkPhysicalDevice physicalDevice, + const VkOpticalFlowImageFormatInfoNV* pOpticalFlowImageFormatInfo, + uint32_t* pFormatCount, + VkOpticalFlowImageFormatPropertiesNV* pImageFormatProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateOpticalFlowSessionNV( + VkDevice device, + const VkOpticalFlowSessionCreateInfoNV* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkOpticalFlowSessionNV* pSession); + +VKAPI_ATTR void VKAPI_CALL vkDestroyOpticalFlowSessionNV( + VkDevice device, + VkOpticalFlowSessionNV session, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkBindOpticalFlowSessionImageNV( + VkDevice device, + VkOpticalFlowSessionNV session, + VkOpticalFlowSessionBindingPointNV bindingPoint, + VkImageView view, + VkImageLayout layout); + +VKAPI_ATTR void VKAPI_CALL vkCmdOpticalFlowExecuteNV( + VkCommandBuffer commandBuffer, + VkOpticalFlowSessionNV session, + const VkOpticalFlowExecuteInfoNV* pExecuteInfo); +#endif + + +// VK_EXT_legacy_dithering is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_legacy_dithering 1 +#define VK_EXT_LEGACY_DITHERING_SPEC_VERSION 1 +#define VK_EXT_LEGACY_DITHERING_EXTENSION_NAME "VK_EXT_legacy_dithering" +typedef struct VkPhysicalDeviceLegacyDitheringFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 legacyDithering; +} VkPhysicalDeviceLegacyDitheringFeaturesEXT; + + + +// VK_EXT_pipeline_protected_access is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_protected_access 1 +#define VK_EXT_PIPELINE_PROTECTED_ACCESS_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_PROTECTED_ACCESS_EXTENSION_NAME "VK_EXT_pipeline_protected_access" +typedef struct VkPhysicalDevicePipelineProtectedAccessFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineProtectedAccess; +} VkPhysicalDevicePipelineProtectedAccessFeaturesEXT; + + + +// VK_EXT_shader_object is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_shader_object 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkShaderEXT) +#define VK_EXT_SHADER_OBJECT_SPEC_VERSION 1 +#define VK_EXT_SHADER_OBJECT_EXTENSION_NAME "VK_EXT_shader_object" + +typedef enum VkShaderCodeTypeEXT { + VK_SHADER_CODE_TYPE_BINARY_EXT = 0, + VK_SHADER_CODE_TYPE_SPIRV_EXT = 1, + VK_SHADER_CODE_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkShaderCodeTypeEXT; + +typedef enum VkShaderCreateFlagBitsEXT { + VK_SHADER_CREATE_LINK_STAGE_BIT_EXT = 0x00000001, + VK_SHADER_CREATE_ALLOW_VARYING_SUBGROUP_SIZE_BIT_EXT = 0x00000002, + VK_SHADER_CREATE_REQUIRE_FULL_SUBGROUPS_BIT_EXT = 0x00000004, + VK_SHADER_CREATE_NO_TASK_SHADER_BIT_EXT = 0x00000008, + VK_SHADER_CREATE_DISPATCH_BASE_BIT_EXT = 0x00000010, + VK_SHADER_CREATE_FRAGMENT_SHADING_RATE_ATTACHMENT_BIT_EXT = 0x00000020, + VK_SHADER_CREATE_FRAGMENT_DENSITY_MAP_ATTACHMENT_BIT_EXT = 0x00000040, + VK_SHADER_CREATE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkShaderCreateFlagBitsEXT; +typedef VkFlags VkShaderCreateFlagsEXT; +typedef struct VkPhysicalDeviceShaderObjectFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 shaderObject; +} VkPhysicalDeviceShaderObjectFeaturesEXT; + +typedef struct VkPhysicalDeviceShaderObjectPropertiesEXT { + VkStructureType sType; + void* pNext; + uint8_t shaderBinaryUUID[VK_UUID_SIZE]; + uint32_t shaderBinaryVersion; +} VkPhysicalDeviceShaderObjectPropertiesEXT; + +typedef struct VkShaderCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkShaderCreateFlagsEXT flags; + VkShaderStageFlagBits stage; + VkShaderStageFlags nextStage; + VkShaderCodeTypeEXT codeType; + size_t codeSize; + const void* pCode; + const char* pName; + uint32_t setLayoutCount; + const VkDescriptorSetLayout* pSetLayouts; + uint32_t pushConstantRangeCount; + const VkPushConstantRange* pPushConstantRanges; + const VkSpecializationInfo* pSpecializationInfo; +} VkShaderCreateInfoEXT; + +typedef VkPipelineShaderStageRequiredSubgroupSizeCreateInfo VkShaderRequiredSubgroupSizeCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateShadersEXT)(VkDevice device, uint32_t createInfoCount, const VkShaderCreateInfoEXT* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkShaderEXT* pShaders); +typedef void (VKAPI_PTR *PFN_vkDestroyShaderEXT)(VkDevice device, VkShaderEXT shader, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetShaderBinaryDataEXT)(VkDevice device, VkShaderEXT shader, size_t* pDataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdBindShadersEXT)(VkCommandBuffer commandBuffer, uint32_t stageCount, const VkShaderStageFlagBits* pStages, const VkShaderEXT* pShaders); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateShadersEXT( + VkDevice device, + uint32_t createInfoCount, + const VkShaderCreateInfoEXT* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkShaderEXT* pShaders); + +VKAPI_ATTR void VKAPI_CALL vkDestroyShaderEXT( + VkDevice device, + VkShaderEXT shader, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetShaderBinaryDataEXT( + VkDevice device, + VkShaderEXT shader, + size_t* pDataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdBindShadersEXT( + VkCommandBuffer commandBuffer, + uint32_t stageCount, + const VkShaderStageFlagBits* pStages, + const VkShaderEXT* pShaders); +#endif + + +// VK_QCOM_tile_properties is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_tile_properties 1 +#define VK_QCOM_TILE_PROPERTIES_SPEC_VERSION 1 +#define VK_QCOM_TILE_PROPERTIES_EXTENSION_NAME "VK_QCOM_tile_properties" +typedef struct VkPhysicalDeviceTilePropertiesFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 tileProperties; +} VkPhysicalDeviceTilePropertiesFeaturesQCOM; + +typedef struct VkTilePropertiesQCOM { + VkStructureType sType; + void* pNext; + VkExtent3D tileSize; + VkExtent2D apronSize; + VkOffset2D origin; +} VkTilePropertiesQCOM; + +typedef VkResult (VKAPI_PTR *PFN_vkGetFramebufferTilePropertiesQCOM)(VkDevice device, VkFramebuffer framebuffer, uint32_t* pPropertiesCount, VkTilePropertiesQCOM* pProperties); +typedef VkResult (VKAPI_PTR *PFN_vkGetDynamicRenderingTilePropertiesQCOM)(VkDevice device, const VkRenderingInfo* pRenderingInfo, VkTilePropertiesQCOM* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetFramebufferTilePropertiesQCOM( + VkDevice device, + VkFramebuffer framebuffer, + uint32_t* pPropertiesCount, + VkTilePropertiesQCOM* pProperties); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDynamicRenderingTilePropertiesQCOM( + VkDevice device, + const VkRenderingInfo* pRenderingInfo, + VkTilePropertiesQCOM* pProperties); +#endif + + +// VK_SEC_amigo_profiling is a preprocessor guard. Do not pass it to API calls. +#define VK_SEC_amigo_profiling 1 +#define VK_SEC_AMIGO_PROFILING_SPEC_VERSION 1 +#define VK_SEC_AMIGO_PROFILING_EXTENSION_NAME "VK_SEC_amigo_profiling" +typedef struct VkPhysicalDeviceAmigoProfilingFeaturesSEC { + VkStructureType sType; + void* pNext; + VkBool32 amigoProfiling; +} VkPhysicalDeviceAmigoProfilingFeaturesSEC; + +typedef struct VkAmigoProfilingSubmitInfoSEC { + VkStructureType sType; + const void* pNext; + uint64_t firstDrawTimestamp; + uint64_t swapBufferTimestamp; +} VkAmigoProfilingSubmitInfoSEC; + + + +// VK_QCOM_multiview_per_view_viewports is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_multiview_per_view_viewports 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_VIEWPORTS_SPEC_VERSION 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_VIEWPORTS_EXTENSION_NAME "VK_QCOM_multiview_per_view_viewports" +typedef struct VkPhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 multiviewPerViewViewports; +} VkPhysicalDeviceMultiviewPerViewViewportsFeaturesQCOM; + + + +// VK_NV_ray_tracing_invocation_reorder is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_ray_tracing_invocation_reorder 1 +#define VK_NV_RAY_TRACING_INVOCATION_REORDER_SPEC_VERSION 1 +#define VK_NV_RAY_TRACING_INVOCATION_REORDER_EXTENSION_NAME "VK_NV_ray_tracing_invocation_reorder" + +typedef enum VkRayTracingInvocationReorderModeNV { + VK_RAY_TRACING_INVOCATION_REORDER_MODE_NONE_NV = 0, + VK_RAY_TRACING_INVOCATION_REORDER_MODE_REORDER_NV = 1, + VK_RAY_TRACING_INVOCATION_REORDER_MODE_MAX_ENUM_NV = 0x7FFFFFFF +} VkRayTracingInvocationReorderModeNV; +typedef struct VkPhysicalDeviceRayTracingInvocationReorderPropertiesNV { + VkStructureType sType; + void* pNext; + VkRayTracingInvocationReorderModeNV rayTracingInvocationReorderReorderingHint; +} VkPhysicalDeviceRayTracingInvocationReorderPropertiesNV; + +typedef struct VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingInvocationReorder; +} VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV; + + + +// VK_NV_extended_sparse_address_space is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_extended_sparse_address_space 1 +#define VK_NV_EXTENDED_SPARSE_ADDRESS_SPACE_SPEC_VERSION 1 +#define VK_NV_EXTENDED_SPARSE_ADDRESS_SPACE_EXTENSION_NAME "VK_NV_extended_sparse_address_space" +typedef struct VkPhysicalDeviceExtendedSparseAddressSpaceFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 extendedSparseAddressSpace; +} VkPhysicalDeviceExtendedSparseAddressSpaceFeaturesNV; + +typedef struct VkPhysicalDeviceExtendedSparseAddressSpacePropertiesNV { + VkStructureType sType; + void* pNext; + VkDeviceSize extendedSparseAddressSpaceSize; + VkImageUsageFlags extendedSparseImageUsageFlags; + VkBufferUsageFlags extendedSparseBufferUsageFlags; +} VkPhysicalDeviceExtendedSparseAddressSpacePropertiesNV; + + + +// VK_EXT_mutable_descriptor_type is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_mutable_descriptor_type 1 +#define VK_EXT_MUTABLE_DESCRIPTOR_TYPE_SPEC_VERSION 1 +#define VK_EXT_MUTABLE_DESCRIPTOR_TYPE_EXTENSION_NAME "VK_EXT_mutable_descriptor_type" + + +// VK_EXT_layer_settings is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_layer_settings 1 +#define VK_EXT_LAYER_SETTINGS_SPEC_VERSION 2 +#define VK_EXT_LAYER_SETTINGS_EXTENSION_NAME "VK_EXT_layer_settings" + +typedef enum VkLayerSettingTypeEXT { + VK_LAYER_SETTING_TYPE_BOOL32_EXT = 0, + VK_LAYER_SETTING_TYPE_INT32_EXT = 1, + VK_LAYER_SETTING_TYPE_INT64_EXT = 2, + VK_LAYER_SETTING_TYPE_UINT32_EXT = 3, + VK_LAYER_SETTING_TYPE_UINT64_EXT = 4, + VK_LAYER_SETTING_TYPE_FLOAT32_EXT = 5, + VK_LAYER_SETTING_TYPE_FLOAT64_EXT = 6, + VK_LAYER_SETTING_TYPE_STRING_EXT = 7, + VK_LAYER_SETTING_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkLayerSettingTypeEXT; +typedef struct VkLayerSettingEXT { + const char* pLayerName; + const char* pSettingName; + VkLayerSettingTypeEXT type; + uint32_t valueCount; + const void* pValues; +} VkLayerSettingEXT; + +typedef struct VkLayerSettingsCreateInfoEXT { + VkStructureType sType; + const void* pNext; + uint32_t settingCount; + const VkLayerSettingEXT* pSettings; +} VkLayerSettingsCreateInfoEXT; + + + +// VK_ARM_shader_core_builtins is a preprocessor guard. Do not pass it to API calls. +#define VK_ARM_shader_core_builtins 1 +#define VK_ARM_SHADER_CORE_BUILTINS_SPEC_VERSION 2 +#define VK_ARM_SHADER_CORE_BUILTINS_EXTENSION_NAME "VK_ARM_shader_core_builtins" +typedef struct VkPhysicalDeviceShaderCoreBuiltinsFeaturesARM { + VkStructureType sType; + void* pNext; + VkBool32 shaderCoreBuiltins; +} VkPhysicalDeviceShaderCoreBuiltinsFeaturesARM; + +typedef struct VkPhysicalDeviceShaderCoreBuiltinsPropertiesARM { + VkStructureType sType; + void* pNext; + uint64_t shaderCoreMask; + uint32_t shaderCoreCount; + uint32_t shaderWarpsPerCore; +} VkPhysicalDeviceShaderCoreBuiltinsPropertiesARM; + + + +// VK_EXT_pipeline_library_group_handles is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_pipeline_library_group_handles 1 +#define VK_EXT_PIPELINE_LIBRARY_GROUP_HANDLES_SPEC_VERSION 1 +#define VK_EXT_PIPELINE_LIBRARY_GROUP_HANDLES_EXTENSION_NAME "VK_EXT_pipeline_library_group_handles" +typedef struct VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 pipelineLibraryGroupHandles; +} VkPhysicalDevicePipelineLibraryGroupHandlesFeaturesEXT; + + + +// VK_EXT_dynamic_rendering_unused_attachments is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_dynamic_rendering_unused_attachments 1 +#define VK_EXT_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_SPEC_VERSION 1 +#define VK_EXT_DYNAMIC_RENDERING_UNUSED_ATTACHMENTS_EXTENSION_NAME "VK_EXT_dynamic_rendering_unused_attachments" +typedef struct VkPhysicalDeviceDynamicRenderingUnusedAttachmentsFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 dynamicRenderingUnusedAttachments; +} VkPhysicalDeviceDynamicRenderingUnusedAttachmentsFeaturesEXT; + + + +// VK_NV_low_latency2 is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_low_latency2 1 +#define VK_NV_LOW_LATENCY_2_SPEC_VERSION 2 +#define VK_NV_LOW_LATENCY_2_EXTENSION_NAME "VK_NV_low_latency2" + +typedef enum VkLatencyMarkerNV { + VK_LATENCY_MARKER_SIMULATION_START_NV = 0, + VK_LATENCY_MARKER_SIMULATION_END_NV = 1, + VK_LATENCY_MARKER_RENDERSUBMIT_START_NV = 2, + VK_LATENCY_MARKER_RENDERSUBMIT_END_NV = 3, + VK_LATENCY_MARKER_PRESENT_START_NV = 4, + VK_LATENCY_MARKER_PRESENT_END_NV = 5, + VK_LATENCY_MARKER_INPUT_SAMPLE_NV = 6, + VK_LATENCY_MARKER_TRIGGER_FLASH_NV = 7, + VK_LATENCY_MARKER_OUT_OF_BAND_RENDERSUBMIT_START_NV = 8, + VK_LATENCY_MARKER_OUT_OF_BAND_RENDERSUBMIT_END_NV = 9, + VK_LATENCY_MARKER_OUT_OF_BAND_PRESENT_START_NV = 10, + VK_LATENCY_MARKER_OUT_OF_BAND_PRESENT_END_NV = 11, + VK_LATENCY_MARKER_MAX_ENUM_NV = 0x7FFFFFFF +} VkLatencyMarkerNV; + +typedef enum VkOutOfBandQueueTypeNV { + VK_OUT_OF_BAND_QUEUE_TYPE_RENDER_NV = 0, + VK_OUT_OF_BAND_QUEUE_TYPE_PRESENT_NV = 1, + VK_OUT_OF_BAND_QUEUE_TYPE_MAX_ENUM_NV = 0x7FFFFFFF +} VkOutOfBandQueueTypeNV; +typedef struct VkLatencySleepModeInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 lowLatencyMode; + VkBool32 lowLatencyBoost; + uint32_t minimumIntervalUs; +} VkLatencySleepModeInfoNV; + +typedef struct VkLatencySleepInfoNV { + VkStructureType sType; + const void* pNext; + VkSemaphore signalSemaphore; + uint64_t value; +} VkLatencySleepInfoNV; + +typedef struct VkSetLatencyMarkerInfoNV { + VkStructureType sType; + const void* pNext; + uint64_t presentID; + VkLatencyMarkerNV marker; +} VkSetLatencyMarkerInfoNV; + +typedef struct VkLatencyTimingsFrameReportNV { + VkStructureType sType; + const void* pNext; + uint64_t presentID; + uint64_t inputSampleTimeUs; + uint64_t simStartTimeUs; + uint64_t simEndTimeUs; + uint64_t renderSubmitStartTimeUs; + uint64_t renderSubmitEndTimeUs; + uint64_t presentStartTimeUs; + uint64_t presentEndTimeUs; + uint64_t driverStartTimeUs; + uint64_t driverEndTimeUs; + uint64_t osRenderQueueStartTimeUs; + uint64_t osRenderQueueEndTimeUs; + uint64_t gpuRenderStartTimeUs; + uint64_t gpuRenderEndTimeUs; +} VkLatencyTimingsFrameReportNV; + +typedef struct VkGetLatencyMarkerInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t timingCount; + VkLatencyTimingsFrameReportNV* pTimings; +} VkGetLatencyMarkerInfoNV; + +typedef struct VkLatencySubmissionPresentIdNV { + VkStructureType sType; + const void* pNext; + uint64_t presentID; +} VkLatencySubmissionPresentIdNV; + +typedef struct VkSwapchainLatencyCreateInfoNV { + VkStructureType sType; + const void* pNext; + VkBool32 latencyModeEnable; +} VkSwapchainLatencyCreateInfoNV; + +typedef struct VkOutOfBandQueueTypeInfoNV { + VkStructureType sType; + const void* pNext; + VkOutOfBandQueueTypeNV queueType; +} VkOutOfBandQueueTypeInfoNV; + +typedef struct VkLatencySurfaceCapabilitiesNV { + VkStructureType sType; + const void* pNext; + uint32_t presentModeCount; + VkPresentModeKHR* pPresentModes; +} VkLatencySurfaceCapabilitiesNV; + +typedef VkResult (VKAPI_PTR *PFN_vkSetLatencySleepModeNV)(VkDevice device, VkSwapchainKHR swapchain, const VkLatencySleepModeInfoNV* pSleepModeInfo); +typedef VkResult (VKAPI_PTR *PFN_vkLatencySleepNV)(VkDevice device, VkSwapchainKHR swapchain, const VkLatencySleepInfoNV* pSleepInfo); +typedef void (VKAPI_PTR *PFN_vkSetLatencyMarkerNV)(VkDevice device, VkSwapchainKHR swapchain, const VkSetLatencyMarkerInfoNV* pLatencyMarkerInfo); +typedef void (VKAPI_PTR *PFN_vkGetLatencyTimingsNV)(VkDevice device, VkSwapchainKHR swapchain, VkGetLatencyMarkerInfoNV* pLatencyMarkerInfo); +typedef void (VKAPI_PTR *PFN_vkQueueNotifyOutOfBandNV)(VkQueue queue, const VkOutOfBandQueueTypeInfoNV* pQueueTypeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkSetLatencySleepModeNV( + VkDevice device, + VkSwapchainKHR swapchain, + const VkLatencySleepModeInfoNV* pSleepModeInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkLatencySleepNV( + VkDevice device, + VkSwapchainKHR swapchain, + const VkLatencySleepInfoNV* pSleepInfo); + +VKAPI_ATTR void VKAPI_CALL vkSetLatencyMarkerNV( + VkDevice device, + VkSwapchainKHR swapchain, + const VkSetLatencyMarkerInfoNV* pLatencyMarkerInfo); + +VKAPI_ATTR void VKAPI_CALL vkGetLatencyTimingsNV( + VkDevice device, + VkSwapchainKHR swapchain, + VkGetLatencyMarkerInfoNV* pLatencyMarkerInfo); + +VKAPI_ATTR void VKAPI_CALL vkQueueNotifyOutOfBandNV( + VkQueue queue, + const VkOutOfBandQueueTypeInfoNV* pQueueTypeInfo); +#endif + + +// VK_QCOM_multiview_per_view_render_areas is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_multiview_per_view_render_areas 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_RENDER_AREAS_SPEC_VERSION 1 +#define VK_QCOM_MULTIVIEW_PER_VIEW_RENDER_AREAS_EXTENSION_NAME "VK_QCOM_multiview_per_view_render_areas" +typedef struct VkPhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 multiviewPerViewRenderAreas; +} VkPhysicalDeviceMultiviewPerViewRenderAreasFeaturesQCOM; + +typedef struct VkMultiviewPerViewRenderAreasRenderPassBeginInfoQCOM { + VkStructureType sType; + const void* pNext; + uint32_t perViewRenderAreaCount; + const VkRect2D* pPerViewRenderAreas; +} VkMultiviewPerViewRenderAreasRenderPassBeginInfoQCOM; + + + +// VK_NV_per_stage_descriptor_set is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_per_stage_descriptor_set 1 +#define VK_NV_PER_STAGE_DESCRIPTOR_SET_SPEC_VERSION 1 +#define VK_NV_PER_STAGE_DESCRIPTOR_SET_EXTENSION_NAME "VK_NV_per_stage_descriptor_set" +typedef struct VkPhysicalDevicePerStageDescriptorSetFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 perStageDescriptorSet; + VkBool32 dynamicPipelineLayout; +} VkPhysicalDevicePerStageDescriptorSetFeaturesNV; + + + +// VK_QCOM_image_processing2 is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_image_processing2 1 +#define VK_QCOM_IMAGE_PROCESSING_2_SPEC_VERSION 1 +#define VK_QCOM_IMAGE_PROCESSING_2_EXTENSION_NAME "VK_QCOM_image_processing2" + +typedef enum VkBlockMatchWindowCompareModeQCOM { + VK_BLOCK_MATCH_WINDOW_COMPARE_MODE_MIN_QCOM = 0, + VK_BLOCK_MATCH_WINDOW_COMPARE_MODE_MAX_QCOM = 1, + VK_BLOCK_MATCH_WINDOW_COMPARE_MODE_MAX_ENUM_QCOM = 0x7FFFFFFF +} VkBlockMatchWindowCompareModeQCOM; +typedef struct VkPhysicalDeviceImageProcessing2FeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 textureBlockMatch2; +} VkPhysicalDeviceImageProcessing2FeaturesQCOM; + +typedef struct VkPhysicalDeviceImageProcessing2PropertiesQCOM { + VkStructureType sType; + void* pNext; + VkExtent2D maxBlockMatchWindow; +} VkPhysicalDeviceImageProcessing2PropertiesQCOM; + +typedef struct VkSamplerBlockMatchWindowCreateInfoQCOM { + VkStructureType sType; + const void* pNext; + VkExtent2D windowExtent; + VkBlockMatchWindowCompareModeQCOM windowCompareMode; +} VkSamplerBlockMatchWindowCreateInfoQCOM; + + + +// VK_QCOM_filter_cubic_weights is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_filter_cubic_weights 1 +#define VK_QCOM_FILTER_CUBIC_WEIGHTS_SPEC_VERSION 1 +#define VK_QCOM_FILTER_CUBIC_WEIGHTS_EXTENSION_NAME "VK_QCOM_filter_cubic_weights" + +typedef enum VkCubicFilterWeightsQCOM { + VK_CUBIC_FILTER_WEIGHTS_CATMULL_ROM_QCOM = 0, + VK_CUBIC_FILTER_WEIGHTS_ZERO_TANGENT_CARDINAL_QCOM = 1, + VK_CUBIC_FILTER_WEIGHTS_B_SPLINE_QCOM = 2, + VK_CUBIC_FILTER_WEIGHTS_MITCHELL_NETRAVALI_QCOM = 3, + VK_CUBIC_FILTER_WEIGHTS_MAX_ENUM_QCOM = 0x7FFFFFFF +} VkCubicFilterWeightsQCOM; +typedef struct VkPhysicalDeviceCubicWeightsFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 selectableCubicWeights; +} VkPhysicalDeviceCubicWeightsFeaturesQCOM; + +typedef struct VkSamplerCubicWeightsCreateInfoQCOM { + VkStructureType sType; + const void* pNext; + VkCubicFilterWeightsQCOM cubicWeights; +} VkSamplerCubicWeightsCreateInfoQCOM; + +typedef struct VkBlitImageCubicWeightsInfoQCOM { + VkStructureType sType; + const void* pNext; + VkCubicFilterWeightsQCOM cubicWeights; +} VkBlitImageCubicWeightsInfoQCOM; + + + +// VK_QCOM_ycbcr_degamma is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_ycbcr_degamma 1 +#define VK_QCOM_YCBCR_DEGAMMA_SPEC_VERSION 1 +#define VK_QCOM_YCBCR_DEGAMMA_EXTENSION_NAME "VK_QCOM_ycbcr_degamma" +typedef struct VkPhysicalDeviceYcbcrDegammaFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 ycbcrDegamma; +} VkPhysicalDeviceYcbcrDegammaFeaturesQCOM; + +typedef struct VkSamplerYcbcrConversionYcbcrDegammaCreateInfoQCOM { + VkStructureType sType; + void* pNext; + VkBool32 enableYDegamma; + VkBool32 enableCbCrDegamma; +} VkSamplerYcbcrConversionYcbcrDegammaCreateInfoQCOM; + + + +// VK_QCOM_filter_cubic_clamp is a preprocessor guard. Do not pass it to API calls. +#define VK_QCOM_filter_cubic_clamp 1 +#define VK_QCOM_FILTER_CUBIC_CLAMP_SPEC_VERSION 1 +#define VK_QCOM_FILTER_CUBIC_CLAMP_EXTENSION_NAME "VK_QCOM_filter_cubic_clamp" +typedef struct VkPhysicalDeviceCubicClampFeaturesQCOM { + VkStructureType sType; + void* pNext; + VkBool32 cubicRangeClamp; +} VkPhysicalDeviceCubicClampFeaturesQCOM; + + + +// VK_EXT_attachment_feedback_loop_dynamic_state is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_attachment_feedback_loop_dynamic_state 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_SPEC_VERSION 1 +#define VK_EXT_ATTACHMENT_FEEDBACK_LOOP_DYNAMIC_STATE_EXTENSION_NAME "VK_EXT_attachment_feedback_loop_dynamic_state" +typedef struct VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 attachmentFeedbackLoopDynamicState; +} VkPhysicalDeviceAttachmentFeedbackLoopDynamicStateFeaturesEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdSetAttachmentFeedbackLoopEnableEXT)(VkCommandBuffer commandBuffer, VkImageAspectFlags aspectMask); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdSetAttachmentFeedbackLoopEnableEXT( + VkCommandBuffer commandBuffer, + VkImageAspectFlags aspectMask); +#endif + + +// VK_MSFT_layered_driver is a preprocessor guard. Do not pass it to API calls. +#define VK_MSFT_layered_driver 1 +#define VK_MSFT_LAYERED_DRIVER_SPEC_VERSION 1 +#define VK_MSFT_LAYERED_DRIVER_EXTENSION_NAME "VK_MSFT_layered_driver" + +typedef enum VkLayeredDriverUnderlyingApiMSFT { + VK_LAYERED_DRIVER_UNDERLYING_API_NONE_MSFT = 0, + VK_LAYERED_DRIVER_UNDERLYING_API_D3D12_MSFT = 1, + VK_LAYERED_DRIVER_UNDERLYING_API_MAX_ENUM_MSFT = 0x7FFFFFFF +} VkLayeredDriverUnderlyingApiMSFT; +typedef struct VkPhysicalDeviceLayeredDriverPropertiesMSFT { + VkStructureType sType; + void* pNext; + VkLayeredDriverUnderlyingApiMSFT underlyingAPI; +} VkPhysicalDeviceLayeredDriverPropertiesMSFT; + + + +// VK_NV_descriptor_pool_overallocation is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_descriptor_pool_overallocation 1 +#define VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_SPEC_VERSION 1 +#define VK_NV_DESCRIPTOR_POOL_OVERALLOCATION_EXTENSION_NAME "VK_NV_descriptor_pool_overallocation" +typedef struct VkPhysicalDeviceDescriptorPoolOverallocationFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 descriptorPoolOverallocation; +} VkPhysicalDeviceDescriptorPoolOverallocationFeaturesNV; + + + +// VK_NV_raw_access_chains is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_raw_access_chains 1 +#define VK_NV_RAW_ACCESS_CHAINS_SPEC_VERSION 1 +#define VK_NV_RAW_ACCESS_CHAINS_EXTENSION_NAME "VK_NV_raw_access_chains" +typedef struct VkPhysicalDeviceRawAccessChainsFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 shaderRawAccessChains; +} VkPhysicalDeviceRawAccessChainsFeaturesNV; + + + +// VK_NV_shader_atomic_float16_vector is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_shader_atomic_float16_vector 1 +#define VK_NV_SHADER_ATOMIC_FLOAT16_VECTOR_SPEC_VERSION 1 +#define VK_NV_SHADER_ATOMIC_FLOAT16_VECTOR_EXTENSION_NAME "VK_NV_shader_atomic_float16_vector" +typedef struct VkPhysicalDeviceShaderAtomicFloat16VectorFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 shaderFloat16VectorAtomics; +} VkPhysicalDeviceShaderAtomicFloat16VectorFeaturesNV; + + + +// VK_NV_ray_tracing_validation is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_ray_tracing_validation 1 +#define VK_NV_RAY_TRACING_VALIDATION_SPEC_VERSION 1 +#define VK_NV_RAY_TRACING_VALIDATION_EXTENSION_NAME "VK_NV_ray_tracing_validation" +typedef struct VkPhysicalDeviceRayTracingValidationFeaturesNV { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingValidation; +} VkPhysicalDeviceRayTracingValidationFeaturesNV; + + + +// VK_KHR_acceleration_structure is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_acceleration_structure 1 +#define VK_KHR_ACCELERATION_STRUCTURE_SPEC_VERSION 13 +#define VK_KHR_ACCELERATION_STRUCTURE_EXTENSION_NAME "VK_KHR_acceleration_structure" + +typedef enum VkBuildAccelerationStructureModeKHR { + VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR = 0, + VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR = 1, + VK_BUILD_ACCELERATION_STRUCTURE_MODE_MAX_ENUM_KHR = 0x7FFFFFFF +} VkBuildAccelerationStructureModeKHR; + +typedef enum VkAccelerationStructureCreateFlagBitsKHR { + VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR = 0x00000001, + VK_ACCELERATION_STRUCTURE_CREATE_DESCRIPTOR_BUFFER_CAPTURE_REPLAY_BIT_EXT = 0x00000008, + VK_ACCELERATION_STRUCTURE_CREATE_MOTION_BIT_NV = 0x00000004, + VK_ACCELERATION_STRUCTURE_CREATE_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF +} VkAccelerationStructureCreateFlagBitsKHR; +typedef VkFlags VkAccelerationStructureCreateFlagsKHR; +typedef struct VkAccelerationStructureBuildRangeInfoKHR { + uint32_t primitiveCount; + uint32_t primitiveOffset; + uint32_t firstVertex; + uint32_t transformOffset; +} VkAccelerationStructureBuildRangeInfoKHR; + +typedef struct VkAccelerationStructureGeometryTrianglesDataKHR { + VkStructureType sType; + const void* pNext; + VkFormat vertexFormat; + VkDeviceOrHostAddressConstKHR vertexData; + VkDeviceSize vertexStride; + uint32_t maxVertex; + VkIndexType indexType; + VkDeviceOrHostAddressConstKHR indexData; + VkDeviceOrHostAddressConstKHR transformData; +} VkAccelerationStructureGeometryTrianglesDataKHR; + +typedef struct VkAccelerationStructureGeometryAabbsDataKHR { + VkStructureType sType; + const void* pNext; + VkDeviceOrHostAddressConstKHR data; + VkDeviceSize stride; +} VkAccelerationStructureGeometryAabbsDataKHR; + +typedef struct VkAccelerationStructureGeometryInstancesDataKHR { + VkStructureType sType; + const void* pNext; + VkBool32 arrayOfPointers; + VkDeviceOrHostAddressConstKHR data; +} VkAccelerationStructureGeometryInstancesDataKHR; + +typedef union VkAccelerationStructureGeometryDataKHR { + VkAccelerationStructureGeometryTrianglesDataKHR triangles; + VkAccelerationStructureGeometryAabbsDataKHR aabbs; + VkAccelerationStructureGeometryInstancesDataKHR instances; +} VkAccelerationStructureGeometryDataKHR; + +typedef struct VkAccelerationStructureGeometryKHR { + VkStructureType sType; + const void* pNext; + VkGeometryTypeKHR geometryType; + VkAccelerationStructureGeometryDataKHR geometry; + VkGeometryFlagsKHR flags; +} VkAccelerationStructureGeometryKHR; + +typedef struct VkAccelerationStructureBuildGeometryInfoKHR { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureTypeKHR type; + VkBuildAccelerationStructureFlagsKHR flags; + VkBuildAccelerationStructureModeKHR mode; + VkAccelerationStructureKHR srcAccelerationStructure; + VkAccelerationStructureKHR dstAccelerationStructure; + uint32_t geometryCount; + const VkAccelerationStructureGeometryKHR* pGeometries; + const VkAccelerationStructureGeometryKHR* const* ppGeometries; + VkDeviceOrHostAddressKHR scratchData; +} VkAccelerationStructureBuildGeometryInfoKHR; + +typedef struct VkAccelerationStructureCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureCreateFlagsKHR createFlags; + VkBuffer buffer; + VkDeviceSize offset; + VkDeviceSize size; + VkAccelerationStructureTypeKHR type; + VkDeviceAddress deviceAddress; +} VkAccelerationStructureCreateInfoKHR; + +typedef struct VkWriteDescriptorSetAccelerationStructureKHR { + VkStructureType sType; + const void* pNext; + uint32_t accelerationStructureCount; + const VkAccelerationStructureKHR* pAccelerationStructures; +} VkWriteDescriptorSetAccelerationStructureKHR; + +typedef struct VkPhysicalDeviceAccelerationStructureFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 accelerationStructure; + VkBool32 accelerationStructureCaptureReplay; + VkBool32 accelerationStructureIndirectBuild; + VkBool32 accelerationStructureHostCommands; + VkBool32 descriptorBindingAccelerationStructureUpdateAfterBind; +} VkPhysicalDeviceAccelerationStructureFeaturesKHR; + +typedef struct VkPhysicalDeviceAccelerationStructurePropertiesKHR { + VkStructureType sType; + void* pNext; + uint64_t maxGeometryCount; + uint64_t maxInstanceCount; + uint64_t maxPrimitiveCount; + uint32_t maxPerStageDescriptorAccelerationStructures; + uint32_t maxPerStageDescriptorUpdateAfterBindAccelerationStructures; + uint32_t maxDescriptorSetAccelerationStructures; + uint32_t maxDescriptorSetUpdateAfterBindAccelerationStructures; + uint32_t minAccelerationStructureScratchOffsetAlignment; +} VkPhysicalDeviceAccelerationStructurePropertiesKHR; + +typedef struct VkAccelerationStructureDeviceAddressInfoKHR { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureKHR accelerationStructure; +} VkAccelerationStructureDeviceAddressInfoKHR; + +typedef struct VkAccelerationStructureVersionInfoKHR { + VkStructureType sType; + const void* pNext; + const uint8_t* pVersionData; +} VkAccelerationStructureVersionInfoKHR; + +typedef struct VkCopyAccelerationStructureToMemoryInfoKHR { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureKHR src; + VkDeviceOrHostAddressKHR dst; + VkCopyAccelerationStructureModeKHR mode; +} VkCopyAccelerationStructureToMemoryInfoKHR; + +typedef struct VkCopyMemoryToAccelerationStructureInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceOrHostAddressConstKHR src; + VkAccelerationStructureKHR dst; + VkCopyAccelerationStructureModeKHR mode; +} VkCopyMemoryToAccelerationStructureInfoKHR; + +typedef struct VkCopyAccelerationStructureInfoKHR { + VkStructureType sType; + const void* pNext; + VkAccelerationStructureKHR src; + VkAccelerationStructureKHR dst; + VkCopyAccelerationStructureModeKHR mode; +} VkCopyAccelerationStructureInfoKHR; + +typedef struct VkAccelerationStructureBuildSizesInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceSize accelerationStructureSize; + VkDeviceSize updateScratchSize; + VkDeviceSize buildScratchSize; +} VkAccelerationStructureBuildSizesInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateAccelerationStructureKHR)(VkDevice device, const VkAccelerationStructureCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkAccelerationStructureKHR* pAccelerationStructure); +typedef void (VKAPI_PTR *PFN_vkDestroyAccelerationStructureKHR)(VkDevice device, VkAccelerationStructureKHR accelerationStructure, const VkAllocationCallbacks* pAllocator); +typedef void (VKAPI_PTR *PFN_vkCmdBuildAccelerationStructuresKHR)(VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos); +typedef void (VKAPI_PTR *PFN_vkCmdBuildAccelerationStructuresIndirectKHR)(VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkDeviceAddress* pIndirectDeviceAddresses, const uint32_t* pIndirectStrides, const uint32_t* const* ppMaxPrimitiveCounts); +typedef VkResult (VKAPI_PTR *PFN_vkBuildAccelerationStructuresKHR)(VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos); +typedef VkResult (VKAPI_PTR *PFN_vkCopyAccelerationStructureKHR)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyAccelerationStructureToMemoryKHR)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkCopyMemoryToAccelerationStructureKHR)(VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo); +typedef VkResult (VKAPI_PTR *PFN_vkWriteAccelerationStructuresPropertiesKHR)(VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR* pAccelerationStructures, VkQueryType queryType, size_t dataSize, void* pData, size_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdCopyAccelerationStructureKHR)(VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyAccelerationStructureToMemoryKHR)(VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdCopyMemoryToAccelerationStructureKHR)(VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo); +typedef VkDeviceAddress (VKAPI_PTR *PFN_vkGetAccelerationStructureDeviceAddressKHR)(VkDevice device, const VkAccelerationStructureDeviceAddressInfoKHR* pInfo); +typedef void (VKAPI_PTR *PFN_vkCmdWriteAccelerationStructuresPropertiesKHR)(VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR* pAccelerationStructures, VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery); +typedef void (VKAPI_PTR *PFN_vkGetDeviceAccelerationStructureCompatibilityKHR)(VkDevice device, const VkAccelerationStructureVersionInfoKHR* pVersionInfo, VkAccelerationStructureCompatibilityKHR* pCompatibility); +typedef void (VKAPI_PTR *PFN_vkGetAccelerationStructureBuildSizesKHR)(VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR* pBuildInfo, const uint32_t* pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR* pSizeInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateAccelerationStructureKHR( + VkDevice device, + const VkAccelerationStructureCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkAccelerationStructureKHR* pAccelerationStructure); + +VKAPI_ATTR void VKAPI_CALL vkDestroyAccelerationStructureKHR( + VkDevice device, + VkAccelerationStructureKHR accelerationStructure, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructuresKHR( + VkCommandBuffer commandBuffer, + uint32_t infoCount, + const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, + const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos); + +VKAPI_ATTR void VKAPI_CALL vkCmdBuildAccelerationStructuresIndirectKHR( + VkCommandBuffer commandBuffer, + uint32_t infoCount, + const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, + const VkDeviceAddress* pIndirectDeviceAddresses, + const uint32_t* pIndirectStrides, + const uint32_t* const* ppMaxPrimitiveCounts); + +VKAPI_ATTR VkResult VKAPI_CALL vkBuildAccelerationStructuresKHR( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + uint32_t infoCount, + const VkAccelerationStructureBuildGeometryInfoKHR* pInfos, + const VkAccelerationStructureBuildRangeInfoKHR* const* ppBuildRangeInfos); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureKHR( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyAccelerationStructureInfoKHR* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyAccelerationStructureToMemoryKHR( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkCopyMemoryToAccelerationStructureKHR( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkWriteAccelerationStructuresPropertiesKHR( + VkDevice device, + uint32_t accelerationStructureCount, + const VkAccelerationStructureKHR* pAccelerationStructures, + VkQueryType queryType, + size_t dataSize, + void* pData, + size_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureKHR( + VkCommandBuffer commandBuffer, + const VkCopyAccelerationStructureInfoKHR* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyAccelerationStructureToMemoryKHR( + VkCommandBuffer commandBuffer, + const VkCopyAccelerationStructureToMemoryInfoKHR* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdCopyMemoryToAccelerationStructureKHR( + VkCommandBuffer commandBuffer, + const VkCopyMemoryToAccelerationStructureInfoKHR* pInfo); + +VKAPI_ATTR VkDeviceAddress VKAPI_CALL vkGetAccelerationStructureDeviceAddressKHR( + VkDevice device, + const VkAccelerationStructureDeviceAddressInfoKHR* pInfo); + +VKAPI_ATTR void VKAPI_CALL vkCmdWriteAccelerationStructuresPropertiesKHR( + VkCommandBuffer commandBuffer, + uint32_t accelerationStructureCount, + const VkAccelerationStructureKHR* pAccelerationStructures, + VkQueryType queryType, + VkQueryPool queryPool, + uint32_t firstQuery); + +VKAPI_ATTR void VKAPI_CALL vkGetDeviceAccelerationStructureCompatibilityKHR( + VkDevice device, + const VkAccelerationStructureVersionInfoKHR* pVersionInfo, + VkAccelerationStructureCompatibilityKHR* pCompatibility); + +VKAPI_ATTR void VKAPI_CALL vkGetAccelerationStructureBuildSizesKHR( + VkDevice device, + VkAccelerationStructureBuildTypeKHR buildType, + const VkAccelerationStructureBuildGeometryInfoKHR* pBuildInfo, + const uint32_t* pMaxPrimitiveCounts, + VkAccelerationStructureBuildSizesInfoKHR* pSizeInfo); +#endif + + +// VK_KHR_ray_tracing_pipeline is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_ray_tracing_pipeline 1 +#define VK_KHR_RAY_TRACING_PIPELINE_SPEC_VERSION 1 +#define VK_KHR_RAY_TRACING_PIPELINE_EXTENSION_NAME "VK_KHR_ray_tracing_pipeline" + +typedef enum VkShaderGroupShaderKHR { + VK_SHADER_GROUP_SHADER_GENERAL_KHR = 0, + VK_SHADER_GROUP_SHADER_CLOSEST_HIT_KHR = 1, + VK_SHADER_GROUP_SHADER_ANY_HIT_KHR = 2, + VK_SHADER_GROUP_SHADER_INTERSECTION_KHR = 3, + VK_SHADER_GROUP_SHADER_MAX_ENUM_KHR = 0x7FFFFFFF +} VkShaderGroupShaderKHR; +typedef struct VkRayTracingShaderGroupCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkRayTracingShaderGroupTypeKHR type; + uint32_t generalShader; + uint32_t closestHitShader; + uint32_t anyHitShader; + uint32_t intersectionShader; + const void* pShaderGroupCaptureReplayHandle; +} VkRayTracingShaderGroupCreateInfoKHR; + +typedef struct VkRayTracingPipelineInterfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t maxPipelineRayPayloadSize; + uint32_t maxPipelineRayHitAttributeSize; +} VkRayTracingPipelineInterfaceCreateInfoKHR; + +typedef struct VkRayTracingPipelineCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkPipelineCreateFlags flags; + uint32_t stageCount; + const VkPipelineShaderStageCreateInfo* pStages; + uint32_t groupCount; + const VkRayTracingShaderGroupCreateInfoKHR* pGroups; + uint32_t maxPipelineRayRecursionDepth; + const VkPipelineLibraryCreateInfoKHR* pLibraryInfo; + const VkRayTracingPipelineInterfaceCreateInfoKHR* pLibraryInterface; + const VkPipelineDynamicStateCreateInfo* pDynamicState; + VkPipelineLayout layout; + VkPipeline basePipelineHandle; + int32_t basePipelineIndex; +} VkRayTracingPipelineCreateInfoKHR; + +typedef struct VkPhysicalDeviceRayTracingPipelineFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rayTracingPipeline; + VkBool32 rayTracingPipelineShaderGroupHandleCaptureReplay; + VkBool32 rayTracingPipelineShaderGroupHandleCaptureReplayMixed; + VkBool32 rayTracingPipelineTraceRaysIndirect; + VkBool32 rayTraversalPrimitiveCulling; +} VkPhysicalDeviceRayTracingPipelineFeaturesKHR; + +typedef struct VkPhysicalDeviceRayTracingPipelinePropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t shaderGroupHandleSize; + uint32_t maxRayRecursionDepth; + uint32_t maxShaderGroupStride; + uint32_t shaderGroupBaseAlignment; + uint32_t shaderGroupHandleCaptureReplaySize; + uint32_t maxRayDispatchInvocationCount; + uint32_t shaderGroupHandleAlignment; + uint32_t maxRayHitAttributeSize; +} VkPhysicalDeviceRayTracingPipelinePropertiesKHR; + +typedef struct VkStridedDeviceAddressRegionKHR { + VkDeviceAddress deviceAddress; + VkDeviceSize stride; + VkDeviceSize size; +} VkStridedDeviceAddressRegionKHR; + +typedef struct VkTraceRaysIndirectCommandKHR { + uint32_t width; + uint32_t height; + uint32_t depth; +} VkTraceRaysIndirectCommandKHR; + +typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysKHR)(VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, uint32_t width, uint32_t height, uint32_t depth); +typedef VkResult (VKAPI_PTR *PFN_vkCreateRayTracingPipelinesKHR)(VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkRayTracingPipelineCreateInfoKHR* pCreateInfos, const VkAllocationCallbacks* pAllocator, VkPipeline* pPipelines); +typedef VkResult (VKAPI_PTR *PFN_vkGetRayTracingCaptureReplayShaderGroupHandlesKHR)(VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void* pData); +typedef void (VKAPI_PTR *PFN_vkCmdTraceRaysIndirectKHR)(VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress); +typedef VkDeviceSize (VKAPI_PTR *PFN_vkGetRayTracingShaderGroupStackSizeKHR)(VkDevice device, VkPipeline pipeline, uint32_t group, VkShaderGroupShaderKHR groupShader); +typedef void (VKAPI_PTR *PFN_vkCmdSetRayTracingPipelineStackSizeKHR)(VkCommandBuffer commandBuffer, uint32_t pipelineStackSize); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysKHR( + VkCommandBuffer commandBuffer, + const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, + const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, + const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, + const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, + uint32_t width, + uint32_t height, + uint32_t depth); + +VKAPI_ATTR VkResult VKAPI_CALL vkCreateRayTracingPipelinesKHR( + VkDevice device, + VkDeferredOperationKHR deferredOperation, + VkPipelineCache pipelineCache, + uint32_t createInfoCount, + const VkRayTracingPipelineCreateInfoKHR* pCreateInfos, + const VkAllocationCallbacks* pAllocator, + VkPipeline* pPipelines); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetRayTracingCaptureReplayShaderGroupHandlesKHR( + VkDevice device, + VkPipeline pipeline, + uint32_t firstGroup, + uint32_t groupCount, + size_t dataSize, + void* pData); + +VKAPI_ATTR void VKAPI_CALL vkCmdTraceRaysIndirectKHR( + VkCommandBuffer commandBuffer, + const VkStridedDeviceAddressRegionKHR* pRaygenShaderBindingTable, + const VkStridedDeviceAddressRegionKHR* pMissShaderBindingTable, + const VkStridedDeviceAddressRegionKHR* pHitShaderBindingTable, + const VkStridedDeviceAddressRegionKHR* pCallableShaderBindingTable, + VkDeviceAddress indirectDeviceAddress); + +VKAPI_ATTR VkDeviceSize VKAPI_CALL vkGetRayTracingShaderGroupStackSizeKHR( + VkDevice device, + VkPipeline pipeline, + uint32_t group, + VkShaderGroupShaderKHR groupShader); + +VKAPI_ATTR void VKAPI_CALL vkCmdSetRayTracingPipelineStackSizeKHR( + VkCommandBuffer commandBuffer, + uint32_t pipelineStackSize); +#endif + + +// VK_KHR_ray_query is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_ray_query 1 +#define VK_KHR_RAY_QUERY_SPEC_VERSION 1 +#define VK_KHR_RAY_QUERY_EXTENSION_NAME "VK_KHR_ray_query" +typedef struct VkPhysicalDeviceRayQueryFeaturesKHR { + VkStructureType sType; + void* pNext; + VkBool32 rayQuery; +} VkPhysicalDeviceRayQueryFeaturesKHR; + + + +// VK_EXT_mesh_shader is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_mesh_shader 1 +#define VK_EXT_MESH_SHADER_SPEC_VERSION 1 +#define VK_EXT_MESH_SHADER_EXTENSION_NAME "VK_EXT_mesh_shader" +typedef struct VkPhysicalDeviceMeshShaderFeaturesEXT { + VkStructureType sType; + void* pNext; + VkBool32 taskShader; + VkBool32 meshShader; + VkBool32 multiviewMeshShader; + VkBool32 primitiveFragmentShadingRateMeshShader; + VkBool32 meshShaderQueries; +} VkPhysicalDeviceMeshShaderFeaturesEXT; + +typedef struct VkPhysicalDeviceMeshShaderPropertiesEXT { + VkStructureType sType; + void* pNext; + uint32_t maxTaskWorkGroupTotalCount; + uint32_t maxTaskWorkGroupCount[3]; + uint32_t maxTaskWorkGroupInvocations; + uint32_t maxTaskWorkGroupSize[3]; + uint32_t maxTaskPayloadSize; + uint32_t maxTaskSharedMemorySize; + uint32_t maxTaskPayloadAndSharedMemorySize; + uint32_t maxMeshWorkGroupTotalCount; + uint32_t maxMeshWorkGroupCount[3]; + uint32_t maxMeshWorkGroupInvocations; + uint32_t maxMeshWorkGroupSize[3]; + uint32_t maxMeshSharedMemorySize; + uint32_t maxMeshPayloadAndSharedMemorySize; + uint32_t maxMeshOutputMemorySize; + uint32_t maxMeshPayloadAndOutputMemorySize; + uint32_t maxMeshOutputComponents; + uint32_t maxMeshOutputVertices; + uint32_t maxMeshOutputPrimitives; + uint32_t maxMeshOutputLayers; + uint32_t maxMeshMultiviewViewCount; + uint32_t meshOutputPerVertexGranularity; + uint32_t meshOutputPerPrimitiveGranularity; + uint32_t maxPreferredTaskWorkGroupInvocations; + uint32_t maxPreferredMeshWorkGroupInvocations; + VkBool32 prefersLocalInvocationVertexOutput; + VkBool32 prefersLocalInvocationPrimitiveOutput; + VkBool32 prefersCompactVertexOutput; + VkBool32 prefersCompactPrimitiveOutput; +} VkPhysicalDeviceMeshShaderPropertiesEXT; + +typedef struct VkDrawMeshTasksIndirectCommandEXT { + uint32_t groupCountX; + uint32_t groupCountY; + uint32_t groupCountZ; +} VkDrawMeshTasksIndirectCommandEXT; + +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksEXT)(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectEXT)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, uint32_t drawCount, uint32_t stride); +typedef void (VKAPI_PTR *PFN_vkCmdDrawMeshTasksIndirectCountEXT)(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkBuffer countBuffer, VkDeviceSize countBufferOffset, uint32_t maxDrawCount, uint32_t stride); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksEXT( + VkCommandBuffer commandBuffer, + uint32_t groupCountX, + uint32_t groupCountY, + uint32_t groupCountZ); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectEXT( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + uint32_t drawCount, + uint32_t stride); + +VKAPI_ATTR void VKAPI_CALL vkCmdDrawMeshTasksIndirectCountEXT( + VkCommandBuffer commandBuffer, + VkBuffer buffer, + VkDeviceSize offset, + VkBuffer countBuffer, + VkDeviceSize countBufferOffset, + uint32_t maxDrawCount, + uint32_t stride); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_directfb.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_directfb.h new file mode 100644 index 0000000..f06f80b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_directfb.h @@ -0,0 +1,55 @@ +#ifndef VULKAN_DIRECTFB_H_ +#define VULKAN_DIRECTFB_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_EXT_directfb_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_directfb_surface 1 +#define VK_EXT_DIRECTFB_SURFACE_SPEC_VERSION 1 +#define VK_EXT_DIRECTFB_SURFACE_EXTENSION_NAME "VK_EXT_directfb_surface" +typedef VkFlags VkDirectFBSurfaceCreateFlagsEXT; +typedef struct VkDirectFBSurfaceCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkDirectFBSurfaceCreateFlagsEXT flags; + IDirectFB* dfb; + IDirectFBSurface* surface; +} VkDirectFBSurfaceCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateDirectFBSurfaceEXT)(VkInstance instance, const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceDirectFBPresentationSupportEXT)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, IDirectFB* dfb); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateDirectFBSurfaceEXT( + VkInstance instance, + const VkDirectFBSurfaceCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceDirectFBPresentationSupportEXT( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + IDirectFB* dfb); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_fuchsia.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_fuchsia.h new file mode 100644 index 0000000..f60907d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_fuchsia.h @@ -0,0 +1,262 @@ +#ifndef VULKAN_FUCHSIA_H_ +#define VULKAN_FUCHSIA_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_FUCHSIA_imagepipe_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_FUCHSIA_imagepipe_surface 1 +#define VK_FUCHSIA_IMAGEPIPE_SURFACE_SPEC_VERSION 1 +#define VK_FUCHSIA_IMAGEPIPE_SURFACE_EXTENSION_NAME "VK_FUCHSIA_imagepipe_surface" +typedef VkFlags VkImagePipeSurfaceCreateFlagsFUCHSIA; +typedef struct VkImagePipeSurfaceCreateInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkImagePipeSurfaceCreateFlagsFUCHSIA flags; + zx_handle_t imagePipeHandle; +} VkImagePipeSurfaceCreateInfoFUCHSIA; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateImagePipeSurfaceFUCHSIA)(VkInstance instance, const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateImagePipeSurfaceFUCHSIA( + VkInstance instance, + const VkImagePipeSurfaceCreateInfoFUCHSIA* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +// VK_FUCHSIA_external_memory is a preprocessor guard. Do not pass it to API calls. +#define VK_FUCHSIA_external_memory 1 +#define VK_FUCHSIA_EXTERNAL_MEMORY_SPEC_VERSION 1 +#define VK_FUCHSIA_EXTERNAL_MEMORY_EXTENSION_NAME "VK_FUCHSIA_external_memory" +typedef struct VkImportMemoryZirconHandleInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; + zx_handle_t handle; +} VkImportMemoryZirconHandleInfoFUCHSIA; + +typedef struct VkMemoryZirconHandlePropertiesFUCHSIA { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; +} VkMemoryZirconHandlePropertiesFUCHSIA; + +typedef struct VkMemoryGetZirconHandleInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkMemoryGetZirconHandleInfoFUCHSIA; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandleFUCHSIA)(VkDevice device, const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle); +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryZirconHandlePropertiesFUCHSIA)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, zx_handle_t zirconHandle, VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandleFUCHSIA( + VkDevice device, + const VkMemoryGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, + zx_handle_t* pZirconHandle); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryZirconHandlePropertiesFUCHSIA( + VkDevice device, + VkExternalMemoryHandleTypeFlagBits handleType, + zx_handle_t zirconHandle, + VkMemoryZirconHandlePropertiesFUCHSIA* pMemoryZirconHandleProperties); +#endif + + +// VK_FUCHSIA_external_semaphore is a preprocessor guard. Do not pass it to API calls. +#define VK_FUCHSIA_external_semaphore 1 +#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_SPEC_VERSION 1 +#define VK_FUCHSIA_EXTERNAL_SEMAPHORE_EXTENSION_NAME "VK_FUCHSIA_external_semaphore" +typedef struct VkImportSemaphoreZirconHandleInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkSemaphoreImportFlags flags; + VkExternalSemaphoreHandleTypeFlagBits handleType; + zx_handle_t zirconHandle; +} VkImportSemaphoreZirconHandleInfoFUCHSIA; + +typedef struct VkSemaphoreGetZirconHandleInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkExternalSemaphoreHandleTypeFlagBits handleType; +} VkSemaphoreGetZirconHandleInfoFUCHSIA; + +typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreZirconHandleFUCHSIA)(VkDevice device, const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, zx_handle_t* pZirconHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreZirconHandleFUCHSIA( + VkDevice device, + const VkImportSemaphoreZirconHandleInfoFUCHSIA* pImportSemaphoreZirconHandleInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreZirconHandleFUCHSIA( + VkDevice device, + const VkSemaphoreGetZirconHandleInfoFUCHSIA* pGetZirconHandleInfo, + zx_handle_t* pZirconHandle); +#endif + + +// VK_FUCHSIA_buffer_collection is a preprocessor guard. Do not pass it to API calls. +#define VK_FUCHSIA_buffer_collection 1 +VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkBufferCollectionFUCHSIA) +#define VK_FUCHSIA_BUFFER_COLLECTION_SPEC_VERSION 2 +#define VK_FUCHSIA_BUFFER_COLLECTION_EXTENSION_NAME "VK_FUCHSIA_buffer_collection" +typedef VkFlags VkImageFormatConstraintsFlagsFUCHSIA; + +typedef enum VkImageConstraintsInfoFlagBitsFUCHSIA { + VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_RARELY_FUCHSIA = 0x00000001, + VK_IMAGE_CONSTRAINTS_INFO_CPU_READ_OFTEN_FUCHSIA = 0x00000002, + VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_RARELY_FUCHSIA = 0x00000004, + VK_IMAGE_CONSTRAINTS_INFO_CPU_WRITE_OFTEN_FUCHSIA = 0x00000008, + VK_IMAGE_CONSTRAINTS_INFO_PROTECTED_OPTIONAL_FUCHSIA = 0x00000010, + VK_IMAGE_CONSTRAINTS_INFO_FLAG_BITS_MAX_ENUM_FUCHSIA = 0x7FFFFFFF +} VkImageConstraintsInfoFlagBitsFUCHSIA; +typedef VkFlags VkImageConstraintsInfoFlagsFUCHSIA; +typedef struct VkBufferCollectionCreateInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + zx_handle_t collectionToken; +} VkBufferCollectionCreateInfoFUCHSIA; + +typedef struct VkImportMemoryBufferCollectionFUCHSIA { + VkStructureType sType; + const void* pNext; + VkBufferCollectionFUCHSIA collection; + uint32_t index; +} VkImportMemoryBufferCollectionFUCHSIA; + +typedef struct VkBufferCollectionImageCreateInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkBufferCollectionFUCHSIA collection; + uint32_t index; +} VkBufferCollectionImageCreateInfoFUCHSIA; + +typedef struct VkBufferCollectionConstraintsInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + uint32_t minBufferCount; + uint32_t maxBufferCount; + uint32_t minBufferCountForCamping; + uint32_t minBufferCountForDedicatedSlack; + uint32_t minBufferCountForSharedSlack; +} VkBufferCollectionConstraintsInfoFUCHSIA; + +typedef struct VkBufferConstraintsInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkBufferCreateInfo createInfo; + VkFormatFeatureFlags requiredFormatFeatures; + VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints; +} VkBufferConstraintsInfoFUCHSIA; + +typedef struct VkBufferCollectionBufferCreateInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkBufferCollectionFUCHSIA collection; + uint32_t index; +} VkBufferCollectionBufferCreateInfoFUCHSIA; + +typedef struct VkSysmemColorSpaceFUCHSIA { + VkStructureType sType; + const void* pNext; + uint32_t colorSpace; +} VkSysmemColorSpaceFUCHSIA; + +typedef struct VkBufferCollectionPropertiesFUCHSIA { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; + uint32_t bufferCount; + uint32_t createInfoIndex; + uint64_t sysmemPixelFormat; + VkFormatFeatureFlags formatFeatures; + VkSysmemColorSpaceFUCHSIA sysmemColorSpaceIndex; + VkComponentMapping samplerYcbcrConversionComponents; + VkSamplerYcbcrModelConversion suggestedYcbcrModel; + VkSamplerYcbcrRange suggestedYcbcrRange; + VkChromaLocation suggestedXChromaOffset; + VkChromaLocation suggestedYChromaOffset; +} VkBufferCollectionPropertiesFUCHSIA; + +typedef struct VkImageFormatConstraintsInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + VkImageCreateInfo imageCreateInfo; + VkFormatFeatureFlags requiredFormatFeatures; + VkImageFormatConstraintsFlagsFUCHSIA flags; + uint64_t sysmemPixelFormat; + uint32_t colorSpaceCount; + const VkSysmemColorSpaceFUCHSIA* pColorSpaces; +} VkImageFormatConstraintsInfoFUCHSIA; + +typedef struct VkImageConstraintsInfoFUCHSIA { + VkStructureType sType; + const void* pNext; + uint32_t formatConstraintsCount; + const VkImageFormatConstraintsInfoFUCHSIA* pFormatConstraints; + VkBufferCollectionConstraintsInfoFUCHSIA bufferCollectionConstraints; + VkImageConstraintsInfoFlagsFUCHSIA flags; +} VkImageConstraintsInfoFUCHSIA; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateBufferCollectionFUCHSIA)(VkDevice device, const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkBufferCollectionFUCHSIA* pCollection); +typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionImageConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo); +typedef VkResult (VKAPI_PTR *PFN_vkSetBufferCollectionBufferConstraintsFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo); +typedef void (VKAPI_PTR *PFN_vkDestroyBufferCollectionFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, const VkAllocationCallbacks* pAllocator); +typedef VkResult (VKAPI_PTR *PFN_vkGetBufferCollectionPropertiesFUCHSIA)(VkDevice device, VkBufferCollectionFUCHSIA collection, VkBufferCollectionPropertiesFUCHSIA* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateBufferCollectionFUCHSIA( + VkDevice device, + const VkBufferCollectionCreateInfoFUCHSIA* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkBufferCollectionFUCHSIA* pCollection); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionImageConstraintsFUCHSIA( + VkDevice device, + VkBufferCollectionFUCHSIA collection, + const VkImageConstraintsInfoFUCHSIA* pImageConstraintsInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkSetBufferCollectionBufferConstraintsFUCHSIA( + VkDevice device, + VkBufferCollectionFUCHSIA collection, + const VkBufferConstraintsInfoFUCHSIA* pBufferConstraintsInfo); + +VKAPI_ATTR void VKAPI_CALL vkDestroyBufferCollectionFUCHSIA( + VkDevice device, + VkBufferCollectionFUCHSIA collection, + const VkAllocationCallbacks* pAllocator); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetBufferCollectionPropertiesFUCHSIA( + VkDevice device, + VkBufferCollectionFUCHSIA collection, + VkBufferCollectionPropertiesFUCHSIA* pProperties); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ggp.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ggp.h new file mode 100644 index 0000000..0a8863a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ggp.h @@ -0,0 +1,60 @@ +#ifndef VULKAN_GGP_H_ +#define VULKAN_GGP_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_GGP_stream_descriptor_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_GGP_stream_descriptor_surface 1 +#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_SPEC_VERSION 1 +#define VK_GGP_STREAM_DESCRIPTOR_SURFACE_EXTENSION_NAME "VK_GGP_stream_descriptor_surface" +typedef VkFlags VkStreamDescriptorSurfaceCreateFlagsGGP; +typedef struct VkStreamDescriptorSurfaceCreateInfoGGP { + VkStructureType sType; + const void* pNext; + VkStreamDescriptorSurfaceCreateFlagsGGP flags; + GgpStreamDescriptor streamDescriptor; +} VkStreamDescriptorSurfaceCreateInfoGGP; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateStreamDescriptorSurfaceGGP)(VkInstance instance, const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateStreamDescriptorSurfaceGGP( + VkInstance instance, + const VkStreamDescriptorSurfaceCreateInfoGGP* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +// VK_GGP_frame_token is a preprocessor guard. Do not pass it to API calls. +#define VK_GGP_frame_token 1 +#define VK_GGP_FRAME_TOKEN_SPEC_VERSION 1 +#define VK_GGP_FRAME_TOKEN_EXTENSION_NAME "VK_GGP_frame_token" +typedef struct VkPresentFrameTokenGGP { + VkStructureType sType; + const void* pNext; + GgpFrameToken frameToken; +} VkPresentFrameTokenGGP; + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ios.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ios.h new file mode 100644 index 0000000..22ed2c0 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_ios.h @@ -0,0 +1,48 @@ +#ifndef VULKAN_IOS_H_ +#define VULKAN_IOS_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_MVK_ios_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_MVK_ios_surface 1 +#define VK_MVK_IOS_SURFACE_SPEC_VERSION 3 +#define VK_MVK_IOS_SURFACE_EXTENSION_NAME "VK_MVK_ios_surface" +typedef VkFlags VkIOSSurfaceCreateFlagsMVK; +typedef struct VkIOSSurfaceCreateInfoMVK { + VkStructureType sType; + const void* pNext; + VkIOSSurfaceCreateFlagsMVK flags; + const void* pView; +} VkIOSSurfaceCreateInfoMVK; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateIOSSurfaceMVK)(VkInstance instance, const VkIOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateIOSSurfaceMVK( + VkInstance instance, + const VkIOSSurfaceCreateInfoMVK* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_macos.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_macos.h new file mode 100644 index 0000000..a7f5613 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_macos.h @@ -0,0 +1,48 @@ +#ifndef VULKAN_MACOS_H_ +#define VULKAN_MACOS_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_MVK_macos_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_MVK_macos_surface 1 +#define VK_MVK_MACOS_SURFACE_SPEC_VERSION 3 +#define VK_MVK_MACOS_SURFACE_EXTENSION_NAME "VK_MVK_macos_surface" +typedef VkFlags VkMacOSSurfaceCreateFlagsMVK; +typedef struct VkMacOSSurfaceCreateInfoMVK { + VkStructureType sType; + const void* pNext; + VkMacOSSurfaceCreateFlagsMVK flags; + const void* pView; +} VkMacOSSurfaceCreateInfoMVK; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMacOSSurfaceMVK)(VkInstance instance, const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMacOSSurfaceMVK( + VkInstance instance, + const VkMacOSSurfaceCreateInfoMVK* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_metal.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_metal.h new file mode 100644 index 0000000..4cb9c69 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_metal.h @@ -0,0 +1,206 @@ +#ifndef VULKAN_METAL_H_ +#define VULKAN_METAL_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_EXT_metal_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_metal_surface 1 +#ifdef __OBJC__ +@class CAMetalLayer; +#else +typedef void CAMetalLayer; +#endif + +#define SDL_UNSAFE_UNRETAINED +#if defined(__OBJC__) && defined(__has_feature) +#if __has_feature(objc_arc) +#undef SDL_UNSAFE_UNRETAINED +#define SDL_UNSAFE_UNRETAINED __unsafe_unretained +#endif +#endif + +#define VK_EXT_METAL_SURFACE_SPEC_VERSION 1 +#define VK_EXT_METAL_SURFACE_EXTENSION_NAME "VK_EXT_metal_surface" +typedef VkFlags VkMetalSurfaceCreateFlagsEXT; +typedef struct VkMetalSurfaceCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkMetalSurfaceCreateFlagsEXT flags; + const CAMetalLayer SDL_UNSAFE_UNRETAINED *pLayer; +} VkMetalSurfaceCreateInfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateMetalSurfaceEXT)(VkInstance instance, const VkMetalSurfaceCreateInfoEXT* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateMetalSurfaceEXT( + VkInstance instance, + const VkMetalSurfaceCreateInfoEXT* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + + +// VK_EXT_metal_objects is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_metal_objects 1 +#ifdef __OBJC__ +@protocol MTLDevice; +typedef __unsafe_unretained id MTLDevice_id; +#else +typedef void* MTLDevice_id; +#endif + +#ifdef __OBJC__ +@protocol MTLCommandQueue; +typedef __unsafe_unretained id MTLCommandQueue_id; +#else +typedef void* MTLCommandQueue_id; +#endif + +#ifdef __OBJC__ +@protocol MTLBuffer; +typedef __unsafe_unretained id MTLBuffer_id; +#else +typedef void* MTLBuffer_id; +#endif + +#ifdef __OBJC__ +@protocol MTLTexture; +typedef __unsafe_unretained id MTLTexture_id; +#else +typedef void* MTLTexture_id; +#endif + +typedef struct __IOSurface* IOSurfaceRef; +#ifdef __OBJC__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunguarded-availability" +@protocol MTLSharedEvent; +typedef __unsafe_unretained id MTLSharedEvent_id; +#pragma clang diagnostic pop +#else +typedef void* MTLSharedEvent_id; +#endif + +#define VK_EXT_METAL_OBJECTS_SPEC_VERSION 2 +#define VK_EXT_METAL_OBJECTS_EXTENSION_NAME "VK_EXT_metal_objects" + +typedef enum VkExportMetalObjectTypeFlagBitsEXT { + VK_EXPORT_METAL_OBJECT_TYPE_METAL_DEVICE_BIT_EXT = 0x00000001, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_COMMAND_QUEUE_BIT_EXT = 0x00000002, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_BUFFER_BIT_EXT = 0x00000004, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_TEXTURE_BIT_EXT = 0x00000008, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_IOSURFACE_BIT_EXT = 0x00000010, + VK_EXPORT_METAL_OBJECT_TYPE_METAL_SHARED_EVENT_BIT_EXT = 0x00000020, + VK_EXPORT_METAL_OBJECT_TYPE_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF +} VkExportMetalObjectTypeFlagBitsEXT; +typedef VkFlags VkExportMetalObjectTypeFlagsEXT; +typedef struct VkExportMetalObjectCreateInfoEXT { + VkStructureType sType; + const void* pNext; + VkExportMetalObjectTypeFlagBitsEXT exportObjectType; +} VkExportMetalObjectCreateInfoEXT; + +typedef struct VkExportMetalObjectsInfoEXT { + VkStructureType sType; + const void* pNext; +} VkExportMetalObjectsInfoEXT; + +typedef struct VkExportMetalDeviceInfoEXT { + VkStructureType sType; + const void* pNext; + MTLDevice_id mtlDevice; +} VkExportMetalDeviceInfoEXT; + +typedef struct VkExportMetalCommandQueueInfoEXT { + VkStructureType sType; + const void* pNext; + VkQueue queue; + MTLCommandQueue_id mtlCommandQueue; +} VkExportMetalCommandQueueInfoEXT; + +typedef struct VkExportMetalBufferInfoEXT { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + MTLBuffer_id mtlBuffer; +} VkExportMetalBufferInfoEXT; + +typedef struct VkImportMetalBufferInfoEXT { + VkStructureType sType; + const void* pNext; + MTLBuffer_id mtlBuffer; +} VkImportMetalBufferInfoEXT; + +typedef struct VkExportMetalTextureInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; + VkImageView imageView; + VkBufferView bufferView; + VkImageAspectFlagBits plane; + MTLTexture_id mtlTexture; +} VkExportMetalTextureInfoEXT; + +typedef struct VkImportMetalTextureInfoEXT { + VkStructureType sType; + const void* pNext; + VkImageAspectFlagBits plane; + MTLTexture_id mtlTexture; +} VkImportMetalTextureInfoEXT; + +typedef struct VkExportMetalIOSurfaceInfoEXT { + VkStructureType sType; + const void* pNext; + VkImage image; + IOSurfaceRef ioSurface; +} VkExportMetalIOSurfaceInfoEXT; + +typedef struct VkImportMetalIOSurfaceInfoEXT { + VkStructureType sType; + const void* pNext; + IOSurfaceRef ioSurface; +} VkImportMetalIOSurfaceInfoEXT; + +typedef struct VkExportMetalSharedEventInfoEXT { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkEvent event; + MTLSharedEvent_id mtlSharedEvent; +} VkExportMetalSharedEventInfoEXT; + +typedef struct VkImportMetalSharedEventInfoEXT { + VkStructureType sType; + const void* pNext; + MTLSharedEvent_id mtlSharedEvent; +} VkImportMetalSharedEventInfoEXT; + +typedef void (VKAPI_PTR *PFN_vkExportMetalObjectsEXT)(VkDevice device, VkExportMetalObjectsInfoEXT* pMetalObjectsInfo); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR void VKAPI_CALL vkExportMetalObjectsEXT( + VkDevice device, + VkExportMetalObjectsInfoEXT* pMetalObjectsInfo); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_screen.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_screen.h new file mode 100644 index 0000000..7e84d4d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_screen.h @@ -0,0 +1,108 @@ +#ifndef VULKAN_SCREEN_H_ +#define VULKAN_SCREEN_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_QNX_screen_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_QNX_screen_surface 1 +#define VK_QNX_SCREEN_SURFACE_SPEC_VERSION 1 +#define VK_QNX_SCREEN_SURFACE_EXTENSION_NAME "VK_QNX_screen_surface" +typedef VkFlags VkScreenSurfaceCreateFlagsQNX; +typedef struct VkScreenSurfaceCreateInfoQNX { + VkStructureType sType; + const void* pNext; + VkScreenSurfaceCreateFlagsQNX flags; + struct _screen_context* context; + struct _screen_window* window; +} VkScreenSurfaceCreateInfoQNX; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateScreenSurfaceQNX)(VkInstance instance, const VkScreenSurfaceCreateInfoQNX* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceScreenPresentationSupportQNX)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct _screen_window* window); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateScreenSurfaceQNX( + VkInstance instance, + const VkScreenSurfaceCreateInfoQNX* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceScreenPresentationSupportQNX( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + struct _screen_window* window); +#endif + + +// VK_QNX_external_memory_screen_buffer is a preprocessor guard. Do not pass it to API calls. +#define VK_QNX_external_memory_screen_buffer 1 +#define VK_QNX_EXTERNAL_MEMORY_SCREEN_BUFFER_SPEC_VERSION 1 +#define VK_QNX_EXTERNAL_MEMORY_SCREEN_BUFFER_EXTENSION_NAME "VK_QNX_external_memory_screen_buffer" +typedef struct VkScreenBufferPropertiesQNX { + VkStructureType sType; + void* pNext; + VkDeviceSize allocationSize; + uint32_t memoryTypeBits; +} VkScreenBufferPropertiesQNX; + +typedef struct VkScreenBufferFormatPropertiesQNX { + VkStructureType sType; + void* pNext; + VkFormat format; + uint64_t externalFormat; + uint64_t screenUsage; + VkFormatFeatureFlags formatFeatures; + VkComponentMapping samplerYcbcrConversionComponents; + VkSamplerYcbcrModelConversion suggestedYcbcrModel; + VkSamplerYcbcrRange suggestedYcbcrRange; + VkChromaLocation suggestedXChromaOffset; + VkChromaLocation suggestedYChromaOffset; +} VkScreenBufferFormatPropertiesQNX; + +typedef struct VkImportScreenBufferInfoQNX { + VkStructureType sType; + const void* pNext; + struct _screen_buffer* buffer; +} VkImportScreenBufferInfoQNX; + +typedef struct VkExternalFormatQNX { + VkStructureType sType; + void* pNext; + uint64_t externalFormat; +} VkExternalFormatQNX; + +typedef struct VkPhysicalDeviceExternalMemoryScreenBufferFeaturesQNX { + VkStructureType sType; + void* pNext; + VkBool32 screenBufferImport; +} VkPhysicalDeviceExternalMemoryScreenBufferFeaturesQNX; + +typedef VkResult (VKAPI_PTR *PFN_vkGetScreenBufferPropertiesQNX)(VkDevice device, const struct _screen_buffer* buffer, VkScreenBufferPropertiesQNX* pProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetScreenBufferPropertiesQNX( + VkDevice device, + const struct _screen_buffer* buffer, + VkScreenBufferPropertiesQNX* pProperties); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_vi.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_vi.h new file mode 100644 index 0000000..c145f4a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_vi.h @@ -0,0 +1,48 @@ +#ifndef VULKAN_VI_H_ +#define VULKAN_VI_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_NN_vi_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_NN_vi_surface 1 +#define VK_NN_VI_SURFACE_SPEC_VERSION 1 +#define VK_NN_VI_SURFACE_EXTENSION_NAME "VK_NN_vi_surface" +typedef VkFlags VkViSurfaceCreateFlagsNN; +typedef struct VkViSurfaceCreateInfoNN { + VkStructureType sType; + const void* pNext; + VkViSurfaceCreateFlagsNN flags; + void* window; +} VkViSurfaceCreateInfoNN; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateViSurfaceNN)(VkInstance instance, const VkViSurfaceCreateInfoNN* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateViSurfaceNN( + VkInstance instance, + const VkViSurfaceCreateInfoNN* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_wayland.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_wayland.h new file mode 100644 index 0000000..ec706a1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_wayland.h @@ -0,0 +1,55 @@ +#ifndef VULKAN_WAYLAND_H_ +#define VULKAN_WAYLAND_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_KHR_wayland_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_wayland_surface 1 +#define VK_KHR_WAYLAND_SURFACE_SPEC_VERSION 6 +#define VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "VK_KHR_wayland_surface" +typedef VkFlags VkWaylandSurfaceCreateFlagsKHR; +typedef struct VkWaylandSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkWaylandSurfaceCreateFlagsKHR flags; + struct wl_display* display; + struct wl_surface* surface; +} VkWaylandSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateWaylandSurfaceKHR)(VkInstance instance, const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, struct wl_display* display); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateWaylandSurfaceKHR( + VkInstance instance, + const VkWaylandSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWaylandPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + struct wl_display* display); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_win32.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_win32.h new file mode 100644 index 0000000..d7a0b2b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_win32.h @@ -0,0 +1,342 @@ +#ifndef VULKAN_WIN32_H_ +#define VULKAN_WIN32_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_KHR_win32_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_win32_surface 1 +#define VK_KHR_WIN32_SURFACE_SPEC_VERSION 6 +#define VK_KHR_WIN32_SURFACE_EXTENSION_NAME "VK_KHR_win32_surface" +typedef VkFlags VkWin32SurfaceCreateFlagsKHR; +typedef struct VkWin32SurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkWin32SurfaceCreateFlagsKHR flags; + HINSTANCE hinstance; + HWND hwnd; +} VkWin32SurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateWin32SurfaceKHR)(VkInstance instance, const VkWin32SurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateWin32SurfaceKHR( + VkInstance instance, + const VkWin32SurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceWin32PresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex); +#endif + + +// VK_KHR_external_memory_win32 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_memory_win32 1 +#define VK_KHR_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_KHR_external_memory_win32" +typedef struct VkImportMemoryWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagBits handleType; + HANDLE handle; + LPCWSTR name; +} VkImportMemoryWin32HandleInfoKHR; + +typedef struct VkExportMemoryWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; + LPCWSTR name; +} VkExportMemoryWin32HandleInfoKHR; + +typedef struct VkMemoryWin32HandlePropertiesKHR { + VkStructureType sType; + void* pNext; + uint32_t memoryTypeBits; +} VkMemoryWin32HandlePropertiesKHR; + +typedef struct VkMemoryGetWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkDeviceMemory memory; + VkExternalMemoryHandleTypeFlagBits handleType; +} VkMemoryGetWin32HandleInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleKHR)(VkDevice device, const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandlePropertiesKHR)(VkDevice device, VkExternalMemoryHandleTypeFlagBits handleType, HANDLE handle, VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleKHR( + VkDevice device, + const VkMemoryGetWin32HandleInfoKHR* pGetWin32HandleInfo, + HANDLE* pHandle); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandlePropertiesKHR( + VkDevice device, + VkExternalMemoryHandleTypeFlagBits handleType, + HANDLE handle, + VkMemoryWin32HandlePropertiesKHR* pMemoryWin32HandleProperties); +#endif + + +// VK_KHR_win32_keyed_mutex is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_win32_keyed_mutex 1 +#define VK_KHR_WIN32_KEYED_MUTEX_SPEC_VERSION 1 +#define VK_KHR_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_KHR_win32_keyed_mutex" +typedef struct VkWin32KeyedMutexAcquireReleaseInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t acquireCount; + const VkDeviceMemory* pAcquireSyncs; + const uint64_t* pAcquireKeys; + const uint32_t* pAcquireTimeouts; + uint32_t releaseCount; + const VkDeviceMemory* pReleaseSyncs; + const uint64_t* pReleaseKeys; +} VkWin32KeyedMutexAcquireReleaseInfoKHR; + + + +// VK_KHR_external_semaphore_win32 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_semaphore_win32 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_SEMAPHORE_WIN32_EXTENSION_NAME "VK_KHR_external_semaphore_win32" +typedef struct VkImportSemaphoreWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkSemaphoreImportFlags flags; + VkExternalSemaphoreHandleTypeFlagBits handleType; + HANDLE handle; + LPCWSTR name; +} VkImportSemaphoreWin32HandleInfoKHR; + +typedef struct VkExportSemaphoreWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; + LPCWSTR name; +} VkExportSemaphoreWin32HandleInfoKHR; + +typedef struct VkD3D12FenceSubmitInfoKHR { + VkStructureType sType; + const void* pNext; + uint32_t waitSemaphoreValuesCount; + const uint64_t* pWaitSemaphoreValues; + uint32_t signalSemaphoreValuesCount; + const uint64_t* pSignalSemaphoreValues; +} VkD3D12FenceSubmitInfoKHR; + +typedef struct VkSemaphoreGetWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkSemaphore semaphore; + VkExternalSemaphoreHandleTypeFlagBits handleType; +} VkSemaphoreGetWin32HandleInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportSemaphoreWin32HandleKHR)(VkDevice device, const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetSemaphoreWin32HandleKHR)(VkDevice device, const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportSemaphoreWin32HandleKHR( + VkDevice device, + const VkImportSemaphoreWin32HandleInfoKHR* pImportSemaphoreWin32HandleInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetSemaphoreWin32HandleKHR( + VkDevice device, + const VkSemaphoreGetWin32HandleInfoKHR* pGetWin32HandleInfo, + HANDLE* pHandle); +#endif + + +// VK_KHR_external_fence_win32 is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_external_fence_win32 1 +#define VK_KHR_EXTERNAL_FENCE_WIN32_SPEC_VERSION 1 +#define VK_KHR_EXTERNAL_FENCE_WIN32_EXTENSION_NAME "VK_KHR_external_fence_win32" +typedef struct VkImportFenceWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkFenceImportFlags flags; + VkExternalFenceHandleTypeFlagBits handleType; + HANDLE handle; + LPCWSTR name; +} VkImportFenceWin32HandleInfoKHR; + +typedef struct VkExportFenceWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; + LPCWSTR name; +} VkExportFenceWin32HandleInfoKHR; + +typedef struct VkFenceGetWin32HandleInfoKHR { + VkStructureType sType; + const void* pNext; + VkFence fence; + VkExternalFenceHandleTypeFlagBits handleType; +} VkFenceGetWin32HandleInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkImportFenceWin32HandleKHR)(VkDevice device, const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo); +typedef VkResult (VKAPI_PTR *PFN_vkGetFenceWin32HandleKHR)(VkDevice device, const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, HANDLE* pHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkImportFenceWin32HandleKHR( + VkDevice device, + const VkImportFenceWin32HandleInfoKHR* pImportFenceWin32HandleInfo); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetFenceWin32HandleKHR( + VkDevice device, + const VkFenceGetWin32HandleInfoKHR* pGetWin32HandleInfo, + HANDLE* pHandle); +#endif + + +// VK_NV_external_memory_win32 is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_external_memory_win32 1 +#define VK_NV_EXTERNAL_MEMORY_WIN32_SPEC_VERSION 1 +#define VK_NV_EXTERNAL_MEMORY_WIN32_EXTENSION_NAME "VK_NV_external_memory_win32" +typedef struct VkImportMemoryWin32HandleInfoNV { + VkStructureType sType; + const void* pNext; + VkExternalMemoryHandleTypeFlagsNV handleType; + HANDLE handle; +} VkImportMemoryWin32HandleInfoNV; + +typedef struct VkExportMemoryWin32HandleInfoNV { + VkStructureType sType; + const void* pNext; + const SECURITY_ATTRIBUTES* pAttributes; + DWORD dwAccess; +} VkExportMemoryWin32HandleInfoNV; + +typedef VkResult (VKAPI_PTR *PFN_vkGetMemoryWin32HandleNV)(VkDevice device, VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagsNV handleType, HANDLE* pHandle); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetMemoryWin32HandleNV( + VkDevice device, + VkDeviceMemory memory, + VkExternalMemoryHandleTypeFlagsNV handleType, + HANDLE* pHandle); +#endif + + +// VK_NV_win32_keyed_mutex is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_win32_keyed_mutex 1 +#define VK_NV_WIN32_KEYED_MUTEX_SPEC_VERSION 2 +#define VK_NV_WIN32_KEYED_MUTEX_EXTENSION_NAME "VK_NV_win32_keyed_mutex" +typedef struct VkWin32KeyedMutexAcquireReleaseInfoNV { + VkStructureType sType; + const void* pNext; + uint32_t acquireCount; + const VkDeviceMemory* pAcquireSyncs; + const uint64_t* pAcquireKeys; + const uint32_t* pAcquireTimeoutMilliseconds; + uint32_t releaseCount; + const VkDeviceMemory* pReleaseSyncs; + const uint64_t* pReleaseKeys; +} VkWin32KeyedMutexAcquireReleaseInfoNV; + + + +// VK_EXT_full_screen_exclusive is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_full_screen_exclusive 1 +#define VK_EXT_FULL_SCREEN_EXCLUSIVE_SPEC_VERSION 4 +#define VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME "VK_EXT_full_screen_exclusive" + +typedef enum VkFullScreenExclusiveEXT { + VK_FULL_SCREEN_EXCLUSIVE_DEFAULT_EXT = 0, + VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT = 1, + VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT = 2, + VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT = 3, + VK_FULL_SCREEN_EXCLUSIVE_MAX_ENUM_EXT = 0x7FFFFFFF +} VkFullScreenExclusiveEXT; +typedef struct VkSurfaceFullScreenExclusiveInfoEXT { + VkStructureType sType; + void* pNext; + VkFullScreenExclusiveEXT fullScreenExclusive; +} VkSurfaceFullScreenExclusiveInfoEXT; + +typedef struct VkSurfaceCapabilitiesFullScreenExclusiveEXT { + VkStructureType sType; + void* pNext; + VkBool32 fullScreenExclusiveSupported; +} VkSurfaceCapabilitiesFullScreenExclusiveEXT; + +typedef struct VkSurfaceFullScreenExclusiveWin32InfoEXT { + VkStructureType sType; + const void* pNext; + HMONITOR hmonitor; +} VkSurfaceFullScreenExclusiveWin32InfoEXT; + +typedef VkResult (VKAPI_PTR *PFN_vkGetPhysicalDeviceSurfacePresentModes2EXT)(VkPhysicalDevice physicalDevice, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, uint32_t* pPresentModeCount, VkPresentModeKHR* pPresentModes); +typedef VkResult (VKAPI_PTR *PFN_vkAcquireFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain); +typedef VkResult (VKAPI_PTR *PFN_vkReleaseFullScreenExclusiveModeEXT)(VkDevice device, VkSwapchainKHR swapchain); +typedef VkResult (VKAPI_PTR *PFN_vkGetDeviceGroupSurfacePresentModes2EXT)(VkDevice device, const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, VkDeviceGroupPresentModeFlagsKHR* pModes); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModes2EXT( + VkPhysicalDevice physicalDevice, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + uint32_t* pPresentModeCount, + VkPresentModeKHR* pPresentModes); + +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireFullScreenExclusiveModeEXT( + VkDevice device, + VkSwapchainKHR swapchain); + +VKAPI_ATTR VkResult VKAPI_CALL vkReleaseFullScreenExclusiveModeEXT( + VkDevice device, + VkSwapchainKHR swapchain); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetDeviceGroupSurfacePresentModes2EXT( + VkDevice device, + const VkPhysicalDeviceSurfaceInfo2KHR* pSurfaceInfo, + VkDeviceGroupPresentModeFlagsKHR* pModes); +#endif + + +// VK_NV_acquire_winrt_display is a preprocessor guard. Do not pass it to API calls. +#define VK_NV_acquire_winrt_display 1 +#define VK_NV_ACQUIRE_WINRT_DISPLAY_SPEC_VERSION 1 +#define VK_NV_ACQUIRE_WINRT_DISPLAY_EXTENSION_NAME "VK_NV_acquire_winrt_display" +typedef VkResult (VKAPI_PTR *PFN_vkAcquireWinrtDisplayNV)(VkPhysicalDevice physicalDevice, VkDisplayKHR display); +typedef VkResult (VKAPI_PTR *PFN_vkGetWinrtDisplayNV)(VkPhysicalDevice physicalDevice, uint32_t deviceRelativeId, VkDisplayKHR* pDisplay); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireWinrtDisplayNV( + VkPhysicalDevice physicalDevice, + VkDisplayKHR display); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetWinrtDisplayNV( + VkPhysicalDevice physicalDevice, + uint32_t deviceRelativeId, + VkDisplayKHR* pDisplay); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xcb.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xcb.h new file mode 100644 index 0000000..cdf6b52 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xcb.h @@ -0,0 +1,56 @@ +#ifndef VULKAN_XCB_H_ +#define VULKAN_XCB_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_KHR_xcb_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_xcb_surface 1 +#define VK_KHR_XCB_SURFACE_SPEC_VERSION 6 +#define VK_KHR_XCB_SURFACE_EXTENSION_NAME "VK_KHR_xcb_surface" +typedef VkFlags VkXcbSurfaceCreateFlagsKHR; +typedef struct VkXcbSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkXcbSurfaceCreateFlagsKHR flags; + xcb_connection_t* connection; + xcb_window_t window; +} VkXcbSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateXcbSurfaceKHR)(VkInstance instance, const VkXcbSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, xcb_connection_t* connection, xcb_visualid_t visual_id); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateXcbSurfaceKHR( + VkInstance instance, + const VkXcbSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXcbPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + xcb_connection_t* connection, + xcb_visualid_t visual_id); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib.h new file mode 100644 index 0000000..b3c3e27 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib.h @@ -0,0 +1,56 @@ +#ifndef VULKAN_XLIB_H_ +#define VULKAN_XLIB_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_KHR_xlib_surface is a preprocessor guard. Do not pass it to API calls. +#define VK_KHR_xlib_surface 1 +#define VK_KHR_XLIB_SURFACE_SPEC_VERSION 6 +#define VK_KHR_XLIB_SURFACE_EXTENSION_NAME "VK_KHR_xlib_surface" +typedef VkFlags VkXlibSurfaceCreateFlagsKHR; +typedef struct VkXlibSurfaceCreateInfoKHR { + VkStructureType sType; + const void* pNext; + VkXlibSurfaceCreateFlagsKHR flags; + Display* dpy; + Window window; +} VkXlibSurfaceCreateInfoKHR; + +typedef VkResult (VKAPI_PTR *PFN_vkCreateXlibSurfaceKHR)(VkInstance instance, const VkXlibSurfaceCreateInfoKHR* pCreateInfo, const VkAllocationCallbacks* pAllocator, VkSurfaceKHR* pSurface); +typedef VkBool32 (VKAPI_PTR *PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, Display* dpy, VisualID visualID); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkCreateXlibSurfaceKHR( + VkInstance instance, + const VkXlibSurfaceCreateInfoKHR* pCreateInfo, + const VkAllocationCallbacks* pAllocator, + VkSurfaceKHR* pSurface); + +VKAPI_ATTR VkBool32 VKAPI_CALL vkGetPhysicalDeviceXlibPresentationSupportKHR( + VkPhysicalDevice physicalDevice, + uint32_t queueFamilyIndex, + Display* dpy, + VisualID visualID); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib_xrandr.h b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib_xrandr.h new file mode 100644 index 0000000..8e99190 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/khronos/vulkan/vulkan_xlib_xrandr.h @@ -0,0 +1,46 @@ +#ifndef VULKAN_XLIB_XRANDR_H_ +#define VULKAN_XLIB_XRANDR_H_ 1 + +/* +** Copyright 2015-2024 The Khronos Group Inc. +** +** SPDX-License-Identifier: Apache-2.0 +*/ + +/* +** This header is generated from the Khronos Vulkan XML API Registry. +** +*/ + + +#ifdef __cplusplus +extern "C" { +#endif + + + +// VK_EXT_acquire_xlib_display is a preprocessor guard. Do not pass it to API calls. +#define VK_EXT_acquire_xlib_display 1 +#define VK_EXT_ACQUIRE_XLIB_DISPLAY_SPEC_VERSION 1 +#define VK_EXT_ACQUIRE_XLIB_DISPLAY_EXTENSION_NAME "VK_EXT_acquire_xlib_display" +typedef VkResult (VKAPI_PTR *PFN_vkAcquireXlibDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, VkDisplayKHR display); +typedef VkResult (VKAPI_PTR *PFN_vkGetRandROutputDisplayEXT)(VkPhysicalDevice physicalDevice, Display* dpy, RROutput rrOutput, VkDisplayKHR* pDisplay); + +#ifndef VK_NO_PROTOTYPES +VKAPI_ATTR VkResult VKAPI_CALL vkAcquireXlibDisplayEXT( + VkPhysicalDevice physicalDevice, + Display* dpy, + VkDisplayKHR display); + +VKAPI_ATTR VkResult VKAPI_CALL vkGetRandROutputDisplayEXT( + VkPhysicalDevice physicalDevice, + Display* dpy, + RROutput rrOutput, + VkDisplayKHR* pDisplay); +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.c b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.c new file mode 100644 index 0000000..a532cea --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.c @@ -0,0 +1,161 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_KMSDRM + +#define DEBUG_DYNAMIC_KMSDRM 0 + +#include "SDL_kmsdrmdyn.h" + +#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC + +typedef struct +{ + void *lib; + const char *libname; +} kmsdrmdynlib; + +#ifndef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM +#define SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM NULL +#endif + +static kmsdrmdynlib kmsdrmlibs[] = { + { NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC_GBM }, + { NULL, SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC } +}; + +static void *KMSDRM_GetSym(const char *fnname, int *pHasModule, bool required) +{ + int i; + void *fn = NULL; + for (i = 0; i < SDL_arraysize(kmsdrmlibs); i++) { + if (kmsdrmlibs[i].lib) { + fn = SDL_LoadFunction(kmsdrmlibs[i].lib, fnname); + if (fn) { + break; + } + } + } + +#if DEBUG_DYNAMIC_KMSDRM + if (fn) + SDL_Log("KMSDRM: Found '%s' in %s (%p)", fnname, kmsdrmlibs[i].libname, fn); + else + SDL_Log("KMSDRM: Symbol '%s' NOT FOUND!", fnname); +#endif + + if (!fn && required) { + *pHasModule = 0; // kill this module. + } + + return fn; +} + +#endif // SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC + +// Define all the function pointers and wrappers... +#define SDL_KMSDRM_MODULE(modname) int SDL_KMSDRM_HAVE_##modname = 0; +#define SDL_KMSDRM_SYM(rc, fn, params) SDL_DYNKMSDRMFN_##fn KMSDRM_##fn = NULL; +#define SDL_KMSDRM_SYM_CONST(type, name) SDL_DYNKMSDRMCONST_##name KMSDRM_##name = NULL; +#define SDL_KMSDRM_SYM_OPT(rc, fn, params) SDL_DYNKMSDRMFN_##fn KMSDRM_##fn = NULL; +#include "SDL_kmsdrmsym.h" + +static int kmsdrm_load_refcount = 0; + +void SDL_KMSDRM_UnloadSymbols(void) +{ + // Don't actually unload if more than one module is using the libs... + if (kmsdrm_load_refcount > 0) { + if (--kmsdrm_load_refcount == 0) { +#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC + int i; +#endif + + // set all the function pointers to NULL. +#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 0; +#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = NULL; +#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = NULL; +#define SDL_KMSDRM_SYM_OPT(rc, fn, params) KMSDRM_##fn = NULL; +#include "SDL_kmsdrmsym.h" + +#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC + for (i = 0; i < SDL_arraysize(kmsdrmlibs); i++) { + if (kmsdrmlibs[i].lib) { + SDL_UnloadObject(kmsdrmlibs[i].lib); + kmsdrmlibs[i].lib = NULL; + } + } +#endif + } + } +} + +// returns non-zero if all needed symbols were loaded. +bool SDL_KMSDRM_LoadSymbols(void) +{ + bool result = true; // always succeed if not using Dynamic KMSDRM stuff. + + // deal with multiple modules needing these symbols... + if (kmsdrm_load_refcount++ == 0) { +#ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC + int i; + int *thismod = NULL; + for (i = 0; i < SDL_arraysize(kmsdrmlibs); i++) { + if (kmsdrmlibs[i].libname) { + kmsdrmlibs[i].lib = SDL_LoadObject(kmsdrmlibs[i].libname); + } + } + +#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; // default yes +#include "SDL_kmsdrmsym.h" + +#define SDL_KMSDRM_MODULE(modname) thismod = &SDL_KMSDRM_HAVE_##modname; +#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = (SDL_DYNKMSDRMFN_##fn)KMSDRM_GetSym(#fn, thismod, true); +#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = *(SDL_DYNKMSDRMCONST_##name *)KMSDRM_GetSym(#name, thismod, true); +#define SDL_KMSDRM_SYM_OPT(rc, fn, params) KMSDRM_##fn = (SDL_DYNKMSDRMFN_##fn)KMSDRM_GetSym(#fn, thismod, false); +#include "SDL_kmsdrmsym.h" + + if ((SDL_KMSDRM_HAVE_LIBDRM) && (SDL_KMSDRM_HAVE_GBM)) { + // all required symbols loaded. + SDL_ClearError(); + } else { + // in case something got loaded... + SDL_KMSDRM_UnloadSymbols(); + result = false; + } + +#else // no dynamic KMSDRM + +#define SDL_KMSDRM_MODULE(modname) SDL_KMSDRM_HAVE_##modname = 1; // default yes +#define SDL_KMSDRM_SYM(rc, fn, params) KMSDRM_##fn = fn; +#define SDL_KMSDRM_SYM_CONST(type, name) KMSDRM_##name = name; +#define SDL_KMSDRM_SYM_OPT(rc, fn, params) KMSDRM_##fn = fn; +#include "SDL_kmsdrmsym.h" + +#endif + } + + return result; +} + +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.h b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.h new file mode 100644 index 0000000..55c5199 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmdyn.h @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_kmsdrmdyn_h_ +#define SDL_kmsdrmdyn_h_ + +#include "SDL_internal.h" + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +extern bool SDL_KMSDRM_LoadSymbols(void); +extern void SDL_KMSDRM_UnloadSymbols(void); + +// Declare all the function pointers and wrappers... +#define SDL_KMSDRM_SYM(rc, fn, params) \ + typedef rc(*SDL_DYNKMSDRMFN_##fn) params; \ + extern SDL_DYNKMSDRMFN_##fn KMSDRM_##fn; +#define SDL_KMSDRM_SYM_CONST(type, name) \ + typedef type SDL_DYNKMSDRMCONST_##name; \ + extern SDL_DYNKMSDRMCONST_##name KMSDRM_##name; +#define SDL_KMSDRM_SYM_OPT(rc, fn, params) \ + typedef rc(*SDL_DYNKMSDRMFN_##fn) params; \ + extern SDL_DYNKMSDRMFN_##fn KMSDRM_##fn; +#include "SDL_kmsdrmsym.h" + +#ifdef __cplusplus +} +#endif + +#endif // SDL_kmsdrmdyn_h_ diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.c b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.c new file mode 100644 index 0000000..78fb9f4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.c @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_KMSDRM + +#include "SDL_kmsdrmvideo.h" +#include "SDL_kmsdrmevents.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../core/linux/SDL_evdev.h" +#elif defined SDL_INPUT_WSCONS +#include "../../core/openbsd/SDL_wscons.h" +#endif + +void KMSDRM_PumpEvents(SDL_VideoDevice *_this) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Poll(); +#elif defined SDL_INPUT_WSCONS + SDL_WSCONS_PumpEvents(); +#endif +} + +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.h b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.h new file mode 100644 index 0000000..35473f8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmevents.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_kmsdrmevents_h_ +#define SDL_kmsdrmevents_h_ + +extern void KMSDRM_PumpEvents(SDL_VideoDevice *_this); + +#endif // SDL_kmsdrmevents_h_ diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.c b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.c new file mode 100644 index 0000000..bb50ae3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -0,0 +1,410 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_KMSDRM + +#include "SDL_kmsdrmvideo.h" +#include "SDL_kmsdrmmouse.h" +#include "SDL_kmsdrmdyn.h" + +#include "../../events/SDL_mouse_c.h" +#include "../../events/default_cursor.h" + +#include "../SDL_pixels_c.h" + +static SDL_Cursor *KMSDRM_CreateDefaultCursor(void); +static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y); +static bool KMSDRM_ShowCursor(SDL_Cursor *cursor); +static bool KMSDRM_MoveCursor(SDL_Cursor *cursor); +static void KMSDRM_FreeCursor(SDL_Cursor *cursor); + +/**************************************************************************************/ +// BEFORE CODING ANYTHING MOUSE/CURSOR RELATED, REMEMBER THIS. +// How does SDL manage cursors internally? First, mouse =! cursor. The mouse can have +// many cursors in mouse->cursors. +// -SDL tells us to create a cursor with KMSDRM_CreateCursor(). It can create many +// cursosr with this, not only one. +// -SDL stores those cursors in a cursors array, in mouse->cursors. +// -Whenever it wants (or the programmer wants) takes a cursor from that array +// and shows it on screen with KMSDRM_ShowCursor(). +// KMSDRM_ShowCursor() simply shows or hides the cursor it receives: it does NOT +// mind if it's mouse->cur_cursor, etc. +// -If KMSDRM_ShowCursor() returns successfully, that cursor becomes +// mouse->cur_cursor and mouse->cursor_shown is 1. +/**************************************************************************************/ + +static SDL_Cursor *KMSDRM_CreateDefaultCursor(void) +{ + return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); +} + +/* Given a display's internal, destroy the cursor BO for it. + To be called from KMSDRM_DestroyWindow(), as that's where we + destroy the internal for the window's display. */ +void KMSDRM_DestroyCursorBO(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayData *dispdata = display->internal; + + // Destroy the curso GBM BO. + if (dispdata->cursor_bo) { + KMSDRM_gbm_bo_destroy(dispdata->cursor_bo); + dispdata->cursor_bo = NULL; + dispdata->cursor_bo_drm_fd = -1; + } +} + +/* Given a display's internal, create the cursor BO for it. + To be called from KMSDRM_CreateWindow(), as that's where we + build a window and assign a display to it. */ +bool KMSDRM_CreateCursorBO(SDL_VideoDisplay *display) +{ + + SDL_VideoDevice *dev = SDL_GetVideoDevice(); + SDL_VideoData *viddata = dev->internal; + SDL_DisplayData *dispdata = display->internal; + + if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, + GBM_FORMAT_ARGB8888, + GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE)) { + return SDL_SetError("Unsupported pixel format for cursor"); + } + + if (KMSDRM_drmGetCap(viddata->drm_fd, + DRM_CAP_CURSOR_WIDTH, &dispdata->cursor_w) || + KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_CURSOR_HEIGHT, + &dispdata->cursor_h)) { + return SDL_SetError("Could not get the recommended GBM cursor size"); + } + + if (dispdata->cursor_w == 0 || dispdata->cursor_h == 0) { + return SDL_SetError("Could not get an usable GBM cursor size"); + } + + dispdata->cursor_bo = KMSDRM_gbm_bo_create(viddata->gbm_dev, + dispdata->cursor_w, dispdata->cursor_h, + GBM_FORMAT_ARGB8888, GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE | GBM_BO_USE_LINEAR); + + if (!dispdata->cursor_bo) { + return SDL_SetError("Could not create GBM cursor BO"); + } + + dispdata->cursor_bo_drm_fd = viddata->drm_fd; + return true; +} + +// Remove a cursor buffer from a display's DRM cursor BO. +static bool KMSDRM_RemoveCursorFromBO(SDL_VideoDisplay *display) +{ + bool result = true; + + SDL_DisplayData *dispdata = display->internal; + SDL_VideoDevice *video_device = SDL_GetVideoDevice(); + SDL_VideoData *viddata = video_device->internal; + + const int rc = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc->crtc_id, 0, 0, 0); + if (rc < 0) { + result = SDL_SetError("drmModeSetCursor() failed: %s", strerror(-rc)); + } + return result; +} + +// Dump a cursor buffer to a display's DRM cursor BO. +static bool KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) +{ + SDL_DisplayData *dispdata = display->internal; + SDL_CursorData *curdata = cursor->internal; + SDL_VideoDevice *video_device = SDL_GetVideoDevice(); + SDL_VideoData *viddata = video_device->internal; + + uint32_t bo_handle; + size_t bo_stride; + size_t bufsize; + uint8_t *ready_buffer = NULL; + uint8_t *src_row; + + int i, rc; + bool result = true; + + if (!curdata || !dispdata->cursor_bo) { + return SDL_SetError("Cursor or display not initialized properly."); + } + + /* Prepare a buffer we can dump to our GBM BO (different + size, alpha premultiplication...) */ + bo_stride = KMSDRM_gbm_bo_get_stride(dispdata->cursor_bo); + bufsize = bo_stride * dispdata->cursor_h; + + ready_buffer = (uint8_t *)SDL_calloc(1, bufsize); + + if (!ready_buffer) { + result = false; + goto cleanup; + } + + // Copy from the cursor buffer to a buffer that we can dump to the GBM BO. + for (i = 0; i < curdata->h; i++) { + src_row = &((uint8_t *)curdata->buffer)[i * curdata->w * 4]; + SDL_memcpy(ready_buffer + (i * bo_stride), src_row, (size_t)4 * curdata->w); + } + + // Dump the cursor buffer to our GBM BO. + if (KMSDRM_gbm_bo_write(dispdata->cursor_bo, ready_buffer, bufsize)) { + result = SDL_SetError("Could not write to GBM cursor BO"); + goto cleanup; + } + + // Put the GBM BO buffer on screen using the DRM interface. + bo_handle = KMSDRM_gbm_bo_get_handle(dispdata->cursor_bo).u32; + if (curdata->hot_x == 0 && curdata->hot_y == 0) { + rc = KMSDRM_drmModeSetCursor(viddata->drm_fd, dispdata->crtc->crtc_id, + bo_handle, dispdata->cursor_w, dispdata->cursor_h); + } else { + rc = KMSDRM_drmModeSetCursor2(viddata->drm_fd, dispdata->crtc->crtc_id, + bo_handle, dispdata->cursor_w, dispdata->cursor_h, curdata->hot_x, curdata->hot_y); + } + if (rc < 0) { + result = SDL_SetError("Failed to set DRM cursor: %s", strerror(-rc)); + goto cleanup; + } + +cleanup: + + if (ready_buffer) { + SDL_free(ready_buffer); + } + return result; +} + +// This is only for freeing the SDL_cursor. +static void KMSDRM_FreeCursor(SDL_Cursor *cursor) +{ + SDL_CursorData *curdata; + + // Even if the cursor is not ours, free it. + if (cursor) { + curdata = cursor->internal; + // Free cursor buffer + if (curdata->buffer) { + SDL_free(curdata->buffer); + curdata->buffer = NULL; + } + // Free cursor itself + if (cursor->internal) { + SDL_free(cursor->internal); + } + SDL_free(cursor); + } +} + +/* This simply gets the cursor soft-buffer ready. + We don't copy it to a GBO BO until ShowCursor() because the cusor GBM BO (living + in dispata) is destroyed and recreated when we recreate windows, etc. */ +static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + SDL_CursorData *curdata; + SDL_Cursor *cursor, *result; + + curdata = NULL; + result = NULL; + + cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); + if (!cursor) { + goto cleanup; + } + curdata = (SDL_CursorData *)SDL_calloc(1, sizeof(*curdata)); + if (!curdata) { + goto cleanup; + } + + // hox_x and hot_y are the coordinates of the "tip of the cursor" from it's base. + curdata->hot_x = hot_x; + curdata->hot_y = hot_y; + curdata->w = surface->w; + curdata->h = surface->h; + curdata->buffer = NULL; + + /* Configure the cursor buffer info. + This buffer has the original size of the cursor surface we are given. */ + curdata->buffer_pitch = surface->w; + curdata->buffer_size = (size_t)surface->w * surface->h * 4; + curdata->buffer = (uint32_t *)SDL_malloc(curdata->buffer_size); + + if (!curdata->buffer) { + goto cleanup; + } + + /* All code below assumes ARGB8888 format for the cursor surface, + like other backends do. Also, the GBM BO pixels have to be + alpha-premultiplied, but the SDL surface we receive has + straight-alpha pixels, so we always have to convert. */ + SDL_PremultiplyAlpha(surface->w, surface->h, + surface->format, surface->pixels, surface->pitch, + SDL_PIXELFORMAT_ARGB8888, curdata->buffer, surface->w * 4, true); + + cursor->internal = curdata; + + result = cursor; + +cleanup: + if (!result) { + if (curdata) { + if (curdata->buffer) { + SDL_free(curdata->buffer); + } + SDL_free(curdata); + } + if (cursor) { + SDL_free(cursor); + } + } + + return result; +} + +// Show the specified cursor, or hide if cursor is NULL or has no focus. +static bool KMSDRM_ShowCursor(SDL_Cursor *cursor) +{ + SDL_VideoDisplay *display; + SDL_Window *window; + SDL_Mouse *mouse = SDL_GetMouse(); + + int i; + bool result = true; + + // Get the mouse focused window, if any. + window = mouse->focus; + + if (!window || !cursor) { + /* If no window is focused by mouse or cursor is NULL, + since we have no window (no mouse->focus) and hence + we have no display, we simply hide mouse on all displays. + This happens on video quit, where we get here after + the mouse focus has been unset, yet SDL wants to + restore the system default cursor (makes no sense here). */ + SDL_DisplayID *displays = SDL_GetDisplays(NULL); + if (displays) { + // Iterate on the displays, hiding the cursor. + for (i = 0; i < displays[i]; i++) { + display = SDL_GetVideoDisplay(displays[i]); + result = KMSDRM_RemoveCursorFromBO(display); + } + SDL_free(displays); + } + } else { + display = SDL_GetVideoDisplayForWindow(window); + if (display) { + if (cursor) { + /* Dump the cursor to the display DRM cursor BO so it becomes visible + on that display. */ + result = KMSDRM_DumpCursorToBO(display, cursor); + } else { + // Hide the cursor on that display. + result = KMSDRM_RemoveCursorFromBO(display); + } + } + } + + return result; +} + +static bool KMSDRM_WarpMouseGlobal(float x, float y) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse && mouse->cur_cursor && mouse->focus) { + SDL_Window *window = mouse->focus; + SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); + + // Update internal mouse position. + SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, false, x, y); + + // And now update the cursor graphic position on screen. + if (dispdata->cursor_bo) { + const int rc = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, (int)x, (int)y); + if (rc < 0) { + return SDL_SetError("drmModeMoveCursor() failed: %s", strerror(-rc)); + } + return true; + } else { + return SDL_SetError("Cursor not initialized properly."); + } + } else { + return SDL_SetError("No mouse or current cursor."); + } +} + +static bool KMSDRM_WarpMouse(SDL_Window *window, float x, float y) +{ + // Only one global/fullscreen window is supported + return KMSDRM_WarpMouseGlobal(x, y); +} + +void KMSDRM_InitMouse(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_DisplayData *dispdata = display->internal; + + mouse->CreateCursor = KMSDRM_CreateCursor; + mouse->ShowCursor = KMSDRM_ShowCursor; + mouse->MoveCursor = KMSDRM_MoveCursor; + mouse->FreeCursor = KMSDRM_FreeCursor; + mouse->WarpMouse = KMSDRM_WarpMouse; + mouse->WarpMouseGlobal = KMSDRM_WarpMouseGlobal; + + /* Only create the default cursor for this display if we haven't done so before, + we don't want several cursors to be created for the same display. */ + if (!dispdata->default_cursor_init) { + SDL_SetDefaultCursor(KMSDRM_CreateDefaultCursor()); + dispdata->default_cursor_init = true; + } +} + +void KMSDRM_QuitMouse(SDL_VideoDevice *_this) +{ + // TODO: ? +} + +// This is called when a mouse motion event occurs +static bool KMSDRM_MoveCursor(SDL_Cursor *cursor) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + /* We must NOT call SDL_SendMouseMotion() here or we will enter recursivity! + That's why we move the cursor graphic ONLY. */ + if (mouse && mouse->cur_cursor && mouse->focus) { + SDL_Window *window = mouse->focus; + SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); + + if (!dispdata->cursor_bo) { + return SDL_SetError("Cursor not initialized properly."); + } + + const int rc = KMSDRM_drmModeMoveCursor(dispdata->cursor_bo_drm_fd, dispdata->crtc->crtc_id, (int)mouse->x, (int)mouse->y); + if (rc < 0) { + return SDL_SetError("drmModeMoveCursor() failed: %s", strerror(-rc)); + } + } + return true; +} + +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.h b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.h new file mode 100644 index 0000000..53e33f4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmmouse.h @@ -0,0 +1,53 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_KMSDRM_mouse_h_ +#define SDL_KMSDRM_mouse_h_ + +#include + +#define MAX_CURSOR_W 512 +#define MAX_CURSOR_H 512 + +struct SDL_CursorData +{ + int hot_x, hot_y; + int w, h; + + /* The buffer where we store the mouse bitmap ready to be used. + We get it ready and filled in CreateCursor(), and copy it + to a GBM BO in ShowCursor().*/ + uint32_t *buffer; + size_t buffer_size; + size_t buffer_pitch; + +}; + +extern void KMSDRM_InitMouse(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern void KMSDRM_QuitMouse(SDL_VideoDevice *_this); + +extern bool KMSDRM_CreateCursorBO(SDL_VideoDisplay *display); +extern void KMSDRM_DestroyCursorBO(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern void KMSDRM_InitCursor(void); + +#endif // SDL_KMSDRM_mouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.c b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.c new file mode 100644 index 0000000..cc93cde --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -0,0 +1,203 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_KMSDRM + +#include "SDL_kmsdrmvideo.h" +#include "SDL_kmsdrmopengles.h" +#include "SDL_kmsdrmdyn.h" +#include + +#ifndef EGL_PLATFORM_GBM_MESA +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif + +// EGL implementation of SDL OpenGL support + +void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor) +{ + /* if SDL was _also_ built with the Raspberry Pi driver (so we're + definitely a Pi device) or with the ROCKCHIP video driver + (it's a ROCKCHIP device), default to GLES2. */ +#if defined(SDL_VIDEO_DRIVER_RPI) || defined(SDL_VIDEO_DRIVER_ROCKCHIP) + *mask = SDL_GL_CONTEXT_PROFILE_ES; + *major = 2; + *minor = 0; +#endif +} + +bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + /* Just pretend you do this here, but don't do it until KMSDRM_CreateWindow(), + where we do the same library load we would normally do here. + because this gets called by SDL_CreateWindow() before KMSDR_CreateWindow(), + so gbm dev isn't yet created when this is called, AND we can't alter the + call order in SDL_CreateWindow(). */ +#if 0 + NativeDisplayType display = (NativeDisplayType)_this->internal->gbm_dev; + return SDL_EGL_LoadLibrary(_this, path, display, EGL_PLATFORM_GBM_MESA); +#endif + return true; +} + +void KMSDRM_GLES_UnloadLibrary(SDL_VideoDevice *_this) +{ + /* As with KMSDRM_GLES_LoadLibrary(), we define our own "dummy" unloading function + so we manually unload the library whenever we want. */ +} + +SDL_EGL_CreateContext_impl(KMSDRM) + +bool KMSDRM_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + if (interval == 0 || interval == 1) { + _this->egl_data->egl_swapinterval = interval; + } else { + return SDL_SetError("Only swap intervals of 0 or 1 are supported"); + } + + return true; +} + +bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *windata = window->internal; + SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); + SDL_VideoData *viddata = _this->internal; + KMSDRM_FBInfo *fb_info; + int ret = 0; + + /* Always wait for the previous issued flip before issuing a new one, + even if you do async flips. */ + uint32_t flip_flags = DRM_MODE_PAGE_FLIP_EVENT; + + // Skip the swap if we've switched away to another VT + if (windata->egl_surface == EGL_NO_SURFACE) { + // Wait a bit, throttling to ~100 FPS + SDL_Delay(10); + return true; + } + + // Recreate the GBM / EGL surfaces if the display mode has changed + if (windata->egl_surface_dirty) { + KMSDRM_CreateSurfaces(_this, window); + } + + /* Wait for confirmation that the next front buffer has been flipped, at which + point the previous front buffer can be released */ + if (!KMSDRM_WaitPageflip(_this, windata)) { + return SDL_SetError("Wait for previous pageflip failed"); + } + + // Release the previous front buffer + if (windata->bo) { + KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo); + windata->bo = NULL; + } + + windata->bo = windata->next_bo; + + /* Mark a buffer to become the next front buffer. + This won't happen until pagelip completes. */ + if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, + windata->egl_surface))) { + return SDL_SetError("eglSwapBuffers failed"); + } + + /* From the GBM surface, get the next BO to become the next front buffer, + and lock it so it can't be allocated as a back buffer (to prevent EGL + from drawing into it!) */ + windata->next_bo = KMSDRM_gbm_surface_lock_front_buffer(windata->gs); + if (!windata->next_bo) { + return SDL_SetError("Could not lock front buffer on GBM surface"); + } + + // Get an actual usable fb for the next front buffer. + fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); + if (!fb_info) { + return SDL_SetError("Could not get a framebuffer"); + } + + if (!windata->bo) { + /* On the first swap, immediately present the new front buffer. Before + drmModePageFlip can be used the CRTC has to be configured to use + the current connector and mode with drmModeSetCrtc */ + ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, + dispdata->crtc->crtc_id, fb_info->fb_id, 0, 0, + &dispdata->connector->connector_id, 1, &dispdata->mode); + + if (ret) { + return SDL_SetError("Could not set videomode on CRTC."); + } + } else { + /* On subsequent swaps, queue the new front buffer to be flipped during + the next vertical blank + + Remember: drmModePageFlip() never blocks, it just issues the flip, + which will be done during the next vblank, or immediately if + we pass the DRM_MODE_PAGE_FLIP_ASYNC flag. + Since calling drmModePageFlip() will return EBUSY if we call it + without having completed the last issued flip, we must pass the + DRM_MODE_PAGE_FLIP_ASYNC if we don't block on EGL (egl_swapinterval = 0). + That makes it flip immediately, without waiting for the next vblank + to do so, so even if we don't block on EGL, the flip will have completed + when we get here again. */ + if (_this->egl_data->egl_swapinterval == 0 && viddata->async_pageflip_support) { + flip_flags |= DRM_MODE_PAGE_FLIP_ASYNC; + } + + ret = KMSDRM_drmModePageFlip(viddata->drm_fd, dispdata->crtc->crtc_id, + fb_info->fb_id, flip_flags, &windata->waiting_for_flip); + + if (ret == 0) { + windata->waiting_for_flip = true; + } else { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not queue pageflip: %d", ret); + } + + /* Wait immediately for vsync (as if we only had two buffers). + Even if we are already doing a WaitPageflip at the beginning of this + function, this is NOT redundant because here we wait immediately + after submitting the image to the screen, reducing lag, and if + we have waited here, there won't be a pending pageflip so the + WaitPageflip at the beginning of this function will be a no-op. + Just leave it here and don't worry. + Run your SDL program with "SDL_VIDEO_DOUBLE_BUFFER=1 " + to enable this. */ + if (windata->double_buffer) { + if (!KMSDRM_WaitPageflip(_this, windata)) { + return SDL_SetError("Immediate wait for previous pageflip failed"); + } + } + } + + return true; +} + +SDL_EGL_MakeCurrent_impl(KMSDRM) + +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.h b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.h new file mode 100644 index 0000000..6a4fa56 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmopengles.h @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_kmsdrmopengles_h_ +#define SDL_kmsdrmopengles_h_ + +#include "../SDL_egl_c.h" + +// OpenGLES functions +#define KMSDRM_GLES_GetAttribute SDL_EGL_GetAttribute +#define KMSDRM_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define KMSDRM_GLES_DestroyContext SDL_EGL_DestroyContext +#define KMSDRM_GLES_GetSwapInterval SDL_EGL_GetSwapInterval + +extern void KMSDRM_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor); +extern bool KMSDRM_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool KMSDRM_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void KMSDRM_GLES_UnloadLibrary(SDL_VideoDevice *_this); +extern SDL_GLContext KMSDRM_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool KMSDRM_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); + +#endif // SDL_kmsdrmopengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmsym.h b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmsym.h new file mode 100644 index 0000000..801942d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmsym.h @@ -0,0 +1,145 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* *INDENT-OFF* */ // clang-format off + +#ifndef SDL_KMSDRM_MODULE +#define SDL_KMSDRM_MODULE(modname) +#endif + +#ifndef SDL_KMSDRM_SYM +#define SDL_KMSDRM_SYM(rc,fn,params) +#endif + +#ifndef SDL_KMSDRM_SYM_CONST +#define SDL_KMSDRM_SYM_CONST(type, name) +#endif + +#ifndef SDL_KMSDRM_SYM_OPT +#define SDL_KMSDRM_SYM_OPT(rc,fn,params) +#endif + + +SDL_KMSDRM_MODULE(LIBDRM) +SDL_KMSDRM_SYM(void,drmModeFreeResources,(drmModeResPtr ptr)) +SDL_KMSDRM_SYM(void,drmModeFreeFB,(drmModeFBPtr ptr)) +SDL_KMSDRM_SYM(void,drmModeFreeCrtc,(drmModeCrtcPtr ptr)) +SDL_KMSDRM_SYM(void,drmModeFreeConnector,(drmModeConnectorPtr ptr)) +SDL_KMSDRM_SYM(void,drmModeFreeEncoder,(drmModeEncoderPtr ptr)) +SDL_KMSDRM_SYM(int,drmGetCap,(int fd, uint64_t capability, uint64_t *value)) +SDL_KMSDRM_SYM(int,drmSetMaster,(int fd)) +SDL_KMSDRM_SYM(int,drmDropMaster,(int fd)) +SDL_KMSDRM_SYM(int,drmAuthMagic,(int fd, drm_magic_t magic)) +SDL_KMSDRM_SYM(drmModeResPtr,drmModeGetResources,(int fd)) +SDL_KMSDRM_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_t depth, + uint8_t bpp, uint32_t pitch, uint32_t bo_handle, + uint32_t *buf_id)) + +SDL_KMSDRM_SYM_OPT(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height, + uint32_t pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const uint32_t offsets[4], + uint32_t *buf_id, uint32_t flags)) + +SDL_KMSDRM_SYM_OPT(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width, + uint32_t height, uint32_t pixel_format, const uint32_t bo_handles[4], + const uint32_t pitches[4], const uint32_t offsets[4], + const uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)) + +SDL_KMSDRM_SYM_OPT(const char *,drmModeGetConnectorTypeName,(uint32_t connector_type)) + +SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId)) +SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf)) +SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId)) +SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId, + uint32_t x, uint32_t y, uint32_t *connectors, int count, + drmModeModeInfoPtr mode)) +SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle, + uint32_t width, uint32_t height)) +SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle, + uint32_t width, uint32_t height, + int32_t hot_x, int32_t hot_y)) +SDL_KMSDRM_SYM(int,drmModeMoveCursor,(int fd, uint32_t crtcId, int x, int y)) +SDL_KMSDRM_SYM(drmModeEncoderPtr,drmModeGetEncoder,(int fd, uint32_t encoder_id)) +SDL_KMSDRM_SYM(drmModeConnectorPtr,drmModeGetConnector,(int fd, uint32_t connector_id)) +SDL_KMSDRM_SYM(int,drmHandleEvent,(int fd,drmEventContextPtr evctx)) +SDL_KMSDRM_SYM(int,drmModePageFlip,(int fd, uint32_t crtc_id, uint32_t fb_id, + uint32_t flags, void *user_data)) + +// Planes stuff. +SDL_KMSDRM_SYM(int,drmSetClientCap,(int fd, uint64_t capability, uint64_t value)) +SDL_KMSDRM_SYM(drmModePlaneResPtr,drmModeGetPlaneResources,(int fd)) +SDL_KMSDRM_SYM(drmModePlanePtr,drmModeGetPlane,(int fd, uint32_t plane_id)) +SDL_KMSDRM_SYM(drmModeObjectPropertiesPtr,drmModeObjectGetProperties,(int fd,uint32_t object_id,uint32_t object_type)) +SDL_KMSDRM_SYM(int,drmModeObjectSetProperty,(int fd, uint32_t object_id, + uint32_t object_type, uint32_t property_id, + uint64_t value)) +SDL_KMSDRM_SYM(drmModePropertyPtr,drmModeGetProperty,(int fd, uint32_t propertyId)) + +SDL_KMSDRM_SYM(void,drmModeFreeProperty,(drmModePropertyPtr ptr)) +SDL_KMSDRM_SYM(void,drmModeFreeObjectProperties,(drmModeObjectPropertiesPtr ptr)) +SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr)) +SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr)) +SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id, + uint32_t fb_id, uint32_t flags, + int32_t crtc_x, int32_t crtc_y, + uint32_t crtc_w, uint32_t crtc_h, + uint32_t src_x, uint32_t src_y, + uint32_t src_w, uint32_t src_h)) +// Planes stuff ends. + +SDL_KMSDRM_MODULE(GBM) +SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm, + uint32_t format, uint32_t usage)) +SDL_KMSDRM_SYM(void,gbm_device_destroy,(struct gbm_device *gbm)) +SDL_KMSDRM_SYM(struct gbm_device *,gbm_create_device,(int fd)) +SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_width,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_height,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_format,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(int,gbm_bo_write,(struct gbm_bo *bo, const void *buf, size_t count)) +SDL_KMSDRM_SYM(struct gbm_device *,gbm_bo_get_device,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(void,gbm_bo_set_user_data,(struct gbm_bo *bo, void *data, + void (*destroy_user_data)(struct gbm_bo *, void *))) +SDL_KMSDRM_SYM(void *,gbm_bo_get_user_data,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(void,gbm_bo_destroy,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM(struct gbm_bo *,gbm_bo_create,(struct gbm_device *gbm, + uint32_t width, uint32_t height, + uint32_t format, uint32_t usage)) +SDL_KMSDRM_SYM(struct gbm_surface *,gbm_surface_create,(struct gbm_device *gbm, + uint32_t width, uint32_t height, + uint32_t format, uint32_t flags)) +SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf)) +SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf)) +SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo)) + +SDL_KMSDRM_SYM_OPT(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM_OPT(int,gbm_bo_get_plane_count,(struct gbm_bo *bo)) +SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane)) +SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane)) +SDL_KMSDRM_SYM_OPT(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane)) + +#undef SDL_KMSDRM_MODULE +#undef SDL_KMSDRM_SYM +#undef SDL_KMSDRM_SYM_CONST +#undef SDL_KMSDRM_SYM_OPT + +/* *INDENT-ON* */ // clang-format on diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.c b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.c new file mode 100644 index 0000000..be1db82 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -0,0 +1,1820 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_KMSDRM + +/* Include this first, as some system headers may pull in EGL headers that + * define EGL types as native types for other enabled platforms, which can + * result in type-mismatch warnings when building with LTO. + */ +#include "../SDL_egl_c.h" + +// SDL internals +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../core/linux/SDL_evdev.h" +#elif defined SDL_INPUT_WSCONS +#include "../../core/openbsd/SDL_wscons.h" +#endif + +// KMS/DRM declarations +#include "SDL_kmsdrmdyn.h" +#include "SDL_kmsdrmevents.h" +#include "SDL_kmsdrmmouse.h" +#include "SDL_kmsdrmvideo.h" +#include "SDL_kmsdrmopengles.h" +#include "SDL_kmsdrmvulkan.h" +#include +#include +#include +#include +#include +#include + +#ifdef SDL_PLATFORM_OPENBSD +static bool moderndri = false; +#else +static bool moderndri = true; +#endif + +static char kmsdrm_dri_path[16]; +static int kmsdrm_dri_pathsize = 0; +static char kmsdrm_dri_devname[8]; +static int kmsdrm_dri_devnamesize = 0; +static char kmsdrm_dri_cardpath[32]; + +#ifndef EGL_PLATFORM_GBM_MESA +#define EGL_PLATFORM_GBM_MESA 0x31D7 +#endif + +static int get_driindex(void) +{ + int available = -ENOENT; + char device[sizeof(kmsdrm_dri_cardpath)]; + int drm_fd; + int i; + int devindex = -1; + DIR *folder; + const char *hint; + struct dirent *res; + + hint = SDL_GetHint(SDL_HINT_KMSDRM_DEVICE_INDEX); + if (hint && *hint) { + char *endptr = NULL; + const int idx = (int)SDL_strtol(hint, &endptr, 10); + if ((*endptr == '\0') && (idx >= 0)) { /* *endptr==0 means "whole string was a valid number" */ + return idx; // we'll take the user's request here. + } + } + + SDL_strlcpy(device, kmsdrm_dri_path, sizeof(device)); + folder = opendir(device); + if (!folder) { + SDL_SetError("Failed to open directory '%s'", device); + return -ENOENT; + } + + SDL_strlcpy(device + kmsdrm_dri_pathsize, kmsdrm_dri_devname, + sizeof(device) - kmsdrm_dri_pathsize); + while((res = readdir(folder)) != NULL && available < 0) { + if (SDL_memcmp(res->d_name, kmsdrm_dri_devname, + kmsdrm_dri_devnamesize) == 0) { + SDL_strlcpy(device + kmsdrm_dri_pathsize + kmsdrm_dri_devnamesize, + res->d_name + kmsdrm_dri_devnamesize, + sizeof(device) - kmsdrm_dri_pathsize - + kmsdrm_dri_devnamesize); + + drm_fd = open(device, O_RDWR | O_CLOEXEC); + if (drm_fd >= 0) { + devindex = SDL_atoi(device + kmsdrm_dri_pathsize + + kmsdrm_dri_devnamesize); + if (SDL_KMSDRM_LoadSymbols()) { + drmModeRes *resources = KMSDRM_drmModeGetResources(drm_fd); + if (resources) { + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, + "%s%d connector, encoder and CRTC counts are: %d %d %d", + kmsdrm_dri_cardpath, devindex, + resources->count_connectors, + resources->count_encoders, + resources->count_crtcs); + + if (resources->count_connectors > 0 && + resources->count_encoders > 0 && + resources->count_crtcs > 0) { + available = -ENOENT; + for (i = 0; i < resources->count_connectors && available < 0; i++) { + drmModeConnector *conn = + KMSDRM_drmModeGetConnector( + drm_fd, resources->connectors[i]); + + if (!conn) { + continue; + } + + if (conn->connection == DRM_MODE_CONNECTED && + conn->count_modes) { + bool access_denied = false; + if (SDL_GetHintBoolean( + SDL_HINT_KMSDRM_REQUIRE_DRM_MASTER, + true)) { + /* Skip this device if we can't obtain + * DRM master */ + KMSDRM_drmSetMaster(drm_fd); + if (KMSDRM_drmAuthMagic(drm_fd, 0) == -EACCES) { + access_denied = true; + } + } + + if (!access_denied) { + available = devindex; + } + } + + KMSDRM_drmModeFreeConnector(conn); + } + } + KMSDRM_drmModeFreeResources(resources); + } + SDL_KMSDRM_UnloadSymbols(); + } + close(drm_fd); + } else { + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, + "Failed to open KMSDRM device %s, errno: %d", device, errno); + } + } + } + + closedir(folder); + + return available; +} + +static void CalculateRefreshRate(drmModeModeInfo *mode, int *numerator, int *denominator) +{ + *numerator = mode->clock * 1000; + *denominator = mode->htotal * mode->vtotal; + + if (mode->flags & DRM_MODE_FLAG_INTERLACE) { + *numerator *= 2; + } + + if (mode->flags & DRM_MODE_FLAG_DBLSCAN) { + *denominator *= 2; + } + + if (mode->vscan > 1) { + *denominator *= mode->vscan; + } +} + +static bool KMSDRM_Available(void) +{ +#ifdef SDL_PLATFORM_OPENBSD + struct utsname nameofsystem; + double releaseversion; +#endif + int ret = -ENOENT; + +#ifdef SDL_PLATFORM_OPENBSD + if (!(uname(&nameofsystem) < 0)) { + releaseversion = SDL_atof(nameofsystem.release); + if (releaseversion >= 6.9) { + moderndri = true; + } + } +#endif + + if (moderndri) { + SDL_strlcpy(kmsdrm_dri_path, "/dev/dri/", sizeof(kmsdrm_dri_path)); + SDL_strlcpy(kmsdrm_dri_devname, "card", sizeof(kmsdrm_dri_devname)); + } else { + SDL_strlcpy(kmsdrm_dri_path, "/dev/", sizeof(kmsdrm_dri_path)); + SDL_strlcpy(kmsdrm_dri_devname, "drm", sizeof(kmsdrm_dri_devname)); + } + + kmsdrm_dri_pathsize = SDL_strlen(kmsdrm_dri_path); + kmsdrm_dri_devnamesize = SDL_strlen(kmsdrm_dri_devname); + (void)SDL_snprintf(kmsdrm_dri_cardpath, sizeof(kmsdrm_dri_cardpath), "%s%s", + kmsdrm_dri_path, kmsdrm_dri_devname); + + ret = get_driindex(); + if (ret >= 0) { + return true; + } + + return false; +} + +static void KMSDRM_DeleteDevice(SDL_VideoDevice *device) +{ + if (device->internal) { + SDL_free(device->internal); + device->internal = NULL; + } + + SDL_free(device); + + SDL_KMSDRM_UnloadSymbols(); +} + +static SDL_VideoDevice *KMSDRM_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *viddata; + int devindex; + + if (!KMSDRM_Available()) { + return NULL; + } + + devindex = get_driindex(); + if (devindex < 0) { + SDL_SetError("devindex (%d) must not be negative.", devindex); + return NULL; + } + + if (!SDL_KMSDRM_LoadSymbols()) { + return NULL; + } + + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + viddata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!viddata) { + goto cleanup; + } + viddata->devindex = devindex; + viddata->drm_fd = -1; + + device->internal = viddata; + + // Setup all functions which we can handle + device->VideoInit = KMSDRM_VideoInit; + device->VideoQuit = KMSDRM_VideoQuit; + device->GetDisplayModes = KMSDRM_GetDisplayModes; + device->SetDisplayMode = KMSDRM_SetDisplayMode; + device->CreateSDLWindow = KMSDRM_CreateWindow; + device->SetWindowTitle = KMSDRM_SetWindowTitle; + device->SetWindowPosition = KMSDRM_SetWindowPosition; + device->SetWindowSize = KMSDRM_SetWindowSize; + device->SetWindowFullscreen = KMSDRM_SetWindowFullscreen; + device->ShowWindow = KMSDRM_ShowWindow; + device->HideWindow = KMSDRM_HideWindow; + device->RaiseWindow = KMSDRM_RaiseWindow; + device->MaximizeWindow = KMSDRM_MaximizeWindow; + device->MinimizeWindow = KMSDRM_MinimizeWindow; + device->RestoreWindow = KMSDRM_RestoreWindow; + device->DestroyWindow = KMSDRM_DestroyWindow; + + device->GL_LoadLibrary = KMSDRM_GLES_LoadLibrary; + device->GL_GetProcAddress = KMSDRM_GLES_GetProcAddress; + device->GL_UnloadLibrary = KMSDRM_GLES_UnloadLibrary; + device->GL_CreateContext = KMSDRM_GLES_CreateContext; + device->GL_MakeCurrent = KMSDRM_GLES_MakeCurrent; + device->GL_SetSwapInterval = KMSDRM_GLES_SetSwapInterval; + device->GL_GetSwapInterval = KMSDRM_GLES_GetSwapInterval; + device->GL_SwapWindow = KMSDRM_GLES_SwapWindow; + device->GL_DestroyContext = KMSDRM_GLES_DestroyContext; + device->GL_DefaultProfileConfig = KMSDRM_GLES_DefaultProfileConfig; + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = KMSDRM_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = KMSDRM_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = KMSDRM_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = KMSDRM_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = KMSDRM_Vulkan_DestroySurface; +#endif + + device->PumpEvents = KMSDRM_PumpEvents; + device->free = KMSDRM_DeleteDevice; + + return device; + +cleanup: + if (device) { + SDL_free(device); + } + + if (viddata) { + SDL_free(viddata); + } + return NULL; +} + +VideoBootStrap KMSDRM_bootstrap = { + "kmsdrm", + "KMS/DRM Video Driver", + KMSDRM_CreateDevice, + NULL, // no ShowMessageBox implementation + false +}; + +static void KMSDRM_FBDestroyCallback(struct gbm_bo *bo, void *data) +{ + KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)data; + + if (fb_info && fb_info->drm_fd >= 0 && fb_info->fb_id != 0) { + KMSDRM_drmModeRmFB(fb_info->drm_fd, fb_info->fb_id); + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Delete DRM FB %u", fb_info->fb_id); + } + + SDL_free(fb_info); +} + +KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo) +{ + SDL_VideoData *viddata = _this->internal; + unsigned w, h; + int rc = -1; + int num_planes = 0; + uint32_t format, strides[4] = { 0 }, handles[4] = { 0 }, offsets[4] = { 0 }, flags = 0; + uint64_t modifiers[4] = { 0 }; + + // Check for an existing framebuffer + KMSDRM_FBInfo *fb_info = (KMSDRM_FBInfo *)KMSDRM_gbm_bo_get_user_data(bo); + + if (fb_info) { + return fb_info; + } + + /* Create a structure that contains enough info to remove the framebuffer + when the backing buffer is destroyed */ + fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo)); + + if (!fb_info) { + return NULL; + } + + fb_info->drm_fd = viddata->drm_fd; + + /* Create framebuffer object for the buffer using the modifiers requested by GBM. + Use of the modifiers is necessary on some platforms. */ + w = KMSDRM_gbm_bo_get_width(bo); + h = KMSDRM_gbm_bo_get_height(bo); + format = KMSDRM_gbm_bo_get_format(bo); + + if (KMSDRM_drmModeAddFB2WithModifiers && + KMSDRM_gbm_bo_get_modifier && + KMSDRM_gbm_bo_get_plane_count && + KMSDRM_gbm_bo_get_offset && + KMSDRM_gbm_bo_get_stride_for_plane && + KMSDRM_gbm_bo_get_handle_for_plane) { + + modifiers[0] = KMSDRM_gbm_bo_get_modifier(bo); + num_planes = KMSDRM_gbm_bo_get_plane_count(bo); + for (int i = 0; i < num_planes; i++) { + strides[i] = KMSDRM_gbm_bo_get_stride_for_plane(bo, i); + handles[i] = KMSDRM_gbm_bo_get_handle_for_plane(bo, i).u32; + offsets[i] = KMSDRM_gbm_bo_get_offset(bo, i); + modifiers[i] = modifiers[0]; + } + + if (modifiers[0] && modifiers[0] != DRM_FORMAT_MOD_INVALID) { + flags = DRM_MODE_FB_MODIFIERS; + } + + rc = KMSDRM_drmModeAddFB2WithModifiers(viddata->drm_fd, w, h, format, handles, strides, offsets, modifiers, &fb_info->fb_id, flags); + } + + if (rc < 0) { + strides[0] = KMSDRM_gbm_bo_get_stride(bo); + handles[0] = KMSDRM_gbm_bo_get_handle(bo).u32; + rc = KMSDRM_drmModeAddFB(viddata->drm_fd, w, h, 24, 32, strides[0], handles[0], &fb_info->fb_id); + } + + if (rc < 0) { + SDL_free(fb_info); + return NULL; + } + + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "New DRM FB (%u): %ux%u, from BO %p", + fb_info->fb_id, w, h, (void *)bo); + + // Associate our DRM framebuffer with this buffer object + KMSDRM_gbm_bo_set_user_data(bo, fb_info, KMSDRM_FBDestroyCallback); + + return fb_info; +} + +static void KMSDRM_FlipHandler(int fd, unsigned int frame, unsigned int sec, unsigned int usec, void *data) +{ + *((bool *)data) = false; +} + +bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata) +{ + + SDL_VideoData *viddata = _this->internal; + drmEventContext ev = { 0 }; + struct pollfd pfd = { 0 }; + int ret; + + ev.version = DRM_EVENT_CONTEXT_VERSION; + ev.page_flip_handler = KMSDRM_FlipHandler; + + pfd.fd = viddata->drm_fd; + pfd.events = POLLIN; + + /* Stay on the while loop until we get the desired event. + We need the while the loop because we could be in a situation where: + -We get and event on the FD in time, thus not on exiting on return number 1. + -The event is not an error, thus not exiting on return number 2. + -The event is of POLLIN type, but even then, if the event is not a pageflip, + drmHandleEvent() won't unset wait_for_pageflip, so we have to iterate + and go polling again. + + If it wasn't for the while loop, we could erroneously exit the function + without the pageflip event to arrive! + + For example, vblank events hit the FD and they are POLLIN events too (POLLIN + means "there's data to read on the FD"), but they are not the pageflip event + we are waiting for, so the drmEventHandle() doesn't run the flip handler, and + since waiting_for_flip is set on the pageflip handle, it's not set and we stay + on the loop, until we get the event for the pageflip, which is fine. + */ + while (windata->waiting_for_flip) { + + pfd.revents = 0; + + /* poll() waits for events arriving on the FD, and returns < 0 if timeout passes + with no events or a signal occurred before any requested event (-EINTR). + We wait forever (timeout = -1), but even if we DO get an event, we have yet + to see if it's of the required type, then if it's a pageflip, etc */ + ret = poll(&pfd, 1, -1); + + if (ret < 0) { + if (errno == EINTR) { + /* poll() returning < 0 and setting errno = EINTR means there was a signal before + any requested event, so we immediately poll again. */ + continue; + } else { + // There was another error. Don't pull again or we could get into a busy loop. + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll error"); + return false; + } + } + + if (pfd.revents & (POLLHUP | POLLERR)) { + // An event arrived on the FD in time, but it's an error. + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "DRM poll hup or error"); + return false; + } + + if (pfd.revents & POLLIN) { + /* There is data to read on the FD! + Is the event a pageflip? We know it is a pageflip if it matches the + event we are passing in &ev. If it does, drmHandleEvent() will unset + windata->waiting_for_flip and we will get out of the "while" loop. + If it's not, we keep iterating on the loop. */ + KMSDRM_drmHandleEvent(viddata->drm_fd, &ev); + } + + /* If we got to this point in the loop, we may iterate or exit the loop: + -A legit (non-error) event arrived, and it was a POLLING event, and it was consumed + by drmHandleEvent(). + -If it was a PAGEFLIP event, waiting_for_flip will be unset by drmHandleEvent() + and we will exit the loop. + -If it wasn't a PAGEFLIP, drmHandleEvent() won't unset waiting_for_flip, so we + iterare back to polling. + -A legit (non-error) event arrived, but it's not a POLLIN event, so it hasn't to be + consumed by drmHandleEvent(), so waiting_for_flip isn't set and we iterate back + to polling. */ + } + + return true; +} + +/* Given w, h and refresh rate, returns the closest DRM video mode + available on the DRM connector of the display. + We use the SDL mode list (which we filled in KMSDRM_GetDisplayModes) + because it's ordered, while the list on the connector is mostly random.*/ +static drmModeModeInfo *KMSDRM_GetClosestDisplayMode(SDL_VideoDisplay *display, int width, int height) +{ + + SDL_DisplayData *dispdata = display->internal; + drmModeConnector *connector = dispdata->connector; + + SDL_DisplayMode closest; + drmModeModeInfo *drm_mode; + + if (SDL_GetClosestFullscreenDisplayMode(display->id, width, height, 0.0f, false, &closest)) { + const SDL_DisplayModeData *modedata = closest.internal; + drm_mode = &connector->modes[modedata->mode_index]; + return drm_mode; + } else { + return NULL; + } +} + +/*****************************************************************************/ +// SDL Video and Display initialization/handling functions +/* _this is a SDL_VideoDevice * */ +/*****************************************************************************/ + +static bool KMSDRM_DropMaster(SDL_VideoDevice *_this) +{ + SDL_VideoData *viddata = _this->internal; + + /* Check if we have DRM master to begin with */ + if (KMSDRM_drmAuthMagic(viddata->drm_fd, 0) == -EACCES) { + /* Nope, nothing to do then */ + return true; + } + + return KMSDRM_drmDropMaster(viddata->drm_fd) == 0; +} + +// Deinitializes the internal of the SDL Displays in the SDL display list. +static void KMSDRM_DeinitDisplays(SDL_VideoDevice *_this) +{ + SDL_VideoData *viddata = _this->internal; + SDL_DisplayID *displays; + SDL_DisplayData *dispdata; + int i; + + displays = SDL_GetDisplays(NULL); + if (displays) { + // Iterate on the SDL Display list. + for (i = 0; displays[i]; ++i) { + + // Get the internal for this display + dispdata = SDL_GetDisplayDriverData(displays[i]); + + // Free connector + if (dispdata && dispdata->connector) { + KMSDRM_drmModeFreeConnector(dispdata->connector); + dispdata->connector = NULL; + } + + // Free CRTC + if (dispdata && dispdata->crtc) { + KMSDRM_drmModeFreeCrtc(dispdata->crtc); + dispdata->crtc = NULL; + } + } + SDL_free(displays); + } + + if (viddata->drm_fd >= 0) { + close(viddata->drm_fd); + viddata->drm_fd = -1; + } +} + +static uint32_t KMSDRM_CrtcGetPropId(uint32_t drm_fd, + drmModeObjectPropertiesPtr props, + char const *name) +{ + uint32_t i, prop_id = 0; + + for (i = 0; !prop_id && i < props->count_props; ++i) { + drmModePropertyPtr drm_prop = + KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); + + if (!drm_prop) { + continue; + } + + if (SDL_strcmp(drm_prop->name, name) == 0) { + prop_id = drm_prop->prop_id; + } + + KMSDRM_drmModeFreeProperty(drm_prop); + } + + return prop_id; +} + +static bool KMSDRM_VrrPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *vrr_prop_id) +{ + drmModeObjectPropertiesPtr drm_props; + + drm_props = KMSDRM_drmModeObjectGetProperties(drm_fd, + crtc_id, + DRM_MODE_OBJECT_CRTC); + + if (!drm_props) { + return false; + } + + *vrr_prop_id = KMSDRM_CrtcGetPropId(drm_fd, + drm_props, + "VRR_ENABLED"); + + KMSDRM_drmModeFreeObjectProperties(drm_props); + + return true; +} + +static bool KMSDRM_ConnectorCheckVrrCapable(uint32_t drm_fd, + uint32_t output_id, + char const *name) +{ + uint32_t i; + bool found = false; + uint64_t prop_value = 0; + + drmModeObjectPropertiesPtr props = KMSDRM_drmModeObjectGetProperties(drm_fd, + output_id, + DRM_MODE_OBJECT_CONNECTOR); + + if (!props) { + return false; + } + + for (i = 0; !found && i < props->count_props; ++i) { + drmModePropertyPtr drm_prop = KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); + + if (!drm_prop) { + continue; + } + + if (SDL_strcasecmp(drm_prop->name, name) == 0) { + prop_value = props->prop_values[i]; + found = true; + } + + KMSDRM_drmModeFreeProperty(drm_prop); + } + if (found) { + return prop_value ? true : false; + } + + return false; +} + +static void KMSDRM_CrtcSetVrr(uint32_t drm_fd, uint32_t crtc_id, bool enabled) +{ + uint32_t vrr_prop_id; + if (!KMSDRM_VrrPropId(drm_fd, crtc_id, &vrr_prop_id)) { + return; + } + + KMSDRM_drmModeObjectSetProperty(drm_fd, + crtc_id, + DRM_MODE_OBJECT_CRTC, + vrr_prop_id, + enabled); +} + +static bool KMSDRM_CrtcGetVrr(uint32_t drm_fd, uint32_t crtc_id) +{ + uint32_t object_prop_id, vrr_prop_id; + drmModeObjectPropertiesPtr props; + bool object_prop_value; + int i; + + if (!KMSDRM_VrrPropId(drm_fd, crtc_id, &vrr_prop_id)) { + return false; + } + + props = KMSDRM_drmModeObjectGetProperties(drm_fd, + crtc_id, + DRM_MODE_OBJECT_CRTC); + + if (!props) { + return false; + } + + for (i = 0; i < props->count_props; ++i) { + drmModePropertyPtr drm_prop = KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); + + if (!drm_prop) { + continue; + } + + object_prop_id = drm_prop->prop_id; + object_prop_value = props->prop_values[i] ? true : false; + + KMSDRM_drmModeFreeProperty(drm_prop); + + if (object_prop_id == vrr_prop_id) { + return object_prop_value; + } + } + return false; +} + +static bool KMSDRM_OrientationPropId(uint32_t drm_fd, uint32_t crtc_id, uint32_t *orientation_prop_id) +{ + drmModeObjectPropertiesPtr drm_props; + + drm_props = KMSDRM_drmModeObjectGetProperties(drm_fd, + crtc_id, + DRM_MODE_OBJECT_CONNECTOR); + + if (!drm_props) { + return false; + } + + *orientation_prop_id = KMSDRM_CrtcGetPropId(drm_fd, + drm_props, + "panel orientation"); + + KMSDRM_drmModeFreeObjectProperties(drm_props); + + return true; +} + +static int KMSDRM_CrtcGetOrientation(uint32_t drm_fd, uint32_t crtc_id) +{ + uint32_t orientation_prop_id; + drmModeObjectPropertiesPtr props; + int i; + bool done = false; + int orientation = 0; + + if (!KMSDRM_OrientationPropId(drm_fd, crtc_id, &orientation_prop_id)) { + return orientation; + } + + props = KMSDRM_drmModeObjectGetProperties(drm_fd, + crtc_id, + DRM_MODE_OBJECT_CONNECTOR); + + if (!props) { + return orientation; + } + + for (i = 0; i < props->count_props && !done; ++i) { + drmModePropertyPtr drm_prop = KMSDRM_drmModeGetProperty(drm_fd, props->props[i]); + + if (!drm_prop) { + continue; + } + + if (drm_prop->prop_id == orientation_prop_id && (drm_prop->flags & DRM_MODE_PROP_ENUM)) { + if (drm_prop->count_enums) { + // "Normal" is the default of no rotation (0 degrees) + if (SDL_strcmp(drm_prop->enums[0].name, "Left Side Up") == 0) { + orientation = 90; + } else if (SDL_strcmp(drm_prop->enums[0].name, "Upside Down") == 0) { + orientation = 180; + } else if (SDL_strcmp(drm_prop->enums[0].name, "Right Side Up") == 0) { + orientation = 270; + } + } + + done = true; + } + + KMSDRM_drmModeFreeProperty(drm_prop); + } + + KMSDRM_drmModeFreeObjectProperties(props); + + return orientation; +} + +/* Gets a DRM connector, builds an SDL_Display with it, and adds it to the + list of SDL Displays in _this->displays[] */ +static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connector, drmModeRes *resources) +{ + SDL_VideoData *viddata = _this->internal; + SDL_DisplayData *dispdata = NULL; + SDL_VideoDisplay display = { 0 }; + SDL_DisplayModeData *modedata = NULL; + drmModeEncoder *encoder = NULL; + drmModeCrtc *crtc = NULL; + const char *connector_type = NULL; + SDL_DisplayID display_id; + SDL_PropertiesID display_properties; + char name_fmt[64]; + int orientation; + int mode_index; + int i, j; + int ret = 0; + + // Reserve memory for the new display's internal. + dispdata = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); + if (!dispdata) { + ret = -1; + goto cleanup; + } + + /* Initialize some of the members of the new display's internal + to sane values. */ + dispdata->cursor_bo = NULL; + dispdata->cursor_bo_drm_fd = -1; + + /* Since we create and show the default cursor on KMSDRM_InitMouse(), + and we call KMSDRM_InitMouse() when we create a window, we have to know + if the display used by the window already has a default cursor or not. + If we don't, new default cursors would stack up on mouse->cursors and SDL + would have to hide and delete them at quit, not to mention the memory leak... */ + dispdata->default_cursor_init = false; + + // Try to find the connector's current encoder + for (i = 0; i < resources->count_encoders; i++) { + encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); + + if (!encoder) { + continue; + } + + if (encoder->encoder_id == connector->encoder_id) { + break; + } + + KMSDRM_drmModeFreeEncoder(encoder); + encoder = NULL; + } + + if (!encoder) { + // No encoder was connected, find the first supported one + for (i = 0; i < resources->count_encoders; i++) { + encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, + resources->encoders[i]); + + if (!encoder) { + continue; + } + + for (j = 0; j < connector->count_encoders; j++) { + if (connector->encoders[j] == encoder->encoder_id) { + break; + } + } + + if (j != connector->count_encoders) { + break; + } + + KMSDRM_drmModeFreeEncoder(encoder); + encoder = NULL; + } + } + + if (!encoder) { + ret = SDL_SetError("No connected encoder found for connector."); + goto cleanup; + } + + // Try to find a CRTC connected to this encoder + crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id); + + /* If no CRTC was connected to the encoder, find the first CRTC + that is supported by the encoder, and use that. */ + if (!crtc) { + for (i = 0; i < resources->count_crtcs; i++) { + if (encoder->possible_crtcs & (1 << i)) { + encoder->crtc_id = resources->crtcs[i]; + crtc = KMSDRM_drmModeGetCrtc(viddata->drm_fd, encoder->crtc_id); + break; + } + } + } + + if (!crtc) { + ret = SDL_SetError("No CRTC found for connector."); + goto cleanup; + } + + // Find the index of the mode attached to this CRTC + mode_index = -1; + + for (i = 0; i < connector->count_modes; i++) { + drmModeModeInfo *mode = &connector->modes[i]; + + if (!SDL_memcmp(mode, &crtc->mode, sizeof(crtc->mode))) { + mode_index = i; + break; + } + } + + if (mode_index == -1) { + int current_area, largest_area = 0; + + // Find the preferred mode or the highest resolution mode + for (i = 0; i < connector->count_modes; i++) { + drmModeModeInfo *mode = &connector->modes[i]; + + if (mode->type & DRM_MODE_TYPE_PREFERRED) { + mode_index = i; + break; + } + + current_area = mode->hdisplay * mode->vdisplay; + if (current_area > largest_area) { + mode_index = i; + largest_area = current_area; + } + } + if (mode_index != -1) { + crtc->mode = connector->modes[mode_index]; + } + } + + if (mode_index == -1) { + ret = SDL_SetError("Failed to find index of mode attached to the CRTC."); + goto cleanup; + } + + /*********************************************/ + // Create an SDL Display for this connector. + /*********************************************/ + + /*********************************************/ + // Part 1: setup the SDL_Display internal. + /*********************************************/ + + /* Get the mode currently setup for this display, + which is the mode currently setup on the CRTC + we found for the active connector. */ + dispdata->mode = crtc->mode; + dispdata->original_mode = crtc->mode; + dispdata->fullscreen_mode = crtc->mode; + + if (dispdata->mode.hdisplay == 0 || dispdata->mode.vdisplay == 0) { + ret = SDL_SetError("Couldn't get a valid connector videomode."); + goto cleanup; + } + + // Store the connector and crtc for this display. + dispdata->connector = connector; + dispdata->crtc = crtc; + + // save previous vrr state + dispdata->saved_vrr = KMSDRM_CrtcGetVrr(viddata->drm_fd, crtc->crtc_id); + // try to enable vrr + if (KMSDRM_ConnectorCheckVrrCapable(viddata->drm_fd, connector->connector_id, "VRR_CAPABLE")) { + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Enabling VRR"); + KMSDRM_CrtcSetVrr(viddata->drm_fd, crtc->crtc_id, true); + } + + // Set the name by the connector type, if possible + if (KMSDRM_drmModeGetConnectorTypeName) { + connector_type = KMSDRM_drmModeGetConnectorTypeName(connector->connector_type); + if (connector_type == NULL) { + connector_type = "Unknown"; + } + SDL_snprintf(name_fmt, sizeof(name_fmt), "%s-%u", connector_type, connector->connector_type_id); + } + + /*****************************************/ + // Part 2: setup the SDL_Display itself. + /*****************************************/ + + /* Setup the display. + There's no problem with it being still incomplete. */ + modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData)); + + if (!modedata) { + ret = -1; + goto cleanup; + } + + modedata->mode_index = mode_index; + + display.internal = dispdata; + display.desktop_mode.w = dispdata->mode.hdisplay; + display.desktop_mode.h = dispdata->mode.vdisplay; + CalculateRefreshRate(&dispdata->mode, &display.desktop_mode.refresh_rate_numerator, &display.desktop_mode.refresh_rate_denominator); + display.desktop_mode.format = SDL_PIXELFORMAT_ARGB8888; + display.desktop_mode.internal = modedata; + if (connector_type) { + display.name = name_fmt; + } + + // Add the display to the list of SDL displays. + display_id = SDL_AddVideoDisplay(&display, false); + if (!display_id) { + ret = -1; + goto cleanup; + } + + orientation = KMSDRM_CrtcGetOrientation(viddata->drm_fd, crtc->crtc_id); + display_properties = SDL_GetDisplayProperties(display_id); + SDL_SetNumberProperty(display_properties, SDL_PROP_DISPLAY_KMSDRM_PANEL_ORIENTATION_NUMBER, orientation); + +cleanup: + if (encoder) { + KMSDRM_drmModeFreeEncoder(encoder); + } + if (ret) { + // Error (complete) cleanup + if (dispdata) { + if (dispdata->connector) { + KMSDRM_drmModeFreeConnector(dispdata->connector); + dispdata->connector = NULL; + } + if (dispdata->crtc) { + KMSDRM_drmModeFreeCrtc(dispdata->crtc); + dispdata->crtc = NULL; + } + SDL_free(dispdata); + } + } +} // NOLINT(clang-analyzer-unix.Malloc): If no error `dispdata` is saved in the display + +static void KMSDRM_SortDisplays(SDL_VideoDevice *_this) +{ + const char *name_hint = SDL_GetHint(SDL_HINT_VIDEO_DISPLAY_PRIORITY); + + if (name_hint) { + char *saveptr; + char *str = SDL_strdup(name_hint); + SDL_VideoDisplay **sorted_list = SDL_malloc(sizeof(SDL_VideoDisplay *) * _this->num_displays); + + if (str && sorted_list) { + int sorted_index = 0; + + // Sort the requested displays to the front of the list. + const char *token = SDL_strtok_r(str, ",", &saveptr); + while (token) { + for (int i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *d = _this->displays[i]; + if (d && SDL_strcmp(token, d->name) == 0) { + sorted_list[sorted_index++] = d; + _this->displays[i] = NULL; + break; + } + } + + token = SDL_strtok_r(NULL, ",", &saveptr); + } + + // Append the remaining displays to the end of the list. + for (int i = 0; i < _this->num_displays; ++i) { + if (_this->displays[i]) { + sorted_list[sorted_index++] = _this->displays[i]; + } + } + + // Copy the sorted list back to the display list. + SDL_memcpy(_this->displays, sorted_list, sizeof(SDL_VideoDisplay *) * _this->num_displays); + } + + SDL_free(str); + SDL_free(sorted_list); + } +} + +/* Initializes the list of SDL displays: we build a new display for each + connecter connector we find. + This is to be called early, in VideoInit(), because it gets us + the videomode information, which SDL needs immediately after VideoInit(). */ +static bool KMSDRM_InitDisplays(SDL_VideoDevice *_this) +{ + + SDL_VideoData *viddata = _this->internal; + drmModeRes *resources = NULL; + uint64_t async_pageflip = 0; + int i; + bool result = true; + + // Open /dev/dri/cardNN (/dev/drmN if on OpenBSD version less than 6.9) + (void)SDL_snprintf(viddata->devpath, sizeof(viddata->devpath), "%s%d", + kmsdrm_dri_cardpath, viddata->devindex); + + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opening device %s", viddata->devpath); + viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC); + + if (viddata->drm_fd < 0) { + result = SDL_SetError("Could not open %s", viddata->devpath); + goto cleanup; + } + + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Opened DRM FD (%d)", viddata->drm_fd); + + // Get all of the available connectors / devices / crtcs + resources = KMSDRM_drmModeGetResources(viddata->drm_fd); + if (!resources) { + result = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd); + goto cleanup; + } + + /* Iterate on the available connectors. For every connected connector, + we create an SDL_Display and add it to the list of SDL Displays. */ + for (i = 0; i < resources->count_connectors; i++) { + drmModeConnector *connector = KMSDRM_drmModeGetConnector(viddata->drm_fd, + resources->connectors[i]); + + if (!connector) { + continue; + } + + if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes) { + /* If it's a connected connector with available videomodes, try to add + an SDL Display representing it. KMSDRM_AddDisplay() is purposely void, + so if it fails (no encoder for connector, no valid video mode for + connector etc...) we can keep looking for connected connectors. */ + KMSDRM_AddDisplay(_this, connector, resources); + } else { + // If it's not, free it now. + KMSDRM_drmModeFreeConnector(connector); + } + } + + // Have we added any SDL displays? + if (SDL_GetPrimaryDisplay() == 0) { + result = SDL_SetError("No connected displays found."); + goto cleanup; + } + + // Sort the displays, if necessary + KMSDRM_SortDisplays(_this); + + // Determine if video hardware supports async pageflips. + if (KMSDRM_drmGetCap(viddata->drm_fd, DRM_CAP_ASYNC_PAGE_FLIP, &async_pageflip) != 0) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not determine async page flip capability."); + } + viddata->async_pageflip_support = async_pageflip ? true : false; + + /***********************************/ + // Block for Vulkan compatibility. + /***********************************/ + + /* Vulkan requires DRM master on its own FD to work, so try to drop master + on our FD. This will only work without root on kernels v5.8 and later. + If it doesn't work, just close the FD and we'll reopen it later. */ + if (!KMSDRM_DropMaster(_this)) { + close(viddata->drm_fd); + viddata->drm_fd = -1; + } + +cleanup: + if (resources) { + KMSDRM_drmModeFreeResources(resources); + } + if (!result) { + if (viddata->drm_fd >= 0) { + close(viddata->drm_fd); + viddata->drm_fd = -1; + } + } + return result; +} + +/* Init the Vulkan-INCOMPATIBLE stuff: + Reopen FD, create gbm dev, create dumb buffer and setup display plane. + This is to be called late, in WindowCreate(), and ONLY if this is not + a Vulkan window. + We are doing this so late to allow Vulkan to work if we build a VK window. + These things are incompatible with Vulkan, which accesses the same resources + internally so they must be free when trying to build a Vulkan surface. +*/ +static bool KMSDRM_GBMInit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) +{ + SDL_VideoData *viddata = _this->internal; + bool result = true; + + // Reopen the FD if we weren't able to drop master on the original one + if (viddata->drm_fd < 0) { + viddata->drm_fd = open(viddata->devpath, O_RDWR | O_CLOEXEC); + if (viddata->drm_fd < 0) { + return SDL_SetError("Could not reopen %s", viddata->devpath); + } + } + + // Set the FD as current DRM master. + KMSDRM_drmSetMaster(viddata->drm_fd); + + // Create the GBM device. + viddata->gbm_dev = KMSDRM_gbm_create_device(viddata->drm_fd); + if (!viddata->gbm_dev) { + result = SDL_SetError("Couldn't create gbm device."); + } + + viddata->gbm_init = true; + + return result; +} + +// Deinit the Vulkan-incompatible KMSDRM stuff. +static void KMSDRM_GBMDeinit(SDL_VideoDevice *_this, SDL_DisplayData *dispdata) +{ + SDL_VideoData *viddata = _this->internal; + + /* Destroy GBM device. GBM surface is destroyed by DestroySurfaces(), + already called when we get here. */ + if (viddata->gbm_dev) { + KMSDRM_gbm_device_destroy(viddata->gbm_dev); + viddata->gbm_dev = NULL; + } + + /* Finally drop DRM master if possible, otherwise close DRM FD. + May be reopened on next non-vulkan window creation. */ + if (viddata->drm_fd >= 0 && !KMSDRM_DropMaster(_this)) { + close(viddata->drm_fd); + viddata->drm_fd = -1; + } + + viddata->gbm_init = false; +} + +static void KMSDRM_DestroySurfaces(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *viddata = _this->internal; + SDL_WindowData *windata = window->internal; + SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); + int ret; + + /**********************************************/ + // Wait for last issued pageflip to complete. + /**********************************************/ + // KMSDRM_WaitPageflip(_this, windata); + + /************************************************************************/ + // Restore the original CRTC configuration: configure the crtc with the + // original video mode and make it point to the original TTY buffer. + /************************************************************************/ + + ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id, + dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, + &dispdata->original_mode); + + // If we failed to set the original mode, try to set the connector preferred mode. + if (ret && (dispdata->crtc->mode_valid == 0)) { + ret = KMSDRM_drmModeSetCrtc(viddata->drm_fd, dispdata->crtc->crtc_id, + dispdata->crtc->buffer_id, 0, 0, &dispdata->connector->connector_id, 1, + &dispdata->original_mode); + } + + if (ret) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not restore CRTC"); + } + + /***************************/ + // Destroy the EGL surface + /***************************/ + + SDL_EGL_MakeCurrent(_this, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + if (windata->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_DestroySurface(_this, windata->egl_surface); + windata->egl_surface = EGL_NO_SURFACE; + } + + /***************************/ + // Destroy the GBM buffers + /***************************/ + + if (windata->bo) { + KMSDRM_gbm_surface_release_buffer(windata->gs, windata->bo); + windata->bo = NULL; + } + + if (windata->next_bo) { + KMSDRM_gbm_surface_release_buffer(windata->gs, windata->next_bo); + windata->next_bo = NULL; + } + + /***************************/ + // Destroy the GBM surface + /***************************/ + + if (windata->gs) { + KMSDRM_gbm_surface_destroy(windata->gs); + windata->gs = NULL; + } +} + +static void KMSDRM_GetModeToSet(SDL_Window *window, drmModeModeInfo *out_mode) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + SDL_DisplayData *dispdata = display->internal; + + if (window->fullscreen_exclusive) { + *out_mode = dispdata->fullscreen_mode; + } else { + drmModeModeInfo *mode = KMSDRM_GetClosestDisplayMode(display, window->windowed.w, window->windowed.h); + if (mode) { + *out_mode = *mode; + } else { + *out_mode = dispdata->original_mode; + } + } +} + +static void KMSDRM_DirtySurfaces(SDL_Window *window) +{ + SDL_WindowData *windata = window->internal; + drmModeModeInfo mode; + + /* Can't recreate EGL surfaces right now, need to wait until SwapWindow + so the correct thread-local surface and context state are available */ + windata->egl_surface_dirty = true; + + /* The app may be waiting for the resize event after calling SetWindowSize + or SetWindowFullscreen, send a fake event for now since the actual + recreation is deferred */ + KMSDRM_GetModeToSet(window, &mode); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, mode.hdisplay, mode.vdisplay); +} + +/* This determines the size of the fb, which comes from the GBM surface + that we create here. */ +bool KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *viddata = _this->internal; + SDL_WindowData *windata = window->internal; + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + SDL_DisplayData *dispdata = display->internal; + + uint32_t surface_fmt = GBM_FORMAT_ARGB8888; + uint32_t surface_flags = GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING; + + EGLContext egl_context; + + bool result = true; + + // If the current window already has surfaces, destroy them before creating other. + if (windata->gs) { + KMSDRM_DestroySurfaces(_this, window); + } + + if (!KMSDRM_gbm_device_is_format_supported(viddata->gbm_dev, + surface_fmt, surface_flags)) { + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "GBM surface format not supported. Trying anyway."); + } + + /* The KMSDRM backend doesn't always set the mode the higher-level code in + SDL_video.c expects. Hulk-smash the display's current_mode to keep the + mode that's set in sync with what SDL_video.c thinks is set + + FIXME: How do we do that now? Can we get a better idea at the higher level? + */ + KMSDRM_GetModeToSet(window, &dispdata->mode); + + windata->gs = KMSDRM_gbm_surface_create(viddata->gbm_dev, + dispdata->mode.hdisplay, dispdata->mode.vdisplay, + surface_fmt, surface_flags); + + if (!windata->gs) { + return SDL_SetError("Could not create GBM surface"); + } + + /* We can't get the EGL context yet because SDL_CreateRenderer has not been called, + but we need an EGL surface NOW, or GL won't be able to render into any surface + and we won't see the first frame. */ + SDL_EGL_SetRequiredVisualId(_this, surface_fmt); + windata->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)windata->gs); + + if (windata->egl_surface == EGL_NO_SURFACE) { + result = SDL_SetError("Could not create EGL window surface"); + goto cleanup; + } + + /* Current context passing to EGL is now done here. If something fails, + go back to delayed SDL_EGL_MakeCurrent() call in SwapWindow. */ + egl_context = (EGLContext)SDL_GL_GetCurrentContext(); + result = SDL_EGL_MakeCurrent(_this, windata->egl_surface, egl_context); + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, + dispdata->mode.hdisplay, dispdata->mode.vdisplay); + + windata->egl_surface_dirty = false; + +cleanup: + + if (!result) { + // Error (complete) cleanup. + if (windata->gs) { + KMSDRM_gbm_surface_destroy(windata->gs); + windata->gs = NULL; + } + } + + return result; +} + +#ifdef SDL_INPUT_LINUXEV +static void KMSDRM_ReleaseVT(void *userdata) +{ + SDL_VideoDevice *_this = (SDL_VideoDevice *)userdata; + SDL_VideoData *viddata = _this->internal; + int i; + + for (i = 0; i < viddata->num_windows; i++) { + SDL_Window *window = viddata->windows[i]; + if (!(window->flags & SDL_WINDOW_VULKAN)) { + KMSDRM_DestroySurfaces(_this, window); + } + } + KMSDRM_drmDropMaster(viddata->drm_fd); +} + +static void KMSDRM_AcquireVT(void *userdata) +{ + SDL_VideoDevice *_this = (SDL_VideoDevice *)userdata; + SDL_VideoData *viddata = _this->internal; + int i; + + KMSDRM_drmSetMaster(viddata->drm_fd); + for (i = 0; i < viddata->num_windows; i++) { + SDL_Window *window = viddata->windows[i]; + if (!(window->flags & SDL_WINDOW_VULKAN)) { + KMSDRM_CreateSurfaces(_this, window); + } + } +} +#endif // defined SDL_INPUT_LINUXEV + +bool KMSDRM_VideoInit(SDL_VideoDevice *_this) +{ + bool result = true; + + SDL_VideoData *viddata = _this->internal; + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "KMSDRM_VideoInit()"); + + viddata->video_init = false; + viddata->gbm_init = false; + + /* Get KMSDRM resources info and store what we need. Getting and storing + this info isn't a problem for VK compatibility. + For VK-incompatible initializations we have KMSDRM_GBMInit(), which is + called on window creation, and only when we know it's not a VK window. */ + if (!KMSDRM_InitDisplays(_this)) { + result = SDL_SetError("error getting KMSDRM displays information"); + } + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Init(); + SDL_EVDEV_SetVTSwitchCallbacks(KMSDRM_ReleaseVT, _this, KMSDRM_AcquireVT, _this); +#elif defined(SDL_INPUT_WSCONS) + SDL_WSCONS_Init(); +#endif + + viddata->video_init = true; + + return result; +} + +/* The internal pointers, like dispdata, viddata, windata, etc... + are freed by SDL internals, so not our job. */ +void KMSDRM_VideoQuit(SDL_VideoDevice *_this) +{ + SDL_VideoData *viddata = _this->internal; + + KMSDRM_DeinitDisplays(_this); + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_SetVTSwitchCallbacks(NULL, NULL, NULL, NULL); + SDL_EVDEV_Quit(); +#elif defined(SDL_INPUT_WSCONS) + SDL_WSCONS_Quit(); +#endif + + // Clear out the window list + SDL_free(viddata->windows); + viddata->windows = NULL; + viddata->max_windows = 0; + viddata->num_windows = 0; + viddata->video_init = false; +} + +// Read modes from the connector modes, and store them in display->display_modes. +bool KMSDRM_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayData *dispdata = display->internal; + drmModeConnector *conn = dispdata->connector; + SDL_DisplayMode mode; + int i; + + for (i = 0; i < conn->count_modes; i++) { + SDL_DisplayModeData *modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData)); + + if (modedata) { + modedata->mode_index = i; + } + + SDL_zero(mode); + mode.w = conn->modes[i].hdisplay; + mode.h = conn->modes[i].vdisplay; + CalculateRefreshRate(&conn->modes[i], &mode.refresh_rate_numerator, &mode.refresh_rate_denominator); + mode.format = SDL_PIXELFORMAT_ARGB8888; + mode.internal = modedata; + + if (!SDL_AddFullscreenDisplayMode(display, &mode)) { + SDL_free(modedata); + } + } + return true; +} + +bool KMSDRM_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + /* Set the dispdata->mode to the new mode and leave actual modesetting + pending to be done on SwapWindow() via drmModeSetCrtc() */ + + SDL_VideoData *viddata = _this->internal; + SDL_DisplayData *dispdata = display->internal; + SDL_DisplayModeData *modedata = mode->internal; + drmModeConnector *conn = dispdata->connector; + int i; + + // Don't do anything if we are in Vulkan mode. + if (viddata->vulkan_mode) { + return true; + } + + if (!modedata) { + return SDL_SetError("Mode doesn't have an associated index"); + } + + /* Take note of the new mode to be set, and leave the CRTC modeset pending + so it's done in SwapWindow. */ + dispdata->fullscreen_mode = conn->modes[modedata->mode_index]; + + for (i = 0; i < viddata->num_windows; i++) { + KMSDRM_DirtySurfaces(viddata->windows[i]); + } + + return true; +} + +void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *windata = window->internal; + SDL_DisplayData *dispdata = SDL_GetDisplayDriverDataForWindow(window); + SDL_VideoData *viddata; + bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; // Is this a VK window? + unsigned int i, j; + + if (!windata) { + return; + } + + // restore vrr state + KMSDRM_CrtcSetVrr(windata->viddata->drm_fd, dispdata->crtc->crtc_id, dispdata->saved_vrr); + + viddata = windata->viddata; + + if (!is_vulkan && viddata->gbm_init) { + + // Destroy cursor GBM BO of the display of this window. + KMSDRM_DestroyCursorBO(_this, SDL_GetVideoDisplayForWindow(window)); + + // Destroy GBM surface and buffers. + KMSDRM_DestroySurfaces(_this, window); + + /* Unload library and deinit GBM, but only if this is the last window. + Note that this is the right comparison because num_windows could be 1 + if there is a complete window, or 0 if we got here from SDL_CreateWindow() + because KMSDRM_CreateWindow() returned an error so the window wasn't + added to the windows list. */ + if (viddata->num_windows <= 1) { + + // Unload EGL/GL library and free egl_data. + if (_this->egl_data) { + SDL_EGL_UnloadLibrary(_this); + _this->gl_config.driver_loaded = 0; + } + + // Free display plane, and destroy GBM device. + KMSDRM_GBMDeinit(_this, dispdata); + } + + } else { + + // If we were in Vulkan mode, get out of it. + if (viddata->vulkan_mode) { + viddata->vulkan_mode = false; + } + } + + /********************************************/ + // Remove from the internal SDL window list + /********************************************/ + + for (i = 0; i < viddata->num_windows; i++) { + if (viddata->windows[i] == window) { + viddata->num_windows--; + + for (j = i; j < viddata->num_windows; j++) { + viddata->windows[j] = viddata->windows[j + 1]; + } + + break; + } + } + + /*********************************************************************/ + // Free the window internal. Bye bye, surface and buffer pointers! + /*********************************************************************/ + SDL_free(window->internal); + window->internal = NULL; +} + +/**********************************************************************/ +// We simply IGNORE if it's a fullscreen window, window->flags don't +// reflect it: if it's fullscreen, KMSDRM_SetWindwoFullscreen() will +// be called by SDL later, and we can manage it there. +/**********************************************************************/ +bool KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *windata = NULL; + SDL_VideoData *viddata = _this->internal; + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + SDL_DisplayData *dispdata = display->internal; + bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; // Is this a VK window? + bool vulkan_mode = viddata->vulkan_mode; // Do we have any Vulkan windows? + NativeDisplayType egl_display; + drmModeModeInfo *mode; + bool result = true; + + // Allocate window internal data + windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!windata) { + return false; + } + + // Setup driver data for this window + windata->viddata = viddata; + window->internal = windata; + + // Do we want a double buffering scheme to get low video lag? + windata->double_buffer = false; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, false)) { + windata->double_buffer = true; + } + + if (!is_vulkan && !vulkan_mode) { // NON-Vulkan block. + + /* Maybe you didn't ask for an OPENGL window, but that's what you will get. + See following comments on why. */ + window->flags |= SDL_WINDOW_OPENGL; + + if (!(viddata->gbm_init)) { + + /* After SDL_CreateWindow, most SDL programs will do SDL_CreateRenderer(), + which will in turn call GL_CreateRenderer() or GLES2_CreateRenderer(). + In order for the GL_CreateRenderer() or GLES2_CreateRenderer() call to + succeed without an unnecessary window re-creation, we must: + -Mark the window as being OPENGL + -Load the GL library (which can't be done until the GBM device has been + created, so we have to do it here instead of doing it on VideoInit()) + and mark it as loaded by setting gl_config.driver_loaded to 1. + So if you ever see KMSDRM_CreateWindow() to be called two times in tests, + don't be shy to debug GL_CreateRenderer() or GLES2_CreateRenderer() + to find out why! + */ + + /* Reopen FD, create gbm dev, setup display plane, etc,. + but only when we come here for the first time, + and only if it's not a VK window. */ + if (!KMSDRM_GBMInit(_this, dispdata)) { + return SDL_SetError("Can't init GBM on window creation."); + } + } + + /* Manually load the GL library. KMSDRM_EGL_LoadLibrary() has already + been called by SDL_CreateWindow() but we don't do anything there, + our KMSDRM_EGL_LoadLibrary() is a dummy precisely to be able to load it here. + If we let SDL_CreateWindow() load the lib, it would be loaded + before we call KMSDRM_GBMInit(), causing all GLES programs to fail. */ + if (!_this->egl_data) { + egl_display = (NativeDisplayType)_this->internal->gbm_dev; + if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) { + // Try again with OpenGL ES 2.0 + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 0; + if (!SDL_EGL_LoadLibrary(_this, NULL, egl_display, EGL_PLATFORM_GBM_MESA)) { + return SDL_SetError("Can't load EGL/GL library on window creation."); + } + } + + _this->gl_config.driver_loaded = 1; + } + + /* Create the cursor BO for the display of this window, + now that we know this is not a VK window. */ + KMSDRM_CreateCursorBO(display); + + /* Create and set the default cursor for the display + of this window, now that we know this is not a VK window. */ + KMSDRM_InitMouse(_this, display); + + /* The FULLSCREEN flags are cut out from window->flags at this point, + so we can't know if a window is fullscreen or not, hence all windows + are considered "windowed" at this point of their life. + If a window is fullscreen, SDL internals will call + KMSDRM_SetWindowFullscreen() to reconfigure it if necessary. */ + mode = KMSDRM_GetClosestDisplayMode(display, window->windowed.w, window->windowed.h); + + if (mode) { + dispdata->fullscreen_mode = *mode; + } else { + dispdata->fullscreen_mode = dispdata->original_mode; + } + + /* Create the window surfaces with the size we have just chosen. + Needs the window diverdata in place. */ + if (!KMSDRM_CreateSurfaces(_this, window)) { + return SDL_SetError("Can't window GBM/EGL surfaces on window creation."); + } + } // NON-Vulkan block ends. + + /* Add window to the internal list of tracked windows. Note, while it may + seem odd to support multiple fullscreen windows, some apps create an + extra window as a dummy surface when working with multiple contexts */ + if (viddata->num_windows >= viddata->max_windows) { + unsigned int new_max_windows = viddata->max_windows + 1; + SDL_Window **new_windows = (SDL_Window **)SDL_realloc(viddata->windows, + new_max_windows * sizeof(SDL_Window *)); + if (!new_windows) { + return false; + } + viddata->windows = new_windows; + viddata->max_windows = new_max_windows; + + } + + viddata->windows[viddata->num_windows++] = window; + + // If we have just created a Vulkan window, establish that we are in Vulkan mode now. + viddata->vulkan_mode = is_vulkan; + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_KMSDRM_DEVICE_INDEX_NUMBER, viddata->devindex); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_KMSDRM_DRM_FD_NUMBER, viddata->drm_fd); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_KMSDRM_GBM_DEVICE_POINTER, viddata->gbm_dev); + + /* Focus on the newly created window. + SDL_SetMouseFocus() also takes care of calling KMSDRM_ShowCursor() if necessary. */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + // Tell the app that the window has moved to top-left. + SDL_Rect display_bounds; + SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &display_bounds); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, display_bounds.x, display_bounds.y); + + /* Allocated windata will be freed in KMSDRM_DestroyWindow, + and KMSDRM_DestroyWindow() will be called by SDL_CreateWindow() + if we return error on any of the previous returns of the function. */ + return result; +} + +void KMSDRM_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +bool KMSDRM_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + return SDL_Unsupported(); +} +void KMSDRM_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *viddata = _this->internal; + if (!viddata->vulkan_mode) { + KMSDRM_DirtySurfaces(window); + } +} +SDL_FullscreenResult KMSDRM_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) +{ + SDL_VideoData *viddata = _this->internal; + if (!viddata->vulkan_mode) { + KMSDRM_DirtySurfaces(window); + } + return SDL_FULLSCREEN_SUCCEEDED; +} +void KMSDRM_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void KMSDRM_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void KMSDRM_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void KMSDRM_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void KMSDRM_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void KMSDRM_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} + +#endif // SDL_VIDEO_DRIVER_KMSDRM diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.h b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.h new file mode 100644 index 0000000..5bd2e9c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvideo.h @@ -0,0 +1,176 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_kmsdrmvideo_h +#define SDL_kmsdrmvideo_h + +#include "../SDL_sysvideo.h" + +#include +#include +#include +#include +#include +#include + +#ifndef DRM_FORMAT_MOD_INVALID +#define DRM_FORMAT_MOD_INVALID 0x00ffffffffffffffULL +#endif + +#ifndef DRM_MODE_FB_MODIFIERS +#define DRM_MODE_FB_MODIFIERS 2 +#endif + +#ifndef DRM_MODE_PAGE_FLIP_ASYNC +#define DRM_MODE_PAGE_FLIP_ASYNC 2 +#endif + +#ifndef DRM_MODE_OBJECT_CONNECTOR +#define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 +#endif + +#ifndef DRM_MODE_OBJECT_CRTC +#define DRM_MODE_OBJECT_CRTC 0xcccccccc +#endif + +#ifndef DRM_CAP_ASYNC_PAGE_FLIP +#define DRM_CAP_ASYNC_PAGE_FLIP 7 +#endif + +#ifndef DRM_CAP_CURSOR_WIDTH +#define DRM_CAP_CURSOR_WIDTH 8 +#endif + +#ifndef DRM_CAP_CURSOR_HEIGHT +#define DRM_CAP_CURSOR_HEIGHT 9 +#endif + +#ifndef GBM_FORMAT_ARGB8888 +#define GBM_FORMAT_ARGB8888 ((uint32_t)('A') | ((uint32_t)('R') << 8) | ((uint32_t)('2') << 16) | ((uint32_t)('4') << 24)) +#define GBM_BO_USE_CURSOR (1 << 1) +#define GBM_BO_USE_WRITE (1 << 3) +#define GBM_BO_USE_LINEAR (1 << 4) +#endif + +struct SDL_VideoData +{ + int devindex; // device index that was passed on creation + int drm_fd; // DRM file desc + char devpath[32]; // DRM dev path. + + struct gbm_device *gbm_dev; + + bool video_init; // Has VideoInit succeeded? + bool vulkan_mode; // Are we in Vulkan mode? One VK window is enough to be. + bool async_pageflip_support; // Does the hardware support async. pageflips? + + SDL_Window **windows; + int max_windows; + int num_windows; + + /* Even if we have several displays, we only have to + open 1 FD and create 1 gbm device. */ + bool gbm_init; + +}; + +struct SDL_DisplayModeData +{ + int mode_index; +}; + +struct SDL_DisplayData +{ + drmModeConnector *connector; + drmModeCrtc *crtc; + drmModeModeInfo mode; + drmModeModeInfo original_mode; + drmModeModeInfo fullscreen_mode; + + drmModeCrtc *saved_crtc; // CRTC to restore on quit + bool saved_vrr; + + /* DRM & GBM cursor stuff lives here, not in an SDL_Cursor's internal struct, + because setting/unsetting up these is done on window creation/destruction, + where we may not have an SDL_Cursor at all (so no SDL_Cursor internal). + There's only one cursor GBM BO because we only support one cursor. */ + struct gbm_bo *cursor_bo; + int cursor_bo_drm_fd; + uint64_t cursor_w, cursor_h; + + bool default_cursor_init; +}; + +struct SDL_WindowData +{ + SDL_VideoData *viddata; + /* SDL internals expect EGL surface to be here, and in KMSDRM the GBM surface is + what supports the EGL surface on the driver side, so all these surfaces and buffers + are expected to be here, in the struct pointed by SDL_Window internal pointer: + this one. So don't try to move these to dispdata! */ + struct gbm_surface *gs; + struct gbm_bo *bo; + struct gbm_bo *next_bo; + + bool waiting_for_flip; + bool double_buffer; + + EGLSurface egl_surface; + bool egl_surface_dirty; +}; + +typedef struct KMSDRM_FBInfo +{ + int drm_fd; // DRM file desc + uint32_t fb_id; // DRM framebuffer ID +} KMSDRM_FBInfo; + +// Helper functions +extern bool KMSDRM_CreateSurfaces(SDL_VideoDevice *_this, SDL_Window *window); +extern KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo); +extern KMSDRM_FBInfo *KMSDRM_FBFromBO2(SDL_VideoDevice *_this, struct gbm_bo *bo, int w, int h); +extern bool KMSDRM_WaitPageflip(SDL_VideoDevice *_this, SDL_WindowData *windata); + +/****************************************************************************/ +// SDL_VideoDevice functions declaration +/****************************************************************************/ + +// Display and window functions +extern bool KMSDRM_VideoInit(SDL_VideoDevice *_this); +extern void KMSDRM_VideoQuit(SDL_VideoDevice *_this); +extern bool KMSDRM_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool KMSDRM_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern bool KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void KMSDRM_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool KMSDRM_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void KMSDRM_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_FullscreenResult KMSDRM_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *_display, SDL_FullscreenOp fullscreen); +extern void KMSDRM_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void KMSDRM_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void KMSDRM_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void KMSDRM_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void KMSDRM_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void KMSDRM_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_kmsdrmvideo_h diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.c new file mode 100644 index 0000000..d58277b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -0,0 +1,520 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Manuel Alfayate Corchere . + * Based on Jacob Lifshay's SDL_x11vulkan.c. + */ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_KMSDRM) + +#include "../SDL_vulkan_internal.h" + +#include "SDL_kmsdrmvideo.h" +#include "SDL_kmsdrmdyn.h" +#include "SDL_kmsdrmvulkan.h" + +#include + +#ifdef SDL_PLATFORM_OPENBSD +#define DEFAULT_VULKAN "libvulkan.so" +#else +#define DEFAULT_VULKAN "libvulkan.so.1" +#endif + +bool KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 i, extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasDisplayExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan already loaded"); + } + + // Load the Vulkan library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + if (!path) { + path = DEFAULT_VULKAN; + } + + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + + if (!_this->vulkan_config.loader_handle) { + return false; + } + + SDL_strlcpy(_this->vulkan_config.loader_path, path, + SDL_arraysize(_this->vulkan_config.loader_path)); + + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + + if (!vkGetInstanceProcAddr) { + goto fail; + } + + _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + + if (!extensions) { + goto fail; + } + + for (i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasDisplayExtension = true; + } + } + + SDL_free(extensions); + + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else if (!hasDisplayExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_DISPLAY_EXTENSION_NAME "extension"); + goto fail; + } + + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void KMSDRM_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + } +} + +/*********************************************************************/ +// Here we can put whatever Vulkan extensions we want to be enabled +// at instance creation, which is done in the programs, not in SDL. +// So: programs call SDL_Vulkan_GetInstanceExtensions() and here +// we put the extensions specific to this backend so the programs +// get a list with the extension we want, so they can include that +// list in the ppEnabledExtensionNames and EnabledExtensionCount +// members of the VkInstanceCreateInfo struct passed to +// vkCreateInstance(). +/*********************************************************************/ +char const* const* KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ + static const char *const extensionsForKMSDRM[] = { + VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME + }; + if (count) { + *count = SDL_arraysize(extensionsForKMSDRM); + } + return extensionsForKMSDRM; +} + +/***********************************************************************/ +// First thing to know is that we don't call vkCreateInstance() here. +// Instead, programs using SDL and Vulkan create their Vulkan instance +// and we get it here, ready to use. +// Extensions specific for this platform are activated in +// KMSDRM_Vulkan_GetInstanceExtensions(), like we do with +// VK_KHR_DISPLAY_EXTENSION_NAME, which is what we need for x-less VK. +/***********************************************************************/ +bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + VkPhysicalDevice gpu = NULL; + uint32_t gpu_count; + uint32_t display_count; + uint32_t mode_count; + uint32_t plane_count; + uint32_t plane = UINT32_MAX; + + VkPhysicalDevice *physical_devices = NULL; + VkPhysicalDeviceProperties *device_props = NULL; + VkDisplayPropertiesKHR *display_props = NULL; + VkDisplayModePropertiesKHR *mode_props = NULL; + VkDisplayPlanePropertiesKHR *plane_props = NULL; + VkDisplayPlaneCapabilitiesKHR plane_caps; + + VkDisplayModeCreateInfoKHR display_mode_create_info; + VkDisplaySurfaceCreateInfoKHR display_plane_surface_create_info; + + VkExtent2D image_size; + VkDisplayKHR display; + VkDisplayModeKHR display_mode = (VkDisplayModeKHR)0; + VkDisplayModePropertiesKHR display_mode_props = { 0 }; + VkDisplayModeParametersKHR new_mode_parameters = { { 0, 0 }, 0 }; + // Prefer a plane that supports per-pixel alpha. + VkDisplayPlaneAlphaFlagBitsKHR alpha_mode = VK_DISPLAY_PLANE_ALPHA_OPAQUE_BIT_KHR; + + VkResult result; + bool ret = false; + bool valid_gpu = false; + bool mode_found = false; + bool plane_supports_display = false; + + // Get the display index from the display being used by the window. + int display_index = SDL_GetDisplayIndex(SDL_GetDisplayForWindow(window)); + int i, j; + + // Get the function pointers for the functions we will use. + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + + PFN_vkCreateDisplayPlaneSurfaceKHR vkCreateDisplayPlaneSurfaceKHR = + (PFN_vkCreateDisplayPlaneSurfaceKHR)vkGetInstanceProcAddr( + instance, "vkCreateDisplayPlaneSurfaceKHR"); + + PFN_vkEnumeratePhysicalDevices vkEnumeratePhysicalDevices = + (PFN_vkEnumeratePhysicalDevices)vkGetInstanceProcAddr( + instance, "vkEnumeratePhysicalDevices"); + + PFN_vkGetPhysicalDeviceProperties vkGetPhysicalDeviceProperties = + (PFN_vkGetPhysicalDeviceProperties)vkGetInstanceProcAddr( + instance, "vkGetPhysicalDeviceProperties"); + + PFN_vkGetPhysicalDeviceDisplayPropertiesKHR vkGetPhysicalDeviceDisplayPropertiesKHR = + (PFN_vkGetPhysicalDeviceDisplayPropertiesKHR)vkGetInstanceProcAddr( + instance, "vkGetPhysicalDeviceDisplayPropertiesKHR"); + + PFN_vkGetDisplayModePropertiesKHR vkGetDisplayModePropertiesKHR = + (PFN_vkGetDisplayModePropertiesKHR)vkGetInstanceProcAddr( + instance, "vkGetDisplayModePropertiesKHR"); + + PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR vkGetPhysicalDeviceDisplayPlanePropertiesKHR = + (PFN_vkGetPhysicalDeviceDisplayPlanePropertiesKHR)vkGetInstanceProcAddr( + instance, "vkGetPhysicalDeviceDisplayPlanePropertiesKHR"); + + PFN_vkGetDisplayPlaneSupportedDisplaysKHR vkGetDisplayPlaneSupportedDisplaysKHR = + (PFN_vkGetDisplayPlaneSupportedDisplaysKHR)vkGetInstanceProcAddr( + instance, "vkGetDisplayPlaneSupportedDisplaysKHR"); + + PFN_vkGetDisplayPlaneCapabilitiesKHR vkGetDisplayPlaneCapabilitiesKHR = + (PFN_vkGetDisplayPlaneCapabilitiesKHR)vkGetInstanceProcAddr( + instance, "vkGetDisplayPlaneCapabilitiesKHR"); + + PFN_vkCreateDisplayModeKHR vkCreateDisplayModeKHR = + (PFN_vkCreateDisplayModeKHR)vkGetInstanceProcAddr( + instance, "vkCreateDisplayModeKHR"); + + if (!_this->vulkan_config.loader_handle) { + SDL_SetError("Vulkan is not loaded"); + goto clean; + } + + /*************************************/ + // Block for vulkan surface creation + /*************************************/ + + /****************************************************************/ + // If we got vkCreateDisplayPlaneSurfaceKHR() pointer, it means + // that the VK_KHR_Display extension is active on the instance. + // That's the central extension we need for x-less VK! + /****************************************************************/ + if (!vkCreateDisplayPlaneSurfaceKHR) { + SDL_SetError(VK_KHR_DISPLAY_EXTENSION_NAME + " extension is not enabled in the Vulkan instance."); + goto clean; + } + + /* A GPU (or physical_device, in vkcube terms) is a physical GPU. + A machine with more than one video output doesn't need to have more than one GPU, + like the Pi4 which has 1 GPU and 2 video outputs. + Just in case, we test that the GPU we choose is Vulkan-capable. + If there are new reports about VK init failures, hardcode + gpu = physical_devices[0], instead of probing, and go with that. + */ + + // Get the physical device count. + vkEnumeratePhysicalDevices(instance, &gpu_count, NULL); + + if (gpu_count == 0) { + SDL_SetError("Vulkan can't find physical devices (gpus)."); + goto clean; + } + + // Get the physical devices. + physical_devices = SDL_malloc(sizeof(VkPhysicalDevice) * gpu_count); + device_props = SDL_malloc(sizeof(VkPhysicalDeviceProperties)); + vkEnumeratePhysicalDevices(instance, &gpu_count, physical_devices); + + // Iterate on the physical devices. + for (i = 0; i < gpu_count; i++) { + + // Get the physical device properties. + vkGetPhysicalDeviceProperties( + physical_devices[i], + device_props); + + // Is this device a real GPU that supports API version 1 at least? + if (device_props->apiVersion >= 1 && + (device_props->deviceType == 1 || device_props->deviceType == 2)) { + gpu = physical_devices[i]; + valid_gpu = true; + break; + } + } + + if (!valid_gpu) { + SDL_SetError("Vulkan can't find a valid physical device (gpu)."); + goto clean; + } + + /* A display is a video output. 1 GPU can have N displays. + Vulkan only counts the connected displays. + Get the display count of the GPU. */ + vkGetPhysicalDeviceDisplayPropertiesKHR(gpu, &display_count, NULL); + if (display_count == 0) { + SDL_SetError("Vulkan can't find any displays."); + goto clean; + } + + // Get the props of the displays of the physical device. + display_props = (VkDisplayPropertiesKHR *)SDL_malloc(display_count * sizeof(*display_props)); + vkGetPhysicalDeviceDisplayPropertiesKHR(gpu, + &display_count, + display_props); + + // Get the chosen display based on the display index. + display = display_props[display_index].display; + + // Get the list of the display videomodes. + vkGetDisplayModePropertiesKHR(gpu, + display, + &mode_count, NULL); + + if (mode_count == 0) { + SDL_SetError("Vulkan can't find any video modes for display %i (%s)", 0, + display_props[display_index].displayName); + goto clean; + } + + mode_props = (VkDisplayModePropertiesKHR *)SDL_malloc(mode_count * sizeof(*mode_props)); + vkGetDisplayModePropertiesKHR(gpu, + display, + &mode_count, mode_props); + + /* Get a video mode equal to the window size among the predefined ones, + if possible. + REMEMBER: We have to get a small enough videomode for the window size, + because videomode determines how big the scanout region is and we can't + scanout a region bigger than the window (we would be reading past the + buffer, and Vulkan would give us a confusing VK_ERROR_SURFACE_LOST_KHR). */ + for (i = 0; i < mode_count; i++) { + if (mode_props[i].parameters.visibleRegion.width == window->w && + mode_props[i].parameters.visibleRegion.height == window->h) { + display_mode_props = mode_props[i]; + mode_found = true; + break; + } + } + + if (mode_found && + display_mode_props.parameters.visibleRegion.width > 0 && + display_mode_props.parameters.visibleRegion.height > 0) { + // Found a suitable mode among the predefined ones. Use that. + display_mode = display_mode_props.displayMode; + } else { + + /* Couldn't find a suitable mode among the predefined ones, so try to create our own. + This won't work for some video chips atm (like Pi's VideoCore) so these are limited + to supported resolutions. Don't try to use "closest" resolutions either, because + those are often bigger than the window size, thus causing out-of-bunds scanout. */ + new_mode_parameters.visibleRegion.width = window->w; + new_mode_parameters.visibleRegion.height = window->h; + /* SDL (and DRM, if we look at drmModeModeInfo vrefresh) uses plain integer Hz for + display mode refresh rate, but Vulkan expects higher precision. */ + new_mode_parameters.refreshRate = (uint32_t)(window->current_fullscreen_mode.refresh_rate * 1000); + + SDL_zero(display_mode_create_info); + display_mode_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_MODE_CREATE_INFO_KHR; + display_mode_create_info.parameters = new_mode_parameters; + result = vkCreateDisplayModeKHR(gpu, + display, + &display_mode_create_info, + NULL, &display_mode); + if (result != VK_SUCCESS) { + SDL_SetError("Vulkan couldn't find a predefined mode for that window size and couldn't create a suitable mode."); + goto clean; + } + } + + // Just in case we get here without a display_mode. + if (!display_mode) { + SDL_SetError("Vulkan couldn't get a display mode."); + goto clean; + } + + // Get the list of the physical device planes. + vkGetPhysicalDeviceDisplayPlanePropertiesKHR(gpu, &plane_count, NULL); + if (plane_count == 0) { + SDL_SetError("Vulkan can't find any planes."); + goto clean; + } + plane_props = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * plane_count); + vkGetPhysicalDeviceDisplayPlanePropertiesKHR(gpu, &plane_count, plane_props); + + /* Iterate on the list of planes of the physical device + to find a plane that matches these criteria: + -It must be compatible with the chosen display + mode. + -It isn't currently bound to another display. + -It supports per-pixel alpha, if possible. */ + for (i = 0; i < plane_count; i++) { + + uint32_t supported_displays_count = 0; + VkDisplayKHR *supported_displays; + + // See if the plane is compatible with the current display. + vkGetDisplayPlaneSupportedDisplaysKHR(gpu, i, &supported_displays_count, NULL); + if (supported_displays_count == 0) { + // This plane doesn't support any displays. Continue to the next plane. + continue; + } + + // Get the list of displays supported by this plane. + supported_displays = (VkDisplayKHR *)SDL_malloc(sizeof(VkDisplayKHR) * supported_displays_count); + vkGetDisplayPlaneSupportedDisplaysKHR(gpu, i, + &supported_displays_count, supported_displays); + + /* The plane must be bound to the chosen display, or not in use. + If none of these is true, iterate to another plane. */ + if (!((plane_props[i].currentDisplay == display) || (plane_props[i].currentDisplay == VK_NULL_HANDLE))) { + continue; + } + + /* Iterate the list of displays supported by this plane + in order to find out if the chosen display is among them. */ + plane_supports_display = false; + for (j = 0; j < supported_displays_count; j++) { + if (supported_displays[j] == display) { + plane_supports_display = true; + break; + } + } + + // Free the list of displays supported by this plane. + if (supported_displays) { + SDL_free(supported_displays); + } + + // If the display is not supported by this plane, iterate to the next plane. + if (!plane_supports_display) { + continue; + } + + // Want a plane that supports the alpha mode we have chosen. + vkGetDisplayPlaneCapabilitiesKHR(gpu, display_mode, i, &plane_caps); + if (plane_caps.supportedAlpha == alpha_mode) { + // Yep, this plane is alright. + plane = i; + break; + } + } + + // If we couldn't find an appropriate plane, error out. + if (plane == UINT32_MAX) { + SDL_SetError("Vulkan couldn't find an appropriate plane."); + goto clean; + } + + /********************************************/ + // Let's finally create the Vulkan surface! + /********************************************/ + + image_size.width = window->w; + image_size.height = window->h; + + SDL_zero(display_plane_surface_create_info); + display_plane_surface_create_info.sType = VK_STRUCTURE_TYPE_DISPLAY_SURFACE_CREATE_INFO_KHR; + display_plane_surface_create_info.displayMode = display_mode; + display_plane_surface_create_info.planeIndex = plane; + display_plane_surface_create_info.imageExtent = image_size; + display_plane_surface_create_info.transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; + display_plane_surface_create_info.alphaMode = alpha_mode; + result = vkCreateDisplayPlaneSurfaceKHR(instance, + &display_plane_surface_create_info, + allocator, + surface); + if (result != VK_SUCCESS) { + SDL_SetError("vkCreateDisplayPlaneSurfaceKHR failed: %s", + SDL_Vulkan_GetResultString(result)); + goto clean; + } + + ret = true; // success! + +clean: + if (physical_devices) { + SDL_free(physical_devices); + } + if (display_props) { + SDL_free(display_props); + } + if (device_props) { + SDL_free(device_props); + } + if (plane_props) { + SDL_free(plane_props); + } + if (mode_props) { + SDL_free(mode_props); + } + + return ret; +} + +void KMSDRM_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.h b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.h new file mode 100644 index 0000000..aabfd92 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/kmsdrm/SDL_kmsdrmvulkan.h @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Manuel Alfayate Corchere . + * Based on Jacob Lifshay's SDL_x11vulkan.c. + */ + +#include "SDL_internal.h" + +#ifndef SDL_kmsdrm_vulkan_h_ +#define SDL_kmsdrm_vulkan_h_ + +#include + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_KMSDRM) + +extern bool KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void KMSDRM_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* KMSDRM_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool KMSDRM_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void KMSDRM_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); + +#endif + +#endif // SDL_kmsdrm_vulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents.c b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents.c new file mode 100644 index 0000000..3d5e0e3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents.c @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_N3DS + +#include <3ds.h> + +#include "../../events/SDL_events_c.h" +#include "SDL_n3dsevents_c.h" +#include "SDL_n3dstouch.h" + +void N3DS_PumpEvents(SDL_VideoDevice *_this) +{ + hidScanInput(); + N3DS_PollTouch(_this); + + if (!aptMainLoop()) { + SDL_Event ev; + ev.type = SDL_EVENT_QUIT; + ev.common.timestamp = 0; + SDL_PushEvent(&ev); + return; + } +} + +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents_c.h b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents_c.h new file mode 100644 index 0000000..898fbb2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsevents_c.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_n3dsevents_c_h_ +#define SDL_n3dsevents_c_h_ + +#include "SDL_internal.h" + +extern void N3DS_PumpEvents(SDL_VideoDevice *_this); + +#endif // SDL_n3dsevents_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer.c b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer.c new file mode 100644 index 0000000..d632545 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer.c @@ -0,0 +1,161 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_N3DS + +#include "../SDL_sysvideo.h" +#include "../../SDL_properties_c.h" +#include "SDL_n3dsframebuffer_c.h" +#include "SDL_n3dsvideo.h" + +#define N3DS_SURFACE "SDL.internal.window.surface" + +typedef struct +{ + int width, height; +} Dimensions; + +static void CopyFramebuffertoN3DS_16(u16 *dest, const Dimensions dest_dim, const u16 *source, const Dimensions source_dim); +static void CopyFramebuffertoN3DS_24(u8 *dest, const Dimensions dest_dim, const u8 *source, const Dimensions source_dim); +static void CopyFramebuffertoN3DS_32(u32 *dest, const Dimensions dest_dim, const u32 *source, const Dimensions source_dim); +static int GetDestOffset(int x, int y, int dest_width); +static int GetSourceOffset(int x, int y, int source_width); +static void FlushN3DSBuffer(const void *buffer, u32 bufsize, gfxScreen_t screen); + + +bool SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_Surface *framebuffer; + const SDL_DisplayMode *mode; + int w, h; + + SDL_N3DS_DestroyWindowFramebuffer(_this, window); + + mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window)); + SDL_GetWindowSizeInPixels(window, &w, &h); + framebuffer = SDL_CreateSurface(w, h, mode->format); + + if (!framebuffer) { + return false; + } + + SDL_SetSurfaceProperty(SDL_GetWindowProperties(window), N3DS_SURFACE, framebuffer); + *format = mode->format; + *pixels = framebuffer->pixels; + *pitch = framebuffer->pitch; + return true; +} + +bool SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_WindowData *drv_data = window->internal; + SDL_Surface *surface; + u16 width, height; + void *framebuffer; + u32 bufsize; + + surface = (SDL_Surface *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), N3DS_SURFACE, NULL); + if (!surface) { + return SDL_SetError("%s: Unable to get the window surface.", __func__); + } + + // Get the N3DS internal framebuffer and its size + framebuffer = gfxGetFramebuffer(drv_data->screen, GFX_LEFT, &width, &height); + bufsize = width * height * 4; + + if (SDL_BYTESPERPIXEL(surface->format) == 2) + CopyFramebuffertoN3DS_16(framebuffer, (Dimensions){ width, height }, + surface->pixels, (Dimensions){ surface->w, surface->h }); + else if (SDL_BYTESPERPIXEL(surface->format) == 3) + CopyFramebuffertoN3DS_24(framebuffer, (Dimensions){ width, height }, + surface->pixels, (Dimensions){ surface->w, surface->h }); + else + CopyFramebuffertoN3DS_32(framebuffer, (Dimensions){ width, height }, + surface->pixels, (Dimensions){ surface->w, surface->h }); + FlushN3DSBuffer(framebuffer, bufsize, drv_data->screen); + + return true; +} + +static void CopyFramebuffertoN3DS_16(u16 *dest, const Dimensions dest_dim, const u16 *source, const Dimensions source_dim) +{ + int rows = SDL_min(dest_dim.width, source_dim.height); + int cols = SDL_min(dest_dim.height, source_dim.width); + for (int y = 0; y < rows; ++y) { + for (int x = 0; x < cols; ++x) { + const u16 *s = source + GetSourceOffset(x, y, source_dim.width); + u16 *d = dest + GetDestOffset(x, y, dest_dim.width); + *d = *s; + } + } +} + +static void CopyFramebuffertoN3DS_24(u8 *dest, const Dimensions dest_dim, const u8 *source, const Dimensions source_dim) +{ + int rows = SDL_min(dest_dim.width, source_dim.height); + int cols = SDL_min(dest_dim.height, source_dim.width); + for (int y = 0; y < rows; ++y) { + for (int x = 0; x < cols; ++x) { + const u8 *s = source + GetSourceOffset(x, y, source_dim.width) * 3; + u8 *d = dest + GetDestOffset(x, y, dest_dim.width) * 3; + d[0] = s[0]; + d[1] = s[1]; + d[2] = s[2]; + } + } +} + +static void CopyFramebuffertoN3DS_32(u32 *dest, const Dimensions dest_dim, const u32 *source, const Dimensions source_dim) +{ + int rows = SDL_min(dest_dim.width, source_dim.height); + int cols = SDL_min(dest_dim.height, source_dim.width); + for (int y = 0; y < rows; ++y) { + for (int x = 0; x < cols; ++x) { + const u32 *s = source + GetSourceOffset(x, y, source_dim.width); + u32 *d = dest + GetDestOffset(x, y, dest_dim.width); + *d = *s; + } + } +} + +static int GetDestOffset(int x, int y, int dest_width) +{ + return dest_width - y - 1 + dest_width * x; +} + +static int GetSourceOffset(int x, int y, int source_width) +{ + return x + y * source_width; +} + +static void FlushN3DSBuffer(const void *buffer, u32 bufsize, gfxScreen_t screen) +{ + GSPGPU_FlushDataCache(buffer, bufsize); + gfxScreenSwapBuffers(screen, false); +} + +void SDL_N3DS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_ClearProperty(SDL_GetWindowProperties(window), N3DS_SURFACE); +} + +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer_c.h b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer_c.h new file mode 100644 index 0000000..d442add --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsframebuffer_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_n3dsframebuffer_c_h_ +#define SDL_n3dsframebuffer_c_h_ + +#include "SDL_internal.h" + +extern bool SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_N3DS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_n3dsframebuffer_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.c b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.c new file mode 100644 index 0000000..95f0466 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.c @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_N3DS + +#include <3ds.h> + +#include "SDL_n3dsswkb.h" + +static SwkbdState sw_keyboard; +const static size_t BUFFER_SIZE = 256; + +void N3DS_SwkbInit(void) +{ + swkbdInit(&sw_keyboard, SWKBD_TYPE_NORMAL, 2, -1); +} + +void N3DS_SwkbPoll(void) +{ + return; +} + +void N3DS_SwkbQuit(void) +{ + return; +} + +bool N3DS_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + return true; +} + +bool N3DS_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + char buffer[BUFFER_SIZE]; + SwkbdButton button_pressed; + button_pressed = swkbdInputText(&sw_keyboard, buffer, BUFFER_SIZE); + if (button_pressed == SWKBD_BUTTON_CONFIRM) { + SDL_SendKeyboardText(buffer); + } + return true; +} + +bool N3DS_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + return true; +} + +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.h b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.h new file mode 100644 index 0000000..8857c00 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsswkb.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_n3dskeyboard_h_ +#define SDL_n3dskeyboard_h_ + +#include "../../events/SDL_events_c.h" + +void N3DS_SwkbInit(); +void N3DS_SwkbPoll(); +void N3DS_SwkbQuit(); + +bool N3DS_HasScreenKeyboardSupport(SDL_VideoDevice *_this); + +bool N3DS_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +bool N3DS_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_n3dskeyboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.c b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.c new file mode 100644 index 0000000..8116e4a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.c @@ -0,0 +1,86 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_N3DS + +#include <3ds.h> + +#include "../../events/SDL_touch_c.h" +#include "../SDL_sysvideo.h" +#include "SDL_n3dstouch.h" +#include "SDL_n3dsvideo.h" + +#define N3DS_TOUCH_ID 1 +#define N3DS_TOUCH_FINGER 1 + +/* + Factors used to convert touchscreen coordinates to + SDL's 0-1 values. Note that the N3DS's screen is + internally in a portrait disposition so the + GSP_SCREEN constants are flipped. +*/ +#define TOUCHSCREEN_SCALE_X 1.0f / (GSP_SCREEN_HEIGHT_BOTTOM - 1) +#define TOUCHSCREEN_SCALE_Y 1.0f / (GSP_SCREEN_WIDTH - 1) + +void N3DS_InitTouch(void) +{ + SDL_AddTouch(N3DS_TOUCH_ID, SDL_TOUCH_DEVICE_DIRECT, "Touchscreen"); +} + +void N3DS_QuitTouch(void) +{ + SDL_DelTouch(N3DS_TOUCH_ID); +} + +void N3DS_PollTouch(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = (SDL_VideoData *)_this->internal; + touchPosition touch; + SDL_Window *window; + SDL_VideoDisplay *display; + static bool was_pressed = false; + bool pressed; + hidTouchRead(&touch); + pressed = (touch.px != 0 || touch.py != 0); + + display = SDL_GetVideoDisplay(internal->touch_display); + window = display ? display->fullscreen_window : NULL; + + if (pressed != was_pressed) { + was_pressed = pressed; + SDL_SendTouch(0, N3DS_TOUCH_ID, N3DS_TOUCH_FINGER, + window, + pressed ? SDL_EVENT_FINGER_DOWN : SDL_EVENT_FINGER_UP, + touch.px * TOUCHSCREEN_SCALE_X, + touch.py * TOUCHSCREEN_SCALE_Y, + pressed ? 1.0f : 0.0f); + } else if (pressed) { + SDL_SendTouchMotion(0, N3DS_TOUCH_ID, N3DS_TOUCH_FINGER, + window, + touch.px * TOUCHSCREEN_SCALE_X, + touch.py * TOUCHSCREEN_SCALE_Y, + 1.0f); + } +} + +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.h b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.h new file mode 100644 index 0000000..7dac5a8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dstouch.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_n3dstouch_h_ +#define SDL_n3dstouch_h_ + +void N3DS_InitTouch(void); +void N3DS_QuitTouch(void); +void N3DS_PollTouch(SDL_VideoDevice *_this); + +#endif // SDL_n3dstouch_h_ diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.c b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.c new file mode 100644 index 0000000..8e925bf --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.c @@ -0,0 +1,259 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_N3DS + +#include "../SDL_sysvideo.h" +#include "SDL_n3dsevents_c.h" +#include "SDL_n3dsframebuffer_c.h" +#include "SDL_n3dsswkb.h" +#include "SDL_n3dstouch.h" +#include "SDL_n3dsvideo.h" + +#define N3DSVID_DRIVER_NAME "n3ds" + +static bool AddN3DSDisplay(gfxScreen_t screen); + +static bool N3DS_VideoInit(SDL_VideoDevice *_this); +static void N3DS_VideoQuit(SDL_VideoDevice *_this); +static bool N3DS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +static bool N3DS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +static bool N3DS_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); +static bool N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +static void N3DS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +struct SDL_DisplayData +{ + gfxScreen_t screen; +}; + +struct SDL_DisplayModeData +{ + GSPGPU_FramebufferFormat fmt; +}; + +static const struct +{ + SDL_PixelFormat pixfmt; + GSPGPU_FramebufferFormat gspfmt; +} format_map[] = { + { SDL_PIXELFORMAT_RGBA8888, GSP_RGBA8_OES }, + { SDL_PIXELFORMAT_BGR24, GSP_BGR8_OES }, + { SDL_PIXELFORMAT_RGB565, GSP_RGB565_OES }, + { SDL_PIXELFORMAT_RGBA5551, GSP_RGB5_A1_OES }, + { SDL_PIXELFORMAT_RGBA4444, GSP_RGBA4_OES } +}; + +// N3DS driver bootstrap functions + +static void N3DS_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *N3DS_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Initialize internal data + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!phdata) { + SDL_free(device); + return NULL; + } + + device->internal = phdata; + + device->VideoInit = N3DS_VideoInit; + device->VideoQuit = N3DS_VideoQuit; + + device->GetDisplayModes = N3DS_GetDisplayModes; + device->SetDisplayMode = N3DS_SetDisplayMode; + device->GetDisplayBounds = N3DS_GetDisplayBounds; + + device->CreateSDLWindow = N3DS_CreateWindow; + device->DestroyWindow = N3DS_DestroyWindow; + + device->HasScreenKeyboardSupport = N3DS_HasScreenKeyboardSupport; + device->StartTextInput = N3DS_StartTextInput; + device->StopTextInput = N3DS_StopTextInput; + + device->PumpEvents = N3DS_PumpEvents; + + device->CreateWindowFramebuffer = SDL_N3DS_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = SDL_N3DS_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = SDL_N3DS_DestroyWindowFramebuffer; + + device->free = N3DS_DeleteDevice; + + device->device_caps = VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY; + + return device; +} + +VideoBootStrap N3DS_bootstrap = { N3DSVID_DRIVER_NAME, "N3DS Video Driver", N3DS_CreateDevice, NULL, /* no ShowMessageBox implementation */ false }; + +static bool N3DS_VideoInit(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = (SDL_VideoData *)_this->internal; + + gfxInit(GSP_RGBA8_OES, GSP_RGBA8_OES, false); + hidInit(); + + internal->top_display = AddN3DSDisplay(GFX_TOP); + internal->touch_display = AddN3DSDisplay(GFX_BOTTOM); + + N3DS_InitTouch(); + N3DS_SwkbInit(); + + return true; +} + +static bool AddN3DSDisplay(gfxScreen_t screen) +{ + SDL_DisplayMode mode; + SDL_DisplayModeData *modedata; + SDL_VideoDisplay display; + SDL_DisplayData *display_driver_data = SDL_calloc(1, sizeof(SDL_DisplayData)); + if (!display_driver_data) { + return false; + } + + SDL_zero(mode); + SDL_zero(display); + + display_driver_data->screen = screen; + + modedata = SDL_malloc(sizeof(SDL_DisplayModeData)); + if (!modedata) { + return false; + } + + mode.w = (screen == GFX_TOP) ? GSP_SCREEN_HEIGHT_TOP : GSP_SCREEN_HEIGHT_BOTTOM; + mode.h = GSP_SCREEN_WIDTH; + mode.refresh_rate = 60.0f; + mode.format = SDL_PIXELFORMAT_RGBA8888; + mode.internal = modedata; + modedata->fmt = GSP_RGBA8_OES; + + display.name = (screen == GFX_TOP) ? "N3DS top screen" : "N3DS bottom screen"; + display.desktop_mode = mode; + display.internal = display_driver_data; + + if (SDL_AddVideoDisplay(&display, false) == 0) { + return false; + } + return true; +} + +static void N3DS_VideoQuit(SDL_VideoDevice *_this) +{ + N3DS_SwkbQuit(); + N3DS_QuitTouch(); + + hidExit(); + gfxExit(); +} + +static bool N3DS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayData *displaydata = display->internal; + SDL_DisplayModeData *modedata; + SDL_DisplayMode mode; + int i; + + for (i = 0; i < SDL_arraysize(format_map); i++) { + modedata = SDL_malloc(sizeof(SDL_DisplayModeData)); + if (!modedata) + continue; + + SDL_zero(mode); + mode.w = (displaydata->screen == GFX_TOP) ? GSP_SCREEN_HEIGHT_TOP : GSP_SCREEN_HEIGHT_BOTTOM; + mode.h = GSP_SCREEN_WIDTH; + mode.refresh_rate = 60.0f; + mode.format = format_map[i].pixfmt; + mode.internal = modedata; + modedata->fmt = format_map[i].gspfmt; + + if (!SDL_AddFullscreenDisplayMode(display, &mode)) { + SDL_free(modedata); + } + } + + return true; +} + +static bool N3DS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + SDL_DisplayData *displaydata = display->internal; + SDL_DisplayModeData *modedata = mode->internal; + + gfxSetScreenFormat(displaydata->screen, modedata->fmt); + return true; +} + +static bool N3DS_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + SDL_DisplayData *driver_data = display->internal; + + if (!driver_data) { + return false; + } + + rect->x = 0; + rect->y = (driver_data->screen == GFX_TOP) ? 0 : GSP_SCREEN_WIDTH; + rect->w = display->current_mode->w; + rect->h = display->current_mode->h; + return true; +} + +static bool N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_DisplayData *display_data; + SDL_WindowData *window_data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!window_data) { + return false; + } + display_data = SDL_GetDisplayDriverDataForWindow(window); + window_data->screen = display_data->screen; + window->internal = window_data; + SDL_SetKeyboardFocus(window); + return true; +} + +static void N3DS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (!window) { + return; + } + SDL_free(window->internal); +} + +#endif // SDL_VIDEO_DRIVER_N3DS diff --git a/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.h b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.h new file mode 100644 index 0000000..14b70e9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/n3ds/SDL_n3dsvideo.h @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_n3dsvideo_h_ +#define SDL_n3dsvideo_h_ + +#include <3ds.h> + +#include "../SDL_sysvideo.h" + +struct SDL_VideoData +{ + int top_display; + int touch_display; +}; + +struct SDL_WindowData +{ + gfxScreen_t screen; /**< Keeps track of which N3DS screen is targeted */ +}; + +#endif // SDL_n3dsvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents.c b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents.c new file mode 100644 index 0000000..256d1a2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents.c @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN + +/* Being a offscreen driver, there's no event stream. We just define stubs for + most of the API. */ + +#include "../../events/SDL_events_c.h" + +#include "SDL_offscreenvideo.h" +#include "SDL_offscreenevents_c.h" + +void OFFSCREEN_PumpEvents(SDL_VideoDevice *_this) +{ + // do nothing. +} + +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents_c.h b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents_c.h new file mode 100644 index 0000000..c06213c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenevents_c.h @@ -0,0 +1,23 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +extern void OFFSCREEN_PumpEvents(SDL_VideoDevice *_this); diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer.c b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer.c new file mode 100644 index 0000000..e7f6103 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer.c @@ -0,0 +1,79 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN + +#include "../SDL_sysvideo.h" +#include "../../SDL_properties_c.h" +#include "SDL_offscreenframebuffer_c.h" + +#define OFFSCREEN_SURFACE "SDL.internal.window.surface" + + +bool SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_Surface *surface; + const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB8888; + int w, h; + + // Create a new framebuffer + SDL_GetWindowSizeInPixels(window, &w, &h); + surface = SDL_CreateSurface(w, h, surface_format); + if (!surface) { + return false; + } + + // Save the info and return! + SDL_SetSurfaceProperty(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE, surface); + *format = surface_format; + *pixels = surface->pixels; + *pitch = surface->pitch; + + return true; +} + +bool SDL_OFFSCREEN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + static int frame_number; + SDL_Surface *surface; + + surface = (SDL_Surface *)SDL_GetPointerProperty(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE, NULL); + if (!surface) { + return SDL_SetError("Couldn't find offscreen surface for window"); + } + + // Send the data to the display + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_OFFSCREEN_SAVE_FRAMES, false)) { + char file[128]; + (void)SDL_snprintf(file, sizeof(file), "SDL_window%" SDL_PRIu32 "-%8.8d.bmp", + SDL_GetWindowID(window), ++frame_number); + SDL_SaveBMP(surface, file); + } + return true; +} + +void SDL_OFFSCREEN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_ClearProperty(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE); +} + +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer_c.h b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer_c.h new file mode 100644 index 0000000..ff39ad6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenframebuffer_c.h @@ -0,0 +1,25 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +extern bool SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool SDL_OFFSCREEN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void SDL_OFFSCREEN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.c b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.c new file mode 100644 index 0000000..87eed0e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.c @@ -0,0 +1,82 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_OFFSCREEN) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "SDL_offscreenopengles.h" +#include "SDL_offscreenvideo.h" +#include "SDL_offscreenwindow.h" + +// EGL implementation of SDL OpenGL support + +bool OFFSCREEN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + if (!SDL_EGL_LoadLibraryOnly(_this, path)) { + return false; + } + + /* driver_loaded gets incremented by SDL_GL_LoadLibrary when we return, + but SDL_EGL_InitializeOffscreen checks that we're loaded before then, + so temporarily bump it since we know that LoadLibraryOnly succeeded. */ + bool result; + _this->gl_config.driver_loaded++; + result = SDL_EGL_InitializeOffscreen(_this, 0); + _this->gl_config.driver_loaded--; + if (!result) { + return false; + } + + if (!SDL_EGL_ChooseConfig(_this)) { + return false; + } + + return true; +} + +SDL_GLContext OFFSCREEN_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *offscreen_window = window->internal; + + SDL_GLContext context; + context = SDL_EGL_CreateContext(_this, offscreen_window->egl_surface); + + return context; +} + +bool OFFSCREEN_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + if (window) { + EGLSurface egl_surface = window->internal->egl_surface; + return SDL_EGL_MakeCurrent(_this, egl_surface, context); + } else { + return SDL_EGL_MakeCurrent(_this, NULL, NULL); + } +} + +bool OFFSCREEN_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *offscreen_wind = window->internal; + + return SDL_EGL_SwapBuffers(_this, offscreen_wind->egl_surface); +} + +#endif // SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.h b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.h new file mode 100644 index 0000000..d6dfc0a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenopengles.h @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_offscreenopengles_h +#define SDL_offscreenopengles_h + +#if defined(SDL_VIDEO_DRIVER_OFFSCREEN) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +#define OFFSCREEN_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define OFFSCREEN_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define OFFSCREEN_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define OFFSCREEN_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define OFFSCREEN_GLES_DestroyContext SDL_EGL_DestroyContext + +extern bool OFFSCREEN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_GLContext OFFSCREEN_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool OFFSCREEN_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool OFFSCREEN_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_OPENGL_EGL + +#endif // SDL_offscreenopengles_h diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.c b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.c new file mode 100644 index 0000000..1ef0f9e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.c @@ -0,0 +1,151 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN + +/* Offscreen video driver is similar to dummy driver, however its purpose + * is enabling applications to use some of the SDL video functionality + * (notably context creation) while not requiring a display output. + * + * An example would be running a graphical program on a headless box + * for automated testing. + */ + +#include "SDL_offscreenvideo.h" +#include "SDL_offscreenevents_c.h" +#include "SDL_offscreenframebuffer_c.h" +#include "SDL_offscreenopengles.h" +#include "SDL_offscreenvulkan.h" +#include "SDL_offscreenwindow.h" + +#define OFFSCREENVID_DRIVER_NAME "offscreen" + +// Initialization/Query functions +static bool OFFSCREEN_VideoInit(SDL_VideoDevice *_this); +static bool OFFSCREEN_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +static void OFFSCREEN_VideoQuit(SDL_VideoDevice *_this); + +// OFFSCREEN driver bootstrap functions + +static void OFFSCREEN_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device); +} + +static bool OFFSCREEN_Available(const char *enable_hint) +{ + const char *hint = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); + if (hint) { + if (SDL_strcmp(hint, enable_hint) == 0) { + return true; + } + } + return false; +} + +static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) +{ + SDL_VideoDevice *device; + + if (!OFFSCREEN_Available(OFFSCREENVID_DRIVER_NAME)) { + return NULL; + } + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // General video + device->VideoInit = OFFSCREEN_VideoInit; + device->VideoQuit = OFFSCREEN_VideoQuit; + device->SetDisplayMode = OFFSCREEN_SetDisplayMode; + device->PumpEvents = OFFSCREEN_PumpEvents; + device->CreateWindowFramebuffer = SDL_OFFSCREEN_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = SDL_OFFSCREEN_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = SDL_OFFSCREEN_DestroyWindowFramebuffer; + device->free = OFFSCREEN_DeleteDevice; + +#ifdef SDL_VIDEO_OPENGL_EGL + // GL context + device->GL_SwapWindow = OFFSCREEN_GLES_SwapWindow; + device->GL_MakeCurrent = OFFSCREEN_GLES_MakeCurrent; + device->GL_CreateContext = OFFSCREEN_GLES_CreateContext; + device->GL_DestroyContext = OFFSCREEN_GLES_DestroyContext; + device->GL_LoadLibrary = OFFSCREEN_GLES_LoadLibrary; + device->GL_UnloadLibrary = OFFSCREEN_GLES_UnloadLibrary; + device->GL_GetProcAddress = OFFSCREEN_GLES_GetProcAddress; + device->GL_GetSwapInterval = OFFSCREEN_GLES_GetSwapInterval; + device->GL_SetSwapInterval = OFFSCREEN_GLES_SetSwapInterval; +#endif + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = OFFSCREEN_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = OFFSCREEN_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = OFFSCREEN_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = OFFSCREEN_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = OFFSCREEN_Vulkan_DestroySurface; +#endif + + // "Window" + device->CreateSDLWindow = OFFSCREEN_CreateWindow; + device->DestroyWindow = OFFSCREEN_DestroyWindow; + device->SetWindowSize = OFFSCREEN_SetWindowSize; + + return device; +} + +VideoBootStrap OFFSCREEN_bootstrap = { + OFFSCREENVID_DRIVER_NAME, "SDL offscreen video driver", + OFFSCREEN_CreateDevice, + NULL, // no ShowMessageBox implementation + false +}; + +static bool OFFSCREEN_VideoInit(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; + + // Use a fake 32-bpp desktop mode + SDL_zero(mode); + mode.format = SDL_PIXELFORMAT_XRGB8888; + mode.w = 1024; + mode.h = 768; + if (SDL_AddBasicVideoDisplay(&mode) == 0) { + return false; + } + + // We're done! + return true; +} + +static bool OFFSCREEN_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + return true; +} + +void OFFSCREEN_VideoQuit(SDL_VideoDevice *_this) +{ +} + +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.h b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.h new file mode 100644 index 0000000..f39d8e7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvideo.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_offscreenvideo_h +#define SDL_offscreenvideo_h + +#include "../SDL_sysvideo.h" + +#endif // SDL_offscreenvideo_h diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.c b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.c new file mode 100644 index 0000000..b3dca4a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.c @@ -0,0 +1,261 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_OFFSCREEN) + +#include "../SDL_vulkan_internal.h" +#include "../SDL_sysvideo.h" + + +static const char *s_defaultPaths[] = { +#if defined(SDL_PLATFORM_WINDOWS) + "vulkan-1.dll" +#elif defined(SDL_PLATFORM_APPLE) + "vulkan.framework/vulkan", + "libvulkan.1.dylib", + "libvulkan.dylib", + "MoltenVK.framework/MoltenVK", + "libMoltenVK.dylib" +#elif defined(SDL_PLATFORM_OPENBSD) + "libvulkan.so" +#else + "libvulkan.so.1" +#endif +}; + +#if defined( SDL_PLATFORM_APPLE ) +#include + +// Since libSDL is most likely a .dylib, need RTLD_DEFAULT not RTLD_SELF. +#define DEFAULT_HANDLE RTLD_DEFAULT +#endif + +/*Should the whole driver fail if it can't create a surface? Rendering to an offscreen buffer is still possible without a surface. + At the time of writing. I need the driver to minimally work even if the surface extension isn't present. + And account for the inability to create a surface on the consumer side. + So for now I'm targeting my specific use case -Dave Kircher*/ +#define HEADLESS_SURFACE_EXTENSION_REQUIRED_TO_LOAD 0 + + +bool OFFSCREEN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasHeadlessSurfaceExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + Uint32 i; + const char **paths; + const char *foundPath = NULL; + Uint32 numPaths; + + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan already loaded"); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + +#if defined(SDL_PLATFORM_APPLE) + if (!path) { + // Handle the case where Vulkan Portability is linked statically. + vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, + "vkGetInstanceProcAddr"); + } + + if (vkGetInstanceProcAddr) { + _this->vulkan_config.loader_handle = DEFAULT_HANDLE; + } else +#endif + { + if (path) { + paths = &path; + numPaths = 1; + } else { + paths = s_defaultPaths; + numPaths = SDL_arraysize(s_defaultPaths); + } + + for (i = 0; i < numPaths && _this->vulkan_config.loader_handle == NULL; i++) { + foundPath = paths[i]; + _this->vulkan_config.loader_handle = SDL_LoadObject(foundPath); + } + + if (_this->vulkan_config.loader_handle == NULL) { + return SDL_SetError("Failed to load Vulkan Portability library"); + } + + SDL_strlcpy(_this->vulkan_config.loader_path, foundPath, + SDL_arraysize(_this->vulkan_config.loader_path)); + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + + if (!vkGetInstanceProcAddr) { + SDL_SetError("Failed to load vkGetInstanceProcAddr from Vulkan Portability library"); + goto fail; + } + } + + _this->vulkan_config.vkGetInstanceProcAddr = (SDL_FunctionPointer)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (SDL_FunctionPointer)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + if (!extensions) { + goto fail; + } + for (i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasHeadlessSurfaceExtension = true; + } + } + SDL_free(extensions); + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } + if (!hasHeadlessSurfaceExtension) { +#if (HEADLESS_SURFACE_EXTENSION_REQUIRED_TO_LOAD != 0) + SDL_SetError("Installed Vulkan doesn't implement the " VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME " extension"); + goto fail; +#else + // Let's at least leave a breadcrumb for people to find if they have issues + SDL_Log("Installed Vulkan doesn't implement the " VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME " extension"); +#endif + } + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void OFFSCREEN_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + } +} + +char const *const *OFFSCREEN_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ +#if (HEADLESS_SURFACE_EXTENSION_REQUIRED_TO_LOAD == 0) + VkExtensionProperties *enumerateExtensions = NULL; + Uint32 enumerateExtensionCount = 0; + bool hasHeadlessSurfaceExtension = false; + Uint32 i; +#endif + + static const char *const returnExtensions[] = { VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME }; + if (count) { +# if (HEADLESS_SURFACE_EXTENSION_REQUIRED_TO_LOAD == 0) + { + /* In optional mode, only return VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME if it's already supported by the instance + There's probably a better way to cache the presence of the extension during OFFSCREEN_Vulkan_LoadLibrary(). + But both SDL_VideoData and SDL_VideoDevice::vulkan_config seem like I'd need to touch a bunch of code to do properly. + And I want a smaller footprint for the first pass*/ + if ( _this->vulkan_config.vkEnumerateInstanceExtensionProperties ) { + enumerateExtensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &enumerateExtensionCount); + for (i = 0; i < enumerateExtensionCount; i++) { + if (SDL_strcmp(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME, enumerateExtensions[i].extensionName) == 0) { + hasHeadlessSurfaceExtension = true; + } + } + SDL_free(enumerateExtensions); + } + if ( hasHeadlessSurfaceExtension == true ) { + *count = SDL_arraysize(returnExtensions); + } else { + *count = SDL_arraysize(returnExtensions) - 1; // assumes VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME is last + } + } +# else + { + *count = SDL_arraysize(returnExtensions); + } +# endif + } + return returnExtensions; +} + +bool OFFSCREEN_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + *surface = VK_NULL_HANDLE; + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT = + (PFN_vkCreateHeadlessSurfaceEXT)vkGetInstanceProcAddr(instance, "vkCreateHeadlessSurfaceEXT"); + VkHeadlessSurfaceCreateInfoEXT createInfo; + VkResult result; + if (!vkCreateHeadlessSurfaceEXT) { + /* This may be surprising to the consumer when HEADLESS_SURFACE_EXTENSION_REQUIRED_TO_LOAD == 0 + But this is the tradeoff for allowing offscreen rendering to a buffer to continue working without requiring the extension during driver load */ + return SDL_SetError(VK_EXT_HEADLESS_SURFACE_EXTENSION_NAME + " extension is not enabled in the Vulkan instance."); + } + SDL_zero(createInfo); + createInfo.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT; + createInfo.pNext = NULL; + createInfo.flags = 0; + result = vkCreateHeadlessSurfaceEXT(instance, &createInfo, allocator, surface); + if (result != VK_SUCCESS) { + return SDL_SetError("vkCreateHeadlessSurfaceEXT failed: %s", SDL_Vulkan_GetResultString(result)); + } + return true; +} + +void OFFSCREEN_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.h b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.h new file mode 100644 index 0000000..b9d348e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenvulkan.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_offscreenvulkan_h +#define SDL_offscreenvulkan_h + +#if defined(SDL_VIDEO_DRIVER_OFFSCREEN) && defined(SDL_VIDEO_VULKAN) + +#include "../SDL_sysvideo.h" + +extern bool OFFSCREEN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void OFFSCREEN_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const *const *OFFSCREEN_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool OFFSCREEN_Vulkan_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, VkInstance instance, const struct VkAllocationCallbacks *allocator, VkSurfaceKHR *surface); +extern void OFFSCREEN_Vulkan_DestroySurface(SDL_VideoDevice *_this, VkInstance instance, VkSurfaceKHR surface, const struct VkAllocationCallbacks *allocator); + +#endif // SDL_VIDEO_DRIVER_OFFSCREEN && SDL_VIDEO_VULKAN + +#endif // SDL_offscreenvulkan_h diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.c b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.c new file mode 100644 index 0000000..579353b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.c @@ -0,0 +1,90 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OFFSCREEN + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_windowevents_c.h" +#include "../SDL_egl_c.h" + +#include "SDL_offscreenwindow.h" + +bool OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *offscreen_window = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + + if (!offscreen_window) { + return false; + } + + window->internal = offscreen_window; + + if (window->x == SDL_WINDOWPOS_UNDEFINED) { + window->x = 0; + } + + if (window->y == SDL_WINDOWPOS_UNDEFINED) { + window->y = 0; + } + + offscreen_window->sdl_window = window; + +#ifdef SDL_VIDEO_OPENGL_EGL + if (window->flags & SDL_WINDOW_OPENGL) { + + if (!_this->egl_data) { + return SDL_SetError("Cannot create an OPENGL window invalid egl_data"); + } + + offscreen_window->egl_surface = SDL_EGL_CreateOffscreenSurface(_this, window->w, window->h); + + if (offscreen_window->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Failed to created an offscreen surface (EGL display: %p)", + _this->egl_data->egl_display); + } + } else { + offscreen_window->egl_surface = EGL_NO_SURFACE; + } +#endif // SDL_VIDEO_OPENGL_EGL + + return true; +} + +void OFFSCREEN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *offscreen_window = window->internal; + + if (offscreen_window) { +#ifdef SDL_VIDEO_OPENGL_EGL + SDL_EGL_DestroySurface(_this, offscreen_window->egl_surface); +#endif + SDL_free(offscreen_window); + } + + window->internal = NULL; +} + +void OFFSCREEN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->pending.w, window->pending.h); +} +#endif // SDL_VIDEO_DRIVER_OFFSCREEN diff --git a/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.h b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.h new file mode 100644 index 0000000..0f723c7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/offscreen/SDL_offscreenwindow.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_offscreenwindow_h +#define SDL_offscreenwindow_h + +#include "SDL_offscreenvideo.h" + +struct SDL_WindowData +{ + SDL_Window *sdl_window; +#ifdef SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif +}; + +extern bool OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void OFFSCREEN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void OFFSCREEN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_offscreenwindow_h diff --git a/contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.c b/contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.c new file mode 100644 index 0000000..6387c37 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.c @@ -0,0 +1,1664 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2022 Charles Lohr + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_OPENVR + +#define DEBUG_OPENVR + +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_events_c.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../SDL_egl_c.h" +#include "SDL_openvrvideo.h" + +#include + +#ifdef SDL_VIDEO_DRIVER_WINDOWS +#include "../windows/SDL_windowsopengles.h" +#include "../windows/SDL_windowsopengl.h" +#include "../windows/SDL_windowsvulkan.h" +#define DEFAULT_OPENGL "OPENGL32.DLL" +static bool OPENVR_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +static SDL_GLContext OPENVR_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); + +struct SDL_GLContextState +{ + HGLRC hglrc; +}; + +#else +#include +#endif + +#define MARKER_ID 0 +#define MARKER_STR "vr-marker,frame_end,type,application" + +#undef EXTERN_C + +// For access to functions that don't get the video data context. +SDL_VideoData * global_openvr_driver; + +static void InitializeMouseFunctions(); + +struct SDL_CursorData +{ + unsigned texture_id_handle; + int hot_x, hot_y; + int w, h; +}; + +// GL Extensions for functions we will be using. +static void (APIENTRY *ov_glGenFramebuffers)(GLsizei n, GLuint *framebuffers); +static void (APIENTRY *ov_glGenRenderbuffers)(GLsizei n, GLuint *renderbuffers); +static void (APIENTRY *ov_glBindFramebuffer)(GLenum target, GLuint framebuffer); +static void (APIENTRY *ov_glBindRenderbuffer)(GLenum target, GLuint renderbuffer); +static void (APIENTRY *ov_glRenderbufferStorage)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); +static void (APIENTRY *ov_glFramebufferRenderbuffer)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); +static void (APIENTRY *ov_glFramebufferTexture2D)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); +static GLenum (APIENTRY *ov_glCheckNamedFramebufferStatus)(GLuint framebuffer, GLenum target); +static GLenum (APIENTRY *ov_glGetError)(); +static void (APIENTRY *ov_glFlush)(); +static void (APIENTRY *ov_glFinish)(); +static void (APIENTRY *ov_glGenTextures)(GLsizei n, GLuint *textures); +static void (APIENTRY *ov_glDeleteTextures)(GLsizei n, GLuint *textures); +static void (APIENTRY *ov_glTexParameterf)(GLenum target, GLenum pname, GLfloat param); +static void (APIENTRY *ov_glTexParameteri)(GLenum target, GLenum pname, GLenum param); +static void (APIENTRY *ov_glTexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *data); +static void (APIENTRY *ov_glBindTexture)(GLenum target, GLuint texture); +static void (APIENTRY *ov_glDrawBuffers)(GLsizei n, const GLenum *bufs); +static void (APIENTRY *ov_glGetIntegerv)(GLenum pname, GLint * data); +static const GLubyte *(APIENTRY *ov_glGetStringi)(GLenum name, GLuint index); +static void (APIENTRY *ov_glClear)(GLbitfield mask); +static void (APIENTRY *ov_glClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +static void (APIENTRY *ov_glColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +static void (APIENTRY *ov_glDebugMessageInsert)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const char *message); + +#ifdef SDL_VIDEO_DRIVER_WINDOWS +static PROC (*ov_wglGetProcAddress)(LPCSTR); +static HGLRC (*ov_wglCreateContext)(HDC); +static BOOL (*ov_wglDeleteContext)(HGLRC); +static BOOL (*ov_wglMakeCurrent)(HDC, HGLRC); +//static HGLRC (*ov_wglGetCurrentContext)(void); +#endif + + +#define OPENVR_DEFAULT_WIDTH 1920 +#define OPENVR_DEFAULT_HEIGHT 1080 + +#define OPENVR_SetupProc(proc) { proc = (void*)SDL_GL_GetProcAddress((#proc)+3); if (!proc) { failed_extension = (#proc)+3; } } + +static bool OPENVR_InitExtensions(SDL_VideoDevice *_this) +{ + if (!ov_glGetError) { + const char * failed_extension = 0; + OPENVR_SetupProc(ov_glGenFramebuffers); + OPENVR_SetupProc(ov_glGenRenderbuffers); + OPENVR_SetupProc(ov_glBindFramebuffer); + OPENVR_SetupProc(ov_glBindRenderbuffer); + OPENVR_SetupProc(ov_glRenderbufferStorage); + OPENVR_SetupProc(ov_glFramebufferRenderbuffer); + OPENVR_SetupProc(ov_glFramebufferTexture2D); + OPENVR_SetupProc(ov_glCheckNamedFramebufferStatus); + OPENVR_SetupProc(ov_glGetError); + OPENVR_SetupProc(ov_glFlush); + OPENVR_SetupProc(ov_glFinish); + OPENVR_SetupProc(ov_glGenTextures); + OPENVR_SetupProc(ov_glDeleteTextures); + OPENVR_SetupProc(ov_glTexParameterf); + OPENVR_SetupProc(ov_glTexParameteri); + OPENVR_SetupProc(ov_glTexImage2D); + OPENVR_SetupProc(ov_glBindTexture); + OPENVR_SetupProc(ov_glDrawBuffers); + OPENVR_SetupProc(ov_glClear); + OPENVR_SetupProc(ov_glClearColor); + OPENVR_SetupProc(ov_glColorMask); + OPENVR_SetupProc(ov_glGetStringi); + OPENVR_SetupProc(ov_glGetIntegerv); + OPENVR_SetupProc(ov_glDebugMessageInsert); + if (failed_extension) { + return SDL_SetError("Error loading GL extension for %s", failed_extension); + } + } + return true; +} + +static bool OPENVR_SetOverlayError(EVROverlayError e) +{ + switch (e) { +#define CASE(X) case EVROverlayError_VROverlayError_##X: return SDL_SetError("VROverlayError %s", #X) + CASE(UnknownOverlay); + CASE(InvalidHandle); + CASE(PermissionDenied); + CASE(OverlayLimitExceeded); + CASE(WrongVisibilityType); + CASE(KeyTooLong); + CASE(NameTooLong); + CASE(KeyInUse); + CASE(WrongTransformType); + CASE(InvalidTrackedDevice); + CASE(InvalidParameter); + CASE(ThumbnailCantBeDestroyed); + CASE(ArrayTooSmall); + CASE(RequestFailed); + CASE(InvalidTexture); + CASE(UnableToLoadFile); + CASE(KeyboardAlreadyInUse); + CASE(NoNeighbor); + CASE(TooManyMaskPrimitives); + CASE(BadMaskPrimitive); + CASE(TextureAlreadyLocked); + CASE(TextureLockCapacityReached); + CASE(TextureNotLocked); + CASE(TimedOut); +#undef CASE + default: + return SDL_SetError("Unknown VROverlayError %d", e); + } +} + +static bool OPENVR_InitializeOverlay(SDL_VideoDevice *_this, SDL_Window *window); + +static bool OPENVR_VideoInit(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = (SDL_VideoData *)_this->internal; + + const char * hintWidth = SDL_GetHint("SDL_DEFAULT_WIDTH"); + const char * hintHeight = SDL_GetHint("SDL_DEFAULT_HEIGHT"); + const char * hintFPS = SDL_GetHint("SDL_DEFAULT_FPS"); + int width = hintWidth ? SDL_atoi(hintWidth) : 0; + int height = hintHeight ? SDL_atoi(hintHeight) : 0; + int fps = hintFPS ? SDL_atoi(hintFPS) : 0; + + SDL_VideoDisplay display; + SDL_zero(display); + display.desktop_mode.format = SDL_PIXELFORMAT_RGBA32; + display.desktop_mode.w = OPENVR_DEFAULT_WIDTH; + display.desktop_mode.h = OPENVR_DEFAULT_HEIGHT; + display.natural_orientation = SDL_ORIENTATION_LANDSCAPE; + display.current_orientation = SDL_ORIENTATION_LANDSCAPE; + display.content_scale = 1.0f; + if (height > 0 && width > 0) { + display.desktop_mode.w = width; + display.desktop_mode.h = height; + } + if (fps) { + display.desktop_mode.refresh_rate = fps; + } else { + display.desktop_mode.refresh_rate = data->oSystem->GetFloatTrackedDeviceProperty(k_unTrackedDeviceIndex_Hmd, ETrackedDeviceProperty_Prop_DisplayFrequency_Float, 0); + } + + display.internal = (SDL_DisplayData *)data; + display.name = (char*)"OpenVRDisplay"; + SDL_AddVideoDisplay(&display, false); + + return true; +} + +static void OPENVR_VideoQuit(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (videodata->bDidCreateOverlay && videodata->overlayID != 0) { + videodata->oOverlay->DestroyOverlay(videodata->overlayID); + } +} + +static void OPENVR_Destroy(SDL_VideoDevice *device) +{ + SDL_VideoData *data = device->internal; + +#ifdef SDL_PLATFORM_WINDOWS + SDL_UnregisterApp(); +#endif + + if (data) { + if (data->openVRLIB) { + SDL_UnloadObject(data->openVRLIB); + } + } + SDL_free(device->internal); + SDL_free(device); +} + +static uint32_t *ImageSDLToOpenVRGL(SDL_Surface * surf, bool bFlipY) +{ + int w = surf->w; + int h = surf->h; + int pitch = surf->pitch; + int x, y; + uint32_t * pxd = SDL_malloc(4 * surf->w * surf->h); + for(y = 0; y < h; y++) { + uint32_t * iline = (uint32_t*)&(((uint8_t*)surf->pixels)[y*pitch]); + uint32_t * oline = &pxd[(bFlipY?(h-y-1):y)*w]; + for(x = 0; x < w; x++) + { + uint32_t pr = iline[x]; + oline[x] = (pr & 0xff00ff00) | ((pr & 0xff) << 16) | ((pr & 0xff0000)>>16); + } + } + return pxd; +} + +static bool OPENVR_CheckRenderbuffer(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + + if (videodata->targw == 0 || videodata->targh == 0) { + videodata->targw = OPENVR_DEFAULT_WIDTH; + videodata->targh = OPENVR_DEFAULT_HEIGHT; + } + + if (videodata->targh != videodata->last_targh + || videodata->targw != videodata->last_targw) { + + struct HmdVector2_t ms; + int status; + + if (videodata->fbo <= 0) { + ov_glGenFramebuffers(1, &videodata->fbo); + ov_glGenRenderbuffers(1, &videodata->rbo); + ov_glGenTextures(1, &videodata->overlaytexture); + } + + // Generate the OpenGL Backing buffers/etc. + ov_glBindFramebuffer(GL_FRAMEBUFFER, videodata->fbo); + ov_glBindRenderbuffer(GL_RENDERBUFFER, videodata->rbo); + ov_glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, videodata->targw, videodata->targh); + ov_glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, videodata->rbo); + ov_glBindTexture(GL_TEXTURE_2D, videodata->overlaytexture); + ov_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + ov_glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + ov_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, videodata->targw, videodata->targh, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + ov_glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, videodata->overlaytexture, 0); + status = ov_glCheckNamedFramebufferStatus(videodata->fbo, GL_FRAMEBUFFER); + if (status != GL_FRAMEBUFFER_COMPLETE) { + return SDL_SetError("OPENVR: Can't generate overlay buffer"); + } + ov_glBindFramebuffer(GL_FRAMEBUFFER, 0); + + ms.v[0] = (float)videodata->targw; + ms.v[1] = (float)videodata->targh; + videodata->oOverlay->SetOverlayMouseScale(videodata->overlayID, &ms); + + videodata->last_targh = videodata->targh; + videodata->last_targw = videodata->targw; + } + return true; +} + +static bool OPENVR_VirtualControllerRumble(void *userdata, Uint16 low_frequency_rumble, Uint16 high_frequency_rumble) +{ + // On XBOX Controllers Low/High maps to Left/Right + SDL_VideoData *videodata = (SDL_VideoData *)userdata; + + const float k_flIntensity = 320.f; // Maximum frequency + float flLeftFrequency = (float)low_frequency_rumble * k_flIntensity / 65535.f; + float flRightFrequency = (float)high_frequency_rumble * k_flIntensity / 65535.f; + float flDurationSeconds = 2.f; + float flAmplitude = 1.f; + + videodata->oInput->TriggerHapticVibrationAction(videodata->input_action_handles_haptics[0], 0, flDurationSeconds, flLeftFrequency, flAmplitude, 0); + videodata->oInput->TriggerHapticVibrationAction(videodata->input_action_handles_haptics[1], 0, flDurationSeconds, flRightFrequency, flAmplitude, 0); + + return true; +} + +static bool OPENVR_VirtualControllerRumbleTriggers(void *userdata, Uint16 left_rumble, Uint16 right_rumble) +{ + SDL_VideoData *videodata = (SDL_VideoData *)userdata; + videodata->oInput->TriggerHapticVibrationAction(videodata->input_action_handles_haptics[0], 0, 0.1f, left_rumble, 1.0, 0); + videodata->oInput->TriggerHapticVibrationAction(videodata->input_action_handles_haptics[1], 0, 0.1f, right_rumble, 1.0, 0); + return true; +} + +static void OPENVR_VirtualControllerUpdate(void *userdata) +{ + SDL_VideoData *videodata = (SDL_VideoData *)userdata; + SDL_Joystick * joystick = videodata->virtual_joystick; + InputDigitalActionData_t digital_input_action; + InputAnalogActionData_t analog_input_action; + EVRInputError e; +#ifdef DEBUG_OPENVR + //char cts[10240]; + //char * ctsx = cts; +#endif + VRActiveActionSet_t actionSet = { 0 }; + actionSet.ulActionSet = videodata->input_action_set; + e = videodata->oInput->UpdateActionState(&actionSet, sizeof(actionSet), 1); + if (e) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to update action state"); +#endif + return; + } + + for (int d = 0; d < videodata->input_action_handles_buttons_count; d++) + { + if (videodata->input_action_handles_buttons[d] == k_ulInvalidActionHandle) + continue; + e = videodata->oInput->GetDigitalActionData(videodata->input_action_handles_buttons[d], &digital_input_action, sizeof(digital_input_action), k_ulInvalidInputValueHandle); + if (e) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to get digital action data: %d", d); +#endif + return; + } + SDL_SetJoystickVirtualButton(joystick, d, digital_input_action.bState); +#ifdef DEBUG_OPENVR + //ctsx+=sprintf(ctsx,"%d", digital_input_action.bState); +#endif + } + + // Left Stick + e = videodata->oInput->GetAnalogActionData(videodata->input_action_handles_axes[0], &analog_input_action, sizeof(analog_input_action), k_ulInvalidInputValueHandle); + if (e) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to get analog action data: left stick"); +#endif + return; + } + SDL_SetJoystickVirtualAxis(joystick, SDL_GAMEPAD_AXIS_LEFTX, (Sint16)(analog_input_action.x * SDL_JOYSTICK_AXIS_MAX)); + SDL_SetJoystickVirtualAxis(joystick, SDL_GAMEPAD_AXIS_LEFTY, (Sint16)(-analog_input_action.y * SDL_JOYSTICK_AXIS_MAX)); + + // Right Stick + e = videodata->oInput->GetAnalogActionData(videodata->input_action_handles_axes[1], &analog_input_action, sizeof(analog_input_action), k_ulInvalidInputValueHandle); + if (e) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to get analog action data: right stick"); +#endif + return; + } + SDL_SetJoystickVirtualAxis(joystick, SDL_GAMEPAD_AXIS_RIGHTX, (Sint16)(analog_input_action.x * SDL_JOYSTICK_AXIS_MAX)); + SDL_SetJoystickVirtualAxis(joystick, SDL_GAMEPAD_AXIS_RIGHTY, (Sint16)(-analog_input_action.y * SDL_JOYSTICK_AXIS_MAX)); + + // Left Trigger + e = videodata->oInput->GetAnalogActionData(videodata->input_action_handles_axes[2], &analog_input_action, sizeof(analog_input_action), k_ulInvalidInputValueHandle); + if (e) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to get analog action data: left trigger"); +#endif + return; + } + SDL_SetJoystickVirtualAxis(joystick, SDL_GAMEPAD_AXIS_LEFT_TRIGGER, (Sint16)((analog_input_action.x * 2.0f - 1.0f) * SDL_JOYSTICK_AXIS_MAX)); + + // Right Trigger + e = videodata->oInput->GetAnalogActionData(videodata->input_action_handles_axes[3], &analog_input_action, sizeof(analog_input_action), k_ulInvalidInputValueHandle); + if (e) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to get analog action data: right trigger"); +#endif + return; + } + SDL_SetJoystickVirtualAxis(joystick, SDL_GAMEPAD_AXIS_RIGHT_TRIGGER, (Sint16)((analog_input_action.x * 2.0f - 1.0f) * SDL_JOYSTICK_AXIS_MAX)); + +#if 0 + for (a = 0; a < videodata->input_action_handles_axes_count; a++) + { + float xval = 0.0f; + e = videodata->oInput->GetAnalogActionData(videodata->input_action_handles_axes[a], &analog_input_action, sizeof(analog_input_action), k_ulInvalidInputValueHandle); + if (e) goto updatefail; + xval = analog_input_action.x; + if (a == SDL_CONTROLLER_AXIS_LEFTY || a == SDL_CONTROLLER_AXIS_RIGHTY) + xval *= -1.0f; + if (a == SDL_GAMEPAD_AXIS_LEFT_TRIGGER || a == SDL_GAMEPAD_AXIS_RIGHT_TRIGGER) + xval = xval * 2.0f - 1.0f; + //SDL_SetJoystickVirtualAxis(joystick, a, analog_input_action.x*32767); + xval *= SDL_JOYSTICK_AXIS_MAX; + SDL_SetJoystickVirtualAxis(joystick, a, xval); +#ifdef DEBUG_OPENVR + //ctsx+=sprintf(ctsx,"[%f]", analog_input_action.x); +#endif + } +#endif +#ifdef DEBUG_OPENVR + //SDL_Log("Debug Input States: %s", cts); +#endif + return; +} + +static bool OPENVR_SetupJoystickBasedOnLoadedActionManifest(SDL_VideoData * videodata) +{ + SDL_VirtualJoystickDesc desc; + int virtual_index; + + EVRInputError e = 0; + + char * k_pchBooleanActionPaths[SDL_GAMEPAD_BUTTON_COUNT] = { + "/actions/virtualgamepad/in/a", + "/actions/virtualgamepad/in/b", + "/actions/virtualgamepad/in/x", + "/actions/virtualgamepad/in/y", + "/actions/virtualgamepad/in/back", + "/actions/virtualgamepad/in/guide", + "/actions/virtualgamepad/in/start", + "/actions/virtualgamepad/in/stick_click_left", + "/actions/virtualgamepad/in/stick_click_right", + "/actions/virtualgamepad/in/shoulder_left", + "/actions/virtualgamepad/in/shoulder_right", + "/actions/virtualgamepad/in/dpad_up", + "/actions/virtualgamepad/in/dpad_down", + "/actions/virtualgamepad/in/dpad_left", + "/actions/virtualgamepad/in/dpad_right", + "/actions/virtualgamepad/in/misc_1", + "/actions/virtualgamepad/in/paddle_1", + "/actions/virtualgamepad/in/paddle_2", + "/actions/virtualgamepad/in/paddle_3", + "/actions/virtualgamepad/in/paddle_4", + "/actions/virtualgamepad/in/touchpad_click", + "/actions/virtualgamepad/in/misc_2", + "/actions/virtualgamepad/in/misc_3", + "/actions/virtualgamepad/in/misc_4", + "/actions/virtualgamepad/in/misc_5", + "/actions/virtualgamepad/in/misc_6", + }; + char * k_pchAnalogActionPaths[4] = { + "/actions/virtualgamepad/in/stick_left", + "/actions/virtualgamepad/in/stick_right", + "/actions/virtualgamepad/in/trigger_left", + "/actions/virtualgamepad/in/trigger_right", + }; + + if ((e = videodata->oInput->GetActionSetHandle("/actions/virtualgamepad", &videodata->input_action_set)) != EVRInputError_VRInputError_None) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to get action set handle: %d", e); +#endif + return SDL_SetError("Failed to get action set handle"); + } + + videodata->input_action_handles_buttons_count = sizeof(k_pchBooleanActionPaths) / sizeof(k_pchBooleanActionPaths[0]); + videodata->input_action_handles_buttons = SDL_malloc(videodata->input_action_handles_buttons_count * sizeof(VRActionHandle_t)); + + for (int i = 0; i < videodata->input_action_handles_buttons_count; i++) + { + e = videodata->oInput->GetActionHandle(k_pchBooleanActionPaths[i], &videodata->input_action_handles_buttons[i]); + if (e) + { + SDL_Log("ERROR: Failed to get button action %d ('%s')", i, k_pchBooleanActionPaths[i]); + return SDL_SetError("ERROR: Failed to get button action"); + } + } + + videodata->input_action_handles_axes_count = sizeof(k_pchAnalogActionPaths) / sizeof(k_pchAnalogActionPaths[0]); + videodata->input_action_handles_axes = SDL_malloc(videodata->input_action_handles_axes_count * sizeof(VRActionHandle_t)); + + for (int i = 0; i < videodata->input_action_handles_axes_count; i++) + { + e = videodata->oInput->GetActionHandle(k_pchAnalogActionPaths[i], &videodata->input_action_handles_axes[i]); + if (e) + { + SDL_Log("ERROR: Failed to get analog action %d ('%s')", i, k_pchAnalogActionPaths[i]); + return SDL_SetError("ERROR: Failed to get analog action"); + } + } + + e = videodata->oInput->GetActionHandle("/actions/virtualgamepad/out/haptic_left", &videodata->input_action_handles_haptics[0]); + e |= videodata->oInput->GetActionHandle("/actions/virtualgamepad/out/haptic_right", &videodata->input_action_handles_haptics[1]); + if (e) + { +#ifdef DEBUG_OPENVR + SDL_Log("ERROR: Failed to get haptics action"); +#endif + return SDL_SetError("ERROR: Failed to get haptics action"); + } + + // Create a virtual joystick. + SDL_INIT_INTERFACE(&desc); + desc.type = SDL_JOYSTICK_TYPE_GAMEPAD; + desc.naxes = SDL_GAMEPAD_AXIS_COUNT; + desc.nbuttons = SDL_GAMEPAD_BUTTON_COUNT; + desc.Rumble = OPENVR_VirtualControllerRumble; + desc.RumbleTriggers = OPENVR_VirtualControllerRumbleTriggers; + desc.Update = OPENVR_VirtualControllerUpdate; + desc.userdata = videodata; + virtual_index = SDL_AttachVirtualJoystick(&desc); + + if (virtual_index < 0) { + return SDL_SetError("OPENVR: Couldn't open virtual joystick device: %s", SDL_GetError()); + } else { + videodata->virtual_joystick = SDL_OpenJoystick(virtual_index); + if (!videodata->virtual_joystick) { + return SDL_SetError("OPENVR: Couldn't open virtual joystick device: %s", SDL_GetError()); + } + } + +#ifdef DEBUG_OPENVR + SDL_Log("Loaded virtual joystick with %d buttons and %d axes", videodata->input_action_handles_buttons_count, videodata->input_action_handles_axes_count); +#endif + + return false; +} + +static bool OPENVR_InitializeOverlay(SDL_VideoDevice *_this,SDL_Window *window) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + + // Wait til here, to make sure we have our context setup correctly. + if (!OPENVR_InitExtensions(_this)) { + return false; + } + + // Generate the overlay. + { + const char * hint = SDL_GetHint("SDL_OPENVR_OVERLAY_NAME"); + char * cursorname = 0; + if (!hint) { + hint = "sdl"; + } + + SDL_asprintf(&videodata->sOverlayName, "%s-overlay",hint); + if (!videodata->sOverlayName) { + return false; + } + SDL_asprintf(&cursorname, "%s-cursor",hint); + if (!cursorname) { + return false; + } + + EVROverlayError result = videodata->oOverlay->CreateDashboardOverlay(videodata->sOverlayName, + window->title, &videodata->overlayID, &videodata->thumbID); + if (result != EVROverlayError_VROverlayError_None) { + SDL_free(cursorname); + return SDL_SetError("Could not create dashboard overlay (%d)", result ); + } + result = videodata->oOverlay->CreateOverlay(cursorname, window->title, &videodata->cursorID); + if (result != EVROverlayError_VROverlayError_None) { + SDL_free(cursorname); + return SDL_SetError("Could not create cursor overlay (%d)", result ); + } + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_OPENVR_OVERLAY_ID, videodata->overlayID); + SDL_free(cursorname); + videodata->bHasShownOverlay = false; + } + { + const char * hint = SDL_GetHint("SDL_OPENVR_OVERLAY_PANEL_WIDTH"); + float fWidth = hint ? (float)SDL_atof(hint) : 1.0f; + videodata->oOverlay->SetOverlayWidthInMeters(videodata->overlayID, fWidth); + } + { + const char * hint = SDL_GetHint("SDL_OPENVR_CURSOR_WIDTH"); + // Default is what SteamVR Does + float fCursorWidth = hint ? (float)SDL_atof(hint) : 0.06f; + videodata->oOverlay->SetOverlayWidthInMeters(videodata->cursorID, fCursorWidth * 0.5f); + } + { + const char * hint = SDL_GetHint("SDL_OPENVR_WINDOW_ICON_FILE"); + videodata->bIconOverridden = false; + if (hint) { + char * tmpcopy = SDL_strdup(hint); + EVROverlayError err = videodata->oOverlay->SetOverlayFromFile(videodata->thumbID, tmpcopy); + SDL_free(tmpcopy); + if (err == EVROverlayError_VROverlayError_None) { + videodata->bIconOverridden = SDL_GetHintBoolean("SDL_OPENVR_WINDOW_ICON_OVERRIDE",false); + } + } + } + { + VRTextureBounds_t bounds; + bounds.uMin = 0; + bounds.uMax = 1; + bounds.vMin = 0; + bounds.vMax = 1; + videodata->oOverlay->SetOverlayTextureBounds(videodata->overlayID, &bounds); + } + + if (!OPENVR_CheckRenderbuffer(_this)) { + return false; + } + + + global_openvr_driver = videodata; + InitializeMouseFunctions(); + + // Actually show the overlay. + videodata->oOverlay->SetOverlayFlag(videodata->overlayID, 1<<23, true); //vr::VROverlayFlags_EnableControlBar + videodata->oOverlay->SetOverlayFlag(videodata->overlayID, 1<<24, true); //vr::VROverlayFlags_EnableControlBarKeyboard + videodata->oOverlay->SetOverlayFlag(videodata->overlayID, 1<<25, true); //vr::VROverlayFlags_EnableControlBarClose + videodata->oOverlay->SetOverlayName(videodata->overlayID, window->title); + + videodata->bDidCreateOverlay = true; + videodata->window = window; + + return true; +} + + +static bool OPENVR_SetupFrame(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + static const GLenum buffers[8] = { GL_COLOR_ATTACHMENT0_EXT }; + + videodata->is_buffer_rendering = true; + +#ifdef DEBUG_OPENVR + { + int error = ov_glGetError(); + if (error) + SDL_Log("Found GL Error before beginning frame: %d / (Framebuffer:%d)", error, ov_glCheckNamedFramebufferStatus(videodata->fbo, GL_FRAMEBUFFER)); + } +#endif + + ov_glBindFramebuffer(GL_FRAMEBUFFER, videodata->fbo); + ov_glDrawBuffers(1, buffers); + + // Set the alpha channel for non-transparent windows + if (!(window->flags & SDL_WINDOW_TRANSPARENT)) { + ov_glClearColor(0.0f, 0.0f, 0.0f, 1.0f); + ov_glColorMask(false, false, false, true); + ov_glClear(GL_COLOR_BUFFER_BIT); + ov_glColorMask(true, true, true, true); + } + + ov_glBindTexture( GL_TEXTURE_2D, videodata->saved_texture_state ); + + return true; +} + +static bool OPENVR_ReleaseFrame(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + ov_glGetIntegerv(GL_TEXTURE_BINDING_2D, &videodata->saved_texture_state); + + if (!ov_glGetError) { + return true; + } + + if (!videodata->is_buffer_rendering) { + return true; + } + +#ifdef DEBUG_OPENVR + { + int error = ov_glGetError(); + if (error) { + SDL_Log("Found GL Error before release frame: %d / (Framebuffer:%d)", error, ov_glCheckNamedFramebufferStatus(videodata->fbo, GL_FRAMEBUFFER)); + } + } +#endif + + videodata->is_buffer_rendering = false; + + ov_glBindFramebuffer(GL_FRAMEBUFFER, 0); + + if (videodata->overlaytexture != 0 && + videodata->targh == videodata->last_targh && + videodata->targw == videodata->last_targw) { + // Only submit frames to OpenVR if the textu re exists. + struct Texture_t tex; + + // Setup a Texture_t object to send in the texture. + tex.eColorSpace = EColorSpace_ColorSpace_Auto; + tex.eType = ETextureType_TextureType_OpenGL; + tex.handle = (void *)(intptr_t)videodata->overlaytexture; + + // Send texture into OpenVR as the overlay. + videodata->oOverlay->SetOverlayTexture(videodata->overlayID, &tex); + } + + if (!videodata->bHasShownOverlay && videodata->bDidCreateOverlay) { + videodata->oOverlay->ShowDashboard(videodata->sOverlayName); + videodata->bHasShownOverlay = true; + } + + if (videodata->renderdoc_debugmarker_frame_end) { + ov_glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, + GL_DEBUG_TYPE_MARKER, MARKER_ID, GL_DEBUG_SEVERITY_NOTIFICATION, -1, + MARKER_STR); + } + + return OPENVR_CheckRenderbuffer(_this); +} + +static void OPENVR_HandleResize(SDL_VideoDevice *_this, int w, int h) +{ + SDL_VideoData *data = (SDL_VideoData *)_this->internal; + data->targw = w; + data->targh = h; +} + +static bool OPENVR_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + return true; +} + + +#ifdef SDL_VIDEO_DRIVER_WINDOWS +static LRESULT CALLBACK OpenVRVideoWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + switch (msg) { + case WM_DESTROY: + return 0; + } + return DefWindowProc(hwnd, msg, wParam, lParam); +} + +static bool OPENVR_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + if (path == NULL) { + path = SDL_GetHint(SDL_HINT_OPENGL_LIBRARY); + } + + if (path == NULL) { + path = DEFAULT_OPENGL; + } + _this->gl_config.dll_handle = SDL_LoadObject(path); + if (!_this->gl_config.dll_handle) { + return false; + } + SDL_strlcpy(_this->gl_config.driver_path, path, + SDL_arraysize(_this->gl_config.driver_path)); + + // Allocate OpenGL memory + _this->gl_data = (struct SDL_GLDriverData *)SDL_calloc(1, sizeof(struct SDL_GLDriverData)); + if (!_this->gl_data) { + return false; + } + _this->gl_config.driver_loaded = true; + + return true; +} + +static SDL_FunctionPointer OPENVR_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + SDL_FunctionPointer result = NULL; + if (ov_wglGetProcAddress) { + result = (SDL_FunctionPointer)ov_wglGetProcAddress(proc); + if (result) { + return result; + } + } + + return SDL_LoadFunction(_this->gl_config.dll_handle, proc); +} + +static void OPENVR_GL_UnloadLibrary(SDL_VideoDevice *_this) +{ + SDL_GL_UnloadLibrary(); +} + +static SDL_GLContext OPENVR_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + GLint numExtensions; + int i; + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (!videodata->hglrc) { + // Crate a surfaceless EGL Context + HWND hwnd; + + WNDCLASSA wnd; + wnd.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; + wnd.lpfnWndProc = OpenVRVideoWndProc; + wnd.cbClsExtra = 0; + wnd.cbWndExtra = 0; + wnd.hInstance = GetModuleHandle(NULL); + wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION); + wnd.hCursor = LoadCursor(NULL, IDC_ARROW); + wnd.hbrBackground = (HBRUSH)(COLOR_BACKGROUND); + wnd.lpszMenuName = NULL; + wnd.lpszClassName = "SDL_openvrvideo_classname"; + RegisterClassA(&wnd); + hwnd = CreateWindowA("SDL_openvrvideo_classname", "SDL_openvrvideo_windowname", (WS_OVERLAPPEDWINDOW), 0, 0, + 100, 100, NULL, NULL, GetModuleHandle(NULL), NULL); + + MSG msg; + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + TranslateMessage(&msg); + DispatchMessage(&msg); + } + + videodata->hdc = GetDC(hwnd); + + static PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | + PFD_SUPPORT_OPENGL | + PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 24, + 8, 0, 8, 8, 8, 16, + 8, + 24, + 32, + 8, 8, 8, 8, + 16, + 0, + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + GLuint PixelFormat = ChoosePixelFormat(videodata->hdc, &pfd); + if (!SetPixelFormat(videodata->hdc, PixelFormat, &pfd)) { + SDL_SetError( "Could not set pixel format" ); + return NULL; + } + HMODULE opengl = GetModuleHandleA(DEFAULT_OPENGL); + if (!opengl) { + SDL_SetError("Could not open OpenGL Library %s", DEFAULT_OPENGL); + return NULL; + } + + ov_wglMakeCurrent = (BOOL(*)(HDC, HGLRC))GetProcAddress(opengl, "wglMakeCurrent"); + ov_wglCreateContext = (HGLRC(*)(HDC))GetProcAddress(opengl, "wglCreateContext"); + ov_wglGetProcAddress = (PROC(*)(LPCSTR))GetProcAddress(opengl, "wglGetProcAddress"); + ov_wglDeleteContext = (BOOL(*)(HGLRC))GetProcAddress(opengl, "wglDeleteContext"); + if (!ov_wglMakeCurrent || !ov_wglCreateContext) { + SDL_SetError("Cannot get wgl context procs(%p, %p)", ov_wglMakeCurrent, ov_wglCreateContext); + return NULL; + } + + videodata->hglrc = ov_wglCreateContext(videodata->hdc); + if (!videodata->hglrc || !ov_wglMakeCurrent(videodata->hdc, videodata->hglrc)) { + SDL_SetError("Could not make current OpenGL context."); + return NULL; + } + } + + i = OPENVR_InitExtensions(_this); + if (i == 0) { + return NULL; + } + + videodata->renderdoc_debugmarker_frame_end = false; + + ov_glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + for (i = 0; i < numExtensions; i++) { + const char *ccc = (const char *)ov_glGetStringi(GL_EXTENSIONS, i); + if (SDL_strcmp(ccc, "GL_KHR_debug") == 0) { +#ifdef DEBUG_OPENVR + SDL_Log("Found renderdoc debug extension."); +#endif + videodata->renderdoc_debugmarker_frame_end = true; + } + } + + if (!videodata->bDidCreateOverlay) { + if (!OPENVR_InitializeOverlay(_this, window)) { + return NULL; + } + } + + OPENVR_CheckRenderbuffer(_this); + + OPENVR_SetupFrame(_this, window); + + SDL_GLContext result = SDL_malloc(sizeof(struct SDL_GLContextState)); + if (!result) { + return NULL; + } + result->hglrc = videodata->hglrc; + return result; +} + +static bool OPENVR_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *wnd, SDL_GLContext context) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + ov_wglMakeCurrent(videodata->hdc, videodata->hglrc); + return true; +} + +static bool OPENVR_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + videodata->swap_interval = interval; + return true; +} + +static bool OPENVR_GL_GetSwapInterval(SDL_VideoDevice *_this, int *swapInterval) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (swapInterval) + *swapInterval = videodata->swap_interval; + else + return SDL_SetError("OPENVR: null passed in for GetSwapInterval"); + return true; +} + +static bool OPENVR_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + ov_wglMakeCurrent(videodata->hdc, NULL); + ov_wglDeleteContext(videodata->hglrc); + return true; +} + + +#else + +static EGLint context_attribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE +}; + +static bool SDL_EGL_InitInternal(SDL_VideoData * vd) +{ + // Crate a surfaceless EGL Context + EGLint major, minor; + EGLConfig eglCfg=NULL; + EGLBoolean b; + + vd->eglDpy = eglGetDisplay(EGL_DEFAULT_DISPLAY); +#ifdef DEBUG_OPENVR + SDL_Log("EGL Display: %p", vd->eglDpy); +#endif + + if (vd->eglDpy == 0) { + return SDL_SetError("No EGL Display"); + } + + b = eglInitialize(vd->eglDpy, &major, &minor); + if (!b) { + return SDL_SetError("eglInitialize failed"); + } + + eglBindAPI(EGL_OPENGL_API); +#ifdef DEBUG_OPENVR + SDL_Log("EGL Major Minor: %d %d = %d", major, minor, b); +#endif + + vd->eglCtx = eglCreateContext(vd->eglDpy, eglCfg, EGL_NO_CONTEXT, context_attribs); + +#ifdef DEBUG_OPENVR + { + int err = eglGetError(); + if (err != EGL_SUCCESS) { + return SDL_SetError("EGL Error after eglCreateContext %d", err); + } + } +#endif + + if (!vd->eglCtx) { + return SDL_SetError("No EGL context available"); + } + + eglMakeCurrent(vd->eglDpy, EGL_NO_SURFACE, EGL_NO_SURFACE, vd->eglCtx); + + return true; +} + +// Linux, EGL, etc. +static bool OVR_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + return SDL_EGL_LoadLibrary(_this, path, /*displaydata->native_display*/0, 0); +} + +static SDL_FunctionPointer OVR_EGL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + return SDL_EGL_GetProcAddress(proc); +} +static void OVR_EGL_UnloadLibrary(SDL_VideoDevice *_this) +{ + return SDL_EGL_UnloadLibrary(_this); +} +static SDL_GLContext OVR_EGL_CreateContext(SDL_VideoDevice *_this, SDL_Window * window) +{ + GLint numExtensions; + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (!videodata->eglCtx) { + if (!SDL_EGL_InitInternal(videodata)) { + return NULL; + } + } + + if (!OPENVR_InitExtensions(_this)) { + return NULL; + } + + videodata->renderdoc_debugmarker_frame_end = false; + + ov_glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); + for(int i = 0; i < numExtensions; i++) { + const char * ccc = (const char*)ov_glGetStringi(GL_EXTENSIONS, i); + if (SDL_strcmp(ccc, "GL_KHR_debug") == 0) { +#ifdef DEBUG_OPENVR + SDL_Log("Found renderdoc debug extension."); +#endif + videodata->renderdoc_debugmarker_frame_end = true; + } + } + + if (!videodata->bDidCreateOverlay) { + if (!OPENVR_InitializeOverlay(_this, window)) { + return NULL; + } + } + + OPENVR_CheckRenderbuffer(_this); + + OPENVR_SetupFrame(_this, window); + + return videodata->eglCtx; +} + +static bool OVR_EGL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window * wnd, SDL_GLContext context) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + eglMakeCurrent(videodata->eglDpy, EGL_NO_SURFACE, EGL_NO_SURFACE, videodata->eglCtx); + return true; +} + +static bool OVR_EGL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + videodata->swap_interval = interval; + return true; +} + +static bool OVR_EGL_GetSwapInterval(SDL_VideoDevice *_this, int * swapInterval) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (swapInterval) + *swapInterval = videodata->swap_interval; + else + return SDL_SetError("OPENVR: null passed in for GetSwapInterval"); + return true; +} + +static bool OVR_EGL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (videodata->eglDpy) { + eglTerminate(videodata->eglDpy); + } + return true; +} + +#endif + +static bool OPENVR_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *data; + + // Allocate window internal data + data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (data == NULL) { + return SDL_OutOfMemory(); + } + + window->max_w = 4096; + window->max_h = 4096; + window->min_w = 1; + window->min_h = 1; + + // Setup driver data for this window + window->internal = data; + return true; +} + + +static void OPENVR_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data; + + data = window->internal; + if (data) { + SDL_free(data); + } + window->internal = NULL; +} + +static void OPENVR_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData * data = (SDL_VideoData *)_this->internal; + if (data->bDidCreateOverlay) { + data->oOverlay->SetOverlayName(data->overlayID, window->title); + } +} + +static void OPENVR_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *data = (SDL_VideoData *)_this->internal; + + if (window->pending.w != window->w) { + window->w = window->pending.w; + } + + if (window->pending.h != window->h) { + window->h = window->pending.h; + } + + if (data->targh != window->h || data->targw != window->w) { + OPENVR_HandleResize(_this, window->w, window->h); + } + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window->w, window->h); +} + +static void OPENVR_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) +{ + SDL_VideoData *data = (SDL_VideoData *)_this->internal; + *w = data->targw; + *h = data->targh; +} + +static void OPENVR_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *data = (SDL_VideoData *)_this->internal; + if (data->targh != window->h || data->targw != window->w) { + OPENVR_HandleResize(_this, window->w, window->h); + } + + data->oOverlay->ShowDashboard(data->sOverlayName); + + window->flags |= (SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS); + SDL_SetKeyboardFocus(window); +} + +static void OPENVR_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + return; +} + +static bool OPENVR_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + + // This is a little weird. On Windows, we don't necessarily call the normal + // context creation function, and we might get here without having our buffers + // initialized. + if (!videodata->bDidCreateOverlay) { + if (!OPENVR_InitializeOverlay(_this, window)) { + return false; + } + } + + if (!OPENVR_ReleaseFrame(_this)) { + return false; + } + + // If swap_interval is nonzero (i.e. -1 or 1) we want to wait for vsync on the compositor. + if (videodata->swap_interval != 0) { + videodata->oOverlay->WaitFrameSync(100); + } + + if (!OPENVR_SetupFrame(_this, window)) { + return false; + } + + return true; +} + +static void OPENVR_HandleMouse(float x, float y, int btn, int evt) +{ + if (evt == 2) { + SDL_SendMouseMotion(0, NULL, SDL_GLOBAL_MOUSE_ID, false, x, y); + } else { + const Uint8 button = SDL_BUTTON_LEFT + btn; + const bool down = (evt != 0); + SDL_SendMouseButton(0, NULL, SDL_GLOBAL_MOUSE_ID, button, down); + } +} + + +static bool OPENVR_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + return true; +} + +static void OPENVR_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (!videodata || + videodata->oOverlay == 0 || + videodata->overlayID == 0) { + return; + } + EGamepadTextInputMode input_mode; + switch (SDL_GetTextInputType(props)) { + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN: + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + input_mode = EGamepadTextInputMode_k_EGamepadTextInputModePassword; + break; + default: + input_mode = EGamepadTextInputMode_k_EGamepadTextInputModeNormal; + break; + } + EGamepadTextInputLineMode line_mode; + if (SDL_GetTextInputMultiline(props)) { + line_mode = EGamepadTextInputLineMode_k_EGamepadTextInputLineModeMultipleLines; + } else { + line_mode = EGamepadTextInputLineMode_k_EGamepadTextInputLineModeSingleLine; + } + videodata->oOverlay->ShowKeyboardForOverlay(videodata->overlayID, + input_mode, line_mode, + EKeyboardFlags_KeyboardFlag_Minimal, "Virtual Keyboard", 128, "", 0); + videodata->bKeyboardShown = true; +} + +static void OPENVR_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + videodata->oOverlay->HideKeyboard(); + videodata->bKeyboardShown = false; +} + +static bool OPENVR_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + return videodata->bKeyboardShown; +} + +static SDL_Cursor *OPENVR_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + SDL_Cursor *result = SDL_calloc(1, sizeof(SDL_Cursor)); + if (!result) { + return NULL; + } + + uint32_t * pixels = ImageSDLToOpenVRGL(surface, false); + SDL_CursorData *ovrc = (SDL_CursorData *)SDL_calloc(1, sizeof(*ovrc)); + if (!ovrc) { + SDL_free(result); + return NULL; + } + result->internal = ovrc; + + ov_glGenTextures(1, &ovrc->texture_id_handle); + ov_glBindTexture(GL_TEXTURE_2D, ovrc->texture_id_handle); + ov_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, surface->w, surface->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + SDL_free(pixels); + ov_glBindTexture(GL_TEXTURE_2D, 0); + + ovrc->hot_x = hot_x; + ovrc->hot_y = hot_y; + ovrc->w = surface->w; + ovrc->h = surface->h; + + return result; +} + +static bool OPENVR_ShowCursor(SDL_Cursor * cursor) +{ + SDL_CursorData * ovrc; + EVROverlayError e; + Texture_t texture; + HmdVector2_t hotspot; + VRTextureBounds_t tb; + + if (!cursor) { + global_openvr_driver->oOverlay->SetOverlayFlag(global_openvr_driver->overlayID, VROverlayFlags_HideLaserIntersection, true); + e = global_openvr_driver->oOverlay->SetOverlayCursor(global_openvr_driver->overlayID, k_ulOverlayHandleInvalid); + if (e != EVROverlayError_VROverlayError_None) { + return OPENVR_SetOverlayError(e); + } + return true; + } + + global_openvr_driver->oOverlay->SetOverlayFlag(global_openvr_driver->overlayID, VROverlayFlags_HideLaserIntersection, false); + + ovrc = cursor->internal; + + if (!ovrc) { + // Sometimes at boot there is a race condition where this is not ready. + return true; + } + + hotspot.v[0] = (float)ovrc->hot_x / (float)ovrc->w; + hotspot.v[1] = (float)ovrc->hot_y / (float)ovrc->h; + + texture.handle = (void*)(intptr_t)(ovrc->texture_id_handle); + texture.eType = ETextureType_TextureType_OpenGL; + texture.eColorSpace = EColorSpace_ColorSpace_Auto; + + tb.uMin = 0; + tb.uMax = 1; + tb.vMin = 1; + tb.vMax = 0; + + e = global_openvr_driver->oOverlay->SetOverlayTextureBounds(global_openvr_driver->cursorID, &tb); + if (e != EVROverlayError_VROverlayError_None) { + return OPENVR_SetOverlayError(e); + } + + e = global_openvr_driver->oOverlay->SetOverlayTransformCursor(global_openvr_driver->cursorID, &hotspot); + if (e != EVROverlayError_VROverlayError_None) { + return OPENVR_SetOverlayError(e); + } + + e = global_openvr_driver->oOverlay->SetOverlayTexture(global_openvr_driver->cursorID, &texture); + if (e != EVROverlayError_VROverlayError_None) { + return OPENVR_SetOverlayError(e); + } + + e = global_openvr_driver->oOverlay->SetOverlayCursor(global_openvr_driver->overlayID, global_openvr_driver->cursorID); + if (e != EVROverlayError_VROverlayError_None) { + return OPENVR_SetOverlayError(e); + } + + return true; +} + +static void OPENVR_FreeCursor(SDL_Cursor * cursor) +{ + if (cursor) { + SDL_CursorData *ovrc = cursor->internal; + if (ovrc) { + ov_glDeleteTextures(1, &ovrc->texture_id_handle); + SDL_free(ovrc); + } + SDL_free(cursor); + } +} + + +static bool OPENVR_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window * window, SDL_Surface * icon) +{ + if (!global_openvr_driver) { + return SDL_SetError("OpenVR Overlay not initialized"); + } + + unsigned texture_id_handle; + EVROverlayError e; + Texture_t texture; + uint32_t * pixels; + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + if (videodata->bIconOverridden) { + return SDL_SetError("OpenVR Icon is overridden."); + } + + pixels = ImageSDLToOpenVRGL(icon, true); + + ov_glGenTextures(1, &texture_id_handle); + ov_glBindTexture(GL_TEXTURE_2D, texture_id_handle); + ov_glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, icon->w, icon->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); + SDL_free(pixels); + ov_glBindTexture(GL_TEXTURE_2D, 0); + + texture.handle = (void*)(intptr_t)(texture_id_handle); + texture.eType = ETextureType_TextureType_OpenGL; + texture.eColorSpace = EColorSpace_ColorSpace_Auto; + + e = global_openvr_driver->oOverlay->SetOverlayTexture(videodata->thumbID, &texture); + if (e != EVROverlayError_VROverlayError_None) { + return OPENVR_SetOverlayError(e); + } + return true; +} + +static bool OPENVR_ShowMessageBox(SDL_VideoDevice *_this,const SDL_MessageBoxData *messageboxdata, int *buttonid) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + char empty = 0; + char * message = SDL_strdup(messageboxdata->message?messageboxdata->message:""); + char * title = SDL_strdup(messageboxdata->message?messageboxdata->message:""); + char * ok = SDL_strdup("Ok"); + videodata->oOverlay->ShowMessageOverlay(message, title, ok, &empty, &empty, &empty); + SDL_free(ok); + SDL_free(title); + SDL_free(message); + return true; +} + +static void InitializeMouseFunctions() +{ + SDL_Mouse *mouse = SDL_GetMouse(); + mouse->CreateCursor = OPENVR_CreateCursor; + mouse->ShowCursor = OPENVR_ShowCursor; + mouse->FreeCursor = OPENVR_FreeCursor; +} + +static void OPENVR_PumpEvents(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = (SDL_VideoData *)_this->internal; + struct VREvent_t nEvent; + if (videodata->overlayID) { + while (videodata->oOverlay->PollNextOverlayEvent(videodata->overlayID, &nEvent, sizeof(nEvent))) { + switch (nEvent.eventType) { + case EVREventType_VREvent_ButtonPress: + case EVREventType_VREvent_ButtonUnpress: + break; + case EVREventType_VREvent_MouseMove: + OPENVR_HandleMouse(nEvent.data.mouse.x, videodata->targh - nEvent.data.mouse.y, nEvent.data.mouse.button, 2); + break; + case EVREventType_VREvent_MouseButtonDown: + OPENVR_HandleMouse(nEvent.data.mouse.x, videodata->targh - nEvent.data.mouse.y, 0, 1); + break; + case EVREventType_VREvent_MouseButtonUp: + OPENVR_HandleMouse(nEvent.data.mouse.x, videodata->targh - nEvent.data.mouse.y, 0, 0); + break; + case EVREventType_VREvent_KeyboardCharInput: + SDL_SendKeyboardUnicodeKey(SDL_GetTicksNS(), nEvent.data.keyboard.cNewInput[0]); + break; + case EVREventType_VREvent_OverlayShown: + SDL_SetKeyboardFocus(videodata->window); + SDL_SendWindowEvent(videodata->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + SDL_SendWindowEvent(videodata->window, SDL_EVENT_WINDOW_SHOWN, 0, 0); + break; + case EVREventType_VREvent_OverlayHidden: + SDL_SendWindowEvent(videodata->window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); + SDL_SendWindowEvent(videodata->window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); + SDL_SetKeyboardFocus(NULL); + break; + case EVREventType_VREvent_OverlayClosed: + case EVREventType_VREvent_Quit: + SDL_Quit(); + break; + } + } + } +} + + +static SDL_VideoDevice *OPENVR_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + +#ifdef SDL_PLATFORM_WINDOWS + SDL_RegisterApp(NULL, 0, NULL); +#endif + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device) { + data = (struct SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + } else { + data = NULL; + } + if (!data) { +#ifdef SDL_PLATFORM_WINDOWS + SDL_UnregisterApp(); +#endif + SDL_free(device); + return NULL; + } + device->internal = data; + + { + const char * hint = SDL_GetHint(SDL_HINT_OPENVR_LIBRARY); + if (hint) + data->openVRLIB = SDL_LoadObject(hint); +#ifdef SDL_PLATFORM_WINDOWS + if (!data->openVRLIB) + data->openVRLIB = SDL_LoadObject("openvr_api.dll"); +#else + if (!data->openVRLIB) + data->openVRLIB = SDL_LoadObject("openvr_api.so"); +#endif + } + + if (!data->openVRLIB) { + SDL_SetError("Could not open OpenVR API Library"); + goto error; + } + + data->FN_VR_InitInternal = (intptr_t(*)(EVRInitError * peError, EVRApplicationType eType))SDL_LoadFunction(data->openVRLIB, "VR_InitInternal"); + data->FN_VR_GetVRInitErrorAsEnglishDescription = (const char *(*)(EVRInitError error))SDL_LoadFunction(data->openVRLIB, "VR_GetVRInitErrorAsEnglishDescription"); + data->FN_VR_GetGenericInterface = (intptr_t (*)(const char *pchInterfaceVersion, EVRInitError * peError))SDL_LoadFunction(data->openVRLIB, "VR_GetGenericInterface"); + if (!data->FN_VR_InitInternal || !data->FN_VR_GetVRInitErrorAsEnglishDescription || !data->FN_VR_GetGenericInterface) { + goto error; + } + + char fnname[128]; + EVRInitError e; + data->vrtoken = data->FN_VR_InitInternal(&e, EVRApplicationType_VRApplication_Overlay); + if (!data->vrtoken) { + const char *err = "Can't get english description"; + if (data->FN_VR_GetVRInitErrorAsEnglishDescription != NULL) + err = data->FN_VR_GetVRInitErrorAsEnglishDescription(e); + SDL_SetError("Could not generate OpenVR Context (%s)", err); + goto error; + } + + SDL_snprintf(fnname, 127, "FnTable:%s", IVRSystem_Version); + data->oSystem = (struct VR_IVRSystem_FnTable *)data->FN_VR_GetGenericInterface(fnname, &e); + SDL_snprintf(fnname, 127, "FnTable:%s", IVROverlay_Version); + data->oOverlay = (struct VR_IVROverlay_FnTable *)data->FN_VR_GetGenericInterface(fnname, &e); + SDL_snprintf(fnname, 127, "FnTable:%s", IVRInput_Version); + data->oInput = (struct VR_IVRInput_FnTable *)data->FN_VR_GetGenericInterface(fnname, &e); + + if (!data->oOverlay || !data->oSystem || !data->oInput) { + SDL_SetError("Could not get interfaces for the OpenVR System (%s), Overlay (%s) and Input (%s) versions", IVRSystem_Version, IVROverlay_Version, IVRInput_Version); + } + + const char *hint = SDL_GetHint("SDL_OPENVR_INPUT_PROFILE"); + char *loadpath = 0; + EVRInputError err; + + if (hint) { + SDL_asprintf(&loadpath, "%s", hint); + } else { + const char *basepath = SDL_GetBasePath(); + SDL_asprintf(&loadpath, "%ssdloverlay_actions.json", basepath); + } + if (!loadpath) { + goto error; + } + + err = data->oInput->SetActionManifestPath(loadpath); +#ifdef DEBUG_OPENVR + SDL_Log("Loaded action manifest at %s (%d)", loadpath, err); +#endif + SDL_free(loadpath); + if (err != EVRInputError_VRInputError_None) { + // I know we don't normally log, but this _really_ should be percolated + // up as far as we can. + SDL_Log("Could not load action manifest path"); + // If we didn't have a hint, this is a soft fail. + // If we did have the hint, then it's a hard fail. + if (hint) { + goto error; + } + } else { + if(!OPENVR_SetupJoystickBasedOnLoadedActionManifest(data)) { + goto error; + } + } + + // Setup amount of available displays + device->num_displays = 0; + + // Set device free function + device->free = OPENVR_Destroy; + + // Setup all functions which we can handle + device->VideoInit = OPENVR_VideoInit; + device->VideoQuit = OPENVR_VideoQuit; + device->SetDisplayMode = OPENVR_SetDisplayMode; + device->CreateSDLWindow = OPENVR_CreateWindow; + device->SetWindowTitle = OPENVR_SetWindowTitle; + device->SetWindowSize = OPENVR_SetWindowSize; + device->GetWindowSizeInPixels = OPENVR_GetWindowSizeInPixels; + device->ShowWindow = OPENVR_ShowWindow; + device->HideWindow = OPENVR_HideWindow; + device->DestroyWindow = OPENVR_DestroyWindow; + device->ShowMessageBox = OPENVR_ShowMessageBox; + +#ifdef SDL_VIDEO_DRIVER_WINDOWS +#ifdef SDL_VIDEO_OPENGL_WGL + device->GL_LoadLibrary = OPENVR_GL_LoadLibrary; + device->GL_GetProcAddress = OPENVR_GL_GetProcAddress; + device->GL_UnloadLibrary = OPENVR_GL_UnloadLibrary; + device->GL_CreateContext = OPENVR_GL_CreateContext; + device->GL_MakeCurrent = OPENVR_GL_MakeCurrent; + device->GL_SetSwapInterval = OPENVR_GL_SetSwapInterval; + device->GL_GetSwapInterval = OPENVR_GL_GetSwapInterval; + device->GL_SwapWindow = OPENVR_GL_SwapWindow; + device->GL_DestroyContext = OPENVR_GL_DestroyContext; +#elif SDL_VIDEO_OPENGL_EGL + device->GL_LoadLibrary = WIN_GLES_LoadLibrary; + device->GL_GetProcAddress = WIN_GLES_GetProcAddress; + device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary; + device->GL_CreateContext = WIN_GLES_CreateContext; + device->GL_MakeCurrent = WIN_GLES_MakeCurrent; + device->GL_SetSwapInterval = WIN_GLES_SetSwapInterval; + device->GL_GetSwapInterval = WIN_GLES_GetSwapInterval; + device->GL_SwapWindow = WIN_GLES_SwapWindow; + device->GL_DestroyContext = WIN_GLES_DestroyContext; +#endif +#else + device->GL_LoadLibrary = OVR_EGL_LoadLibrary; + device->GL_GetProcAddress = OVR_EGL_GetProcAddress; + device->GL_UnloadLibrary = OVR_EGL_UnloadLibrary; + device->GL_CreateContext = OVR_EGL_CreateContext; + device->GL_MakeCurrent = OVR_EGL_MakeCurrent; + device->GL_SetSwapInterval = OVR_EGL_SetSwapInterval; + device->GL_GetSwapInterval = OVR_EGL_GetSwapInterval; + device->GL_DestroyContext = OVR_EGL_DestroyContext; + device->GL_SwapWindow = OPENVR_GL_SwapWindow; +#endif + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WINDOWS) + device->Vulkan_LoadLibrary = WIN_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = WIN_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = WIN_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = WIN_Vulkan_CreateSurface; +#else + device->Vulkan_LoadLibrary = 0; + device->Vulkan_UnloadLibrary = 0; + device->Vulkan_GetInstanceExtensions = 0; + device->Vulkan_CreateSurface = 0; +#endif + + device->PumpEvents = OPENVR_PumpEvents; + device->VideoInit = OPENVR_VideoInit; + device->VideoQuit = OPENVR_VideoQuit; + + device->HasScreenKeyboardSupport = OPENVR_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = OPENVR_ShowScreenKeyboard; + device->HideScreenKeyboard = OPENVR_HideScreenKeyboard; + device->IsScreenKeyboardShown = OPENVR_IsScreenKeyboardShown; + device->SetWindowIcon = OPENVR_SetWindowIcon; + + return device; + +error: + OPENVR_Destroy(device); + return NULL; +} + +VideoBootStrap OPENVR_bootstrap = { + "openvr", "SDL OpenVR video driver", OPENVR_CreateDevice, NULL, false +}; + +#endif // SDL_VIDEO_DRIVER_WINDOWS + diff --git a/contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.h b/contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.h new file mode 100644 index 0000000..6eade3e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/openvr/SDL_openvrvideo.h @@ -0,0 +1,106 @@ +#ifndef _SDL_OPENVRVIDEO_H +#define _SDL_OPENVRVIDEO_H + +#ifdef SDL_VIDEO_DRIVER_WINDOWS +#ifdef EXTERN_C +#undef EXTERN_C +#endif +#endif + +// OpenVR has a LOT of unused variables that GCC will freak out on. +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-variable" +#endif + +#define USE_SDL +#include "openvr_capi.h" + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + +#include + +#ifndef SDL_VIDEO_DRIVER_WINDOWS + +#include +#include +#include +#include +#include +#include + +#endif + + +struct SDL_WindowData +{ +#ifdef SDL_VIDEO_DRIVER_WINDOWS + SDL_Window *window; + HWND hwnd; + HWND parent; + HDC hdc; + HDC mdc; +#else + int dummy; +#endif +}; + +struct SDL_VideoData { + void * openVRLIB; + intptr_t vrtoken; + intptr_t (*FN_VR_InitInternal)( EVRInitError *peError, EVRApplicationType eType ); + const char *(*FN_VR_GetVRInitErrorAsEnglishDescription)( EVRInitError error ); + intptr_t (*FN_VR_GetGenericInterface)( const char *pchInterfaceVersion, EVRInitError *peError ); + + int is_buffer_rendering; + + unsigned int overlaytexture; + + unsigned int fbo, rbo; + + int saved_texture_state; + + struct VR_IVRSystem_FnTable *oSystem; + struct VR_IVROverlay_FnTable *oOverlay; + struct VR_IVRInput_FnTable * oInput; + VROverlayHandle_t overlayID, thumbID, cursorID; + + char * sOverlayName; + + VRActionSetHandle_t input_action_set; + VRActionHandle_t * input_action_handles_buttons; + int input_action_handles_buttons_count; + VRActionHandle_t * input_action_handles_axes; + int input_action_handles_axes_count; + VRActionHandle_t input_action_handles_haptics[2]; + + bool bKeyboardShown; + bool bHasShownOverlay; + int targw, targh; + int last_targw, last_targh; + int swap_interval; + + bool bDidCreateOverlay; + bool renderdoc_debugmarker_frame_end; + bool bIconOverridden; + + SDL_Window * window; + + SDL_Joystick *virtual_joystick; +#ifdef SDL_VIDEO_DRIVER_WINDOWS + HDC hdc; + HGLRC hglrc; +#else + EGLDisplay eglDpy; + EGLContext eglCtx; +#endif +}; + +struct SDL_DisplayData +{ + int dummy; +}; + +#endif diff --git a/contrib/SDL-3.2.8/src/video/openvr/openvr_capi.h b/contrib/SDL-3.2.8/src/video/openvr/openvr_capi.h new file mode 100644 index 0000000..a772626 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/openvr/openvr_capi.h @@ -0,0 +1,3200 @@ +/* + Copyright (c) 2015, Valve Corporation + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, + are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + + 3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software without + specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR + ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +//============================================================================= +// +// Purpose: Header for flatted SteamAPI. Use this for binding to other languages. +// This file is auto-generated, do not edit it. +// +//============================================================================= + +#ifndef __OPENVR_API_FLAT_H__ +#define __OPENVR_API_FLAT_H__ +#if defined( _WIN32 ) || defined( __clang__ ) +#pragma once +#endif + +#ifdef __cplusplus +#define EXTERN_C extern "C" +#else +#define EXTERN_C +#endif + +#if defined( _WIN32 ) +#define OPENVR_FNTABLE_CALLTYPE __stdcall +#else +#define OPENVR_FNTABLE_CALLTYPE +#endif + +// OPENVR API export macro +#if defined( _WIN32 ) && !defined( _X360 ) + #if defined( OPENVR_API_EXPORTS ) + #define S_API EXTERN_C __declspec( dllexport ) + #elif defined( OPENVR_API_NODLL ) + #define S_API EXTERN_C + #else + #define S_API extern "C" __declspec( dllimport ) + #endif // OPENVR_API_EXPORTS +#elif defined( __GNUC__ ) + #if defined( OPENVR_API_EXPORTS ) + #define S_API EXTERN_C __attribute__ ((visibility("default"))) + #else + #define S_API EXTERN_C + #endif // OPENVR_API_EXPORTS +#else // !WIN32 + #if defined( OPENVR_API_EXPORTS ) + #define S_API EXTERN_C + #else + #define S_API EXTERN_C + #endif // OPENVR_API_EXPORTS +#endif + +#ifndef USE_SDL +#include + +#if defined( __WIN32 ) +typedef char bool; +#else +#include +#endif +#endif // USE_SDL + +// OpenVR Constants + +static const unsigned long k_nDriverNone = 4294967295; +static const unsigned long k_unMaxDriverDebugResponseSize = 32768; +static const unsigned long k_unTrackedDeviceIndex_Hmd = 0; +static const unsigned long k_unMaxTrackedDeviceCount = 64; +static const unsigned long k_unTrackedDeviceIndexOther = 4294967294; +static const unsigned long k_unTrackedDeviceIndexInvalid = 4294967295; +static const unsigned long long k_ulInvalidPropertyContainer = 0; +static const unsigned long k_unInvalidPropertyTag = 0; +static const unsigned long long k_ulInvalidDriverHandle = 0; +static const unsigned long k_unFloatPropertyTag = 1; +static const unsigned long k_unInt32PropertyTag = 2; +static const unsigned long k_unUint64PropertyTag = 3; +static const unsigned long k_unBoolPropertyTag = 4; +static const unsigned long k_unStringPropertyTag = 5; +static const unsigned long k_unErrorPropertyTag = 6; +static const unsigned long k_unDoublePropertyTag = 7; +static const unsigned long k_unHmdMatrix34PropertyTag = 20; +static const unsigned long k_unHmdMatrix44PropertyTag = 21; +static const unsigned long k_unHmdVector3PropertyTag = 22; +static const unsigned long k_unHmdVector4PropertyTag = 23; +static const unsigned long k_unHmdVector2PropertyTag = 24; +static const unsigned long k_unHmdQuadPropertyTag = 25; +static const unsigned long k_unHiddenAreaPropertyTag = 30; +static const unsigned long k_unPathHandleInfoTag = 31; +static const unsigned long k_unActionPropertyTag = 32; +static const unsigned long k_unInputValuePropertyTag = 33; +static const unsigned long k_unWildcardPropertyTag = 34; +static const unsigned long k_unHapticVibrationPropertyTag = 35; +static const unsigned long k_unSkeletonPropertyTag = 36; +static const unsigned long k_unSpatialAnchorPosePropertyTag = 40; +static const unsigned long k_unJsonPropertyTag = 41; +static const unsigned long k_unActiveActionSetPropertyTag = 42; +static const unsigned long k_unOpenVRInternalReserved_Start = 1000; +static const unsigned long k_unOpenVRInternalReserved_End = 10000; +static const unsigned long k_unMaxPropertyStringSize = 32768; +static const unsigned long long k_ulInvalidActionHandle = 0; +static const unsigned long long k_ulInvalidActionSetHandle = 0; +static const unsigned long long k_ulInvalidInputValueHandle = 0; +static const unsigned long k_unControllerStateAxisCount = 5; +static const unsigned long long k_ulOverlayHandleInvalid = 0; +static const unsigned long k_unMaxDistortionFunctionParameters = 8; +static const unsigned long k_unScreenshotHandleInvalid = 0; +static const char * IVRSystem_Version = "IVRSystem_022"; +static const char * IVRExtendedDisplay_Version = "IVRExtendedDisplay_001"; +static const char * IVRTrackedCamera_Version = "IVRTrackedCamera_006"; +static const unsigned long k_unMaxApplicationKeyLength = 128; +static const char * k_pch_MimeType_HomeApp = "vr/home"; +static const char * k_pch_MimeType_GameTheater = "vr/game_theater"; +static const char * IVRApplications_Version = "IVRApplications_007"; +static const char * IVRChaperone_Version = "IVRChaperone_004"; +static const char * IVRChaperoneSetup_Version = "IVRChaperoneSetup_006"; +static const char * IVRCompositor_Version = "IVRCompositor_027"; +static const unsigned long k_unVROverlayMaxKeyLength = 128; +static const unsigned long k_unVROverlayMaxNameLength = 128; +static const unsigned long k_unMaxOverlayCount = 128; +static const unsigned long k_unMaxOverlayIntersectionMaskPrimitivesCount = 32; +static const char * IVROverlay_Version = "IVROverlay_026"; +static const char * IVROverlayView_Version = "IVROverlayView_003"; +static const unsigned long k_unHeadsetViewMaxWidth = 3840; +static const unsigned long k_unHeadsetViewMaxHeight = 2160; +static const char * k_pchHeadsetViewOverlayKey = "system.HeadsetView"; +static const char * IVRHeadsetView_Version = "IVRHeadsetView_001"; +static const char * k_pch_Controller_Component_GDC2015 = "gdc2015"; +static const char * k_pch_Controller_Component_Base = "base"; +static const char * k_pch_Controller_Component_Tip = "tip"; +static const char * k_pch_Controller_Component_OpenXR_Aim = "openxr_aim"; +static const char * k_pch_Controller_Component_HandGrip = "handgrip"; +static const char * k_pch_Controller_Component_OpenXR_Grip = "openxr_grip"; +static const char * k_pch_Controller_Component_OpenXR_HandModel = "openxr_handmodel"; +static const char * k_pch_Controller_Component_Status = "status"; +static const char * IVRRenderModels_Version = "IVRRenderModels_006"; +static const unsigned long k_unNotificationTextMaxSize = 256; +static const char * IVRNotifications_Version = "IVRNotifications_002"; +static const unsigned long k_unMaxSettingsKeyLength = 128; +static const char * IVRSettings_Version = "IVRSettings_003"; +static const char * k_pch_SteamVR_Section = "steamvr"; +static const char * k_pch_SteamVR_RequireHmd_String = "requireHmd"; +static const char * k_pch_SteamVR_ForcedDriverKey_String = "forcedDriver"; +static const char * k_pch_SteamVR_ForcedHmdKey_String = "forcedHmd"; +static const char * k_pch_SteamVR_DisplayDebug_Bool = "displayDebug"; +static const char * k_pch_SteamVR_DebugProcessPipe_String = "debugProcessPipe"; +static const char * k_pch_SteamVR_DisplayDebugX_Int32 = "displayDebugX"; +static const char * k_pch_SteamVR_DisplayDebugY_Int32 = "displayDebugY"; +static const char * k_pch_SteamVR_SendSystemButtonToAllApps_Bool = "sendSystemButtonToAllApps"; +static const char * k_pch_SteamVR_LogLevel_Int32 = "loglevel"; +static const char * k_pch_SteamVR_IPD_Float = "ipd"; +static const char * k_pch_SteamVR_Background_String = "background"; +static const char * k_pch_SteamVR_BackgroundUseDomeProjection_Bool = "backgroundUseDomeProjection"; +static const char * k_pch_SteamVR_BackgroundCameraHeight_Float = "backgroundCameraHeight"; +static const char * k_pch_SteamVR_BackgroundDomeRadius_Float = "backgroundDomeRadius"; +static const char * k_pch_SteamVR_GridColor_String = "gridColor"; +static const char * k_pch_SteamVR_PlayAreaColor_String = "playAreaColor"; +static const char * k_pch_SteamVR_TrackingLossColor_String = "trackingLossColor"; +static const char * k_pch_SteamVR_ShowStage_Bool = "showStage"; +static const char * k_pch_SteamVR_DrawTrackingReferences_Bool = "drawTrackingReferences"; +static const char * k_pch_SteamVR_ActivateMultipleDrivers_Bool = "activateMultipleDrivers"; +static const char * k_pch_SteamVR_UsingSpeakers_Bool = "usingSpeakers"; +static const char * k_pch_SteamVR_SpeakersForwardYawOffsetDegrees_Float = "speakersForwardYawOffsetDegrees"; +static const char * k_pch_SteamVR_BaseStationPowerManagement_Int32 = "basestationPowerManagement"; +static const char * k_pch_SteamVR_ShowBaseStationPowerManagementTip_Int32 = "ShowBaseStationPowerManagementTip"; +static const char * k_pch_SteamVR_NeverKillProcesses_Bool = "neverKillProcesses"; +static const char * k_pch_SteamVR_SupersampleScale_Float = "supersampleScale"; +static const char * k_pch_SteamVR_MaxRecommendedResolution_Int32 = "maxRecommendedResolution"; +static const char * k_pch_SteamVR_MotionSmoothing_Bool = "motionSmoothing"; +static const char * k_pch_SteamVR_MotionSmoothingOverride_Int32 = "motionSmoothingOverride"; +static const char * k_pch_SteamVR_FramesToThrottle_Int32 = "framesToThrottle"; +static const char * k_pch_SteamVR_AdditionalFramesToPredict_Int32 = "additionalFramesToPredict"; +static const char * k_pch_SteamVR_WorldScale_Float = "worldScale"; +static const char * k_pch_SteamVR_FovScale_Int32 = "fovScale"; +static const char * k_pch_SteamVR_DisableAsyncReprojection_Bool = "disableAsync"; +static const char * k_pch_SteamVR_ForceFadeOnBadTracking_Bool = "forceFadeOnBadTracking"; +static const char * k_pch_SteamVR_DefaultMirrorView_Int32 = "mirrorView"; +static const char * k_pch_SteamVR_ShowLegacyMirrorView_Bool = "showLegacyMirrorView"; +static const char * k_pch_SteamVR_MirrorViewVisibility_Bool = "showMirrorView"; +static const char * k_pch_SteamVR_MirrorViewDisplayMode_Int32 = "mirrorViewDisplayMode"; +static const char * k_pch_SteamVR_MirrorViewEye_Int32 = "mirrorViewEye"; +static const char * k_pch_SteamVR_MirrorViewGeometry_String = "mirrorViewGeometry"; +static const char * k_pch_SteamVR_MirrorViewGeometryMaximized_String = "mirrorViewGeometryMaximized"; +static const char * k_pch_SteamVR_PerfGraphVisibility_Bool = "showPerfGraph"; +static const char * k_pch_SteamVR_StartMonitorFromAppLaunch = "startMonitorFromAppLaunch"; +static const char * k_pch_SteamVR_StartCompositorFromAppLaunch_Bool = "startCompositorFromAppLaunch"; +static const char * k_pch_SteamVR_StartDashboardFromAppLaunch_Bool = "startDashboardFromAppLaunch"; +static const char * k_pch_SteamVR_StartOverlayAppsFromDashboard_Bool = "startOverlayAppsFromDashboard"; +static const char * k_pch_SteamVR_EnableHomeApp = "enableHomeApp"; +static const char * k_pch_SteamVR_CycleBackgroundImageTimeSec_Int32 = "CycleBackgroundImageTimeSec"; +static const char * k_pch_SteamVR_RetailDemo_Bool = "retailDemo"; +static const char * k_pch_SteamVR_IpdOffset_Float = "ipdOffset"; +static const char * k_pch_SteamVR_AllowSupersampleFiltering_Bool = "allowSupersampleFiltering"; +static const char * k_pch_SteamVR_SupersampleManualOverride_Bool = "supersampleManualOverride"; +static const char * k_pch_SteamVR_EnableLinuxVulkanAsync_Bool = "enableLinuxVulkanAsync"; +static const char * k_pch_SteamVR_AllowDisplayLockedMode_Bool = "allowDisplayLockedMode"; +static const char * k_pch_SteamVR_HaveStartedTutorialForNativeChaperoneDriver_Bool = "haveStartedTutorialForNativeChaperoneDriver"; +static const char * k_pch_SteamVR_ForceWindows32bitVRMonitor = "forceWindows32BitVRMonitor"; +static const char * k_pch_SteamVR_DebugInputBinding = "debugInputBinding"; +static const char * k_pch_SteamVR_DoNotFadeToGrid = "doNotFadeToGrid"; +static const char * k_pch_SteamVR_RenderCameraMode = "renderCameraMode"; +static const char * k_pch_SteamVR_EnableSharedResourceJournaling = "enableSharedResourceJournaling"; +static const char * k_pch_SteamVR_EnableSafeMode = "enableSafeMode"; +static const char * k_pch_SteamVR_PreferredRefreshRate = "preferredRefreshRate"; +static const char * k_pch_SteamVR_LastVersionNotice = "lastVersionNotice"; +static const char * k_pch_SteamVR_LastVersionNoticeDate = "lastVersionNoticeDate"; +static const char * k_pch_SteamVR_HmdDisplayColorGainR_Float = "hmdDisplayColorGainR"; +static const char * k_pch_SteamVR_HmdDisplayColorGainG_Float = "hmdDisplayColorGainG"; +static const char * k_pch_SteamVR_HmdDisplayColorGainB_Float = "hmdDisplayColorGainB"; +static const char * k_pch_SteamVR_CustomIconStyle_String = "customIconStyle"; +static const char * k_pch_SteamVR_CustomOffIconStyle_String = "customOffIconStyle"; +static const char * k_pch_SteamVR_CustomIconForceUpdate_String = "customIconForceUpdate"; +static const char * k_pch_SteamVR_AllowGlobalActionSetPriority = "globalActionSetPriority"; +static const char * k_pch_SteamVR_OverlayRenderQuality = "overlayRenderQuality_2"; +static const char * k_pch_SteamVR_BlockOculusSDKOnOpenVRLaunchOption_Bool = "blockOculusSDKOnOpenVRLaunchOption"; +static const char * k_pch_SteamVR_BlockOculusSDKOnAllLaunches_Bool = "blockOculusSDKOnAllLaunches"; +static const char * k_pch_SteamVR_HDCPLegacyCompatibility_Bool = "hdcp14legacyCompatibility"; +static const char * k_pch_SteamVR_DisplayPortTrainingMode_Int = "displayPortTrainingMode"; +static const char * k_pch_SteamVR_UsePrism_Bool = "usePrism"; +static const char * k_pch_DirectMode_Section = "direct_mode"; +static const char * k_pch_DirectMode_Enable_Bool = "enable"; +static const char * k_pch_DirectMode_Count_Int32 = "count"; +static const char * k_pch_DirectMode_EdidVid_Int32 = "edidVid"; +static const char * k_pch_DirectMode_EdidPid_Int32 = "edidPid"; +static const char * k_pch_Lighthouse_Section = "driver_lighthouse"; +static const char * k_pch_Lighthouse_DisableIMU_Bool = "disableimu"; +static const char * k_pch_Lighthouse_DisableIMUExceptHMD_Bool = "disableimuexcepthmd"; +static const char * k_pch_Lighthouse_UseDisambiguation_String = "usedisambiguation"; +static const char * k_pch_Lighthouse_DisambiguationDebug_Int32 = "disambiguationdebug"; +static const char * k_pch_Lighthouse_PrimaryBasestation_Int32 = "primarybasestation"; +static const char * k_pch_Lighthouse_DBHistory_Bool = "dbhistory"; +static const char * k_pch_Lighthouse_EnableBluetooth_Bool = "enableBluetooth"; +static const char * k_pch_Lighthouse_PowerManagedBaseStations_String = "PowerManagedBaseStations"; +static const char * k_pch_Lighthouse_PowerManagedBaseStations2_String = "PowerManagedBaseStations2"; +static const char * k_pch_Lighthouse_InactivityTimeoutForBaseStations_Int32 = "InactivityTimeoutForBaseStations"; +static const char * k_pch_Lighthouse_EnableImuFallback_Bool = "enableImuFallback"; +static const char * k_pch_Null_Section = "driver_null"; +static const char * k_pch_Null_SerialNumber_String = "serialNumber"; +static const char * k_pch_Null_ModelNumber_String = "modelNumber"; +static const char * k_pch_Null_WindowX_Int32 = "windowX"; +static const char * k_pch_Null_WindowY_Int32 = "windowY"; +static const char * k_pch_Null_WindowWidth_Int32 = "windowWidth"; +static const char * k_pch_Null_WindowHeight_Int32 = "windowHeight"; +static const char * k_pch_Null_RenderWidth_Int32 = "renderWidth"; +static const char * k_pch_Null_RenderHeight_Int32 = "renderHeight"; +static const char * k_pch_Null_SecondsFromVsyncToPhotons_Float = "secondsFromVsyncToPhotons"; +static const char * k_pch_Null_DisplayFrequency_Float = "displayFrequency"; +static const char * k_pch_WindowsMR_Section = "driver_holographic"; +static const char * k_pch_UserInterface_Section = "userinterface"; +static const char * k_pch_UserInterface_StatusAlwaysOnTop_Bool = "StatusAlwaysOnTop"; +static const char * k_pch_UserInterface_MinimizeToTray_Bool = "MinimizeToTray"; +static const char * k_pch_UserInterface_HidePopupsWhenStatusMinimized_Bool = "HidePopupsWhenStatusMinimized"; +static const char * k_pch_UserInterface_Screenshots_Bool = "screenshots"; +static const char * k_pch_UserInterface_ScreenshotType_Int = "screenshotType"; +static const char * k_pch_Notifications_Section = "notifications"; +static const char * k_pch_Notifications_DoNotDisturb_Bool = "DoNotDisturb"; +static const char * k_pch_Keyboard_Section = "keyboard"; +static const char * k_pch_Keyboard_TutorialCompletions = "TutorialCompletions"; +static const char * k_pch_Keyboard_ScaleX = "ScaleX"; +static const char * k_pch_Keyboard_ScaleY = "ScaleY"; +static const char * k_pch_Keyboard_OffsetLeftX = "OffsetLeftX"; +static const char * k_pch_Keyboard_OffsetRightX = "OffsetRightX"; +static const char * k_pch_Keyboard_OffsetY = "OffsetY"; +static const char * k_pch_Keyboard_Smoothing = "Smoothing"; +static const char * k_pch_Perf_Section = "perfcheck"; +static const char * k_pch_Perf_PerfGraphInHMD_Bool = "perfGraphInHMD"; +static const char * k_pch_Perf_AllowTimingStore_Bool = "allowTimingStore"; +static const char * k_pch_Perf_SaveTimingsOnExit_Bool = "saveTimingsOnExit"; +static const char * k_pch_Perf_TestData_Float = "perfTestData"; +static const char * k_pch_Perf_GPUProfiling_Bool = "GPUProfiling"; +static const char * k_pch_CollisionBounds_Section = "collisionBounds"; +static const char * k_pch_CollisionBounds_Style_Int32 = "CollisionBoundsStyle"; +static const char * k_pch_CollisionBounds_GroundPerimeterOn_Bool = "CollisionBoundsGroundPerimeterOn"; +static const char * k_pch_CollisionBounds_CenterMarkerOn_Bool = "CollisionBoundsCenterMarkerOn"; +static const char * k_pch_CollisionBounds_PlaySpaceOn_Bool = "CollisionBoundsPlaySpaceOn"; +static const char * k_pch_CollisionBounds_FadeDistance_Float = "CollisionBoundsFadeDistance"; +static const char * k_pch_CollisionBounds_WallHeight_Float = "CollisionBoundsWallHeight"; +static const char * k_pch_CollisionBounds_ColorGammaR_Int32 = "CollisionBoundsColorGammaR"; +static const char * k_pch_CollisionBounds_ColorGammaG_Int32 = "CollisionBoundsColorGammaG"; +static const char * k_pch_CollisionBounds_ColorGammaB_Int32 = "CollisionBoundsColorGammaB"; +static const char * k_pch_CollisionBounds_ColorGammaA_Int32 = "CollisionBoundsColorGammaA"; +static const char * k_pch_CollisionBounds_EnableDriverImport = "enableDriverBoundsImport"; +static const char * k_pch_Camera_Section = "camera"; +static const char * k_pch_Camera_EnableCamera_Bool = "enableCamera"; +static const char * k_pch_Camera_ShowOnController_Bool = "showOnController"; +static const char * k_pch_Camera_EnableCameraForCollisionBounds_Bool = "enableCameraForCollisionBounds"; +static const char * k_pch_Camera_RoomView_Int32 = "roomView"; +static const char * k_pch_Camera_BoundsColorGammaR_Int32 = "cameraBoundsColorGammaR"; +static const char * k_pch_Camera_BoundsColorGammaG_Int32 = "cameraBoundsColorGammaG"; +static const char * k_pch_Camera_BoundsColorGammaB_Int32 = "cameraBoundsColorGammaB"; +static const char * k_pch_Camera_BoundsColorGammaA_Int32 = "cameraBoundsColorGammaA"; +static const char * k_pch_Camera_BoundsStrength_Int32 = "cameraBoundsStrength"; +static const char * k_pch_Camera_RoomViewStyle_Int32 = "roomViewStyle"; +static const char * k_pch_audio_Section = "audio"; +static const char * k_pch_audio_SetOsDefaultPlaybackDevice_Bool = "setOsDefaultPlaybackDevice"; +static const char * k_pch_audio_EnablePlaybackDeviceOverride_Bool = "enablePlaybackDeviceOverride"; +static const char * k_pch_audio_PlaybackDeviceOverride_String = "playbackDeviceOverride"; +static const char * k_pch_audio_PlaybackDeviceOverrideName_String = "playbackDeviceOverrideName"; +static const char * k_pch_audio_SetOsDefaultRecordingDevice_Bool = "setOsDefaultRecordingDevice"; +static const char * k_pch_audio_EnableRecordingDeviceOverride_Bool = "enableRecordingDeviceOverride"; +static const char * k_pch_audio_RecordingDeviceOverride_String = "recordingDeviceOverride"; +static const char * k_pch_audio_RecordingDeviceOverrideName_String = "recordingDeviceOverrideName"; +static const char * k_pch_audio_EnablePlaybackMirror_Bool = "enablePlaybackMirror"; +static const char * k_pch_audio_PlaybackMirrorDevice_String = "playbackMirrorDevice"; +static const char * k_pch_audio_PlaybackMirrorDeviceName_String = "playbackMirrorDeviceName"; +static const char * k_pch_audio_OldPlaybackMirrorDevice_String = "onPlaybackMirrorDevice"; +static const char * k_pch_audio_ActiveMirrorDevice_String = "activePlaybackMirrorDevice"; +static const char * k_pch_audio_EnablePlaybackMirrorIndependentVolume_Bool = "enablePlaybackMirrorIndependentVolume"; +static const char * k_pch_audio_LastHmdPlaybackDeviceId_String = "lastHmdPlaybackDeviceId"; +static const char * k_pch_audio_VIVEHDMIGain = "viveHDMIGain"; +static const char * k_pch_audio_DualSpeakerAndJackOutput_Bool = "dualSpeakerAndJackOutput"; +static const char * k_pch_audio_MuteMicMonitor_Bool = "muteMicMonitor"; +static const char * k_pch_Power_Section = "power"; +static const char * k_pch_Power_PowerOffOnExit_Bool = "powerOffOnExit"; +static const char * k_pch_Power_TurnOffScreensTimeout_Float = "turnOffScreensTimeout"; +static const char * k_pch_Power_TurnOffControllersTimeout_Float = "turnOffControllersTimeout"; +static const char * k_pch_Power_ReturnToWatchdogTimeout_Float = "returnToWatchdogTimeout"; +static const char * k_pch_Power_AutoLaunchSteamVROnButtonPress = "autoLaunchSteamVROnButtonPress"; +static const char * k_pch_Power_PauseCompositorOnStandby_Bool = "pauseCompositorOnStandby"; +static const char * k_pch_Dashboard_Section = "dashboard"; +static const char * k_pch_Dashboard_EnableDashboard_Bool = "enableDashboard"; +static const char * k_pch_Dashboard_ArcadeMode_Bool = "arcadeMode"; +static const char * k_pch_Dashboard_Position = "position"; +static const char * k_pch_Dashboard_DesktopScale = "desktopScale"; +static const char * k_pch_Dashboard_DashboardScale = "dashboardScale"; +static const char * k_pch_Dashboard_UseStandaloneSystemLayer = "standaloneSystemLayer"; +static const char * k_pch_Dashboard_StickyDashboard = "stickyDashboard"; +static const char * k_pch_modelskin_Section = "modelskins"; +static const char * k_pch_Driver_Enable_Bool = "enable"; +static const char * k_pch_Driver_BlockedBySafemode_Bool = "blocked_by_safe_mode"; +static const char * k_pch_Driver_LoadPriority_Int32 = "loadPriority"; +static const char * k_pch_WebInterface_Section = "WebInterface"; +static const char * k_pch_VRWebHelper_Section = "VRWebHelper"; +static const char * k_pch_VRWebHelper_DebuggerEnabled_Bool = "DebuggerEnabled"; +static const char * k_pch_VRWebHelper_DebuggerPort_Int32 = "DebuggerPort"; +static const char * k_pch_TrackingOverride_Section = "TrackingOverrides"; +static const char * k_pch_App_BindingAutosaveURLSuffix_String = "AutosaveURL"; +static const char * k_pch_App_BindingLegacyAPISuffix_String = "_legacy"; +static const char * k_pch_App_BindingSteamVRInputAPISuffix_String = "_steamvrinput"; +static const char * k_pch_App_BindingOpenXRAPISuffix_String = "_openxr"; +static const char * k_pch_App_BindingCurrentURLSuffix_String = "CurrentURL"; +static const char * k_pch_App_BindingPreviousURLSuffix_String = "PreviousURL"; +static const char * k_pch_App_NeedToUpdateAutosaveSuffix_Bool = "NeedToUpdateAutosave"; +static const char * k_pch_App_DominantHand_Int32 = "DominantHand"; +static const char * k_pch_App_BlockOculusSDK_Bool = "blockOculusSDK"; +static const char * k_pch_Trackers_Section = "trackers"; +static const char * k_pch_DesktopUI_Section = "DesktopUI"; +static const char * k_pch_LastKnown_Section = "LastKnown"; +static const char * k_pch_LastKnown_HMDManufacturer_String = "HMDManufacturer"; +static const char * k_pch_LastKnown_HMDModel_String = "HMDModel"; +static const char * k_pch_DismissedWarnings_Section = "DismissedWarnings"; +static const char * k_pch_Input_Section = "input"; +static const char * k_pch_Input_LeftThumbstickRotation_Float = "leftThumbstickRotation"; +static const char * k_pch_Input_RightThumbstickRotation_Float = "rightThumbstickRotation"; +static const char * k_pch_Input_ThumbstickDeadzone_Float = "thumbstickDeadzone"; +static const char * k_pch_GpuSpeed_Section = "GpuSpeed"; +static const char * IVRScreenshots_Version = "IVRScreenshots_001"; +static const char * IVRResources_Version = "IVRResources_001"; +static const char * IVRDriverManager_Version = "IVRDriverManager_001"; +static const unsigned long k_unMaxActionNameLength = 64; +static const unsigned long k_unMaxActionSetNameLength = 64; +static const unsigned long k_unMaxActionOriginCount = 16; +static const unsigned long k_unMaxBoneNameLength = 32; +static const int k_nActionSetOverlayGlobalPriorityMin = 16777216; +static const int k_nActionSetOverlayGlobalPriorityMax = 33554431; +static const int k_nActionSetPriorityReservedMin = 33554432; +static const char * IVRInput_Version = "IVRInput_010"; +static const unsigned long long k_ulInvalidIOBufferHandle = 0; +static const char * IVRIOBuffer_Version = "IVRIOBuffer_002"; +static const unsigned long k_ulInvalidSpatialAnchorHandle = 0; +static const char * IVRSpatialAnchors_Version = "IVRSpatialAnchors_001"; +static const char * IVRDebug_Version = "IVRDebug_001"; +static const unsigned long long k_ulDisplayRedirectContainer = 25769803779; +static const char * IVRProperties_Version = "IVRProperties_001"; +static const char * k_pchPathUserHandRight = "/user/hand/right"; +static const char * k_pchPathUserHandLeft = "/user/hand/left"; +static const char * k_pchPathUserHandPrimary = "/user/hand/primary"; +static const char * k_pchPathUserHandSecondary = "/user/hand/secondary"; +static const char * k_pchPathUserHead = "/user/head"; +static const char * k_pchPathUserGamepad = "/user/gamepad"; +static const char * k_pchPathUserTreadmill = "/user/treadmill"; +static const char * k_pchPathUserStylus = "/user/stylus"; +static const char * k_pchPathDevices = "/devices"; +static const char * k_pchPathDevicePath = "/device_path"; +static const char * k_pchPathBestAliasPath = "/best_alias_path"; +static const char * k_pchPathBoundTrackerAliasPath = "/bound_tracker_path"; +static const char * k_pchPathBoundTrackerRole = "/bound_tracker_role"; +static const char * k_pchPathPoseRaw = "/pose/raw"; +static const char * k_pchPathPoseTip = "/pose/tip"; +static const char * k_pchPathPoseGrip = "/pose/grip"; +static const char * k_pchPathSystemButtonClick = "/input/system/click"; +static const char * k_pchPathProximity = "/proximity"; +static const char * k_pchPathControllerTypePrefix = "/controller_type/"; +static const char * k_pchPathInputProfileSuffix = "/input_profile"; +static const char * k_pchPathBindingNameSuffix = "/binding_name"; +static const char * k_pchPathBindingUrlSuffix = "/binding_url"; +static const char * k_pchPathBindingErrorSuffix = "/binding_error"; +static const char * k_pchPathActiveActionSets = "/active_action_sets"; +static const char * k_pchPathComponentUpdates = "/total_component_updates"; +static const char * k_pchPathUserFootLeft = "/user/foot/left"; +static const char * k_pchPathUserFootRight = "/user/foot/right"; +static const char * k_pchPathUserShoulderLeft = "/user/shoulder/left"; +static const char * k_pchPathUserShoulderRight = "/user/shoulder/right"; +static const char * k_pchPathUserElbowLeft = "/user/elbow/left"; +static const char * k_pchPathUserElbowRight = "/user/elbow/right"; +static const char * k_pchPathUserKneeLeft = "/user/knee/left"; +static const char * k_pchPathUserKneeRight = "/user/knee/right"; +static const char * k_pchPathUserWaist = "/user/waist"; +static const char * k_pchPathUserChest = "/user/chest"; +static const char * k_pchPathUserCamera = "/user/camera"; +static const char * k_pchPathUserKeyboard = "/user/keyboard"; +static const char * k_pchPathClientAppKey = "/client_info/app_key"; +static const unsigned long long k_ulInvalidPathHandle = 0; +static const char * IVRPaths_Version = "IVRPaths_001"; +static const char * IVRBlockQueue_Version = "IVRBlockQueue_005"; + +// OpenVR Enums + +typedef enum EVREye +{ + EVREye_Eye_Left = 0, + EVREye_Eye_Right = 1, +} EVREye; + +typedef enum ETextureType +{ + ETextureType_TextureType_Invalid = -1, + ETextureType_TextureType_DirectX = 0, + ETextureType_TextureType_OpenGL = 1, + ETextureType_TextureType_Vulkan = 2, + ETextureType_TextureType_IOSurface = 3, + ETextureType_TextureType_DirectX12 = 4, + ETextureType_TextureType_DXGISharedHandle = 5, + ETextureType_TextureType_Metal = 6, +} ETextureType; + +typedef enum EColorSpace +{ + EColorSpace_ColorSpace_Auto = 0, + EColorSpace_ColorSpace_Gamma = 1, + EColorSpace_ColorSpace_Linear = 2, +} EColorSpace; + +typedef enum ETrackingResult +{ + ETrackingResult_TrackingResult_Uninitialized = 1, + ETrackingResult_TrackingResult_Calibrating_InProgress = 100, + ETrackingResult_TrackingResult_Calibrating_OutOfRange = 101, + ETrackingResult_TrackingResult_Running_OK = 200, + ETrackingResult_TrackingResult_Running_OutOfRange = 201, + ETrackingResult_TrackingResult_Fallback_RotationOnly = 300, +} ETrackingResult; + +typedef enum ETrackedDeviceClass +{ + ETrackedDeviceClass_TrackedDeviceClass_Invalid = 0, + ETrackedDeviceClass_TrackedDeviceClass_HMD = 1, + ETrackedDeviceClass_TrackedDeviceClass_Controller = 2, + ETrackedDeviceClass_TrackedDeviceClass_GenericTracker = 3, + ETrackedDeviceClass_TrackedDeviceClass_TrackingReference = 4, + ETrackedDeviceClass_TrackedDeviceClass_DisplayRedirect = 5, + ETrackedDeviceClass_TrackedDeviceClass_Max = 6, +} ETrackedDeviceClass; + +typedef enum ETrackedControllerRole +{ + ETrackedControllerRole_TrackedControllerRole_Invalid = 0, + ETrackedControllerRole_TrackedControllerRole_LeftHand = 1, + ETrackedControllerRole_TrackedControllerRole_RightHand = 2, + ETrackedControllerRole_TrackedControllerRole_OptOut = 3, + ETrackedControllerRole_TrackedControllerRole_Treadmill = 4, + ETrackedControllerRole_TrackedControllerRole_Stylus = 5, + ETrackedControllerRole_TrackedControllerRole_Max = 5, +} ETrackedControllerRole; + +typedef enum ETrackingUniverseOrigin +{ + ETrackingUniverseOrigin_TrackingUniverseSeated = 0, + ETrackingUniverseOrigin_TrackingUniverseStanding = 1, + ETrackingUniverseOrigin_TrackingUniverseRawAndUncalibrated = 2, +} ETrackingUniverseOrigin; + +typedef enum EAdditionalRadioFeatures +{ + EAdditionalRadioFeatures_AdditionalRadioFeatures_None = 0, + EAdditionalRadioFeatures_AdditionalRadioFeatures_HTCLinkBox = 1, + EAdditionalRadioFeatures_AdditionalRadioFeatures_InternalDongle = 2, + EAdditionalRadioFeatures_AdditionalRadioFeatures_ExternalDongle = 4, +} EAdditionalRadioFeatures; + +typedef enum ETrackedDeviceProperty +{ + ETrackedDeviceProperty_Prop_Invalid = 0, + ETrackedDeviceProperty_Prop_TrackingSystemName_String = 1000, + ETrackedDeviceProperty_Prop_ModelNumber_String = 1001, + ETrackedDeviceProperty_Prop_SerialNumber_String = 1002, + ETrackedDeviceProperty_Prop_RenderModelName_String = 1003, + ETrackedDeviceProperty_Prop_WillDriftInYaw_Bool = 1004, + ETrackedDeviceProperty_Prop_ManufacturerName_String = 1005, + ETrackedDeviceProperty_Prop_TrackingFirmwareVersion_String = 1006, + ETrackedDeviceProperty_Prop_HardwareRevision_String = 1007, + ETrackedDeviceProperty_Prop_AllWirelessDongleDescriptions_String = 1008, + ETrackedDeviceProperty_Prop_ConnectedWirelessDongle_String = 1009, + ETrackedDeviceProperty_Prop_DeviceIsWireless_Bool = 1010, + ETrackedDeviceProperty_Prop_DeviceIsCharging_Bool = 1011, + ETrackedDeviceProperty_Prop_DeviceBatteryPercentage_Float = 1012, + ETrackedDeviceProperty_Prop_StatusDisplayTransform_Matrix34 = 1013, + ETrackedDeviceProperty_Prop_Firmware_UpdateAvailable_Bool = 1014, + ETrackedDeviceProperty_Prop_Firmware_ManualUpdate_Bool = 1015, + ETrackedDeviceProperty_Prop_Firmware_ManualUpdateURL_String = 1016, + ETrackedDeviceProperty_Prop_HardwareRevision_Uint64 = 1017, + ETrackedDeviceProperty_Prop_FirmwareVersion_Uint64 = 1018, + ETrackedDeviceProperty_Prop_FPGAVersion_Uint64 = 1019, + ETrackedDeviceProperty_Prop_VRCVersion_Uint64 = 1020, + ETrackedDeviceProperty_Prop_RadioVersion_Uint64 = 1021, + ETrackedDeviceProperty_Prop_DongleVersion_Uint64 = 1022, + ETrackedDeviceProperty_Prop_BlockServerShutdown_Bool = 1023, + ETrackedDeviceProperty_Prop_CanUnifyCoordinateSystemWithHmd_Bool = 1024, + ETrackedDeviceProperty_Prop_ContainsProximitySensor_Bool = 1025, + ETrackedDeviceProperty_Prop_DeviceProvidesBatteryStatus_Bool = 1026, + ETrackedDeviceProperty_Prop_DeviceCanPowerOff_Bool = 1027, + ETrackedDeviceProperty_Prop_Firmware_ProgrammingTarget_String = 1028, + ETrackedDeviceProperty_Prop_DeviceClass_Int32 = 1029, + ETrackedDeviceProperty_Prop_HasCamera_Bool = 1030, + ETrackedDeviceProperty_Prop_DriverVersion_String = 1031, + ETrackedDeviceProperty_Prop_Firmware_ForceUpdateRequired_Bool = 1032, + ETrackedDeviceProperty_Prop_ViveSystemButtonFixRequired_Bool = 1033, + ETrackedDeviceProperty_Prop_ParentDriver_Uint64 = 1034, + ETrackedDeviceProperty_Prop_ResourceRoot_String = 1035, + ETrackedDeviceProperty_Prop_RegisteredDeviceType_String = 1036, + ETrackedDeviceProperty_Prop_InputProfilePath_String = 1037, + ETrackedDeviceProperty_Prop_NeverTracked_Bool = 1038, + ETrackedDeviceProperty_Prop_NumCameras_Int32 = 1039, + ETrackedDeviceProperty_Prop_CameraFrameLayout_Int32 = 1040, + ETrackedDeviceProperty_Prop_CameraStreamFormat_Int32 = 1041, + ETrackedDeviceProperty_Prop_AdditionalDeviceSettingsPath_String = 1042, + ETrackedDeviceProperty_Prop_Identifiable_Bool = 1043, + ETrackedDeviceProperty_Prop_BootloaderVersion_Uint64 = 1044, + ETrackedDeviceProperty_Prop_AdditionalSystemReportData_String = 1045, + ETrackedDeviceProperty_Prop_CompositeFirmwareVersion_String = 1046, + ETrackedDeviceProperty_Prop_Firmware_RemindUpdate_Bool = 1047, + ETrackedDeviceProperty_Prop_PeripheralApplicationVersion_Uint64 = 1048, + ETrackedDeviceProperty_Prop_ManufacturerSerialNumber_String = 1049, + ETrackedDeviceProperty_Prop_ComputedSerialNumber_String = 1050, + ETrackedDeviceProperty_Prop_EstimatedDeviceFirstUseTime_Int32 = 1051, + ETrackedDeviceProperty_Prop_DevicePowerUsage_Float = 1052, + ETrackedDeviceProperty_Prop_IgnoreMotionForStandby_Bool = 1053, + ETrackedDeviceProperty_Prop_ReportsTimeSinceVSync_Bool = 2000, + ETrackedDeviceProperty_Prop_SecondsFromVsyncToPhotons_Float = 2001, + ETrackedDeviceProperty_Prop_DisplayFrequency_Float = 2002, + ETrackedDeviceProperty_Prop_UserIpdMeters_Float = 2003, + ETrackedDeviceProperty_Prop_CurrentUniverseId_Uint64 = 2004, + ETrackedDeviceProperty_Prop_PreviousUniverseId_Uint64 = 2005, + ETrackedDeviceProperty_Prop_DisplayFirmwareVersion_Uint64 = 2006, + ETrackedDeviceProperty_Prop_IsOnDesktop_Bool = 2007, + ETrackedDeviceProperty_Prop_DisplayMCType_Int32 = 2008, + ETrackedDeviceProperty_Prop_DisplayMCOffset_Float = 2009, + ETrackedDeviceProperty_Prop_DisplayMCScale_Float = 2010, + ETrackedDeviceProperty_Prop_EdidVendorID_Int32 = 2011, + ETrackedDeviceProperty_Prop_DisplayMCImageLeft_String = 2012, + ETrackedDeviceProperty_Prop_DisplayMCImageRight_String = 2013, + ETrackedDeviceProperty_Prop_DisplayGCBlackClamp_Float = 2014, + ETrackedDeviceProperty_Prop_EdidProductID_Int32 = 2015, + ETrackedDeviceProperty_Prop_CameraToHeadTransform_Matrix34 = 2016, + ETrackedDeviceProperty_Prop_DisplayGCType_Int32 = 2017, + ETrackedDeviceProperty_Prop_DisplayGCOffset_Float = 2018, + ETrackedDeviceProperty_Prop_DisplayGCScale_Float = 2019, + ETrackedDeviceProperty_Prop_DisplayGCPrescale_Float = 2020, + ETrackedDeviceProperty_Prop_DisplayGCImage_String = 2021, + ETrackedDeviceProperty_Prop_LensCenterLeftU_Float = 2022, + ETrackedDeviceProperty_Prop_LensCenterLeftV_Float = 2023, + ETrackedDeviceProperty_Prop_LensCenterRightU_Float = 2024, + ETrackedDeviceProperty_Prop_LensCenterRightV_Float = 2025, + ETrackedDeviceProperty_Prop_UserHeadToEyeDepthMeters_Float = 2026, + ETrackedDeviceProperty_Prop_CameraFirmwareVersion_Uint64 = 2027, + ETrackedDeviceProperty_Prop_CameraFirmwareDescription_String = 2028, + ETrackedDeviceProperty_Prop_DisplayFPGAVersion_Uint64 = 2029, + ETrackedDeviceProperty_Prop_DisplayBootloaderVersion_Uint64 = 2030, + ETrackedDeviceProperty_Prop_DisplayHardwareVersion_Uint64 = 2031, + ETrackedDeviceProperty_Prop_AudioFirmwareVersion_Uint64 = 2032, + ETrackedDeviceProperty_Prop_CameraCompatibilityMode_Int32 = 2033, + ETrackedDeviceProperty_Prop_ScreenshotHorizontalFieldOfViewDegrees_Float = 2034, + ETrackedDeviceProperty_Prop_ScreenshotVerticalFieldOfViewDegrees_Float = 2035, + ETrackedDeviceProperty_Prop_DisplaySuppressed_Bool = 2036, + ETrackedDeviceProperty_Prop_DisplayAllowNightMode_Bool = 2037, + ETrackedDeviceProperty_Prop_DisplayMCImageWidth_Int32 = 2038, + ETrackedDeviceProperty_Prop_DisplayMCImageHeight_Int32 = 2039, + ETrackedDeviceProperty_Prop_DisplayMCImageNumChannels_Int32 = 2040, + ETrackedDeviceProperty_Prop_DisplayMCImageData_Binary = 2041, + ETrackedDeviceProperty_Prop_SecondsFromPhotonsToVblank_Float = 2042, + ETrackedDeviceProperty_Prop_DriverDirectModeSendsVsyncEvents_Bool = 2043, + ETrackedDeviceProperty_Prop_DisplayDebugMode_Bool = 2044, + ETrackedDeviceProperty_Prop_GraphicsAdapterLuid_Uint64 = 2045, + ETrackedDeviceProperty_Prop_DriverProvidedChaperonePath_String = 2048, + ETrackedDeviceProperty_Prop_ExpectedTrackingReferenceCount_Int32 = 2049, + ETrackedDeviceProperty_Prop_ExpectedControllerCount_Int32 = 2050, + ETrackedDeviceProperty_Prop_NamedIconPathControllerLeftDeviceOff_String = 2051, + ETrackedDeviceProperty_Prop_NamedIconPathControllerRightDeviceOff_String = 2052, + ETrackedDeviceProperty_Prop_NamedIconPathTrackingReferenceDeviceOff_String = 2053, + ETrackedDeviceProperty_Prop_DoNotApplyPrediction_Bool = 2054, + ETrackedDeviceProperty_Prop_CameraToHeadTransforms_Matrix34_Array = 2055, + ETrackedDeviceProperty_Prop_DistortionMeshResolution_Int32 = 2056, + ETrackedDeviceProperty_Prop_DriverIsDrawingControllers_Bool = 2057, + ETrackedDeviceProperty_Prop_DriverRequestsApplicationPause_Bool = 2058, + ETrackedDeviceProperty_Prop_DriverRequestsReducedRendering_Bool = 2059, + ETrackedDeviceProperty_Prop_MinimumIpdStepMeters_Float = 2060, + ETrackedDeviceProperty_Prop_AudioBridgeFirmwareVersion_Uint64 = 2061, + ETrackedDeviceProperty_Prop_ImageBridgeFirmwareVersion_Uint64 = 2062, + ETrackedDeviceProperty_Prop_ImuToHeadTransform_Matrix34 = 2063, + ETrackedDeviceProperty_Prop_ImuFactoryGyroBias_Vector3 = 2064, + ETrackedDeviceProperty_Prop_ImuFactoryGyroScale_Vector3 = 2065, + ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerBias_Vector3 = 2066, + ETrackedDeviceProperty_Prop_ImuFactoryAccelerometerScale_Vector3 = 2067, + ETrackedDeviceProperty_Prop_ConfigurationIncludesLighthouse20Features_Bool = 2069, + ETrackedDeviceProperty_Prop_AdditionalRadioFeatures_Uint64 = 2070, + ETrackedDeviceProperty_Prop_CameraWhiteBalance_Vector4_Array = 2071, + ETrackedDeviceProperty_Prop_CameraDistortionFunction_Int32_Array = 2072, + ETrackedDeviceProperty_Prop_CameraDistortionCoefficients_Float_Array = 2073, + ETrackedDeviceProperty_Prop_ExpectedControllerType_String = 2074, + ETrackedDeviceProperty_Prop_HmdTrackingStyle_Int32 = 2075, + ETrackedDeviceProperty_Prop_DriverProvidedChaperoneVisibility_Bool = 2076, + ETrackedDeviceProperty_Prop_HmdColumnCorrectionSettingPrefix_String = 2077, + ETrackedDeviceProperty_Prop_CameraSupportsCompatibilityModes_Bool = 2078, + ETrackedDeviceProperty_Prop_SupportsRoomViewDepthProjection_Bool = 2079, + ETrackedDeviceProperty_Prop_DisplayAvailableFrameRates_Float_Array = 2080, + ETrackedDeviceProperty_Prop_DisplaySupportsMultipleFramerates_Bool = 2081, + ETrackedDeviceProperty_Prop_DisplayColorMultLeft_Vector3 = 2082, + ETrackedDeviceProperty_Prop_DisplayColorMultRight_Vector3 = 2083, + ETrackedDeviceProperty_Prop_DisplaySupportsRuntimeFramerateChange_Bool = 2084, + ETrackedDeviceProperty_Prop_DisplaySupportsAnalogGain_Bool = 2085, + ETrackedDeviceProperty_Prop_DisplayMinAnalogGain_Float = 2086, + ETrackedDeviceProperty_Prop_DisplayMaxAnalogGain_Float = 2087, + ETrackedDeviceProperty_Prop_CameraExposureTime_Float = 2088, + ETrackedDeviceProperty_Prop_CameraGlobalGain_Float = 2089, + ETrackedDeviceProperty_Prop_DashboardScale_Float = 2091, + ETrackedDeviceProperty_Prop_PeerButtonInfo_String = 2092, + ETrackedDeviceProperty_Prop_Hmd_SupportsHDR10_Bool = 2093, + ETrackedDeviceProperty_Prop_IpdUIRangeMinMeters_Float = 2100, + ETrackedDeviceProperty_Prop_IpdUIRangeMaxMeters_Float = 2101, + ETrackedDeviceProperty_Prop_Hmd_SupportsHDCP14LegacyCompat_Bool = 2102, + ETrackedDeviceProperty_Prop_Hmd_SupportsMicMonitoring_Bool = 2103, + ETrackedDeviceProperty_Prop_Hmd_SupportsDisplayPortTrainingMode_Bool = 2104, + ETrackedDeviceProperty_Prop_SupportsRoomViewDirect_Bool = 2105, + ETrackedDeviceProperty_Prop_SupportsAppThrottling_Bool = 2106, + ETrackedDeviceProperty_Prop_DSCVersion_Int32 = 2110, + ETrackedDeviceProperty_Prop_DSCSliceCount_Int32 = 2111, + ETrackedDeviceProperty_Prop_DSCBPPx16_Int32 = 2112, + ETrackedDeviceProperty_Prop_DriverRequestedMuraCorrectionMode_Int32 = 2200, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerLeft_Int32 = 2201, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerRight_Int32 = 2202, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerTop_Int32 = 2203, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_InnerBottom_Int32 = 2204, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterLeft_Int32 = 2205, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterRight_Int32 = 2206, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterTop_Int32 = 2207, + ETrackedDeviceProperty_Prop_DriverRequestedMuraFeather_OuterBottom_Int32 = 2208, + ETrackedDeviceProperty_Prop_Audio_DefaultPlaybackDeviceId_String = 2300, + ETrackedDeviceProperty_Prop_Audio_DefaultRecordingDeviceId_String = 2301, + ETrackedDeviceProperty_Prop_Audio_DefaultPlaybackDeviceVolume_Float = 2302, + ETrackedDeviceProperty_Prop_Audio_SupportsDualSpeakerAndJackOutput_Bool = 2303, + ETrackedDeviceProperty_Prop_AttachedDeviceId_String = 3000, + ETrackedDeviceProperty_Prop_SupportedButtons_Uint64 = 3001, + ETrackedDeviceProperty_Prop_Axis0Type_Int32 = 3002, + ETrackedDeviceProperty_Prop_Axis1Type_Int32 = 3003, + ETrackedDeviceProperty_Prop_Axis2Type_Int32 = 3004, + ETrackedDeviceProperty_Prop_Axis3Type_Int32 = 3005, + ETrackedDeviceProperty_Prop_Axis4Type_Int32 = 3006, + ETrackedDeviceProperty_Prop_ControllerRoleHint_Int32 = 3007, + ETrackedDeviceProperty_Prop_FieldOfViewLeftDegrees_Float = 4000, + ETrackedDeviceProperty_Prop_FieldOfViewRightDegrees_Float = 4001, + ETrackedDeviceProperty_Prop_FieldOfViewTopDegrees_Float = 4002, + ETrackedDeviceProperty_Prop_FieldOfViewBottomDegrees_Float = 4003, + ETrackedDeviceProperty_Prop_TrackingRangeMinimumMeters_Float = 4004, + ETrackedDeviceProperty_Prop_TrackingRangeMaximumMeters_Float = 4005, + ETrackedDeviceProperty_Prop_ModeLabel_String = 4006, + ETrackedDeviceProperty_Prop_CanWirelessIdentify_Bool = 4007, + ETrackedDeviceProperty_Prop_Nonce_Int32 = 4008, + ETrackedDeviceProperty_Prop_IconPathName_String = 5000, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceOff_String = 5001, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearching_String = 5002, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceSearchingAlert_String = 5003, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceReady_String = 5004, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceReadyAlert_String = 5005, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceNotReady_String = 5006, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandby_String = 5007, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceAlertLow_String = 5008, + ETrackedDeviceProperty_Prop_NamedIconPathDeviceStandbyAlert_String = 5009, + ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_Start = 5100, + ETrackedDeviceProperty_Prop_DisplayHiddenArea_Binary_End = 5150, + ETrackedDeviceProperty_Prop_ParentContainer = 5151, + ETrackedDeviceProperty_Prop_OverrideContainer_Uint64 = 5152, + ETrackedDeviceProperty_Prop_UserConfigPath_String = 6000, + ETrackedDeviceProperty_Prop_InstallPath_String = 6001, + ETrackedDeviceProperty_Prop_HasDisplayComponent_Bool = 6002, + ETrackedDeviceProperty_Prop_HasControllerComponent_Bool = 6003, + ETrackedDeviceProperty_Prop_HasCameraComponent_Bool = 6004, + ETrackedDeviceProperty_Prop_HasDriverDirectModeComponent_Bool = 6005, + ETrackedDeviceProperty_Prop_HasVirtualDisplayComponent_Bool = 6006, + ETrackedDeviceProperty_Prop_HasSpatialAnchorsSupport_Bool = 6007, + ETrackedDeviceProperty_Prop_ControllerType_String = 7000, + ETrackedDeviceProperty_Prop_ControllerHandSelectionPriority_Int32 = 7002, + ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_Start = 10000, + ETrackedDeviceProperty_Prop_VendorSpecific_Reserved_End = 10999, + ETrackedDeviceProperty_Prop_TrackedDeviceProperty_Max = 1000000, +} ETrackedDeviceProperty; + +typedef enum ETrackedPropertyError +{ + ETrackedPropertyError_TrackedProp_Success = 0, + ETrackedPropertyError_TrackedProp_WrongDataType = 1, + ETrackedPropertyError_TrackedProp_WrongDeviceClass = 2, + ETrackedPropertyError_TrackedProp_BufferTooSmall = 3, + ETrackedPropertyError_TrackedProp_UnknownProperty = 4, + ETrackedPropertyError_TrackedProp_InvalidDevice = 5, + ETrackedPropertyError_TrackedProp_CouldNotContactServer = 6, + ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice = 7, + ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength = 8, + ETrackedPropertyError_TrackedProp_NotYetAvailable = 9, + ETrackedPropertyError_TrackedProp_PermissionDenied = 10, + ETrackedPropertyError_TrackedProp_InvalidOperation = 11, + ETrackedPropertyError_TrackedProp_CannotWriteToWildcards = 12, + ETrackedPropertyError_TrackedProp_IPCReadFailure = 13, + ETrackedPropertyError_TrackedProp_OutOfMemory = 14, + ETrackedPropertyError_TrackedProp_InvalidContainer = 15, +} ETrackedPropertyError; + +typedef enum EHmdTrackingStyle +{ + EHmdTrackingStyle_HmdTrackingStyle_Unknown = 0, + EHmdTrackingStyle_HmdTrackingStyle_Lighthouse = 1, + EHmdTrackingStyle_HmdTrackingStyle_OutsideInCameras = 2, + EHmdTrackingStyle_HmdTrackingStyle_InsideOutCameras = 3, +} EHmdTrackingStyle; + +typedef enum EVRSubmitFlags +{ + EVRSubmitFlags_Submit_Default = 0, + EVRSubmitFlags_Submit_LensDistortionAlreadyApplied = 1, + EVRSubmitFlags_Submit_GlRenderBuffer = 2, + EVRSubmitFlags_Submit_Reserved = 4, + EVRSubmitFlags_Submit_TextureWithPose = 8, + EVRSubmitFlags_Submit_TextureWithDepth = 16, + EVRSubmitFlags_Submit_FrameDiscontinuty = 32, + EVRSubmitFlags_Submit_VulkanTextureWithArrayData = 64, + EVRSubmitFlags_Submit_GlArrayTexture = 128, + EVRSubmitFlags_Submit_Reserved2 = 32768, + EVRSubmitFlags_Submit_Reserved3 = 65536, +} EVRSubmitFlags; + +typedef enum EVRState +{ + EVRState_VRState_Undefined = -1, + EVRState_VRState_Off = 0, + EVRState_VRState_Searching = 1, + EVRState_VRState_Searching_Alert = 2, + EVRState_VRState_Ready = 3, + EVRState_VRState_Ready_Alert = 4, + EVRState_VRState_NotReady = 5, + EVRState_VRState_Standby = 6, + EVRState_VRState_Ready_Alert_Low = 7, +} EVRState; + +typedef enum EVREventType +{ + EVREventType_VREvent_None = 0, + EVREventType_VREvent_TrackedDeviceActivated = 100, + EVREventType_VREvent_TrackedDeviceDeactivated = 101, + EVREventType_VREvent_TrackedDeviceUpdated = 102, + EVREventType_VREvent_TrackedDeviceUserInteractionStarted = 103, + EVREventType_VREvent_TrackedDeviceUserInteractionEnded = 104, + EVREventType_VREvent_IpdChanged = 105, + EVREventType_VREvent_EnterStandbyMode = 106, + EVREventType_VREvent_LeaveStandbyMode = 107, + EVREventType_VREvent_TrackedDeviceRoleChanged = 108, + EVREventType_VREvent_WatchdogWakeUpRequested = 109, + EVREventType_VREvent_LensDistortionChanged = 110, + EVREventType_VREvent_PropertyChanged = 111, + EVREventType_VREvent_WirelessDisconnect = 112, + EVREventType_VREvent_WirelessReconnect = 113, + EVREventType_VREvent_ButtonPress = 200, + EVREventType_VREvent_ButtonUnpress = 201, + EVREventType_VREvent_ButtonTouch = 202, + EVREventType_VREvent_ButtonUntouch = 203, + EVREventType_VREvent_Modal_Cancel = 257, + EVREventType_VREvent_MouseMove = 300, + EVREventType_VREvent_MouseButtonDown = 301, + EVREventType_VREvent_MouseButtonUp = 302, + EVREventType_VREvent_FocusEnter = 303, + EVREventType_VREvent_FocusLeave = 304, + EVREventType_VREvent_ScrollDiscrete = 305, + EVREventType_VREvent_TouchPadMove = 306, + EVREventType_VREvent_OverlayFocusChanged = 307, + EVREventType_VREvent_ReloadOverlays = 308, + EVREventType_VREvent_ScrollSmooth = 309, + EVREventType_VREvent_LockMousePosition = 310, + EVREventType_VREvent_UnlockMousePosition = 311, + EVREventType_VREvent_InputFocusCaptured = 400, + EVREventType_VREvent_InputFocusReleased = 401, + EVREventType_VREvent_SceneApplicationChanged = 404, + EVREventType_VREvent_InputFocusChanged = 406, + EVREventType_VREvent_SceneApplicationUsingWrongGraphicsAdapter = 408, + EVREventType_VREvent_ActionBindingReloaded = 409, + EVREventType_VREvent_HideRenderModels = 410, + EVREventType_VREvent_ShowRenderModels = 411, + EVREventType_VREvent_SceneApplicationStateChanged = 412, + EVREventType_VREvent_SceneAppPipeDisconnected = 413, + EVREventType_VREvent_ConsoleOpened = 420, + EVREventType_VREvent_ConsoleClosed = 421, + EVREventType_VREvent_OverlayShown = 500, + EVREventType_VREvent_OverlayHidden = 501, + EVREventType_VREvent_DashboardActivated = 502, + EVREventType_VREvent_DashboardDeactivated = 503, + EVREventType_VREvent_DashboardRequested = 505, + EVREventType_VREvent_ResetDashboard = 506, + EVREventType_VREvent_ImageLoaded = 508, + EVREventType_VREvent_ShowKeyboard = 509, + EVREventType_VREvent_HideKeyboard = 510, + EVREventType_VREvent_OverlayGamepadFocusGained = 511, + EVREventType_VREvent_OverlayGamepadFocusLost = 512, + EVREventType_VREvent_OverlaySharedTextureChanged = 513, + EVREventType_VREvent_ScreenshotTriggered = 516, + EVREventType_VREvent_ImageFailed = 517, + EVREventType_VREvent_DashboardOverlayCreated = 518, + EVREventType_VREvent_SwitchGamepadFocus = 519, + EVREventType_VREvent_RequestScreenshot = 520, + EVREventType_VREvent_ScreenshotTaken = 521, + EVREventType_VREvent_ScreenshotFailed = 522, + EVREventType_VREvent_SubmitScreenshotToDashboard = 523, + EVREventType_VREvent_ScreenshotProgressToDashboard = 524, + EVREventType_VREvent_PrimaryDashboardDeviceChanged = 525, + EVREventType_VREvent_RoomViewShown = 526, + EVREventType_VREvent_RoomViewHidden = 527, + EVREventType_VREvent_ShowUI = 528, + EVREventType_VREvent_ShowDevTools = 529, + EVREventType_VREvent_DesktopViewUpdating = 530, + EVREventType_VREvent_DesktopViewReady = 531, + EVREventType_VREvent_StartDashboard = 532, + EVREventType_VREvent_ElevatePrism = 533, + EVREventType_VREvent_OverlayClosed = 534, + EVREventType_VREvent_Notification_Shown = 600, + EVREventType_VREvent_Notification_Hidden = 601, + EVREventType_VREvent_Notification_BeginInteraction = 602, + EVREventType_VREvent_Notification_Destroyed = 603, + EVREventType_VREvent_Quit = 700, + EVREventType_VREvent_ProcessQuit = 701, + EVREventType_VREvent_QuitAcknowledged = 703, + EVREventType_VREvent_DriverRequestedQuit = 704, + EVREventType_VREvent_RestartRequested = 705, + EVREventType_VREvent_InvalidateSwapTextureSets = 706, + EVREventType_VREvent_ChaperoneDataHasChanged = 800, + EVREventType_VREvent_ChaperoneUniverseHasChanged = 801, + EVREventType_VREvent_ChaperoneTempDataHasChanged = 802, + EVREventType_VREvent_ChaperoneSettingsHaveChanged = 803, + EVREventType_VREvent_SeatedZeroPoseReset = 804, + EVREventType_VREvent_ChaperoneFlushCache = 805, + EVREventType_VREvent_ChaperoneRoomSetupStarting = 806, + EVREventType_VREvent_ChaperoneRoomSetupFinished = 807, + EVREventType_VREvent_StandingZeroPoseReset = 808, + EVREventType_VREvent_AudioSettingsHaveChanged = 820, + EVREventType_VREvent_BackgroundSettingHasChanged = 850, + EVREventType_VREvent_CameraSettingsHaveChanged = 851, + EVREventType_VREvent_ReprojectionSettingHasChanged = 852, + EVREventType_VREvent_ModelSkinSettingsHaveChanged = 853, + EVREventType_VREvent_EnvironmentSettingsHaveChanged = 854, + EVREventType_VREvent_PowerSettingsHaveChanged = 855, + EVREventType_VREvent_EnableHomeAppSettingsHaveChanged = 856, + EVREventType_VREvent_SteamVRSectionSettingChanged = 857, + EVREventType_VREvent_LighthouseSectionSettingChanged = 858, + EVREventType_VREvent_NullSectionSettingChanged = 859, + EVREventType_VREvent_UserInterfaceSectionSettingChanged = 860, + EVREventType_VREvent_NotificationsSectionSettingChanged = 861, + EVREventType_VREvent_KeyboardSectionSettingChanged = 862, + EVREventType_VREvent_PerfSectionSettingChanged = 863, + EVREventType_VREvent_DashboardSectionSettingChanged = 864, + EVREventType_VREvent_WebInterfaceSectionSettingChanged = 865, + EVREventType_VREvent_TrackersSectionSettingChanged = 866, + EVREventType_VREvent_LastKnownSectionSettingChanged = 867, + EVREventType_VREvent_DismissedWarningsSectionSettingChanged = 868, + EVREventType_VREvent_GpuSpeedSectionSettingChanged = 869, + EVREventType_VREvent_WindowsMRSectionSettingChanged = 870, + EVREventType_VREvent_OtherSectionSettingChanged = 871, + EVREventType_VREvent_StatusUpdate = 900, + EVREventType_VREvent_WebInterface_InstallDriverCompleted = 950, + EVREventType_VREvent_MCImageUpdated = 1000, + EVREventType_VREvent_FirmwareUpdateStarted = 1100, + EVREventType_VREvent_FirmwareUpdateFinished = 1101, + EVREventType_VREvent_KeyboardClosed = 1200, + EVREventType_VREvent_KeyboardCharInput = 1201, + EVREventType_VREvent_KeyboardDone = 1202, + EVREventType_VREvent_ApplicationListUpdated = 1303, + EVREventType_VREvent_ApplicationMimeTypeLoad = 1304, + EVREventType_VREvent_ProcessConnected = 1306, + EVREventType_VREvent_ProcessDisconnected = 1307, + EVREventType_VREvent_Compositor_ChaperoneBoundsShown = 1410, + EVREventType_VREvent_Compositor_ChaperoneBoundsHidden = 1411, + EVREventType_VREvent_Compositor_DisplayDisconnected = 1412, + EVREventType_VREvent_Compositor_DisplayReconnected = 1413, + EVREventType_VREvent_Compositor_HDCPError = 1414, + EVREventType_VREvent_Compositor_ApplicationNotResponding = 1415, + EVREventType_VREvent_Compositor_ApplicationResumed = 1416, + EVREventType_VREvent_Compositor_OutOfVideoMemory = 1417, + EVREventType_VREvent_Compositor_DisplayModeNotSupported = 1418, + EVREventType_VREvent_Compositor_StageOverrideReady = 1419, + EVREventType_VREvent_Compositor_RequestDisconnectReconnect = 1420, + EVREventType_VREvent_TrackedCamera_StartVideoStream = 1500, + EVREventType_VREvent_TrackedCamera_StopVideoStream = 1501, + EVREventType_VREvent_TrackedCamera_PauseVideoStream = 1502, + EVREventType_VREvent_TrackedCamera_ResumeVideoStream = 1503, + EVREventType_VREvent_TrackedCamera_EditingSurface = 1550, + EVREventType_VREvent_PerformanceTest_EnableCapture = 1600, + EVREventType_VREvent_PerformanceTest_DisableCapture = 1601, + EVREventType_VREvent_PerformanceTest_FidelityLevel = 1602, + EVREventType_VREvent_MessageOverlay_Closed = 1650, + EVREventType_VREvent_MessageOverlayCloseRequested = 1651, + EVREventType_VREvent_Input_HapticVibration = 1700, + EVREventType_VREvent_Input_BindingLoadFailed = 1701, + EVREventType_VREvent_Input_BindingLoadSuccessful = 1702, + EVREventType_VREvent_Input_ActionManifestReloaded = 1703, + EVREventType_VREvent_Input_ActionManifestLoadFailed = 1704, + EVREventType_VREvent_Input_ProgressUpdate = 1705, + EVREventType_VREvent_Input_TrackerActivated = 1706, + EVREventType_VREvent_Input_BindingsUpdated = 1707, + EVREventType_VREvent_Input_BindingSubscriptionChanged = 1708, + EVREventType_VREvent_SpatialAnchors_PoseUpdated = 1800, + EVREventType_VREvent_SpatialAnchors_DescriptorUpdated = 1801, + EVREventType_VREvent_SpatialAnchors_RequestPoseUpdate = 1802, + EVREventType_VREvent_SpatialAnchors_RequestDescriptorUpdate = 1803, + EVREventType_VREvent_SystemReport_Started = 1900, + EVREventType_VREvent_Monitor_ShowHeadsetView = 2000, + EVREventType_VREvent_Monitor_HideHeadsetView = 2001, + EVREventType_VREvent_VendorSpecific_Reserved_Start = 10000, + EVREventType_VREvent_VendorSpecific_Reserved_End = 19999, +} EVREventType; + +typedef enum EDeviceActivityLevel +{ + EDeviceActivityLevel_k_EDeviceActivityLevel_Unknown = -1, + EDeviceActivityLevel_k_EDeviceActivityLevel_Idle = 0, + EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction = 1, + EDeviceActivityLevel_k_EDeviceActivityLevel_UserInteraction_Timeout = 2, + EDeviceActivityLevel_k_EDeviceActivityLevel_Standby = 3, + EDeviceActivityLevel_k_EDeviceActivityLevel_Idle_Timeout = 4, +} EDeviceActivityLevel; + +typedef enum EVRButtonId +{ + EVRButtonId_k_EButton_System = 0, + EVRButtonId_k_EButton_ApplicationMenu = 1, + EVRButtonId_k_EButton_Grip = 2, + EVRButtonId_k_EButton_DPad_Left = 3, + EVRButtonId_k_EButton_DPad_Up = 4, + EVRButtonId_k_EButton_DPad_Right = 5, + EVRButtonId_k_EButton_DPad_Down = 6, + EVRButtonId_k_EButton_A = 7, + EVRButtonId_k_EButton_ProximitySensor = 31, + EVRButtonId_k_EButton_Axis0 = 32, + EVRButtonId_k_EButton_Axis1 = 33, + EVRButtonId_k_EButton_Axis2 = 34, + EVRButtonId_k_EButton_Axis3 = 35, + EVRButtonId_k_EButton_Axis4 = 36, + EVRButtonId_k_EButton_SteamVR_Touchpad = 32, + EVRButtonId_k_EButton_SteamVR_Trigger = 33, + EVRButtonId_k_EButton_Dashboard_Back = 2, + EVRButtonId_k_EButton_IndexController_A = 2, + EVRButtonId_k_EButton_IndexController_B = 1, + EVRButtonId_k_EButton_IndexController_JoyStick = 35, + EVRButtonId_k_EButton_Max = 64, +} EVRButtonId; + +typedef enum EVRMouseButton +{ + EVRMouseButton_VRMouseButton_Left = 1, + EVRMouseButton_VRMouseButton_Right = 2, + EVRMouseButton_VRMouseButton_Middle = 4, +} EVRMouseButton; + +typedef enum EShowUIType +{ + EShowUIType_ShowUI_ControllerBinding = 0, + EShowUIType_ShowUI_ManageTrackers = 1, + EShowUIType_ShowUI_Pairing = 3, + EShowUIType_ShowUI_Settings = 4, + EShowUIType_ShowUI_DebugCommands = 5, + EShowUIType_ShowUI_FullControllerBinding = 6, + EShowUIType_ShowUI_ManageDrivers = 7, +} EShowUIType; + +typedef enum EHDCPError +{ + EHDCPError_HDCPError_None = 0, + EHDCPError_HDCPError_LinkLost = 1, + EHDCPError_HDCPError_Tampered = 2, + EHDCPError_HDCPError_DeviceRevoked = 3, + EHDCPError_HDCPError_Unknown = 4, +} EHDCPError; + +typedef enum EVRComponentProperty +{ + EVRComponentProperty_VRComponentProperty_IsStatic = 1, + EVRComponentProperty_VRComponentProperty_IsVisible = 2, + EVRComponentProperty_VRComponentProperty_IsTouched = 4, + EVRComponentProperty_VRComponentProperty_IsPressed = 8, + EVRComponentProperty_VRComponentProperty_IsScrolled = 16, + EVRComponentProperty_VRComponentProperty_IsHighlighted = 32, +} EVRComponentProperty; + +typedef enum EVRInputError +{ + EVRInputError_VRInputError_None = 0, + EVRInputError_VRInputError_NameNotFound = 1, + EVRInputError_VRInputError_WrongType = 2, + EVRInputError_VRInputError_InvalidHandle = 3, + EVRInputError_VRInputError_InvalidParam = 4, + EVRInputError_VRInputError_NoSteam = 5, + EVRInputError_VRInputError_MaxCapacityReached = 6, + EVRInputError_VRInputError_IPCError = 7, + EVRInputError_VRInputError_NoActiveActionSet = 8, + EVRInputError_VRInputError_InvalidDevice = 9, + EVRInputError_VRInputError_InvalidSkeleton = 10, + EVRInputError_VRInputError_InvalidBoneCount = 11, + EVRInputError_VRInputError_InvalidCompressedData = 12, + EVRInputError_VRInputError_NoData = 13, + EVRInputError_VRInputError_BufferTooSmall = 14, + EVRInputError_VRInputError_MismatchedActionManifest = 15, + EVRInputError_VRInputError_MissingSkeletonData = 16, + EVRInputError_VRInputError_InvalidBoneIndex = 17, + EVRInputError_VRInputError_InvalidPriority = 18, + EVRInputError_VRInputError_PermissionDenied = 19, + EVRInputError_VRInputError_InvalidRenderModel = 20, +} EVRInputError; + +typedef enum EVRSpatialAnchorError +{ + EVRSpatialAnchorError_VRSpatialAnchorError_Success = 0, + EVRSpatialAnchorError_VRSpatialAnchorError_Internal = 1, + EVRSpatialAnchorError_VRSpatialAnchorError_UnknownHandle = 2, + EVRSpatialAnchorError_VRSpatialAnchorError_ArrayTooSmall = 3, + EVRSpatialAnchorError_VRSpatialAnchorError_InvalidDescriptorChar = 4, + EVRSpatialAnchorError_VRSpatialAnchorError_NotYetAvailable = 5, + EVRSpatialAnchorError_VRSpatialAnchorError_NotAvailableInThisUniverse = 6, + EVRSpatialAnchorError_VRSpatialAnchorError_PermanentlyUnavailable = 7, + EVRSpatialAnchorError_VRSpatialAnchorError_WrongDriver = 8, + EVRSpatialAnchorError_VRSpatialAnchorError_DescriptorTooLong = 9, + EVRSpatialAnchorError_VRSpatialAnchorError_Unknown = 10, + EVRSpatialAnchorError_VRSpatialAnchorError_NoRoomCalibration = 11, + EVRSpatialAnchorError_VRSpatialAnchorError_InvalidArgument = 12, + EVRSpatialAnchorError_VRSpatialAnchorError_UnknownDriver = 13, +} EVRSpatialAnchorError; + +typedef enum EHiddenAreaMeshType +{ + EHiddenAreaMeshType_k_eHiddenAreaMesh_Standard = 0, + EHiddenAreaMeshType_k_eHiddenAreaMesh_Inverse = 1, + EHiddenAreaMeshType_k_eHiddenAreaMesh_LineLoop = 2, + EHiddenAreaMeshType_k_eHiddenAreaMesh_Max = 3, +} EHiddenAreaMeshType; + +typedef enum EVRControllerAxisType +{ + EVRControllerAxisType_k_eControllerAxis_None = 0, + EVRControllerAxisType_k_eControllerAxis_TrackPad = 1, + EVRControllerAxisType_k_eControllerAxis_Joystick = 2, + EVRControllerAxisType_k_eControllerAxis_Trigger = 3, +} EVRControllerAxisType; + +typedef enum EVRControllerEventOutputType +{ + EVRControllerEventOutputType_ControllerEventOutput_OSEvents = 0, + EVRControllerEventOutputType_ControllerEventOutput_VREvents = 1, +} EVRControllerEventOutputType; + +typedef enum ECollisionBoundsStyle +{ + ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_BEGINNER = 0, + ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_INTERMEDIATE = 1, + ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_SQUARES = 2, + ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_ADVANCED = 3, + ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_NONE = 4, + ECollisionBoundsStyle_COLLISION_BOUNDS_STYLE_COUNT = 5, +} ECollisionBoundsStyle; + +typedef enum EVROverlayError +{ + EVROverlayError_VROverlayError_None = 0, + EVROverlayError_VROverlayError_UnknownOverlay = 10, + EVROverlayError_VROverlayError_InvalidHandle = 11, + EVROverlayError_VROverlayError_PermissionDenied = 12, + EVROverlayError_VROverlayError_OverlayLimitExceeded = 13, + EVROverlayError_VROverlayError_WrongVisibilityType = 14, + EVROverlayError_VROverlayError_KeyTooLong = 15, + EVROverlayError_VROverlayError_NameTooLong = 16, + EVROverlayError_VROverlayError_KeyInUse = 17, + EVROverlayError_VROverlayError_WrongTransformType = 18, + EVROverlayError_VROverlayError_InvalidTrackedDevice = 19, + EVROverlayError_VROverlayError_InvalidParameter = 20, + EVROverlayError_VROverlayError_ThumbnailCantBeDestroyed = 21, + EVROverlayError_VROverlayError_ArrayTooSmall = 22, + EVROverlayError_VROverlayError_RequestFailed = 23, + EVROverlayError_VROverlayError_InvalidTexture = 24, + EVROverlayError_VROverlayError_UnableToLoadFile = 25, + EVROverlayError_VROverlayError_KeyboardAlreadyInUse = 26, + EVROverlayError_VROverlayError_NoNeighbor = 27, + EVROverlayError_VROverlayError_TooManyMaskPrimitives = 29, + EVROverlayError_VROverlayError_BadMaskPrimitive = 30, + EVROverlayError_VROverlayError_TextureAlreadyLocked = 31, + EVROverlayError_VROverlayError_TextureLockCapacityReached = 32, + EVROverlayError_VROverlayError_TextureNotLocked = 33, + EVROverlayError_VROverlayError_TimedOut = 34, +} EVROverlayError; + +typedef enum EVRApplicationType +{ + EVRApplicationType_VRApplication_Other = 0, + EVRApplicationType_VRApplication_Scene = 1, + EVRApplicationType_VRApplication_Overlay = 2, + EVRApplicationType_VRApplication_Background = 3, + EVRApplicationType_VRApplication_Utility = 4, + EVRApplicationType_VRApplication_VRMonitor = 5, + EVRApplicationType_VRApplication_SteamWatchdog = 6, + EVRApplicationType_VRApplication_Bootstrapper = 7, + EVRApplicationType_VRApplication_WebHelper = 8, + EVRApplicationType_VRApplication_OpenXRInstance = 9, + EVRApplicationType_VRApplication_OpenXRScene = 10, + EVRApplicationType_VRApplication_OpenXROverlay = 11, + EVRApplicationType_VRApplication_Prism = 12, + EVRApplicationType_VRApplication_RoomView = 13, + EVRApplicationType_VRApplication_Max = 14, +} EVRApplicationType; + +typedef enum EVRFirmwareError +{ + EVRFirmwareError_VRFirmwareError_None = 0, + EVRFirmwareError_VRFirmwareError_Success = 1, + EVRFirmwareError_VRFirmwareError_Fail = 2, +} EVRFirmwareError; + +typedef enum EVRNotificationError +{ + EVRNotificationError_VRNotificationError_OK = 0, + EVRNotificationError_VRNotificationError_InvalidNotificationId = 100, + EVRNotificationError_VRNotificationError_NotificationQueueFull = 101, + EVRNotificationError_VRNotificationError_InvalidOverlayHandle = 102, + EVRNotificationError_VRNotificationError_SystemWithUserValueAlreadyExists = 103, +} EVRNotificationError; + +typedef enum EVRSkeletalMotionRange +{ + EVRSkeletalMotionRange_VRSkeletalMotionRange_WithController = 0, + EVRSkeletalMotionRange_VRSkeletalMotionRange_WithoutController = 1, +} EVRSkeletalMotionRange; + +typedef enum EVRSkeletalTrackingLevel +{ + EVRSkeletalTrackingLevel_VRSkeletalTracking_Estimated = 0, + EVRSkeletalTrackingLevel_VRSkeletalTracking_Partial = 1, + EVRSkeletalTrackingLevel_VRSkeletalTracking_Full = 2, + EVRSkeletalTrackingLevel_VRSkeletalTrackingLevel_Count = 3, + EVRSkeletalTrackingLevel_VRSkeletalTrackingLevel_Max = 2, +} EVRSkeletalTrackingLevel; + +typedef enum EVRInitError +{ + EVRInitError_VRInitError_None = 0, + EVRInitError_VRInitError_Unknown = 1, + EVRInitError_VRInitError_Init_InstallationNotFound = 100, + EVRInitError_VRInitError_Init_InstallationCorrupt = 101, + EVRInitError_VRInitError_Init_VRClientDLLNotFound = 102, + EVRInitError_VRInitError_Init_FileNotFound = 103, + EVRInitError_VRInitError_Init_FactoryNotFound = 104, + EVRInitError_VRInitError_Init_InterfaceNotFound = 105, + EVRInitError_VRInitError_Init_InvalidInterface = 106, + EVRInitError_VRInitError_Init_UserConfigDirectoryInvalid = 107, + EVRInitError_VRInitError_Init_HmdNotFound = 108, + EVRInitError_VRInitError_Init_NotInitialized = 109, + EVRInitError_VRInitError_Init_PathRegistryNotFound = 110, + EVRInitError_VRInitError_Init_NoConfigPath = 111, + EVRInitError_VRInitError_Init_NoLogPath = 112, + EVRInitError_VRInitError_Init_PathRegistryNotWritable = 113, + EVRInitError_VRInitError_Init_AppInfoInitFailed = 114, + EVRInitError_VRInitError_Init_Retry = 115, + EVRInitError_VRInitError_Init_InitCanceledByUser = 116, + EVRInitError_VRInitError_Init_AnotherAppLaunching = 117, + EVRInitError_VRInitError_Init_SettingsInitFailed = 118, + EVRInitError_VRInitError_Init_ShuttingDown = 119, + EVRInitError_VRInitError_Init_TooManyObjects = 120, + EVRInitError_VRInitError_Init_NoServerForBackgroundApp = 121, + EVRInitError_VRInitError_Init_NotSupportedWithCompositor = 122, + EVRInitError_VRInitError_Init_NotAvailableToUtilityApps = 123, + EVRInitError_VRInitError_Init_Internal = 124, + EVRInitError_VRInitError_Init_HmdDriverIdIsNone = 125, + EVRInitError_VRInitError_Init_HmdNotFoundPresenceFailed = 126, + EVRInitError_VRInitError_Init_VRMonitorNotFound = 127, + EVRInitError_VRInitError_Init_VRMonitorStartupFailed = 128, + EVRInitError_VRInitError_Init_LowPowerWatchdogNotSupported = 129, + EVRInitError_VRInitError_Init_InvalidApplicationType = 130, + EVRInitError_VRInitError_Init_NotAvailableToWatchdogApps = 131, + EVRInitError_VRInitError_Init_WatchdogDisabledInSettings = 132, + EVRInitError_VRInitError_Init_VRDashboardNotFound = 133, + EVRInitError_VRInitError_Init_VRDashboardStartupFailed = 134, + EVRInitError_VRInitError_Init_VRHomeNotFound = 135, + EVRInitError_VRInitError_Init_VRHomeStartupFailed = 136, + EVRInitError_VRInitError_Init_RebootingBusy = 137, + EVRInitError_VRInitError_Init_FirmwareUpdateBusy = 138, + EVRInitError_VRInitError_Init_FirmwareRecoveryBusy = 139, + EVRInitError_VRInitError_Init_USBServiceBusy = 140, + EVRInitError_VRInitError_Init_VRWebHelperStartupFailed = 141, + EVRInitError_VRInitError_Init_TrackerManagerInitFailed = 142, + EVRInitError_VRInitError_Init_AlreadyRunning = 143, + EVRInitError_VRInitError_Init_FailedForVrMonitor = 144, + EVRInitError_VRInitError_Init_PropertyManagerInitFailed = 145, + EVRInitError_VRInitError_Init_WebServerFailed = 146, + EVRInitError_VRInitError_Init_IllegalTypeTransition = 147, + EVRInitError_VRInitError_Init_MismatchedRuntimes = 148, + EVRInitError_VRInitError_Init_InvalidProcessId = 149, + EVRInitError_VRInitError_Init_VRServiceStartupFailed = 150, + EVRInitError_VRInitError_Init_PrismNeedsNewDrivers = 151, + EVRInitError_VRInitError_Init_PrismStartupTimedOut = 152, + EVRInitError_VRInitError_Init_CouldNotStartPrism = 153, + EVRInitError_VRInitError_Init_PrismClientInitFailed = 154, + EVRInitError_VRInitError_Init_PrismClientStartFailed = 155, + EVRInitError_VRInitError_Init_PrismExitedUnexpectedly = 156, + EVRInitError_VRInitError_Init_BadLuid = 157, + EVRInitError_VRInitError_Init_NoServerForAppContainer = 158, + EVRInitError_VRInitError_Init_DuplicateBootstrapper = 159, + EVRInitError_VRInitError_Init_VRDashboardServicePending = 160, + EVRInitError_VRInitError_Init_VRDashboardServiceTimeout = 161, + EVRInitError_VRInitError_Init_VRDashboardServiceStopped = 162, + EVRInitError_VRInitError_Init_VRDashboardAlreadyStarted = 163, + EVRInitError_VRInitError_Init_VRDashboardCopyFailed = 164, + EVRInitError_VRInitError_Init_VRDashboardTokenFailure = 165, + EVRInitError_VRInitError_Init_VRDashboardEnvironmentFailure = 166, + EVRInitError_VRInitError_Init_VRDashboardPathFailure = 167, + EVRInitError_VRInitError_Driver_Failed = 200, + EVRInitError_VRInitError_Driver_Unknown = 201, + EVRInitError_VRInitError_Driver_HmdUnknown = 202, + EVRInitError_VRInitError_Driver_NotLoaded = 203, + EVRInitError_VRInitError_Driver_RuntimeOutOfDate = 204, + EVRInitError_VRInitError_Driver_HmdInUse = 205, + EVRInitError_VRInitError_Driver_NotCalibrated = 206, + EVRInitError_VRInitError_Driver_CalibrationInvalid = 207, + EVRInitError_VRInitError_Driver_HmdDisplayNotFound = 208, + EVRInitError_VRInitError_Driver_TrackedDeviceInterfaceUnknown = 209, + EVRInitError_VRInitError_Driver_HmdDriverIdOutOfBounds = 211, + EVRInitError_VRInitError_Driver_HmdDisplayMirrored = 212, + EVRInitError_VRInitError_Driver_HmdDisplayNotFoundLaptop = 213, + EVRInitError_VRInitError_Driver_PeerDriverNotInstalled = 214, + EVRInitError_VRInitError_Driver_WirelessHmdNotConnected = 215, + EVRInitError_VRInitError_IPC_ServerInitFailed = 300, + EVRInitError_VRInitError_IPC_ConnectFailed = 301, + EVRInitError_VRInitError_IPC_SharedStateInitFailed = 302, + EVRInitError_VRInitError_IPC_CompositorInitFailed = 303, + EVRInitError_VRInitError_IPC_MutexInitFailed = 304, + EVRInitError_VRInitError_IPC_Failed = 305, + EVRInitError_VRInitError_IPC_CompositorConnectFailed = 306, + EVRInitError_VRInitError_IPC_CompositorInvalidConnectResponse = 307, + EVRInitError_VRInitError_IPC_ConnectFailedAfterMultipleAttempts = 308, + EVRInitError_VRInitError_IPC_ConnectFailedAfterTargetExited = 309, + EVRInitError_VRInitError_IPC_NamespaceUnavailable = 310, + EVRInitError_VRInitError_Compositor_Failed = 400, + EVRInitError_VRInitError_Compositor_D3D11HardwareRequired = 401, + EVRInitError_VRInitError_Compositor_FirmwareRequiresUpdate = 402, + EVRInitError_VRInitError_Compositor_OverlayInitFailed = 403, + EVRInitError_VRInitError_Compositor_ScreenshotsInitFailed = 404, + EVRInitError_VRInitError_Compositor_UnableToCreateDevice = 405, + EVRInitError_VRInitError_Compositor_SharedStateIsNull = 406, + EVRInitError_VRInitError_Compositor_NotificationManagerIsNull = 407, + EVRInitError_VRInitError_Compositor_ResourceManagerClientIsNull = 408, + EVRInitError_VRInitError_Compositor_MessageOverlaySharedStateInitFailure = 409, + EVRInitError_VRInitError_Compositor_PropertiesInterfaceIsNull = 410, + EVRInitError_VRInitError_Compositor_CreateFullscreenWindowFailed = 411, + EVRInitError_VRInitError_Compositor_SettingsInterfaceIsNull = 412, + EVRInitError_VRInitError_Compositor_FailedToShowWindow = 413, + EVRInitError_VRInitError_Compositor_DistortInterfaceIsNull = 414, + EVRInitError_VRInitError_Compositor_DisplayFrequencyFailure = 415, + EVRInitError_VRInitError_Compositor_RendererInitializationFailed = 416, + EVRInitError_VRInitError_Compositor_DXGIFactoryInterfaceIsNull = 417, + EVRInitError_VRInitError_Compositor_DXGIFactoryCreateFailed = 418, + EVRInitError_VRInitError_Compositor_DXGIFactoryQueryFailed = 419, + EVRInitError_VRInitError_Compositor_InvalidAdapterDesktop = 420, + EVRInitError_VRInitError_Compositor_InvalidHmdAttachment = 421, + EVRInitError_VRInitError_Compositor_InvalidOutputDesktop = 422, + EVRInitError_VRInitError_Compositor_InvalidDeviceProvided = 423, + EVRInitError_VRInitError_Compositor_D3D11RendererInitializationFailed = 424, + EVRInitError_VRInitError_Compositor_FailedToFindDisplayMode = 425, + EVRInitError_VRInitError_Compositor_FailedToCreateSwapChain = 426, + EVRInitError_VRInitError_Compositor_FailedToGetBackBuffer = 427, + EVRInitError_VRInitError_Compositor_FailedToCreateRenderTarget = 428, + EVRInitError_VRInitError_Compositor_FailedToCreateDXGI2SwapChain = 429, + EVRInitError_VRInitError_Compositor_FailedtoGetDXGI2BackBuffer = 430, + EVRInitError_VRInitError_Compositor_FailedToCreateDXGI2RenderTarget = 431, + EVRInitError_VRInitError_Compositor_FailedToGetDXGIDeviceInterface = 432, + EVRInitError_VRInitError_Compositor_SelectDisplayMode = 433, + EVRInitError_VRInitError_Compositor_FailedToCreateNvAPIRenderTargets = 434, + EVRInitError_VRInitError_Compositor_NvAPISetDisplayMode = 435, + EVRInitError_VRInitError_Compositor_FailedToCreateDirectModeDisplay = 436, + EVRInitError_VRInitError_Compositor_InvalidHmdPropertyContainer = 437, + EVRInitError_VRInitError_Compositor_UpdateDisplayFrequency = 438, + EVRInitError_VRInitError_Compositor_CreateRasterizerState = 439, + EVRInitError_VRInitError_Compositor_CreateWireframeRasterizerState = 440, + EVRInitError_VRInitError_Compositor_CreateSamplerState = 441, + EVRInitError_VRInitError_Compositor_CreateClampToBorderSamplerState = 442, + EVRInitError_VRInitError_Compositor_CreateAnisoSamplerState = 443, + EVRInitError_VRInitError_Compositor_CreateOverlaySamplerState = 444, + EVRInitError_VRInitError_Compositor_CreatePanoramaSamplerState = 445, + EVRInitError_VRInitError_Compositor_CreateFontSamplerState = 446, + EVRInitError_VRInitError_Compositor_CreateNoBlendState = 447, + EVRInitError_VRInitError_Compositor_CreateBlendState = 448, + EVRInitError_VRInitError_Compositor_CreateAlphaBlendState = 449, + EVRInitError_VRInitError_Compositor_CreateBlendStateMaskR = 450, + EVRInitError_VRInitError_Compositor_CreateBlendStateMaskG = 451, + EVRInitError_VRInitError_Compositor_CreateBlendStateMaskB = 452, + EVRInitError_VRInitError_Compositor_CreateDepthStencilState = 453, + EVRInitError_VRInitError_Compositor_CreateDepthStencilStateNoWrite = 454, + EVRInitError_VRInitError_Compositor_CreateDepthStencilStateNoDepth = 455, + EVRInitError_VRInitError_Compositor_CreateFlushTexture = 456, + EVRInitError_VRInitError_Compositor_CreateDistortionSurfaces = 457, + EVRInitError_VRInitError_Compositor_CreateConstantBuffer = 458, + EVRInitError_VRInitError_Compositor_CreateHmdPoseConstantBuffer = 459, + EVRInitError_VRInitError_Compositor_CreateHmdPoseStagingConstantBuffer = 460, + EVRInitError_VRInitError_Compositor_CreateSharedFrameInfoConstantBuffer = 461, + EVRInitError_VRInitError_Compositor_CreateOverlayConstantBuffer = 462, + EVRInitError_VRInitError_Compositor_CreateSceneTextureIndexConstantBuffer = 463, + EVRInitError_VRInitError_Compositor_CreateReadableSceneTextureIndexConstantBuffer = 464, + EVRInitError_VRInitError_Compositor_CreateLayerGraphicsTextureIndexConstantBuffer = 465, + EVRInitError_VRInitError_Compositor_CreateLayerComputeTextureIndexConstantBuffer = 466, + EVRInitError_VRInitError_Compositor_CreateLayerComputeSceneTextureIndexConstantBuffer = 467, + EVRInitError_VRInitError_Compositor_CreateComputeHmdPoseConstantBuffer = 468, + EVRInitError_VRInitError_Compositor_CreateGeomConstantBuffer = 469, + EVRInitError_VRInitError_Compositor_CreatePanelMaskConstantBuffer = 470, + EVRInitError_VRInitError_Compositor_CreatePixelSimUBO = 471, + EVRInitError_VRInitError_Compositor_CreateMSAARenderTextures = 472, + EVRInitError_VRInitError_Compositor_CreateResolveRenderTextures = 473, + EVRInitError_VRInitError_Compositor_CreateComputeResolveRenderTextures = 474, + EVRInitError_VRInitError_Compositor_CreateDriverDirectModeResolveTextures = 475, + EVRInitError_VRInitError_Compositor_OpenDriverDirectModeResolveTextures = 476, + EVRInitError_VRInitError_Compositor_CreateFallbackSyncTexture = 477, + EVRInitError_VRInitError_Compositor_ShareFallbackSyncTexture = 478, + EVRInitError_VRInitError_Compositor_CreateOverlayIndexBuffer = 479, + EVRInitError_VRInitError_Compositor_CreateOverlayVertexBuffer = 480, + EVRInitError_VRInitError_Compositor_CreateTextVertexBuffer = 481, + EVRInitError_VRInitError_Compositor_CreateTextIndexBuffer = 482, + EVRInitError_VRInitError_Compositor_CreateMirrorTextures = 483, + EVRInitError_VRInitError_Compositor_CreateLastFrameRenderTexture = 484, + EVRInitError_VRInitError_Compositor_CreateMirrorOverlay = 485, + EVRInitError_VRInitError_Compositor_FailedToCreateVirtualDisplayBackbuffer = 486, + EVRInitError_VRInitError_Compositor_DisplayModeNotSupported = 487, + EVRInitError_VRInitError_Compositor_CreateOverlayInvalidCall = 488, + EVRInitError_VRInitError_Compositor_CreateOverlayAlreadyInitialized = 489, + EVRInitError_VRInitError_Compositor_FailedToCreateMailbox = 490, + EVRInitError_VRInitError_Compositor_WindowInterfaceIsNull = 491, + EVRInitError_VRInitError_Compositor_SystemLayerCreateInstance = 492, + EVRInitError_VRInitError_Compositor_SystemLayerCreateSession = 493, + EVRInitError_VRInitError_Compoistor_CreateInverseDistortUVs = 494, + EVRInitError_VRInitError_Compoistor_CreateBackbufferDepth = 495, + EVRInitError_VRInitError_VendorSpecific_UnableToConnectToOculusRuntime = 1000, + EVRInitError_VRInitError_VendorSpecific_WindowsNotInDevMode = 1001, + EVRInitError_VRInitError_VendorSpecific_OculusLinkNotEnabled = 1002, + EVRInitError_VRInitError_VendorSpecific_HmdFound_CantOpenDevice = 1101, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToRequestConfigStart = 1102, + EVRInitError_VRInitError_VendorSpecific_HmdFound_NoStoredConfig = 1103, + EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooBig = 1104, + EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigTooSmall = 1105, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToInitZLib = 1106, + EVRInitError_VRInitError_VendorSpecific_HmdFound_CantReadFirmwareVersion = 1107, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToSendUserDataStart = 1108, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataStart = 1109, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UnableToGetUserDataNext = 1110, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataAddressRange = 1111, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UserDataError = 1112, + EVRInitError_VRInitError_VendorSpecific_HmdFound_ConfigFailedSanityCheck = 1113, + EVRInitError_VRInitError_VendorSpecific_OculusRuntimeBadInstall = 1114, + EVRInitError_VRInitError_VendorSpecific_HmdFound_UnexpectedConfiguration_1 = 1115, + EVRInitError_VRInitError_Steam_SteamInstallationNotFound = 2000, + EVRInitError_VRInitError_LastError = 2001, +} EVRInitError; + +typedef enum EVRScreenshotType +{ + EVRScreenshotType_VRScreenshotType_None = 0, + EVRScreenshotType_VRScreenshotType_Mono = 1, + EVRScreenshotType_VRScreenshotType_Stereo = 2, + EVRScreenshotType_VRScreenshotType_Cubemap = 3, + EVRScreenshotType_VRScreenshotType_MonoPanorama = 4, + EVRScreenshotType_VRScreenshotType_StereoPanorama = 5, +} EVRScreenshotType; + +typedef enum EVRScreenshotPropertyFilenames +{ + EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_Preview = 0, + EVRScreenshotPropertyFilenames_VRScreenshotPropertyFilenames_VR = 1, +} EVRScreenshotPropertyFilenames; + +typedef enum EVRTrackedCameraError +{ + EVRTrackedCameraError_VRTrackedCameraError_None = 0, + EVRTrackedCameraError_VRTrackedCameraError_OperationFailed = 100, + EVRTrackedCameraError_VRTrackedCameraError_InvalidHandle = 101, + EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameHeaderVersion = 102, + EVRTrackedCameraError_VRTrackedCameraError_OutOfHandles = 103, + EVRTrackedCameraError_VRTrackedCameraError_IPCFailure = 104, + EVRTrackedCameraError_VRTrackedCameraError_NotSupportedForThisDevice = 105, + EVRTrackedCameraError_VRTrackedCameraError_SharedMemoryFailure = 106, + EVRTrackedCameraError_VRTrackedCameraError_FrameBufferingFailure = 107, + EVRTrackedCameraError_VRTrackedCameraError_StreamSetupFailure = 108, + EVRTrackedCameraError_VRTrackedCameraError_InvalidGLTextureId = 109, + EVRTrackedCameraError_VRTrackedCameraError_InvalidSharedTextureHandle = 110, + EVRTrackedCameraError_VRTrackedCameraError_FailedToGetGLTextureId = 111, + EVRTrackedCameraError_VRTrackedCameraError_SharedTextureFailure = 112, + EVRTrackedCameraError_VRTrackedCameraError_NoFrameAvailable = 113, + EVRTrackedCameraError_VRTrackedCameraError_InvalidArgument = 114, + EVRTrackedCameraError_VRTrackedCameraError_InvalidFrameBufferSize = 115, +} EVRTrackedCameraError; + +typedef enum EVRTrackedCameraFrameLayout +{ + EVRTrackedCameraFrameLayout_Mono = 1, + EVRTrackedCameraFrameLayout_Stereo = 2, + EVRTrackedCameraFrameLayout_VerticalLayout = 16, + EVRTrackedCameraFrameLayout_HorizontalLayout = 32, +} EVRTrackedCameraFrameLayout; + +typedef enum EVRTrackedCameraFrameType +{ + EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Distorted = 0, + EVRTrackedCameraFrameType_VRTrackedCameraFrameType_Undistorted = 1, + EVRTrackedCameraFrameType_VRTrackedCameraFrameType_MaximumUndistorted = 2, + EVRTrackedCameraFrameType_MAX_CAMERA_FRAME_TYPES = 3, +} EVRTrackedCameraFrameType; + +typedef enum EVRDistortionFunctionType +{ + EVRDistortionFunctionType_VRDistortionFunctionType_None = 0, + EVRDistortionFunctionType_VRDistortionFunctionType_FTheta = 1, + EVRDistortionFunctionType_VRDistortionFunctionType_Extended_FTheta = 2, + EVRDistortionFunctionType_MAX_DISTORTION_FUNCTION_TYPES = 3, +} EVRDistortionFunctionType; + +typedef enum EVSync +{ + EVSync_VSync_None = 0, + EVSync_VSync_WaitRender = 1, + EVSync_VSync_NoWaitRender = 2, +} EVSync; + +typedef enum EVRMuraCorrectionMode +{ + EVRMuraCorrectionMode_Default = 0, + EVRMuraCorrectionMode_NoCorrection = 1, +} EVRMuraCorrectionMode; + +typedef enum Imu_OffScaleFlags +{ + Imu_OffScaleFlags_OffScale_AccelX = 1, + Imu_OffScaleFlags_OffScale_AccelY = 2, + Imu_OffScaleFlags_OffScale_AccelZ = 4, + Imu_OffScaleFlags_OffScale_GyroX = 8, + Imu_OffScaleFlags_OffScale_GyroY = 16, + Imu_OffScaleFlags_OffScale_GyroZ = 32, +} Imu_OffScaleFlags; + +typedef enum EVRApplicationError +{ + EVRApplicationError_VRApplicationError_None = 0, + EVRApplicationError_VRApplicationError_AppKeyAlreadyExists = 100, + EVRApplicationError_VRApplicationError_NoManifest = 101, + EVRApplicationError_VRApplicationError_NoApplication = 102, + EVRApplicationError_VRApplicationError_InvalidIndex = 103, + EVRApplicationError_VRApplicationError_UnknownApplication = 104, + EVRApplicationError_VRApplicationError_IPCFailed = 105, + EVRApplicationError_VRApplicationError_ApplicationAlreadyRunning = 106, + EVRApplicationError_VRApplicationError_InvalidManifest = 107, + EVRApplicationError_VRApplicationError_InvalidApplication = 108, + EVRApplicationError_VRApplicationError_LaunchFailed = 109, + EVRApplicationError_VRApplicationError_ApplicationAlreadyStarting = 110, + EVRApplicationError_VRApplicationError_LaunchInProgress = 111, + EVRApplicationError_VRApplicationError_OldApplicationQuitting = 112, + EVRApplicationError_VRApplicationError_TransitionAborted = 113, + EVRApplicationError_VRApplicationError_IsTemplate = 114, + EVRApplicationError_VRApplicationError_SteamVRIsExiting = 115, + EVRApplicationError_VRApplicationError_BufferTooSmall = 200, + EVRApplicationError_VRApplicationError_PropertyNotSet = 201, + EVRApplicationError_VRApplicationError_UnknownProperty = 202, + EVRApplicationError_VRApplicationError_InvalidParameter = 203, + EVRApplicationError_VRApplicationError_NotImplemented = 300, +} EVRApplicationError; + +typedef enum EVRApplicationProperty +{ + EVRApplicationProperty_VRApplicationProperty_Name_String = 0, + EVRApplicationProperty_VRApplicationProperty_LaunchType_String = 11, + EVRApplicationProperty_VRApplicationProperty_WorkingDirectory_String = 12, + EVRApplicationProperty_VRApplicationProperty_BinaryPath_String = 13, + EVRApplicationProperty_VRApplicationProperty_Arguments_String = 14, + EVRApplicationProperty_VRApplicationProperty_URL_String = 15, + EVRApplicationProperty_VRApplicationProperty_Description_String = 50, + EVRApplicationProperty_VRApplicationProperty_NewsURL_String = 51, + EVRApplicationProperty_VRApplicationProperty_ImagePath_String = 52, + EVRApplicationProperty_VRApplicationProperty_Source_String = 53, + EVRApplicationProperty_VRApplicationProperty_ActionManifestURL_String = 54, + EVRApplicationProperty_VRApplicationProperty_IsDashboardOverlay_Bool = 60, + EVRApplicationProperty_VRApplicationProperty_IsTemplate_Bool = 61, + EVRApplicationProperty_VRApplicationProperty_IsInstanced_Bool = 62, + EVRApplicationProperty_VRApplicationProperty_IsInternal_Bool = 63, + EVRApplicationProperty_VRApplicationProperty_WantsCompositorPauseInStandby_Bool = 64, + EVRApplicationProperty_VRApplicationProperty_IsHidden_Bool = 65, + EVRApplicationProperty_VRApplicationProperty_LastLaunchTime_Uint64 = 70, +} EVRApplicationProperty; + +typedef enum EVRSceneApplicationState +{ + EVRSceneApplicationState_None = 0, + EVRSceneApplicationState_Starting = 1, + EVRSceneApplicationState_Quitting = 2, + EVRSceneApplicationState_Running = 3, + EVRSceneApplicationState_Waiting = 4, +} EVRSceneApplicationState; + +typedef enum ChaperoneCalibrationState +{ + ChaperoneCalibrationState_OK = 1, + ChaperoneCalibrationState_Warning = 100, + ChaperoneCalibrationState_Warning_BaseStationMayHaveMoved = 101, + ChaperoneCalibrationState_Warning_BaseStationRemoved = 102, + ChaperoneCalibrationState_Warning_SeatedBoundsInvalid = 103, + ChaperoneCalibrationState_Error = 200, + ChaperoneCalibrationState_Error_BaseStationUninitialized = 201, + ChaperoneCalibrationState_Error_BaseStationConflict = 202, + ChaperoneCalibrationState_Error_PlayAreaInvalid = 203, + ChaperoneCalibrationState_Error_CollisionBoundsInvalid = 204, +} ChaperoneCalibrationState; + +typedef enum EChaperoneConfigFile +{ + EChaperoneConfigFile_Live = 1, + EChaperoneConfigFile_Temp = 2, +} EChaperoneConfigFile; + +typedef enum EChaperoneImportFlags +{ + EChaperoneImportFlags_EChaperoneImport_BoundsOnly = 1, +} EChaperoneImportFlags; + +typedef enum EVRCompositorError +{ + EVRCompositorError_VRCompositorError_None = 0, + EVRCompositorError_VRCompositorError_RequestFailed = 1, + EVRCompositorError_VRCompositorError_IncompatibleVersion = 100, + EVRCompositorError_VRCompositorError_DoNotHaveFocus = 101, + EVRCompositorError_VRCompositorError_InvalidTexture = 102, + EVRCompositorError_VRCompositorError_IsNotSceneApplication = 103, + EVRCompositorError_VRCompositorError_TextureIsOnWrongDevice = 104, + EVRCompositorError_VRCompositorError_TextureUsesUnsupportedFormat = 105, + EVRCompositorError_VRCompositorError_SharedTexturesNotSupported = 106, + EVRCompositorError_VRCompositorError_IndexOutOfRange = 107, + EVRCompositorError_VRCompositorError_AlreadySubmitted = 108, + EVRCompositorError_VRCompositorError_InvalidBounds = 109, + EVRCompositorError_VRCompositorError_AlreadySet = 110, +} EVRCompositorError; + +typedef enum EVRCompositorTimingMode +{ + EVRCompositorTimingMode_VRCompositorTimingMode_Implicit = 0, + EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_RuntimePerformsPostPresentHandoff = 1, + EVRCompositorTimingMode_VRCompositorTimingMode_Explicit_ApplicationPerformsPostPresentHandoff = 2, +} EVRCompositorTimingMode; + +typedef enum VROverlayInputMethod +{ + VROverlayInputMethod_None = 0, + VROverlayInputMethod_Mouse = 1, +} VROverlayInputMethod; + +typedef enum VROverlayTransformType +{ + VROverlayTransformType_VROverlayTransform_Invalid = -1, + VROverlayTransformType_VROverlayTransform_Absolute = 0, + VROverlayTransformType_VROverlayTransform_TrackedDeviceRelative = 1, + VROverlayTransformType_VROverlayTransform_SystemOverlay = 2, + VROverlayTransformType_VROverlayTransform_TrackedComponent = 3, + VROverlayTransformType_VROverlayTransform_Cursor = 4, + VROverlayTransformType_VROverlayTransform_DashboardTab = 5, + VROverlayTransformType_VROverlayTransform_DashboardThumb = 6, + VROverlayTransformType_VROverlayTransform_Mountable = 7, + VROverlayTransformType_VROverlayTransform_Projection = 8, +} VROverlayTransformType; + +typedef enum VROverlayFlags +{ + VROverlayFlags_NoDashboardTab = 8, + VROverlayFlags_SendVRDiscreteScrollEvents = 64, + VROverlayFlags_SendVRTouchpadEvents = 128, + VROverlayFlags_ShowTouchPadScrollWheel = 256, + VROverlayFlags_TransferOwnershipToInternalProcess = 512, + VROverlayFlags_SideBySide_Parallel = 1024, + VROverlayFlags_SideBySide_Crossed = 2048, + VROverlayFlags_Panorama = 4096, + VROverlayFlags_StereoPanorama = 8192, + VROverlayFlags_SortWithNonSceneOverlays = 16384, + VROverlayFlags_VisibleInDashboard = 32768, + VROverlayFlags_MakeOverlaysInteractiveIfVisible = 65536, + VROverlayFlags_SendVRSmoothScrollEvents = 131072, + VROverlayFlags_ProtectedContent = 262144, + VROverlayFlags_HideLaserIntersection = 524288, + VROverlayFlags_WantsModalBehavior = 1048576, + VROverlayFlags_IsPremultiplied = 2097152, + VROverlayFlags_IgnoreTextureAlpha = 4194304, + VROverlayFlags_EnableControlBar = 8388608, + VROverlayFlags_EnableControlBarKeyboard = 16777216, + VROverlayFlags_EnableControlBarClose = 33554432, +} VROverlayFlags; + +typedef enum VRMessageOverlayResponse +{ + VRMessageOverlayResponse_ButtonPress_0 = 0, + VRMessageOverlayResponse_ButtonPress_1 = 1, + VRMessageOverlayResponse_ButtonPress_2 = 2, + VRMessageOverlayResponse_ButtonPress_3 = 3, + VRMessageOverlayResponse_CouldntFindSystemOverlay = 4, + VRMessageOverlayResponse_CouldntFindOrCreateClientOverlay = 5, + VRMessageOverlayResponse_ApplicationQuit = 6, +} VRMessageOverlayResponse; + +typedef enum EGamepadTextInputMode +{ + EGamepadTextInputMode_k_EGamepadTextInputModeNormal = 0, + EGamepadTextInputMode_k_EGamepadTextInputModePassword = 1, + EGamepadTextInputMode_k_EGamepadTextInputModeSubmit = 2, +} EGamepadTextInputMode; + +typedef enum EGamepadTextInputLineMode +{ + EGamepadTextInputLineMode_k_EGamepadTextInputLineModeSingleLine = 0, + EGamepadTextInputLineMode_k_EGamepadTextInputLineModeMultipleLines = 1, +} EGamepadTextInputLineMode; + +typedef enum EVROverlayIntersectionMaskPrimitiveType +{ + EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Rectangle = 0, + EVROverlayIntersectionMaskPrimitiveType_OverlayIntersectionPrimitiveType_Circle = 1, +} EVROverlayIntersectionMaskPrimitiveType; + +typedef enum EKeyboardFlags +{ + EKeyboardFlags_KeyboardFlag_Minimal = 1, + EKeyboardFlags_KeyboardFlag_Modal = 2, +} EKeyboardFlags; + +typedef enum EDeviceType +{ + EDeviceType_DeviceType_Invalid = -1, + EDeviceType_DeviceType_DirectX11 = 0, + EDeviceType_DeviceType_Vulkan = 1, +} EDeviceType; + +typedef enum HeadsetViewMode_t +{ + HeadsetViewMode_t_HeadsetViewMode_Left = 0, + HeadsetViewMode_t_HeadsetViewMode_Right = 1, + HeadsetViewMode_t_HeadsetViewMode_Both = 2, +} HeadsetViewMode_t; + +typedef enum EVRRenderModelError +{ + EVRRenderModelError_VRRenderModelError_None = 0, + EVRRenderModelError_VRRenderModelError_Loading = 100, + EVRRenderModelError_VRRenderModelError_NotSupported = 200, + EVRRenderModelError_VRRenderModelError_InvalidArg = 300, + EVRRenderModelError_VRRenderModelError_InvalidModel = 301, + EVRRenderModelError_VRRenderModelError_NoShapes = 302, + EVRRenderModelError_VRRenderModelError_MultipleShapes = 303, + EVRRenderModelError_VRRenderModelError_TooManyVertices = 304, + EVRRenderModelError_VRRenderModelError_MultipleTextures = 305, + EVRRenderModelError_VRRenderModelError_BufferTooSmall = 306, + EVRRenderModelError_VRRenderModelError_NotEnoughNormals = 307, + EVRRenderModelError_VRRenderModelError_NotEnoughTexCoords = 308, + EVRRenderModelError_VRRenderModelError_InvalidTexture = 400, +} EVRRenderModelError; + +typedef enum EVRRenderModelTextureFormat +{ + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_RGBA8_SRGB = 0, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC2 = 1, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC4 = 2, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC7 = 3, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_BC7_SRGB = 4, + EVRRenderModelTextureFormat_VRRenderModelTextureFormat_RGBA16_FLOAT = 5, +} EVRRenderModelTextureFormat; + +typedef enum EVRNotificationType +{ + EVRNotificationType_Transient = 0, + EVRNotificationType_Persistent = 1, + EVRNotificationType_Transient_SystemWithUserValue = 2, +} EVRNotificationType; + +typedef enum EVRNotificationStyle +{ + EVRNotificationStyle_None = 0, + EVRNotificationStyle_Application = 100, + EVRNotificationStyle_Contact_Disabled = 200, + EVRNotificationStyle_Contact_Enabled = 201, + EVRNotificationStyle_Contact_Active = 202, +} EVRNotificationStyle; + +typedef enum EVRSettingsError +{ + EVRSettingsError_VRSettingsError_None = 0, + EVRSettingsError_VRSettingsError_IPCFailed = 1, + EVRSettingsError_VRSettingsError_WriteFailed = 2, + EVRSettingsError_VRSettingsError_ReadFailed = 3, + EVRSettingsError_VRSettingsError_JsonParseFailed = 4, + EVRSettingsError_VRSettingsError_UnsetSettingHasNoDefault = 5, +} EVRSettingsError; + +typedef enum EVRScreenshotError +{ + EVRScreenshotError_VRScreenshotError_None = 0, + EVRScreenshotError_VRScreenshotError_RequestFailed = 1, + EVRScreenshotError_VRScreenshotError_IncompatibleVersion = 100, + EVRScreenshotError_VRScreenshotError_NotFound = 101, + EVRScreenshotError_VRScreenshotError_BufferTooSmall = 102, + EVRScreenshotError_VRScreenshotError_ScreenshotAlreadyInProgress = 108, +} EVRScreenshotError; + +typedef enum EVRSkeletalTransformSpace +{ + EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Model = 0, + EVRSkeletalTransformSpace_VRSkeletalTransformSpace_Parent = 1, +} EVRSkeletalTransformSpace; + +typedef enum EVRSkeletalReferencePose +{ + EVRSkeletalReferencePose_VRSkeletalReferencePose_BindPose = 0, + EVRSkeletalReferencePose_VRSkeletalReferencePose_OpenHand = 1, + EVRSkeletalReferencePose_VRSkeletalReferencePose_Fist = 2, + EVRSkeletalReferencePose_VRSkeletalReferencePose_GripLimit = 3, +} EVRSkeletalReferencePose; + +typedef enum EVRFinger +{ + EVRFinger_VRFinger_Thumb = 0, + EVRFinger_VRFinger_Index = 1, + EVRFinger_VRFinger_Middle = 2, + EVRFinger_VRFinger_Ring = 3, + EVRFinger_VRFinger_Pinky = 4, + EVRFinger_VRFinger_Count = 5, +} EVRFinger; + +typedef enum EVRFingerSplay +{ + EVRFingerSplay_VRFingerSplay_Thumb_Index = 0, + EVRFingerSplay_VRFingerSplay_Index_Middle = 1, + EVRFingerSplay_VRFingerSplay_Middle_Ring = 2, + EVRFingerSplay_VRFingerSplay_Ring_Pinky = 3, + EVRFingerSplay_VRFingerSplay_Count = 4, +} EVRFingerSplay; + +typedef enum EVRSummaryType +{ + EVRSummaryType_VRSummaryType_FromAnimation = 0, + EVRSummaryType_VRSummaryType_FromDevice = 1, +} EVRSummaryType; + +typedef enum EVRInputFilterCancelType +{ + EVRInputFilterCancelType_VRInputFilterCancel_Timers = 0, + EVRInputFilterCancelType_VRInputFilterCancel_Momentum = 1, +} EVRInputFilterCancelType; + +typedef enum EVRInputStringBits +{ + EVRInputStringBits_VRInputString_Hand = 1, + EVRInputStringBits_VRInputString_ControllerType = 2, + EVRInputStringBits_VRInputString_InputSource = 4, + EVRInputStringBits_VRInputString_All = -1, +} EVRInputStringBits; + +typedef enum EIOBufferError +{ + EIOBufferError_IOBuffer_Success = 0, + EIOBufferError_IOBuffer_OperationFailed = 100, + EIOBufferError_IOBuffer_InvalidHandle = 101, + EIOBufferError_IOBuffer_InvalidArgument = 102, + EIOBufferError_IOBuffer_PathExists = 103, + EIOBufferError_IOBuffer_PathDoesNotExist = 104, + EIOBufferError_IOBuffer_Permission = 105, +} EIOBufferError; + +typedef enum EIOBufferMode +{ + EIOBufferMode_IOBufferMode_Read = 1, + EIOBufferMode_IOBufferMode_Write = 2, + EIOBufferMode_IOBufferMode_Create = 512, +} EIOBufferMode; + +typedef enum EVRDebugError +{ + EVRDebugError_VRDebugError_Success = 0, + EVRDebugError_VRDebugError_BadParameter = 1, +} EVRDebugError; + +typedef enum EPropertyWriteType +{ + EPropertyWriteType_PropertyWrite_Set = 0, + EPropertyWriteType_PropertyWrite_Erase = 1, + EPropertyWriteType_PropertyWrite_SetError = 2, +} EPropertyWriteType; + +typedef enum EBlockQueueError +{ + EBlockQueueError_BlockQueueError_None = 0, + EBlockQueueError_BlockQueueError_QueueAlreadyExists = 1, + EBlockQueueError_BlockQueueError_QueueNotFound = 2, + EBlockQueueError_BlockQueueError_BlockNotAvailable = 3, + EBlockQueueError_BlockQueueError_InvalidHandle = 4, + EBlockQueueError_BlockQueueError_InvalidParam = 5, + EBlockQueueError_BlockQueueError_ParamMismatch = 6, + EBlockQueueError_BlockQueueError_InternalError = 7, + EBlockQueueError_BlockQueueError_AlreadyInitialized = 8, + EBlockQueueError_BlockQueueError_OperationIsServerOnly = 9, + EBlockQueueError_BlockQueueError_TooManyConnections = 10, +} EBlockQueueError; + +typedef enum EBlockQueueReadType +{ + EBlockQueueReadType_BlockQueueRead_Latest = 0, + EBlockQueueReadType_BlockQueueRead_New = 1, + EBlockQueueReadType_BlockQueueRead_Next = 2, +} EBlockQueueReadType; + +typedef enum EBlockQueueCreationFlag +{ + EBlockQueueCreationFlag_BlockQueueFlag_OwnerIsReader = 1, +} EBlockQueueCreationFlag; + + +// OpenVR typedefs + +typedef uint32_t PropertyTypeTag_t; +typedef uint32_t SpatialAnchorHandle_t; +typedef void * glSharedTextureHandle_t; +typedef int32_t glInt_t; +typedef uint32_t glUInt_t; +typedef uint64_t SharedTextureHandle_t; +typedef uint32_t DriverId_t; +typedef uint32_t TrackedDeviceIndex_t; +typedef uint64_t WebConsoleHandle_t; +typedef uint64_t PropertyContainerHandle_t; +typedef PropertyContainerHandle_t DriverHandle_t; +typedef uint64_t VRActionHandle_t; +typedef uint64_t VRActionSetHandle_t; +typedef uint64_t VRInputValueHandle_t; +typedef uint32_t VRComponentProperties; +typedef uint64_t VROverlayHandle_t; +typedef int32_t BoneIndex_t; +typedef uint64_t TrackedCameraHandle_t; +typedef uint32_t ScreenshotHandle_t; +typedef int32_t TextureID_t; +typedef uint32_t VRNotificationId; +typedef uint64_t IOBufferHandle_t; +typedef uint64_t VrProfilerEventHandle_t; +typedef EVRInitError HmdError; +typedef EVREye Hmd_Eye; +typedef EColorSpace ColorSpace; +typedef ETrackingResult HmdTrackingResult; +typedef ETrackedDeviceClass TrackedDeviceClass; +typedef ETrackingUniverseOrigin TrackingUniverseOrigin; +typedef ETrackedDeviceProperty TrackedDeviceProperty; +typedef ETrackedPropertyError TrackedPropertyError; +typedef EVRSubmitFlags VRSubmitFlags_t; +typedef EVRState VRState_t; +typedef ECollisionBoundsStyle CollisionBoundsStyle_t; +typedef EVROverlayError VROverlayError; +typedef EVRFirmwareError VRFirmwareError; +typedef EVRCompositorError VRCompositorError; +typedef EVRScreenshotError VRScreenshotsError; +typedef uint64_t PathHandle_t; + +// OpenVR Structs + +typedef struct HmdMatrix34_t +{ + float m[3][4]; //float[3][4] +} HmdMatrix34_t; + +typedef struct HmdMatrix33_t +{ + float m[3][3]; //float[3][3] +} HmdMatrix33_t; + +typedef struct HmdMatrix44_t +{ + float m[4][4]; //float[4][4] +} HmdMatrix44_t; + +typedef struct HmdVector3_t +{ + float v[3]; //float[3] +} HmdVector3_t; + +typedef struct HmdVector4_t +{ + float v[4]; //float[4] +} HmdVector4_t; + +typedef struct HmdVector3d_t +{ + double v[3]; //double[3] +} HmdVector3d_t; + +typedef struct HmdVector2_t +{ + float v[2]; //float[2] +} HmdVector2_t; + +typedef struct HmdQuaternion_t +{ + double w; + double x; + double y; + double z; +} HmdQuaternion_t; + +typedef struct HmdQuaternionf_t +{ + float w; + float x; + float y; + float z; +} HmdQuaternionf_t; + +typedef struct HmdColor_t +{ + float r; + float g; + float b; + float a; +} HmdColor_t; + +typedef struct HmdQuad_t +{ + struct HmdVector3_t vCorners[4]; //struct vr::HmdVector3_t[4] +} HmdQuad_t; + +typedef struct HmdRect2_t +{ + struct HmdVector2_t vTopLeft; + struct HmdVector2_t vBottomRight; +} HmdRect2_t; + +typedef struct VRBoneTransform_t +{ + struct HmdVector4_t position; + struct HmdQuaternionf_t orientation; +} VRBoneTransform_t; + +typedef struct DistortionCoordinates_t +{ + float rfRed[2]; //float[2] + float rfGreen[2]; //float[2] + float rfBlue[2]; //float[2] +} DistortionCoordinates_t; + +typedef struct Texture_t +{ + void * handle; // void * + enum ETextureType eType; + enum EColorSpace eColorSpace; +} Texture_t; + +typedef struct TrackedDevicePose_t +{ + struct HmdMatrix34_t mDeviceToAbsoluteTracking; + struct HmdVector3_t vVelocity; + struct HmdVector3_t vAngularVelocity; + enum ETrackingResult eTrackingResult; + bool bPoseIsValid; + bool bDeviceIsConnected; +} TrackedDevicePose_t; + +typedef struct VRTextureBounds_t +{ + float uMin; + float vMin; + float uMax; + float vMax; +} VRTextureBounds_t; + +typedef struct VRTextureWithPose_t +{ + void * handle; // void * + enum ETextureType eType; + enum EColorSpace eColorSpace; + struct HmdMatrix34_t mDeviceToAbsoluteTracking; +} VRTextureWithPose_t; + +typedef struct VRTextureDepthInfo_t +{ + void * handle; // void * + struct HmdMatrix44_t mProjection; + struct HmdVector2_t vRange; +} VRTextureDepthInfo_t; + +typedef struct VRTextureWithDepth_t +{ + void * handle; // void * + enum ETextureType eType; + enum EColorSpace eColorSpace; + struct VRTextureDepthInfo_t depth; +} VRTextureWithDepth_t; + +typedef struct VRTextureWithPoseAndDepth_t +{ + void * handle; // void * + enum ETextureType eType; + enum EColorSpace eColorSpace; + struct HmdMatrix34_t mDeviceToAbsoluteTracking; + struct VRTextureDepthInfo_t depth; +} VRTextureWithPoseAndDepth_t; + +typedef struct VRVulkanTextureData_t +{ + uint64_t m_nImage; + struct VkDevice_T * m_pDevice; // struct VkDevice_T * + struct VkPhysicalDevice_T * m_pPhysicalDevice; // struct VkPhysicalDevice_T * + struct VkInstance_T * m_pInstance; // struct VkInstance_T * + struct VkQueue_T * m_pQueue; // struct VkQueue_T * + uint32_t m_nQueueFamilyIndex; + uint32_t m_nWidth; + uint32_t m_nHeight; + uint32_t m_nFormat; + uint32_t m_nSampleCount; +} VRVulkanTextureData_t; + +typedef struct VRVulkanTextureArrayData_t +{ + uint32_t m_unArrayIndex; + uint32_t m_unArraySize; +} VRVulkanTextureArrayData_t; + +typedef struct D3D12TextureData_t +{ + struct ID3D12Resource * m_pResource; // struct ID3D12Resource * + struct ID3D12CommandQueue * m_pCommandQueue; // struct ID3D12CommandQueue * + uint32_t m_nNodeMask; +} D3D12TextureData_t; + +typedef struct VREvent_Controller_t +{ + uint32_t button; +} VREvent_Controller_t; + +typedef struct VREvent_Mouse_t +{ + float x; + float y; + uint32_t button; +} VREvent_Mouse_t; + +typedef struct VREvent_Scroll_t +{ + float xdelta; + float ydelta; + uint32_t unused; + float viewportscale; +} VREvent_Scroll_t; + +typedef struct VREvent_TouchPadMove_t +{ + bool bFingerDown; + float flSecondsFingerDown; + float fValueXFirst; + float fValueYFirst; + float fValueXRaw; + float fValueYRaw; +} VREvent_TouchPadMove_t; + +typedef struct VREvent_Notification_t +{ + uint64_t ulUserValue; + uint32_t notificationId; +} VREvent_Notification_t; + +typedef struct VREvent_Process_t +{ + uint32_t pid; + uint32_t oldPid; + bool bForced; + bool bConnectionLost; +} VREvent_Process_t; + +typedef struct VREvent_Overlay_t +{ + uint64_t overlayHandle; + uint64_t devicePath; + uint64_t memoryBlockId; +} VREvent_Overlay_t; + +typedef struct VREvent_Status_t +{ + uint32_t statusState; +} VREvent_Status_t; + +typedef struct VREvent_Keyboard_t +{ + char cNewInput[8]; //char[8] + uint64_t uUserValue; +} VREvent_Keyboard_t; + +typedef struct VREvent_Ipd_t +{ + float ipdMeters; +} VREvent_Ipd_t; + +typedef struct VREvent_Chaperone_t +{ + uint64_t m_nPreviousUniverse; + uint64_t m_nCurrentUniverse; +} VREvent_Chaperone_t; + +typedef struct VREvent_Reserved_t +{ + uint64_t reserved0; + uint64_t reserved1; + uint64_t reserved2; + uint64_t reserved3; + uint64_t reserved4; + uint64_t reserved5; +} VREvent_Reserved_t; + +typedef struct VREvent_PerformanceTest_t +{ + uint32_t m_nFidelityLevel; +} VREvent_PerformanceTest_t; + +typedef struct VREvent_SeatedZeroPoseReset_t +{ + bool bResetBySystemMenu; +} VREvent_SeatedZeroPoseReset_t; + +typedef struct VREvent_Screenshot_t +{ + uint32_t handle; + uint32_t type; +} VREvent_Screenshot_t; + +typedef struct VREvent_ScreenshotProgress_t +{ + float progress; +} VREvent_ScreenshotProgress_t; + +typedef struct VREvent_ApplicationLaunch_t +{ + uint32_t pid; + uint32_t unArgsHandle; +} VREvent_ApplicationLaunch_t; + +typedef struct VREvent_EditingCameraSurface_t +{ + uint64_t overlayHandle; + uint32_t nVisualMode; +} VREvent_EditingCameraSurface_t; + +typedef struct VREvent_MessageOverlay_t +{ + uint32_t unVRMessageOverlayResponse; +} VREvent_MessageOverlay_t; + +typedef struct VREvent_Property_t +{ + PropertyContainerHandle_t container; + enum ETrackedDeviceProperty prop; +} VREvent_Property_t; + +typedef struct VREvent_HapticVibration_t +{ + uint64_t containerHandle; + uint64_t componentHandle; + float fDurationSeconds; + float fFrequency; + float fAmplitude; +} VREvent_HapticVibration_t; + +typedef struct VREvent_WebConsole_t +{ + WebConsoleHandle_t webConsoleHandle; +} VREvent_WebConsole_t; + +typedef struct VREvent_InputBindingLoad_t +{ + PropertyContainerHandle_t ulAppContainer; + uint64_t pathMessage; + uint64_t pathUrl; + uint64_t pathControllerType; +} VREvent_InputBindingLoad_t; + +typedef struct VREvent_InputActionManifestLoad_t +{ + uint64_t pathAppKey; + uint64_t pathMessage; + uint64_t pathMessageParam; + uint64_t pathManifestPath; +} VREvent_InputActionManifestLoad_t; + +typedef struct VREvent_SpatialAnchor_t +{ + SpatialAnchorHandle_t unHandle; +} VREvent_SpatialAnchor_t; + +typedef struct VREvent_ProgressUpdate_t +{ + uint64_t ulApplicationPropertyContainer; + uint64_t pathDevice; + uint64_t pathInputSource; + uint64_t pathProgressAction; + uint64_t pathIcon; + float fProgress; +} VREvent_ProgressUpdate_t; + +typedef struct VREvent_ShowUI_t +{ + enum EShowUIType eType; +} VREvent_ShowUI_t; + +typedef struct VREvent_ShowDevTools_t +{ + int32_t nBrowserIdentifier; +} VREvent_ShowDevTools_t; + +typedef struct VREvent_HDCPError_t +{ + enum EHDCPError eCode; +} VREvent_HDCPError_t; + +typedef struct RenderModel_ComponentState_t +{ + struct HmdMatrix34_t mTrackingToComponentRenderModel; + struct HmdMatrix34_t mTrackingToComponentLocal; + VRComponentProperties uProperties; +} RenderModel_ComponentState_t; + +typedef struct HiddenAreaMesh_t +{ + struct HmdVector2_t * pVertexData; // const struct vr::HmdVector2_t * + uint32_t unTriangleCount; +} HiddenAreaMesh_t; + +typedef struct VRControllerAxis_t +{ + float x; + float y; +} VRControllerAxis_t; + +typedef struct VRControllerState_t +{ + uint32_t unPacketNum; + uint64_t ulButtonPressed; + uint64_t ulButtonTouched; + struct VRControllerAxis_t rAxis[5]; //struct vr::VRControllerAxis_t[5] +} VRControllerState_t; + +typedef struct CameraVideoStreamFrameHeader_t +{ + enum EVRTrackedCameraFrameType eFrameType; + uint32_t nWidth; + uint32_t nHeight; + uint32_t nBytesPerPixel; + uint32_t nFrameSequence; + struct TrackedDevicePose_t trackedDevicePose; + uint64_t ulFrameExposureTime; +} CameraVideoStreamFrameHeader_t; + +typedef struct Compositor_FrameTiming +{ + uint32_t m_nSize; + uint32_t m_nFrameIndex; + uint32_t m_nNumFramePresents; + uint32_t m_nNumMisPresented; + uint32_t m_nNumDroppedFrames; + uint32_t m_nReprojectionFlags; + double m_flSystemTimeInSeconds; + float m_flPreSubmitGpuMs; + float m_flPostSubmitGpuMs; + float m_flTotalRenderGpuMs; + float m_flCompositorRenderGpuMs; + float m_flCompositorRenderCpuMs; + float m_flCompositorIdleCpuMs; + float m_flClientFrameIntervalMs; + float m_flPresentCallCpuMs; + float m_flWaitForPresentCpuMs; + float m_flSubmitFrameMs; + float m_flWaitGetPosesCalledMs; + float m_flNewPosesReadyMs; + float m_flNewFrameReadyMs; + float m_flCompositorUpdateStartMs; + float m_flCompositorUpdateEndMs; + float m_flCompositorRenderStartMs; + TrackedDevicePose_t m_HmdPose; + uint32_t m_nNumVSyncsReadyForUse; + uint32_t m_nNumVSyncsToFirstView; +} Compositor_FrameTiming; + +typedef struct Compositor_BenchmarkResults +{ + float m_flMegaPixelsPerSecond; + float m_flHmdRecommendedMegaPixelsPerSecond; +} Compositor_BenchmarkResults; + +typedef struct DriverDirectMode_FrameTiming +{ + uint32_t m_nSize; + uint32_t m_nNumFramePresents; + uint32_t m_nNumMisPresented; + uint32_t m_nNumDroppedFrames; + uint32_t m_nReprojectionFlags; +} DriverDirectMode_FrameTiming; + +typedef struct ImuSample_t +{ + double fSampleTime; + struct HmdVector3d_t vAccel; + struct HmdVector3d_t vGyro; + uint32_t unOffScaleFlags; +} ImuSample_t; + +typedef struct AppOverrideKeys_t +{ + char * pchKey; // const char * + char * pchValue; // const char * +} AppOverrideKeys_t; + +typedef struct Compositor_CumulativeStats +{ + uint32_t m_nPid; + uint32_t m_nNumFramePresents; + uint32_t m_nNumDroppedFrames; + uint32_t m_nNumReprojectedFrames; + uint32_t m_nNumFramePresentsOnStartup; + uint32_t m_nNumDroppedFramesOnStartup; + uint32_t m_nNumReprojectedFramesOnStartup; + uint32_t m_nNumLoading; + uint32_t m_nNumFramePresentsLoading; + uint32_t m_nNumDroppedFramesLoading; + uint32_t m_nNumReprojectedFramesLoading; + uint32_t m_nNumTimedOut; + uint32_t m_nNumFramePresentsTimedOut; + uint32_t m_nNumDroppedFramesTimedOut; + uint32_t m_nNumReprojectedFramesTimedOut; + uint32_t m_nNumFrameSubmits; + double m_flSumCompositorCPUTimeMS; + double m_flSumCompositorGPUTimeMS; + double m_flSumTargetFrameTimes; + double m_flSumApplicationCPUTimeMS; + double m_flSumApplicationGPUTimeMS; +} Compositor_CumulativeStats; + +typedef struct Compositor_StageRenderSettings +{ + struct HmdColor_t m_PrimaryColor; + struct HmdColor_t m_SecondaryColor; + float m_flVignetteInnerRadius; + float m_flVignetteOuterRadius; + float m_flFresnelStrength; + bool m_bBackfaceCulling; + bool m_bGreyscale; + bool m_bWireframe; +} Compositor_StageRenderSettings; + +typedef struct VROverlayIntersectionParams_t +{ + struct HmdVector3_t vSource; + struct HmdVector3_t vDirection; + enum ETrackingUniverseOrigin eOrigin; +} VROverlayIntersectionParams_t; + +typedef struct VROverlayIntersectionResults_t +{ + struct HmdVector3_t vPoint; + struct HmdVector3_t vNormal; + struct HmdVector2_t vUVs; + float fDistance; +} VROverlayIntersectionResults_t; + +typedef struct IntersectionMaskRectangle_t +{ + float m_flTopLeftX; + float m_flTopLeftY; + float m_flWidth; + float m_flHeight; +} IntersectionMaskRectangle_t; + +typedef struct IntersectionMaskCircle_t +{ + float m_flCenterX; + float m_flCenterY; + float m_flRadius; +} IntersectionMaskCircle_t; + +typedef struct VROverlayProjection_t +{ + float fLeft; + float fRight; + float fTop; + float fBottom; +} VROverlayProjection_t; + +typedef struct VROverlayView_t +{ + VROverlayHandle_t overlayHandle; + struct Texture_t texture; + struct VRTextureBounds_t textureBounds; +} VROverlayView_t; + +typedef struct VRVulkanDevice_t +{ + struct VkInstance_T * m_pInstance; // struct VkInstance_T * + struct VkDevice_T * m_pDevice; // struct VkDevice_T * + struct VkPhysicalDevice_T * m_pPhysicalDevice; // struct VkPhysicalDevice_T * + struct VkQueue_T * m_pQueue; // struct VkQueue_T * + uint32_t m_uQueueFamilyIndex; +} VRVulkanDevice_t; + +typedef struct VRNativeDevice_t +{ + void * handle; // void * + enum EDeviceType eType; +} VRNativeDevice_t; + +typedef struct RenderModel_Vertex_t +{ + struct HmdVector3_t vPosition; + struct HmdVector3_t vNormal; + float rfTextureCoord[2]; //float[2] +} RenderModel_Vertex_t; + +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( push, 4 ) +#endif +typedef struct RenderModel_TextureMap_t +{ + uint16_t unWidth; + uint16_t unHeight; + uint8_t * rubTextureMapData; // const uint8_t * + enum EVRRenderModelTextureFormat format; + uint16_t unMipLevels; +} RenderModel_TextureMap_t; + +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( push, 4 ) +#endif +typedef struct RenderModel_t +{ + struct RenderModel_Vertex_t * rVertexData; // const struct vr::RenderModel_Vertex_t * + uint32_t unVertexCount; + uint16_t * rIndexData; // const uint16_t * + uint32_t unTriangleCount; + TextureID_t diffuseTextureId; +} RenderModel_t; + +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif +typedef struct RenderModel_ControllerMode_State_t +{ + bool bScrollWheelVisible; +} RenderModel_ControllerMode_State_t; + +typedef struct NotificationBitmap_t +{ + void * m_pImageData; // void * + int32_t m_nWidth; + int32_t m_nHeight; + int32_t m_nBytesPerPixel; +} NotificationBitmap_t; + +typedef struct CVRSettingHelper +{ + intptr_t m_pSettings; // class vr::IVRSettings * +} CVRSettingHelper; + +typedef struct InputAnalogActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; + float x; + float y; + float z; + float deltaX; + float deltaY; + float deltaZ; + float fUpdateTime; +} InputAnalogActionData_t; + +typedef struct InputDigitalActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; + bool bState; + bool bChanged; + float fUpdateTime; +} InputDigitalActionData_t; + +typedef struct InputPoseActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; + struct TrackedDevicePose_t pose; +} InputPoseActionData_t; + +typedef struct InputSkeletalActionData_t +{ + bool bActive; + VRInputValueHandle_t activeOrigin; +} InputSkeletalActionData_t; + +typedef struct InputOriginInfo_t +{ + VRInputValueHandle_t devicePath; + TrackedDeviceIndex_t trackedDeviceIndex; + char rchRenderModelComponentName[128]; //char[128] +} InputOriginInfo_t; + +typedef struct InputBindingInfo_t +{ + char rchDevicePathName[128]; //char[128] + char rchInputPathName[128]; //char[128] + char rchModeName[128]; //char[128] + char rchSlotName[128]; //char[128] + char rchInputSourceType[32]; //char[32] +} InputBindingInfo_t; + +typedef struct VRActiveActionSet_t +{ + VRActionSetHandle_t ulActionSet; + VRInputValueHandle_t ulRestrictedToDevice; + VRActionSetHandle_t ulSecondaryActionSet; + uint32_t unPadding; + int32_t nPriority; +} VRActiveActionSet_t; + +typedef struct VRSkeletalSummaryData_t +{ + float flFingerCurl[5]; //float[5] + float flFingerSplay[4]; //float[4] +} VRSkeletalSummaryData_t; + +typedef struct SpatialAnchorPose_t +{ + struct HmdMatrix34_t mAnchorToAbsoluteTracking; +} SpatialAnchorPose_t; + +typedef struct COpenVRContext +{ + intptr_t m_pVRSystem; // class vr::IVRSystem * + intptr_t m_pVRChaperone; // class vr::IVRChaperone * + intptr_t m_pVRChaperoneSetup; // class vr::IVRChaperoneSetup * + intptr_t m_pVRCompositor; // class vr::IVRCompositor * + intptr_t m_pVRHeadsetView; // class vr::IVRHeadsetView * + intptr_t m_pVROverlay; // class vr::IVROverlay * + intptr_t m_pVROverlayView; // class vr::IVROverlayView * + intptr_t m_pVRResources; // class vr::IVRResources * + intptr_t m_pVRRenderModels; // class vr::IVRRenderModels * + intptr_t m_pVRExtendedDisplay; // class vr::IVRExtendedDisplay * + intptr_t m_pVRSettings; // class vr::IVRSettings * + intptr_t m_pVRApplications; // class vr::IVRApplications * + intptr_t m_pVRTrackedCamera; // class vr::IVRTrackedCamera * + intptr_t m_pVRScreenshots; // class vr::IVRScreenshots * + intptr_t m_pVRDriverManager; // class vr::IVRDriverManager * + intptr_t m_pVRInput; // class vr::IVRInput * + intptr_t m_pVRIOBuffer; // class vr::IVRIOBuffer * + intptr_t m_pVRSpatialAnchors; // class vr::IVRSpatialAnchors * + intptr_t m_pVRDebug; // class vr::IVRDebug * + intptr_t m_pVRNotifications; // class vr::IVRNotifications * +} COpenVRContext; + +typedef struct PropertyWrite_t +{ + enum ETrackedDeviceProperty prop; + enum EPropertyWriteType writeType; + enum ETrackedPropertyError eSetError; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + enum ETrackedPropertyError eError; +} PropertyWrite_t; + +typedef struct PropertyRead_t +{ + enum ETrackedDeviceProperty prop; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + uint32_t unRequiredBufferSize; + enum ETrackedPropertyError eError; +} PropertyRead_t; + +typedef struct CVRPropertyHelpers +{ + intptr_t m_pProperties; // class vr::IVRProperties * +} CVRPropertyHelpers; + +typedef struct PathWrite_t +{ + PathHandle_t ulPath; + enum EPropertyWriteType writeType; + enum ETrackedPropertyError eSetError; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + enum ETrackedPropertyError eError; + char * pszPath; // const char * +} PathWrite_t; + +typedef struct PathRead_t +{ + PathHandle_t ulPath; + void * pvBuffer; // void * + uint32_t unBufferSize; + PropertyTypeTag_t unTag; + uint32_t unRequiredBufferSize; + enum ETrackedPropertyError eError; + char * pszPath; // const char * +} PathRead_t; + + +typedef union +{ + VREvent_Reserved_t reserved; + VREvent_Controller_t controller; + VREvent_Mouse_t mouse; + VREvent_Scroll_t scroll; + VREvent_Process_t process; + VREvent_Notification_t notification; + VREvent_Overlay_t overlay; + VREvent_Status_t status; + VREvent_Keyboard_t keyboard; + VREvent_Ipd_t ipd; + VREvent_Chaperone_t chaperone; + VREvent_PerformanceTest_t performanceTest; + VREvent_TouchPadMove_t touchPadMove; + VREvent_SeatedZeroPoseReset_t seatedZeroPoseReset; + VREvent_Screenshot_t screenshot; + VREvent_ScreenshotProgress_t screenshotProgress; + VREvent_ApplicationLaunch_t applicationLaunch; + VREvent_EditingCameraSurface_t cameraSurface; + VREvent_MessageOverlay_t messageOverlay; + VREvent_Property_t property; + VREvent_HapticVibration_t hapticVibration; + VREvent_WebConsole_t webConsole; + VREvent_InputBindingLoad_t inputBinding; + VREvent_InputActionManifestLoad_t actionManifest; + VREvent_SpatialAnchor_t spatialAnchor; +} VREvent_Data_t; + +#if defined(__linux__) || defined(__APPLE__) +// This structure was originally defined mis-packed on Linux, preserved for +// compatibility. +#pragma pack( push, 4 ) +#endif + +/** An event posted by the server to all running applications */ +struct VREvent_t +{ + uint32_t eventType; // EVREventType enum + TrackedDeviceIndex_t trackedDeviceIndex; + float eventAgeSeconds; + // event data must be the end of the struct as its size is variable + VREvent_Data_t data; +}; + +#if defined(__linux__) || defined(__APPLE__) +#pragma pack( pop ) +#endif + + +typedef union +{ + IntersectionMaskRectangle_t m_Rectangle; + IntersectionMaskCircle_t m_Circle; +} VROverlayIntersectionMaskPrimitive_Data_t; + +struct VROverlayIntersectionMaskPrimitive_t +{ + EVROverlayIntersectionMaskPrimitiveType m_nPrimitiveType; + VROverlayIntersectionMaskPrimitive_Data_t m_Primitive; +}; + + +// OpenVR Function Pointer Tables + +struct VR_IVRSystem_FnTable +{ + void (OPENVR_FNTABLE_CALLTYPE *GetRecommendedRenderTargetSize)(uint32_t * pnWidth, uint32_t * pnHeight); + struct HmdMatrix44_t (OPENVR_FNTABLE_CALLTYPE *GetProjectionMatrix)(EVREye eEye, float fNearZ, float fFarZ); + void (OPENVR_FNTABLE_CALLTYPE *GetProjectionRaw)(EVREye eEye, float * pfLeft, float * pfRight, float * pfTop, float * pfBottom); + bool (OPENVR_FNTABLE_CALLTYPE *ComputeDistortion)(EVREye eEye, float fU, float fV, struct DistortionCoordinates_t * pDistortionCoordinates); + struct HmdMatrix34_t (OPENVR_FNTABLE_CALLTYPE *GetEyeToHeadTransform)(EVREye eEye); + bool (OPENVR_FNTABLE_CALLTYPE *GetTimeSinceLastVsync)(float * pfSecondsSinceLastVsync, uint64_t * pulFrameCounter); + int32_t (OPENVR_FNTABLE_CALLTYPE *GetD3D9AdapterIndex)(); + void (OPENVR_FNTABLE_CALLTYPE *GetDXGIOutputInfo)(int32_t * pnAdapterIndex); + void (OPENVR_FNTABLE_CALLTYPE *GetOutputDevice)(uint64_t * pnDevice, ETextureType textureType, struct VkInstance_T * pInstance); + bool (OPENVR_FNTABLE_CALLTYPE *IsDisplayOnDesktop)(); + bool (OPENVR_FNTABLE_CALLTYPE *SetDisplayVisibility)(bool bIsVisibleOnDesktop); + void (OPENVR_FNTABLE_CALLTYPE *GetDeviceToAbsoluteTrackingPose)(ETrackingUniverseOrigin eOrigin, float fPredictedSecondsToPhotonsFromNow, struct TrackedDevicePose_t * pTrackedDevicePoseArray, uint32_t unTrackedDevicePoseArrayCount); + struct HmdMatrix34_t (OPENVR_FNTABLE_CALLTYPE *GetSeatedZeroPoseToStandingAbsoluteTrackingPose)(); + struct HmdMatrix34_t (OPENVR_FNTABLE_CALLTYPE *GetRawZeroPoseToStandingAbsoluteTrackingPose)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetSortedTrackedDeviceIndicesOfClass)(ETrackedDeviceClass eTrackedDeviceClass, TrackedDeviceIndex_t * punTrackedDeviceIndexArray, uint32_t unTrackedDeviceIndexArrayCount, TrackedDeviceIndex_t unRelativeToTrackedDeviceIndex); + EDeviceActivityLevel (OPENVR_FNTABLE_CALLTYPE *GetTrackedDeviceActivityLevel)(TrackedDeviceIndex_t unDeviceId); + void (OPENVR_FNTABLE_CALLTYPE *ApplyTransform)(struct TrackedDevicePose_t * pOutputPose, struct TrackedDevicePose_t * pTrackedDevicePose, struct HmdMatrix34_t * pTransform); + TrackedDeviceIndex_t (OPENVR_FNTABLE_CALLTYPE *GetTrackedDeviceIndexForControllerRole)(ETrackedControllerRole unDeviceType); + ETrackedControllerRole (OPENVR_FNTABLE_CALLTYPE *GetControllerRoleForTrackedDeviceIndex)(TrackedDeviceIndex_t unDeviceIndex); + ETrackedDeviceClass (OPENVR_FNTABLE_CALLTYPE *GetTrackedDeviceClass)(TrackedDeviceIndex_t unDeviceIndex); + bool (OPENVR_FNTABLE_CALLTYPE *IsTrackedDeviceConnected)(TrackedDeviceIndex_t unDeviceIndex); + bool (OPENVR_FNTABLE_CALLTYPE *GetBoolTrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); + float (OPENVR_FNTABLE_CALLTYPE *GetFloatTrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); + int32_t (OPENVR_FNTABLE_CALLTYPE *GetInt32TrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); + uint64_t (OPENVR_FNTABLE_CALLTYPE *GetUint64TrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); + struct HmdMatrix34_t (OPENVR_FNTABLE_CALLTYPE *GetMatrix34TrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, ETrackedPropertyError * pError); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetArrayTrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, PropertyTypeTag_t propType, void * pBuffer, uint32_t unBufferSize, ETrackedPropertyError * pError); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetStringTrackedDeviceProperty)(TrackedDeviceIndex_t unDeviceIndex, ETrackedDeviceProperty prop, char * pchValue, uint32_t unBufferSize, ETrackedPropertyError * pError); + char * (OPENVR_FNTABLE_CALLTYPE *GetPropErrorNameFromEnum)(ETrackedPropertyError error); + bool (OPENVR_FNTABLE_CALLTYPE *PollNextEvent)(struct VREvent_t * pEvent, uint32_t uncbVREvent); + bool (OPENVR_FNTABLE_CALLTYPE *PollNextEventWithPose)(ETrackingUniverseOrigin eOrigin, struct VREvent_t * pEvent, uint32_t uncbVREvent, TrackedDevicePose_t * pTrackedDevicePose); + char * (OPENVR_FNTABLE_CALLTYPE *GetEventTypeNameFromEnum)(EVREventType eType); + struct HiddenAreaMesh_t (OPENVR_FNTABLE_CALLTYPE *GetHiddenAreaMesh)(EVREye eEye, EHiddenAreaMeshType type); + bool (OPENVR_FNTABLE_CALLTYPE *GetControllerState)(TrackedDeviceIndex_t unControllerDeviceIndex, VRControllerState_t * pControllerState, uint32_t unControllerStateSize); + bool (OPENVR_FNTABLE_CALLTYPE *GetControllerStateWithPose)(ETrackingUniverseOrigin eOrigin, TrackedDeviceIndex_t unControllerDeviceIndex, VRControllerState_t * pControllerState, uint32_t unControllerStateSize, struct TrackedDevicePose_t * pTrackedDevicePose); + void (OPENVR_FNTABLE_CALLTYPE *TriggerHapticPulse)(TrackedDeviceIndex_t unControllerDeviceIndex, uint32_t unAxisId, unsigned short usDurationMicroSec); + char * (OPENVR_FNTABLE_CALLTYPE *GetButtonIdNameFromEnum)(EVRButtonId eButtonId); + char * (OPENVR_FNTABLE_CALLTYPE *GetControllerAxisTypeNameFromEnum)(EVRControllerAxisType eAxisType); + bool (OPENVR_FNTABLE_CALLTYPE *IsInputAvailable)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsSteamVRDrawingControllers)(); + bool (OPENVR_FNTABLE_CALLTYPE *ShouldApplicationPause)(); + bool (OPENVR_FNTABLE_CALLTYPE *ShouldApplicationReduceRenderingWork)(); + EVRFirmwareError (OPENVR_FNTABLE_CALLTYPE *PerformFirmwareUpdate)(TrackedDeviceIndex_t unDeviceIndex); + void (OPENVR_FNTABLE_CALLTYPE *AcknowledgeQuit_Exiting)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetAppContainerFilePaths)(char * pchBuffer, uint32_t unBufferSize); + char * (OPENVR_FNTABLE_CALLTYPE *GetRuntimeVersion)(); +}; + +struct VR_IVRExtendedDisplay_FnTable +{ + void (OPENVR_FNTABLE_CALLTYPE *GetWindowBounds)(int32_t * pnX, int32_t * pnY, uint32_t * pnWidth, uint32_t * pnHeight); + void (OPENVR_FNTABLE_CALLTYPE *GetEyeOutputViewport)(EVREye eEye, uint32_t * pnX, uint32_t * pnY, uint32_t * pnWidth, uint32_t * pnHeight); + void (OPENVR_FNTABLE_CALLTYPE *GetDXGIOutputInfo)(int32_t * pnAdapterIndex, int32_t * pnAdapterOutputIndex); +}; + +struct VR_IVRTrackedCamera_FnTable +{ + char * (OPENVR_FNTABLE_CALLTYPE *GetCameraErrorNameFromEnum)(EVRTrackedCameraError eCameraError); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *HasCamera)(TrackedDeviceIndex_t nDeviceIndex, bool * pHasCamera); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraFrameSize)(TrackedDeviceIndex_t nDeviceIndex, EVRTrackedCameraFrameType eFrameType, uint32_t * pnWidth, uint32_t * pnHeight, uint32_t * pnFrameBufferSize); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraIntrinsics)(TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, EVRTrackedCameraFrameType eFrameType, HmdVector2_t * pFocalLength, HmdVector2_t * pCenter); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetCameraProjection)(TrackedDeviceIndex_t nDeviceIndex, uint32_t nCameraIndex, EVRTrackedCameraFrameType eFrameType, float flZNear, float flZFar, HmdMatrix44_t * pProjection); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *AcquireVideoStreamingService)(TrackedDeviceIndex_t nDeviceIndex, TrackedCameraHandle_t * pHandle); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *ReleaseVideoStreamingService)(TrackedCameraHandle_t hTrackedCamera); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetVideoStreamFrameBuffer)(TrackedCameraHandle_t hTrackedCamera, EVRTrackedCameraFrameType eFrameType, void * pFrameBuffer, uint32_t nFrameBufferSize, CameraVideoStreamFrameHeader_t * pFrameHeader, uint32_t nFrameHeaderSize); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetVideoStreamTextureSize)(TrackedDeviceIndex_t nDeviceIndex, EVRTrackedCameraFrameType eFrameType, VRTextureBounds_t * pTextureBounds, uint32_t * pnWidth, uint32_t * pnHeight); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetVideoStreamTextureD3D11)(TrackedCameraHandle_t hTrackedCamera, EVRTrackedCameraFrameType eFrameType, void * pD3D11DeviceOrResource, void ** ppD3D11ShaderResourceView, CameraVideoStreamFrameHeader_t * pFrameHeader, uint32_t nFrameHeaderSize); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *GetVideoStreamTextureGL)(TrackedCameraHandle_t hTrackedCamera, EVRTrackedCameraFrameType eFrameType, glUInt_t * pglTextureId, CameraVideoStreamFrameHeader_t * pFrameHeader, uint32_t nFrameHeaderSize); + EVRTrackedCameraError (OPENVR_FNTABLE_CALLTYPE *ReleaseVideoStreamTextureGL)(TrackedCameraHandle_t hTrackedCamera, glUInt_t glTextureId); + void (OPENVR_FNTABLE_CALLTYPE *SetCameraTrackingSpace)(ETrackingUniverseOrigin eUniverse); + ETrackingUniverseOrigin (OPENVR_FNTABLE_CALLTYPE *GetCameraTrackingSpace)(); +}; + +struct VR_IVRApplications_FnTable +{ + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *AddApplicationManifest)(char * pchApplicationManifestFullPath, bool bTemporary); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *RemoveApplicationManifest)(char * pchApplicationManifestFullPath); + bool (OPENVR_FNTABLE_CALLTYPE *IsApplicationInstalled)(char * pchAppKey); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationCount)(); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *GetApplicationKeyByIndex)(uint32_t unApplicationIndex, char * pchAppKeyBuffer, uint32_t unAppKeyBufferLen); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *GetApplicationKeyByProcessId)(uint32_t unProcessId, char * pchAppKeyBuffer, uint32_t unAppKeyBufferLen); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *LaunchApplication)(char * pchAppKey); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *LaunchTemplateApplication)(char * pchTemplateAppKey, char * pchNewAppKey, struct AppOverrideKeys_t * pKeys, uint32_t unKeys); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *LaunchApplicationFromMimeType)(char * pchMimeType, char * pchArgs); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *LaunchDashboardOverlay)(char * pchAppKey); + bool (OPENVR_FNTABLE_CALLTYPE *CancelApplicationLaunch)(char * pchAppKey); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *IdentifyApplication)(uint32_t unProcessId, char * pchAppKey); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationProcessId)(char * pchAppKey); + char * (OPENVR_FNTABLE_CALLTYPE *GetApplicationsErrorNameFromEnum)(EVRApplicationError error); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationPropertyString)(char * pchAppKey, EVRApplicationProperty eProperty, char * pchPropertyValueBuffer, uint32_t unPropertyValueBufferLen, EVRApplicationError * peError); + bool (OPENVR_FNTABLE_CALLTYPE *GetApplicationPropertyBool)(char * pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError * peError); + uint64_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationPropertyUint64)(char * pchAppKey, EVRApplicationProperty eProperty, EVRApplicationError * peError); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *SetApplicationAutoLaunch)(char * pchAppKey, bool bAutoLaunch); + bool (OPENVR_FNTABLE_CALLTYPE *GetApplicationAutoLaunch)(char * pchAppKey); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *SetDefaultApplicationForMimeType)(char * pchAppKey, char * pchMimeType); + bool (OPENVR_FNTABLE_CALLTYPE *GetDefaultApplicationForMimeType)(char * pchMimeType, char * pchAppKeyBuffer, uint32_t unAppKeyBufferLen); + bool (OPENVR_FNTABLE_CALLTYPE *GetApplicationSupportedMimeTypes)(char * pchAppKey, char * pchMimeTypesBuffer, uint32_t unMimeTypesBuffer); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationsThatSupportMimeType)(char * pchMimeType, char * pchAppKeysThatSupportBuffer, uint32_t unAppKeysThatSupportBuffer); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetApplicationLaunchArguments)(uint32_t unHandle, char * pchArgs, uint32_t unArgs); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *GetStartingApplication)(char * pchAppKeyBuffer, uint32_t unAppKeyBufferLen); + EVRSceneApplicationState (OPENVR_FNTABLE_CALLTYPE *GetSceneApplicationState)(); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *PerformApplicationPrelaunchCheck)(char * pchAppKey); + char * (OPENVR_FNTABLE_CALLTYPE *GetSceneApplicationStateNameFromEnum)(EVRSceneApplicationState state); + EVRApplicationError (OPENVR_FNTABLE_CALLTYPE *LaunchInternalProcess)(char * pchBinaryPath, char * pchArguments, char * pchWorkingDirectory); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetCurrentSceneProcessId)(); +}; + +struct VR_IVRChaperone_FnTable +{ + ChaperoneCalibrationState (OPENVR_FNTABLE_CALLTYPE *GetCalibrationState)(); + bool (OPENVR_FNTABLE_CALLTYPE *GetPlayAreaSize)(float * pSizeX, float * pSizeZ); + bool (OPENVR_FNTABLE_CALLTYPE *GetPlayAreaRect)(struct HmdQuad_t * rect); + void (OPENVR_FNTABLE_CALLTYPE *ReloadInfo)(); + void (OPENVR_FNTABLE_CALLTYPE *SetSceneColor)(struct HmdColor_t color); + void (OPENVR_FNTABLE_CALLTYPE *GetBoundsColor)(struct HmdColor_t * pOutputColorArray, int nNumOutputColors, float flCollisionBoundsFadeDistance, struct HmdColor_t * pOutputCameraColor); + bool (OPENVR_FNTABLE_CALLTYPE *AreBoundsVisible)(); + void (OPENVR_FNTABLE_CALLTYPE *ForceBoundsVisible)(bool bForce); + void (OPENVR_FNTABLE_CALLTYPE *ResetZeroPose)(ETrackingUniverseOrigin eTrackingUniverseOrigin); +}; + +struct VR_IVRChaperoneSetup_FnTable +{ + bool (OPENVR_FNTABLE_CALLTYPE *CommitWorkingCopy)(EChaperoneConfigFile configFile); + void (OPENVR_FNTABLE_CALLTYPE *RevertWorkingCopy)(); + bool (OPENVR_FNTABLE_CALLTYPE *GetWorkingPlayAreaSize)(float * pSizeX, float * pSizeZ); + bool (OPENVR_FNTABLE_CALLTYPE *GetWorkingPlayAreaRect)(struct HmdQuad_t * rect); + bool (OPENVR_FNTABLE_CALLTYPE *GetWorkingCollisionBoundsInfo)(struct HmdQuad_t * pQuadsBuffer, uint32_t * punQuadsCount); + bool (OPENVR_FNTABLE_CALLTYPE *GetLiveCollisionBoundsInfo)(struct HmdQuad_t * pQuadsBuffer, uint32_t * punQuadsCount); + bool (OPENVR_FNTABLE_CALLTYPE *GetWorkingSeatedZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pmatSeatedZeroPoseToRawTrackingPose); + bool (OPENVR_FNTABLE_CALLTYPE *GetWorkingStandingZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pmatStandingZeroPoseToRawTrackingPose); + void (OPENVR_FNTABLE_CALLTYPE *SetWorkingPlayAreaSize)(float sizeX, float sizeZ); + void (OPENVR_FNTABLE_CALLTYPE *SetWorkingCollisionBoundsInfo)(struct HmdQuad_t * pQuadsBuffer, uint32_t unQuadsCount); + void (OPENVR_FNTABLE_CALLTYPE *SetWorkingPerimeter)(struct HmdVector2_t * pPointBuffer, uint32_t unPointCount); + void (OPENVR_FNTABLE_CALLTYPE *SetWorkingSeatedZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pMatSeatedZeroPoseToRawTrackingPose); + void (OPENVR_FNTABLE_CALLTYPE *SetWorkingStandingZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pMatStandingZeroPoseToRawTrackingPose); + void (OPENVR_FNTABLE_CALLTYPE *ReloadFromDisk)(EChaperoneConfigFile configFile); + bool (OPENVR_FNTABLE_CALLTYPE *GetLiveSeatedZeroPoseToRawTrackingPose)(struct HmdMatrix34_t * pmatSeatedZeroPoseToRawTrackingPose); + bool (OPENVR_FNTABLE_CALLTYPE *ExportLiveToBuffer)(char * pBuffer, uint32_t * pnBufferLength); + bool (OPENVR_FNTABLE_CALLTYPE *ImportFromBufferToWorking)(char * pBuffer, uint32_t nImportFlags); + void (OPENVR_FNTABLE_CALLTYPE *ShowWorkingSetPreview)(); + void (OPENVR_FNTABLE_CALLTYPE *HideWorkingSetPreview)(); + void (OPENVR_FNTABLE_CALLTYPE *RoomSetupStarting)(); +}; + +struct VR_IVRCompositor_FnTable +{ + void (OPENVR_FNTABLE_CALLTYPE *SetTrackingSpace)(ETrackingUniverseOrigin eOrigin); + ETrackingUniverseOrigin (OPENVR_FNTABLE_CALLTYPE *GetTrackingSpace)(); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *WaitGetPoses)(struct TrackedDevicePose_t * pRenderPoseArray, uint32_t unRenderPoseArrayCount, struct TrackedDevicePose_t * pGamePoseArray, uint32_t unGamePoseArrayCount); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetLastPoses)(struct TrackedDevicePose_t * pRenderPoseArray, uint32_t unRenderPoseArrayCount, struct TrackedDevicePose_t * pGamePoseArray, uint32_t unGamePoseArrayCount); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetLastPoseForTrackedDeviceIndex)(TrackedDeviceIndex_t unDeviceIndex, struct TrackedDevicePose_t * pOutputPose, struct TrackedDevicePose_t * pOutputGamePose); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *Submit)(EVREye eEye, struct Texture_t * pTexture, struct VRTextureBounds_t * pBounds, EVRSubmitFlags nSubmitFlags); + void (OPENVR_FNTABLE_CALLTYPE *ClearLastSubmittedFrame)(); + void (OPENVR_FNTABLE_CALLTYPE *PostPresentHandoff)(); + bool (OPENVR_FNTABLE_CALLTYPE *GetFrameTiming)(struct Compositor_FrameTiming * pTiming, uint32_t unFramesAgo); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetFrameTimings)(struct Compositor_FrameTiming * pTiming, uint32_t nFrames); + float (OPENVR_FNTABLE_CALLTYPE *GetFrameTimeRemaining)(); + void (OPENVR_FNTABLE_CALLTYPE *GetCumulativeStats)(struct Compositor_CumulativeStats * pStats, uint32_t nStatsSizeInBytes); + void (OPENVR_FNTABLE_CALLTYPE *FadeToColor)(float fSeconds, float fRed, float fGreen, float fBlue, float fAlpha, bool bBackground); + struct HmdColor_t (OPENVR_FNTABLE_CALLTYPE *GetCurrentFadeColor)(bool bBackground); + void (OPENVR_FNTABLE_CALLTYPE *FadeGrid)(float fSeconds, bool bFadeGridIn); + float (OPENVR_FNTABLE_CALLTYPE *GetCurrentGridAlpha)(); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *SetSkyboxOverride)(struct Texture_t * pTextures, uint32_t unTextureCount); + void (OPENVR_FNTABLE_CALLTYPE *ClearSkyboxOverride)(); + void (OPENVR_FNTABLE_CALLTYPE *CompositorBringToFront)(); + void (OPENVR_FNTABLE_CALLTYPE *CompositorGoToBack)(); + void (OPENVR_FNTABLE_CALLTYPE *CompositorQuit)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsFullscreen)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetCurrentSceneFocusProcess)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetLastFrameRenderer)(); + bool (OPENVR_FNTABLE_CALLTYPE *CanRenderScene)(); + void (OPENVR_FNTABLE_CALLTYPE *ShowMirrorWindow)(); + void (OPENVR_FNTABLE_CALLTYPE *HideMirrorWindow)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsMirrorWindowVisible)(); + void (OPENVR_FNTABLE_CALLTYPE *CompositorDumpImages)(); + bool (OPENVR_FNTABLE_CALLTYPE *ShouldAppRenderWithLowResources)(); + void (OPENVR_FNTABLE_CALLTYPE *ForceInterleavedReprojectionOn)(bool bOverride); + void (OPENVR_FNTABLE_CALLTYPE *ForceReconnectProcess)(); + void (OPENVR_FNTABLE_CALLTYPE *SuspendRendering)(bool bSuspend); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetMirrorTextureD3D11)(EVREye eEye, void * pD3D11DeviceOrResource, void ** ppD3D11ShaderResourceView); + void (OPENVR_FNTABLE_CALLTYPE *ReleaseMirrorTextureD3D11)(void * pD3D11ShaderResourceView); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetMirrorTextureGL)(EVREye eEye, glUInt_t * pglTextureId, glSharedTextureHandle_t * pglSharedTextureHandle); + bool (OPENVR_FNTABLE_CALLTYPE *ReleaseSharedGLTexture)(glUInt_t glTextureId, glSharedTextureHandle_t glSharedTextureHandle); + void (OPENVR_FNTABLE_CALLTYPE *LockGLSharedTextureForAccess)(glSharedTextureHandle_t glSharedTextureHandle); + void (OPENVR_FNTABLE_CALLTYPE *UnlockGLSharedTextureForAccess)(glSharedTextureHandle_t glSharedTextureHandle); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetVulkanInstanceExtensionsRequired)(char * pchValue, uint32_t unBufferSize); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetVulkanDeviceExtensionsRequired)(struct VkPhysicalDevice_T * pPhysicalDevice, char * pchValue, uint32_t unBufferSize); + void (OPENVR_FNTABLE_CALLTYPE *SetExplicitTimingMode)(EVRCompositorTimingMode eTimingMode); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *SubmitExplicitTimingData)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsMotionSmoothingEnabled)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsMotionSmoothingSupported)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsCurrentSceneFocusAppLoading)(); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *SetStageOverride_Async)(char * pchRenderModelPath, struct HmdMatrix34_t * pTransform, struct Compositor_StageRenderSettings * pRenderSettings, uint32_t nSizeOfRenderSettings); + void (OPENVR_FNTABLE_CALLTYPE *ClearStageOverride)(); + bool (OPENVR_FNTABLE_CALLTYPE *GetCompositorBenchmarkResults)(struct Compositor_BenchmarkResults * pBenchmarkResults, uint32_t nSizeOfBenchmarkResults); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetLastPosePredictionIDs)(uint32_t * pRenderPosePredictionID, uint32_t * pGamePosePredictionID); + EVRCompositorError (OPENVR_FNTABLE_CALLTYPE *GetPosesForFrame)(uint32_t unPosePredictionID, struct TrackedDevicePose_t * pPoseArray, uint32_t unPoseArrayCount); +}; + +struct VR_IVROverlay_FnTable +{ + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *FindOverlay)(char * pchOverlayKey, VROverlayHandle_t * pOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *CreateOverlay)(char * pchOverlayKey, char * pchOverlayName, VROverlayHandle_t * pOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *DestroyOverlay)(VROverlayHandle_t ulOverlayHandle); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetOverlayKey)(VROverlayHandle_t ulOverlayHandle, char * pchValue, uint32_t unBufferSize, EVROverlayError * pError); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetOverlayName)(VROverlayHandle_t ulOverlayHandle, char * pchValue, uint32_t unBufferSize, EVROverlayError * pError); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayName)(VROverlayHandle_t ulOverlayHandle, char * pchName); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayImageData)(VROverlayHandle_t ulOverlayHandle, void * pvBuffer, uint32_t unBufferSize, uint32_t * punWidth, uint32_t * punHeight); + char * (OPENVR_FNTABLE_CALLTYPE *GetOverlayErrorNameFromEnum)(EVROverlayError error); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayRenderingPid)(VROverlayHandle_t ulOverlayHandle, uint32_t unPID); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetOverlayRenderingPid)(VROverlayHandle_t ulOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayFlag)(VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool bEnabled); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayFlag)(VROverlayHandle_t ulOverlayHandle, VROverlayFlags eOverlayFlag, bool * pbEnabled); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayFlags)(VROverlayHandle_t ulOverlayHandle, uint32_t * pFlags); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayColor)(VROverlayHandle_t ulOverlayHandle, float fRed, float fGreen, float fBlue); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayColor)(VROverlayHandle_t ulOverlayHandle, float * pfRed, float * pfGreen, float * pfBlue); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayAlpha)(VROverlayHandle_t ulOverlayHandle, float fAlpha); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayAlpha)(VROverlayHandle_t ulOverlayHandle, float * pfAlpha); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTexelAspect)(VROverlayHandle_t ulOverlayHandle, float fTexelAspect); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTexelAspect)(VROverlayHandle_t ulOverlayHandle, float * pfTexelAspect); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlaySortOrder)(VROverlayHandle_t ulOverlayHandle, uint32_t unSortOrder); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlaySortOrder)(VROverlayHandle_t ulOverlayHandle, uint32_t * punSortOrder); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayWidthInMeters)(VROverlayHandle_t ulOverlayHandle, float fWidthInMeters); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayWidthInMeters)(VROverlayHandle_t ulOverlayHandle, float * pfWidthInMeters); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayCurvature)(VROverlayHandle_t ulOverlayHandle, float fCurvature); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayCurvature)(VROverlayHandle_t ulOverlayHandle, float * pfCurvature); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayPreCurvePitch)(VROverlayHandle_t ulOverlayHandle, float fRadians); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayPreCurvePitch)(VROverlayHandle_t ulOverlayHandle, float * pfRadians); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTextureColorSpace)(VROverlayHandle_t ulOverlayHandle, EColorSpace eTextureColorSpace); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTextureColorSpace)(VROverlayHandle_t ulOverlayHandle, EColorSpace * peTextureColorSpace); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTextureBounds)(VROverlayHandle_t ulOverlayHandle, struct VRTextureBounds_t * pOverlayTextureBounds); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTextureBounds)(VROverlayHandle_t ulOverlayHandle, struct VRTextureBounds_t * pOverlayTextureBounds); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformType)(VROverlayHandle_t ulOverlayHandle, VROverlayTransformType * peTransformType); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformAbsolute)(VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, struct HmdMatrix34_t * pmatTrackingOriginToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformAbsolute)(VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin * peTrackingOrigin, struct HmdMatrix34_t * pmatTrackingOriginToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformTrackedDeviceRelative)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unTrackedDevice, struct HmdMatrix34_t * pmatTrackedDeviceToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformTrackedDeviceRelative)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t * punTrackedDevice, struct HmdMatrix34_t * pmatTrackedDeviceToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformTrackedDeviceComponent)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t unDeviceIndex, char * pchComponentName); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformTrackedDeviceComponent)(VROverlayHandle_t ulOverlayHandle, TrackedDeviceIndex_t * punDeviceIndex, char * pchComponentName, uint32_t unComponentNameSize); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformOverlayRelative)(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t * ulOverlayHandleParent, struct HmdMatrix34_t * pmatParentOverlayToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformOverlayRelative)(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulOverlayHandleParent, struct HmdMatrix34_t * pmatParentOverlayToOverlayTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformCursor)(VROverlayHandle_t ulCursorOverlayHandle, struct HmdVector2_t * pvHotspot); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTransformCursor)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvHotspot); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTransformProjection)(VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, struct HmdMatrix34_t * pmatTrackingOriginToOverlayTransform, struct VROverlayProjection_t * pProjection, EVREye eEye); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowOverlay)(VROverlayHandle_t ulOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *HideOverlay)(VROverlayHandle_t ulOverlayHandle); + bool (OPENVR_FNTABLE_CALLTYPE *IsOverlayVisible)(VROverlayHandle_t ulOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetTransformForOverlayCoordinates)(VROverlayHandle_t ulOverlayHandle, ETrackingUniverseOrigin eTrackingOrigin, struct HmdVector2_t coordinatesInOverlay, struct HmdMatrix34_t * pmatTransform); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *WaitFrameSync)(uint32_t nTimeoutMs); + bool (OPENVR_FNTABLE_CALLTYPE *PollNextOverlayEvent)(VROverlayHandle_t ulOverlayHandle, struct VREvent_t * pEvent, uint32_t uncbVREvent); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayInputMethod)(VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod * peInputMethod); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayInputMethod)(VROverlayHandle_t ulOverlayHandle, VROverlayInputMethod eInputMethod); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayMouseScale)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvecMouseScale); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayMouseScale)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvecMouseScale); + bool (OPENVR_FNTABLE_CALLTYPE *ComputeOverlayIntersection)(VROverlayHandle_t ulOverlayHandle, struct VROverlayIntersectionParams_t * pParams, struct VROverlayIntersectionResults_t * pResults); + bool (OPENVR_FNTABLE_CALLTYPE *IsHoverTargetOverlay)(VROverlayHandle_t ulOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayIntersectionMask)(VROverlayHandle_t ulOverlayHandle, struct VROverlayIntersectionMaskPrimitive_t * pMaskPrimitives, uint32_t unNumMaskPrimitives, uint32_t unPrimitiveSize); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *TriggerLaserMouseHapticVibration)(VROverlayHandle_t ulOverlayHandle, float fDurationSeconds, float fFrequency, float fAmplitude); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayCursor)(VROverlayHandle_t ulOverlayHandle, VROverlayHandle_t ulCursorHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayCursorPositionOverride)(VROverlayHandle_t ulOverlayHandle, struct HmdVector2_t * pvCursor); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ClearOverlayCursorPositionOverride)(VROverlayHandle_t ulOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayTexture)(VROverlayHandle_t ulOverlayHandle, struct Texture_t * pTexture); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ClearOverlayTexture)(VROverlayHandle_t ulOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayRaw)(VROverlayHandle_t ulOverlayHandle, void * pvBuffer, uint32_t unWidth, uint32_t unHeight, uint32_t unBytesPerPixel); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetOverlayFromFile)(VROverlayHandle_t ulOverlayHandle, char * pchFilePath); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTexture)(VROverlayHandle_t ulOverlayHandle, void ** pNativeTextureHandle, void * pNativeTextureRef, uint32_t * pWidth, uint32_t * pHeight, uint32_t * pNativeFormat, ETextureType * pAPIType, EColorSpace * pColorSpace, struct VRTextureBounds_t * pTextureBounds); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ReleaseNativeOverlayHandle)(VROverlayHandle_t ulOverlayHandle, void * pNativeTextureHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetOverlayTextureSize)(VROverlayHandle_t ulOverlayHandle, uint32_t * pWidth, uint32_t * pHeight); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *CreateDashboardOverlay)(char * pchOverlayKey, char * pchOverlayFriendlyName, VROverlayHandle_t * pMainHandle, VROverlayHandle_t * pThumbnailHandle); + bool (OPENVR_FNTABLE_CALLTYPE *IsDashboardVisible)(); + bool (OPENVR_FNTABLE_CALLTYPE *IsActiveDashboardOverlay)(VROverlayHandle_t ulOverlayHandle); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *SetDashboardOverlaySceneProcess)(VROverlayHandle_t ulOverlayHandle, uint32_t unProcessId); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *GetDashboardOverlaySceneProcess)(VROverlayHandle_t ulOverlayHandle, uint32_t * punProcessId); + void (OPENVR_FNTABLE_CALLTYPE *ShowDashboard)(char * pchOverlayToShow); + TrackedDeviceIndex_t (OPENVR_FNTABLE_CALLTYPE *GetPrimaryDashboardDevice)(); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowKeyboard)(EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, uint32_t unFlags, char * pchDescription, uint32_t unCharMax, char * pchExistingText, uint64_t uUserValue); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ShowKeyboardForOverlay)(VROverlayHandle_t ulOverlayHandle, EGamepadTextInputMode eInputMode, EGamepadTextInputLineMode eLineInputMode, uint32_t unFlags, char * pchDescription, uint32_t unCharMax, char * pchExistingText, uint64_t uUserValue); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetKeyboardText)(char * pchText, uint32_t cchText); + void (OPENVR_FNTABLE_CALLTYPE *HideKeyboard)(); + void (OPENVR_FNTABLE_CALLTYPE *SetKeyboardTransformAbsolute)(ETrackingUniverseOrigin eTrackingOrigin, struct HmdMatrix34_t * pmatTrackingOriginToKeyboardTransform); + void (OPENVR_FNTABLE_CALLTYPE *SetKeyboardPositionForOverlay)(VROverlayHandle_t ulOverlayHandle, struct HmdRect2_t avoidRect); + VRMessageOverlayResponse (OPENVR_FNTABLE_CALLTYPE *ShowMessageOverlay)(char * pchText, char * pchCaption, char * pchButton0Text, char * pchButton1Text, char * pchButton2Text, char * pchButton3Text); + void (OPENVR_FNTABLE_CALLTYPE *CloseMessageOverlay)(); +}; + +struct VR_IVROverlayView_FnTable +{ + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *AcquireOverlayView)(VROverlayHandle_t ulOverlayHandle, struct VRNativeDevice_t * pNativeDevice, struct VROverlayView_t * pOverlayView, uint32_t unOverlayViewSize); + EVROverlayError (OPENVR_FNTABLE_CALLTYPE *ReleaseOverlayView)(struct VROverlayView_t * pOverlayView); + void (OPENVR_FNTABLE_CALLTYPE *PostOverlayEvent)(VROverlayHandle_t ulOverlayHandle, struct VREvent_t * pvrEvent); + bool (OPENVR_FNTABLE_CALLTYPE *IsViewingPermitted)(VROverlayHandle_t ulOverlayHandle); +}; + +struct VR_IVRHeadsetView_FnTable +{ + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewSize)(uint32_t nWidth, uint32_t nHeight); + void (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewSize)(uint32_t * pnWidth, uint32_t * pnHeight); + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewMode)(HeadsetViewMode_t eHeadsetViewMode); + HeadsetViewMode_t (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewMode)(); + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewCropped)(bool bCropped); + bool (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewCropped)(); + float (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewAspectRatio)(); + void (OPENVR_FNTABLE_CALLTYPE *SetHeadsetViewBlendRange)(float flStartPct, float flEndPct); + void (OPENVR_FNTABLE_CALLTYPE *GetHeadsetViewBlendRange)(float * pStartPct, float * pEndPct); +}; + +struct VR_IVRRenderModels_FnTable +{ + EVRRenderModelError (OPENVR_FNTABLE_CALLTYPE *LoadRenderModel_Async)(char * pchRenderModelName, struct RenderModel_t ** ppRenderModel); + void (OPENVR_FNTABLE_CALLTYPE *FreeRenderModel)(struct RenderModel_t * pRenderModel); + EVRRenderModelError (OPENVR_FNTABLE_CALLTYPE *LoadTexture_Async)(TextureID_t textureId, struct RenderModel_TextureMap_t ** ppTexture); + void (OPENVR_FNTABLE_CALLTYPE *FreeTexture)(struct RenderModel_TextureMap_t * pTexture); + EVRRenderModelError (OPENVR_FNTABLE_CALLTYPE *LoadTextureD3D11_Async)(TextureID_t textureId, void * pD3D11Device, void ** ppD3D11Texture2D); + EVRRenderModelError (OPENVR_FNTABLE_CALLTYPE *LoadIntoTextureD3D11_Async)(TextureID_t textureId, void * pDstTexture); + void (OPENVR_FNTABLE_CALLTYPE *FreeTextureD3D11)(void * pD3D11Texture2D); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetRenderModelName)(uint32_t unRenderModelIndex, char * pchRenderModelName, uint32_t unRenderModelNameLen); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetRenderModelCount)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetComponentCount)(char * pchRenderModelName); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetComponentName)(char * pchRenderModelName, uint32_t unComponentIndex, char * pchComponentName, uint32_t unComponentNameLen); + uint64_t (OPENVR_FNTABLE_CALLTYPE *GetComponentButtonMask)(char * pchRenderModelName, char * pchComponentName); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetComponentRenderModelName)(char * pchRenderModelName, char * pchComponentName, char * pchComponentRenderModelName, uint32_t unComponentRenderModelNameLen); + bool (OPENVR_FNTABLE_CALLTYPE *GetComponentStateForDevicePath)(char * pchRenderModelName, char * pchComponentName, VRInputValueHandle_t devicePath, RenderModel_ControllerMode_State_t * pState, RenderModel_ComponentState_t * pComponentState); + bool (OPENVR_FNTABLE_CALLTYPE *GetComponentState)(char * pchRenderModelName, char * pchComponentName, VRControllerState_t * pControllerState, struct RenderModel_ControllerMode_State_t * pState, struct RenderModel_ComponentState_t * pComponentState); + bool (OPENVR_FNTABLE_CALLTYPE *RenderModelHasComponent)(char * pchRenderModelName, char * pchComponentName); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetRenderModelThumbnailURL)(char * pchRenderModelName, char * pchThumbnailURL, uint32_t unThumbnailURLLen, EVRRenderModelError * peError); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetRenderModelOriginalPath)(char * pchRenderModelName, char * pchOriginalPath, uint32_t unOriginalPathLen, EVRRenderModelError * peError); + char * (OPENVR_FNTABLE_CALLTYPE *GetRenderModelErrorNameFromEnum)(EVRRenderModelError error); +}; + +struct VR_IVRNotifications_FnTable +{ + EVRNotificationError (OPENVR_FNTABLE_CALLTYPE *CreateNotification)(VROverlayHandle_t ulOverlayHandle, uint64_t ulUserValue, EVRNotificationType type, char * pchText, EVRNotificationStyle style, struct NotificationBitmap_t * pImage, VRNotificationId * pNotificationId); + EVRNotificationError (OPENVR_FNTABLE_CALLTYPE *RemoveNotification)(VRNotificationId notificationId); +}; + +struct VR_IVRSettings_FnTable +{ + char * (OPENVR_FNTABLE_CALLTYPE *GetSettingsErrorNameFromEnum)(EVRSettingsError eError); + void (OPENVR_FNTABLE_CALLTYPE *SetBool)(char * pchSection, char * pchSettingsKey, bool bValue, EVRSettingsError * peError); + void (OPENVR_FNTABLE_CALLTYPE *SetInt32)(char * pchSection, char * pchSettingsKey, int32_t nValue, EVRSettingsError * peError); + void (OPENVR_FNTABLE_CALLTYPE *SetFloat)(char * pchSection, char * pchSettingsKey, float flValue, EVRSettingsError * peError); + void (OPENVR_FNTABLE_CALLTYPE *SetString)(char * pchSection, char * pchSettingsKey, char * pchValue, EVRSettingsError * peError); + bool (OPENVR_FNTABLE_CALLTYPE *GetBool)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); + int32_t (OPENVR_FNTABLE_CALLTYPE *GetInt32)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); + float (OPENVR_FNTABLE_CALLTYPE *GetFloat)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); + void (OPENVR_FNTABLE_CALLTYPE *GetString)(char * pchSection, char * pchSettingsKey, char * pchValue, uint32_t unValueLen, EVRSettingsError * peError); + void (OPENVR_FNTABLE_CALLTYPE *RemoveSection)(char * pchSection, EVRSettingsError * peError); + void (OPENVR_FNTABLE_CALLTYPE *RemoveKeyInSection)(char * pchSection, char * pchSettingsKey, EVRSettingsError * peError); +}; + +struct VR_IVRScreenshots_FnTable +{ + EVRScreenshotError (OPENVR_FNTABLE_CALLTYPE *RequestScreenshot)(ScreenshotHandle_t * pOutScreenshotHandle, EVRScreenshotType type, char * pchPreviewFilename, char * pchVRFilename); + EVRScreenshotError (OPENVR_FNTABLE_CALLTYPE *HookScreenshot)(EVRScreenshotType * pSupportedTypes, int numTypes); + EVRScreenshotType (OPENVR_FNTABLE_CALLTYPE *GetScreenshotPropertyType)(ScreenshotHandle_t screenshotHandle, EVRScreenshotError * pError); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetScreenshotPropertyFilename)(ScreenshotHandle_t screenshotHandle, EVRScreenshotPropertyFilenames filenameType, char * pchFilename, uint32_t cchFilename, EVRScreenshotError * pError); + EVRScreenshotError (OPENVR_FNTABLE_CALLTYPE *UpdateScreenshotProgress)(ScreenshotHandle_t screenshotHandle, float flProgress); + EVRScreenshotError (OPENVR_FNTABLE_CALLTYPE *TakeStereoScreenshot)(ScreenshotHandle_t * pOutScreenshotHandle, char * pchPreviewFilename, char * pchVRFilename); + EVRScreenshotError (OPENVR_FNTABLE_CALLTYPE *SubmitScreenshot)(ScreenshotHandle_t screenshotHandle, EVRScreenshotType type, char * pchSourcePreviewFilename, char * pchSourceVRFilename); +}; + +struct VR_IVRResources_FnTable +{ + uint32_t (OPENVR_FNTABLE_CALLTYPE *LoadSharedResource)(char * pchResourceName, char * pchBuffer, uint32_t unBufferLen); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetResourceFullPath)(char * pchResourceName, char * pchResourceTypeDirectory, char * pchPathBuffer, uint32_t unBufferLen); +}; + +struct VR_IVRDriverManager_FnTable +{ + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetDriverCount)(); + uint32_t (OPENVR_FNTABLE_CALLTYPE *GetDriverName)(DriverId_t nDriver, char * pchValue, uint32_t unBufferSize); + DriverHandle_t (OPENVR_FNTABLE_CALLTYPE *GetDriverHandle)(char * pchDriverName); + bool (OPENVR_FNTABLE_CALLTYPE *IsEnabled)(DriverId_t nDriver); +}; + +struct VR_IVRInput_FnTable +{ + EVRInputError (OPENVR_FNTABLE_CALLTYPE *SetActionManifestPath)(char * pchActionManifestPath); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionSetHandle)(char * pchActionSetName, VRActionSetHandle_t * pHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionHandle)(char * pchActionName, VRActionHandle_t * pHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetInputSourceHandle)(char * pchInputSourcePath, VRInputValueHandle_t * pHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *UpdateActionState)(struct VRActiveActionSet_t * pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetDigitalActionData)(VRActionHandle_t action, struct InputDigitalActionData_t * pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetAnalogActionData)(VRActionHandle_t action, struct InputAnalogActionData_t * pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetPoseActionDataRelativeToNow)(VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, float fPredictedSecondsFromNow, struct InputPoseActionData_t * pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetPoseActionDataForNextFrame)(VRActionHandle_t action, ETrackingUniverseOrigin eOrigin, struct InputPoseActionData_t * pActionData, uint32_t unActionDataSize, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalActionData)(VRActionHandle_t action, struct InputSkeletalActionData_t * pActionData, uint32_t unActionDataSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetDominantHand)(ETrackedControllerRole * peDominantHand); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *SetDominantHand)(ETrackedControllerRole eDominantHand); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBoneCount)(VRActionHandle_t action, uint32_t * pBoneCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBoneHierarchy)(VRActionHandle_t action, BoneIndex_t * pParentIndices, uint32_t unIndexArayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBoneName)(VRActionHandle_t action, BoneIndex_t nBoneIndex, char * pchBoneName, uint32_t unNameBufferSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalReferenceTransforms)(VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalReferencePose eReferencePose, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalTrackingLevel)(VRActionHandle_t action, EVRSkeletalTrackingLevel * pSkeletalTrackingLevel); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalBoneData)(VRActionHandle_t action, EVRSkeletalTransformSpace eTransformSpace, EVRSkeletalMotionRange eMotionRange, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalSummaryData)(VRActionHandle_t action, EVRSummaryType eSummaryType, struct VRSkeletalSummaryData_t * pSkeletalSummaryData); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetSkeletalBoneDataCompressed)(VRActionHandle_t action, EVRSkeletalMotionRange eMotionRange, void * pvCompressedData, uint32_t unCompressedSize, uint32_t * punRequiredCompressedSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *DecompressSkeletalBoneData)(void * pvCompressedBuffer, uint32_t unCompressedBufferSize, EVRSkeletalTransformSpace eTransformSpace, struct VRBoneTransform_t * pTransformArray, uint32_t unTransformArrayCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *TriggerHapticVibrationAction)(VRActionHandle_t action, float fStartSecondsFromNow, float fDurationSeconds, float fFrequency, float fAmplitude, VRInputValueHandle_t ulRestrictToDevice); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionOrigins)(VRActionSetHandle_t actionSetHandle, VRActionHandle_t digitalActionHandle, VRInputValueHandle_t * originsOut, uint32_t originOutCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetOriginLocalizedName)(VRInputValueHandle_t origin, char * pchNameArray, uint32_t unNameArraySize, int32_t unStringSectionsToInclude); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetOriginTrackedDeviceInfo)(VRInputValueHandle_t origin, struct InputOriginInfo_t * pOriginInfo, uint32_t unOriginInfoSize); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetActionBindingInfo)(VRActionHandle_t action, struct InputBindingInfo_t * pOriginInfo, uint32_t unBindingInfoSize, uint32_t unBindingInfoCount, uint32_t * punReturnedBindingInfoCount); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *ShowActionOrigins)(VRActionSetHandle_t actionSetHandle, VRActionHandle_t ulActionHandle); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *ShowBindingsForActionSet)(struct VRActiveActionSet_t * pSets, uint32_t unSizeOfVRSelectedActionSet_t, uint32_t unSetCount, VRInputValueHandle_t originToHighlight); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetComponentStateForBinding)(char * pchRenderModelName, char * pchComponentName, struct InputBindingInfo_t * pOriginInfo, uint32_t unBindingInfoSize, uint32_t unBindingInfoCount, RenderModel_ComponentState_t * pComponentState); + bool (OPENVR_FNTABLE_CALLTYPE *IsUsingLegacyInput)(); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *OpenBindingUI)(char * pchAppKey, VRActionSetHandle_t ulActionSetHandle, VRInputValueHandle_t ulDeviceHandle, bool bShowOnDesktop); + EVRInputError (OPENVR_FNTABLE_CALLTYPE *GetBindingVariant)(VRInputValueHandle_t ulDevicePath, char * pchVariantArray, uint32_t unVariantArraySize); +}; + +struct VR_IVRIOBuffer_FnTable +{ + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Open)(char * pchPath, EIOBufferMode mode, uint32_t unElementSize, uint32_t unElements, IOBufferHandle_t * pulBuffer); + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Close)(IOBufferHandle_t ulBuffer); + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Read)(IOBufferHandle_t ulBuffer, void * pDst, uint32_t unBytes, uint32_t * punRead); + EIOBufferError (OPENVR_FNTABLE_CALLTYPE *Write)(IOBufferHandle_t ulBuffer, void * pSrc, uint32_t unBytes); + PropertyContainerHandle_t (OPENVR_FNTABLE_CALLTYPE *PropertyContainer)(IOBufferHandle_t ulBuffer); + bool (OPENVR_FNTABLE_CALLTYPE *HasReaders)(IOBufferHandle_t ulBuffer); +}; + +struct VR_IVRSpatialAnchors_FnTable +{ + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *CreateSpatialAnchorFromDescriptor)(char * pchDescriptor, SpatialAnchorHandle_t * pHandleOut); + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *CreateSpatialAnchorFromPose)(TrackedDeviceIndex_t unDeviceIndex, ETrackingUniverseOrigin eOrigin, struct SpatialAnchorPose_t * pPose, SpatialAnchorHandle_t * pHandleOut); + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *GetSpatialAnchorPose)(SpatialAnchorHandle_t unHandle, ETrackingUniverseOrigin eOrigin, struct SpatialAnchorPose_t * pPoseOut); + EVRSpatialAnchorError (OPENVR_FNTABLE_CALLTYPE *GetSpatialAnchorDescriptor)(SpatialAnchorHandle_t unHandle, char * pchDescriptorOut, uint32_t * punDescriptorBufferLenInOut); +}; + +struct VR_IVRDebug_FnTable +{ + EVRDebugError (OPENVR_FNTABLE_CALLTYPE *EmitVrProfilerEvent)(char * pchMessage); + EVRDebugError (OPENVR_FNTABLE_CALLTYPE *BeginVrProfilerEvent)(VrProfilerEventHandle_t * pHandleOut); + EVRDebugError (OPENVR_FNTABLE_CALLTYPE *FinishVrProfilerEvent)(VrProfilerEventHandle_t hHandle, char * pchMessage); + uint32_t (OPENVR_FNTABLE_CALLTYPE *DriverDebugRequest)(TrackedDeviceIndex_t unDeviceIndex, char * pchRequest, char * pchResponseBuffer, uint32_t unResponseBufferSize); +}; + +struct VR_IVRProperties_FnTable +{ + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *ReadPropertyBatch)(PropertyContainerHandle_t ulContainerHandle, struct PropertyRead_t * pBatch, uint32_t unBatchEntryCount); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *WritePropertyBatch)(PropertyContainerHandle_t ulContainerHandle, struct PropertyWrite_t * pBatch, uint32_t unBatchEntryCount); + char * (OPENVR_FNTABLE_CALLTYPE *GetPropErrorNameFromEnum)(ETrackedPropertyError error); + PropertyContainerHandle_t (OPENVR_FNTABLE_CALLTYPE *TrackedDeviceToPropertyContainer)(TrackedDeviceIndex_t nDevice); +}; + +struct VR_IVRPaths_FnTable +{ + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *ReadPathBatch)(PropertyContainerHandle_t ulRootHandle, struct PathRead_t * pBatch, uint32_t unBatchEntryCount); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *WritePathBatch)(PropertyContainerHandle_t ulRootHandle, struct PathWrite_t * pBatch, uint32_t unBatchEntryCount); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *StringToHandle)(PathHandle_t * pHandle, char * pchPath); + ETrackedPropertyError (OPENVR_FNTABLE_CALLTYPE *HandleToString)(PathHandle_t pHandle, char * pchBuffer, uint32_t unBufferSize, uint32_t * punBufferSizeUsed); +}; + +struct VR_IVRBlockQueue_FnTable +{ + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *Create)(PropertyContainerHandle_t * pulQueueHandle, char * pchPath, uint32_t unBlockDataSize, uint32_t unBlockHeaderSize, uint32_t unBlockCount, uint32_t unFlags); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *Connect)(PropertyContainerHandle_t * pulQueueHandle, char * pchPath); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *Destroy)(PropertyContainerHandle_t ulQueueHandle); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *AcquireWriteOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t * pulBlockHandle, void ** ppvBuffer); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *ReleaseWriteOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t ulBlockHandle); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *WaitAndAcquireReadOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t * pulBlockHandle, void ** ppvBuffer, EBlockQueueReadType eReadType, uint32_t unTimeoutMs); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *AcquireReadOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t * pulBlockHandle, void ** ppvBuffer, EBlockQueueReadType eReadType); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *ReleaseReadOnlyBlock)(PropertyContainerHandle_t ulQueueHandle, PropertyContainerHandle_t ulBlockHandle); + EBlockQueueError (OPENVR_FNTABLE_CALLTYPE *QueueHasReader)(PropertyContainerHandle_t ulQueueHandle, bool * pbHasReaders); +}; + + +#if 0 +// Global entry points +S_API intptr_t VR_InitInternal( EVRInitError *peError, EVRApplicationType eType ); +S_API void VR_ShutdownInternal(); +S_API bool VR_IsHmdPresent(); +S_API intptr_t VR_GetGenericInterface( const char *pchInterfaceVersion, EVRInitError *peError ); +S_API bool VR_IsRuntimeInstalled(); +S_API const char * VR_GetVRInitErrorAsSymbol( EVRInitError error ); +S_API const char * VR_GetVRInitErrorAsEnglishDescription( EVRInitError error ); +#endif + +#endif // __OPENVR_API_FLAT_H__ + + diff --git a/contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.c b/contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.c new file mode 100644 index 0000000..e8d2635 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.c @@ -0,0 +1,121 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_PS2 + +/* PS2 SDL video driver implementation; this is just enough to make an + * SDL-based application THINK it's got a working video driver, for + * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, + * and also for use as a collection of stubs when porting SDL to a new + * platform for which you haven't yet written a valid video driver. + * + * This is also a great way to determine bottlenecks: if you think that SDL + * is a performance problem for a given platform, enable this driver, and + * then see if your application runs faster without video overhead. + * + * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion + * of this was cut-and-pasted from Stephane Peter's work in the AAlib + * SDL video driver. Renamed to "PS2" by Sam Lantinga. + */ + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_ps2video.h" + +// PS2 driver bootstrap functions + +static bool PS2_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + return true; +} + +static void PS2_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device); +} + +static bool PS2_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_SetKeyboardFocus(window); + + // Window has been successfully created + return true; +} + +static bool PS2_VideoInit(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; + + SDL_zero(mode); + mode.w = 640; + mode.h = 480; + mode.refresh_rate = 60.0f; + + // 32 bpp for default + mode.format = SDL_PIXELFORMAT_ABGR8888; + + SDL_AddBasicVideoDisplay(&mode); + + return true; +} + +static void PS2_VideoQuit(SDL_VideoDevice *_this) +{ +} + +static void PS2_PumpEvents(SDL_VideoDevice *_this) +{ + // do nothing. +} + +static SDL_VideoDevice *PS2_CreateDevice(void) +{ + SDL_VideoDevice *device; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Set the function pointers + device->VideoInit = PS2_VideoInit; + device->VideoQuit = PS2_VideoQuit; + device->SetDisplayMode = PS2_SetDisplayMode; + device->CreateSDLWindow = PS2_CreateWindow; + device->PumpEvents = PS2_PumpEvents; + device->free = PS2_DeleteDevice; + + return device; +} + +VideoBootStrap PS2_bootstrap = { + "ps2", + "PS2 Video Driver", + PS2_CreateDevice, + NULL, // no ShowMessageBox implementation + false +}; + +#endif // SDL_VIDEO_DRIVER_PS2 diff --git a/contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.h b/contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.h new file mode 100644 index 0000000..fb79781 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/ps2/SDL_ps2video.h @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_ps2video_h_ +#define SDL_ps2video_h_ + +#include "../SDL_sysvideo.h" + +#include + +#include +#include + +#include + +#ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeclaration-after-statement" +#endif + +#include + +#ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA +#pragma GCC diagnostic pop +#endif + +#endif // SDL_ps2video_h_ diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspevents.c b/contrib/SDL-3.2.8/src/video/psp/SDL_pspevents.c new file mode 100644 index 0000000..631f0aa --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspevents.c @@ -0,0 +1,274 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_PSP + +/* Being a null driver, there's no event stream. We just define stubs for + most of the API. */ + +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../SDL_sysvideo.h" +#include "SDL_pspvideo.h" +#include "SDL_pspevents_c.h" +#include "../../thread/SDL_systhread.h" +#include +#include + +#ifdef PSPIRKEYB +#include +#include + +#define IRKBD_CONFIG_FILE NULL // this will take ms0:/seplugins/pspirkeyb.ini + +static int irkbd_ready = 0; +static SDL_Scancode keymap[256]; +#endif + +static enum PspHprmKeys hprm = 0; +static SDL_Semaphore *event_sem = NULL; +static SDL_Thread *thread = NULL; +static int running = 0; +static struct +{ + enum PspHprmKeys id; + SDL_Scancode scancode; +} keymap_psp[] = { + { PSP_HPRM_PLAYPAUSE, SDL_SCANCODE_F10 }, + { PSP_HPRM_FORWARD, SDL_SCANCODE_F11 }, + { PSP_HPRM_BACK, SDL_SCANCODE_F12 }, + { PSP_HPRM_VOL_UP, SDL_SCANCODE_F13 }, + { PSP_HPRM_VOL_DOWN, SDL_SCANCODE_F14 }, + { PSP_HPRM_HOLD, SDL_SCANCODE_F15 } +}; + +int EventUpdate(void *data) +{ + while (running) { + SDL_WaitSemaphore(event_sem); + sceHprmPeekCurrentKey((u32 *)&hprm); + SDL_SignalSemaphore(event_sem); + // Delay 1/60th of a second + sceKernelDelayThread(1000000 / 60); + } + return 0; +} + +void PSP_PumpEvents(SDL_VideoDevice *_this) +{ + int i; + enum PspHprmKeys keys; + enum PspHprmKeys changed; + static enum PspHprmKeys old_keys = 0; + + SDL_WaitSemaphore(event_sem); + keys = hprm; + SDL_SignalSemaphore(event_sem); + + // HPRM Keyboard + changed = old_keys ^ keys; + old_keys = keys; + if (changed) { + for (i = 0; i < sizeof(keymap_psp) / sizeof(keymap_psp[0]); i++) { + if (changed & keymap_psp[i].id) { + bool down = ((keys & keymap_psp[i].id) != 0); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, keymap_psp[i].id, keymap_psp[i].scancode, down); + } + } + } + +#ifdef PSPIRKEYB + if (irkbd_ready) { + unsigned char buffer[255]; + int i, length, count; + SIrKeybScanCodeData *scanData; + + if (pspIrKeybReadinput(buffer, &length) >= 0) { + if ((length % sizeof(SIrKeybScanCodeData)) == 0) { + count = length / sizeof(SIrKeybScanCodeData); + for (i = 0; i < count; i++) { + unsigned char raw; + bool down; + scanData = (SIrKeybScanCodeData *)buffer + i; + raw = scanData->raw; + down = (scanData->pressed != 0); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, raw, keymap[raw], down); + } + } + } + } +#endif + sceKernelDelayThread(0); + + return; +} + +void PSP_InitOSKeymap(SDL_VideoDevice *_this) +{ +#ifdef PSPIRKEYB + int i; + for (i = 0; i < SDL_arraysize(keymap); ++i) { + keymap[i] = SDL_SCANCODE_UNKNOWN; + } + + keymap[KEY_ESC] = SDL_SCANCODE_ESCAPE; + + keymap[KEY_F1] = SDL_SCANCODE_F1; + keymap[KEY_F2] = SDL_SCANCODE_F2; + keymap[KEY_F3] = SDL_SCANCODE_F3; + keymap[KEY_F4] = SDL_SCANCODE_F4; + keymap[KEY_F5] = SDL_SCANCODE_F5; + keymap[KEY_F6] = SDL_SCANCODE_F6; + keymap[KEY_F7] = SDL_SCANCODE_F7; + keymap[KEY_F8] = SDL_SCANCODE_F8; + keymap[KEY_F9] = SDL_SCANCODE_F9; + keymap[KEY_F10] = SDL_SCANCODE_F10; + keymap[KEY_F11] = SDL_SCANCODE_F11; + keymap[KEY_F12] = SDL_SCANCODE_F12; + keymap[KEY_F13] = SDL_SCANCODE_PRINT; + keymap[KEY_F14] = SDL_SCANCODE_PAUSE; + + keymap[KEY_GRAVE] = SDL_SCANCODE_GRAVE; + keymap[KEY_1] = SDL_SCANCODE_1; + keymap[KEY_2] = SDL_SCANCODE_2; + keymap[KEY_3] = SDL_SCANCODE_3; + keymap[KEY_4] = SDL_SCANCODE_4; + keymap[KEY_5] = SDL_SCANCODE_5; + keymap[KEY_6] = SDL_SCANCODE_6; + keymap[KEY_7] = SDL_SCANCODE_7; + keymap[KEY_8] = SDL_SCANCODE_8; + keymap[KEY_9] = SDL_SCANCODE_9; + keymap[KEY_0] = SDL_SCANCODE_0; + keymap[KEY_MINUS] = SDL_SCANCODE_MINUS; + keymap[KEY_EQUAL] = SDL_SCANCODE_EQUALS; + keymap[KEY_BACKSPACE] = SDL_SCANCODE_BACKSPACE; + + keymap[KEY_TAB] = SDL_SCANCODE_TAB; + keymap[KEY_Q] = SDL_SCANCODE_q; + keymap[KEY_W] = SDL_SCANCODE_w; + keymap[KEY_E] = SDL_SCANCODE_e; + keymap[KEY_R] = SDL_SCANCODE_r; + keymap[KEY_T] = SDL_SCANCODE_t; + keymap[KEY_Y] = SDL_SCANCODE_y; + keymap[KEY_U] = SDL_SCANCODE_u; + keymap[KEY_I] = SDL_SCANCODE_i; + keymap[KEY_O] = SDL_SCANCODE_o; + keymap[KEY_P] = SDL_SCANCODE_p; + keymap[KEY_LEFTBRACE] = SDL_SCANCODE_LEFTBRACKET; + keymap[KEY_RIGHTBRACE] = SDL_SCANCODE_RIGHTBRACKET; + keymap[KEY_ENTER] = SDL_SCANCODE_RETURN; + + keymap[KEY_CAPSLOCK] = SDL_SCANCODE_CAPSLOCK; + keymap[KEY_A] = SDL_SCANCODE_a; + keymap[KEY_S] = SDL_SCANCODE_s; + keymap[KEY_D] = SDL_SCANCODE_d; + keymap[KEY_F] = SDL_SCANCODE_f; + keymap[KEY_G] = SDL_SCANCODE_g; + keymap[KEY_H] = SDL_SCANCODE_h; + keymap[KEY_J] = SDL_SCANCODE_j; + keymap[KEY_K] = SDL_SCANCODE_k; + keymap[KEY_L] = SDL_SCANCODE_l; + keymap[KEY_SEMICOLON] = SDL_SCANCODE_SEMICOLON; + keymap[KEY_APOSTROPHE] = SDL_SCANCODE_APOSTROPHE; + keymap[KEY_BACKSLASH] = SDL_SCANCODE_BACKSLASH; + + keymap[KEY_Z] = SDL_SCANCODE_z; + keymap[KEY_X] = SDL_SCANCODE_x; + keymap[KEY_C] = SDL_SCANCODE_c; + keymap[KEY_V] = SDL_SCANCODE_v; + keymap[KEY_B] = SDL_SCANCODE_b; + keymap[KEY_N] = SDL_SCANCODE_n; + keymap[KEY_M] = SDL_SCANCODE_m; + keymap[KEY_COMMA] = SDL_SCANCODE_COMMA; + keymap[KEY_DOT] = SDL_SCANCODE_PERIOD; + keymap[KEY_SLASH] = SDL_SCANCODE_SLASH; + + keymap[KEY_SPACE] = SDL_SCANCODE_SPACE; + + keymap[KEY_UP] = SDL_SCANCODE_UP; + keymap[KEY_DOWN] = SDL_SCANCODE_DOWN; + keymap[KEY_LEFT] = SDL_SCANCODE_LEFT; + keymap[KEY_RIGHT] = SDL_SCANCODE_RIGHT; + + keymap[KEY_HOME] = SDL_SCANCODE_HOME; + keymap[KEY_END] = SDL_SCANCODE_END; + keymap[KEY_INSERT] = SDL_SCANCODE_INSERT; + keymap[KEY_DELETE] = SDL_SCANCODE_DELETE; + + keymap[KEY_NUMLOCK] = SDL_SCANCODE_NUMLOCK; + keymap[KEY_LEFTMETA] = SDL_SCANCODE_LSUPER; + + keymap[KEY_KPSLASH] = SDL_SCANCODE_KP_DIVIDE; + keymap[KEY_KPASTERISK] = SDL_SCANCODE_KP_MULTIPLY; + keymap[KEY_KPMINUS] = SDL_SCANCODE_KP_MINUS; + keymap[KEY_KPPLUS] = SDL_SCANCODE_KP_PLUS; + keymap[KEY_KPDOT] = SDL_SCANCODE_KP_PERIOD; + keymap[KEY_KPEQUAL] = SDL_SCANCODE_KP_EQUALS; + + keymap[KEY_LEFTCTRL] = SDL_SCANCODE_LCTRL; + keymap[KEY_RIGHTCTRL] = SDL_SCANCODE_RCTRL; + keymap[KEY_LEFTALT] = SDL_SCANCODE_LALT; + keymap[KEY_RIGHTALT] = SDL_SCANCODE_RALT; + keymap[KEY_LEFTSHIFT] = SDL_SCANCODE_LSHIFT; + keymap[KEY_RIGHTSHIFT] = SDL_SCANCODE_RSHIFT; +#endif +} + +bool PSP_EventInit(SDL_VideoDevice *_this) +{ +#ifdef PSPIRKEYB + int outputmode = PSP_IRKBD_OUTPUT_MODE_SCANCODE; + int ret = pspIrKeybInit(IRKBD_CONFIG_FILE, 0); + if (ret == PSP_IRKBD_RESULT_OK) { + pspIrKeybOutputMode(outputmode); + irkbd_ready = 1; + } else { + irkbd_ready = 0; + } +#endif + // Start thread to read data + if ((event_sem = SDL_CreateSemaphore(1)) == NULL) { + return SDL_SetError("Can't create input semaphore"); + } + running = 1; + if ((thread = SDL_CreateThreadWithStackSize(EventUpdate, "PSPInputThread", 4096, NULL)) == NULL) { + return SDL_SetError("Can't create input thread"); + } + return true; +} + +void PSP_EventQuit(SDL_VideoDevice *_this) +{ + running = 0; + SDL_WaitThread(thread, NULL); + SDL_DestroySemaphore(event_sem); +#ifdef PSPIRKEYB + if (irkbd_ready) { + pspIrKeybFinish(); + irkbd_ready = 0; + } +#endif +} + +// end of SDL_pspevents.c ... + +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspevents_c.h b/contrib/SDL-3.2.8/src/video/psp/SDL_pspevents_c.h new file mode 100644 index 0000000..295c21a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspevents_c.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_pspvideo.h" + +extern void PSP_InitOSKeymap(SDL_VideoDevice *_this); +extern void PSP_PumpEvents(SDL_VideoDevice *_this); +extern bool PSP_EventInit(SDL_VideoDevice *_this); +extern void PSP_EventQuit(SDL_VideoDevice *_this); + +// end of SDL_pspevents_c.h ... diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspgl.c b/contrib/SDL-3.2.8/src/video/psp/SDL_pspgl.c new file mode 100644 index 0000000..0e58256 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspgl.c @@ -0,0 +1,190 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_PSP + +#include +#include + +#include "SDL_pspvideo.h" +#include "SDL_pspgl_c.h" + +/*****************************************************************************/ +// SDL OpenGL/OpenGL ES functions +/*****************************************************************************/ +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return NULL; \ + } \ + } while (0) + +bool PSP_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + return true; +} + +/* pspgl doesn't provide this call, so stub it out since SDL requires it. +#define GLSTUB(func,params) void func params {} + +GLSTUB(glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, + GLdouble zNear, GLdouble zFar)) +*/ +SDL_FunctionPointer PSP_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + return eglGetProcAddress(proc); +} + +void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this) +{ + eglTerminate(_this->gl_data->display); +} + +static EGLint width = 480; +static EGLint height = 272; + +SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + + SDL_WindowData *wdata = window->internal; + + EGLint attribs[32]; + EGLDisplay display; + EGLContext context; + EGLSurface surface; + EGLConfig config; + EGLint num_configs; + int i; + + // EGL init taken from glutCreateWindow() in PSPGL's glut.c. + EGLCHK(display = eglGetDisplay(0)); + EGLCHK(eglInitialize(display, NULL, NULL)); + wdata->uses_gles = true; + window->flags |= SDL_WINDOW_FULLSCREEN; + + // Setup the config based on SDL's current values. + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + + if (_this->gl_config.alpha_size) { + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + if (_this->gl_config.stencil_size) { + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } + + attribs[i++] = EGL_NONE; + + EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs)); + + if (num_configs == 0) { + SDL_SetError("No valid EGL configs for requested mode"); + return NULL; + } + + EGLCHK(eglGetConfigAttrib(display, config, EGL_WIDTH, &width)); + EGLCHK(eglGetConfigAttrib(display, config, EGL_HEIGHT, &height)); + + EGLCHK(context = eglCreateContext(display, config, NULL, NULL)); + EGLCHK(surface = eglCreateWindowSurface(display, config, 0, NULL)); + EGLCHK(eglMakeCurrent(display, surface, surface, context)); + + _this->gl_data->display = display; + _this->gl_data->context = context; + _this->gl_data->surface = surface; + + return context; +} + +bool PSP_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, + _this->gl_data->surface, _this->gl_data->context)) { + return SDL_SetError("Unable to make EGL context current"); + } + return true; +} + +bool PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + EGLBoolean status; + status = eglSwapInterval(_this->gl_data->display, interval); + if (status == EGL_TRUE) { + // Return success to upper level + _this->gl_data->swapinterval = interval; + return true; + } + // Failed to set swap interval + return SDL_SetError("Unable to set the EGL swap interval"); +} + +bool PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + *interval = _this->gl_data->swapinterval; + return true; +} + +bool PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) { + return SDL_SetError("eglSwapBuffers() failed"); + } + return true; +} + +bool PSP_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + SDL_VideoData *phdata = _this->internal; + EGLBoolean status; + + if (phdata->egl_initialized != true) { + return SDL_SetError("PSP: GLES initialization failed, no OpenGL ES support"); + } + + // Check if OpenGL ES connection has been initialized + if (_this->gl_data->display != EGL_NO_DISPLAY) { + if (context != EGL_NO_CONTEXT) { + status = eglDestroyContext(_this->gl_data->display, context); + if (status != EGL_TRUE) { + // Error during OpenGL ES context destroying + return SDL_SetError("PSP: OpenGL ES context destroy error"); + } + } + } + return true; +} + +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspgl_c.h b/contrib/SDL-3.2.8/src/video/psp/SDL_pspgl_c.h new file mode 100644 index 0000000..028860d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspgl_c.h @@ -0,0 +1,50 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_pspgl_c_h_ +#define SDL_pspgl_c_h_ + +#include +#include + +#include "SDL_pspvideo.h" + +typedef struct SDL_GLDriverData +{ + EGLDisplay display; + EGLContext context; + EGLSurface surface; + uint32_t swapinterval; +} SDL_GLDriverData; + +extern SDL_FunctionPointer PSP_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern bool PSP_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern void PSP_GL_SwapBuffers(SDL_VideoDevice *_this); + +extern bool PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); + +extern bool PSP_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this); +extern bool PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); + +#endif // SDL_pspgl_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse.c b/contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse.c new file mode 100644 index 0000000..e63be96 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse.c @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_PSP + +#include + +#include "../../events/SDL_events_c.h" + +#include "SDL_pspmouse_c.h" + +// The implementation dependent data for the window manager cursor +struct WMcursor +{ + int unused; +}; + +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse_c.h b/contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse_c.h new file mode 100644 index 0000000..95d1ff4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspmouse_c.h @@ -0,0 +1,24 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_pspvideo.h" + +// Functions to be exported diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.c b/contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.c new file mode 100644 index 0000000..2458235 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.c @@ -0,0 +1,499 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_PSP + +// SDL internals +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" + +// PSP declarations +#include "SDL_pspvideo.h" +#include "SDL_pspevents_c.h" +#include "SDL_pspgl_c.h" +#include "../../render/psp/SDL_render_psp_c.h" + +#include +#include +#include +#include + +/* unused +static bool PSP_initialized = false; +*/ + +static void PSP_Destroy(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *PSP_Create(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; + SDL_GLDriverData *gldata; + + // Initialize SDL_VideoDevice structure + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Initialize internal PSP specific data + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!phdata) { + SDL_free(device); + return NULL; + } + + gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); + if (!gldata) { + SDL_free(device); + SDL_free(phdata); + return NULL; + } + device->gl_data = gldata; + + device->internal = phdata; + + phdata->egl_initialized = true; + + // Setup amount of available displays + device->num_displays = 0; + + // Set device free function + device->free = PSP_Destroy; + + // Setup all functions which we can handle + device->VideoInit = PSP_VideoInit; + device->VideoQuit = PSP_VideoQuit; + device->GetDisplayModes = PSP_GetDisplayModes; + device->SetDisplayMode = PSP_SetDisplayMode; + device->CreateSDLWindow = PSP_CreateWindow; + device->SetWindowTitle = PSP_SetWindowTitle; + device->SetWindowPosition = PSP_SetWindowPosition; + device->SetWindowSize = PSP_SetWindowSize; + device->ShowWindow = PSP_ShowWindow; + device->HideWindow = PSP_HideWindow; + device->RaiseWindow = PSP_RaiseWindow; + device->MaximizeWindow = PSP_MaximizeWindow; + device->MinimizeWindow = PSP_MinimizeWindow; + device->RestoreWindow = PSP_RestoreWindow; + device->DestroyWindow = PSP_DestroyWindow; + device->GL_LoadLibrary = PSP_GL_LoadLibrary; + device->GL_GetProcAddress = PSP_GL_GetProcAddress; + device->GL_UnloadLibrary = PSP_GL_UnloadLibrary; + device->GL_CreateContext = PSP_GL_CreateContext; + device->GL_MakeCurrent = PSP_GL_MakeCurrent; + device->GL_SetSwapInterval = PSP_GL_SetSwapInterval; + device->GL_GetSwapInterval = PSP_GL_GetSwapInterval; + device->GL_SwapWindow = PSP_GL_SwapWindow; + device->GL_DestroyContext = PSP_GL_DestroyContext; + device->HasScreenKeyboardSupport = PSP_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = PSP_ShowScreenKeyboard; + device->HideScreenKeyboard = PSP_HideScreenKeyboard; + device->IsScreenKeyboardShown = PSP_IsScreenKeyboardShown; + + device->PumpEvents = PSP_PumpEvents; + + return device; +} + +static void configure_dialog(pspUtilityMsgDialogParams *dialog, size_t dialog_size) +{ + // clear structure and setup size + SDL_memset(dialog, 0, dialog_size); + dialog->base.size = dialog_size; + + // set language + sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, &dialog->base.language); + + // set X/O swap + sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &dialog->base.buttonSwap); + + // set thread priorities + // TODO: understand how these work + dialog->base.soundThread = 0x10; + dialog->base.graphicsThread = 0x11; + dialog->base.fontThread = 0x12; + dialog->base.accessThread = 0x13; +} + +static void *setup_temporal_gu(void *list) +{ + // Using GU_PSM_8888 for the framebuffer + int bpp = 4; + + void *doublebuffer = vramalloc(PSP_FRAME_BUFFER_SIZE * bpp * 2); + void *backbuffer = doublebuffer; + void *frontbuffer = ((uint8_t *)doublebuffer) + PSP_FRAME_BUFFER_SIZE * bpp; + + sceGuInit(); + + sceGuStart(GU_DIRECT,list); + sceGuDrawBuffer(GU_PSM_8888, vrelptr(frontbuffer), PSP_FRAME_BUFFER_WIDTH); + sceGuDispBuffer(PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT, vrelptr(backbuffer), PSP_FRAME_BUFFER_WIDTH); + + sceGuOffset(2048 - (PSP_SCREEN_WIDTH >> 1), 2048 - (PSP_SCREEN_HEIGHT >> 1)); + sceGuViewport(2048, 2048, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + + sceGuDisable(GU_DEPTH_TEST); + + // Scissoring + sceGuScissor(0, 0, PSP_SCREEN_WIDTH, PSP_SCREEN_HEIGHT); + sceGuEnable(GU_SCISSOR_TEST); + + sceGuFinish(); + sceGuSync(0,0); + + sceDisplayWaitVblankStart(); + sceGuDisplay(GU_TRUE); + + return doublebuffer; +} + +static void term_temporal_gu(void *guBuffer) +{ + sceGuTerm(); + vfree(guBuffer); + sceDisplayWaitVblankStart(); +} + +bool PSP_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + unsigned char list[64] __attribute__((aligned(64))); + pspUtilityMsgDialogParams dialog; + int status; + void *guBuffer = NULL; + + // check if it's possible to use existing video context + if (SDL_GetKeyboardFocus() == NULL) { + guBuffer = setup_temporal_gu(list); + } + + // configure dialog + configure_dialog(&dialog, sizeof(dialog)); + + // setup dialog options for text + dialog.mode = PSP_UTILITY_MSGDIALOG_MODE_TEXT; + dialog.options = PSP_UTILITY_MSGDIALOG_OPTION_TEXT; + + // copy the message in, 512 bytes max + SDL_snprintf(dialog.message, sizeof(dialog.message), "%s\r\n\r\n%s", messageboxdata->title, messageboxdata->message); + + // too many buttons + if (messageboxdata->numbuttons > 2) + return SDL_SetError("messageboxdata->numbuttons valid values are 0, 1, 2"); + + // we only have two options, "yes/no" or "ok" + if (messageboxdata->numbuttons == 2) + dialog.options |= PSP_UTILITY_MSGDIALOG_OPTION_YESNO_BUTTONS | PSP_UTILITY_MSGDIALOG_OPTION_DEFAULT_NO; + + // start dialog + if (sceUtilityMsgDialogInitStart(&dialog) != 0) + return SDL_SetError("sceUtilityMsgDialogInitStart() failed for some reason"); + + // loop while the dialog is active + status = PSP_UTILITY_DIALOG_NONE; + do + { + sceGuStart(GU_DIRECT, list); + sceGuClearColor(0); + sceGuClearDepth(0); + sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); + sceGuFinish(); + sceGuSync(0,0); + + status = sceUtilityMsgDialogGetStatus(); + + switch (status) + { + case PSP_UTILITY_DIALOG_VISIBLE: + sceUtilityMsgDialogUpdate(1); + break; + + case PSP_UTILITY_DIALOG_QUIT: + sceUtilityMsgDialogShutdownStart(); + break; + } + + sceDisplayWaitVblankStart(); + sceGuSwapBuffers(); + + } while (status != PSP_UTILITY_DIALOG_NONE); + + // cleanup + if (guBuffer) + { + term_temporal_gu(guBuffer); + } + + // success + if (dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_YES) + *buttonID = messageboxdata->buttons[0].buttonID; + else if (dialog.buttonPressed == PSP_UTILITY_MSGDIALOG_RESULT_NO) + *buttonID = messageboxdata->buttons[1].buttonID; + else + *buttonID = messageboxdata->buttons[0].buttonID; + + return true; +} + +VideoBootStrap PSP_bootstrap = { + "psp", + "PSP Video Driver", + PSP_Create, + PSP_ShowMessageBox, + false +}; + +/*****************************************************************************/ +// SDL Video and Display initialization/handling functions +/*****************************************************************************/ +bool PSP_VideoInit(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; + + if (!PSP_EventInit(_this)) { + return false; // error string would already be set + } + + SDL_zero(mode); + mode.w = PSP_SCREEN_WIDTH; + mode.h = PSP_SCREEN_HEIGHT; + mode.refresh_rate = 60.0f; + + // 32 bpp for default + mode.format = SDL_PIXELFORMAT_ABGR8888; + + if (SDL_AddBasicVideoDisplay(&mode) == 0) { + return false; + } + return true; +} + +void PSP_VideoQuit(SDL_VideoDevice *_this) +{ + PSP_EventQuit(_this); +} + +bool PSP_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayMode mode; + + SDL_zero(mode); + mode.w = PSP_SCREEN_WIDTH; + mode.h = PSP_SCREEN_HEIGHT; + mode.refresh_rate = 60.0f; + + // 32 bpp for default + mode.format = SDL_PIXELFORMAT_ABGR8888; + SDL_AddFullscreenDisplayMode(display, &mode); + + // 16 bpp secondary mode + mode.format = SDL_PIXELFORMAT_BGR565; + SDL_AddFullscreenDisplayMode(display, &mode); + return true; +} + +bool PSP_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + return true; +} + +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return true; \ + } \ + } while (0) + +bool PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *wdata; + + // Allocate window internal data + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!wdata) { + return false; + } + + // Setup driver data for this window + window->internal = wdata; + + SDL_SetKeyboardFocus(window); + + // Window has been successfully created + return true; +} + +void PSP_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +bool PSP_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + return SDL_Unsupported(); +} +void PSP_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void PSP_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void PSP_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void PSP_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void PSP_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void PSP_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void PSP_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void PSP_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} + +bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + return true; +} + +void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + char list[0x20000] __attribute__((aligned(64))); // Needed for sceGuStart to work + int i; + int done = 0; + int input_text_length = 32; // SDL_SendKeyboardText supports up to 32 characters per event + unsigned short outtext[input_text_length]; + char text_string[input_text_length]; + + SceUtilityOskData data; + SceUtilityOskParams params; + + SDL_memset(outtext, 0, input_text_length * sizeof(unsigned short)); + + data.language = PSP_UTILITY_OSK_LANGUAGE_DEFAULT; + data.lines = 1; + data.unk_24 = 1; + switch (SDL_GetTextInputType(props)) { + default: + case SDL_TEXTINPUT_TYPE_TEXT: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_NAME: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_EMAIL: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_USERNAME: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_ALL; + break; + case SDL_TEXTINPUT_TYPE_NUMBER: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE: + data.inputtype = PSP_UTILITY_OSK_INPUTTYPE_LATIN_DIGIT; + break; + } + data.desc = NULL; + data.intext = NULL; + data.outtextlength = input_text_length; + data.outtextlimit = input_text_length; + data.outtext = outtext; + + params.base.size = sizeof(params); + sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_LANGUAGE, ¶ms.base.language); + sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, ¶ms.base.buttonSwap); + params.base.graphicsThread = 17; + params.base.accessThread = 19; + params.base.fontThread = 18; + params.base.soundThread = 16; + params.datacount = 1; + params.data = &data; + + sceUtilityOskInitStart(¶ms); + + while(!done) { + sceGuStart(GU_DIRECT, list); + sceGuClearColor(0); + sceGuClearDepth(0); + sceGuClear(GU_COLOR_BUFFER_BIT|GU_DEPTH_BUFFER_BIT); + sceGuFinish(); + sceGuSync(0,0); + + switch(sceUtilityOskGetStatus()) + { + case PSP_UTILITY_DIALOG_VISIBLE: + sceUtilityOskUpdate(1); + break; + case PSP_UTILITY_DIALOG_QUIT: + sceUtilityOskShutdownStart(); + break; + case PSP_UTILITY_DIALOG_NONE: + done = 1; + break; + default : + break; + } + sceDisplayWaitVblankStart(); + sceGuSwapBuffers(); + } + + // Convert input list to string + for (i = 0; i < input_text_length; i++) { + text_string[i] = outtext[i]; + } + SDL_SendKeyboardText((const char *) text_string); +} +void PSP_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +{ + return false; +} + +#endif // SDL_VIDEO_DRIVER_PSP diff --git a/contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.h b/contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.h new file mode 100644 index 0000000..971f442 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/psp/SDL_pspvideo.h @@ -0,0 +1,81 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_pspvideo_h_ +#define SDL_pspvideo_h_ + +#include + +#include "SDL_internal.h" +#include "../SDL_sysvideo.h" + +struct SDL_VideoData +{ + bool egl_initialized; // OpenGL ES device initialization status + uint32_t egl_refcount; // OpenGL ES reference count + +}; + +struct SDL_WindowData +{ + bool uses_gles; // if true window must support OpenGL ES + +}; + +/****************************************************************************/ +// SDL_VideoDevice functions declaration +/****************************************************************************/ + +// Display and window functions +extern bool PSP_VideoInit(SDL_VideoDevice *_this); +extern void PSP_VideoQuit(SDL_VideoDevice *_this); +extern bool PSP_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool PSP_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern bool PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void PSP_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool PSP_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void PSP_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +// OpenGL/OpenGL ES functions +extern bool PSP_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_FunctionPointer PSP_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern void PSP_GL_UnloadLibrary(SDL_VideoDevice *_this); +extern SDL_GLContext PSP_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool PSP_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool PSP_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool PSP_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern bool PSP_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool PSP_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); + +// PSP on screen keyboard +extern bool PSP_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern void PSP_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern void PSP_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); +extern bool PSP_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_pspvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/qnx/SDL_qnx.h b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnx.h new file mode 100644 index 0000000..f8a50cf --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnx.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2017 BlackBerry Limited + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef __SDL_QNX_H__ +#define __SDL_QNX_H__ + +#include "../SDL_sysvideo.h" +#include +#include + +typedef struct +{ + screen_window_t window; + EGLSurface surface; + EGLConfig conf; +} window_impl_t; + +extern void handleKeyboardEvent(screen_event_t event); + +extern bool glGetConfig(EGLConfig *pconf, int *pformat); +extern bool glLoadLibrary(SDL_VideoDevice *_this, const char *name); +extern SDL_FunctionPointer glGetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern SDL_GLContext glCreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool glSetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool glSwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool glMakeCurrent(SDL_VideoDevice *_this, SDL_Window * window, SDL_GLContext context); +extern void glDeleteContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern void glUnloadLibrary(SDL_VideoDevice *_this); + +#endif diff --git a/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxgl.c b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxgl.c new file mode 100644 index 0000000..639e556 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxgl.c @@ -0,0 +1,277 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2017 BlackBerry Limited + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" +#include "SDL_qnx.h" + +static EGLDisplay egl_disp; + +/** + * Detertmines the pixel format to use based on the current display and EGL + * configuration. + * @param egl_conf EGL configuration to use + * @return A SCREEN_FORMAT* constant for the pixel format to use + */ +static int chooseFormat(EGLConfig egl_conf) +{ + EGLint buffer_bit_depth; + EGLint alpha_bit_depth; + + eglGetConfigAttrib(egl_disp, egl_conf, EGL_BUFFER_SIZE, &buffer_bit_depth); + eglGetConfigAttrib(egl_disp, egl_conf, EGL_ALPHA_SIZE, &alpha_bit_depth); + + switch (buffer_bit_depth) { + case 32: + return SCREEN_FORMAT_RGBX8888; + case 24: + return SDL_PIXELFORMAT_RGB24; + case 16: + switch (alpha_bit_depth) { + case 4: + return SCREEN_FORMAT_RGBX4444; + case 1: + return SCREEN_FORMAT_RGBA5551; + default: + return SCREEN_FORMAT_RGB565; + } + default: + return 0; + } +} + +/** + * Enumerates the supported EGL configurations and chooses a suitable one. + * @param[out] pconf The chosen configuration + * @param[out] pformat The chosen pixel format + * @return true if successful, -1 on error + */ +bool glGetConfig(EGLConfig *pconf, int *pformat) +{ + EGLConfig egl_conf = (EGLConfig)0; + EGLConfig *egl_configs; + EGLint egl_num_configs; + EGLint val; + EGLBoolean rc; + EGLint i; + + // Determine the numbfer of configurations. + rc = eglGetConfigs(egl_disp, NULL, 0, &egl_num_configs); + if (rc != EGL_TRUE) { + return false; + } + + if (egl_num_configs == 0) { + return false; + } + + // Allocate enough memory for all configurations. + egl_configs = SDL_malloc(egl_num_configs * sizeof(*egl_configs)); + if (!egl_configs) { + return false; + } + + // Get the list of configurations. + rc = eglGetConfigs(egl_disp, egl_configs, egl_num_configs, + &egl_num_configs); + if (rc != EGL_TRUE) { + SDL_free(egl_configs); + return false; + } + + // Find a good configuration. + for (i = 0; i < egl_num_configs; i++) { + eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_SURFACE_TYPE, &val); + if (!(val & EGL_WINDOW_BIT)) { + continue; + } + + eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_RENDERABLE_TYPE, &val); + if (!(val & EGL_OPENGL_ES2_BIT)) { + continue; + } + + eglGetConfigAttrib(egl_disp, egl_configs[i], EGL_DEPTH_SIZE, &val); + if (val == 0) { + continue; + } + + egl_conf = egl_configs[i]; + break; + } + + SDL_free(egl_configs); + *pconf = egl_conf; + *pformat = chooseFormat(egl_conf); + + return true; +} + +/** + * Initializes the EGL library. + * @param SDL_VideoDevice *_this + * @param name unused + * @return 0 if successful, -1 on error + */ +bool glLoadLibrary(SDL_VideoDevice *_this, const char *name) +{ + EGLNativeDisplayType disp_id = EGL_DEFAULT_DISPLAY; + + egl_disp = eglGetDisplay(disp_id); + if (egl_disp == EGL_NO_DISPLAY) { + return false; + } + + if (eglInitialize(egl_disp, NULL, NULL) == EGL_FALSE) { + return false; + } + + return true; +} + +/** + * Finds the address of an EGL extension function. + * @param proc Function name + * @return Function address + */ +SDL_FunctionPointer glGetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + return eglGetProcAddress(proc); +} + +/** + * Associates the given window with the necessary EGL structures for drawing and + * displaying content. + * @param SDL_VideoDevice *_this + * @param window The SDL window to create the context for + * @return A pointer to the created context, if successful, NULL on error + */ +SDL_GLContext glCreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + window_impl_t *impl = (window_impl_t *)window->internal; + EGLContext context; + EGLSurface surface; + + struct { + EGLint client_version[2]; + EGLint none; + } egl_ctx_attr = { + .client_version = { EGL_CONTEXT_CLIENT_VERSION, 2 }, + .none = EGL_NONE + }; + + struct { + EGLint render_buffer[2]; + EGLint none; + } egl_surf_attr = { + .render_buffer = { EGL_RENDER_BUFFER, EGL_BACK_BUFFER }, + .none = EGL_NONE + }; + + context = eglCreateContext(egl_disp, impl->conf, EGL_NO_CONTEXT, + (EGLint *)&egl_ctx_attr); + if (context == EGL_NO_CONTEXT) { + return NULL; + } + + surface = eglCreateWindowSurface(egl_disp, impl->conf, + (EGLNativeWindowType)impl->window, + (EGLint *)&egl_surf_attr); + if (surface == EGL_NO_SURFACE) { + return NULL; + } + + eglMakeCurrent(egl_disp, surface, surface, context); + + impl->surface = surface; + return context; +} + +/** + * Sets a new value for the number of frames to display before swapping buffers. + * @param SDL_VideoDevice *_this + * @param interval New interval value + * @return 0 if successful, -1 on error + */ +bool glSetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + if (eglSwapInterval(egl_disp, interval) != EGL_TRUE) { + return false; + } + + return true; +} + +/** + * Swaps the EGL buffers associated with the given window + * @param SDL_VideoDevice *_this + * @param window Window to swap buffers for + * @return 0 if successful, -1 on error + */ +bool glSwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + // !!! FIXME: should we migrate this all over to use SDL_egl.c? + window_impl_t *impl = (window_impl_t *)window->internal; + return eglSwapBuffers(egl_disp, impl->surface) == EGL_TRUE ? 0 : -1; +} + +/** + * Makes the given context the current one for drawing operations. + * @param SDL_VideoDevice *_this + * @param window SDL window associated with the context (maybe NULL) + * @param context The context to activate + * @return 0 if successful, -1 on error + */ +bool glMakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + window_impl_t *impl; + EGLSurface surface = NULL; + + if (window) { + impl = (window_impl_t *)window->internal; + surface = impl->surface; + } + + if (eglMakeCurrent(egl_disp, surface, surface, context) != EGL_TRUE) { + return false; + } + + return true; +} + +/** + * Destroys a context. + * @param SDL_VideoDevice *_this + * @param context The context to destroy + */ +bool glDeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + eglDestroyContext(egl_disp, context); + return true; +} + +/** + * Terminates access to the EGL library. + * @param SDL_VideoDevice *_this + */ +void glUnloadLibrary(SDL_VideoDevice *_this) +{ + eglTerminate(egl_disp); +} diff --git a/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxkeyboard.c b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxkeyboard.c new file mode 100644 index 0000000..b224caa --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxkeyboard.c @@ -0,0 +1,132 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2017 BlackBerry Limited + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "../../SDL_internal.h" +#include "../../events/SDL_keyboard_c.h" +#include "SDL3/SDL_scancode.h" +#include "SDL3/SDL_events.h" +#include "SDL_qnx.h" +#include + +/** + * A map that translates Screen key names to SDL scan codes. + * This map is incomplete, but should include most major keys. + */ +static int key_to_sdl[] = { + [KEYCODE_SPACE] = SDL_SCANCODE_SPACE, + [KEYCODE_APOSTROPHE] = SDL_SCANCODE_APOSTROPHE, + [KEYCODE_COMMA] = SDL_SCANCODE_COMMA, + [KEYCODE_MINUS] = SDL_SCANCODE_MINUS, + [KEYCODE_PERIOD] = SDL_SCANCODE_PERIOD, + [KEYCODE_SLASH] = SDL_SCANCODE_SLASH, + [KEYCODE_ZERO] = SDL_SCANCODE_0, + [KEYCODE_ONE] = SDL_SCANCODE_1, + [KEYCODE_TWO] = SDL_SCANCODE_2, + [KEYCODE_THREE] = SDL_SCANCODE_3, + [KEYCODE_FOUR] = SDL_SCANCODE_4, + [KEYCODE_FIVE] = SDL_SCANCODE_5, + [KEYCODE_SIX] = SDL_SCANCODE_6, + [KEYCODE_SEVEN] = SDL_SCANCODE_7, + [KEYCODE_EIGHT] = SDL_SCANCODE_8, + [KEYCODE_NINE] = SDL_SCANCODE_9, + [KEYCODE_SEMICOLON] = SDL_SCANCODE_SEMICOLON, + [KEYCODE_EQUAL] = SDL_SCANCODE_EQUALS, + [KEYCODE_LEFT_BRACKET] = SDL_SCANCODE_LEFTBRACKET, + [KEYCODE_BACK_SLASH] = SDL_SCANCODE_BACKSLASH, + [KEYCODE_RIGHT_BRACKET] = SDL_SCANCODE_RIGHTBRACKET, + [KEYCODE_GRAVE] = SDL_SCANCODE_GRAVE, + [KEYCODE_A] = SDL_SCANCODE_A, + [KEYCODE_B] = SDL_SCANCODE_B, + [KEYCODE_C] = SDL_SCANCODE_C, + [KEYCODE_D] = SDL_SCANCODE_D, + [KEYCODE_E] = SDL_SCANCODE_E, + [KEYCODE_F] = SDL_SCANCODE_F, + [KEYCODE_G] = SDL_SCANCODE_G, + [KEYCODE_H] = SDL_SCANCODE_H, + [KEYCODE_I] = SDL_SCANCODE_I, + [KEYCODE_J] = SDL_SCANCODE_J, + [KEYCODE_K] = SDL_SCANCODE_K, + [KEYCODE_L] = SDL_SCANCODE_L, + [KEYCODE_M] = SDL_SCANCODE_M, + [KEYCODE_N] = SDL_SCANCODE_N, + [KEYCODE_O] = SDL_SCANCODE_O, + [KEYCODE_P] = SDL_SCANCODE_P, + [KEYCODE_Q] = SDL_SCANCODE_Q, + [KEYCODE_R] = SDL_SCANCODE_R, + [KEYCODE_S] = SDL_SCANCODE_S, + [KEYCODE_T] = SDL_SCANCODE_T, + [KEYCODE_U] = SDL_SCANCODE_U, + [KEYCODE_V] = SDL_SCANCODE_V, + [KEYCODE_W] = SDL_SCANCODE_W, + [KEYCODE_X] = SDL_SCANCODE_X, + [KEYCODE_Y] = SDL_SCANCODE_Y, + [KEYCODE_Z] = SDL_SCANCODE_Z, + [KEYCODE_UP] = SDL_SCANCODE_UP, + [KEYCODE_DOWN] = SDL_SCANCODE_DOWN, + [KEYCODE_LEFT] = SDL_SCANCODE_LEFT, + [KEYCODE_PG_UP] = SDL_SCANCODE_PAGEUP, + [KEYCODE_PG_DOWN] = SDL_SCANCODE_PAGEDOWN, + [KEYCODE_RIGHT] = SDL_SCANCODE_RIGHT, + [KEYCODE_RETURN] = SDL_SCANCODE_RETURN, + [KEYCODE_TAB] = SDL_SCANCODE_TAB, + [KEYCODE_ESCAPE] = SDL_SCANCODE_ESCAPE, +}; + +/** + * Called from the event dispatcher when a keyboard event is encountered. + * Translates the event such that it can be handled by SDL. + * @param event Screen keyboard event + */ +void handleKeyboardEvent(screen_event_t event) +{ + int val; + SDL_Scancode scancode; + + // Get the key value. + if (screen_get_event_property_iv(event, SCREEN_PROPERTY_SYM, &val) < 0) { + return; + } + + // Skip unrecognized keys. + if ((val < 0) || (val >= SDL_arraysize(key_to_sdl))) { + return; + } + + // Translate to an SDL scan code. + scancode = key_to_sdl[val]; + if (scancode == 0) { + return; + } + + // Get event flags (key state). + if (screen_get_event_property_iv(event, SCREEN_PROPERTY_FLAGS, &val) < 0) { + return; + } + + // Propagate the event to SDL. + // FIXME: + // Need to handle more key states (such as key combinations). + if (val & KEY_DOWN) { + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, val, scancode, true); + } else { + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, val, scancode, false); + } +} diff --git a/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxvideo.c b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxvideo.c new file mode 100644 index 0000000..4192cdb --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/qnx/SDL_qnxvideo.c @@ -0,0 +1,351 @@ +/* + Simple DirectMedia Layer + Copyright (C) 2017 BlackBerry Limited + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" +#include "../SDL_sysvideo.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "SDL_qnx.h" + +static screen_context_t context; +static screen_event_t event; + +/** + * Initializes the QNX video plugin. + * Creates the Screen context and event handles used for all window operations + * by the plugin. + * @param SDL_VideoDevice *_this + * @return 0 if successful, -1 on error + */ +static bool videoInit(SDL_VideoDevice *_this) +{ + SDL_VideoDisplay display; + + if (screen_create_context(&context, 0) < 0) { + return false; + } + + if (screen_create_event(&event) < 0) { + return false; + } + + SDL_zero(display); + + if (SDL_AddVideoDisplay(&display, false) == 0) { + return false; + } + + // Assume we have a mouse and keyboard + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); + + return true; +} + +static void videoQuit(SDL_VideoDevice *_this) +{ +} + +/** + * Creates a new native Screen window and associates it with the given SDL + * window. + * @param SDL_VideoDevice *_this + * @param window SDL window to initialize + * @return 0 if successful, -1 on error + */ +static bool createWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + window_impl_t *impl; + int size[2]; + int numbufs; + int format; + int usage; + + impl = SDL_calloc(1, sizeof(*impl)); + if (!impl) { + return false; + } + + // Create a native window. + if (screen_create_window(&impl->window, context) < 0) { + goto fail; + } + + // Set the native window's size to match the SDL window. + size[0] = window->w; + size[1] = window->h; + + if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE, + size) < 0) { + goto fail; + } + + if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE, + size) < 0) { + goto fail; + } + + // Create window buffer(s). + if (window->flags & SDL_WINDOW_OPENGL) { + if (glGetConfig(&impl->conf, &format) < 0) { + goto fail; + } + numbufs = 2; + + usage = SCREEN_USAGE_OPENGL_ES2; + if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_USAGE, + &usage) < 0) { + return false; + } + } else { + format = SCREEN_FORMAT_RGBX8888; + numbufs = 1; + } + + // Set pixel format. + if (screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_FORMAT, + &format) < 0) { + goto fail; + } + + // Create buffer(s). + if (screen_create_window_buffers(impl->window, numbufs) < 0) { + goto fail; + } + + window->internal = impl; + return true; + +fail: + if (impl->window) { + screen_destroy_window(impl->window); + } + + SDL_free(impl); + return false; +} + +/** + * Gets a pointer to the Screen buffer associated with the given window. Note + * that the buffer is actually created in createWindow(). + * @param SDL_VideoDevice *_this + * @param window SDL window to get the buffer for + * @param[out] pixles Holds a pointer to the window's buffer + * @param[out] format Holds the pixel format for the buffer + * @param[out] pitch Holds the number of bytes per line + * @return 0 if successful, -1 on error + */ +static bool createWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, SDL_PixelFormat * format, + void ** pixels, int *pitch) +{ + window_impl_t *impl = (window_impl_t *)window->internal; + screen_buffer_t buffer; + + // Get a pointer to the buffer's memory. + if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS, + (void **)&buffer) < 0) { + return false; + } + + if (screen_get_buffer_property_pv(buffer, SCREEN_PROPERTY_POINTER, + pixels) < 0) { + return false; + } + + // Set format and pitch. + if (screen_get_buffer_property_iv(buffer, SCREEN_PROPERTY_STRIDE, + pitch) < 0) { + return false; + } + + *format = SDL_PIXELFORMAT_XRGB8888; + return true; +} + +/** + * Informs the window manager that the window needs to be updated. + * @param SDL_VideoDevice *_this + * @param window The window to update + * @param rects An array of reectangular areas to update + * @param numrects Rect array length + * @return 0 if successful, -1 on error + */ +static bool updateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, + int numrects) +{ + window_impl_t *impl = (window_impl_t *)window->internal; + screen_buffer_t buffer; + + if (screen_get_window_property_pv(impl->window, SCREEN_PROPERTY_BUFFERS, + (void **)&buffer) < 0) { + return false; + } + + screen_post_window(impl->window, buffer, numrects, (int *)rects, 0); + screen_flush_context(context, 0); + return true; +} + +/** + * Runs the main event loop. + * @param SDL_VideoDevice *_this + */ +static void pumpEvents(SDL_VideoDevice *_this) +{ + int type; + + for (;;) { + if (screen_get_event(context, event, 0) < 0) { + break; + } + + if (screen_get_event_property_iv(event, SCREEN_PROPERTY_TYPE, &type) + < 0) { + break; + } + + if (type == SCREEN_EVENT_NONE) { + break; + } + + switch (type) { + case SCREEN_EVENT_KEYBOARD: + handleKeyboardEvent(event); + break; + + default: + break; + } + } +} + +/** + * Updates the size of the native window using the geometry of the SDL window. + * @param SDL_VideoDevice *_this + * @param window SDL window to update + */ +static void setWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + window_impl_t *impl = (window_impl_t *)window->internal; + int size[2]; + + size[0] = window->pending.w; + size[1] = window->pending.h; + + screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SIZE, size); + screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_SOURCE_SIZE, size); +} + +/** + * Makes the native window associated with the given SDL window visible. + * @param SDL_VideoDevice *_this + * @param window SDL window to update + */ +static void showWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + window_impl_t *impl = (window_impl_t *)window->internal; + const int visible = 1; + + screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE, + &visible); +} + +/** + * Makes the native window associated with the given SDL window invisible. + * @param SDL_VideoDevice *_this + * @param window SDL window to update + */ +static void hideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + window_impl_t *impl = (window_impl_t *)window->internal; + const int visible = 0; + + screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE, + &visible); +} + +/** + * Destroys the native window associated with the given SDL window. + * @param SDL_VideoDevice *_this + * @param window SDL window that is being destroyed + */ +static void destroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + window_impl_t *impl = (window_impl_t *)window->internal; + + if (impl) { + screen_destroy_window(impl->window); + window->internal = NULL; + } +} + +/** + * Frees the plugin object created by createDevice(). + * @param device Plugin object to free + */ +static void deleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device); +} + +/** + * Creates the QNX video plugin used by SDL. + * @return Initialized device if successful, NULL otherwise + */ +static SDL_VideoDevice *createDevice(void) +{ + SDL_VideoDevice *device; + + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + device->internal = NULL; + device->VideoInit = videoInit; + device->VideoQuit = videoQuit; + device->CreateSDLWindow = createWindow; + device->CreateWindowFramebuffer = createWindowFramebuffer; + device->UpdateWindowFramebuffer = updateWindowFramebuffer; + device->SetWindowSize = setWindowSize; + device->ShowWindow = showWindow; + device->HideWindow = hideWindow; + device->PumpEvents = pumpEvents; + device->DestroyWindow = destroyWindow; + + device->GL_LoadLibrary = glLoadLibrary; + device->GL_GetProcAddress = glGetProcAddress; + device->GL_CreateContext = glCreateContext; + device->GL_SetSwapInterval = glSetSwapInterval; + device->GL_SwapWindow = glSwapWindow; + device->GL_MakeCurrent = glMakeCurrent; + device->GL_DestroyContext = glDeleteContext; + device->GL_UnloadLibrary = glUnloadLibrary; + + device->free = deleteDevice; + return device; +} + +VideoBootStrap QNX_bootstrap = { + "qnx", "QNX Screen", + createDevice, + NULL, // no ShowMessageBox implementation + false +}; diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents.c b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents.c new file mode 100644 index 0000000..bb4f49d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents.c @@ -0,0 +1,43 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RPI + +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../SDL_sysvideo.h" +#include "SDL_rpivideo.h" +#include "SDL_rpievents_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../core/linux/SDL_evdev.h" +#endif + +void RPI_PumpEvents(SDL_VideoDevice *_this) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Poll(); +#endif +} + +#endif // SDL_VIDEO_DRIVER_RPI diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents_c.h b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents_c.h new file mode 100644 index 0000000..6aceae6 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpievents_c.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_rpievents_c_h_ +#define SDL_rpievents_c_h_ + +#include "SDL_rpivideo.h" + +void RPI_PumpEvents(SDL_VideoDevice *_this); + +#endif // SDL_rpievents_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.c b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.c new file mode 100644 index 0000000..925b734 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.c @@ -0,0 +1,314 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RPI + +#include "SDL_rpivideo.h" +#include "SDL_rpimouse.h" + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/default_cursor.h" + +// Copied from vc_vchi_dispmanx.h which is bugged and tries to include a non existing file +// Attributes changes flag mask +#define ELEMENT_CHANGE_LAYER (1 << 0) +#define ELEMENT_CHANGE_OPACITY (1 << 1) +#define ELEMENT_CHANGE_DEST_RECT (1 << 2) +#define ELEMENT_CHANGE_SRC_RECT (1 << 3) +#define ELEMENT_CHANGE_MASK_RESOURCE (1 << 4) +#define ELEMENT_CHANGE_TRANSFORM (1 << 5) +// End copied from vc_vchi_dispmanx.h + +static SDL_Cursor *RPI_CreateDefaultCursor(void); +static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y); +static bool RPI_ShowCursor(SDL_Cursor *cursor); +static bool RPI_MoveCursor(SDL_Cursor *cursor); +static void RPI_FreeCursor(SDL_Cursor *cursor); + +static SDL_Cursor *global_cursor; + +static SDL_Cursor *RPI_CreateDefaultCursor(void) +{ + return SDL_CreateCursor(default_cdata, default_cmask, DEFAULT_CWIDTH, DEFAULT_CHEIGHT, DEFAULT_CHOTX, DEFAULT_CHOTY); +} + +// Create a cursor from a surface +static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + int rc; + SDL_CursorData *curdata; + SDL_Cursor *cursor; + VC_RECT_T dst_rect; + Uint32 dummy; + + SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + + cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); + if (!cursor) { + return NULL; + } + curdata = (SDL_CursorData *)SDL_calloc(1, sizeof(*curdata)); + if (!curdata) { + SDL_free(cursor); + return NULL; + } + + curdata->hot_x = hot_x; + curdata->hot_y = hot_y; + curdata->w = surface->w; + curdata->h = surface->h; + + // This usage is inspired by Wayland/Weston RPI code, how they figured this out is anyone's guess + curdata->resource = vc_dispmanx_resource_create(VC_IMAGE_ARGB8888, surface->w | (surface->pitch << 16), surface->h | (surface->h << 16), &dummy); + SDL_assert(curdata->resource); + vc_dispmanx_rect_set(&dst_rect, 0, 0, curdata->w, curdata->h); + /* A note from Weston: + * vc_dispmanx_resource_write_data() ignores ifmt, + * rect.x, rect.width, and uses stride only for computing + * the size of the transfer as rect.height * stride. + * Therefore we can only write rows starting at x=0. + */ + rc = vc_dispmanx_resource_write_data(curdata->resource, VC_IMAGE_ARGB8888, surface->pitch, surface->pixels, &dst_rect); + SDL_assert(rc == DISPMANX_SUCCESS); + + cursor->internal = curdata; + + return cursor; +} + +// Show the specified cursor, or hide if cursor is NULL +static bool RPI_ShowCursor(SDL_Cursor *cursor) +{ + int rc; + DISPMANX_UPDATE_HANDLE_T update; + SDL_CursorData *curdata; + VC_RECT_T src_rect, dst_rect; + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_DisplayData *data; + VC_DISPMANX_ALPHA_T alpha = { DISPMANX_FLAGS_ALPHA_FROM_SOURCE /* flags */, 255 /*opacity 0->255*/, 0 /* mask */ }; + uint32_t layer = SDL_RPI_MOUSELAYER; + const char *hint; + + if (cursor != global_cursor) { + if (global_cursor) { + curdata = global_cursor->internal; + if (curdata && curdata->element > DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start(0); + SDL_assert(update); + rc = vc_dispmanx_element_remove(update, curdata->element); + SDL_assert(rc == DISPMANX_SUCCESS); + rc = vc_dispmanx_update_submit_sync(update); + SDL_assert(rc == DISPMANX_SUCCESS); + curdata->element = DISPMANX_NO_HANDLE; + } + } + global_cursor = cursor; + } + + if (!cursor) { + return true; + } + + curdata = cursor->internal; + if (!curdata) { + return false; + } + + if (!mouse->focus) { + return false; + } + + data = SDL_GetDisplayDriverDataForWindow(mouse->focus); + if (!data) { + return false; + } + + if (curdata->element == DISPMANX_NO_HANDLE) { + vc_dispmanx_rect_set(&src_rect, 0, 0, curdata->w << 16, curdata->h << 16); + vc_dispmanx_rect_set(&dst_rect, mouse->x - curdata->hot_x, mouse->y - curdata->hot_y, curdata->w, curdata->h); + + update = vc_dispmanx_update_start(0); + SDL_assert(update); + + hint = SDL_GetHint(SDL_HINT_RPI_VIDEO_LAYER); + if (hint) { + layer = SDL_atoi(hint) + 1; + } + + curdata->element = vc_dispmanx_element_add(update, + data->dispman_display, + layer, + &dst_rect, + curdata->resource, + &src_rect, + DISPMANX_PROTECTION_NONE, + &alpha, + DISPMANX_NO_HANDLE, // clamp + DISPMANX_NO_ROTATE); + SDL_assert(curdata->element > DISPMANX_NO_HANDLE); + rc = vc_dispmanx_update_submit_sync(update); + SDL_assert(rc == DISPMANX_SUCCESS); + } + + return true; +} + +// Free a window manager cursor +static void RPI_FreeCursor(SDL_Cursor *cursor) +{ + int rc; + DISPMANX_UPDATE_HANDLE_T update; + SDL_CursorData *curdata; + + if (cursor) { + curdata = cursor->internal; + + if (curdata) { + if (curdata->element != DISPMANX_NO_HANDLE) { + update = vc_dispmanx_update_start(0); + SDL_assert(update); + rc = vc_dispmanx_element_remove(update, curdata->element); + SDL_assert(rc == DISPMANX_SUCCESS); + rc = vc_dispmanx_update_submit_sync(update); + SDL_assert(rc == DISPMANX_SUCCESS); + } + + if (curdata->resource != DISPMANX_NO_HANDLE) { + rc = vc_dispmanx_resource_delete(curdata->resource); + SDL_assert(rc == DISPMANX_SUCCESS); + } + + SDL_free(cursor->internal); + } + SDL_free(cursor); + if (cursor == global_cursor) { + global_cursor = NULL; + } + } +} + +static bool RPI_WarpMouseGlobalGraphically(float x, float y) +{ + int rc; + SDL_CursorData *curdata; + DISPMANX_UPDATE_HANDLE_T update; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + SDL_Mouse *mouse = SDL_GetMouse(); + + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->internal) { + return true; + } + + curdata = mouse->cur_cursor->internal; + if (curdata->element == DISPMANX_NO_HANDLE) { + return true; + } + + update = vc_dispmanx_update_start(0); + if (!update) { + return true; + } + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = curdata->w << 16; + src_rect.height = curdata->h << 16; + dst_rect.x = (int)x - curdata->hot_x; + dst_rect.y = (int)y - curdata->hot_y; + dst_rect.width = curdata->w; + dst_rect.height = curdata->h; + + rc = vc_dispmanx_element_change_attributes( + update, + curdata->element, + 0, + 0, + 0, + &dst_rect, + &src_rect, + DISPMANX_NO_HANDLE, + DISPMANX_NO_ROTATE); + if (rc != DISPMANX_SUCCESS) { + return SDL_SetError("vc_dispmanx_element_change_attributes() failed"); + } + + // Submit asynchronously, otherwise the performance suffers a lot + rc = vc_dispmanx_update_submit(update, 0, NULL); + if (rc != DISPMANX_SUCCESS) { + return SDL_SetError("vc_dispmanx_update_submit() failed"); + } + return true; +} + +static bool RPI_WarpMouseGlobal(float x, float y) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->internal) { + return true; + } + + // Update internal mouse position. + SDL_SendMouseMotion(0, mouse->focus, SDL_GLOBAL_MOUSE_ID, false, x, y); + + return RPI_WarpMouseGlobalGraphically(x, y); +} + +static bool RPI_WarpMouse(SDL_Window *window, float x, float y) +{ + return RPI_WarpMouseGlobal(x, y); +} + +void RPI_InitMouse(SDL_VideoDevice *_this) +{ + /* FIXME: Using UDEV it should be possible to scan all mice + * but there's no point in doing so as there's no multimice support...yet! + */ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = RPI_CreateCursor; + mouse->ShowCursor = RPI_ShowCursor; + mouse->MoveCursor = RPI_MoveCursor; + mouse->FreeCursor = RPI_FreeCursor; + mouse->WarpMouse = RPI_WarpMouse; + mouse->WarpMouseGlobal = RPI_WarpMouseGlobal; + + SDL_SetDefaultCursor(RPI_CreateDefaultCursor()); +} + +void RPI_QuitMouse(SDL_VideoDevice *_this) +{ +} + +// This is called when a mouse motion event occurs +static bool RPI_MoveCursor(SDL_Cursor *cursor) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + /* We must NOT call SDL_SendMouseMotion() on the next call or we will enter recursivity, + * so we create a version of WarpMouseGlobal without it. */ + return RPI_WarpMouseGlobalGraphically(mouse->x, mouse->y); +} + +#endif // SDL_VIDEO_DRIVER_RPI diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.h b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.h new file mode 100644 index 0000000..4b5b95c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpimouse.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_RPI_mouse_h_ +#define SDL_RPI_mouse_h_ + +#include "../SDL_sysvideo.h" + +struct SDL_CursorData +{ + DISPMANX_RESOURCE_HANDLE_T resource; + DISPMANX_ELEMENT_HANDLE_T element; + int hot_x, hot_y; + int w, h; +}; + +#define SDL_RPI_CURSORDATA(curs) RPI_CursorData *curdata = (RPI_CursorData *)((curs) ? (curs)->internal : NULL) + +extern void RPI_InitMouse(SDL_VideoDevice *_this); +extern void RPI_QuitMouse(SDL_VideoDevice *_this); + +#endif // SDL_RPI_mouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.c b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.c new file mode 100644 index 0000000..0561d8b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.c @@ -0,0 +1,65 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_RPI) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "SDL_rpivideo.h" +#include "SDL_rpiopengles.h" + +// EGL implementation of SDL OpenGL support + +void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor) +{ + *mask = SDL_GL_CONTEXT_PROFILE_ES; + *major = 2; + *minor = 0; +} + +bool RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + return SDL_EGL_LoadLibrary(_this, path, EGL_DEFAULT_DISPLAY, 0); +} + +bool RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wdata = window->internal; + + if (!(_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, wdata->egl_surface))) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "eglSwapBuffers failed."); + return true; + } + + /* Wait immediately for vsync (as if we only had two buffers), for low input-lag scenarios. + * Run your SDL program with "SDL_RPI_DOUBLE_BUFFER=1 " to enable this. */ + if (wdata->double_buffer) { + SDL_LockMutex(wdata->vsync_cond_mutex); + SDL_WaitCondition(wdata->vsync_cond, wdata->vsync_cond_mutex); + SDL_UnlockMutex(wdata->vsync_cond_mutex); + } + + return true; +} + +SDL_EGL_CreateContext_impl(RPI) +SDL_EGL_MakeCurrent_impl(RPI) + +#endif // SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.h b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.h new file mode 100644 index 0000000..f6f0396 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpiopengles.h @@ -0,0 +1,47 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_rpiopengles_h_ +#define SDL_rpiopengles_h_ + +#if defined(SDL_VIDEO_DRIVER_RPI) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +// OpenGLES functions +#define RPI_GLES_GetAttribute SDL_EGL_GetAttribute +#define RPI_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define RPI_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define RPI_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define RPI_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define RPI_GLES_DestroyContext SDL_EGL_DestroyContext + +extern bool RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_GLContext RPI_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool RPI_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern void RPI_GLES_DefaultProfileConfig(SDL_VideoDevice *_this, int *mask, int *major, int *minor); + +#endif // SDL_VIDEO_DRIVER_RPI && SDL_VIDEO_OPENGL_EGL + +#endif // SDL_rpiopengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.c b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.c new file mode 100644 index 0000000..d313f9e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.c @@ -0,0 +1,376 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RPI + +/* References + * http://elinux.org/RPi_VideoCore_APIs + * https://github.com/raspberrypi/firmware/blob/master/opt/vc/src/hello_pi/hello_triangle/triangle.c + * http://cgit.freedesktop.org/wayland/weston/tree/src/rpi-renderer.c + * http://cgit.freedesktop.org/wayland/weston/tree/src/compositor-rpi.c + */ + +// SDL internals +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../core/linux/SDL_evdev.h" +#endif + +// RPI declarations +#include "SDL_rpivideo.h" +#include "SDL_rpievents_c.h" +#include "SDL_rpiopengles.h" +#include "SDL_rpimouse.h" + +static void RPI_Destroy(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static void RPI_GetRefreshRate(int *numerator, int *denominator) +{ + TV_DISPLAY_STATE_T tvstate; + if (vc_tv_get_display_state(&tvstate) == 0) { + // The width/height parameters are in the same position in the union + // for HDMI and SDTV + HDMI_PROPERTY_PARAM_T property; + property.property = HDMI_PROPERTY_PIXEL_CLOCK_TYPE; + vc_tv_hdmi_get_property(&property); + if (property.param1 == HDMI_PIXEL_CLOCK_TYPE_NTSC) { + *numerator = tvstate.display.hdmi.frame_rate * 1000; + *denominator = 1001; + } else { + *numerator = tvstate.display.hdmi.frame_rate; + *denominator = 1; + } + return; + } + + // Failed to get display state, default to 60 + *numerator = 60; + *denominator = 1; +} + +static SDL_VideoDevice *RPI_Create(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; + + // Initialize SDL_VideoDevice structure + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Initialize internal data + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!phdata) { + SDL_free(device); + return NULL; + } + + device->internal = phdata; + + // Setup amount of available displays + device->num_displays = 0; + + // Set device free function + device->free = RPI_Destroy; + + // Setup all functions which we can handle + device->VideoInit = RPI_VideoInit; + device->VideoQuit = RPI_VideoQuit; + device->CreateSDLWindow = RPI_CreateWindow; + device->SetWindowTitle = RPI_SetWindowTitle; + device->SetWindowPosition = RPI_SetWindowPosition; + device->SetWindowSize = RPI_SetWindowSize; + device->ShowWindow = RPI_ShowWindow; + device->HideWindow = RPI_HideWindow; + device->RaiseWindow = RPI_RaiseWindow; + device->MaximizeWindow = RPI_MaximizeWindow; + device->MinimizeWindow = RPI_MinimizeWindow; + device->RestoreWindow = RPI_RestoreWindow; + device->DestroyWindow = RPI_DestroyWindow; + device->GL_LoadLibrary = RPI_GLES_LoadLibrary; + device->GL_GetProcAddress = RPI_GLES_GetProcAddress; + device->GL_UnloadLibrary = RPI_GLES_UnloadLibrary; + device->GL_CreateContext = RPI_GLES_CreateContext; + device->GL_MakeCurrent = RPI_GLES_MakeCurrent; + device->GL_SetSwapInterval = RPI_GLES_SetSwapInterval; + device->GL_GetSwapInterval = RPI_GLES_GetSwapInterval; + device->GL_SwapWindow = RPI_GLES_SwapWindow; + device->GL_DestroyContext = RPI_GLES_DestroyContext; + device->GL_DefaultProfileConfig = RPI_GLES_DefaultProfileConfig; + + device->PumpEvents = RPI_PumpEvents; + + return device; +} + +VideoBootStrap RPI_bootstrap = { + "rpi", + "RPI Video Driver", + RPI_Create, + NULL, // no ShowMessageBox implementation + false +}; + +/*****************************************************************************/ +// SDL Video and Display initialization/handling functions +/*****************************************************************************/ + +static void AddDispManXDisplay(const int display_id) +{ + DISPMANX_MODEINFO_T modeinfo; + DISPMANX_DISPLAY_HANDLE_T handle; + SDL_VideoDisplay display; + SDL_DisplayMode mode; + SDL_DisplayData *data; + + handle = vc_dispmanx_display_open(display_id); + if (!handle) { + return; // this display isn't available + } + + if (vc_dispmanx_display_get_info(handle, &modeinfo) < 0) { + vc_dispmanx_display_close(handle); + return; + } + + // RPI_GetRefreshRate() doesn't distinguish between displays. I'm not sure the hardware distinguishes either + SDL_zero(mode); + mode.w = modeinfo.width; + mode.h = modeinfo.height; + RPI_GetRefreshRate(&mode.refresh_rate_numerator, &mode.refresh_rate_denominator); + + // 32 bpp for default + mode.format = SDL_PIXELFORMAT_ABGR8888; + + SDL_zero(display); + display.desktop_mode = mode; + + // Allocate display internal data + data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); + if (!data) { + vc_dispmanx_display_close(handle); + return; // oh well + } + + data->dispman_display = handle; + + display.internal = data; + + SDL_AddVideoDisplay(&display, false); +} + +bool RPI_VideoInit(SDL_VideoDevice *_this) +{ + // Initialize BCM Host + bcm_host_init(); + + AddDispManXDisplay(DISPMANX_ID_MAIN_LCD); // your default display + AddDispManXDisplay(DISPMANX_ID_FORCE_OTHER); // an "other" display...maybe DSI-connected screen while HDMI is your main + +#ifdef SDL_INPUT_LINUXEV + if (!SDL_EVDEV_Init()) { + return false; + } +#endif + + RPI_InitMouse(_this); + + return true; +} + +void RPI_VideoQuit(SDL_VideoDevice *_this) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#endif +} + +static void RPI_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data) +{ + SDL_WindowData *wdata = (SDL_WindowData *)data; + + SDL_LockMutex(wdata->vsync_cond_mutex); + SDL_SignalCondition(wdata->vsync_cond); + SDL_UnlockMutex(wdata->vsync_cond_mutex); +} + +bool RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *wdata; + SDL_VideoDisplay *display; + SDL_DisplayData *displaydata; + VC_RECT_T dst_rect; + VC_RECT_T src_rect; + VC_DISPMANX_ALPHA_T dispman_alpha; + DISPMANX_UPDATE_HANDLE_T dispman_update; + uint32_t layer = SDL_RPI_VIDEOLAYER; + const char *env; + + // Disable alpha, otherwise the app looks composed with whatever dispman is showing (X11, console,etc) + dispman_alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; + dispman_alpha.opacity = 0xFF; + dispman_alpha.mask = 0; + + // Allocate window internal data + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!wdata) { + return false; + } + display = SDL_GetVideoDisplayForWindow(window); + displaydata = display->internal; + + // Windows have one size for now + window->w = display->desktop_mode.w; + window->h = display->desktop_mode.h; + + // OpenGL ES is the law here, buddy + window->flags |= SDL_WINDOW_OPENGL; + + // Create a dispman element and associate a window to it + dst_rect.x = 0; + dst_rect.y = 0; + dst_rect.width = window->w; + dst_rect.height = window->h; + + src_rect.x = 0; + src_rect.y = 0; + src_rect.width = window->w << 16; + src_rect.height = window->h << 16; + + env = SDL_GetHint(SDL_HINT_RPI_VIDEO_LAYER); + if (env) { + layer = SDL_atoi(env); + } + + dispman_update = vc_dispmanx_update_start(0); + wdata->dispman_window.element = vc_dispmanx_element_add(dispman_update, + displaydata->dispman_display, + layer /* layer */, + &dst_rect, + 0 /*src*/, + &src_rect, + DISPMANX_PROTECTION_NONE, + &dispman_alpha /*alpha*/, + 0 /*clamp*/, + 0 /*transform*/); + wdata->dispman_window.width = window->w; + wdata->dispman_window.height = window->h; + vc_dispmanx_update_submit_sync(dispman_update); + + if (!_this->egl_data) { + if (!SDL_GL_LoadLibrary(NULL)) { + return false; + } + } + wdata->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)&wdata->dispman_window); + + if (wdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + + // Start generating vsync callbacks if necessary + wdata->double_buffer = false; + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, false)) { + wdata->vsync_cond = SDL_CreateCondition(); + wdata->vsync_cond_mutex = SDL_CreateMutex(); + wdata->double_buffer = true; + vc_dispmanx_vsync_callback(displaydata->dispman_display, RPI_vsync_callback, (void *)wdata); + } + + // Setup driver data for this window + window->internal = wdata; + + // One window, it always has focus + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + + // Window has been successfully created + return true; +} + +void RPI_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + + if (data) { + if (data->double_buffer) { + // Wait for vsync, and then stop vsync callbacks and destroy related stuff, if needed + SDL_LockMutex(data->vsync_cond_mutex); + SDL_WaitCondition(data->vsync_cond, data->vsync_cond_mutex); + SDL_UnlockMutex(data->vsync_cond_mutex); + + vc_dispmanx_vsync_callback(displaydata->dispman_display, NULL, NULL); + + SDL_DestroyCondition(data->vsync_cond); + SDL_DestroyMutex(data->vsync_cond_mutex); + } + +#ifdef SDL_VIDEO_OPENGL_EGL + if (data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_DestroySurface(_this, data->egl_surface); + } +#endif + SDL_free(data); + window->internal = NULL; + } +} + +void RPI_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +bool RPI_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + return SDL_Unsupported(); +} +void RPI_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void RPI_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void RPI_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void RPI_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void RPI_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void RPI_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void RPI_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} + +#endif // SDL_VIDEO_DRIVER_RPI diff --git a/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.h b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.h new file mode 100644 index 0000000..c154655 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/raspberry/SDL_rpivideo.h @@ -0,0 +1,89 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_rpivideo_h +#define SDL_rpivideo_h + +#include "SDL_internal.h" +#include "../SDL_sysvideo.h" + +#include +#include + +struct SDL_VideoData +{ + uint32_t egl_refcount; // OpenGL ES reference count +}; + +struct SDL_DisplayData +{ + DISPMANX_DISPLAY_HANDLE_T dispman_display; +}; + +struct SDL_WindowData +{ + EGL_DISPMANX_WINDOW_T dispman_window; +#ifdef SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif + + // Vsync callback cond and mutex + SDL_Condition *vsync_cond; + SDL_Mutex *vsync_cond_mutex; + bool double_buffer; +}; + +#define SDL_RPI_VIDEOLAYER 10000 // High enough so to occlude everything +#define SDL_RPI_MOUSELAYER SDL_RPI_VIDEOLAYER + 1 + +/****************************************************************************/ +// SDL_VideoDevice functions declaration +/****************************************************************************/ + +// Display and window functions +extern bool RPI_VideoInit(SDL_VideoDevice *_this); +extern void RPI_VideoQuit(SDL_VideoDevice *_this); +extern bool RPI_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool RPI_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern bool RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void RPI_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool RPI_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void RPI_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +// OpenGL/OpenGL ES functions +extern bool RPI_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_FunctionPointer RPI_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern void RPI_GLES_UnloadLibrary(SDL_VideoDevice *_this); +extern SDL_GLContext RPI_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool RPI_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool RPI_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool RPI_GLES_GetSwapInterval(SDL_VideoDevice *_this); +extern bool RPI_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool RPI_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); + +#endif // SDL_rpivideo_h diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h new file mode 100644 index 0000000..85be939 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosdefs.h @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosdefs_h_ +#define SDL_riscosdefs_h_ + +typedef struct sprite_area +{ + int size; // +0 + int count; // +4 + int start; // +8 + int end; // +12 +} sprite_area; + +SDL_COMPILE_TIME_ASSERT(sprite_area, sizeof(sprite_area) == 16); + +typedef struct sprite_header +{ + int next; // +0 + char name[12]; // +4 + int width; // +16 + int height; // +20 + int first_bit; // +24 + int last_bit; // +28 + int image_offset; // +32 + int mask_offset; // +36 + int mode; // +40 +} sprite_header; + +SDL_COMPILE_TIME_ASSERT(sprite_header, sizeof(sprite_header) == 44); + +#endif // SDL_riscosdefs_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c new file mode 100644 index 0000000..367ea47 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents.c @@ -0,0 +1,177 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../../events/SDL_events_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscosevents_c.h" +#include "scancodes_riscos.h" + +#include +#include + +static SDL_Scancode SDL_RISCOS_translate_keycode(int keycode) +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + + if (keycode < SDL_arraysize(riscos_scancode_table)) { + scancode = riscos_scancode_table[keycode]; + +#ifdef DEBUG_SCANCODES + if (scancode == SDL_SCANCODE_UNKNOWN) { + SDL_Log("The key you just pressed is not recognized by SDL: %d", keycode); + } +#endif + } + + return scancode; +} + +void RISCOS_PollKeyboard(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = _this->internal; + Uint8 key = 2; + int i; + + // Check for key releases + for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { + if (internal->key_pressed[i] != 255) { + if ((_kernel_osbyte(129, internal->key_pressed[i] ^ 0xff, 0xff) & 0xff) != 255) { + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, internal->key_pressed[i], SDL_RISCOS_translate_keycode(internal->key_pressed[i]), false); + internal->key_pressed[i] = 255; + } + } + } + + // Check for key presses + while (key < 0xff) { + key = _kernel_osbyte(121, key + 1, 0) & 0xff; + switch (key) { + case 255: + // Ignore mouse keys + case 9: + case 10: + case 11: + // Ignore keys with multiple INKEY codes + case 24: + case 40: + case 71: + case 87: + break; + + default: + SDL_SendKeyboardKey(0, SDL_DEFAULT_KEYBOARD_ID, key, SDL_RISCOS_translate_keycode(key), true); + + // Record the press so we can detect release later. + for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { + if (internal->key_pressed[i] == key) { + break; + } + if (internal->key_pressed[i] == 255) { + internal->key_pressed[i] = key; + break; + } + } + } + } +} + +static const Uint8 mouse_button_map[] = { + SDL_BUTTON_RIGHT, + SDL_BUTTON_MIDDLE, + SDL_BUTTON_LEFT, + SDL_BUTTON_X1, + SDL_BUTTON_X2, + SDL_BUTTON_X2 + 1, + SDL_BUTTON_X2 + 2, + SDL_BUTTON_X2 + 3 +}; + +void RISCOS_PollMouse(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = _this->internal; + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_Rect rect; + _kernel_swi_regs regs; + int i, x, y, buttons; + + if (!SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &rect)) { + return; + } + + _kernel_swi(OS_Mouse, ®s, ®s); + x = (regs.r[0] >> 1); + y = rect.h - (regs.r[1] >> 1); + buttons = regs.r[2]; + + if (mouse->x != x || mouse->y != y) { + SDL_SendMouseMotion(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, false, (float)x, (float)y); + } + + if (internal->last_mouse_buttons != buttons) { + for (i = 0; i < SDL_arraysize(mouse_button_map); i++) { + bool down = ((buttons & (1 << i)) != 0); + SDL_SendMouseButton(0, mouse->focus, SDL_DEFAULT_MOUSE_ID, mouse_button_map[i], down); + } + internal->last_mouse_buttons = buttons; + } +} + +bool RISCOS_InitEvents(SDL_VideoDevice *_this) +{ + SDL_VideoData *internal = _this->internal; + _kernel_swi_regs regs; + int i, status; + + for (i = 0; i < RISCOS_MAX_KEYS_PRESSED; i++) { + internal->key_pressed[i] = 255; + } + + status = (_kernel_osbyte(202, 0, 255) & 0xFF); + SDL_ToggleModState(SDL_KMOD_NUM, (status & (1 << 2)) ? false : true); + SDL_ToggleModState(SDL_KMOD_CAPS, (status & (1 << 4)) ? false : true); + SDL_ToggleModState(SDL_KMOD_SCROLL, (status & (1 << 1)) ? true : false); + + _kernel_swi(OS_Mouse, ®s, ®s); + internal->last_mouse_buttons = regs.r[2]; + + // Disable escape. + _kernel_osbyte(229, 1, 0); + + return true; +} + +void RISCOS_PumpEvents(SDL_VideoDevice *_this) +{ + RISCOS_PollMouse(_this); + RISCOS_PollKeyboard(_this); +} + +void RISCOS_QuitEvents(SDL_VideoDevice *_this) +{ + // Re-enable escape. + _kernel_osbyte(229, 0, 0); +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h new file mode 100644 index 0000000..5db26fd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosevents_c.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_riscosevents_c_h_ +#define SDL_riscosevents_c_h_ + +#include "SDL_internal.h" + +#include "SDL_riscosvideo.h" + +extern bool RISCOS_InitEvents(SDL_VideoDevice *_this); +extern void RISCOS_PumpEvents(SDL_VideoDevice *_this); +extern void RISCOS_QuitEvents(SDL_VideoDevice *_this); + +#endif // SDL_riscosevents_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c new file mode 100644 index 0000000..a13cab8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer.c @@ -0,0 +1,127 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "SDL_riscosframebuffer_c.h" +#include "SDL_riscosvideo.h" +#include "SDL_riscoswindow.h" + +#include +#include + +bool RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_WindowData *internal = window->internal; + const char *sprite_name = "display"; + unsigned int sprite_mode; + _kernel_oserror *error; + _kernel_swi_regs regs; + const SDL_DisplayMode *mode; + int size; + int w, h; + + SDL_GetWindowSizeInPixels(window, &w, &h); + + // Free the old framebuffer surface + RISCOS_DestroyWindowFramebuffer(_this, window); + + // Create a new one + mode = SDL_GetCurrentDisplayMode(SDL_GetDisplayForWindow(window)); + if ((SDL_ISPIXELFORMAT_PACKED(mode->format) || SDL_ISPIXELFORMAT_ARRAY(mode->format))) { + *format = mode->format; + sprite_mode = (unsigned int)mode->internal; + } else { + *format = SDL_PIXELFORMAT_XBGR8888; + sprite_mode = (1 | (90 << 1) | (90 << 14) | (6 << 27)); + } + + // Calculate pitch + *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); + + // Allocate the sprite area + size = sizeof(sprite_area) + sizeof(sprite_header) + ((*pitch) * h); + internal->fb_area = SDL_malloc(size); + if (!internal->fb_area) { + return false; + } + + internal->fb_area->size = size; + internal->fb_area->count = 0; + internal->fb_area->start = 16; + internal->fb_area->end = 16; + + // Create the actual image + regs.r[0] = 256 + 15; + regs.r[1] = (int)internal->fb_area; + regs.r[2] = (int)sprite_name; + regs.r[3] = 0; + regs.r[4] = w; + regs.r[5] = h; + regs.r[6] = sprite_mode; + error = _kernel_swi(OS_SpriteOp, ®s, ®s); + if (error) { + SDL_free(internal->fb_area); + return SDL_SetError("Unable to create sprite: %s (%i)", error->errmess, error->errnum); + } + + internal->fb_sprite = (sprite_header *)(((Uint8 *)internal->fb_area) + internal->fb_area->start); + *pixels = ((Uint8 *)internal->fb_sprite) + internal->fb_sprite->image_offset; + + return true; +} + +bool RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_WindowData *internal = window->internal; + _kernel_swi_regs regs; + _kernel_oserror *error; + + regs.r[0] = 512 + 52; + regs.r[1] = (int)internal->fb_area; + regs.r[2] = (int)internal->fb_sprite; + regs.r[3] = 0; // window->x << 1; + regs.r[4] = 0; // window->y << 1; + regs.r[5] = 0x50; + regs.r[6] = 0; + regs.r[7] = 0; + error = _kernel_swi(OS_SpriteOp, ®s, ®s); + if (error) { + return SDL_SetError("OS_SpriteOp 52 failed: %s (%i)", error->errmess, error->errnum); + } + + return true; +} + +void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *internal = window->internal; + + if (internal->fb_area) { + SDL_free(internal->fb_area); + internal->fb_area = NULL; + } + internal->fb_sprite = NULL; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h new file mode 100644 index 0000000..ee3c847 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosframebuffer_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_riscosframebuffer_c_h_ +#define SDL_riscosframebuffer_c_h_ + +#include "SDL_internal.h" + +extern bool RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void RISCOS_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_riscosframebuffer_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c new file mode 100644 index 0000000..a4b358c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.c @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "SDL_riscosmessagebox.h" + +#include +#include + +bool RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + _kernel_swi_regs regs; + _kernel_oserror error; + char buttonstring[1024]; + int i; + + error.errnum = 0; + SDL_strlcpy(error.errmess, messageboxdata->message, 252); + regs.r[0] = (unsigned int)&error; + + regs.r[1] = (1 << 8) | (1 << 4); + if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) { + regs.r[1] |= (1 << 9); + } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) { + regs.r[1] |= (2 << 9); + } + + regs.r[2] = (unsigned int)messageboxdata->title; + regs.r[3] = 0; + regs.r[4] = 0; + + SDL_strlcpy(buttonstring, "", 1024); + for (i = 0; i < messageboxdata->numbuttons; i++) { + SDL_strlcat(buttonstring, messageboxdata->buttons[i].text, 1024); + if (i + 1 < messageboxdata->numbuttons) { + SDL_strlcat(buttonstring, ",", 1024); + } + } + regs.r[5] = (unsigned int)buttonstring; + + _kernel_swi(Wimp_ReportError, ®s, ®s); + + *buttonID = (regs.r[1] == 0) ? -1 : messageboxdata->buttons[regs.r[1] - 3].buttonID; + return true; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h new file mode 100644 index 0000000..21af02f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmessagebox.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +extern bool RISCOS_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c new file mode 100644 index 0000000..d4e9a53 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.c @@ -0,0 +1,310 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscosmodes.h" + +#include +#include + +enum +{ + MODE_FLAG_565 = 1 << 7, + + MODE_FLAG_COLOUR_SPACE = 0xF << 12, + + MODE_FLAG_TBGR = 0, + MODE_FLAG_TRGB = 1 << 14, + MODE_FLAG_ABGR = 1 << 15, + MODE_FLAG_ARGB = MODE_FLAG_TRGB | MODE_FLAG_ABGR +}; + +static const struct +{ + SDL_PixelFormat pixel_format; + int modeflags, ncolour, log2bpp; +} mode_to_pixelformat[] = { + // { SDL_PIXELFORMAT_INDEX1LSB, 0, 1, 0 }, + // { SDL_PIXELFORMAT_INDEX2LSB, 0, 3, 1 }, + // { SDL_PIXELFORMAT_INDEX4LSB, 0, 15, 2 }, + // { SDL_PIXELFORMAT_INDEX8, MODE_FLAG_565, 255, 3 }, + { SDL_PIXELFORMAT_XBGR1555, MODE_FLAG_TBGR, 65535, 4 }, + { SDL_PIXELFORMAT_XRGB1555, MODE_FLAG_TRGB, 65535, 4 }, + { SDL_PIXELFORMAT_ABGR1555, MODE_FLAG_ABGR, 65535, 4 }, + { SDL_PIXELFORMAT_ARGB1555, MODE_FLAG_ARGB, 65535, 4 }, + { SDL_PIXELFORMAT_XBGR4444, MODE_FLAG_TBGR, 4095, 4 }, + { SDL_PIXELFORMAT_XRGB4444, MODE_FLAG_TRGB, 4095, 4 }, + { SDL_PIXELFORMAT_ABGR4444, MODE_FLAG_ABGR, 4095, 4 }, + { SDL_PIXELFORMAT_ARGB4444, MODE_FLAG_ARGB, 4095, 4 }, + { SDL_PIXELFORMAT_BGR565, MODE_FLAG_TBGR | MODE_FLAG_565, 65535, 4 }, + { SDL_PIXELFORMAT_RGB565, MODE_FLAG_TRGB | MODE_FLAG_565, 65535, 4 }, + { SDL_PIXELFORMAT_BGR24, MODE_FLAG_TBGR, 16777215, 6 }, + { SDL_PIXELFORMAT_RGB24, MODE_FLAG_TRGB, 16777215, 6 }, + { SDL_PIXELFORMAT_XBGR8888, MODE_FLAG_TBGR, -1, 5 }, + { SDL_PIXELFORMAT_XRGB8888, MODE_FLAG_TRGB, -1, 5 }, + { SDL_PIXELFORMAT_ABGR8888, MODE_FLAG_ABGR, -1, 5 }, + { SDL_PIXELFORMAT_ARGB8888, MODE_FLAG_ARGB, -1, 5 } +}; + +static SDL_PixelFormat RISCOS_ModeToPixelFormat(int ncolour, int modeflags, int log2bpp) +{ + int i; + + for (i = 0; i < SDL_arraysize(mode_to_pixelformat); i++) { + if (log2bpp == mode_to_pixelformat[i].log2bpp && + (ncolour == mode_to_pixelformat[i].ncolour || ncolour == 0) && + (modeflags & (MODE_FLAG_565 | MODE_FLAG_COLOUR_SPACE)) == mode_to_pixelformat[i].modeflags) { + return mode_to_pixelformat[i].pixel_format; + } + } + + return SDL_PIXELFORMAT_UNKNOWN; +} + +static size_t measure_mode_block(const int *block) +{ + size_t blockSize = ((block[0] & 0xFF) == 3) ? 7 : 5; + while (block[blockSize] != -1) { + blockSize += 2; + } + blockSize++; + + return blockSize * 4; +} + +static bool read_mode_variable(int *block, int var) +{ + _kernel_swi_regs regs; + regs.r[0] = (int)block; + regs.r[1] = var; + _kernel_swi(OS_ReadModeVariable, ®s, ®s); + return regs.r[2]; +} + +static bool read_mode_block(int *block, SDL_DisplayMode *mode, bool extended) +{ + int xres, yres, ncolour, modeflags, log2bpp, rate; + + if ((block[0] & 0xFF) == 1) { + xres = block[1]; + yres = block[2]; + log2bpp = block[3]; + rate = block[4]; + ncolour = (1 << (1 << log2bpp)) - 1; + modeflags = MODE_FLAG_TBGR; + } else if ((block[0] & 0xFF) == 3) { + xres = block[1]; + yres = block[2]; + ncolour = block[3]; + modeflags = block[4]; + log2bpp = block[5]; + rate = block[6]; + } else { + return false; + } + + if (extended) { + xres = read_mode_variable(block, 11) + 1; + yres = read_mode_variable(block, 12) + 1; + log2bpp = read_mode_variable(block, 9); + ncolour = read_mode_variable(block, 3); + modeflags = read_mode_variable(block, 0); + } + + SDL_zerop(mode); + mode->w = xres; + mode->h = yres; + mode->format = RISCOS_ModeToPixelFormat(ncolour, modeflags, log2bpp); + mode->refresh_rate = (float)rate; + + return true; +} + +static void *convert_mode_block(const int *block) +{ + int xres, yres, log2bpp, rate, ncolour = 0, modeflags = 0; + size_t pos = 0; + int *dst; + + if ((block[0] & 0xFF) == 1) { + xres = block[1]; + yres = block[2]; + log2bpp = block[3]; + rate = block[4]; + } else if ((block[0] & 0xFF) == 3) { + xres = block[1]; + yres = block[2]; + ncolour = block[3]; + modeflags = block[4]; + log2bpp = block[5]; + rate = block[6]; + } else { + return NULL; + } + + dst = SDL_malloc(40); + if (!dst) { + return NULL; + } + + dst[pos++] = 1; + dst[pos++] = xres; + dst[pos++] = yres; + dst[pos++] = log2bpp; + dst[pos++] = rate; + if (ncolour != 0) { + dst[pos++] = 3; + dst[pos++] = ncolour; + } + if (modeflags != 0) { + dst[pos++] = 0; + dst[pos++] = modeflags; + } + dst[pos++] = -1; + + return dst; +} + +static void *copy_memory(const void *src, size_t size, size_t alloc) +{ + void *dst = SDL_malloc(alloc); + if (dst) { + SDL_memcpy(dst, src, size); + } + return dst; +} + +bool RISCOS_InitModes(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; + int *current_mode; + _kernel_swi_regs regs; + _kernel_oserror *error; + size_t size; + + regs.r[0] = 1; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + return SDL_SetError("Unable to retrieve the current screen mode: %s (%i)", error->errmess, error->errnum); + } + + current_mode = (int *)regs.r[1]; + if (!read_mode_block(current_mode, &mode, true)) { + return SDL_SetError("Unsupported mode block format %d", current_mode[0]); + } + + size = measure_mode_block(current_mode); + mode.internal = copy_memory(current_mode, size, size); + if (!mode.internal) { + return false; + } + + if (SDL_AddBasicVideoDisplay(&mode) == 0) { + return false; + } + return true; +} + +bool RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayMode mode; + _kernel_swi_regs regs; + _kernel_oserror *error; + void *block, *pos; + + regs.r[0] = 2; + regs.r[2] = 0; + regs.r[6] = 0; + regs.r[7] = 0; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); + } + + block = SDL_malloc(-regs.r[7]); + if (!block) { + return false; + } + + regs.r[6] = (int)block; + regs.r[7] = -regs.r[7]; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + SDL_free(block); + return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); + } + + for (pos = block; pos < (void *)regs.r[6]; pos += *((int *)pos)) { + if (!read_mode_block(pos + 4, &mode, false)) { + continue; + } + + if (mode.format == SDL_PIXELFORMAT_UNKNOWN) { + continue; + } + + mode.internal = convert_mode_block(pos + 4); + if (!mode.internal) { + SDL_free(block); + return false; + } + + if (!SDL_AddFullscreenDisplayMode(display, &mode)) { + SDL_free(mode.internal); + } + } + + SDL_free(block); + return true; +} + +bool RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + const char disable_cursor[] = { 23, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + _kernel_swi_regs regs; + _kernel_oserror *error; + int i; + + regs.r[0] = 0; + regs.r[1] = (int)mode->internal; + error = _kernel_swi(OS_ScreenMode, ®s, ®s); + if (error) { + return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum); + } + + // Turn the text cursor off + for (i = 0; i < SDL_arraysize(disable_cursor); i++) { + _kernel_oswrch(disable_cursor[i]); + } + + // Update cursor visibility, since it may have been disabled by the mode change. + SDL_SetCursor(NULL); + + return true; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h new file mode 100644 index 0000000..fa5d65c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmodes.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosmodes_h_ +#define SDL_riscosmodes_h_ + +extern bool RISCOS_InitModes(SDL_VideoDevice *_this); +extern bool RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); + +#endif // SDL_riscosmodes_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c new file mode 100644 index 0000000..d67e7c8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.c @@ -0,0 +1,79 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "SDL_riscosvideo.h" +#include "SDL_riscosmouse.h" +#include "../../events/SDL_mouse_c.h" + +#include + +static SDL_Cursor *RISCOS_CreateDefaultCursor(void) +{ + SDL_Cursor *cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + // NULL is used to indicate the default cursor + cursor->internal = NULL; + } + + return cursor; +} + +static void RISCOS_FreeCursor(SDL_Cursor *cursor) +{ + SDL_free(cursor); +} + +static bool RISCOS_ShowCursor(SDL_Cursor *cursor) +{ + if (cursor) { + // Turn the mouse pointer on + _kernel_osbyte(106, 1, 0); + } else { + // Turn the mouse pointer off + _kernel_osbyte(106, 0, 0); + } + + return true; +} + +bool RISCOS_InitMouse(SDL_VideoDevice *_this) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + // mouse->CreateCursor = RISCOS_CreateCursor; + // mouse->CreateSystemCursor = RISCOS_CreateSystemCursor; + mouse->ShowCursor = RISCOS_ShowCursor; + mouse->FreeCursor = RISCOS_FreeCursor; + // mouse->WarpMouse = RISCOS_WarpMouse; + // mouse->WarpMouseGlobal = RISCOS_WarpMouseGlobal; + // mouse->SetRelativeMouseMode = RISCOS_SetRelativeMouseMode; + // mouse->CaptureMouse = RISCOS_CaptureMouse; + // mouse->GetGlobalMouseState = RISCOS_GetGlobalMouseState; + + SDL_SetDefaultCursor(RISCOS_CreateDefaultCursor()); + + return true; +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h new file mode 100644 index 0000000..e28d1dc --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosmouse.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosmouse_h_ +#define SDL_riscosmouse_h_ + +extern bool RISCOS_InitMouse(SDL_VideoDevice *_this); + +#endif // SDL_riscosmouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c new file mode 100644 index 0000000..1f556d2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.c @@ -0,0 +1,130 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscosevents_c.h" +#include "SDL_riscosframebuffer_c.h" +#include "SDL_riscosmouse.h" +#include "SDL_riscosmodes.h" +#include "SDL_riscoswindow.h" +#include "SDL_riscosmessagebox.h" + +#define RISCOSVID_DRIVER_NAME "riscos" + +// Initialization/Query functions +static bool RISCOS_VideoInit(SDL_VideoDevice *_this); +static void RISCOS_VideoQuit(SDL_VideoDevice *_this); + +// RISC OS driver bootstrap functions + +static void RISCOS_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *RISCOS_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Initialize internal data + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!data) { + SDL_free(device); + return NULL; + } + + device->internal = data; + + // Set the function pointers + device->VideoInit = RISCOS_VideoInit; + device->VideoQuit = RISCOS_VideoQuit; + device->PumpEvents = RISCOS_PumpEvents; + + device->GetDisplayModes = RISCOS_GetDisplayModes; + device->SetDisplayMode = RISCOS_SetDisplayMode; + + device->CreateSDLWindow = RISCOS_CreateWindow; + device->DestroyWindow = RISCOS_DestroyWindow; + + device->CreateWindowFramebuffer = RISCOS_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = RISCOS_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = RISCOS_DestroyWindowFramebuffer; + + device->free = RISCOS_DeleteDevice; + + // TODO: Support windowed mode + device->device_caps = VIDEO_DEVICE_CAPS_FULLSCREEN_ONLY; + + return device; +} + +VideoBootStrap RISCOS_bootstrap = { + RISCOSVID_DRIVER_NAME, "SDL RISC OS video driver", + RISCOS_CreateDevice, + RISCOS_ShowMessageBox, + false +}; + +static bool RISCOS_VideoInit(SDL_VideoDevice *_this) +{ + if (!RISCOS_InitEvents(_this)) { + return false; + } + + if (!RISCOS_InitMouse(_this)) { + return false; + } + + // Assume we have a mouse and keyboard + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); + + if (!RISCOS_InitModes(_this)) { + return false; + } + + // We're done! + return true; +} + +static void RISCOS_VideoQuit(SDL_VideoDevice *_this) +{ + RISCOS_QuitEvents(_this); +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h new file mode 100644 index 0000000..f9e42ee --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscosvideo.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscosvideo_h_ +#define SDL_riscosvideo_h_ + +#include "../SDL_sysvideo.h" + +#define RISCOS_MAX_KEYS_PRESSED 6 + +struct SDL_VideoData +{ + int last_mouse_buttons; + Uint8 key_pressed[RISCOS_MAX_KEYS_PRESSED]; +}; + +#endif // SDL_riscosvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c new file mode 100644 index 0000000..cc28123 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.c @@ -0,0 +1,56 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_RISCOS + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" + +#include "SDL_riscosvideo.h" +#include "SDL_riscoswindow.h" + +bool RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *data; + + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + return false; + } + data->window = window; + + SDL_SetMouseFocus(window); + + // All done! + window->internal = data; + return true; +} + +void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (window->internal) { + SDL_free(window->internal); + window->internal = NULL; + } +} + +#endif // SDL_VIDEO_DRIVER_RISCOS diff --git a/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h new file mode 100644 index 0000000..eefec97 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/SDL_riscoswindow.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_riscoswindow_h_ +#define SDL_riscoswindow_h_ + +#include "SDL_riscosdefs.h" + +struct SDL_WindowData +{ + SDL_Window *window; + sprite_area *fb_area; + sprite_header *fb_sprite; +}; + +extern bool RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_riscoswindow_h_ diff --git a/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h b/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h new file mode 100644 index 0000000..2b99135 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/riscos/scancodes_riscos.h @@ -0,0 +1,157 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* RISC OS key code to SDL_Keycode mapping table + Sources: + - https://www.riscosopen.org/wiki/documentation/show/Keyboard Scan Codes +*/ +/* *INDENT-OFF* */ // clang-format off +static SDL_Scancode const riscos_scancode_table[] = { + /* 0 */ SDL_SCANCODE_UNKNOWN, // Shift + /* 1 */ SDL_SCANCODE_UNKNOWN, // Ctrl + /* 2 */ SDL_SCANCODE_UNKNOWN, // Alt + /* 3 */ SDL_SCANCODE_LSHIFT, + /* 4 */ SDL_SCANCODE_LCTRL, + /* 5 */ SDL_SCANCODE_LALT, + /* 6 */ SDL_SCANCODE_RSHIFT, + /* 7 */ SDL_SCANCODE_RCTRL, + /* 8 */ SDL_SCANCODE_RALT, + /* 9 */ SDL_SCANCODE_UNKNOWN, // Left mouse + /* 10 */ SDL_SCANCODE_UNKNOWN, // Center mouse + /* 11 */ SDL_SCANCODE_UNKNOWN, // Right mouse + /* 12 */ SDL_SCANCODE_UNKNOWN, + /* 13 */ SDL_SCANCODE_UNKNOWN, + /* 14 */ SDL_SCANCODE_UNKNOWN, + /* 15 */ SDL_SCANCODE_UNKNOWN, + /* 16 */ SDL_SCANCODE_Q, + /* 17 */ SDL_SCANCODE_3, + /* 18 */ SDL_SCANCODE_4, + /* 19 */ SDL_SCANCODE_5, + /* 20 */ SDL_SCANCODE_F4, + /* 21 */ SDL_SCANCODE_8, + /* 22 */ SDL_SCANCODE_F7, + /* 23 */ SDL_SCANCODE_MINUS, + /* 24 */ SDL_SCANCODE_6, // Duplicate of 52 + /* 25 */ SDL_SCANCODE_LEFT, + /* 26 */ SDL_SCANCODE_KP_6, + /* 27 */ SDL_SCANCODE_KP_7, + /* 28 */ SDL_SCANCODE_F11, + /* 29 */ SDL_SCANCODE_F12, + /* 30 */ SDL_SCANCODE_F10, + /* 31 */ SDL_SCANCODE_SCROLLLOCK, + /* 32 */ SDL_SCANCODE_PRINTSCREEN, + /* 33 */ SDL_SCANCODE_W, + /* 34 */ SDL_SCANCODE_E, + /* 35 */ SDL_SCANCODE_T, + /* 36 */ SDL_SCANCODE_7, + /* 37 */ SDL_SCANCODE_I, + /* 38 */ SDL_SCANCODE_9, + /* 39 */ SDL_SCANCODE_0, + /* 40 */ SDL_SCANCODE_MINUS, // Duplicate of 23 + /* 41 */ SDL_SCANCODE_DOWN, + /* 42 */ SDL_SCANCODE_KP_8, + /* 43 */ SDL_SCANCODE_KP_9, + /* 44 */ SDL_SCANCODE_PAUSE, + /* 45 */ SDL_SCANCODE_GRAVE, + /* 46 */ SDL_SCANCODE_CURRENCYUNIT, + /* 47 */ SDL_SCANCODE_BACKSPACE, + /* 48 */ SDL_SCANCODE_1, + /* 49 */ SDL_SCANCODE_2, + /* 50 */ SDL_SCANCODE_D, + /* 51 */ SDL_SCANCODE_R, + /* 52 */ SDL_SCANCODE_6, + /* 53 */ SDL_SCANCODE_U, + /* 54 */ SDL_SCANCODE_O, + /* 55 */ SDL_SCANCODE_P, + /* 56 */ SDL_SCANCODE_LEFTBRACKET, + /* 57 */ SDL_SCANCODE_UP, + /* 58 */ SDL_SCANCODE_KP_PLUS, + /* 59 */ SDL_SCANCODE_KP_MINUS, + /* 60 */ SDL_SCANCODE_KP_ENTER, + /* 61 */ SDL_SCANCODE_INSERT, + /* 62 */ SDL_SCANCODE_HOME, + /* 63 */ SDL_SCANCODE_PAGEUP, + /* 64 */ SDL_SCANCODE_CAPSLOCK, + /* 65 */ SDL_SCANCODE_A, + /* 66 */ SDL_SCANCODE_X, + /* 67 */ SDL_SCANCODE_F, + /* 68 */ SDL_SCANCODE_Y, + /* 69 */ SDL_SCANCODE_J, + /* 70 */ SDL_SCANCODE_K, + /* 71 */ SDL_SCANCODE_2, // Duplicate of 49 + /* 72 */ SDL_SCANCODE_SEMICOLON, // Duplicate of 87 + /* 73 */ SDL_SCANCODE_RETURN, + /* 74 */ SDL_SCANCODE_KP_DIVIDE, + /* 75 */ SDL_SCANCODE_UNKNOWN, + /* 76 */ SDL_SCANCODE_KP_PERIOD, + /* 77 */ SDL_SCANCODE_NUMLOCKCLEAR, + /* 78 */ SDL_SCANCODE_PAGEDOWN, + /* 79 */ SDL_SCANCODE_APOSTROPHE, + /* 80 */ SDL_SCANCODE_UNKNOWN, + /* 81 */ SDL_SCANCODE_S, + /* 82 */ SDL_SCANCODE_C, + /* 83 */ SDL_SCANCODE_G, + /* 84 */ SDL_SCANCODE_H, + /* 85 */ SDL_SCANCODE_N, + /* 86 */ SDL_SCANCODE_L, + /* 87 */ SDL_SCANCODE_SEMICOLON, + /* 88 */ SDL_SCANCODE_RIGHTBRACKET, + /* 89 */ SDL_SCANCODE_DELETE, + /* 90 */ SDL_SCANCODE_KP_HASH, + /* 91 */ SDL_SCANCODE_KP_MULTIPLY, + /* 92 */ SDL_SCANCODE_UNKNOWN, + /* 93 */ SDL_SCANCODE_EQUALS, + /* 94 */ SDL_SCANCODE_NONUSBACKSLASH, + /* 95 */ SDL_SCANCODE_UNKNOWN, + /* 96 */ SDL_SCANCODE_TAB, + /* 97 */ SDL_SCANCODE_Z, + /* 98 */ SDL_SCANCODE_SPACE, + /* 99 */ SDL_SCANCODE_V, + /* 100 */ SDL_SCANCODE_B, + /* 101 */ SDL_SCANCODE_M, + /* 102 */ SDL_SCANCODE_COMMA, + /* 103 */ SDL_SCANCODE_PERIOD, + /* 104 */ SDL_SCANCODE_SLASH, + /* 105 */ SDL_SCANCODE_END, + /* 106 */ SDL_SCANCODE_KP_0, + /* 107 */ SDL_SCANCODE_KP_1, + /* 108 */ SDL_SCANCODE_KP_3, + /* 109 */ SDL_SCANCODE_UNKNOWN, + /* 110 */ SDL_SCANCODE_UNKNOWN, + /* 111 */ SDL_SCANCODE_UNKNOWN, + /* 112 */ SDL_SCANCODE_ESCAPE, + /* 113 */ SDL_SCANCODE_F1, + /* 114 */ SDL_SCANCODE_F2, + /* 115 */ SDL_SCANCODE_F3, + /* 116 */ SDL_SCANCODE_F5, + /* 117 */ SDL_SCANCODE_F6, + /* 118 */ SDL_SCANCODE_F8, + /* 119 */ SDL_SCANCODE_F9, + /* 120 */ SDL_SCANCODE_BACKSLASH, + /* 121 */ SDL_SCANCODE_RIGHT, + /* 122 */ SDL_SCANCODE_KP_4, + /* 123 */ SDL_SCANCODE_KP_5, + /* 124 */ SDL_SCANCODE_KP_2, + /* 125 */ SDL_SCANCODE_LGUI, + /* 126 */ SDL_SCANCODE_RGUI, + /* 127 */ SDL_SCANCODE_MENU +}; +/* *INDENT-ON* */ // clang-format on diff --git a/contrib/SDL-3.2.8/src/video/sdlgenblit.pl b/contrib/SDL-3.2.8/src/video/sdlgenblit.pl new file mode 100755 index 0000000..47c90d5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/sdlgenblit.pl @@ -0,0 +1,736 @@ +#!/usr/bin/perl -w +# +# A script to generate optimized C blitters for Simple DirectMedia Layer +# http://www.libsdl.org/ + +use warnings; +use strict; + +my %file; + +# The formats potentially supported by this script: +# SDL_PIXELFORMAT_RGB332 +# SDL_PIXELFORMAT_XRGB4444 +# SDL_PIXELFORMAT_XRGB1555 +# SDL_PIXELFORMAT_ARGB4444 +# SDL_PIXELFORMAT_ARGB1555 +# SDL_PIXELFORMAT_RGB565 +# SDL_PIXELFORMAT_RGB24 +# SDL_PIXELFORMAT_BGR24 +# SDL_PIXELFORMAT_XRGB8888 +# SDL_PIXELFORMAT_XBGR8888 +# SDL_PIXELFORMAT_ARGB8888 +# SDL_PIXELFORMAT_RGBA8888 +# SDL_PIXELFORMAT_ABGR8888 +# SDL_PIXELFORMAT_BGRA8888 +# SDL_PIXELFORMAT_ARGB2101010 + +# The formats we're actually creating blitters for: +my @src_formats = ( + "XRGB8888", + "XBGR8888", + "ARGB8888", + "RGBA8888", + "ABGR8888", + "BGRA8888", +); +my @dst_formats = ( + "XRGB8888", + "XBGR8888", + "ARGB8888", + "ABGR8888", +); + +my %format_size = ( + "XRGB8888" => 4, + "XBGR8888" => 4, + "ARGB8888" => 4, + "RGBA8888" => 4, + "ABGR8888" => 4, + "BGRA8888" => 4, +); + +my %format_type = ( + "XRGB8888" => "Uint32", + "XBGR8888" => "Uint32", + "ARGB8888" => "Uint32", + "RGBA8888" => "Uint32", + "ABGR8888" => "Uint32", + "BGRA8888" => "Uint32", +); + +my %get_rgba_string_ignore_alpha = ( + "XRGB8888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;", + "XBGR8888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;", + "ARGB8888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;", + "RGBA8888" => "_R = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _B = (Uint8)(_pixel >> 8);", + "ABGR8888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;", + "BGRA8888" => "_B = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _R = (Uint8)(_pixel >> 8);", +); + +my %get_rgba_string = ( + "XRGB8888" => $get_rgba_string_ignore_alpha{"XRGB8888"}, + "XBGR8888" => $get_rgba_string_ignore_alpha{"XBGR8888"}, + "ARGB8888" => $get_rgba_string_ignore_alpha{"ARGB8888"} . " _A = (Uint8)(_pixel >> 24);", + "RGBA8888" => $get_rgba_string_ignore_alpha{"RGBA8888"} . " _A = (Uint8)_pixel;", + "ABGR8888" => $get_rgba_string_ignore_alpha{"ABGR8888"} . " _A = (Uint8)(_pixel >> 24);", + "BGRA8888" => $get_rgba_string_ignore_alpha{"BGRA8888"} . " _A = (Uint8)_pixel;", +); + +my %set_rgba_string = ( + "XRGB8888" => "_pixel = (_R << 16) | (_G << 8) | _B;", + "XBGR8888" => "_pixel = (_B << 16) | (_G << 8) | _R;", + "ARGB8888" => "_pixel = (_A << 24) | (_R << 16) | (_G << 8) | _B;", + "RGBA8888" => "_pixel = (_R << 24) | (_G << 16) | (_B << 8) | _A;", + "ABGR8888" => "_pixel = (_A << 24) | (_B << 16) | (_G << 8) | _R;", + "BGRA8888" => "_pixel = (_B << 24) | (_G << 16) | (_R << 8) | _A;", +); + +sub open_file { + my $name = shift; + open(FILE, ">$name.new") || die "Can't open $name.new: $!"; + print FILE <<__EOF__; +// DO NOT EDIT! This file is generated by sdlgenblit.pl +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" +#include "SDL_surface_c.h" + +#ifdef SDL_HAVE_BLIT_AUTO + +/* *INDENT-OFF* */ // clang-format off + +__EOF__ +} + +sub close_file { + my $name = shift; + print FILE <<__EOF__; +/* *INDENT-ON* */ // clang-format on + +#endif // SDL_HAVE_BLIT_AUTO + +__EOF__ + close FILE; + if ( ! -f $name || system("cmp -s $name $name.new") != 0 ) { + rename("$name.new", "$name"); + } else { + unlink("$name.new"); + } +} + +sub output_copydefs +{ + print FILE <<__EOF__; +extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[]; +__EOF__ +} + +sub output_copyfuncname +{ + my $prefix = shift; + my $src = shift; + my $dst = shift; + my $modulate = shift; + my $blend = shift; + my $scale = shift; + my $args = shift; + my $suffix = shift; + + print FILE "$prefix SDL_Blit_${src}_${dst}"; + if ( $modulate ) { + print FILE "_Modulate"; + } + if ( $blend ) { + print FILE "_Blend"; + } + if ( $scale ) { + print FILE "_Scale"; + } + if ( $args ) { + print FILE "(SDL_BlitInfo *info)"; + } + print FILE "$suffix"; +} + +sub get_rgba +{ + my $prefix = shift; + my $format = shift; + my $ignore_alpha = shift; + + my $string; + if ($ignore_alpha) { + $string = $get_rgba_string_ignore_alpha{$format}; + } else { + $string = $get_rgba_string{$format}; + } + + $string =~ s/_/$prefix/g; + if ( $prefix ne "" ) { + print FILE <<__EOF__; + ${prefix}pixel = *$prefix; +__EOF__ + } else { + print FILE <<__EOF__; + pixel = *src; +__EOF__ + } + print FILE <<__EOF__; + $string +__EOF__ +} + +sub set_rgba +{ + my $prefix = shift; + my $format = shift; + my $string = $set_rgba_string{$format}; + $string =~ s/_/$prefix/g; + print FILE <<__EOF__; + $string + *dst = ${prefix}pixel; +__EOF__ +} + +sub output_copycore +{ + my $src = shift; + my $dst = shift; + my $modulate = shift; + my $blend = shift; + my $is_modulateA_done = shift; + my $A_is_const_FF = shift; + my $s = ""; + my $d = ""; + my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0; + my $src_has_alpha = ($src =~ /A/) ? 1 : 0; + my $sa = ""; + my $da = ""; + + if (!$modulate && !$blend) { + # Nice and easy... + if ( $src eq $dst ) { + print FILE <<__EOF__; + *dst = *src; +__EOF__ + return; + } + + # Matching color-order + $sa = $src; + $sa =~ s/[XA8]//g; + $da = $dst; + $da =~ s/[XA8]//g; + if ($sa eq $da) { + if ($dst_has_alpha && $src_has_alpha) { + $da = substr $dst, 0, 1; + if ($da eq "A") { + # RGBA -> ARGB + print FILE <<__EOF__; + pixel = *src; + pixel = (pixel >> 8) | (pixel << 24); + *dst = pixel; +__EOF__ + } else { + # ARGB -> RGBA -- unused + print FILE <<__EOF__; + pixel = *src; + pixel = (pixel << 8) | A; + *dst = pixel; +__EOF__ + } + } elsif ($dst_has_alpha) { + $da = substr $dst, 0, 1; + if ($da eq "A") { + # XRGB -> ARGB + print FILE <<__EOF__; + pixel = *src; + pixel |= (A << 24); + *dst = pixel; +__EOF__ + } else { + # XRGB -> RGBA -- unused + print FILE <<__EOF__; + pixel = *src; + pixel = (pixel << 8) | A; + *dst = pixel; +__EOF__ + } + } else { + $sa = substr $src, 0, 1; + if ($sa eq "A") { + # ARGB -> XRGB + print FILE <<__EOF__; + pixel = *src; + pixel &= 0xFFFFFF; + *dst = pixel; +__EOF__ + } else { + # RGBA -> XRGB + print FILE <<__EOF__; + pixel = *src; + pixel >>= 8; + *dst = pixel; +__EOF__ + } + } + return; + } + } + + my $ignore_dst_alpha = !$dst_has_alpha && !$blend; + + if ( $blend ) { + get_rgba("src", $src, $ignore_dst_alpha); + get_rgba("dst", $dst, !$dst_has_alpha); + $s = "src"; + $d = "dst"; + } else { + get_rgba("", $src, $ignore_dst_alpha); + } + + if ( $modulate ) { + print FILE <<__EOF__; + if (flags & SDL_COPY_MODULATE_COLOR) { + MULT_DIV_255(${s}R, modulateR, ${s}R); + MULT_DIV_255(${s}G, modulateG, ${s}G); + MULT_DIV_255(${s}B, modulateB, ${s}B); + } +__EOF__ + if (!$ignore_dst_alpha && !$is_modulateA_done) { + print FILE <<__EOF__; + if (flags & SDL_COPY_MODULATE_ALPHA) { + MULT_DIV_255(${s}A, modulateA, ${s}A); + } +__EOF__ + } + } + if ( $blend ) { + if (!$A_is_const_FF) { + print FILE <<__EOF__; + if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { + if (${s}A < 255) { + MULT_DIV_255(${s}R, ${s}A, ${s}R); + MULT_DIV_255(${s}G, ${s}A, ${s}G); + MULT_DIV_255(${s}B, ${s}A, ${s}B); + } + } +__EOF__ + } + print FILE <<__EOF__; + switch (flags & SDL_COPY_BLEND_MASK) { + case SDL_COPY_BLEND: +__EOF__ + if ($A_is_const_FF) { + print FILE <<__EOF__; + ${d}R = ${s}R; + ${d}G = ${s}G; + ${d}B = ${s}B; +__EOF__ + } else { + print FILE <<__EOF__; + MULT_DIV_255((255 - ${s}A), ${d}R, ${d}R); + ${d}R += ${s}R; + MULT_DIV_255((255 - ${s}A), ${d}G, ${d}G); + ${d}G += ${s}G; + MULT_DIV_255((255 - ${s}A), ${d}B, ${d}B); + ${d}B += ${s}B; +__EOF__ + } + if ( $dst_has_alpha ) { + if ($A_is_const_FF) { + print FILE <<__EOF__; + ${d}A = 0xFF; +__EOF__ + } else { + print FILE <<__EOF__; + MULT_DIV_255((255 - ${s}A), ${d}A, ${d}A); + ${d}A += ${s}A; +__EOF__ + } + } + + print FILE <<__EOF__; + break; + case SDL_COPY_BLEND_PREMULTIPLIED: +__EOF__ + if ($A_is_const_FF) { + print FILE <<__EOF__; + ${d}R = ${s}R; + ${d}G = ${s}G; + ${d}B = ${s}B; +__EOF__ + } else { + print FILE <<__EOF__; + MULT_DIV_255((255 - ${s}A), ${d}R, ${d}R); + ${d}R += ${s}R; + if (${d}R > 255) ${d}R = 255; + MULT_DIV_255((255 - ${s}A), ${d}G, ${d}G); + ${d}G += ${s}G; + if (${d}G > 255) ${d}G = 255; + MULT_DIV_255((255 - ${s}A), ${d}B, ${d}B); + ${d}B += ${s}B; + if (${d}B > 255) ${d}B = 255; +__EOF__ + } + if ( $dst_has_alpha ) { + if ($A_is_const_FF) { + print FILE <<__EOF__; + ${d}A = 0xFF; +__EOF__ + } else { + print FILE <<__EOF__; + MULT_DIV_255((255 - ${s}A), ${d}A, ${d}A); + ${d}A += ${s}A; + if (${d}A > 255) ${d}A = 255; +__EOF__ + } + } + + print FILE <<__EOF__; + break; + case SDL_COPY_ADD: + case SDL_COPY_ADD_PREMULTIPLIED: + ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255; + ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255; + ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255; + break; + case SDL_COPY_MOD: + MULT_DIV_255(${s}R, ${d}R, ${d}R); + MULT_DIV_255(${s}G, ${d}G, ${d}G); + MULT_DIV_255(${s}B, ${d}B, ${d}B); + break; + case SDL_COPY_MUL: +__EOF__ + if ($A_is_const_FF) { + print FILE <<__EOF__; + MULT_DIV_255(${s}R, ${d}R, ${d}R); + MULT_DIV_255(${s}G, ${d}G, ${d}G); + MULT_DIV_255(${s}B, ${d}B, ${d}B); +__EOF__ + } else { + print FILE <<__EOF__; + { + Uint32 tmp1, tmp2; + + MULT_DIV_255(${s}R, ${d}R, tmp1); + MULT_DIV_255(${d}R, (255 - ${s}A), tmp2); + ${d}R = tmp1 + tmp2; if (${d}R > 255) ${d}R = 255; + MULT_DIV_255(${s}G, ${d}G, tmp1); + MULT_DIV_255(${d}G, (255 - ${s}A), tmp2); + ${d}G = tmp1 + tmp2; if (${d}G > 255) ${d}G = 255; + MULT_DIV_255(${s}B, ${d}B, tmp1); + MULT_DIV_255(${d}B, (255 - ${s}A), tmp2); + ${d}B = tmp1 + tmp2; if (${d}B > 255) ${d}B = 255; + } +__EOF__ + } + + print FILE <<__EOF__; + break; + } +__EOF__ + } + if ( $blend ) { + set_rgba("dst", $dst); + } else { + set_rgba("", $dst); + } +} + +sub output_copyfunc +{ + my $src = shift; + my $dst = shift; + my $modulate = shift; + my $blend = shift; + my $scale = shift; + + my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0; + my $ignore_dst_alpha = !$dst_has_alpha && !$blend; + + my $src_has_alpha = ($src =~ /A/) ? 1 : 0; + + my $is_modulateA_done = 0; + my $A_is_const_FF = 0; + + my $sa = $src; + my $da = $dst; + my $matching_colors = 0; + + $sa =~ s/[XA8]//g; + $da =~ s/[XA8]//g; + $matching_colors = (!$modulate && !$blend && ($sa eq $da)) ? 1 : 0; + + output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n"); + print FILE <<__EOF__; +{ +__EOF__ + if ( $modulate || $blend ) { + print FILE <<__EOF__; + const int flags = info->flags; +__EOF__ + } + if ( $modulate ) { + print FILE <<__EOF__; + const Uint32 modulateR = info->r; + const Uint32 modulateG = info->g; + const Uint32 modulateB = info->b; +__EOF__ + if (!$ignore_dst_alpha) { + print FILE <<__EOF__; + const Uint32 modulateA = info->a; +__EOF__ + } + } + if ( $blend ) { + print FILE <<__EOF__; + Uint32 srcpixel; +__EOF__ + if (!$ignore_dst_alpha && !$src_has_alpha) { + if ($modulate){ + $is_modulateA_done = 1; + print FILE <<__EOF__; + const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; +__EOF__ + } else { + $A_is_const_FF = 1; + } + print FILE <<__EOF__; + Uint32 srcR, srcG, srcB; +__EOF__ + } else { + print FILE <<__EOF__; + Uint32 srcR, srcG, srcB, srcA; +__EOF__ + } + print FILE <<__EOF__; + Uint32 dstpixel; +__EOF__ + if ($dst_has_alpha) { + print FILE <<__EOF__; + Uint32 dstR, dstG, dstB, dstA; +__EOF__ + } else { + print FILE <<__EOF__; + Uint32 dstR, dstG, dstB; +__EOF__ + } + } elsif ( $modulate || $src ne $dst ) { + print FILE <<__EOF__; + Uint32 pixel; +__EOF__ + if ( !$ignore_dst_alpha && !$src_has_alpha ) { + if ( $modulate ) { + $is_modulateA_done = 1; + print FILE <<__EOF__; + const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; +__EOF__ + } else { + $A_is_const_FF = 1; + print FILE <<__EOF__; + const Uint32 A = 0xFF; +__EOF__ + } + if ( !$matching_colors ) { + print FILE <<__EOF__; + Uint32 R, G, B; +__EOF__ + } + } elsif ( !$ignore_dst_alpha ) { + if ( !$matching_colors ) { + print FILE <<__EOF__; + Uint32 R, G, B, A; +__EOF__ + } + } elsif ( !$matching_colors ) { + print FILE <<__EOF__; + Uint32 R, G, B; +__EOF__ + } + } + if ( $scale ) { + print FILE <<__EOF__; + Uint64 srcy, srcx; + Uint64 posy, posx; + Uint64 incy, incx; +__EOF__ + + print FILE <<__EOF__; + + incy = ((Uint64)info->src_h << 16) / info->dst_h; + incx = ((Uint64)info->src_w << 16) / info->dst_w; + posy = incy / 2; + + while (info->dst_h--) { + $format_type{$src} *src = 0; + $format_type{$dst} *dst = ($format_type{$dst} *)info->dst; + int n = info->dst_w; + posx = incx / 2; + + srcy = posy >> 16; + while (n--) { + srcx = posx >> 16; + src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src})); +__EOF__ + print FILE <<__EOF__; +__EOF__ + output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); + print FILE <<__EOF__; + posx += incx; + ++dst; + } + posy += incy; + info->dst += info->dst_pitch; + } +__EOF__ + } else { + print FILE <<__EOF__; + + while (info->dst_h--) { + $format_type{$src} *src = ($format_type{$src} *)info->src; + $format_type{$dst} *dst = ($format_type{$dst} *)info->dst; + int n = info->dst_w; + while (n--) { +__EOF__ + output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); + print FILE <<__EOF__; + ++src; + ++dst; + } + info->src += info->src_pitch; + info->dst += info->dst_pitch; + } +__EOF__ + } + print FILE <<__EOF__; +} + +__EOF__ +} + +sub output_copyfunc_h +{ +} + +sub output_copyinc +{ + print FILE <<__EOF__; +#include "SDL_blit.h" +#include "SDL_blit_auto.h" + +__EOF__ +} + +sub output_copyfunctable +{ + print FILE <<__EOF__; +SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { +__EOF__ + for (my $i = 0; $i <= $#src_formats; ++$i) { + my $src = $src_formats[$i]; + for (my $j = 0; $j <= $#dst_formats; ++$j) { + my $dst = $dst_formats[$j]; + for (my $modulate = 0; $modulate <= 1; ++$modulate) { + for (my $blend = 0; $blend <= 1; ++$blend) { + for (my $scale = 0; $scale <= 1; ++$scale) { + if ( $modulate || $blend || $scale ) { + print FILE " { SDL_PIXELFORMAT_$src, SDL_PIXELFORMAT_$dst, "; + my $flags = ""; + my $flag = ""; + if ( $modulate ) { + $flag = "SDL_COPY_MODULATE_MASK"; + if ( $flags eq "" ) { + $flags = $flag; + } else { + $flags = "$flags | $flag"; + } + } + if ( $blend ) { + $flag = "SDL_COPY_BLEND_MASK"; + if ( $flags eq "" ) { + $flags = $flag; + } else { + $flags = "$flags | $flag"; + } + } + if ( $scale ) { + $flag = "SDL_COPY_NEAREST"; + if ( $flags eq "" ) { + $flags = $flag; + } else { + $flags = "$flags | $flag"; + } + } + if ( $flags eq "" ) { + $flags = "0"; + } + print FILE "($flags), SDL_CPU_ANY,"; + output_copyfuncname("", $src_formats[$i], $dst_formats[$j], $modulate, $blend, $scale, 0, " },\n"); + } + } + } + } + } + } + print FILE <<__EOF__; + { 0, 0, 0, 0, NULL } +}; + +__EOF__ +} + +sub output_copyfunc_c +{ + my $src = shift; + my $dst = shift; + + for (my $modulate = 0; $modulate <= 1; ++$modulate) { + for (my $blend = 0; $blend <= 1; ++$blend) { + for (my $scale = 0; $scale <= 1; ++$scale) { + if ( $modulate || $blend || $scale ) { + output_copyfunc($src, $dst, $modulate, $blend, $scale); + } + } + } + } +} + +open_file("SDL_blit_auto.h"); +output_copydefs(); +for (my $i = 0; $i <= $#src_formats; ++$i) { + for (my $j = 0; $j <= $#dst_formats; ++$j) { + output_copyfunc_h($src_formats[$i], $dst_formats[$j]); + } +} +print FILE "\n"; +close_file("SDL_blit_auto.h"); + +open_file("SDL_blit_auto.c"); +output_copyinc(); +for (my $i = 0; $i <= $#src_formats; ++$i) { + for (my $j = 0; $j <= $#dst_formats; ++$j) { + output_copyfunc_c($src_formats[$i], $dst_formats[$j]); + } +} +output_copyfunctable(); +close_file("SDL_blit_auto.c"); diff --git a/contrib/SDL-3.2.8/src/video/stb_image.h b/contrib/SDL-3.2.8/src/video/stb_image.h new file mode 100644 index 0000000..f22de1b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/stb_image.h @@ -0,0 +1,8252 @@ +/* stb_image - v2.30 - public domain image loader - http://nothings.org/stb + no warranty implied; use at your own risk + + Do this: + #define STB_IMAGE_IMPLEMENTATION + before you include this file in *one* C or C++ file to create the implementation. + + // i.e. it should look like this: + #include ... + #include ... + #include ... + #define STB_IMAGE_IMPLEMENTATION + #include "stb_image.h" + + You can #define STBI_ASSERT(x) before the #include to avoid using assert.h. + And #define STBI_MALLOC, STBI_REALLOC, and STBI_FREE to avoid using malloc,realloc,free + + + QUICK NOTES: + Primarily of interest to game developers and other people who can + avoid problematic images and only need the trivial interface + + JPEG baseline & progressive (12 bpc/arithmetic not supported, same as stock IJG lib) + PNG 1/2/4/8/16-bit-per-channel + + TGA (not sure what subset, if a subset) + BMP non-1bpp, non-RLE + PSD (composited view only, no extra channels, 8/16 bit-per-channel) + + GIF (*comp always reports as 4-channel) + HDR (radiance rgbE format) + PIC (Softimage PIC) + PNM (PPM and PGM binary only) + + Animated GIF still needs a proper API, but here's one way to do it: + http://gist.github.com/urraka/685d9a6340b26b830d49 + + - decode from memory or through FILE (define STBI_NO_STDIO to remove code) + - decode from arbitrary I/O callbacks + - SIMD acceleration on x86/x64 (SSE2) and ARM (NEON) + + Full documentation under "DOCUMENTATION" below. + + +LICENSE + + See end of file for license information. + +RECENT REVISION HISTORY: + + 2.30 (2024-05-31) avoid erroneous gcc warning + 2.29 (2023-05-xx) optimizations + 2.28 (2023-01-29) many error fixes, security errors, just tons of stuff + 2.27 (2021-07-11) document stbi_info better, 16-bit PNM support, bug fixes + 2.26 (2020-07-13) many minor fixes + 2.25 (2020-02-02) fix warnings + 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically + 2.23 (2019-08-11) fix clang static analysis warning + 2.22 (2019-03-04) gif fixes, fix warnings + 2.21 (2019-02-25) fix typo in comment + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs + 2.19 (2018-02-11) fix warning + 2.18 (2018-01-30) fix warnings + 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings + 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes + 2.15 (2017-03-18) fix png-1,2,4; all Imagenet JPGs; no runtime SSE detection on GCC + 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs + 2.13 (2016-12-04) experimental 16-bit API, only for PNG so far; fixes + 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes + 2.11 (2016-04-02) 16-bit PNGS; enable SSE2 in non-gcc x64 + RGB-format JPEG; remove white matting in PSD; + allocate large structures on the stack; + correct channel count for PNG & BMP + 2.10 (2016-01-22) avoid warning introduced in 2.09 + 2.09 (2016-01-16) 16-bit TGA; comments in PNM files; STBI_REALLOC_SIZED + + See end of file for full revision history. + + + ============================ Contributors ========================= + + Image formats Extensions, features + Sean Barrett (jpeg, png, bmp) Jetro Lauha (stbi_info) + Nicolas Schulz (hdr, psd) Martin "SpartanJ" Golini (stbi_info) + Jonathan Dummer (tga) James "moose2000" Brown (iPhone PNG) + Jean-Marc Lienher (gif) Ben "Disch" Wenger (io callbacks) + Tom Seddon (pic) Omar Cornut (1/2/4-bit PNG) + Thatcher Ulrich (psd) Nicolas Guillemot (vertical flip) + Ken Miller (pgm, ppm) Richard Mitton (16-bit PSD) + github:urraka (animated gif) Junggon Kim (PNM comments) + Christopher Forseth (animated gif) Daniel Gibson (16-bit TGA) + socks-the-fox (16-bit PNG) + Jeremy Sawicki (handle all ImageNet JPGs) + Optimizations & bugfixes Mikhail Morozov (1-bit BMP) + Fabian "ryg" Giesen Anael Seghezzi (is-16-bit query) + Arseny Kapoulkine Simon Breuss (16-bit PNM) + John-Mark Allen Katelyn Gadd (indexed color loading) + Carmelo J Fdez-Aguera + + Bug & warning fixes + Marc LeBlanc David Woo Guillaume George Martins Mozeiko + Christpher Lloyd Jerry Jansson Joseph Thomson Blazej Dariusz Roszkowski + Phil Jordan Dave Moore Roy Eltham + Hayaki Saito Nathan Reed Won Chun + Luke Graham Johan Duparc Nick Verigakis the Horde3D community + Thomas Ruf Ronny Chevalier github:rlyeh + Janez Zemva John Bartholomew Michal Cichon github:romigrou + Jonathan Blow Ken Hamada Tero Hanninen github:svdijk + Eugene Golushkov Laurent Gomila Cort Stratton github:snagar + Aruelien Pocheville Sergio Gonzalez Thibault Reuille github:Zelex + Cass Everitt Ryamond Barbiero github:grim210 + Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw + Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus + Josh Tobin Neil Bickford Matthew Gregan github:poppolopoppo + Julian Raschke Gregory Mullen Christian Floisand github:darealshinji + Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007 + Brad Weinberger Matvey Cherevko github:mosra + Luca Sas Alexander Veselov Zack Middleton [reserved] + Ryan C. Gordon [reserved] [reserved] + DO NOT ADD YOUR NAME HERE + + Jacko Dirks + + To add your name to the credits, pick a random blank space in the middle and fill it. + 80% of merge conflicts on stb PRs are due to people adding their name at the end + of the credits. +*/ + +#ifndef STBI_INCLUDE_STB_IMAGE_H +#define STBI_INCLUDE_STB_IMAGE_H + +// DOCUMENTATION +// +// Limitations: +// - no 12-bit-per-channel JPEG +// - no JPEGs with arithmetic coding +// - GIF always returns *comp=4 +// +// Basic usage (see HDR discussion below for HDR usage): +// int x,y,n; +// unsigned char *data = stbi_load(filename, &x, &y, &n, 0); +// // ... process data if not NULL ... +// // ... x = width, y = height, n = # 8-bit components per pixel ... +// // ... replace '0' with '1'..'4' to force that many components per pixel +// // ... but 'n' will always be the number that it would have been if you said 0 +// stbi_image_free(data); +// +// Standard parameters: +// int *x -- outputs image width in pixels +// int *y -- outputs image height in pixels +// int *channels_in_file -- outputs # of image components in image file +// int desired_channels -- if non-zero, # of image components requested in result +// +// The return value from an image loader is an 'unsigned char *' which points +// to the pixel data, or NULL on an allocation failure or if the image is +// corrupt or invalid. The pixel data consists of *y scanlines of *x pixels, +// with each pixel consisting of N interleaved 8-bit components; the first +// pixel pointed to is top-left-most in the image. There is no padding between +// image scanlines or between pixels, regardless of format. The number of +// components N is 'desired_channels' if desired_channels is non-zero, or +// *channels_in_file otherwise. If desired_channels is non-zero, +// *channels_in_file has the number of components that _would_ have been +// output otherwise. E.g. if you set desired_channels to 4, you will always +// get RGBA output, but you can check *channels_in_file to see if it's trivially +// opaque because e.g. there were only 3 channels in the source image. +// +// An output image with N components has the following components interleaved +// in this order in each pixel: +// +// N=#comp components +// 1 grey +// 2 grey, alpha +// 3 red, green, blue +// 4 red, green, blue, alpha +// +// If image loading fails for any reason, the return value will be NULL, +// and *x, *y, *channels_in_file will be unchanged. The function +// stbi_failure_reason() can be queried for an extremely brief, end-user +// unfriendly explanation of why the load failed. Define STBI_NO_FAILURE_STRINGS +// to avoid compiling these strings at all, and STBI_FAILURE_USERMSG to get slightly +// more user-friendly ones. +// +// Paletted PNG, BMP, GIF, and PIC images are automatically depalettized. +// +// To query the width, height and component count of an image without having to +// decode the full file, you can use the stbi_info family of functions: +// +// int x,y,n,ok; +// ok = stbi_info(filename, &x, &y, &n); +// // returns ok=1 and sets x, y, n if image is a supported format, +// // 0 otherwise. +// +// Note that stb_image pervasively uses ints in its public API for sizes, +// including sizes of memory buffers. This is now part of the API and thus +// hard to change without causing breakage. As a result, the various image +// loaders all have certain limits on image size; these differ somewhat +// by format but generally boil down to either just under 2GB or just under +// 1GB. When the decoded image would be larger than this, stb_image decoding +// will fail. +// +// Additionally, stb_image will reject image files that have any of their +// dimensions set to a larger value than the configurable STBI_MAX_DIMENSIONS, +// which defaults to 2**24 = 16777216 pixels. Due to the above memory limit, +// the only way to have an image with such dimensions load correctly +// is for it to have a rather extreme aspect ratio. Either way, the +// assumption here is that such larger images are likely to be malformed +// or malicious. If you do need to load an image with individual dimensions +// larger than that, and it still fits in the overall size limit, you can +// #define STBI_MAX_DIMENSIONS on your own to be something larger. +// +// =========================================================================== +// +// UNICODE: +// +// If compiling for Windows and you wish to use Unicode filenames, compile +// with +// #define STBI_WINDOWS_UTF8 +// and pass utf8-encoded filenames. Call stbi_convert_wchar_to_utf8 to convert +// Windows wchar_t filenames to utf8. +// +// =========================================================================== +// +// Philosophy +// +// stb libraries are designed with the following priorities: +// +// 1. easy to use +// 2. easy to maintain +// 3. good performance +// +// Sometimes I let "good performance" creep up in priority over "easy to maintain", +// and for best performance I may provide less-easy-to-use APIs that give higher +// performance, in addition to the easy-to-use ones. Nevertheless, it's important +// to keep in mind that from the standpoint of you, a client of this library, +// all you care about is #1 and #3, and stb libraries DO NOT emphasize #3 above all. +// +// Some secondary priorities arise directly from the first two, some of which +// provide more explicit reasons why performance can't be emphasized. +// +// - Portable ("ease of use") +// - Small source code footprint ("easy to maintain") +// - No dependencies ("ease of use") +// +// =========================================================================== +// +// I/O callbacks +// +// I/O callbacks allow you to read from arbitrary sources, like packaged +// files or some other source. Data read from callbacks are processed +// through a small internal buffer (currently 128 bytes) to try to reduce +// overhead. +// +// The three functions you must define are "read" (reads some bytes of data), +// "skip" (skips some bytes of data), "eof" (reports if the stream is at the end). +// +// =========================================================================== +// +// SIMD support +// +// The JPEG decoder will try to automatically use SIMD kernels on x86 when +// supported by the compiler. For ARM Neon support, you must explicitly +// request it. +// +// (The old do-it-yourself SIMD API is no longer supported in the current +// code.) +// +// On x86, SSE2 will automatically be used when available based on a run-time +// test; if not, the generic C versions are used as a fall-back. On ARM targets, +// the typical path is to have separate builds for NEON and non-NEON devices +// (at least this is true for iOS and Android). Therefore, the NEON support is +// toggled by a build flag: define STBI_NEON to get NEON loops. +// +// If for some reason you do not want to use any of SIMD code, or if +// you have issues compiling it, you can disable it entirely by +// defining STBI_NO_SIMD. +// +// =========================================================================== +// +// HDR image support (disable by defining STBI_NO_HDR) +// +// stb_image supports loading HDR images in general, and currently the Radiance +// .HDR file format specifically. You can still load any file through the existing +// interface; if you attempt to load an HDR file, it will be automatically remapped +// to LDR, assuming gamma 2.2 and an arbitrary scale factor defaulting to 1; +// both of these constants can be reconfigured through this interface: +// +// stbi_hdr_to_ldr_gamma(2.2f); +// stbi_hdr_to_ldr_scale(1.0f); +// +// (note, do not use _inverse_ constants; stbi_image will invert them +// appropriately). +// +// Additionally, there is a new, parallel interface for loading files as +// (linear) floats to preserve the full dynamic range: +// +// float *data = stbi_loadf(filename, &x, &y, &n, 0); +// +// If you load LDR images through this interface, those images will +// be promoted to floating point values, run through the inverse of +// constants corresponding to the above: +// +// stbi_ldr_to_hdr_scale(1.0f); +// stbi_ldr_to_hdr_gamma(2.2f); +// +// Finally, given a filename (or an open file or memory block--see header +// file for details) containing image data, you can query for the "most +// appropriate" interface to use (that is, whether the image is HDR or +// not), using: +// +// stbi_is_hdr(char *filename); +// +// =========================================================================== +// +// iPhone PNG support: +// +// We optionally support converting iPhone-formatted PNGs (which store +// premultiplied BGRA) back to RGB, even though they're internally encoded +// differently. To enable this conversion, call +// stbi_convert_iphone_png_to_rgb(1). +// +// Call stbi_set_unpremultiply_on_load(1) as well to force a divide per +// pixel to remove any premultiplied alpha *only* if the image file explicitly +// says there's premultiplied data (currently only happens in iPhone images, +// and only if iPhone convert-to-rgb processing is on). +// +// =========================================================================== +// +// ADDITIONAL CONFIGURATION +// +// - You can suppress implementation of any of the decoders to reduce +// your code footprint by #defining one or more of the following +// symbols before creating the implementation. +// +// STBI_NO_JPEG +// STBI_NO_PNG +// STBI_NO_BMP +// STBI_NO_PSD +// STBI_NO_TGA +// STBI_NO_GIF +// STBI_NO_HDR +// STBI_NO_PIC +// STBI_NO_PNM (.ppm and .pgm) +// +// - You can request *only* certain decoders and suppress all other ones +// (this will be more forward-compatible, as addition of new decoders +// doesn't require you to disable them explicitly): +// +// STBI_ONLY_JPEG +// STBI_ONLY_PNG +// STBI_ONLY_BMP +// STBI_ONLY_PSD +// STBI_ONLY_TGA +// STBI_ONLY_GIF +// STBI_ONLY_HDR +// STBI_ONLY_PIC +// STBI_ONLY_PNM (.ppm and .pgm) +// +// - If you use STBI_NO_PNG (or _ONLY_ without PNG), and you still +// want the zlib decoder to be available, #define STBI_SUPPORT_ZLIB +// +// - If you define STBI_MAX_DIMENSIONS, stb_image will reject images greater +// than that size (in either width or height) without further processing. +// This is to let programs in the wild set an upper bound to prevent +// denial-of-service attacks on untrusted data, as one could generate a +// valid image of gigantic dimensions and force stb_image to allocate a +// huge block of memory and spend disproportionate time decoding it. By +// default this is set to (1 << 24), which is 16777216, but that's still +// very big. + +#ifndef STBI_NO_STDIO +#include +#endif // STBI_NO_STDIO + +#define STBI_VERSION 1 + +enum +{ + STBI_default = 0, // only used for desired_channels + + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4 +}; + +#if 0 /* SDL change */ +#include +typedef unsigned char stbi_uc; +typedef unsigned short stbi_us; +#else +typedef Uint8 stbi_uc; +typedef Uint16 stbi_us; +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef STBIDEF +#ifdef STB_IMAGE_STATIC +#define STBIDEF static +#else +#define STBIDEF extern +#endif +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// PRIMARY API - works on images of any type +// + +// +// load image by filename, open file, or memory buffer +// + +typedef struct +{ + int (*read) (void *user,char *data,int size); // fill 'data' with 'size' bytes. return number of bytes actually read + void (*skip) (void *user,int n); // skip the next 'n' bytes, or 'unget' the last -n bytes if negative + int (*eof) (void *user); // returns nonzero if we are at end of file/data +} stbi_io_callbacks; + +//////////////////////////////////// +// +// 8-bits-per-channel interface +// + +STBIDEF stbi_uc *stbi_load_from_memory (stbi_uc const *buffer, int len , int *x, int *y, int *channels_in_file, int desired_channels); +#if 0 /* not used in SDL */ +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk , void *user, int *x, int *y, int *channels_in_file, int desired_channels); +#endif + +#ifndef STBI_NO_STDIO +STBIDEF stbi_uc *stbi_load (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_uc *stbi_load_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); +// for stbi_load_from_file, file pointer is left pointing immediately after image +#endif + +#ifndef STBI_NO_GIF +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp); +#endif + +#ifdef STBI_WINDOWS_UTF8 +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input); +#endif + +//////////////////////////////////// +// +// 8-bits-per-channel indexed color +// Will fail if image is not an 8-bit PNG or TGA with a palette. +// Palette buffer needs to be at least 256 entries for PNG. +// + +#if 0 /* not used in SDL */ +STBIDEF stbi_uc *stbi_load_from_memory_with_palette (stbi_uc const *buffer, int len , int *x, int *y, unsigned int *palette_buffer, int palette_buffer_len); +STBIDEF stbi_uc *stbi_load_from_callbacks_with_palette(stbi_io_callbacks const *clbk, void *user, int *x, int *y, unsigned int *palette_buffer, int palette_buffer_len); +#endif + +//////////////////////////////////// +// +// 16-bits-per-channel interface +// + +#if 0 /* not used in SDL */ +STBIDEF stbi_us *stbi_load_16_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); +#endif + +#ifndef STBI_NO_STDIO +STBIDEF stbi_us *stbi_load_16 (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); +STBIDEF stbi_us *stbi_load_from_file_16(FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); +#endif + +//////////////////////////////////// +// +// float-per-channel interface +// +#ifndef STBI_NO_LINEAR + STBIDEF float *stbi_loadf_from_memory (stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF float *stbi_loadf_from_callbacks (stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels); + + #ifndef STBI_NO_STDIO + STBIDEF float *stbi_loadf (char const *filename, int *x, int *y, int *channels_in_file, int desired_channels); + STBIDEF float *stbi_loadf_from_file (FILE *f, int *x, int *y, int *channels_in_file, int desired_channels); + #endif +#endif + +#ifndef STBI_NO_HDR + STBIDEF void stbi_hdr_to_ldr_gamma(float gamma); + STBIDEF void stbi_hdr_to_ldr_scale(float scale); +#endif // STBI_NO_HDR + +#ifndef STBI_NO_LINEAR + STBIDEF void stbi_ldr_to_hdr_gamma(float gamma); + STBIDEF void stbi_ldr_to_hdr_scale(float scale); +#endif // STBI_NO_LINEAR + +#if 0 /* not used in SDL */ +// stbi_is_hdr is always defined, but always returns false if STBI_NO_HDR +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user); +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len); +#endif +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr (char const *filename); +STBIDEF int stbi_is_hdr_from_file(FILE *f); +#endif // STBI_NO_STDIO + + +#if 0 /* not used in SDL */ +// get a VERY brief reason for failure +// on most compilers (and ALL modern mainstream compilers) this is threadsafe +STBIDEF const char *stbi_failure_reason (void); +#endif + +// free the loaded image -- this is just free() +STBIDEF void stbi_image_free (void *retval_from_stbi_load); + +#if 0 /* not used in SDL */ +// get image dimensions & components without fully decoding +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp); +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len); +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *clbk, void *user); +#endif + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info (char const *filename, int *x, int *y, int *comp); +STBIDEF int stbi_info_from_file (FILE *f, int *x, int *y, int *comp); +STBIDEF int stbi_is_16_bit (char const *filename); +STBIDEF int stbi_is_16_bit_from_file(FILE *f); +#endif + + +#ifndef STBI_NO_PNG +#if 0 /* not used in SDL */ +// for image formats that explicitly notate that they have premultiplied alpha, +// we just return the colors as stored in the file. set this flag to force +// unpremultiplication. results are undefined if the unpremultiply overflow. +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply); + +// indicate whether we should process iphone images back to canonical format, +// or just pass them through "as-is" +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert); + +// flip the image vertically, so the first pixel in the output array is the bottom left +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip); +#endif /**/ + +#ifndef STBI_NO_THREAD_LOCALS /**/ +// as above, but only applies to images loaded on the thread that calls the function +// this function is only available if your compiler supports thread-local variables; +// calling it will fail to link if your compiler doesn't +STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply); +STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert); +STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip); +#endif +#endif + +// ZLIB client - used by PNG, available for other purposes + +#ifndef STBI_NO_ZLIB +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen); +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header); +STBIDEF char *stbi_zlib_decode_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); + +STBIDEF char *stbi_zlib_decode_noheader_malloc(const char *buffer, int len, int *outlen); +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen); +#endif + + +#ifdef __cplusplus +} +#endif + +// +// +//// end header file ///////////////////////////////////////////////////// +#endif // STBI_INCLUDE_STB_IMAGE_H + +#ifdef STB_IMAGE_IMPLEMENTATION + +#if defined(STBI_ONLY_JPEG) || defined(STBI_ONLY_PNG) || defined(STBI_ONLY_BMP) \ + || defined(STBI_ONLY_TGA) || defined(STBI_ONLY_GIF) || defined(STBI_ONLY_PSD) \ + || defined(STBI_ONLY_HDR) || defined(STBI_ONLY_PIC) || defined(STBI_ONLY_PNM) \ + || defined(STBI_ONLY_ZLIB) + #ifndef STBI_ONLY_JPEG + #define STBI_NO_JPEG + #endif + #ifndef STBI_ONLY_PNG + #define STBI_NO_PNG + #endif + #ifndef STBI_ONLY_BMP + #define STBI_NO_BMP + #endif + #ifndef STBI_ONLY_PSD + #define STBI_NO_PSD + #endif + #ifndef STBI_ONLY_TGA + #define STBI_NO_TGA + #endif + #ifndef STBI_ONLY_GIF + #define STBI_NO_GIF + #endif + #ifndef STBI_ONLY_HDR + #define STBI_NO_HDR + #endif + #ifndef STBI_ONLY_PIC + #define STBI_NO_PIC + #endif + #ifndef STBI_ONLY_PNM + #define STBI_NO_PNM + #endif +#endif + +#if defined(STBI_NO_PNG) && !defined(STBI_SUPPORT_ZLIB) && !defined(STBI_NO_ZLIB) +#define STBI_NO_ZLIB +#endif + + +#if 0 /* SDL change */ +#include +#include // ptrdiff_t on osx +#include +#include +#include + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) +#include // ldexp, pow +#endif +#else /* SDL change */ +#ifndef UINT_MAX +#define UINT_MAX SDL_MAX_UINT32 +#endif +#ifndef INT_MAX +#define INT_MAX SDL_MAX_SINT32 +#endif +#ifndef INT_MIN +#define INT_MIN SDL_MIN_SINT32 +#endif +#ifndef SHRT_MAX +#define SHRT_MAX SDL_MAX_SINT16 +#endif +#ifndef SHRT_MIN +#define SHRT_MIN SDL_MIN_SINT16 +#endif +#endif + +#ifndef STBI_NO_STDIO +#include +#endif + +#ifndef STBI_ASSERT +#include +#define STBI_ASSERT(x) assert(x) +#endif + +#ifdef __cplusplus +#define STBI_EXTERN extern "C" +#else +#define STBI_EXTERN extern +#endif + + +#ifndef _MSC_VER + #ifdef __cplusplus + #define stbi_inline inline + #else + #define stbi_inline + #endif +#else + #define stbi_inline __forceinline +#endif + +#ifndef STBI_NO_THREAD_LOCALS + #if defined(__cplusplus) && __cplusplus >= 201103L + #define STBI_THREAD_LOCAL thread_local + #elif defined(__GNUC__) && __GNUC__ < 5 + #define STBI_THREAD_LOCAL __thread + #elif defined(_MSC_VER) + #define STBI_THREAD_LOCAL __declspec(thread) + #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__) + #define STBI_THREAD_LOCAL _Thread_local + #endif + + #ifndef STBI_THREAD_LOCAL + #if defined(__GNUC__) + #define STBI_THREAD_LOCAL __thread + #endif + #endif +#endif + +#if 0 /* SDL change */ +#if defined(_MSC_VER) || defined(__SYMBIAN32__) +typedef unsigned short stbi__uint16; +typedef signed short stbi__int16; +typedef unsigned int stbi__uint32; +typedef signed int stbi__int32; +#else +#include +typedef uint16_t stbi__uint16; +typedef int16_t stbi__int16; +typedef uint32_t stbi__uint32; +typedef int32_t stbi__int32; +#endif +#else +typedef Uint16 stbi__uint16; +typedef Sint16 stbi__int16; +typedef Uint32 stbi__uint32; +typedef Sint32 stbi__int32; +#endif + +#ifndef STBI_BUFFER_SIZE +#define STBI_BUFFER_SIZE 128 +#endif + +// should produce compiler error if size is wrong +typedef unsigned char validate_uint32[sizeof(stbi__uint32)==4 ? 1 : -1]; + +#ifdef _MSC_VER +#define STBI_NOTUSED(v) (void)(v) +#else +#define STBI_NOTUSED(v) (void)sizeof(v) +#endif + +#if 0 /* SDL change: */ +#ifdef _MSC_VER +#define STBI_HAS_LROTL +#endif +#endif + +#ifdef STBI_HAS_LROTL + #define stbi_lrot(x,y) _lrotl(x,y) +#else + #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (-(y) & 31))) +#endif + +#if defined(STBI_MALLOC) && defined(STBI_FREE) && (defined(STBI_REALLOC) || defined(STBI_REALLOC_SIZED)) +// ok +#elif !defined(STBI_MALLOC) && !defined(STBI_FREE) && !defined(STBI_REALLOC) && !defined(STBI_REALLOC_SIZED) +// ok +#else +#error "Must define all or none of STBI_MALLOC, STBI_FREE, and STBI_REALLOC (or STBI_REALLOC_SIZED)." +#endif + +#ifndef STBI_MALLOC +#define STBI_MALLOC(sz) malloc(sz) +#define STBI_REALLOC(p,newsz) realloc(p,newsz) +#define STBI_FREE(p) free(p) +#endif + +#ifndef STBI_REALLOC_SIZED +#define STBI_REALLOC_SIZED(p,oldsz,newsz) STBI_REALLOC(p,newsz) +#endif + +// x86/x64 detection +#if defined(__x86_64__) || defined(_M_X64) +#define STBI__X64_TARGET +#elif defined(__i386) || defined(_M_IX86) +#define STBI__X86_TARGET +#endif + +#if defined(__GNUC__) && defined(STBI__X86_TARGET) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +// gcc doesn't support sse2 intrinsics unless you compile with -msse2, +// which in turn means it gets to use SSE2 everywhere. This is unfortunate, +// but previous attempts to provide the SSE2 functions with runtime +// detection caused numerous issues. The way architecture extensions are +// exposed in GCC/Clang is, sadly, not really suited for one-file libs. +// New behavior: if compiled with -msse2, we use SSE2 without any +// detection; if not, we don't use it at all. +#define STBI_NO_SIMD +#endif + +#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +// Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET +// +// 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the +// Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. +// As a result, enabling SSE2 on 32-bit MinGW is dangerous when not +// simultaneously enabling "-mstackrealign". +// +// See https://github.com/nothings/stb/issues/81 for more information. +// +// So default to no SSE2 on 32-bit MinGW. If you've read this far and added +// -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. +#define STBI_NO_SIMD +#endif + +#if !defined(STBI_NO_SIMD) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) +#define STBI_SSE2 +#include + +#ifdef _MSC_VER + +#if _MSC_VER >= 1400 // not VC6 +#include // __cpuid +static int stbi__cpuid3(void) +{ + int info[4]; + __cpuid(info,1); + return info[3]; +} +#else +static int stbi__cpuid3(void) +{ + int res; + __asm { + mov eax,1 + cpuid + mov res,edx + } + return res; +} +#endif + +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name + +#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) +static int stbi__sse2_available(void) +{ + int info3 = stbi__cpuid3(); + return ((info3 >> 26) & 1) != 0; +} +#endif + +#else // assume GCC-style if not VC++ +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) + +#if !defined(STBI_NO_JPEG) && defined(STBI_SSE2) +static int stbi__sse2_available(void) +{ + // If we're even attempting to compile this on GCC/Clang, that means + // -msse2 is on, which means the compiler is allowed to use SSE2 + // instructions at will, and so are we. + return 1; +} +#endif + +#endif +#endif + +// ARM NEON +#if defined(STBI_NO_SIMD) && defined(STBI_NEON) +#undef STBI_NEON +#endif + +#ifdef STBI_NEON +#include +#ifdef _MSC_VER +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name +#else +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif +#endif + +#ifndef STBI_SIMD_ALIGN +#define STBI_SIMD_ALIGN(type, name) type name +#endif + +#ifndef STBI_MAX_DIMENSIONS +#define STBI_MAX_DIMENSIONS (1 << 24) +#endif + +/////////////////////////////////////////////// +// +// stbi__context struct and start_xxx functions + +// stbi__context structure is our basic context used by all images, so it +// contains all the IO context, plus some basic image information +typedef struct +{ + stbi__uint32 img_x, img_y; + int img_n, img_out_n; + + stbi_io_callbacks io; + void *io_user_data; + + int read_from_callbacks; + int buflen; + stbi_uc buffer_start[128]; + int callback_already_read; + + stbi_uc *img_buffer, *img_buffer_end; + stbi_uc *img_buffer_original, *img_buffer_original_end; +} stbi__context; + + +static void stbi__refill_buffer(stbi__context *s); + +// initialize a memory-decode context +static void stbi__start_mem(stbi__context *s, stbi_uc const *buffer, int len) +{ + s->io.read = NULL; + s->read_from_callbacks = 0; + s->callback_already_read = 0; + s->img_buffer = s->img_buffer_original = (stbi_uc *) buffer; + s->img_buffer_end = s->img_buffer_original_end = (stbi_uc *) buffer+len; +} + +#if 0 /* not used in SDL */ +// initialize a callback-based context +static void stbi__start_callbacks(stbi__context *s, stbi_io_callbacks *c, void *user) +{ + s->io = *c; + s->io_user_data = user; + s->buflen = sizeof(s->buffer_start); + s->read_from_callbacks = 1; + s->callback_already_read = 0; + s->img_buffer = s->img_buffer_original = s->buffer_start; + stbi__refill_buffer(s); + s->img_buffer_original_end = s->img_buffer_end; +} +#endif + +#ifndef STBI_NO_STDIO + +static int stbi__stdio_read(void *user, char *data, int size) +{ + return (int) fread(data,1,size,(FILE*) user); +} + +static void stbi__stdio_skip(void *user, int n) +{ + int ch; + fseek((FILE*) user, n, SEEK_CUR); + ch = fgetc((FILE*) user); /* have to read a byte to reset feof()'s flag */ + if (ch != EOF) { + ungetc(ch, (FILE *) user); /* push byte back onto stream if valid. */ + } +} + +static int stbi__stdio_eof(void *user) +{ + return feof((FILE*) user) || ferror((FILE *) user); +} + +static stbi_io_callbacks stbi__stdio_callbacks = +{ + stbi__stdio_read, + stbi__stdio_skip, + stbi__stdio_eof, +}; + +static void stbi__start_file(stbi__context *s, FILE *f) +{ + stbi__start_callbacks(s, &stbi__stdio_callbacks, (void *) f); +} + +//static void stop_file(stbi__context *s) { } + +#endif // !STBI_NO_STDIO + +static void stbi__rewind(stbi__context *s) +{ + // conceptually rewind SHOULD rewind to the beginning of the stream, + // but we just rewind to the beginning of the initial buffer, because + // we only use it after doing 'test', which only ever looks at at most 92 bytes + s->img_buffer = s->img_buffer_original; + s->img_buffer_end = s->img_buffer_original_end; +} + +enum +{ + STBI_ORDER_RGB, + STBI_ORDER_BGR +}; + +typedef struct +{ + int w; + int h; + int pitch; + stbi_uc *y; + stbi_uc *uv; +} stbi__nv12; + +typedef struct +{ + int bits_per_channel; + int num_channels; + int channel_order; +} stbi__result_info; + +#ifndef STBI_NO_JPEG +static int stbi__jpeg_test(stbi__context *s); +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__nv12 *nv12, stbi__result_info *ri); +#if 0 /* not used in SDL */ +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp); +#endif +#endif + +#ifndef STBI_NO_PNG +static int stbi__png_test(stbi__context *s); +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, unsigned int *palette_buffer, int palette_buffer_len, stbi__result_info *ri); +#if 0 /* not used in SDL */ +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__png_is16(stbi__context *s); +#endif +#endif + +#ifndef STBI_NO_BMP +static int stbi__bmp_test(stbi__context *s); +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_TGA +static int stbi__tga_test(stbi__context *s); +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, unsigned int *palette_buffer, int palette_buffer_len, stbi__result_info *ri); +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s); +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc); +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__psd_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_HDR +static int stbi__hdr_test(stbi__context *s); +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_test(stbi__context *s); +static void *stbi__pic_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_GIF +static int stbi__gif_test(stbi__context *s); +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp); +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp); +#endif + +#ifndef STBI_NO_PNM +static int stbi__pnm_test(stbi__context *s); +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri); +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp); +static int stbi__pnm_is16(stbi__context *s); +#endif + +#ifndef STBI_NO_FAILURE_STRINGS +#if 1 /* SDL change: */ +static int stbi__err(const char *str) +{ + SDL_SetError("%s", str); + return 0; +} +#else /* SDL change. */ +static +#ifdef STBI_THREAD_LOCAL +STBI_THREAD_LOCAL +#endif +const char *stbi__g_failure_reason; + +STBIDEF const char *stbi_failure_reason(void) +{ + return stbi__g_failure_reason; +} + +static int stbi__err(const char *str) +{ + stbi__g_failure_reason = str; + return 0; +} +#endif /**/ +#endif + +static void *stbi__malloc(size_t size) +{ + return STBI_MALLOC(size); +} + +// stb_image uses ints pervasively, including for offset calculations. +// therefore the largest decoded image size we can support with the +// current code, even on 64-bit targets, is INT_MAX. this is not a +// significant limitation for the intended use case. +// +// we do, however, need to make sure our size calculations don't +// overflow. hence a few helper functions for size calculations that +// multiply integers together, making sure that they're non-negative +// and no overflow occurs. + +// return 1 if the sum is valid, 0 on overflow. +// negative terms are considered invalid. +static int stbi__addsizes_valid(int a, int b) +{ + if (b < 0) return 0; + // now 0 <= b <= INT_MAX, hence also + // 0 <= INT_MAX - b <= INTMAX. + // And "a + b <= INT_MAX" (which might overflow) is the + // same as a <= INT_MAX - b (no overflow) + return a <= INT_MAX - b; +} + +// returns 1 if the product is valid, 0 on overflow. +// negative factors are considered invalid. +static int stbi__mul2sizes_valid(int a, int b) +{ + if (a < 0 || b < 0) return 0; + if (b == 0) return 1; // mul-by-0 is always safe + // portable way to check for no overflows in a*b + return a <= INT_MAX/b; +} + +#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) +// returns 1 if "a*b + add" has no negative terms/factors and doesn't overflow +static int stbi__mad2sizes_valid(int a, int b, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__addsizes_valid(a*b, add); +} +#endif + +// returns 1 if "a*b*c + add" has no negative terms/factors and doesn't overflow +static int stbi__mad3sizes_valid(int a, int b, int c, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && + stbi__addsizes_valid(a*b*c, add); +} + +// returns 1 if "a*b*c*d + add" has no negative terms/factors and doesn't overflow +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) +static int stbi__mad4sizes_valid(int a, int b, int c, int d, int add) +{ + return stbi__mul2sizes_valid(a, b) && stbi__mul2sizes_valid(a*b, c) && + stbi__mul2sizes_valid(a*b*c, d) && stbi__addsizes_valid(a*b*c*d, add); +} +#endif + +#if !defined(STBI_NO_JPEG) || !defined(STBI_NO_PNG) || !defined(STBI_NO_TGA) || !defined(STBI_NO_HDR) +// mallocs with size overflow checking +static void *stbi__malloc_mad2(int a, int b, int add) +{ + if (!stbi__mad2sizes_valid(a, b, add)) return NULL; + return stbi__malloc(a*b + add); +} +#endif + +static void *stbi__malloc_mad3(int a, int b, int c, int add) +{ + if (!stbi__mad3sizes_valid(a, b, c, add)) return NULL; + return stbi__malloc(a*b*c + add); +} + +#if !defined(STBI_NO_LINEAR) || !defined(STBI_NO_HDR) || !defined(STBI_NO_PNM) +static void *stbi__malloc_mad4(int a, int b, int c, int d, int add) +{ + if (!stbi__mad4sizes_valid(a, b, c, d, add)) return NULL; + return stbi__malloc(a*b*c*d + add); +} +#endif + +// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow. +static int stbi__addints_valid(int a, int b) +{ + if ((a >= 0) != (b >= 0)) return 1; // a and b have different signs, so no overflow + if (a < 0 && b < 0) return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0. + return a <= INT_MAX - b; +} + +// returns 1 if the product of two ints fits in a signed short, 0 on overflow. +static int stbi__mul2shorts_valid(int a, int b) +{ + if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow + if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid + if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN + return a >= SHRT_MIN / b; +} + +// stbi__err - error +// stbi__errpf - error returning pointer to float +// stbi__errpuc - error returning pointer to unsigned char + +#ifdef STBI_NO_FAILURE_STRINGS + #define stbi__err(x,y) 0 +#elif defined(STBI_FAILURE_USERMSG) + #define stbi__err(x,y) stbi__err(y) +#else + #define stbi__err(x,y) stbi__err(x) +#endif + +#define stbi__errpf(x,y) ((float *)(size_t) (stbi__err(x,y)?NULL:NULL)) +#define stbi__errpuc(x,y) ((unsigned char *)(size_t) (stbi__err(x,y)?NULL:NULL)) + +STBIDEF void stbi_image_free(void *retval_from_stbi_load) +{ + STBI_FREE(retval_from_stbi_load); +} + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp); +#endif + +#ifndef STBI_NO_HDR +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp); +#endif + +static int stbi__vertically_flip_on_load_global = 0; + +#ifndef STBI_NO_PNG +#if 0 /* not used in SDL */ +STBIDEF void stbi_set_flip_vertically_on_load(int flag_true_if_should_flip) +{ + stbi__vertically_flip_on_load_global = flag_true_if_should_flip; +} +#endif /**/ +#endif + +#ifndef STBI_THREAD_LOCAL +#define stbi__vertically_flip_on_load stbi__vertically_flip_on_load_global +#else +static STBI_THREAD_LOCAL int stbi__vertically_flip_on_load_local, stbi__vertically_flip_on_load_set; + +#ifndef STBI_NO_PNG +STBIDEF void stbi_set_flip_vertically_on_load_thread(int flag_true_if_should_flip) +{ + stbi__vertically_flip_on_load_local = flag_true_if_should_flip; + stbi__vertically_flip_on_load_set = 1; +} +#endif + +#define stbi__vertically_flip_on_load (stbi__vertically_flip_on_load_set \ + ? stbi__vertically_flip_on_load_local \ + : stbi__vertically_flip_on_load_global) +#endif // STBI_THREAD_LOCAL + +static void *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc, unsigned int *palette_buffer, int palette_buffer_len) +{ + memset(ri, 0, sizeof(*ri)); // make sure it's initialized if we add new fields + ri->bits_per_channel = 8; // default is 8 so most paths don't have to be changed + ri->channel_order = STBI_ORDER_RGB; // all current input & output are this, but this is here so we can add BGR order + ri->num_channels = 0; + + // test the formats with a very explicit header first (at least a FOURCC + // or distinctive magic number first) + #ifndef STBI_NO_PNG + if (stbi__png_test(s)) return stbi__png_load(s,x,y,comp,req_comp, palette_buffer, palette_buffer_len, ri); + #endif + #ifndef STBI_NO_BMP + if (stbi__bmp_test(s)) return stbi__bmp_load(s,x,y,comp,req_comp, ri); + #endif + #ifndef STBI_NO_GIF + if (stbi__gif_test(s)) return stbi__gif_load(s,x,y,comp,req_comp, ri); + #endif + #ifndef STBI_NO_PSD + if (stbi__psd_test(s)) return stbi__psd_load(s,x,y,comp,req_comp, ri, bpc); + #else + STBI_NOTUSED(bpc); + #endif + #ifndef STBI_NO_PIC + if (stbi__pic_test(s)) return stbi__pic_load(s,x,y,comp,req_comp, ri); + #endif + + // then the formats that can end up attempting to load with just 1 or 2 + // bytes matching expectations; these are prone to false positives, so + // try them later + #ifndef STBI_NO_JPEG + if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp,NULL, ri); + #endif + #ifndef STBI_NO_PNM + if (stbi__pnm_test(s)) return stbi__pnm_load(s,x,y,comp,req_comp, ri); + #endif + + #ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + float *hdr = stbi__hdr_load(s, x,y,comp,req_comp, ri); + return stbi__hdr_to_ldr(hdr, *x, *y, req_comp ? req_comp : *comp); + } + #endif + + #ifndef STBI_NO_TGA + // test tga last because it's a crappy test! + if (stbi__tga_test(s)) + return stbi__tga_load(s,x,y,comp,req_comp, palette_buffer, palette_buffer_len, ri); + #endif + + return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); +} + +static stbi_uc *stbi__convert_16_to_8(stbi__uint16 *orig, int w, int h, int channels) +{ + int i; + int img_len = w * h * channels; + stbi_uc *reduced; + + reduced = (stbi_uc *) stbi__malloc(img_len); + if (reduced == NULL) return stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + reduced[i] = (stbi_uc)((orig[i] >> 8) & 0xFF); // top half of each byte is sufficient approx of 16->8 bit scaling + + STBI_FREE(orig); + return reduced; +} + +#if 0 /* not used in SDL */ +static stbi__uint16 *stbi__convert_8_to_16(stbi_uc *orig, int w, int h, int channels) +{ + int i; + int img_len = w * h * channels; + stbi__uint16 *enlarged; + + enlarged = (stbi__uint16 *) stbi__malloc(img_len*2); + if (enlarged == NULL) return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); + + for (i = 0; i < img_len; ++i) + enlarged[i] = (stbi__uint16)((orig[i] << 8) + orig[i]); // replicate to high and low byte, maps 0->0, 255->0xffff + + STBI_FREE(orig); + return enlarged; +} +#endif + +static void stbi__vertical_flip(void *image, int w, int h, int bytes_per_pixel) +{ + int row; + size_t bytes_per_row = (size_t)w * bytes_per_pixel; + stbi_uc temp[2048]; + stbi_uc *bytes = (stbi_uc *)image; + + for (row = 0; row < (h>>1); row++) { + stbi_uc *row0 = bytes + row*bytes_per_row; + stbi_uc *row1 = bytes + (h - row - 1)*bytes_per_row; + // swap row0 with row1 + size_t bytes_left = bytes_per_row; + while (bytes_left) { + size_t bytes_copy = (bytes_left < sizeof(temp)) ? bytes_left : sizeof(temp); + memcpy(temp, row0, bytes_copy); + memcpy(row0, row1, bytes_copy); + memcpy(row1, temp, bytes_copy); + row0 += bytes_copy; + row1 += bytes_copy; + bytes_left -= bytes_copy; + } + } +} + +#ifndef STBI_NO_GIF +static void stbi__vertical_flip_slices(void *image, int w, int h, int z, int bytes_per_pixel) +{ + int slice; + int slice_size = w * h * bytes_per_pixel; + + stbi_uc *bytes = (stbi_uc *)image; + for (slice = 0; slice < z; ++slice) { + stbi__vertical_flip(bytes, w, h, bytes_per_pixel); + bytes += slice_size; + } +} +#endif + +#if 0 /* not used in SDL */ +static unsigned char *stbi__load_indexed(stbi__context *s, int *x, int *y, unsigned int *palette_buffer, int palette_buffer_len) +{ + stbi__result_info ri; + int comp; + void *result; + + if (!palette_buffer) + return NULL; + + result = stbi__load_main(s, x, y, &comp, 1, &ri, 8, palette_buffer, palette_buffer_len); + if (result == NULL) + return NULL; + + if (comp != 1) { + stbi_image_free(result); + return NULL; + } + + if (ri.bits_per_channel != 8) { + stbi_image_free(result); + return NULL; + } + + // @TODO: move stbi__convert_format to here + + if (stbi__vertically_flip_on_load) { + int channels = 1; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); + } + + return (unsigned char *) result; +} +#endif /**/ + +static unsigned char *stbi__load_and_postprocess_8bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 8, NULL, 0); + + if (result == NULL) + return NULL; + + // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. + STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); + + if (ri.bits_per_channel != 8) { + result = stbi__convert_16_to_8((stbi__uint16 *) result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 8; + } + + // @TODO: move stbi__convert_format to here + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi_uc)); + } + + return (unsigned char *) result; +} + +#if 0 /* not used in SDL */ +static stbi__uint16 *stbi__load_and_postprocess_16bit(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__result_info ri; + void *result = stbi__load_main(s, x, y, comp, req_comp, &ri, 16, NULL, 0); + + if (result == NULL) + return NULL; + + // it is the responsibility of the loaders to make sure we get either 8 or 16 bit. + STBI_ASSERT(ri.bits_per_channel == 8 || ri.bits_per_channel == 16); + + if (ri.bits_per_channel != 16) { + result = stbi__convert_8_to_16((stbi_uc *) result, *x, *y, req_comp == 0 ? *comp : req_comp); + ri.bits_per_channel = 16; + } + + // @TODO: move stbi__convert_format16 to here + // @TODO: special case RGB-to-Y (and RGBA-to-YA) for 8-bit-to-16-bit case to keep more precision + + if (stbi__vertically_flip_on_load) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(stbi__uint16)); + } + + return (stbi__uint16 *) result; +} +#endif /**/ + +#if !defined(STBI_NO_HDR) && !defined(STBI_NO_LINEAR) +static void stbi__float_postprocess(float *result, int *x, int *y, int *comp, int req_comp) +{ + if (stbi__vertically_flip_on_load && result != NULL) { + int channels = req_comp ? req_comp : *comp; + stbi__vertical_flip(result, *x, *y, channels * sizeof(float)); + } +} +#endif + +#ifndef STBI_NO_STDIO + +#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) +STBI_EXTERN __declspec(dllimport) int __stdcall MultiByteToWideChar(unsigned int cp, unsigned long flags, const char *str, int cbmb, wchar_t *widestr, int cchwide); +STBI_EXTERN __declspec(dllimport) int __stdcall WideCharToMultiByte(unsigned int cp, unsigned long flags, const wchar_t *widestr, int cchwide, char *str, int cbmb, const char *defchar, int *used_default); +#endif + +#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) +STBIDEF int stbi_convert_wchar_to_utf8(char *buffer, size_t bufferlen, const wchar_t* input) +{ + return WideCharToMultiByte(65001 /* UTF8 */, 0, input, -1, buffer, (int) bufferlen, NULL, NULL); +} +#endif + +static FILE *stbi__fopen(char const *filename, char const *mode) +{ + FILE *f; +#if defined(_WIN32) && defined(STBI_WINDOWS_UTF8) + wchar_t wMode[64]; + wchar_t wFilename[1024]; + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)/sizeof(*wFilename))) + return 0; + + if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)/sizeof(*wMode))) + return 0; + +#if defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != _wfopen_s(&f, wFilename, wMode)) + f = 0; +#else + f = _wfopen(wFilename, wMode); +#endif + +#elif defined(_MSC_VER) && _MSC_VER >= 1400 + if (0 != fopen_s(&f, filename, mode)) + f=0; +#else + f = fopen(filename, mode); +#endif + return f; +} + + +STBIDEF stbi_uc *stbi_load(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + unsigned char *result; + if (!f) return stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +STBIDEF stbi_uc *stbi_load_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *result; + stbi__context s; + stbi__start_file(&s,f); + result = stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi__uint16 *stbi_load_from_file_16(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + stbi__uint16 *result; + stbi__context s; + stbi__start_file(&s,f); + result = stbi__load_and_postprocess_16bit(&s,x,y,comp,req_comp); + if (result) { + // need to 'unget' all the characters in the IO buffer + fseek(f, - (int) (s.img_buffer_end - s.img_buffer), SEEK_CUR); + } + return result; +} + +STBIDEF stbi_us *stbi_load_16(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + stbi__uint16 *result; + if (!f) return (stbi_us *) stbi__errpuc("can't fopen", "Unable to open file"); + result = stbi_load_from_file_16(f,x,y,comp,req_comp); + fclose(f); + return result; +} + + +#endif //!STBI_NO_STDIO + +#if 0 /* not used in SDL */ +STBIDEF stbi_us *stbi_load_16_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *channels_in_file, int desired_channels) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); +} + +STBIDEF stbi_us *stbi_load_16_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *channels_in_file, int desired_channels) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_and_postprocess_16bit(&s,x,y,channels_in_file,desired_channels); +} +#endif /**/ + +STBIDEF stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); +} + +#if 0 /* not used in SDL */ +STBIDEF stbi_uc *stbi_load_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__load_and_postprocess_8bit(&s,x,y,comp,req_comp); +} + +STBIDEF stbi_uc *stbi_load_from_memory_with_palette(stbi_uc const *buffer, int len, int *x, int *y, unsigned int *palette_buffer, int palette_buffer_len) +{ + stbi__context s; + stbi__start_mem(&s, buffer, len); + return stbi__load_indexed(&s, x, y, palette_buffer, palette_buffer_len); +} + +STBIDEF stbi_uc *stbi_load_from_callbacks_with_palette(stbi_io_callbacks const *clbk, void *user, int *x, int *y, unsigned int *palette_buffer, int palette_buffer_len) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *)clbk, user); + return stbi__load_indexed(&s, x, y, palette_buffer, palette_buffer_len); +} +#endif + +#ifndef STBI_NO_GIF +STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +{ + unsigned char *result; + stbi__context s; + stbi__start_mem(&s,buffer,len); + + result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp); + if (stbi__vertically_flip_on_load) { + stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); + } + + return result; +} +#endif + +#ifndef STBI_NO_LINEAR +static float *stbi__loadf_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *data; + #ifndef STBI_NO_HDR + if (stbi__hdr_test(s)) { + stbi__result_info ri; + float *hdr_data = stbi__hdr_load(s,x,y,comp,req_comp, &ri); + if (hdr_data) + stbi__float_postprocess(hdr_data,x,y,comp,req_comp); + return hdr_data; + } + #endif + data = stbi__load_and_postprocess_8bit(s, x, y, comp, req_comp); + if (data) + return stbi__ldr_to_hdr(data, *x, *y, req_comp ? req_comp : *comp); + return stbi__errpf("unknown image type", "Image not of any known type, or corrupt"); +} + +STBIDEF float *stbi_loadf_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} + +STBIDEF float *stbi_loadf_from_callbacks(stbi_io_callbacks const *clbk, void *user, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} + +#ifndef STBI_NO_STDIO +STBIDEF float *stbi_loadf(char const *filename, int *x, int *y, int *comp, int req_comp) +{ + float *result; + FILE *f = stbi__fopen(filename, "rb"); + if (!f) return stbi__errpf("can't fopen", "Unable to open file"); + result = stbi_loadf_from_file(f,x,y,comp,req_comp); + fclose(f); + return result; +} + +STBIDEF float *stbi_loadf_from_file(FILE *f, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_file(&s,f); + return stbi__loadf_main(&s,x,y,comp,req_comp); +} +#endif // !STBI_NO_STDIO + +#endif // !STBI_NO_LINEAR + +#if 0 /* not used in SDL */ +// these is-hdr-or-not is defined independent of whether STBI_NO_LINEAR is +// defined, for API simplicity; if STBI_NO_LINEAR is defined, it always +// reports false! + +STBIDEF int stbi_is_hdr_from_memory(stbi_uc const *buffer, int len) +{ + #ifndef STBI_NO_HDR + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__hdr_test(&s); + #else + STBI_NOTUSED(buffer); + STBI_NOTUSED(len); + return 0; + #endif +} +#endif + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_is_hdr (char const *filename) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result=0; + if (f) { + result = stbi_is_hdr_from_file(f); + fclose(f); + } + return result; +} + +STBIDEF int stbi_is_hdr_from_file(FILE *f) +{ + #ifndef STBI_NO_HDR + long pos = ftell(f); + int res; + stbi__context s; + stbi__start_file(&s,f); + res = stbi__hdr_test(&s); + fseek(f, pos, SEEK_SET); + return res; + #else + STBI_NOTUSED(f); + return 0; + #endif +} +#endif // !STBI_NO_STDIO + +#if 0 /* not used in SDL */ +STBIDEF int stbi_is_hdr_from_callbacks(stbi_io_callbacks const *clbk, void *user) +{ + #ifndef STBI_NO_HDR + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) clbk, user); + return stbi__hdr_test(&s); + #else + STBI_NOTUSED(clbk); + STBI_NOTUSED(user); + return 0; + #endif +} +#endif + +#ifndef STBI_NO_LINEAR +static float stbi__l2h_gamma=2.2f, stbi__l2h_scale=1.0f; + +STBIDEF void stbi_ldr_to_hdr_gamma(float gamma) { stbi__l2h_gamma = gamma; } +STBIDEF void stbi_ldr_to_hdr_scale(float scale) { stbi__l2h_scale = scale; } +#endif + +#ifndef STBI_NO_HDR +static float stbi__h2l_gamma_i=1.0f/2.2f, stbi__h2l_scale_i=1.0f; + +STBIDEF void stbi_hdr_to_ldr_gamma(float gamma) { stbi__h2l_gamma_i = 1/gamma; } +STBIDEF void stbi_hdr_to_ldr_scale(float scale) { stbi__h2l_scale_i = 1/scale; } +#endif + + +////////////////////////////////////////////////////////////////////////////// +// +// Common code used by all image loaders +// + +enum +{ + STBI__SCAN_load=0, + STBI__SCAN_type, + STBI__SCAN_header +}; + +static void stbi__refill_buffer(stbi__context *s) +{ + int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); + s->callback_already_read += (int) (s->img_buffer - s->img_buffer_original); + if (n == 0) { + // at end of file, treat same as if from memory, but need to handle case + // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start+1; + *s->img_buffer = 0; + } else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +stbi_inline static stbi_uc stbi__get8(stbi__context *s) +{ + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + stbi__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_HDR) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +stbi_inline static int stbi__at_eof(stbi__context *s) +{ + if (s->io.read) { + if (!(s->io.eof)(s->io_user_data)) return 0; + // if feof() is true, check if buffer = end + // special case: we've only got the special 0 character at the end + if (s->read_from_callbacks == 0) return 1; + } + + return s->img_buffer >= s->img_buffer_end; +} +#endif + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) +// nothing +#else +static void stbi__skip(stbi__context *s, int n) +{ + if (n == 0) return; // already there! + if (n < 0) { + s->img_buffer = s->img_buffer_end; + return; + } + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); + return; + } + } + s->img_buffer += n; +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_TGA) && defined(STBI_NO_HDR) && defined(STBI_NO_PNM) +// nothing +#else +static int stbi__getn(stbi__context *s, stbi_uc *buffer, int n) +{ + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + int res, count; + + memcpy(buffer, s->img_buffer, blen); + + count = (s->io.read)(s->io_user_data, (char*) buffer + blen, n - blen); + res = (count == (n-blen)); + s->img_buffer = s->img_buffer_end; + return res; + } + } + + if (s->img_buffer+n <= s->img_buffer_end) { + memcpy(buffer, s->img_buffer, n); + s->img_buffer += n; + return 1; + } else + return 0; +} +#endif + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) +// nothing +#else +static int stbi__get16be(stbi__context *s) +{ + int z = stbi__get8(s); + return (z << 8) + stbi__get8(s); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) && defined(STBI_NO_PIC) +// nothing +#else +static stbi__uint32 stbi__get32be(stbi__context *s) +{ + stbi__uint32 z = stbi__get16be(s); + return (z << 16) + stbi__get16be(s); +} +#endif + +#if defined(STBI_NO_BMP) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) +// nothing +#else +static int stbi__get16le(stbi__context *s) +{ + int z = stbi__get8(s); + return z + (stbi__get8(s) << 8); +} +#endif + +#ifndef STBI_NO_BMP +static stbi__uint32 stbi__get32le(stbi__context *s) +{ + stbi__uint32 z = stbi__get16le(s); + z += (stbi__uint32)stbi__get16le(s) << 16; + return z; +} +#endif + +#define STBI__BYTECAST(x) ((stbi_uc) ((x) & 255)) // truncate int to byte without warnings + +#if defined(STBI_NO_JPEG) && defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +////////////////////////////////////////////////////////////////////////////// +// +// generic converter from built-in img_n to req_comp +// individual types do this automatically as much as possible (e.g. jpeg +// does all cases internally since it needs to colorspace convert anyway, +// and it never has alpha, so very few cases ). png can automatically +// interleave an alpha=255 channel, but falls back to this for other cases +// +// assume data buffer is malloced, so malloc a new one and free that one +// only failure mode is malloc failing + +static stbi_uc stbi__compute_y(int r, int g, int b) +{ + return (stbi_uc) (((r*77) + (g*150) + (29*b)) >> 8); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_BMP) && defined(STBI_NO_PSD) && defined(STBI_NO_TGA) && defined(STBI_NO_GIF) && defined(STBI_NO_PIC) && defined(STBI_NO_PNM) +// nothing +#else +static unsigned char *stbi__convert_format(unsigned char *data, int img_n, int req_comp, unsigned int x, unsigned int y) +{ + int i,j; + unsigned char *good; + + if (req_comp == img_n) return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (unsigned char *) stbi__malloc_mad3(req_comp, x, y, 0); + if (good == NULL) { + STBI_FREE(data); + return stbi__errpuc("outofmem", "Out of memory"); + } + + for (j=0; j < (int) y; ++j) { + unsigned char *src = data + j * x * img_n ; + unsigned char *dest = good + j * x * req_comp; + + #define STBI__COMBO(a,b) ((a)*8+(b)) + #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=255; } break; + STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=255; } break; + STBI__CASE(2,1) { dest[0]=src[0]; } break; + STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; + STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=255; } break; + STBI__CASE(3,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; + STBI__CASE(3,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = 255; } break; + STBI__CASE(4,1) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); } break; + STBI__CASE(4,2) { dest[0]=stbi__compute_y(src[0],src[1],src[2]); dest[1] = src[3]; } break; + STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; + default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return stbi__errpuc("unsupported", "Unsupported format conversion"); + } + #undef STBI__CASE + } + + STBI_FREE(data); + return good; +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) +// nothing +#else +static stbi__uint16 stbi__compute_y_16(int r, int g, int b) +{ + return (stbi__uint16) (((r*77) + (g*150) + (29*b)) >> 8); +} +#endif + +#if defined(STBI_NO_PNG) && defined(STBI_NO_PSD) +// nothing +#else +static stbi__uint16 *stbi__convert_format16(stbi__uint16 *data, int img_n, int req_comp, unsigned int x, unsigned int y) +{ + int i,j; + stbi__uint16 *good; + + if (req_comp == img_n) return data; + STBI_ASSERT(req_comp >= 1 && req_comp <= 4); + + good = (stbi__uint16 *) stbi__malloc(req_comp * x * y * 2); + if (good == NULL) { + STBI_FREE(data); + return (stbi__uint16 *) stbi__errpuc("outofmem", "Out of memory"); + } + + for (j=0; j < (int) y; ++j) { + stbi__uint16 *src = data + j * x * img_n ; + stbi__uint16 *dest = good + j * x * req_comp; + + #define STBI__COMBO(a,b) ((a)*8+(b)) + #define STBI__CASE(a,b) case STBI__COMBO(a,b): for(i=x-1; i >= 0; --i, src += a, dest += b) + // convert source image with img_n components to one with req_comp components; + // avoid switch per pixel, so use switch per scanline and massive macros + switch (STBI__COMBO(img_n, req_comp)) { + STBI__CASE(1,2) { dest[0]=src[0]; dest[1]=0xffff; } break; + STBI__CASE(1,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(1,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=0xffff; } break; + STBI__CASE(2,1) { dest[0]=src[0]; } break; + STBI__CASE(2,3) { dest[0]=dest[1]=dest[2]=src[0]; } break; + STBI__CASE(2,4) { dest[0]=dest[1]=dest[2]=src[0]; dest[3]=src[1]; } break; + STBI__CASE(3,4) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2];dest[3]=0xffff; } break; + STBI__CASE(3,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; + STBI__CASE(3,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = 0xffff; } break; + STBI__CASE(4,1) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); } break; + STBI__CASE(4,2) { dest[0]=stbi__compute_y_16(src[0],src[1],src[2]); dest[1] = src[3]; } break; + STBI__CASE(4,3) { dest[0]=src[0];dest[1]=src[1];dest[2]=src[2]; } break; + default: STBI_ASSERT(0); STBI_FREE(data); STBI_FREE(good); return (stbi__uint16*) stbi__errpuc("unsupported", "Unsupported format conversion"); + } + #undef STBI__CASE + } + + STBI_FREE(data); + return good; +} +#endif + +#ifndef STBI_NO_LINEAR +static float *stbi__ldr_to_hdr(stbi_uc *data, int x, int y, int comp) +{ + int i,k,n; + float *output; + if (!data) return NULL; + output = (float *) stbi__malloc_mad4(x, y, comp, sizeof(float), 0); + if (output == NULL) { STBI_FREE(data); return stbi__errpf("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + output[i*comp + k] = (float) (pow(data[i*comp+k]/255.0f, stbi__l2h_gamma) * stbi__l2h_scale); + } + } + if (n < comp) { + for (i=0; i < x*y; ++i) { + output[i*comp + n] = data[i*comp + n]/255.0f; + } + } + STBI_FREE(data); + return output; +} +#endif + +#ifndef STBI_NO_HDR +#define stbi__float2int(x) ((int) (x)) +static stbi_uc *stbi__hdr_to_ldr(float *data, int x, int y, int comp) +{ + int i,k,n; + stbi_uc *output; + if (!data) return NULL; + output = (stbi_uc *) stbi__malloc_mad3(x, y, comp, 0); + if (output == NULL) { STBI_FREE(data); return stbi__errpuc("outofmem", "Out of memory"); } + // compute number of non-alpha components + if (comp & 1) n = comp; else n = comp-1; + for (i=0; i < x*y; ++i) { + for (k=0; k < n; ++k) { + float z = (float) pow(data[i*comp+k]*stbi__h2l_scale_i, stbi__h2l_gamma_i) * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc) stbi__float2int(z); + } + if (k < comp) { + float z = data[i*comp+k] * 255 + 0.5f; + if (z < 0) z = 0; + if (z > 255) z = 255; + output[i*comp + k] = (stbi_uc) stbi__float2int(z); + } + } + STBI_FREE(data); + return output; +} +#endif + +////////////////////////////////////////////////////////////////////////////// +// +// "baseline" JPEG/JFIF decoder +// +// simple implementation +// - doesn't support delayed output of y-dimension +// - simple interface (only one output format: 8-bit interleaved RGB) +// - doesn't try to recover corrupt jpegs +// - doesn't allow partial loading, loading multiple at once +// - still fast on x86 (copying globals into locals doesn't help x86) +// - allocates lots of intermediate memory (full size of all components) +// - non-interleaved case requires this anyway +// - allows good upsampling (see next) +// high-quality +// - upsampled channels are bilinearly interpolated, even across blocks +// - quality integer IDCT derived from IJG's 'slow' +// performance +// - fast huffman; reasonable integer IDCT +// - some SIMD kernels for common paths on targets with SSE2/NEON +// - uses a lot of intermediate memory, could cache poorly + +#ifndef STBI_NO_JPEG + +// huffman decoding acceleration +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct +{ + stbi_uc fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + stbi__uint16 code[256]; + stbi_uc values[256]; + stbi_uc size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' +} stbi__huffman; + +typedef struct +{ + stbi__context *s; + stbi__huffman huff_dc[4]; + stbi__huffman huff_ac[4]; + stbi__uint16 dequant[4][64]; + stbi__int16 fast_ac[4][1 << FAST_BITS]; + +// sizes for components, interleaved MCUs + int img_h_max, img_v_max; + int img_mcu_x, img_mcu_y; + int img_mcu_w, img_mcu_h; + +// definition of jpeg image component + struct + { + int id; + int h,v; + int tq; + int hd,ha; + int dc_pred; + + int x,y,w2,h2; + stbi_uc *data; + void *raw_data, *raw_coeff; + stbi_uc *linebuf; + short *coeff; // progressive only + int coeff_w, coeff_h; // number of 8x8 coefficient blocks + } img_comp[4]; + + stbi__uint32 code_buffer; // jpeg entropy-coded buffer + int code_bits; // number of valid bits + unsigned char marker; // marker seen while filling entropy buffer + int nomore; // flag if we saw a marker so must stop + + int progressive; + int spec_start; + int spec_end; + int succ_high; + int succ_low; + int eob_run; + int jfif; + int app14_color_transform; // Adobe APP14 tag + int rgb; + + int scan_n, order[4]; + int restart_interval, todo; + +// kernels + void (*idct_block_kernel)(stbi_uc *out, int out_stride, short data[64]); + void (*YCbCr_to_RGB_kernel)(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step); + stbi_uc *(*resample_row_hv_2_kernel)(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs); +} stbi__jpeg; + +static int stbi__build_huffman(stbi__huffman *h, int *count) +{ + int i,j,k=0; + unsigned int code; + // build size list for each symbol (from JPEG spec) + for (i=0; i < 16; ++i) { + for (j=0; j < count[i]; ++j) { + h->size[k++] = (stbi_uc) (i+1); + if(k >= 257) return stbi__err("bad size list","Corrupt JPEG"); + } + } + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for(j=1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (stbi__uint16) (code++); + if (code-1 >= (1u << j)) return stbi__err("bad code lengths","Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16-j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i=0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS-s); + int m = 1 << (FAST_BITS-s); + for (j=0; j < m; ++j) { + h->fast[c+j] = (stbi_uc) i; + } + } + } + return 1; +} + +// build a table that decodes both magnitude and value of small ACs in +// one go. +static void stbi__build_fast_ac(stbi__int16 *fast_ac, stbi__huffman *h) +{ + int i; + for (i=0; i < (1 << FAST_BITS); ++i) { + stbi_uc fast = h->fast[i]; + fast_ac[i] = 0; + if (fast < 255) { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; + + if (magbits && len + magbits <= FAST_BITS) { + // magnitude code followed by receive_extend code + int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); + int m = 1 << (magbits - 1); + if (k < m) k += (~0U << magbits) + 1; + // if the result is small enough, we can fit it in fast_ac table + if (k >= -128 && k <= 127) + fast_ac[i] = (stbi__int16) ((k * 256) + (run * 16) + (len + magbits)); + } + } + } +} + +static void stbi__grow_buffer_unsafe(stbi__jpeg *j) +{ + do { + unsigned int b = j->nomore ? 0 : stbi__get8(j->s); + if (b == 0xff) { + int c = stbi__get8(j->s); + while (c == 0xff) c = stbi__get8(j->s); // consume fill bytes + if (c != 0) { + j->marker = (unsigned char) c; + j->nomore = 1; + return; + } + } + j->code_buffer |= b << (24 - j->code_bits); + j->code_bits += 8; + } while (j->code_bits <= 24); +} + +// (1 << n) - 1 +static const stbi__uint32 stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; + +// decode a jpeg huffman value from the bitstream +stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) +{ + unsigned int temp; + int c,k; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + k = h->fast[c]; + if (k < 255) { + int s = h->size[k]; + if (s > j->code_bits) + return -1; + j->code_buffer <<= s; + j->code_bits -= s; + return h->values[k]; + } + + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + temp = j->code_buffer >> 16; + for (k=FAST_BITS+1 ; ; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + j->code_bits -= 16; + return -1; + } + + if (k > j->code_bits) + return -1; + + // convert the huffman code to the symbol id + c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; + if(c < 0 || c >= 256) // symbol id out of bounds! + return -1; + STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + j->code_bits -= k; + j->code_buffer <<= k; + return h->values[c]; +} + +// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); + if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing + + sgn = j->code_buffer >> 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative) + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k + (stbi__jbias[n] & (sgn - 1)); +} + +// get some unsigned bits +stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n) +{ + unsigned int k; + if (j->code_bits < n) stbi__grow_buffer_unsafe(j); + if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k; +} + +stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j) +{ + unsigned int k; + if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); + if (j->code_bits < 1) return 0; // ran out of bits from stream, return 0s intead of continuing + k = j->code_buffer; + j->code_buffer <<= 1; + --j->code_bits; + return k & 0x80000000; +} + +// given a value that's at position X in the zigzag stream, +// where does it appear in the 8x8 matrix coded as row-major? +static const stbi_uc stbi__jpeg_dezigzag[64+15] = +{ + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63 +}; + +// decode one 64-entry block-- +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, stbi__int16 *fac, int b, stbi__uint16 *dequant) +{ + int diff,dc,k; + int t; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0 || t > 15) return stbi__err("bad huffman code","Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data,0,64*sizeof(data[0])); + + diff = t ? stbi__extend_receive(j, t) : 0; + if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta","Corrupt JPEG"); + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + if (!stbi__mul2shorts_valid(dc, dequant[0])) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + data[0] = (short) (dc * dequant[0]); + + // decode AC components, see JPEG spec + k = 1; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available"); + j->code_buffer <<= s; + j->code_bits -= s; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) * dequant[zig]); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) break; // end block + k += 16; + } else { + k += r; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); + } + } + } while (k < 64); + return 1; +} + +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) +{ + int diff,dc; + int t; + if (j->spec_end != 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + if (j->succ_high == 0) { + // first scan for DC coefficient, must be first + memset(data,0,64*sizeof(data[0])); // 0 all the ac values now + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + diff = t ? stbi__extend_receive(j, t) : 0; + + if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta", "Corrupt JPEG"); + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + data[0] = (short) (dc * (1 << j->succ_low)); + } else { + // refinement scan for DC coefficient + if (stbi__jpeg_get_bit(j)) + data[0] += (short) (1 << j->succ_low); + } + return 1; +} + +// @OPTIMIZE: store non-zigzagged during the decode passes, +// and only de-zigzag when dequantizing +static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, stbi__int16 *fac) +{ + int k; + if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->succ_high == 0) { + int shift = j->succ_low; + + if (j->eob_run) { + --j->eob_run; + return 1; + } + + k = j->spec_start; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available"); + j->code_buffer <<= s; + j->code_bits -= s; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) * (1 << shift)); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r); + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + --j->eob_run; + break; + } + k += 16; + } else { + k += r; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) * (1 << shift)); + } + } + } while (k <= j->spec_end); + } else { + // refinement scan for these AC coefficients + + short bit = (short) (1 << j->succ_low); + + if (j->eob_run) { + --j->eob_run; + for (k = j->spec_start; k <= j->spec_end; ++k) { + short *p = &data[stbi__jpeg_dezigzag[k]]; + if (*p != 0) + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } + } else { + k = j->spec_start; + do { + int r,s; + int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r) - 1; + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + r = 64; // force end of block + } else { + // r=15 s=0 should write 16 0s, so we just do + // a run of 15 0s and then write s (which is 0), + // so we don't have to do anything special here + } + } else { + if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); + // sign bit + if (stbi__jpeg_get_bit(j)) + s = bit; + else + s = -bit; + } + + // advance by r + while (k <= j->spec_end) { + short *p = &data[stbi__jpeg_dezigzag[k++]]; + if (*p != 0) { + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } else { + if (r == 0) { + *p = (short) s; + break; + } + --r; + } + } + } while (k <= j->spec_end); + } + } + return 1; +} + +// take a -128..127 value and stbi__clamp it and convert to 0..255 +stbi_inline static stbi_uc stbi__clamp(int x) +{ + // trick to use a single test to catch both cases + if ((unsigned int) x > 255) { + if (x < 0) return 0; + if (x > 255) return 255; + } + return (stbi_uc) x; +} + +#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) * 4096) + +// derived from jidctint -- DCT_ISLOW +#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ + int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2+p3) * stbi__f2f(0.5411961f); \ + t2 = p1 + p3*stbi__f2f(-1.847759065f); \ + t3 = p1 + p2*stbi__f2f( 0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = stbi__fsh(p2+p3); \ + t1 = stbi__fsh(p2-p3); \ + x0 = t0+t3; \ + x3 = t0-t3; \ + x1 = t1+t2; \ + x2 = t1-t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0+t2; \ + p4 = t1+t3; \ + p1 = t0+t3; \ + p2 = t1+t2; \ + p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ + t0 = t0*stbi__f2f( 0.298631336f); \ + t1 = t1*stbi__f2f( 2.053119869f); \ + t2 = t2*stbi__f2f( 3.072711026f); \ + t3 = t3*stbi__f2f( 1.501321110f); \ + p1 = p5 + p1*stbi__f2f(-0.899976223f); \ + p2 = p5 + p2*stbi__f2f(-2.562915447f); \ + p3 = p3*stbi__f2f(-1.961570560f); \ + p4 = p4*stbi__f2f(-0.390180644f); \ + t3 += p1+p4; \ + t2 += p2+p3; \ + t1 += p2+p4; \ + t0 += p1+p3; + +static void stbi__idct_block(stbi_uc *out, int out_stride, short data[64]) +{ + int i,val[64],*v=val; + stbi_uc *o; + short *d = data; + + // columns + for (i=0; i < 8; ++i,++d, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 + && d[40]==0 && d[48]==0 && d[56]==0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0]*4; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } else { + STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; x1 += 512; x2 += 512; x3 += 512; + v[ 0] = (x0+t3) >> 10; + v[56] = (x0-t3) >> 10; + v[ 8] = (x1+t2) >> 10; + v[48] = (x1-t2) >> 10; + v[16] = (x2+t1) >> 10; + v[40] = (x2-t1) >> 10; + v[24] = (x3+t0) >> 10; + v[32] = (x3-t0) >> 10; + } + } + + for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { + // no fast case since the first 1D IDCT spread components out + STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + // so we want to round that, which means adding 0.5 * 1<<17, + // aka 65536. Also, we'll end up with -128 to 127 that we want + // to encode as 0..255 by adding 128, so we'll add that before the shift + x0 += 65536 + (128<<17); + x1 += 65536 + (128<<17); + x2 += 65536 + (128<<17); + x3 += 65536 + (128<<17); + // tried computing the shifts into temps, or'ing the temps to see + // if any were out of range, but that was slower + o[0] = stbi__clamp((x0+t3) >> 17); + o[7] = stbi__clamp((x0-t3) >> 17); + o[1] = stbi__clamp((x1+t2) >> 17); + o[6] = stbi__clamp((x1-t2) >> 17); + o[2] = stbi__clamp((x2+t1) >> 17); + o[5] = stbi__clamp((x2-t1) >> 17); + o[3] = stbi__clamp((x3+t0) >> 17); + o[4] = stbi__clamp((x3-t0) >> 17); + } +} + +#ifdef STBI_SSE2 +// sse2 integer IDCT. not the fastest possible implementation but it +// produces bit-identical results to the generic C version so it's +// fully "transparent". +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + // This is constructed to match our regular (generic) integer IDCT exactly. + __m128i row0, row1, row2, row3, row4, row5, row6, row7; + __m128i tmp; + + // dot product constant: even elems=x, odd elems=y + #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) + + // out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) + // out(1) = c1[even]*x + c1[odd]*y + #define dct_rot(out0,out1, x,y,c0,c1) \ + __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ + __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ + __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ + __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ + __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ + __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) + + // out = in << 12 (in 16-bit, out 32-bit) + #define dct_widen(out, in) \ + __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ + __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) + + // wide add + #define dct_wadd(out, a, b) \ + __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_add_epi32(a##_h, b##_h) + + // wide sub + #define dct_wsub(out, a, b) \ + __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) + + // butterfly a/b, add bias, then shift by "s" and pack + #define dct_bfly32o(out0, out1, a,b,bias,s) \ + { \ + __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ + __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ + dct_wadd(sum, abiased, b); \ + dct_wsub(dif, abiased, b); \ + out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ + out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ + } + + // 8-bit interleave step (for transposes) + #define dct_interleave8(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi8(a, b); \ + b = _mm_unpackhi_epi8(tmp, b) + + // 16-bit interleave step (for transposes) + #define dct_interleave16(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi16(a, b); \ + b = _mm_unpackhi_epi16(tmp, b) + + #define dct_pass(bias,shift) \ + do { \ + /* even part */ \ + dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ + __m128i sum04 = _mm_add_epi16(row0, row4); \ + __m128i dif04 = _mm_sub_epi16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ + dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ + __m128i sum17 = _mm_add_epi16(row1, row7); \ + __m128i sum35 = _mm_add_epi16(row3, row5); \ + dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ + dct_wadd(x4, y0o, y4o); \ + dct_wadd(x5, y1o, y5o); \ + dct_wadd(x6, y2o, y5o); \ + dct_wadd(x7, y3o, y4o); \ + dct_bfly32o(row0,row7, x0,x7,bias,shift); \ + dct_bfly32o(row1,row6, x1,x6,bias,shift); \ + dct_bfly32o(row2,row5, x2,x5,bias,shift); \ + dct_bfly32o(row3,row4, x3,x4,bias,shift); \ + } while ( 0 ) + + __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); + __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); + __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); + __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); + __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); + __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); + __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); + __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); + + // rounding biases in column/row passes, see stbi__idct_block for explanation. + __m128i bias_0 = _mm_set1_epi32(512); + __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); + + // load + row0 = _mm_load_si128((const __m128i *) (data + 0*8)); + row1 = _mm_load_si128((const __m128i *) (data + 1*8)); + row2 = _mm_load_si128((const __m128i *) (data + 2*8)); + row3 = _mm_load_si128((const __m128i *) (data + 3*8)); + row4 = _mm_load_si128((const __m128i *) (data + 4*8)); + row5 = _mm_load_si128((const __m128i *) (data + 5*8)); + row6 = _mm_load_si128((const __m128i *) (data + 6*8)); + row7 = _mm_load_si128((const __m128i *) (data + 7*8)); + + // column pass + dct_pass(bias_0, 10); + + { + // 16bit 8x8 transpose pass 1 + dct_interleave16(row0, row4); + dct_interleave16(row1, row5); + dct_interleave16(row2, row6); + dct_interleave16(row3, row7); + + // transpose pass 2 + dct_interleave16(row0, row2); + dct_interleave16(row1, row3); + dct_interleave16(row4, row6); + dct_interleave16(row5, row7); + + // transpose pass 3 + dct_interleave16(row0, row1); + dct_interleave16(row2, row3); + dct_interleave16(row4, row5); + dct_interleave16(row6, row7); + } + + // row pass + dct_pass(bias_1, 17); + + { + // pack + __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 + __m128i p1 = _mm_packus_epi16(row2, row3); + __m128i p2 = _mm_packus_epi16(row4, row5); + __m128i p3 = _mm_packus_epi16(row6, row7); + + // 8bit 8x8 transpose pass 1 + dct_interleave8(p0, p2); // a0e0a1e1... + dct_interleave8(p1, p3); // c0g0c1g1... + + // transpose pass 2 + dct_interleave8(p0, p1); // a0c0e0g0... + dct_interleave8(p2, p3); // b0d0f0h0... + + // transpose pass 3 + dct_interleave8(p0, p2); // a0b0c0d0... + dct_interleave8(p1, p3); // a4b4c4d4... + + // store + _mm_storel_epi64((__m128i *) out, p0); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p2); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p1); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p3); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); + } + +#undef dct_const +#undef dct_rot +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_interleave8 +#undef dct_interleave16 +#undef dct_pass +} + +#endif // STBI_SSE2 + +#ifdef STBI_NEON + +// NEON integer IDCT. should produce bit-identical +// results to the generic C version. +static void stbi__idct_simd(stbi_uc *out, int out_stride, short data[64]) +{ + int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; + + int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); + +#define dct_long_mul(out, inq, coeff) \ + int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) + +#define dct_long_mac(out, acc, inq, coeff) \ + int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) + +#define dct_widen(out, inq) \ + int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ + int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) + +// wide add +#define dct_wadd(out, a, b) \ + int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vaddq_s32(a##_h, b##_h) + +// wide sub +#define dct_wsub(out, a, b) \ + int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vsubq_s32(a##_h, b##_h) + +// butterfly a/b, then shift using "shiftop" by "s" and pack +#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ + do { \ + dct_wadd(sum, a, b); \ + dct_wsub(dif, a, b); \ + out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ + out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ + } while ( 0 ) + +#define dct_pass(shiftop, shift) \ + do { \ + /* even part */ \ + int16x8_t sum26 = vaddq_s16(row2, row6); \ + dct_long_mul(p1e, sum26, rot0_0); \ + dct_long_mac(t2e, p1e, row6, rot0_1); \ + dct_long_mac(t3e, p1e, row2, rot0_2); \ + int16x8_t sum04 = vaddq_s16(row0, row4); \ + int16x8_t dif04 = vsubq_s16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + int16x8_t sum15 = vaddq_s16(row1, row5); \ + int16x8_t sum17 = vaddq_s16(row1, row7); \ + int16x8_t sum35 = vaddq_s16(row3, row5); \ + int16x8_t sum37 = vaddq_s16(row3, row7); \ + int16x8_t sumodd = vaddq_s16(sum17, sum35); \ + dct_long_mul(p5o, sumodd, rot1_0); \ + dct_long_mac(p1o, p5o, sum17, rot1_1); \ + dct_long_mac(p2o, p5o, sum35, rot1_2); \ + dct_long_mul(p3o, sum37, rot2_0); \ + dct_long_mul(p4o, sum15, rot2_1); \ + dct_wadd(sump13o, p1o, p3o); \ + dct_wadd(sump24o, p2o, p4o); \ + dct_wadd(sump23o, p2o, p3o); \ + dct_wadd(sump14o, p1o, p4o); \ + dct_long_mac(x4, sump13o, row7, rot3_0); \ + dct_long_mac(x5, sump24o, row5, rot3_1); \ + dct_long_mac(x6, sump23o, row3, rot3_2); \ + dct_long_mac(x7, sump14o, row1, rot3_3); \ + dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ + dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ + dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ + dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ + } while ( 0 ) + + // load + row0 = vld1q_s16(data + 0*8); + row1 = vld1q_s16(data + 1*8); + row2 = vld1q_s16(data + 2*8); + row3 = vld1q_s16(data + 3*8); + row4 = vld1q_s16(data + 4*8); + row5 = vld1q_s16(data + 5*8); + row6 = vld1q_s16(data + 6*8); + row7 = vld1q_s16(data + 7*8); + + // add DC bias + row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); + + // column pass + dct_pass(vrshrn_n_s32, 10); + + // 16bit 8x8 transpose + { +// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. +// whether compilers actually get this is another story, sadly. +#define dct_trn16(x, y) do { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } while ( 0 ) +#define dct_trn32(x, y) do { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } while ( 0 ) +#define dct_trn64(x, y) do { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } while ( 0 ) + + // pass 1 + dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 + dct_trn16(row2, row3); + dct_trn16(row4, row5); + dct_trn16(row6, row7); + + // pass 2 + dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 + dct_trn32(row1, row3); + dct_trn32(row4, row6); + dct_trn32(row5, row7); + + // pass 3 + dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 + dct_trn64(row1, row5); + dct_trn64(row2, row6); + dct_trn64(row3, row7); + +#undef dct_trn16 +#undef dct_trn32 +#undef dct_trn64 + } + + // row pass + // vrshrn_n_s32 only supports shifts up to 16, we need + // 17. so do a non-rounding shift of 16 first then follow + // up with a rounding shift by 1. + dct_pass(vshrn_n_s32, 16); + + { + // pack and round + uint8x8_t p0 = vqrshrun_n_s16(row0, 1); + uint8x8_t p1 = vqrshrun_n_s16(row1, 1); + uint8x8_t p2 = vqrshrun_n_s16(row2, 1); + uint8x8_t p3 = vqrshrun_n_s16(row3, 1); + uint8x8_t p4 = vqrshrun_n_s16(row4, 1); + uint8x8_t p5 = vqrshrun_n_s16(row5, 1); + uint8x8_t p6 = vqrshrun_n_s16(row6, 1); + uint8x8_t p7 = vqrshrun_n_s16(row7, 1); + + // again, these can translate into one instruction, but often don't. +#define dct_trn8_8(x, y) do { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } while ( 0 ) +#define dct_trn8_16(x, y) do { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } while ( 0 ) +#define dct_trn8_32(x, y) do { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } while ( 0 ) + + // sadly can't use interleaved stores here since we only write + // 8 bytes to each scan line! + + // 8x8 8-bit transpose pass 1 + dct_trn8_8(p0, p1); + dct_trn8_8(p2, p3); + dct_trn8_8(p4, p5); + dct_trn8_8(p6, p7); + + // pass 2 + dct_trn8_16(p0, p2); + dct_trn8_16(p1, p3); + dct_trn8_16(p4, p6); + dct_trn8_16(p5, p7); + + // pass 3 + dct_trn8_32(p0, p4); + dct_trn8_32(p1, p5); + dct_trn8_32(p2, p6); + dct_trn8_32(p3, p7); + + // store + vst1_u8(out, p0); out += out_stride; + vst1_u8(out, p1); out += out_stride; + vst1_u8(out, p2); out += out_stride; + vst1_u8(out, p3); out += out_stride; + vst1_u8(out, p4); out += out_stride; + vst1_u8(out, p5); out += out_stride; + vst1_u8(out, p6); out += out_stride; + vst1_u8(out, p7); + +#undef dct_trn8_8 +#undef dct_trn8_16 +#undef dct_trn8_32 + } + +#undef dct_long_mul +#undef dct_long_mac +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_pass +} + +#endif // STBI_NEON + +#define STBI__MARKER_none 0xff +// if there's a pending marker from the entropy stream, return that +// otherwise, fetch from the stream and get a marker. if there's no +// marker, return 0xff, which is never a valid marker value +static stbi_uc stbi__get_marker(stbi__jpeg *j) +{ + stbi_uc x; + if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } + x = stbi__get8(j->s); + if (x != 0xff) return STBI__MARKER_none; + while (x == 0xff) + x = stbi__get8(j->s); // consume repeated 0xff fill bytes + return x; +} + +// in each scan, we'll have scan_n components, and the order +// of the components is specified by order[] +#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +// after a restart interval, stbi__jpeg_reset the entropy decoder and +// the dc prediction +static void stbi__jpeg_reset(stbi__jpeg *j) +{ + j->code_bits = 0; + j->code_buffer = 0; + j->nomore = 0; + j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = j->img_comp[3].dc_pred = 0; + j->marker = STBI__MARKER_none; + j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; + j->eob_run = 0; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int stbi__parse_entropy_coded_data(stbi__jpeg *z) +{ + stbi__jpeg_reset(z); + if (!z->progressive) { + if (z->scan_n == 1) { + int i,j; + STBI_SIMD_ALIGN(short, data[64]); + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i,j,k,x,y; + STBI_SIMD_ALIGN(short, data[64]); + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x)*8; + int y2 = (j*z->img_comp[n].v + y)*8; + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } else { + if (z->scan_n == 1) { + int i,j; + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + if (z->spec_start == 0) { + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } else { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) + return 0; + } + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i,j,k,x,y; + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x); + int y2 = (j*z->img_comp[n].v + y); + short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } + } +} + +static void stbi__jpeg_dequantize(short *data, stbi__uint16 *dequant) +{ + int i; + for (i=0; i < 64; ++i) + data[i] *= dequant[i]; +} + +static void stbi__jpeg_finish(stbi__jpeg *z) +{ + if (z->progressive) { + // dequantize and idct the data + int i,j,n; + for (n=0; n < z->s->img_n; ++n) { + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + } + } + } + } +} + +static int stbi__process_marker(stbi__jpeg *z, int m) +{ + int L; + switch (m) { + case STBI__MARKER_none: // no marker found + return stbi__err("expected marker","Corrupt JPEG"); + + case 0xDD: // DRI - specify restart interval + if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); + z->restart_interval = stbi__get16be(z->s); + return 1; + + case 0xDB: // DQT - define quantization table + L = stbi__get16be(z->s)-2; + while (L > 0) { + int q = stbi__get8(z->s); + int p = q >> 4, sixteen = (p != 0); + int t = q & 15,i; + if (p != 0 && p != 1) return stbi__err("bad DQT type","Corrupt JPEG"); + if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); + + for (i=0; i < 64; ++i) + z->dequant[t][stbi__jpeg_dezigzag[i]] = (stbi__uint16)(sixteen ? stbi__get16be(z->s) : stbi__get8(z->s)); + L -= (sixteen ? 129 : 65); + } + return L==0; + + case 0xC4: // DHT - define huffman table + L = stbi__get16be(z->s)-2; + while (L > 0) { + stbi_uc *v; + int sizes[16],i,n=0; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); + for (i=0; i < 16; ++i) { + sizes[i] = stbi__get8(z->s); + n += sizes[i]; + } + if(n > 256) return stbi__err("bad DHT header","Corrupt JPEG"); // Loop over i < n would write past end of values! + L -= 17; + if (tc == 0) { + if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; + v = z->huff_dc[th].values; + } else { + if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; + v = z->huff_ac[th].values; + } + for (i=0; i < n; ++i) + v[i] = stbi__get8(z->s); + if (tc != 0) + stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + L -= n; + } + return L==0; + } + + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + L = stbi__get16be(z->s); + if (L < 2) { + if (m == 0xFE) + return stbi__err("bad COM len","Corrupt JPEG"); + else + return stbi__err("bad APP len","Corrupt JPEG"); + } + L -= 2; + + if (m == 0xE0 && L >= 5) { // JFIF APP0 segment + static const unsigned char tag[5] = {'J','F','I','F','\0'}; + int ok = 1; + int i; + for (i=0; i < 5; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 5; + if (ok) + z->jfif = 1; + } else if (m == 0xEE && L >= 12) { // Adobe APP14 segment + static const unsigned char tag[6] = {'A','d','o','b','e','\0'}; + int ok = 1; + int i; + for (i=0; i < 6; ++i) + if (stbi__get8(z->s) != tag[i]) + ok = 0; + L -= 6; + if (ok) { + stbi__get8(z->s); // version + stbi__get16be(z->s); // flags0 + stbi__get16be(z->s); // flags1 + z->app14_color_transform = stbi__get8(z->s); // color transform + L -= 6; + } + } + + stbi__skip(z->s, L); + return 1; + } + + return stbi__err("unknown marker","Corrupt JPEG"); +} + +// after we see SOS +static int stbi__process_scan_header(stbi__jpeg *z) +{ + int i; + int Ls = stbi__get16be(z->s); + z->scan_n = stbi__get8(z->s); + if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) return stbi__err("bad SOS component count","Corrupt JPEG"); + if (Ls != 6+2*z->scan_n) return stbi__err("bad SOS len","Corrupt JPEG"); + for (i=0; i < z->scan_n; ++i) { + int id = stbi__get8(z->s), which; + int q = stbi__get8(z->s); + for (which = 0; which < z->s->img_n; ++which) + if (z->img_comp[which].id == id) + break; + if (which == z->s->img_n) return 0; // no match + z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) return stbi__err("bad DC huff","Corrupt JPEG"); + z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) return stbi__err("bad AC huff","Corrupt JPEG"); + z->order[i] = which; + } + + { + int aa; + z->spec_start = stbi__get8(z->s); + z->spec_end = stbi__get8(z->s); // should be 63, but might be 0 + aa = stbi__get8(z->s); + z->succ_high = (aa >> 4); + z->succ_low = (aa & 15); + if (z->progressive) { + if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) + return stbi__err("bad SOS", "Corrupt JPEG"); + } else { + if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); + z->spec_end = 63; + } + } + + return 1; +} + +static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why) +{ + int i; + for (i=0; i < ncomp; ++i) { + if (z->img_comp[i].raw_data) { + STBI_FREE(z->img_comp[i].raw_data); + z->img_comp[i].raw_data = NULL; + z->img_comp[i].data = NULL; + } + if (z->img_comp[i].raw_coeff) { + STBI_FREE(z->img_comp[i].raw_coeff); + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].coeff = 0; + } + if (z->img_comp[i].linebuf) { + STBI_FREE(z->img_comp[i].linebuf); + z->img_comp[i].linebuf = NULL; + } + } + return why; +} + +static int stbi__process_frame_header(stbi__jpeg *z, int scan) +{ + stbi__context *s = z->s; + int Lf,p,i,q, h_max=1,v_max=1,c; + Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG + p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline + s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG + s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires + if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); + c = stbi__get8(s); + if (c != 3 && c != 1 && c != 4) return stbi__err("bad component count","Corrupt JPEG"); + s->img_n = c; + for (i=0; i < c; ++i) { + z->img_comp[i].data = NULL; + z->img_comp[i].linebuf = NULL; + } + + if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); + + z->rgb = 0; + for (i=0; i < s->img_n; ++i) { + static const unsigned char rgb[3] = { 'R', 'G', 'B' }; + z->img_comp[i].id = stbi__get8(s); + if (s->img_n == 3 && z->img_comp[i].id == rgb[i]) + ++z->rgb; + q = stbi__get8(s); + z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); + z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); + z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); + } + + if (scan != STBI__SCAN_load) return 1; + + if (!stbi__mad3sizes_valid(s->img_x, s->img_y, s->img_n, 0)) return stbi__err("too large", "Image too large to decode"); + + for (i=0; i < s->img_n; ++i) { + if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; + if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; + } + + // check that plane subsampling factors are integer ratios; our resamplers can't deal with fractional ratios + // and I've never seen a non-corrupted JPEG file actually use them + for (i=0; i < s->img_n; ++i) { + if (h_max % z->img_comp[i].h != 0) return stbi__err("bad H","Corrupt JPEG"); + if (v_max % z->img_comp[i].v != 0) return stbi__err("bad V","Corrupt JPEG"); + } + + // compute interleaved mcu info + z->img_h_max = h_max; + z->img_v_max = v_max; + z->img_mcu_w = h_max * 8; + z->img_mcu_h = v_max * 8; + // these sizes can't be more than 17 bits + z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; + z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; + + for (i=0; i < s->img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; + z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + // + // img_mcu_x, img_mcu_y: <=17 bits; comp[i].h and .v are <=4 (checked earlier) + // so these muls can't overflow with 32-bit ints (which we require) + z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; + z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; + z->img_comp[i].coeff = 0; + z->img_comp[i].raw_coeff = 0; + z->img_comp[i].linebuf = NULL; + z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15); + if (z->img_comp[i].raw_data == NULL) + return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); + // align blocks for idct using mmx/sse + z->img_comp[i].data = (stbi_uc*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); + if (z->progressive) { + // w2, h2 are multiples of 8 (see above) + z->img_comp[i].coeff_w = z->img_comp[i].w2 / 8; + z->img_comp[i].coeff_h = z->img_comp[i].h2 / 8; + z->img_comp[i].raw_coeff = stbi__malloc_mad3(z->img_comp[i].w2, z->img_comp[i].h2, sizeof(short), 15); + if (z->img_comp[i].raw_coeff == NULL) + return stbi__free_jpeg_components(z, i+1, stbi__err("outofmem", "Out of memory")); + z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); + } + } + + return 1; +} + +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define stbi__DNL(x) ((x) == 0xdc) +#define stbi__SOI(x) ((x) == 0xd8) +#define stbi__EOI(x) ((x) == 0xd9) +#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define stbi__SOS(x) ((x) == 0xda) + +#define stbi__SOF_progressive(x) ((x) == 0xc2) + +static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) +{ + int m; + z->jfif = 0; + z->app14_color_transform = -1; // valid values are 0,1,2 + z->marker = STBI__MARKER_none; // initialize cached marker to empty + m = stbi__get_marker(z); + if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); + if (scan == STBI__SCAN_type) return 1; + m = stbi__get_marker(z); + while (!stbi__SOF(m)) { + if (!stbi__process_marker(z,m)) return 0; + m = stbi__get_marker(z); + while (m == STBI__MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); + m = stbi__get_marker(z); + } + } + z->progressive = stbi__SOF_progressive(m); + if (!stbi__process_frame_header(z, scan)) return 0; + return 1; +} + +static stbi_uc stbi__skip_jpeg_junk_at_end(stbi__jpeg *j) +{ + // some JPEGs have junk at end, skip over it but if we find what looks + // like a valid marker, resume there + while (!stbi__at_eof(j->s)) { + stbi_uc x = stbi__get8(j->s); + while (x == 0xff) { // might be a marker + if (stbi__at_eof(j->s)) return STBI__MARKER_none; + x = stbi__get8(j->s); + if (x != 0x00 && x != 0xff) { + // not a stuffed zero or lead-in to another marker, looks + // like an actual marker, return it + return x; + } + // stuffed zero has x=0 now which ends the loop, meaning we go + // back to regular scan loop. + // repeated 0xff keeps trying to read the next byte of the marker. + } + } + return STBI__MARKER_none; +} + +// decode image to YCbCr format +static int stbi__decode_jpeg_image(stbi__jpeg *j) +{ + int m; + for (m = 0; m < 4; m++) { + j->img_comp[m].raw_data = NULL; + j->img_comp[m].raw_coeff = NULL; + } + j->restart_interval = 0; + if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; + m = stbi__get_marker(j); + while (!stbi__EOI(m)) { + if (stbi__SOS(m)) { + if (!stbi__process_scan_header(j)) return 0; + if (!stbi__parse_entropy_coded_data(j)) return 0; + if (j->marker == STBI__MARKER_none ) { + j->marker = stbi__skip_jpeg_junk_at_end(j); + // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 + } + m = stbi__get_marker(j); + if (STBI__RESTART(m)) + m = stbi__get_marker(j); + } else if (stbi__DNL(m)) { + int Ld = stbi__get16be(j->s); + stbi__uint32 NL = stbi__get16be(j->s); + if (Ld != 4) return stbi__err("bad DNL len", "Corrupt JPEG"); + if (NL != j->s->img_y) return stbi__err("bad DNL height", "Corrupt JPEG"); + m = stbi__get_marker(j); + } else { + if (!stbi__process_marker(j, m)) return 1; + m = stbi__get_marker(j); + } + } + if (j->progressive) + stbi__jpeg_finish(j); + return 1; +} + +// static jfif-centered resampling (across block boundaries) + +typedef stbi_uc *(*resample_row_func)(stbi_uc *out, stbi_uc *in0, stbi_uc *in1, + int w, int hs); + +#define stbi__div4(x) ((stbi_uc) ((x) >> 2)) + +static stbi_uc *resample_row_1(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + STBI_NOTUSED(out); + STBI_NOTUSED(in_far); + STBI_NOTUSED(w); + STBI_NOTUSED(hs); + return in_near; +} + +static stbi_uc* stbi__resample_row_v_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples vertically for every one in input + int i; + STBI_NOTUSED(hs); + for (i=0; i < w; ++i) + out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); + return out; +} + +static stbi_uc* stbi__resample_row_h_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate two samples horizontally for every one in input + int i; + stbi_uc *input = in_near; + + if (w == 1) { + // if only one sample, can't do any interpolation + out[0] = out[1] = input[0]; + return out; + } + + out[0] = input[0]; + out[1] = stbi__div4(input[0]*3 + input[1] + 2); + for (i=1; i < w-1; ++i) { + int n = 3*input[i]+2; + out[i*2+0] = stbi__div4(n+input[i-1]); + out[i*2+1] = stbi__div4(n+input[i+1]); + } + out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); + out[i*2+1] = input[w-1]; + + STBI_NOTUSED(in_far); + STBI_NOTUSED(hs); + + return out; +} + +#define stbi__div16(x) ((stbi_uc) ((x) >> 4)) + +static stbi_uc *stbi__resample_row_hv_2(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i,t0,t1; + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + out[0] = stbi__div4(t1+2); + for (i=1; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static stbi_uc *stbi__resample_row_hv_2_simd(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i=0,t0,t1; + + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + // process groups of 8 pixels for as long as we can. + // note we can't handle the last pixel in a row in this loop + // because we need to handle the filter boundary conditions. + for (; i < ((w-1) & ~7); i += 8) { +#if defined(STBI_SSE2) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + __m128i zero = _mm_setzero_si128(); + __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); + __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); + __m128i farw = _mm_unpacklo_epi8(farb, zero); + __m128i nearw = _mm_unpacklo_epi8(nearb, zero); + __m128i diff = _mm_sub_epi16(farw, nearw); + __m128i nears = _mm_slli_epi16(nearw, 2); + __m128i curr = _mm_add_epi16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + __m128i prv0 = _mm_slli_si128(curr, 2); + __m128i nxt0 = _mm_srli_si128(curr, 2); + __m128i prev = _mm_insert_epi16(prv0, t1, 0); + __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + __m128i bias = _mm_set1_epi16(8); + __m128i curs = _mm_slli_epi16(curr, 2); + __m128i prvd = _mm_sub_epi16(prev, curr); + __m128i nxtd = _mm_sub_epi16(next, curr); + __m128i curb = _mm_add_epi16(curs, bias); + __m128i even = _mm_add_epi16(prvd, curb); + __m128i odd = _mm_add_epi16(nxtd, curb); + + // interleave even and odd pixels, then undo scaling. + __m128i int0 = _mm_unpacklo_epi16(even, odd); + __m128i int1 = _mm_unpackhi_epi16(even, odd); + __m128i de0 = _mm_srli_epi16(int0, 4); + __m128i de1 = _mm_srli_epi16(int1, 4); + + // pack and write output + __m128i outv = _mm_packus_epi16(de0, de1); + _mm_storeu_si128((__m128i *) (out + i*2), outv); +#elif defined(STBI_NEON) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + uint8x8_t farb = vld1_u8(in_far + i); + uint8x8_t nearb = vld1_u8(in_near + i); + int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); + int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); + int16x8_t curr = vaddq_s16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + int16x8_t prv0 = vextq_s16(curr, curr, 7); + int16x8_t nxt0 = vextq_s16(curr, curr, 1); + int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); + int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); + + // horizontal filter, polyphase implementation since it's convenient: + // even pixels = 3*cur + prev = cur*4 + (prev - cur) + // odd pixels = 3*cur + next = cur*4 + (next - cur) + // note the shared term. + int16x8_t curs = vshlq_n_s16(curr, 2); + int16x8_t prvd = vsubq_s16(prev, curr); + int16x8_t nxtd = vsubq_s16(next, curr); + int16x8_t even = vaddq_s16(curs, prvd); + int16x8_t odd = vaddq_s16(curs, nxtd); + + // undo scaling and round, then store with even/odd phases interleaved + uint8x8x2_t o; + o.val[0] = vqrshrun_n_s16(even, 4); + o.val[1] = vqrshrun_n_s16(odd, 4); + vst2_u8(out + i*2, o); +#endif + + // "previous" value for next iter + t1 = 3*in_near[i+7] + in_far[i+7]; + } + + t0 = t1; + t1 = 3*in_near[i] + in_far[i]; + out[i*2] = stbi__div16(3*t1 + t0 + 8); + + for (++i; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} +#endif + +static stbi_uc *stbi__resample_row_generic(stbi_uc *out, stbi_uc *in_near, stbi_uc *in_far, int w, int hs) +{ + // resample with nearest-neighbor + int i,j; + STBI_NOTUSED(in_far); + for (i=0; i < w; ++i) + for (j=0; j < hs; ++j) + out[i*hs+j] = in_near[i]; + return out; +} + +// this is a reduced-precision calculation of YCbCr-to-RGB introduced +// to make sure the code produces the same results in both SIMD and scalar +#define stbi__float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) +static void stbi__YCbCr_to_RGB_row(stbi_uc *out, const stbi_uc *y, const stbi_uc *pcb, const stbi_uc *pcr, int count, int step) +{ + int i; + for (i=0; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* stbi__float2fixed(1.40200f); + g = y_fixed + (cr*-stbi__float2fixed(0.71414f)) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static void stbi__YCbCr_to_RGB_simd(stbi_uc *out, stbi_uc const *y, stbi_uc const *pcb, stbi_uc const *pcr, int count, int step) +{ + int i = 0; + +#ifdef STBI_SSE2 + // step == 3 is pretty ugly on the final interleave, and i'm not convinced + // it's useful in practice (you wouldn't use it for textures, for example). + // so just accelerate step == 4 case. + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + __m128i signflip = _mm_set1_epi8(-0x80); + __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); + __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); + __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); + __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); + __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); + __m128i xw = _mm_set1_epi16(255); // alpha channel + + for (; i+7 < count; i += 8) { + // load + __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); + __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); + __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + + // unpack to short (and left-shift cr, cb by 8) + __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); + __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); + __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); + + // color transform + __m128i yws = _mm_srli_epi16(yw, 4); + __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); + __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); + __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); + __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); + __m128i rws = _mm_add_epi16(cr0, yws); + __m128i gwt = _mm_add_epi16(cb0, yws); + __m128i bws = _mm_add_epi16(yws, cb1); + __m128i gws = _mm_add_epi16(gwt, cr1); + + // descale + __m128i rw = _mm_srai_epi16(rws, 4); + __m128i bw = _mm_srai_epi16(bws, 4); + __m128i gw = _mm_srai_epi16(gws, 4); + + // back to byte, set up for transpose + __m128i brb = _mm_packus_epi16(rw, bw); + __m128i gxb = _mm_packus_epi16(gw, xw); + + // transpose to interleave channels + __m128i t0 = _mm_unpacklo_epi8(brb, gxb); + __m128i t1 = _mm_unpackhi_epi8(brb, gxb); + __m128i o0 = _mm_unpacklo_epi16(t0, t1); + __m128i o1 = _mm_unpackhi_epi16(t0, t1); + + // store + _mm_storeu_si128((__m128i *) (out + 0), o0); + _mm_storeu_si128((__m128i *) (out + 16), o1); + out += 32; + } + } +#endif + +#ifdef STBI_NEON + // in this version, step=3 support would be easy to add. but is there demand? + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + uint8x8_t signflip = vdup_n_u8(0x80); + int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); + int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); + int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); + int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); + + for (; i+7 < count; i += 8) { + // load + uint8x8_t y_bytes = vld1_u8(y + i); + uint8x8_t cr_bytes = vld1_u8(pcr + i); + uint8x8_t cb_bytes = vld1_u8(pcb + i); + int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); + int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); + + // expand to s16 + int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); + int16x8_t crw = vshll_n_s8(cr_biased, 7); + int16x8_t cbw = vshll_n_s8(cb_biased, 7); + + // color transform + int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); + int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); + int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); + int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); + int16x8_t rws = vaddq_s16(yws, cr0); + int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); + int16x8_t bws = vaddq_s16(yws, cb1); + + // undo scaling, round, convert to byte + uint8x8x4_t o; + o.val[0] = vqrshrun_n_s16(rws, 4); + o.val[1] = vqrshrun_n_s16(gws, 4); + o.val[2] = vqrshrun_n_s16(bws, 4); + o.val[3] = vdup_n_u8(255); + + // store, interleaving r/g/b/a + vst4_u8(out, o); + out += 8*4; + } + } +#endif + + for (; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* stbi__float2fixed(1.40200f); + g = y_fixed + cr*-stbi__float2fixed(0.71414f) + ((cb*-stbi__float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* stbi__float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (stbi_uc)r; + out[1] = (stbi_uc)g; + out[2] = (stbi_uc)b; + out[3] = 255; + out += step; + } +} +#endif + +// set up the kernels +static void stbi__setup_jpeg(stbi__jpeg *j) +{ + j->idct_block_kernel = stbi__idct_block; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; + +#ifdef STBI_SSE2 + if (stbi__sse2_available()) { + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } +#endif + +#ifdef STBI_NEON + if (SDL_HasNEON()) { /* SDL change */ + j->idct_block_kernel = stbi__idct_simd; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } /**/ +#endif +} + +// clean up the temporary component buffers +static void stbi__cleanup_jpeg(stbi__jpeg *j) +{ + stbi__free_jpeg_components(j, j->s->img_n, 0); +} + +typedef struct +{ + resample_row_func resample; + stbi_uc *line0,*line1; + int hs,vs; // expansion factor in each axis + int w_lores; // horizontal pixels pre-expansion + int ystep; // how far through vertical expansion we are + int ypos; // which pre-expansion row we're on +} stbi__resample; + +// fast 0..255 * 0..255 => 0..255 rounded multiplication +static stbi_uc stbi__blinn_8x8(stbi_uc x, stbi_uc y) +{ + unsigned int t = x*y + 128; + return (stbi_uc) ((t + (t >>8)) >> 8); +} + +static stbi_uc *output_jpeg_nv12(stbi__jpeg *z, stbi__nv12 *nv12) +{ + unsigned int i,j; + + // Copy the Y plane + if (nv12->pitch == (int)z->s->img_x) { + memcpy(nv12->y, z->img_comp[0].data, z->s->img_y * z->s->img_x); + } else { + for (i=0; i < z->s->img_y; ++i) { + memcpy(nv12->y + i * nv12->pitch, z->img_comp[0].data + i * z->s->img_x, z->s->img_x); + } + } + + if (z->s->img_n == 3) { + // NV12: U and V are interleaved, each subsampled by 2 + const int nv12_hs = 2; + const int nv12_vs = 2; + const int u_hs = (z->img_h_max / z->img_comp[1].h); + const int u_vs = (z->img_v_max / z->img_comp[1].v); + const int v_hs = (z->img_h_max / z->img_comp[2].h); + const int v_vs = (z->img_v_max / z->img_comp[2].v); + for (i=0; i < (z->s->img_y + 1) / 2; ++i) { + stbi_uc *src_u = z->img_comp[1].data + i * (1 + (nv12_vs - u_vs)) * z->img_comp[1].x; + stbi_uc *src_v = z->img_comp[2].data + i * (1 + (nv12_vs - v_vs)) * z->img_comp[2].x; + stbi_uc *dst = nv12->uv + i * nv12->pitch; + for (j=0; j < (z->s->img_x + 1) / 2; ++j) { + *dst++ = *src_u; + src_u += 1 + (nv12_hs - u_hs); + *dst++ = *src_v; + src_v += 1 + (nv12_hs - v_hs); + } + } + } else { + // Grayscale + for (i=0; i < (z->s->img_y + 1) / 2; ++i) { + memset(nv12->uv + i * nv12->pitch, 0x80808080, ((z->s->img_x + 1) / 2) * 2); + } + } + + return nv12->y; +} + +static stbi_uc *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp, stbi__nv12 *nv12) +{ + int n, decode_n, is_rgb; + z->s->img_n = 0; // make stbi__cleanup_jpeg safe + + // validate req_comp + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source, but leave in YCbCr format + if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } + + // determine actual number of components to generate + n = req_comp ? req_comp : z->s->img_n >= 3 ? 3 : 1; + + is_rgb = z->s->img_n == 3 && (z->rgb == 3 || (z->app14_color_transform == 0 && !z->jfif)); + + if (z->s->img_n == 3 && n < 3 && !is_rgb) + decode_n = 1; + else + decode_n = z->s->img_n; + + // nothing to do if no components requested; check this now to avoid + // accessing uninitialized coutput[0] later + if (decode_n <= 0) { stbi__cleanup_jpeg(z); return NULL; } + + // resample and color-convert + { + int k; + unsigned int i,j; + stbi_uc *output; + stbi_uc *coutput[4] = { NULL, NULL, NULL, NULL }; + + stbi__resample res_comp[4]; + + if (nv12) { + if (nv12->w != (int)z->s->img_x || nv12->h != (int)z->s->img_y) { + stbi__cleanup_jpeg(z); + return stbi__errpuc("badsize", "Unexpected size"); + } + + if (is_rgb) { + stbi__cleanup_jpeg(z); + return stbi__errpuc("rgbtonv12", "Can't convert RGB to NV12"); + } + + output = output_jpeg_nv12(z, nv12); + } else { + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + + // allocate line buffer big enough for upsampling off the edges + // with upsample factor of 4 + z->img_comp[k].linebuf = (stbi_uc *) stbi__malloc(z->s->img_x + 3); + if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs-1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + + if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; + else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; + else r->resample = stbi__resample_row_generic; + } + + // can't error after this so, this is safe + output = (stbi_uc *) stbi__malloc_mad3(n, z->s->img_x, z->s->img_y, 1); + if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + // now go ahead and resample + for (j=0; j < z->s->img_y; ++j) { + stbi_uc *out = output + n * z->s->img_x * j; + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + int y_bot = r->ystep >= (r->vs >> 1); + coutput[k] = r->resample(z->img_comp[k].linebuf, + y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, + r->w_lores, r->hs); + if (++r->ystep >= r->vs) { + r->ystep = 0; + r->line0 = r->line1; + if (++r->ypos < z->img_comp[k].y) + r->line1 += z->img_comp[k].w2; + } + } + if (n >= 3) { + stbi_uc *y = coutput[0]; + if (z->s->img_n == 3) { + if (is_rgb) { + for (i=0; i < z->s->img_x; ++i) { + out[0] = y[i]; + out[1] = coutput[1][i]; + out[2] = coutput[2][i]; + out[3] = 255; + out += n; + } + } else { + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } else if (z->s->img_n == 4) { + if (z->app14_color_transform == 0) { // CMYK + for (i=0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(coutput[0][i], m); + out[1] = stbi__blinn_8x8(coutput[1][i], m); + out[2] = stbi__blinn_8x8(coutput[2][i], m); + out[3] = 255; + out += n; + } + } else if (z->app14_color_transform == 2) { // YCCK + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + for (i=0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + out[0] = stbi__blinn_8x8(255 - out[0], m); + out[1] = stbi__blinn_8x8(255 - out[1], m); + out[2] = stbi__blinn_8x8(255 - out[2], m); + out += n; + } + } else { // YCbCr + alpha? Ignore the fourth channel for now + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } + } else + for (i=0; i < z->s->img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n==3 + out += n; + } + } else { + if (is_rgb) { + if (n == 1) + for (i=0; i < z->s->img_x; ++i) + *out++ = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + else { + for (i=0; i < z->s->img_x; ++i, out += 2) { + out[0] = stbi__compute_y(coutput[0][i], coutput[1][i], coutput[2][i]); + out[1] = 255; + } + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 0) { + for (i=0; i < z->s->img_x; ++i) { + stbi_uc m = coutput[3][i]; + stbi_uc r = stbi__blinn_8x8(coutput[0][i], m); + stbi_uc g = stbi__blinn_8x8(coutput[1][i], m); + stbi_uc b = stbi__blinn_8x8(coutput[2][i], m); + out[0] = stbi__compute_y(r, g, b); + out[1] = 255; + out += n; + } + } else if (z->s->img_n == 4 && z->app14_color_transform == 2) { + for (i=0; i < z->s->img_x; ++i) { + out[0] = stbi__blinn_8x8(255 - coutput[0][i], coutput[3][i]); + out[1] = 255; + out += n; + } + } else { + stbi_uc *y = coutput[0]; + if (n == 1) + for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; + else + for (i=0; i < z->s->img_x; ++i) { *out++ = y[i]; *out++ = 255; } + } + } + } + } + stbi__cleanup_jpeg(z); + *out_x = z->s->img_x; + *out_y = z->s->img_y; + if (comp) *comp = z->s->img_n >= 3 ? 3 : 1; // report original components, not output + return output; + } +} + +static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__nv12 *nv12, stbi__result_info *ri) +{ + unsigned char* result; + stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg)); + if (!j) return stbi__errpuc("outofmem", "Out of memory"); + memset(j, 0, sizeof(stbi__jpeg)); + STBI_NOTUSED(ri); + j->s = s; + stbi__setup_jpeg(j); + result = load_jpeg_image(j, x,y,comp,req_comp,nv12); + STBI_FREE(j); + return result; +} + +static int stbi__jpeg_test(stbi__context *s) +{ + int r; + stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg)); + if (!j) return stbi__err("outofmem", "Out of memory"); + memset(j, 0, sizeof(stbi__jpeg)); + j->s = s; + stbi__setup_jpeg(j); + r = stbi__decode_jpeg_header(j, STBI__SCAN_type); + stbi__rewind(s); + STBI_FREE(j); + return r; +} + +#if 0 /* not used in SDL */ +static int stbi__jpeg_info_raw(stbi__jpeg *j, int *x, int *y, int *comp) +{ + if (!stbi__decode_jpeg_header(j, STBI__SCAN_header)) { + stbi__rewind( j->s ); + return 0; + } + if (x) *x = j->s->img_x; + if (y) *y = j->s->img_y; + if (comp) *comp = j->s->img_n >= 3 ? 3 : 1; + return 1; +} + +static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp) +{ + int result; + stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg))); + if (!j) return stbi__err("outofmem", "Out of memory"); + memset(j, 0, sizeof(stbi__jpeg)); + j->s = s; + result = stbi__jpeg_info_raw(j, x, y, comp); + STBI_FREE(j); + return result; +} +#endif /**/ +#endif + +// public domain zlib decode v0.2 Sean Barrett 2006-11-18 +// simple implementation +// - all input must be provided in an upfront buffer +// - all output is written to a single output buffer (can malloc/realloc) +// performance +// - fast huffman + +#ifndef STBI_NO_ZLIB + +// fast-way is faster to check than jpeg huffman, but slow way is slower +#define STBI__ZFAST_BITS 9 // accelerate all cases in default tables +#define STBI__ZFAST_MASK ((1 << STBI__ZFAST_BITS) - 1) +#define STBI__ZNSYMS 288 // number of symbols in literal/length alphabet + +// zlib-style huffman encoding +// (jpegs packs from left, zlib from right, so can't share code) +typedef struct +{ + stbi__uint16 fast[1 << STBI__ZFAST_BITS]; + stbi__uint16 firstcode[16]; + int maxcode[17]; + stbi__uint16 firstsymbol[16]; + stbi_uc size[STBI__ZNSYMS]; + stbi__uint16 value[STBI__ZNSYMS]; +} stbi__zhuffman; + +stbi_inline static int stbi__bitreverse16(int n) +{ + n = ((n & 0xAAAA) >> 1) | ((n & 0x5555) << 1); + n = ((n & 0xCCCC) >> 2) | ((n & 0x3333) << 2); + n = ((n & 0xF0F0) >> 4) | ((n & 0x0F0F) << 4); + n = ((n & 0xFF00) >> 8) | ((n & 0x00FF) << 8); + return n; +} + +stbi_inline static int stbi__bit_reverse(int v, int bits) +{ + STBI_ASSERT(bits <= 16); + // to bit reverse n bits, reverse 16 and shift + // e.g. 11 bits, bit reverse and shift away 5 + return stbi__bitreverse16(v) >> (16-bits); +} + +static int stbi__zbuild_huffman(stbi__zhuffman *z, const stbi_uc *sizelist, int num) +{ + int i,k=0; + int code, next_code[16], sizes[17]; + + // DEFLATE spec for generating codes + memset(sizes, 0, sizeof(sizes)); + memset(z->fast, 0, sizeof(z->fast)); + for (i=0; i < num; ++i) + ++sizes[sizelist[i]]; + sizes[0] = 0; + for (i=1; i < 16; ++i) + if (sizes[i] > (1 << i)) + return stbi__err("bad sizes", "Corrupt PNG"); + code = 0; + for (i=1; i < 16; ++i) { + next_code[i] = code; + z->firstcode[i] = (stbi__uint16) code; + z->firstsymbol[i] = (stbi__uint16) k; + code = (code + sizes[i]); + if (sizes[i]) + if (code-1 >= (1 << i)) return stbi__err("bad codelengths","Corrupt PNG"); + z->maxcode[i] = code << (16-i); // preshift for inner loop + code <<= 1; + k += sizes[i]; + } + z->maxcode[16] = 0x10000; // sentinel + for (i=0; i < num; ++i) { + int s = sizelist[i]; + if (s) { + int c = next_code[s] - z->firstcode[s] + z->firstsymbol[s]; + stbi__uint16 fastv = (stbi__uint16) ((s << 9) | i); + z->size [c] = (stbi_uc ) s; + z->value[c] = (stbi__uint16) i; + if (s <= STBI__ZFAST_BITS) { + int j = stbi__bit_reverse(next_code[s],s); + while (j < (1 << STBI__ZFAST_BITS)) { + z->fast[j] = fastv; + j += (1 << s); + } + } + ++next_code[s]; + } + } + return 1; +} + +// zlib-from-memory implementation for PNG reading +// because PNG allows splitting the zlib stream arbitrarily, +// and it's annoying structurally to have PNG call ZLIB call PNG, +// we require PNG read all the IDATs and combine them into a single +// memory buffer + +typedef struct +{ + stbi_uc *zbuffer, *zbuffer_end; + int num_bits; + int hit_zeof_once; + stbi__uint32 code_buffer; + + char *zout; + char *zout_start; + char *zout_end; + int z_expandable; + + stbi__zhuffman z_length, z_distance; +} stbi__zbuf; + +stbi_inline static int stbi__zeof(stbi__zbuf *z) +{ + return (z->zbuffer >= z->zbuffer_end); +} + +stbi_inline static stbi_uc stbi__zget8(stbi__zbuf *z) +{ + return stbi__zeof(z) ? 0 : *z->zbuffer++; +} + +static void stbi__fill_bits(stbi__zbuf *z) +{ + do { + if (z->code_buffer >= (1U << z->num_bits)) { + z->zbuffer = z->zbuffer_end; /* treat this as EOF so we fail. */ + return; + } + z->code_buffer |= (unsigned int) stbi__zget8(z) << z->num_bits; + z->num_bits += 8; + } while (z->num_bits <= 24); +} + +stbi_inline static unsigned int stbi__zreceive(stbi__zbuf *z, int n) +{ + unsigned int k; + if (z->num_bits < n) stbi__fill_bits(z); + k = z->code_buffer & ((1 << n) - 1); + z->code_buffer >>= n; + z->num_bits -= n; + return k; +} + +static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b,s,k; + // not resolved by fast table, so compute it the slow way + // use jpeg approach, which requires MSbits at top + k = stbi__bit_reverse(a->code_buffer, 16); + for (s=STBI__ZFAST_BITS+1; ; ++s) + if (k < z->maxcode[s]) + break; + if (s >= 16) return -1; // invalid code! + // code size is s, so: + b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; + if (b >= STBI__ZNSYMS) return -1; // some data was corrupt somewhere! + if (z->size[b] != s) return -1; // was originally an assert, but report failure instead. + a->code_buffer >>= s; + a->num_bits -= s; + return z->value[b]; +} + +stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) +{ + int b,s; + if (a->num_bits < 16) { + if (stbi__zeof(a)) { + if (!a->hit_zeof_once) { + // This is the first time we hit eof, insert 16 extra padding btis + // to allow us to keep going; if we actually consume any of them + // though, that is invalid data. This is caught later. + a->hit_zeof_once = 1; + a->num_bits += 16; // add 16 implicit zero bits + } else { + // We already inserted our extra 16 padding bits and are again + // out, this stream is actually prematurely terminated. + return -1; + } + } else { + stbi__fill_bits(a); + } + } + b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; + if (b) { + s = b >> 9; + a->code_buffer >>= s; + a->num_bits -= s; + return b & 511; + } + return stbi__zhuffman_decode_slowpath(a, z); +} + +static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes +{ + char *q; + unsigned int cur, limit, old_limit; + z->zout = zout; + if (!z->z_expandable) return stbi__err("output buffer limit","Corrupt PNG"); + cur = (unsigned int) (z->zout - z->zout_start); + limit = old_limit = (unsigned) (z->zout_end - z->zout_start); + if (UINT_MAX - cur < (unsigned) n) return stbi__err("outofmem", "Out of memory"); + while (cur + n > limit) { + if(limit > UINT_MAX / 2) return stbi__err("outofmem", "Out of memory"); + limit *= 2; + } + q = (char *) STBI_REALLOC_SIZED(z->zout_start, old_limit, limit); + STBI_NOTUSED(old_limit); + if (q == NULL) return stbi__err("outofmem", "Out of memory"); + z->zout_start = q; + z->zout = q + cur; + z->zout_end = q + limit; + return 1; +} + +static const int stbi__zlength_base[31] = { + 3,4,5,6,7,8,9,10,11,13, + 15,17,19,23,27,31,35,43,51,59, + 67,83,99,115,131,163,195,227,258,0,0 }; + +static const int stbi__zlength_extra[31]= +{ 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 }; + +static const int stbi__zdist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, +257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0}; + +static const int stbi__zdist_extra[32] = +{ 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; + +static int stbi__parse_huffman_block(stbi__zbuf *a) +{ + char *zout = a->zout; + for(;;) { + int z = stbi__zhuffman_decode(a, &a->z_length); + if (z < 256) { + if (z < 0) return stbi__err("bad huffman code","Corrupt PNG"); // error in huffman codes + if (zout >= a->zout_end) { + if (!stbi__zexpand(a, zout, 1)) return 0; + zout = a->zout; + } + *zout++ = (char) z; + } else { + stbi_uc *p; + int len,dist; + if (z == 256) { + a->zout = zout; + if (a->hit_zeof_once && a->num_bits < 16) { + // The first time we hit zeof, we inserted 16 extra zero bits into our bit + // buffer so the decoder can just do its speculative decoding. But if we + // actually consumed any of those bits (which is the case when num_bits < 16), + // the stream actually read past the end so it is malformed. + return stbi__err("unexpected end","Corrupt PNG"); + } + return 1; + } + if (z >= 286) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, length codes 286 and 287 must not appear in compressed data + z -= 257; + len = stbi__zlength_base[z]; + if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]); + z = stbi__zhuffman_decode(a, &a->z_distance); + if (z < 0 || z >= 30) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, distance codes 30 and 31 must not appear in compressed data + dist = stbi__zdist_base[z]; + if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]); + if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG"); + if (len > a->zout_end - zout) { + if (!stbi__zexpand(a, zout, len)) return 0; + zout = a->zout; + } + p = (stbi_uc *) (zout - dist); + if (dist == 1) { // run of one byte; common in images. + stbi_uc v = *p; + if (len) { do *zout++ = v; while (--len); } + } else { + if (len) { do *zout++ = *p++; while (--len); } + } + } + } +} + +static int stbi__compute_huffman_codes(stbi__zbuf *a) +{ + static const stbi_uc length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 }; + stbi__zhuffman z_codelength; + stbi_uc lencodes[286+32+137];//padding for maximum single op + stbi_uc codelength_sizes[19]; + int i,n; + + int hlit = stbi__zreceive(a,5) + 257; + int hdist = stbi__zreceive(a,5) + 1; + int hclen = stbi__zreceive(a,4) + 4; + int ntot = hlit + hdist; + + memset(codelength_sizes, 0, sizeof(codelength_sizes)); + for (i=0; i < hclen; ++i) { + int s = stbi__zreceive(a,3); + codelength_sizes[length_dezigzag[i]] = (stbi_uc) s; + } + if (!stbi__zbuild_huffman(&z_codelength, codelength_sizes, 19)) return 0; + + n = 0; + while (n < ntot) { + int c = stbi__zhuffman_decode(a, &z_codelength); + if (c < 0 || c >= 19) return stbi__err("bad codelengths", "Corrupt PNG"); + if (c < 16) + lencodes[n++] = (stbi_uc) c; + else { + stbi_uc fill = 0; + if (c == 16) { + c = stbi__zreceive(a,2)+3; + if (n == 0) return stbi__err("bad codelengths", "Corrupt PNG"); + fill = lencodes[n-1]; + } else if (c == 17) { + c = stbi__zreceive(a,3)+3; + } else if (c == 18) { + c = stbi__zreceive(a,7)+11; + } else { + return stbi__err("bad codelengths", "Corrupt PNG"); + } + if (ntot - n < c) return stbi__err("bad codelengths", "Corrupt PNG"); + memset(lencodes+n, fill, c); + n += c; + } + } + if (n != ntot) return stbi__err("bad codelengths","Corrupt PNG"); + if (!stbi__zbuild_huffman(&a->z_length, lencodes, hlit)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, lencodes+hlit, hdist)) return 0; + return 1; +} + +static int stbi__parse_uncompressed_block(stbi__zbuf *a) +{ + stbi_uc header[4]; + int len,nlen,k; + if (a->num_bits & 7) + stbi__zreceive(a, a->num_bits & 7); // discard + // drain the bit-packed data into header + k = 0; + while (a->num_bits > 0) { + header[k++] = (stbi_uc) (a->code_buffer & 255); // suppress MSVC run-time check + a->code_buffer >>= 8; + a->num_bits -= 8; + } + if (a->num_bits < 0) return stbi__err("zlib corrupt","Corrupt PNG"); + // now fill header the normal way + while (k < 4) + header[k++] = stbi__zget8(a); + len = header[1] * 256 + header[0]; + nlen = header[3] * 256 + header[2]; + if (nlen != (len ^ 0xffff)) return stbi__err("zlib corrupt","Corrupt PNG"); + if (a->zbuffer + len > a->zbuffer_end) return stbi__err("read past buffer","Corrupt PNG"); + if (a->zout + len > a->zout_end) + if (!stbi__zexpand(a, a->zout, len)) return 0; + memcpy(a->zout, a->zbuffer, len); + a->zbuffer += len; + a->zout += len; + return 1; +} + +static int stbi__parse_zlib_header(stbi__zbuf *a) +{ + int cmf = stbi__zget8(a); + int cm = cmf & 15; + /* int cinfo = cmf >> 4; */ + int flg = stbi__zget8(a); + if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec + if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec + if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png + if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png + // window = 1 << (8 + cinfo)... but who cares, we fully buffer output + return 1; +} + +static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] = +{ + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, + 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9, + 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8 +}; +static const stbi_uc stbi__zdefault_distance[32] = +{ + 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5 +}; +/* +Init algorithm: +{ + int i; // use <= to match clearly with spec + for (i=0; i <= 143; ++i) stbi__zdefault_length[i] = 8; + for ( ; i <= 255; ++i) stbi__zdefault_length[i] = 9; + for ( ; i <= 279; ++i) stbi__zdefault_length[i] = 7; + for ( ; i <= 287; ++i) stbi__zdefault_length[i] = 8; + + for (i=0; i <= 31; ++i) stbi__zdefault_distance[i] = 5; +} +*/ + +static int stbi__parse_zlib(stbi__zbuf *a, int parse_header) +{ + int final, type; + if (parse_header) + if (!stbi__parse_zlib_header(a)) return 0; + a->num_bits = 0; + a->code_buffer = 0; + a->hit_zeof_once = 0; + do { + final = stbi__zreceive(a,1); + type = stbi__zreceive(a,2); + if (type == 0) { + if (!stbi__parse_uncompressed_block(a)) return 0; + } else if (type == 3) { + return 0; + } else { + if (type == 1) { + // use fixed code lengths + if (!stbi__zbuild_huffman(&a->z_length , stbi__zdefault_length , STBI__ZNSYMS)) return 0; + if (!stbi__zbuild_huffman(&a->z_distance, stbi__zdefault_distance, 32)) return 0; + } else { + if (!stbi__compute_huffman_codes(a)) return 0; + } + if (!stbi__parse_huffman_block(a)) return 0; + } + } while (!final); + return 1; +} + +static int stbi__do_zlib(stbi__zbuf *a, char *obuf, int olen, int exp, int parse_header) +{ + a->zout_start = obuf; + a->zout = obuf; + a->zout_end = obuf + olen; + a->z_expandable = exp; + + return stbi__parse_zlib(a, parse_header); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize(const char *buffer, int len, int initial_size, int *outlen) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, 1)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF char *stbi_zlib_decode_malloc(char const *buffer, int len, int *outlen) +{ + return stbi_zlib_decode_malloc_guesssize(buffer, len, 16384, outlen); +} + +STBIDEF char *stbi_zlib_decode_malloc_guesssize_headerflag(const char *buffer, int len, int initial_size, int *outlen, int parse_header) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(initial_size); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer + len; + if (stbi__do_zlib(&a, p, initial_size, 1, parse_header)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_buffer(char *obuffer, int olen, char const *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *) ibuffer; + a.zbuffer_end = (stbi_uc *) ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 1)) + return (int) (a.zout - a.zout_start); + else + return -1; +} + +STBIDEF char *stbi_zlib_decode_noheader_malloc(char const *buffer, int len, int *outlen) +{ + stbi__zbuf a; + char *p = (char *) stbi__malloc(16384); + if (p == NULL) return NULL; + a.zbuffer = (stbi_uc *) buffer; + a.zbuffer_end = (stbi_uc *) buffer+len; + if (stbi__do_zlib(&a, p, 16384, 1, 0)) { + if (outlen) *outlen = (int) (a.zout - a.zout_start); + return a.zout_start; + } else { + STBI_FREE(a.zout_start); + return NULL; + } +} + +STBIDEF int stbi_zlib_decode_noheader_buffer(char *obuffer, int olen, const char *ibuffer, int ilen) +{ + stbi__zbuf a; + a.zbuffer = (stbi_uc *) ibuffer; + a.zbuffer_end = (stbi_uc *) ibuffer + ilen; + if (stbi__do_zlib(&a, obuffer, olen, 0, 0)) + return (int) (a.zout - a.zout_start); + else + return -1; +} +#endif + +// public domain "baseline" PNG decoder v0.10 Sean Barrett 2006-11-18 +// simple implementation +// - only 8-bit samples +// - no CRC checking +// - allocates lots of intermediate memory +// - avoids problem of streaming data between subsystems +// - avoids explicit window management +// performance +// - uses stb_zlib, a PD zlib implementation with fast huffman decoding + +#ifndef STBI_NO_PNG +typedef struct +{ + stbi__uint32 length; + stbi__uint32 type; +} stbi__pngchunk; + +static stbi__pngchunk stbi__get_chunk_header(stbi__context *s) +{ + stbi__pngchunk c; + c.length = stbi__get32be(s); + c.type = stbi__get32be(s); + return c; +} + +static int stbi__check_png_header(stbi__context *s) +{ + static const stbi_uc png_sig[8] = { 137,80,78,71,13,10,26,10 }; + int i; + for (i=0; i < 8; ++i) + if (stbi__get8(s) != png_sig[i]) return stbi__err("bad png sig","Not a PNG"); + return 1; +} + +typedef struct +{ + stbi__context *s; + stbi_uc *idata, *expanded, *out; + int depth; +} stbi__png; + + +enum { + STBI__F_none=0, + STBI__F_sub=1, + STBI__F_up=2, + STBI__F_avg=3, + STBI__F_paeth=4, + // synthetic filter used for first scanline to avoid needing a dummy row of 0s + STBI__F_avg_first +}; + +static stbi_uc first_row_filter[5] = +{ + STBI__F_none, + STBI__F_sub, + STBI__F_none, + STBI__F_avg_first, + STBI__F_sub // Paeth with b=c=0 turns out to be equivalent to sub +}; + +static int stbi__paeth(int a, int b, int c) +{ + // This formulation looks very different from the reference in the PNG spec, but is + // actually equivalent and has favorable data dependencies and admits straightforward + // generation of branch-free code, which helps performance significantly. + int thresh = c*3 - (a + b); + int lo = a < b ? a : b; + int hi = a < b ? b : a; + int t0 = (hi <= thresh) ? lo : c; + int t1 = (thresh <= lo) ? hi : t0; + return t1; +} + +static const stbi_uc stbi__depth_scale_table[9] = { 0, 0xff, 0x55, 0, 0x11, 0,0,0, 0x01 }; + +// adds an extra all-255 alpha channel +// dest == src is legal +// img_n must be 1 or 3 +static void stbi__create_png_alpha_expand8(stbi_uc *dest, stbi_uc *src, stbi__uint32 x, int img_n) +{ + int i; + // must process data backwards since we allow dest==src + if (img_n == 1) { + for (i=x-1; i >= 0; --i) { + dest[i*2+1] = 255; + dest[i*2+0] = src[i]; + } + } else { + STBI_ASSERT(img_n == 3); + for (i=x-1; i >= 0; --i) { + dest[i*4+3] = 255; + dest[i*4+2] = src[i*3+2]; + dest[i*4+1] = src[i*3+1]; + dest[i*4+0] = src[i*3+0]; + } + } +} + +// create the png data from post-deflated data +static int stbi__create_png_image_raw(stbi__png *a, stbi_uc *raw, stbi__uint32 raw_len, int out_n, stbi__uint32 x, stbi__uint32 y, int depth, int color) +{ + int bytes = (depth == 16 ? 2 : 1); + stbi__context *s = a->s; + stbi__uint32 i,j,stride = x*out_n*bytes; + stbi__uint32 img_len, img_width_bytes; + stbi_uc *filter_buf; + int all_ok = 1; + int k; + int img_n = s->img_n; // copy it into a local for later + + int output_bytes = out_n*bytes; + int filter_bytes = img_n*bytes; + int width = x; + + STBI_ASSERT(out_n == s->img_n || out_n == s->img_n+1); + a->out = (stbi_uc *) stbi__malloc_mad3(x, y, output_bytes, 0); // extra bytes to write off the end into + if (!a->out) return stbi__err("outofmem", "Out of memory"); + + // note: error exits here don't need to clean up a->out individually, + // stbi__do_png always does on error. + if (!stbi__mad3sizes_valid(img_n, x, depth, 7)) return stbi__err("too large", "Corrupt PNG"); + img_width_bytes = (((img_n * x * depth) + 7) >> 3); + if (!stbi__mad2sizes_valid(img_width_bytes, y, img_width_bytes)) return stbi__err("too large", "Corrupt PNG"); + img_len = (img_width_bytes + 1) * y; + + // we used to check for exact match between raw_len and img_len on non-interlaced PNGs, + // but issue #276 reported a PNG in the wild that had extra data at the end (all zeros), + // so just check for raw_len < img_len always. + if (raw_len < img_len) return stbi__err("not enough pixels","Corrupt PNG"); + + // Allocate two scan lines worth of filter workspace buffer. + filter_buf = (stbi_uc *) stbi__malloc_mad2(img_width_bytes, 2, 0); + if (!filter_buf) return stbi__err("outofmem", "Out of memory"); + + // Filtering for low-bit-depth images + if (depth < 8) { + filter_bytes = 1; + width = img_width_bytes; + } + + for (j=0; j < y; ++j) { + // cur/prior filter buffers alternate + stbi_uc *cur = filter_buf + (j & 1)*img_width_bytes; + stbi_uc *prior = filter_buf + (~j & 1)*img_width_bytes; + stbi_uc *dest = a->out + stride*j; + int nk = width * filter_bytes; + int filter = *raw++; + + // check filter type + if (filter > 4) { + all_ok = stbi__err("invalid filter","Corrupt PNG"); + break; + } + + // if first row, use special filter that doesn't sample previous row + if (j == 0) filter = first_row_filter[filter]; + + // perform actual filtering + switch (filter) { + case STBI__F_none: + memcpy(cur, raw, nk); + break; + case STBI__F_sub: + memcpy(cur, raw, filter_bytes); + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + cur[k-filter_bytes]); + break; + case STBI__F_up: + for (k = 0; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + prior[k]); + break; + case STBI__F_avg: + for (k = 0; k < filter_bytes; ++k) + cur[k] = STBI__BYTECAST(raw[k] + (prior[k]>>1)); + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + ((prior[k] + cur[k-filter_bytes])>>1)); + break; + case STBI__F_paeth: + for (k = 0; k < filter_bytes; ++k) + cur[k] = STBI__BYTECAST(raw[k] + prior[k]); // prior[k] == stbi__paeth(0,prior[k],0) + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + stbi__paeth(cur[k-filter_bytes], prior[k], prior[k-filter_bytes])); + break; + case STBI__F_avg_first: + memcpy(cur, raw, filter_bytes); + for (k = filter_bytes; k < nk; ++k) + cur[k] = STBI__BYTECAST(raw[k] + (cur[k-filter_bytes] >> 1)); + break; + } + + raw += nk; + + // expand decoded bits in cur to dest, also adding an extra alpha channel if desired + if (depth < 8) { + stbi_uc scale = (color == 0) ? stbi__depth_scale_table[depth] : 1; // scale grayscale values to 0..255 range + stbi_uc *in = cur; + stbi_uc *out = dest; + stbi_uc inb = 0; + stbi__uint32 nsmp = x*img_n; + + // expand bits to bytes first + if (depth == 4) { + for (i=0; i < nsmp; ++i) { + if ((i & 1) == 0) inb = *in++; + *out++ = scale * (inb >> 4); + inb <<= 4; + } + } else if (depth == 2) { + for (i=0; i < nsmp; ++i) { + if ((i & 3) == 0) inb = *in++; + *out++ = scale * (inb >> 6); + inb <<= 2; + } + } else { + STBI_ASSERT(depth == 1); + for (i=0; i < nsmp; ++i) { + if ((i & 7) == 0) inb = *in++; + *out++ = scale * (inb >> 7); + inb <<= 1; + } + } + + // insert alpha=255 values if desired + if (img_n != out_n) + stbi__create_png_alpha_expand8(dest, dest, x, img_n); + } else if (depth == 8) { + if (img_n == out_n) + memcpy(dest, cur, x*img_n); + else + stbi__create_png_alpha_expand8(dest, cur, x, img_n); + } else if (depth == 16) { + // convert the image data from big-endian to platform-native + stbi__uint16 *dest16 = (stbi__uint16*)dest; + stbi__uint32 nsmp = x*img_n; + + if (img_n == out_n) { + for (i = 0; i < nsmp; ++i, ++dest16, cur += 2) + *dest16 = (cur[0] << 8) | cur[1]; + } else { + STBI_ASSERT(img_n+1 == out_n); + if (img_n == 1) { + for (i = 0; i < x; ++i, dest16 += 2, cur += 2) { + dest16[0] = (cur[0] << 8) | cur[1]; + dest16[1] = 0xffff; + } + } else { + STBI_ASSERT(img_n == 3); + for (i = 0; i < x; ++i, dest16 += 4, cur += 6) { + dest16[0] = (cur[0] << 8) | cur[1]; + dest16[1] = (cur[2] << 8) | cur[3]; + dest16[2] = (cur[4] << 8) | cur[5]; + dest16[3] = 0xffff; + } + } + } + } + } + + STBI_FREE(filter_buf); + if (!all_ok) return 0; + + return 1; +} + +static int stbi__create_png_image(stbi__png *a, stbi_uc *image_data, stbi__uint32 image_data_len, int out_n, int depth, int color, int interlaced) +{ + int bytes = (depth == 16 ? 2 : 1); + int out_bytes = out_n * bytes; + stbi_uc *final; + int p; + if (!interlaced) + return stbi__create_png_image_raw(a, image_data, image_data_len, out_n, a->s->img_x, a->s->img_y, depth, color); + + // de-interlacing + final = (stbi_uc *) stbi__malloc_mad3(a->s->img_x, a->s->img_y, out_bytes, 0); + if (!final) return stbi__err("outofmem", "Out of memory"); + for (p=0; p < 7; ++p) { + int xorig[] = { 0,4,0,2,0,1,0 }; + int yorig[] = { 0,0,4,0,2,0,1 }; + int xspc[] = { 8,8,4,4,2,2,1 }; + int yspc[] = { 8,8,8,4,4,2,2 }; + int i,j,x,y; + // pass1_x[4] = 0, pass1_x[5] = 1, pass1_x[12] = 1 + x = (a->s->img_x - xorig[p] + xspc[p]-1) / xspc[p]; + y = (a->s->img_y - yorig[p] + yspc[p]-1) / yspc[p]; + if (x && y) { + stbi__uint32 img_len = ((((a->s->img_n * x * depth) + 7) >> 3) + 1) * y; + if (!stbi__create_png_image_raw(a, image_data, image_data_len, out_n, x, y, depth, color)) { + STBI_FREE(final); + return 0; + } + for (j=0; j < y; ++j) { + for (i=0; i < x; ++i) { + int out_y = j*yspc[p]+yorig[p]; + int out_x = i*xspc[p]+xorig[p]; + memcpy(final + out_y*a->s->img_x*out_bytes + out_x*out_bytes, + a->out + (j*x+i)*out_bytes, out_bytes); + } + } + STBI_FREE(a->out); + image_data += img_len; + image_data_len -= img_len; + } + } + a->out = final; + + return 1; +} + +static int stbi__compute_transparency(stbi__png *z, stbi_uc tc[3], int out_n) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + // compute color-based transparency, assuming we've + // already got 255 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i=0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 255); + p += 2; + } + } else { + for (i=0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__compute_transparency16(stbi__png *z, stbi__uint16 tc[3], int out_n) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi__uint16 *p = (stbi__uint16*) z->out; + + // compute color-based transparency, assuming we've + // already got 65535 as the alpha value in the output + STBI_ASSERT(out_n == 2 || out_n == 4); + + if (out_n == 2) { + for (i = 0; i < pixel_count; ++i) { + p[1] = (p[0] == tc[0] ? 0 : 65535); + p += 2; + } + } else { + for (i = 0; i < pixel_count; ++i) { + if (p[0] == tc[0] && p[1] == tc[1] && p[2] == tc[2]) + p[3] = 0; + p += 4; + } + } + return 1; +} + +static int stbi__expand_png_palette(stbi__png *a, stbi_uc *palette, int len, int pal_img_n) +{ + stbi__uint32 i, pixel_count = a->s->img_x * a->s->img_y; + stbi_uc *p, *temp_out, *orig = a->out; + + p = (stbi_uc *) stbi__malloc_mad2(pixel_count, pal_img_n, 0); + if (p == NULL) return stbi__err("outofmem", "Out of memory"); + + // between here and free(out) below, exitting would leak + temp_out = p; + + if (pal_img_n == 3) { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p += 3; + } + } else { + for (i=0; i < pixel_count; ++i) { + int n = orig[i]*4; + p[0] = palette[n ]; + p[1] = palette[n+1]; + p[2] = palette[n+2]; + p[3] = palette[n+3]; + p += 4; + } + } + STBI_FREE(a->out); + a->out = temp_out; + + STBI_NOTUSED(len); + + return 1; +} + +static int stbi__unpremultiply_on_load_global = 0; +static int stbi__de_iphone_flag_global = 0; + +#if 0 /* not used in SDL */ +STBIDEF void stbi_set_unpremultiply_on_load(int flag_true_if_should_unpremultiply) +{ + stbi__unpremultiply_on_load_global = flag_true_if_should_unpremultiply; +} + +STBIDEF void stbi_convert_iphone_png_to_rgb(int flag_true_if_should_convert) +{ + stbi__de_iphone_flag_global = flag_true_if_should_convert; +} +#endif + +#ifndef STBI_THREAD_LOCAL +#define stbi__unpremultiply_on_load stbi__unpremultiply_on_load_global +#define stbi__de_iphone_flag stbi__de_iphone_flag_global +#else +static STBI_THREAD_LOCAL int stbi__unpremultiply_on_load_local, stbi__unpremultiply_on_load_set; +static STBI_THREAD_LOCAL int stbi__de_iphone_flag_local, stbi__de_iphone_flag_set; + +STBIDEF void stbi_set_unpremultiply_on_load_thread(int flag_true_if_should_unpremultiply) +{ + stbi__unpremultiply_on_load_local = flag_true_if_should_unpremultiply; + stbi__unpremultiply_on_load_set = 1; +} + +STBIDEF void stbi_convert_iphone_png_to_rgb_thread(int flag_true_if_should_convert) +{ + stbi__de_iphone_flag_local = flag_true_if_should_convert; + stbi__de_iphone_flag_set = 1; +} + +#define stbi__unpremultiply_on_load (stbi__unpremultiply_on_load_set \ + ? stbi__unpremultiply_on_load_local \ + : stbi__unpremultiply_on_load_global) +#define stbi__de_iphone_flag (stbi__de_iphone_flag_set \ + ? stbi__de_iphone_flag_local \ + : stbi__de_iphone_flag_global) +#endif // STBI_THREAD_LOCAL + +static void stbi__de_iphone(stbi__png *z) +{ + stbi__context *s = z->s; + stbi__uint32 i, pixel_count = s->img_x * s->img_y; + stbi_uc *p = z->out; + + if (s->img_out_n == 3) { // convert bgr to rgb + for (i=0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 3; + } + } else { + STBI_ASSERT(s->img_out_n == 4); + if (stbi__unpremultiply_on_load) { + // convert bgr to rgb and unpremultiply + for (i=0; i < pixel_count; ++i) { + stbi_uc a = p[3]; + stbi_uc t = p[0]; + if (a) { + stbi_uc half = a / 2; + p[0] = (p[2] * 255 + half) / a; + p[1] = (p[1] * 255 + half) / a; + p[2] = ( t * 255 + half) / a; + } else { + p[0] = p[2]; + p[2] = t; + } + p += 4; + } + } else { + // convert bgr to rgb + for (i=0; i < pixel_count; ++i) { + stbi_uc t = p[0]; + p[0] = p[2]; + p[2] = t; + p += 4; + } + } + } +} + +#define STBI__PNG_TYPE(a,b,c,d) (((unsigned) (a) << 24) + ((unsigned) (b) << 16) + ((unsigned) (c) << 8) + (unsigned) (d)) + +static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp, unsigned int *palette_buffer, int palette_buffer_len) +{ + stbi_uc _palette[1024], pal_img_n=0; + stbi_uc *palette = _palette; + stbi_uc has_trans=0, tc[3]={0}; + stbi__uint16 tc16[3]; + stbi__uint32 ioff=0, idata_limit=0, i, pal_len=0; + int first=1,k,interlace=0, color=0, is_iphone=0; + stbi__context *s = z->s; + + if (palette_buffer) { + if (palette_buffer_len < 256) + return stbi__err("palette buffer too small", "palette buffer len must be 256"); + else if (req_comp != 1) + return stbi__err("invalid req_comp", "req_comp must be 1 when loading paletted"); + else + palette = (stbi_uc *)(void *)palette_buffer; + } + + z->expanded = NULL; + z->idata = NULL; + z->out = NULL; + + if (!stbi__check_png_header(s)) return 0; + + if (scan == STBI__SCAN_type) return 1; + + for (;;) { + stbi__pngchunk c = stbi__get_chunk_header(s); + switch (c.type) { + case STBI__PNG_TYPE('C','g','B','I'): + is_iphone = 1; + stbi__skip(s, c.length); + break; + case STBI__PNG_TYPE('I','H','D','R'): { + int comp,filter; + if (!first) return stbi__err("multiple IHDR","Corrupt PNG"); + first = 0; + if (c.length != 13) return stbi__err("bad IHDR len","Corrupt PNG"); + s->img_x = stbi__get32be(s); + s->img_y = stbi__get32be(s); + if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); + z->depth = stbi__get8(s); if (z->depth != 1 && z->depth != 2 && z->depth != 4 && z->depth != 8 && z->depth != 16) return stbi__err("1/2/4/8/16-bit only","PNG not supported: 1/2/4/8/16-bit only"); + color = stbi__get8(s); if (color > 6) return stbi__err("bad ctype","Corrupt PNG"); + if (color == 3 && z->depth == 16) return stbi__err("bad ctype","Corrupt PNG"); + if (color == 3) pal_img_n = 3; else if (color & 1) return stbi__err("bad ctype","Corrupt PNG"); + comp = stbi__get8(s); if (comp) return stbi__err("bad comp method","Corrupt PNG"); + filter= stbi__get8(s); if (filter) return stbi__err("bad filter method","Corrupt PNG"); + interlace = stbi__get8(s); if (interlace>1) return stbi__err("bad interlace method","Corrupt PNG"); + if (!s->img_x || !s->img_y) return stbi__err("0-pixel image","Corrupt PNG"); + if (!pal_img_n) { + s->img_n = (color & 2 ? 3 : 1) + (color & 4 ? 1 : 0); + if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); + } else { + // if paletted, then pal_n is our final components, and + // img_n is # components to decompress/filter. + s->img_n = 1; + if ((1 << 30) / s->img_x / 4 < s->img_y) return stbi__err("too large","Corrupt PNG"); + } + // even with SCAN_header, have to scan to see if we have a tRNS + break; + } + + case STBI__PNG_TYPE('P','L','T','E'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (c.length > 256*3) return stbi__err("invalid PLTE","Corrupt PNG"); + pal_len = c.length / 3; + if (pal_len * 3 != c.length) return stbi__err("invalid PLTE","Corrupt PNG"); + for (i=0; i < pal_len; ++i) { + palette[i*4+0] = stbi__get8(s); + palette[i*4+1] = stbi__get8(s); + palette[i*4+2] = stbi__get8(s); + palette[i*4+3] = 255; + } + break; + } + + case STBI__PNG_TYPE('t','R','N','S'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (z->idata) return stbi__err("tRNS after IDAT","Corrupt PNG"); + if (pal_img_n) { + if (scan == STBI__SCAN_header) { s->img_n = 4; return 1; } + if (pal_len == 0) return stbi__err("tRNS before PLTE","Corrupt PNG"); + if (c.length > pal_len) return stbi__err("bad tRNS len","Corrupt PNG"); + pal_img_n = 4; + for (i=0; i < c.length; ++i) + palette[i*4+3] = stbi__get8(s); + } else { + if (!(s->img_n & 1)) return stbi__err("tRNS with alpha","Corrupt PNG"); + if (c.length != (stbi__uint32) s->img_n*2) return stbi__err("bad tRNS len","Corrupt PNG"); + has_trans = 1; + // non-paletted with tRNS = constant alpha. if header-scanning, we can stop now. + if (scan == STBI__SCAN_header) { ++s->img_n; return 1; } + if (z->depth == 16) { + for (k = 0; k < s->img_n && k < 3; ++k) // extra loop test to suppress false GCC warning + tc16[k] = (stbi__uint16)stbi__get16be(s); // copy the values as-is + } else { + for (k = 0; k < s->img_n && k < 3; ++k) + tc[k] = (stbi_uc)(stbi__get16be(s) & 255) * stbi__depth_scale_table[z->depth]; // non 8-bit images will be larger + } + } + break; + } + + case STBI__PNG_TYPE('I','D','A','T'): { + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG"); + if (scan == STBI__SCAN_header) { + // header scan definitely stops at first IDAT + if (pal_img_n) + s->img_n = pal_img_n; + return 1; + } + if (c.length > (1u << 30)) return stbi__err("IDAT size limit", "IDAT section larger than 2^30 bytes"); + if ((int)(ioff + c.length) < (int)ioff) return 0; + if (ioff + c.length > idata_limit) { + stbi__uint32 idata_limit_old = idata_limit; + stbi_uc *p; + if (idata_limit == 0) idata_limit = c.length > 4096 ? c.length : 4096; + while (ioff + c.length > idata_limit) + idata_limit *= 2; + STBI_NOTUSED(idata_limit_old); + p = (stbi_uc *) STBI_REALLOC_SIZED(z->idata, idata_limit_old, idata_limit); if (p == NULL) return stbi__err("outofmem", "Out of memory"); + z->idata = p; + } + if (!stbi__getn(s, z->idata+ioff,c.length)) return stbi__err("outofdata","Corrupt PNG"); + ioff += c.length; + break; + } + + case STBI__PNG_TYPE('I','E','N','D'): { + stbi__uint32 raw_len, bpl; + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if (scan != STBI__SCAN_load) return 1; + if (z->idata == NULL) return stbi__err("no IDAT","Corrupt PNG"); + // initial guess for decoded data size to avoid unnecessary reallocs + bpl = (s->img_x * z->depth + 7) / 8; // bytes per line, per component + raw_len = bpl * s->img_y * s->img_n /* pixels */ + s->img_y /* filter mode per row */; + z->expanded = (stbi_uc *) stbi_zlib_decode_malloc_guesssize_headerflag((char *) z->idata, ioff, raw_len, (int *) &raw_len, !is_iphone); + if (z->expanded == NULL) return 0; // zlib should set error + STBI_FREE(z->idata); z->idata = NULL; + if ((req_comp == s->img_n+1 && req_comp != 3 && !pal_img_n) || has_trans) + s->img_out_n = s->img_n+1; + else + s->img_out_n = s->img_n; + if (!stbi__create_png_image(z, z->expanded, raw_len, s->img_out_n, z->depth, color, interlace)) return 0; + if (has_trans) { + if (z->depth == 16) { + if (!stbi__compute_transparency16(z, tc16, s->img_out_n)) return 0; + } else { + if (!stbi__compute_transparency(z, tc, s->img_out_n)) return 0; + } + } + if (is_iphone && stbi__de_iphone_flag && s->img_out_n > 2) + stbi__de_iphone(z); + if (pal_img_n) { + // pal_img_n == 3 or 4 + s->img_n = pal_img_n; // record the actual colors we had + s->img_out_n = pal_img_n; + if (req_comp >= 3) s->img_out_n = req_comp; + if (!palette_buffer) + if (!stbi__expand_png_palette(z, palette, pal_len, s->img_out_n)) + return 0; + } else if (has_trans) { + // non-paletted image with tRNS -> source image has (constant) alpha + ++s->img_n; + } + STBI_FREE(z->expanded); z->expanded = NULL; + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + if (s->io.skip && s->img_buffer_end > s->img_buffer) { + // rewind the additional bytes that have been read to the buffer + (s->io.skip)(s->io_user_data, (int)(s->img_buffer - s->img_buffer_end)); + } + return 1; + } + + default: + // if critical, fail + if (first) return stbi__err("first not IHDR", "Corrupt PNG"); + if ((c.type & (1 << 29)) == 0) { + #ifndef STBI_NO_FAILURE_STRINGS + // not threadsafe + static char invalid_chunk[] = "XXXX PNG chunk not known"; + invalid_chunk[0] = STBI__BYTECAST(c.type >> 24); + invalid_chunk[1] = STBI__BYTECAST(c.type >> 16); + invalid_chunk[2] = STBI__BYTECAST(c.type >> 8); + invalid_chunk[3] = STBI__BYTECAST(c.type >> 0); + (void)invalid_chunk; + #endif + return stbi__err(invalid_chunk, "PNG not supported: unknown PNG chunk type"); + } + stbi__skip(s, c.length); + break; + } + // end of PNG chunk, read and skip CRC + stbi__get32be(s); + } +} + +static void *stbi__do_png(stbi__png *p, int *x, int *y, int *n, int req_comp, unsigned int *palette_buffer, int palette_buffer_len, stbi__result_info *ri) +{ + void *result=NULL; + if (palette_buffer && req_comp != 1) { + stbi__err("bad req_comp", "req_comp must be 1 if loading paletted image without expansion"); + return NULL; + } + if (req_comp < 0 || req_comp > 4) { + stbi__err("bad req_comp", "Internal error"); + return NULL; + } + if (stbi__parse_png_file(p, STBI__SCAN_load, req_comp, palette_buffer, palette_buffer_len)) { + if (p->depth <= 8) + ri->bits_per_channel = 8; + else if (p->depth == 16) + ri->bits_per_channel = 16; + else + return stbi__errpuc("bad bits_per_channel", "PNG not supported: unsupported color depth"); + result = p->out; + p->out = NULL; + if (req_comp && req_comp != p->s->img_out_n) { + if (palette_buffer) + ; + else if (ri->bits_per_channel == 8) + result = stbi__convert_format((unsigned char *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); + else + result = stbi__convert_format16((stbi__uint16 *) result, p->s->img_out_n, req_comp, p->s->img_x, p->s->img_y); + p->s->img_out_n = req_comp; + if (result == NULL) return result; + } + *x = p->s->img_x; + *y = p->s->img_y; + if (n) { + if (palette_buffer) + *n = 1; + else + *n = p->s->img_n; + } + } + STBI_FREE(p->out); p->out = NULL; + STBI_FREE(p->expanded); p->expanded = NULL; + STBI_FREE(p->idata); p->idata = NULL; + + return result; +} + +static void *stbi__png_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, unsigned int *palette_buffer, int palette_buffer_len, stbi__result_info *ri) +{ + stbi__png p; + p.s = s; + return stbi__do_png(&p, x,y,comp,req_comp, palette_buffer, palette_buffer_len, ri); +} + +static int stbi__png_test(stbi__context *s) +{ + int r; + r = stbi__check_png_header(s); + stbi__rewind(s); + return r; +} + +#if 0 /* not used in SDL */ +static int stbi__png_info_raw(stbi__png *p, int *x, int *y, int *comp) +{ + if (!stbi__parse_png_file(p, STBI__SCAN_header, NULL, 0, NULL)) { + stbi__rewind( p->s ); + return 0; + } + if (x) *x = p->s->img_x; + if (y) *y = p->s->img_y; + if (comp) *comp = p->s->img_n; + return 1; +} + +static int stbi__png_info(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__png p; + p.s = s; + return stbi__png_info_raw(&p, x, y, comp); +} + +static int stbi__png_is16(stbi__context *s) +{ + stbi__png p; + p.s = s; + if (!stbi__png_info_raw(&p, NULL, NULL, NULL)) + return 0; + if (p.depth != 16) { + stbi__rewind(p.s); + return 0; + } + return 1; +} +#endif /**/ +#endif + +// Microsoft/Windows BMP image + +#ifndef STBI_NO_BMP +static int stbi__bmp_test_raw(stbi__context *s) +{ + int r; + int sz; + if (stbi__get8(s) != 'B') return 0; + if (stbi__get8(s) != 'M') return 0; + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + stbi__get32le(s); // discard data offset + sz = stbi__get32le(s); + r = (sz == 12 || sz == 40 || sz == 56 || sz == 108 || sz == 124); + return r; +} + +static int stbi__bmp_test(stbi__context *s) +{ + int r = stbi__bmp_test_raw(s); + stbi__rewind(s); + return r; +} + + +// returns 0..31 for the highest set bit +static int stbi__high_bit(unsigned int z) +{ + int n=0; + if (z == 0) return -1; + if (z >= 0x10000) { n += 16; z >>= 16; } + if (z >= 0x00100) { n += 8; z >>= 8; } + if (z >= 0x00010) { n += 4; z >>= 4; } + if (z >= 0x00004) { n += 2; z >>= 2; } + if (z >= 0x00002) { n += 1;/* >>= 1;*/ } + return n; +} + +static int stbi__bitcount(unsigned int a) +{ + a = (a & 0x55555555) + ((a >> 1) & 0x55555555); // max 2 + a = (a & 0x33333333) + ((a >> 2) & 0x33333333); // max 4 + a = (a + (a >> 4)) & 0x0f0f0f0f; // max 8 per 4, now 8 bits + a = (a + (a >> 8)); // max 16 per 8 bits + a = (a + (a >> 16)); // max 32 per 8 bits + return a & 0xff; +} + +// extract an arbitrarily-aligned N-bit value (N=bits) +// from v, and then make it 8-bits long and fractionally +// extend it to full full range. +static int stbi__shiftsigned(unsigned int v, int shift, int bits) +{ + static unsigned int mul_table[9] = { + 0, + 0xff/*0b11111111*/, 0x55/*0b01010101*/, 0x49/*0b01001001*/, 0x11/*0b00010001*/, + 0x21/*0b00100001*/, 0x41/*0b01000001*/, 0x81/*0b10000001*/, 0x01/*0b00000001*/, + }; + static unsigned int shift_table[9] = { + 0, 0,0,1,0,2,4,6,0, + }; + if (shift < 0) + v <<= -shift; + else + v >>= shift; + STBI_ASSERT(v < 256); + v >>= (8-bits); + STBI_ASSERT(bits >= 0 && bits <= 8); + return (int) ((unsigned) v * mul_table[bits]) >> shift_table[bits]; +} + +typedef struct +{ + int bpp, offset, hsz; + unsigned int mr,mg,mb,ma, all_a; + int extra_read; +} stbi__bmp_data; + +static int stbi__bmp_set_mask_defaults(stbi__bmp_data *info, int compress) +{ + // BI_BITFIELDS specifies masks explicitly, don't override + if (compress == 3) + return 1; + + if (compress == 0) { + if (info->bpp == 16) { + info->mr = 31u << 10; + info->mg = 31u << 5; + info->mb = 31u << 0; + } else if (info->bpp == 32) { + info->mr = 0xffu << 16; + info->mg = 0xffu << 8; + info->mb = 0xffu << 0; + info->ma = 0xffu << 24; + info->all_a = 0; // if all_a is 0 at end, then we loaded alpha channel but it was all 0 + } else { + // otherwise, use defaults, which is all-0 + info->mr = info->mg = info->mb = info->ma = 0; + } + return 1; + } + return 0; // error +} + +static void *stbi__bmp_parse_header(stbi__context *s, stbi__bmp_data *info) +{ + int hsz; + if (stbi__get8(s) != 'B' || stbi__get8(s) != 'M') return stbi__errpuc("not BMP", "Corrupt BMP"); + stbi__get32le(s); // discard filesize + stbi__get16le(s); // discard reserved + stbi__get16le(s); // discard reserved + info->offset = stbi__get32le(s); + info->hsz = hsz = stbi__get32le(s); + info->mr = info->mg = info->mb = info->ma = 0; + info->extra_read = 14; + + if (info->offset < 0) return stbi__errpuc("bad BMP", "bad BMP"); + + if (hsz != 12 && hsz != 40 && hsz != 56 && hsz != 108 && hsz != 124) return stbi__errpuc("unknown BMP", "BMP type not supported: unknown"); + if (hsz == 12) { + s->img_x = stbi__get16le(s); + s->img_y = stbi__get16le(s); + } else { + s->img_x = stbi__get32le(s); + s->img_y = stbi__get32le(s); + } + if (stbi__get16le(s) != 1) return stbi__errpuc("bad BMP", "bad BMP"); + info->bpp = stbi__get16le(s); + if (hsz != 12) { + int compress = stbi__get32le(s); + if (compress == 1 || compress == 2) return stbi__errpuc("BMP RLE", "BMP type not supported: RLE"); + if (compress >= 4) return stbi__errpuc("BMP JPEG/PNG", "BMP type not supported: unsupported compression"); // this includes PNG/JPEG modes + if (compress == 3 && info->bpp != 16 && info->bpp != 32) return stbi__errpuc("bad BMP", "bad BMP"); // bitfields requires 16 or 32 bits/pixel + stbi__get32le(s); // discard sizeof + stbi__get32le(s); // discard hres + stbi__get32le(s); // discard vres + stbi__get32le(s); // discard colorsused + stbi__get32le(s); // discard max important + if (hsz == 40 || hsz == 56) { + if (hsz == 56) { + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + stbi__get32le(s); + } + if (info->bpp == 16 || info->bpp == 32) { + if (compress == 0) { + stbi__bmp_set_mask_defaults(info, compress); + } else if (compress == 3) { + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->extra_read += 12; + // not documented, but generated by photoshop and handled by mspaint + if (info->mr == info->mg && info->mg == info->mb) { + // ?!?!? + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else + return stbi__errpuc("bad BMP", "bad BMP"); + } + } else { + // V4/V5 header + int i; + if (hsz != 108 && hsz != 124) + return stbi__errpuc("bad BMP", "bad BMP"); + info->mr = stbi__get32le(s); + info->mg = stbi__get32le(s); + info->mb = stbi__get32le(s); + info->ma = stbi__get32le(s); + if (compress != 3) // override mr/mg/mb unless in BI_BITFIELDS mode, as per docs + stbi__bmp_set_mask_defaults(info, compress); + stbi__get32le(s); // discard color space + for (i=0; i < 12; ++i) + stbi__get32le(s); // discard color space parameters + if (hsz == 124) { + stbi__get32le(s); // discard rendering intent + stbi__get32le(s); // discard offset of profile data + stbi__get32le(s); // discard size of profile data + stbi__get32le(s); // discard reserved + } + } + } + return (void *) 1; +} + + +static void *stbi__bmp_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *out; + unsigned int mr=0,mg=0,mb=0,ma=0, all_a; + stbi_uc pal[256][4]; + int psize=0,i,j,width; + int flip_vertically, pad, target; + stbi__bmp_data info; + STBI_NOTUSED(ri); + + info.all_a = 255; + if (stbi__bmp_parse_header(s, &info) == NULL) + return NULL; // error code already set + + flip_vertically = ((int) s->img_y) > 0; + s->img_y = abs((int) s->img_y); + + if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + + mr = info.mr; + mg = info.mg; + mb = info.mb; + ma = info.ma; + all_a = info.all_a; + + if (info.hsz == 12) { + if (info.bpp < 24) + psize = (info.offset - info.extra_read - 24) / 3; + } else { + if (info.bpp < 16) + psize = (info.offset - info.extra_read - info.hsz) >> 2; + } + if (psize == 0) { + // accept some number of extra bytes after the header, but if the offset points either to before + // the header ends or implies a large amount of extra data, reject the file as malformed + int bytes_read_so_far = s->callback_already_read + (int)(s->img_buffer - s->img_buffer_original); + int header_limit = 1024; // max we actually read is below 256 bytes currently. + int extra_data_limit = 256*4; // what ordinarily goes here is a palette; 256 entries*4 bytes is its max size. + if (bytes_read_so_far <= 0 || bytes_read_so_far > header_limit) { + return stbi__errpuc("bad header", "Corrupt BMP"); + } + // we established that bytes_read_so_far is positive and sensible. + // the first half of this test rejects offsets that are either too small positives, or + // negative, and guarantees that info.offset >= bytes_read_so_far > 0. this in turn + // ensures the number computed in the second half of the test can't overflow. + if (info.offset < bytes_read_so_far || info.offset - bytes_read_so_far > extra_data_limit) { + return stbi__errpuc("bad offset", "Corrupt BMP"); + } else { + stbi__skip(s, info.offset - bytes_read_so_far); + } + } + + if (info.bpp == 24 && ma == 0xff000000) + s->img_n = 3; + else + s->img_n = ma ? 4 : 3; + if (req_comp && req_comp >= 3) // we can directly decode 3 or 4 + target = req_comp; + else + target = s->img_n; // if they want monochrome, we'll post-convert + + // sanity-check size + if (!stbi__mad3sizes_valid(target, s->img_x, s->img_y, 0)) + return stbi__errpuc("too large", "Corrupt BMP"); + + out = (stbi_uc *) stbi__malloc_mad3(target, s->img_x, s->img_y, 0); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + if (info.bpp < 16) { + int z=0; + if (psize == 0 || psize > 256) { STBI_FREE(out); return stbi__errpuc("invalid", "Corrupt BMP"); } + for (i=0; i < psize; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + if (info.hsz != 12) stbi__get8(s); + pal[i][3] = 255; + } + stbi__skip(s, info.offset - info.extra_read - info.hsz - psize * (info.hsz == 12 ? 3 : 4)); + if (info.bpp == 1) width = (s->img_x + 7) >> 3; + else if (info.bpp == 4) width = (s->img_x + 1) >> 1; + else if (info.bpp == 8) width = s->img_x; + else { STBI_FREE(out); return stbi__errpuc("bad bpp", "Corrupt BMP"); } + pad = (-width)&3; + if (info.bpp == 1) { + for (j=0; j < (int) s->img_y; ++j) { + int bit_offset = 7, v = stbi__get8(s); + for (i=0; i < (int) s->img_x; ++i) { + int color = (v>>bit_offset)&0x1; + out[z++] = pal[color][0]; + out[z++] = pal[color][1]; + out[z++] = pal[color][2]; + if (target == 4) out[z++] = 255; + if (i+1 == (int) s->img_x) break; + if((--bit_offset) < 0) { + bit_offset = 7; + v = stbi__get8(s); + } + } + stbi__skip(s, pad); + } + } else { + for (j=0; j < (int) s->img_y; ++j) { + for (i=0; i < (int) s->img_x; i += 2) { + int v=stbi__get8(s),v2=0; + if (info.bpp == 4) { + v2 = v & 15; + v >>= 4; + } + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + if (i+1 == (int) s->img_x) break; + v = (info.bpp == 8) ? stbi__get8(s) : v2; + out[z++] = pal[v][0]; + out[z++] = pal[v][1]; + out[z++] = pal[v][2]; + if (target == 4) out[z++] = 255; + } + stbi__skip(s, pad); + } + } + } else { + int rshift=0,gshift=0,bshift=0,ashift=0,rcount=0,gcount=0,bcount=0,acount=0; + int z = 0; + int easy=0; + stbi__skip(s, info.offset - info.extra_read - info.hsz); + if (info.bpp == 24) width = 3 * s->img_x; + else if (info.bpp == 16) width = 2*s->img_x; + else /* bpp = 32 and pad = 0 */ width=0; + pad = (-width) & 3; + if (info.bpp == 24) { + easy = 1; + } else if (info.bpp == 32) { + if (mb == 0xff && mg == 0xff00 && mr == 0x00ff0000 && ma == 0xff000000) + easy = 2; + } + if (!easy) { + if (!mr || !mg || !mb) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } + // right shift amt to put high bit in position #7 + rshift = stbi__high_bit(mr)-7; rcount = stbi__bitcount(mr); + gshift = stbi__high_bit(mg)-7; gcount = stbi__bitcount(mg); + bshift = stbi__high_bit(mb)-7; bcount = stbi__bitcount(mb); + ashift = stbi__high_bit(ma)-7; acount = stbi__bitcount(ma); + if (rcount > 8 || gcount > 8 || bcount > 8 || acount > 8) { STBI_FREE(out); return stbi__errpuc("bad masks", "Corrupt BMP"); } + } + for (j=0; j < (int) s->img_y; ++j) { + if (easy) { + for (i=0; i < (int) s->img_x; ++i) { + unsigned char a; + out[z+2] = stbi__get8(s); + out[z+1] = stbi__get8(s); + out[z+0] = stbi__get8(s); + z += 3; + a = (easy == 2 ? stbi__get8(s) : 255); + all_a |= a; + if (target == 4) out[z++] = a; + } + } else { + int bpp = info.bpp; + for (i=0; i < (int) s->img_x; ++i) { + stbi__uint32 v = (bpp == 16 ? (stbi__uint32) stbi__get16le(s) : stbi__get32le(s)); + unsigned int a; + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mr, rshift, rcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mg, gshift, gcount)); + out[z++] = STBI__BYTECAST(stbi__shiftsigned(v & mb, bshift, bcount)); + a = (ma ? stbi__shiftsigned(v & ma, ashift, acount) : 255); + all_a |= a; + if (target == 4) out[z++] = STBI__BYTECAST(a); + } + } + stbi__skip(s, pad); + } + } + + // if alpha channel is all 0s, replace with all 255s + if (target == 4 && all_a == 0) + for (i=4*s->img_x*s->img_y-1; i >= 0; i -= 4) + out[i] = 255; + + if (flip_vertically) { + stbi_uc t; + for (j=0; j < (int) s->img_y>>1; ++j) { + stbi_uc *p1 = out + j *s->img_x*target; + stbi_uc *p2 = out + (s->img_y-1-j)*s->img_x*target; + for (i=0; i < (int) s->img_x*target; ++i) { + t = p1[i]; p1[i] = p2[i]; p2[i] = t; + } + } + } + + if (req_comp && req_comp != target) { + out = stbi__convert_format(out, target, req_comp, s->img_x, s->img_y); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + *x = s->img_x; + *y = s->img_y; + if (comp) *comp = s->img_n; + return out; +} +#endif + +// Targa Truevision - TGA +// by Jonathan Dummer +#ifndef STBI_NO_TGA +// returns STBI_rgb or whatever, 0 on error +static int stbi__tga_get_comp(int bits_per_pixel, int is_grey, int* is_rgb16) +{ + // only RGB or RGBA (incl. 16bit) or grey allowed + if (is_rgb16) *is_rgb16 = 0; + switch(bits_per_pixel) { + case 8: return STBI_grey; + case 16: if(is_grey) return STBI_grey_alpha; + // fallthrough + case 15: if(is_rgb16) *is_rgb16 = 1; + return STBI_rgb; + case 24: // fallthrough + case 32: return bits_per_pixel/8; + default: return 0; + } +} + +static int stbi__tga_info(stbi__context *s, int *x, int *y, int *comp) +{ + int tga_w, tga_h, tga_comp, tga_image_type, tga_bits_per_pixel, tga_colormap_bpp; + int sz, tga_colormap_type; + stbi__get8(s); // discard Offset + tga_colormap_type = stbi__get8(s); // colormap type + if( tga_colormap_type > 1 ) { + stbi__rewind(s); + return 0; // only RGB or indexed allowed + } + tga_image_type = stbi__get8(s); // image type + if ( tga_colormap_type == 1 ) { // colormapped (paletted) image + if (tga_image_type != 1 && tga_image_type != 9) { + stbi__rewind(s); + return 0; + } + stbi__skip(s,4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) { + stbi__rewind(s); + return 0; + } + stbi__skip(s,4); // skip image x and y origin + tga_colormap_bpp = sz; + } else { // "normal" image w/o colormap - only RGB or grey allowed, +/- RLE + if ( (tga_image_type != 2) && (tga_image_type != 3) && (tga_image_type != 10) && (tga_image_type != 11) ) { + stbi__rewind(s); + return 0; // only RGB or grey allowed, +/- RLE + } + stbi__skip(s,9); // skip colormap specification and image x/y origin + tga_colormap_bpp = 0; + } + tga_w = stbi__get16le(s); + if( tga_w < 1 ) { + stbi__rewind(s); + return 0; // test width + } + tga_h = stbi__get16le(s); + if( tga_h < 1 ) { + stbi__rewind(s); + return 0; // test height + } + tga_bits_per_pixel = stbi__get8(s); // bits per pixel + stbi__get8(s); // ignore alpha bits + if (tga_colormap_bpp != 0) { + if((tga_bits_per_pixel != 8) && (tga_bits_per_pixel != 16)) { + // when using a colormap, tga_bits_per_pixel is the size of the indexes + // I don't think anything but 8 or 16bit indexes makes sense + stbi__rewind(s); + return 0; + } + tga_comp = stbi__tga_get_comp(tga_colormap_bpp, 0, NULL); + } else { + tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3) || (tga_image_type == 11), NULL); + } + if(!tga_comp) { + stbi__rewind(s); + return 0; + } + if (x) *x = tga_w; + if (y) *y = tga_h; + if (comp) *comp = tga_comp; + return 1; // seems to have passed everything +} + +static int stbi__tga_test(stbi__context *s) +{ + int res = 0; + int sz, tga_color_type; + stbi__get8(s); // discard Offset + tga_color_type = stbi__get8(s); // color type + if ( tga_color_type > 1 ) goto errorEnd; // only RGB or indexed allowed + sz = stbi__get8(s); // image type + if ( tga_color_type == 1 ) { // colormapped (paletted) image + if (sz != 1 && sz != 9) goto errorEnd; // colortype 1 demands image type 1 or 9 + stbi__skip(s,4); // skip index of first colormap entry and number of entries + sz = stbi__get8(s); // check bits per palette color entry + if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; + stbi__skip(s,4); // skip image x and y origin + } else { // "normal" image w/o colormap + if ( (sz != 2) && (sz != 3) && (sz != 10) && (sz != 11) ) goto errorEnd; // only RGB or grey allowed, +/- RLE + stbi__skip(s,9); // skip colormap specification and image x/y origin + } + if ( stbi__get16le(s) < 1 ) goto errorEnd; // test width + if ( stbi__get16le(s) < 1 ) goto errorEnd; // test height + sz = stbi__get8(s); // bits per pixel + if ( (tga_color_type == 1) && (sz != 8) && (sz != 16) ) goto errorEnd; // for colormapped images, bpp is size of an index + if ( (sz != 8) && (sz != 15) && (sz != 16) && (sz != 24) && (sz != 32) ) goto errorEnd; + + res = 1; // if we got this far, everything's good and we can return 1 instead of 0 + +errorEnd: + stbi__rewind(s); + return res; +} + +// read 16bit value and convert to 24bit RGB +static void stbi__tga_read_rgb16(stbi__context *s, stbi_uc* out) +{ + stbi__uint16 px = (stbi__uint16)stbi__get16le(s); + stbi__uint16 fiveBitMask = 31; + // we have 3 channels with 5bits each + int r = (px >> 10) & fiveBitMask; + int g = (px >> 5) & fiveBitMask; + int b = px & fiveBitMask; + // Note that this saves the data in RGB(A) order, so it doesn't need to be swapped later + out[0] = (stbi_uc)((r * 255)/31); + out[1] = (stbi_uc)((g * 255)/31); + out[2] = (stbi_uc)((b * 255)/31); + + // some people claim that the most significant bit might be used for alpha + // (possibly if an alpha-bit is set in the "image descriptor byte") + // but that only made 16bit test images completely translucent.. + // so let's treat all 15 and 16bit TGAs as RGB with no alpha. +} + +static void *stbi__tga_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, unsigned int *palette_buffer, int palette_buffer_len, stbi__result_info *ri) +{ + // read in the TGA header stuff + int tga_offset = stbi__get8(s); + int tga_indexed = stbi__get8(s); + int tga_image_type = stbi__get8(s); + int tga_is_RLE = 0; + int tga_palette_start = stbi__get16le(s); + int tga_palette_len = stbi__get16le(s); + int tga_palette_bits = stbi__get8(s); + int tga_x_origin = stbi__get16le(s); + int tga_y_origin = stbi__get16le(s); + int tga_width = stbi__get16le(s); + int tga_height = stbi__get16le(s); + int tga_bits_per_pixel = stbi__get8(s); + int tga_comp, tga_rgb16=0; + int tga_inverted = stbi__get8(s); + // int tga_alpha_bits = tga_inverted & 15; // the 4 lowest bits - unused (useless?) + // image data + unsigned char *tga_data; + unsigned char *tga_palette = NULL; + int i, j; + unsigned char raw_data[4] = {0}; + int RLE_count = 0; + int RLE_repeating = 0; + int read_next_pixel = 1; + STBI_NOTUSED(ri); + STBI_NOTUSED(tga_x_origin); // @TODO + STBI_NOTUSED(tga_y_origin); // @TODO + + if (tga_height > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + if (tga_width > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + + // do a tiny bit of precessing + if ( tga_image_type >= 8 ) + { + tga_image_type -= 8; + tga_is_RLE = 1; + } + tga_inverted = 1 - ((tga_inverted >> 5) & 1); + + // If I'm paletted, then I'll use the number of bits from the palette + if ( tga_indexed ) tga_comp = stbi__tga_get_comp(tga_palette_bits, 0, &tga_rgb16); + else tga_comp = stbi__tga_get_comp(tga_bits_per_pixel, (tga_image_type == 3), &tga_rgb16); + + if(!tga_comp) // shouldn't really happen, stbi__tga_test() should have ensured basic consistency + return stbi__errpuc("bad format", "Can't find out TGA pixelformat"); + + // tga info + *x = tga_width; + *y = tga_height; + if (comp) *comp = tga_comp; + + if (!stbi__mad3sizes_valid(tga_width, tga_height, tga_comp, 0)) + return stbi__errpuc("too large", "Corrupt TGA"); + + tga_data = (unsigned char*)stbi__malloc_mad3(tga_width, tga_height, tga_comp, 0); + if (!tga_data) return stbi__errpuc("outofmem", "Out of memory"); + + // skip to the data's starting position (offset usually = 0) + stbi__skip(s, tga_offset ); + + if ( !tga_indexed && !tga_is_RLE && !tga_rgb16 ) { + for (i=0; i < tga_height; ++i) { + int row = tga_inverted ? tga_height -i - 1 : i; + stbi_uc *tga_row = tga_data + row*tga_width*tga_comp; + stbi__getn(s, tga_row, tga_width * tga_comp); + } + } else { + // do I need to load a palette? + if ( tga_indexed) + { + if (tga_palette_len == 0) { /* you have to have at least one entry! */ + STBI_FREE(tga_data); + return stbi__errpuc("bad palette", "Corrupt TGA"); + } + + // any data to skip? (offset usually = 0) + stbi__skip(s, tga_palette_start ); + // load the palette + if (palette_buffer) { + if (palette_buffer_len < tga_palette_len * tga_comp) { + STBI_FREE(tga_data); + return stbi__errpuc("buffer too small", "Palette buffer too small"); + } + tga_palette = (unsigned char*)(void*)palette_buffer; + } else { + tga_palette = (unsigned char*)stbi__malloc_mad2(tga_palette_len, tga_comp, 0); + if (!tga_palette) { + STBI_FREE(tga_data); + return stbi__errpuc("outofmem", "Out of memory"); + } + } + if (tga_rgb16) { + stbi_uc *pal_entry = tga_palette; + STBI_ASSERT(tga_comp == STBI_rgb); + for (i=0; i < tga_palette_len; ++i) { + stbi__tga_read_rgb16(s, pal_entry); + pal_entry += tga_comp; + } + } else if (!stbi__getn(s, tga_palette, tga_palette_len * tga_comp)) { + STBI_FREE(tga_data); + if (!palette_buffer) + STBI_FREE(tga_palette); + return stbi__errpuc("bad palette", "Corrupt TGA"); + } + } + // load the data + for (i=0; i < tga_width * tga_height; ++i) + { + // if I'm in RLE mode, do I need to get a RLE stbi__pngchunk? + if ( tga_is_RLE ) + { + if ( RLE_count == 0 ) + { + // yep, get the next byte as a RLE command + int RLE_cmd = stbi__get8(s); + RLE_count = 1 + (RLE_cmd & 127); + RLE_repeating = RLE_cmd >> 7; + read_next_pixel = 1; + } else if ( !RLE_repeating ) + { + read_next_pixel = 1; + } + } else + { + read_next_pixel = 1; + } + // OK, if I need to read a pixel, do it now + if ( read_next_pixel ) + { + // load however much data we did have + if ( tga_indexed && !palette_buffer ) + { + // read in index, then perform the lookup + int pal_idx = (tga_bits_per_pixel == 8) ? stbi__get8(s) : stbi__get16le(s); + if ( pal_idx >= tga_palette_len ) { + // invalid index + pal_idx = 0; + } + pal_idx *= tga_comp; + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = tga_palette[pal_idx+j]; + } + } else if(tga_rgb16) { + STBI_ASSERT(tga_comp == STBI_rgb); + stbi__tga_read_rgb16(s, raw_data); + } else { + // read in the data raw + for (j = 0; j < tga_comp; ++j) { + raw_data[j] = stbi__get8(s); + } + } + // clear the reading flag for the next pixel + read_next_pixel = 0; + } // end of reading a pixel + + // copy data + for (j = 0; j < tga_comp; ++j) + tga_data[i*tga_comp+j] = raw_data[j]; + + // in case we're in RLE mode, keep counting down + --RLE_count; + } + // do I need to invert the image? + if ( tga_inverted ) + { + for (j = 0; j*2 < tga_height; ++j) + { + int index1 = j * tga_width * tga_comp; + int index2 = (tga_height - 1 - j) * tga_width * tga_comp; + for (i = tga_width * tga_comp; i > 0; --i) + { + unsigned char temp = tga_data[index1]; + tga_data[index1] = tga_data[index2]; + tga_data[index2] = temp; + ++index1; + ++index2; + } + } + } + // clear my palette, if I had one + if ( tga_palette != NULL && !palette_buffer ) + { + STBI_FREE( tga_palette ); + } + } + + // swap RGB - if the source data was RGB16, it already is in the right order + if (tga_comp >= 3 && !tga_rgb16) + { + unsigned char* tga_pixel = tga_data; + for (i=0; i < tga_width * tga_height; ++i) + { + unsigned char temp = tga_pixel[0]; + tga_pixel[0] = tga_pixel[2]; + tga_pixel[2] = temp; + tga_pixel += tga_comp; + } + } + + // convert to target component count + if (req_comp && req_comp != tga_comp) + tga_data = stbi__convert_format(tga_data, tga_comp, req_comp, tga_width, tga_height); + + // the things I do to get rid of an error message, and yet keep + // Microsoft's C compilers happy... [8^( + tga_palette_start = tga_palette_len = tga_palette_bits = + tga_x_origin = tga_y_origin = 0; + STBI_NOTUSED(tga_palette_start); + // OK, done + return tga_data; +} +#endif + +// ************************************************************************************************* +// Photoshop PSD loader -- PD by Thatcher Ulrich, integration by Nicolas Schulz, tweaked by STB + +#ifndef STBI_NO_PSD +static int stbi__psd_test(stbi__context *s) +{ + int r = (stbi__get32be(s) == 0x38425053); + stbi__rewind(s); + return r; +} + +static int stbi__psd_decode_rle(stbi__context *s, stbi_uc *p, int pixelCount) +{ + int count, nleft, len; + + count = 0; + while ((nleft = pixelCount - count) > 0) { + len = stbi__get8(s); + if (len == 128) { + // No-op. + } else if (len < 128) { + // Copy next len+1 bytes literally. + len++; + if (len > nleft) return 0; // corrupt data + count += len; + while (len) { + *p = stbi__get8(s); + p += 4; + len--; + } + } else if (len > 128) { + stbi_uc val; + // Next -len+1 bytes in the dest are replicated from next source byte. + // (Interpret len as a negative 8-bit int.) + len = 257 - len; + if (len > nleft) return 0; // corrupt data + val = stbi__get8(s); + count += len; + while (len) { + *p = val; + p += 4; + len--; + } + } + } + + return 1; +} + +static void *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri, int bpc) +{ + int pixelCount; + int channelCount, compression; + int channel, i; + int bitdepth; + int w,h; + stbi_uc *out; + STBI_NOTUSED(ri); + + // Check identifier + if (stbi__get32be(s) != 0x38425053) // "8BPS" + return stbi__errpuc("not PSD", "Corrupt PSD image"); + + // Check file type version. + if (stbi__get16be(s) != 1) + return stbi__errpuc("wrong version", "Unsupported version of PSD image"); + + // Skip 6 reserved bytes. + stbi__skip(s, 6 ); + + // Read the number of channels (R, G, B, A, etc). + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) + return stbi__errpuc("wrong channel count", "Unsupported number of channels in PSD image"); + + // Read the rows and columns of the image. + h = stbi__get32be(s); + w = stbi__get32be(s); + + if (h > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + if (w > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + + // Make sure the depth is 8 bits. + bitdepth = stbi__get16be(s); + if (bitdepth != 8 && bitdepth != 16) + return stbi__errpuc("unsupported bit depth", "PSD bit depth is not 8 or 16 bit"); + + // Make sure the color mode is RGB. + // Valid options are: + // 0: Bitmap + // 1: Grayscale + // 2: Indexed color + // 3: RGB color + // 4: CMYK color + // 7: Multichannel + // 8: Duotone + // 9: Lab color + if (stbi__get16be(s) != 3) + return stbi__errpuc("wrong color format", "PSD is not in RGB color format"); + + // Skip the Mode Data. (It's the palette for indexed color; other info for other modes.) + stbi__skip(s,stbi__get32be(s) ); + + // Skip the image resources. (resolution, pen tool paths, etc) + stbi__skip(s, stbi__get32be(s) ); + + // Skip the reserved data. + stbi__skip(s, stbi__get32be(s) ); + + // Find out if the data is compressed. + // Known values: + // 0: no compression + // 1: RLE compressed + compression = stbi__get16be(s); + if (compression > 1) + return stbi__errpuc("bad compression", "PSD has an unknown compression format"); + + // Check size + if (!stbi__mad3sizes_valid(4, w, h, 0)) + return stbi__errpuc("too large", "Corrupt PSD"); + + // Create the destination image. + + if (!compression && bitdepth == 16 && bpc == 16) { + out = (stbi_uc *) stbi__malloc_mad3(8, w, h, 0); + ri->bits_per_channel = 16; + } else + out = (stbi_uc *) stbi__malloc(4 * w*h); + + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + pixelCount = w*h; + + // Initialize the data to zero. + //memset( out, 0, pixelCount * 4 ); + + // Finally, the image data. + if (compression) { + // RLE as used by .PSD and .TIFF + // Loop until you get the number of unpacked bytes you are expecting: + // Read the next source byte into n. + // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally. + // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times. + // Else if n is 128, noop. + // Endloop + + // The RLE-compressed data is preceded by a 2-byte data count for each row in the data, + // which we're going to just skip. + stbi__skip(s, h * channelCount * 2 ); + + // Read the RLE data by channel. + for (channel = 0; channel < 4; channel++) { + stbi_uc *p; + + p = out+channel; + if (channel >= channelCount) { + // Fill this channel with default data. + for (i = 0; i < pixelCount; i++, p += 4) + *p = (channel == 3 ? 255 : 0); + } else { + // Read the RLE data. + if (!stbi__psd_decode_rle(s, p, pixelCount)) { + STBI_FREE(out); + return stbi__errpuc("corrupt", "bad RLE data"); + } + } + } + + } else { + // We're at the raw image data. It's each channel in order (Red, Green, Blue, Alpha, ...) + // where each channel consists of an 8-bit (or 16-bit) value for each pixel in the image. + + // Read the data by channel. + for (channel = 0; channel < 4; channel++) { + if (channel >= channelCount) { + // Fill this channel with default data. + if (bitdepth == 16 && bpc == 16) { + stbi__uint16 *q = ((stbi__uint16 *) out) + channel; + stbi__uint16 val = channel == 3 ? 65535 : 0; + for (i = 0; i < pixelCount; i++, q += 4) + *q = val; + } else { + stbi_uc *p = out+channel; + stbi_uc val = channel == 3 ? 255 : 0; + for (i = 0; i < pixelCount; i++, p += 4) + *p = val; + } + } else { + if (ri->bits_per_channel == 16) { // output bpc + stbi__uint16 *q = ((stbi__uint16 *) out) + channel; + for (i = 0; i < pixelCount; i++, q += 4) + *q = (stbi__uint16) stbi__get16be(s); + } else { + stbi_uc *p = out+channel; + if (bitdepth == 16) { // input bpc + for (i = 0; i < pixelCount; i++, p += 4) + *p = (stbi_uc) (stbi__get16be(s) >> 8); + } else { + for (i = 0; i < pixelCount; i++, p += 4) + *p = stbi__get8(s); + } + } + } + } + } + + // remove weird white matte from PSD + if (channelCount >= 4) { + if (ri->bits_per_channel == 16) { + for (i=0; i < w*h; ++i) { + stbi__uint16 *pixel = (stbi__uint16 *) out + 4*i; + if (pixel[3] != 0 && pixel[3] != 65535) { + float a = pixel[3] / 65535.0f; + float ra = 1.0f / a; + float inv_a = 65535.0f * (1 - ra); + pixel[0] = (stbi__uint16) (pixel[0]*ra + inv_a); + pixel[1] = (stbi__uint16) (pixel[1]*ra + inv_a); + pixel[2] = (stbi__uint16) (pixel[2]*ra + inv_a); + } + } + } else { + for (i=0; i < w*h; ++i) { + unsigned char *pixel = out + 4*i; + if (pixel[3] != 0 && pixel[3] != 255) { + float a = pixel[3] / 255.0f; + float ra = 1.0f / a; + float inv_a = 255.0f * (1 - ra); + pixel[0] = (unsigned char) (pixel[0]*ra + inv_a); + pixel[1] = (unsigned char) (pixel[1]*ra + inv_a); + pixel[2] = (unsigned char) (pixel[2]*ra + inv_a); + } + } + } + } + + // convert to desired output format + if (req_comp && req_comp != 4) { + if (ri->bits_per_channel == 16) + out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, 4, req_comp, w, h); + else + out = stbi__convert_format(out, 4, req_comp, w, h); + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + + if (comp) *comp = 4; + *y = h; + *x = w; + + return out; +} +#endif + +// ************************************************************************************************* +// Softimage PIC loader +// by Tom Seddon +// +// See http://softimage.wiki.softimage.com/index.php/INFO:_PIC_file_format +// See http://ozviz.wasp.uwa.edu.au/~pbourke/dataformats/softimagepic/ + +#ifndef STBI_NO_PIC +static int stbi__pic_is4(stbi__context *s,const char *str) +{ + int i; + for (i=0; i<4; ++i) + if (stbi__get8(s) != (stbi_uc)str[i]) + return 0; + + return 1; +} + +static int stbi__pic_test_core(stbi__context *s) +{ + int i; + + if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) + return 0; + + for(i=0;i<84;++i) + stbi__get8(s); + + if (!stbi__pic_is4(s,"PICT")) + return 0; + + return 1; +} + +typedef struct +{ + stbi_uc size,type,channel; +} stbi__pic_packet; + +static stbi_uc *stbi__readval(stbi__context *s, int channel, stbi_uc *dest) +{ + int mask=0x80, i; + + for (i=0; i<4; ++i, mask>>=1) { + if (channel & mask) { + if (stbi__at_eof(s)) return stbi__errpuc("bad file","PIC file too short"); + dest[i]=stbi__get8(s); + } + } + + return dest; +} + +static void stbi__copyval(int channel,stbi_uc *dest,const stbi_uc *src) +{ + int mask=0x80,i; + + for (i=0;i<4; ++i, mask>>=1) + if (channel&mask) + dest[i]=src[i]; +} + +static stbi_uc *stbi__pic_load_core(stbi__context *s,int width,int height,int *comp, stbi_uc *result) +{ + int act_comp=0,num_packets=0,y,chained; + stbi__pic_packet packets[10]; + + // this will (should...) cater for even some bizarre stuff like having data + // for the same channel in multiple packets. + do { + stbi__pic_packet *packet; + + if (num_packets==sizeof(packets)/sizeof(packets[0])) + return stbi__errpuc("bad format","too many packets"); + + packet = &packets[num_packets++]; + + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + + act_comp |= packet->channel; + + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (reading packets)"); + if (packet->size != 8) return stbi__errpuc("bad format","packet isn't 8bpp"); + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); // has alpha channel? + + for(y=0; ytype) { + default: + return stbi__errpuc("bad format","packet has bad compression type"); + + case 0: {//uncompressed + int x; + + for(x=0;xchannel,dest)) + return 0; + break; + } + + case 1://Pure RLE + { + int left=width, i; + + while (left>0) { + stbi_uc count,value[4]; + + count=stbi__get8(s); + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pure read count)"); + + if (count > left) + count = (stbi_uc) left; + + if (!stbi__readval(s,packet->channel,value)) return 0; + + for(i=0; ichannel,dest,value); + left -= count; + } + } + break; + + case 2: {//Mixed RLE + int left=width; + while (left>0) { + int count = stbi__get8(s), i; + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (mixed read count)"); + + if (count >= 128) { // Repeated + stbi_uc value[4]; + + if (count==128) + count = stbi__get16be(s); + else + count -= 127; + if (count > left) + return stbi__errpuc("bad file","scanline overrun"); + + if (!stbi__readval(s,packet->channel,value)) + return 0; + + for(i=0;ichannel,dest,value); + } else { // Raw + ++count; + if (count>left) return stbi__errpuc("bad file","scanline overrun"); + + for(i=0;ichannel,dest)) + return 0; + } + left-=count; + } + break; + } + } + } + } + + return result; +} + +static void *stbi__pic_load(stbi__context *s,int *px,int *py,int *comp,int req_comp, stbi__result_info *ri) +{ + stbi_uc *result; + int i, x,y, internal_comp; + STBI_NOTUSED(ri); + + if (!comp) comp = &internal_comp; + + for (i=0; i<92; ++i) + stbi__get8(s); + + x = stbi__get16be(s); + y = stbi__get16be(s); + + if (y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + if (x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + + if (stbi__at_eof(s)) return stbi__errpuc("bad file","file too short (pic header)"); + if (!stbi__mad3sizes_valid(x, y, 4, 0)) return stbi__errpuc("too large", "PIC image too large to decode"); + + stbi__get32be(s); //skip `ratio' + stbi__get16be(s); //skip `fields' + stbi__get16be(s); //skip `pad' + + // intermediate buffer is RGBA + result = (stbi_uc *) stbi__malloc_mad3(x, y, 4, 0); + if (!result) return stbi__errpuc("outofmem", "Out of memory"); + memset(result, 0xff, x*y*4); + + if (!stbi__pic_load_core(s,x,y,comp, result)) { + STBI_FREE(result); + return 0; + } + *px = x; + *py = y; + if (req_comp == 0) req_comp = *comp; + result=stbi__convert_format(result,4,req_comp,x,y); + + return result; +} + +static int stbi__pic_test(stbi__context *s) +{ + int r = stbi__pic_test_core(s); + stbi__rewind(s); + return r; +} +#endif + +// ************************************************************************************************* +// GIF loader -- public domain by Jean-Marc Lienher -- simplified/shrunk by stb + +#ifndef STBI_NO_GIF +typedef struct +{ + stbi__int16 prefix; + stbi_uc first; + stbi_uc suffix; +} stbi__gif_lzw; + +typedef struct +{ + int w,h; + stbi_uc *out; // output buffer (always 4 components) + stbi_uc *background; // The current "background" as far as a gif is concerned + stbi_uc *history; + int flags, bgindex, ratio, transparent, eflags; + stbi_uc pal[256][4]; + stbi_uc lpal[256][4]; + stbi__gif_lzw codes[8192]; + stbi_uc *color_table; + int parse, step; + int lflags; + int start_x, start_y; + int max_x, max_y; + int cur_x, cur_y; + int line_size; + int delay; +} stbi__gif; + +static int stbi__gif_test_raw(stbi__context *s) +{ + int sz; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') return 0; + sz = stbi__get8(s); + if (sz != '9' && sz != '7') return 0; + if (stbi__get8(s) != 'a') return 0; + return 1; +} + +static int stbi__gif_test(stbi__context *s) +{ + int r = stbi__gif_test_raw(s); + stbi__rewind(s); + return r; +} + +static void stbi__gif_parse_colortable(stbi__context *s, stbi_uc pal[256][4], int num_entries, int transp) +{ + int i; + for (i=0; i < num_entries; ++i) { + pal[i][2] = stbi__get8(s); + pal[i][1] = stbi__get8(s); + pal[i][0] = stbi__get8(s); + pal[i][3] = transp == i ? 0 : 255; + } +} + +static int stbi__gif_header(stbi__context *s, stbi__gif *g, int *comp, int is_info) +{ + stbi_uc version; + if (stbi__get8(s) != 'G' || stbi__get8(s) != 'I' || stbi__get8(s) != 'F' || stbi__get8(s) != '8') + return stbi__err("not GIF", "Corrupt GIF"); + + version = stbi__get8(s); + if (version != '7' && version != '9') return stbi__err("not GIF", "Corrupt GIF"); + if (stbi__get8(s) != 'a') return stbi__err("not GIF", "Corrupt GIF"); + + stbi__g_failure_reason = ""; + g->w = stbi__get16le(s); + g->h = stbi__get16le(s); + g->flags = stbi__get8(s); + g->bgindex = stbi__get8(s); + g->ratio = stbi__get8(s); + g->transparent = -1; + + if (g->w > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); + if (g->h > STBI_MAX_DIMENSIONS) return stbi__err("too large","Very large image (corrupt?)"); + + if (comp != 0) *comp = 4; // can't actually tell whether it's 3 or 4 until we parse the comments + + if (is_info) return 1; + + if (g->flags & 0x80) + stbi__gif_parse_colortable(s,g->pal, 2 << (g->flags & 7), -1); + + return 1; +} + +static int stbi__gif_info_raw(stbi__context *s, int *x, int *y, int *comp) +{ + stbi__gif* g = (stbi__gif*) stbi__malloc(sizeof(stbi__gif)); + if (!g) return stbi__err("outofmem", "Out of memory"); + if (!stbi__gif_header(s, g, comp, 1)) { + STBI_FREE(g); + stbi__rewind( s ); + return 0; + } + if (x) *x = g->w; + if (y) *y = g->h; + STBI_FREE(g); + return 1; +} + +static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code) +{ + stbi_uc *p, *c; + int idx; + + // recurse to decode the prefixes, since the linked-list is backwards, + // and working backwards through an interleaved image would be nasty + if (g->codes[code].prefix >= 0) + stbi__out_gif_code(g, g->codes[code].prefix); + + if (g->cur_y >= g->max_y) return; + + idx = g->cur_x + g->cur_y; + p = &g->out[idx]; + g->history[idx / 4] = 1; + + c = &g->color_table[g->codes[code].suffix * 4]; + if (c[3] > 128) { // don't render transparent pixels; + p[0] = c[2]; + p[1] = c[1]; + p[2] = c[0]; + p[3] = c[3]; + } + g->cur_x += 4; + + if (g->cur_x >= g->max_x) { + g->cur_x = g->start_x; + g->cur_y += g->step; + + while (g->cur_y >= g->max_y && g->parse > 0) { + g->step = (1 << g->parse) * g->line_size; + g->cur_y = g->start_y + (g->step >> 1); + --g->parse; + } + } +} + +static stbi_uc *stbi__process_gif_raster(stbi__context *s, stbi__gif *g) +{ + stbi_uc lzw_cs; + stbi__int32 len, init_code; + stbi__uint32 first; + stbi__int32 codesize, codemask, avail, oldcode, bits, valid_bits, clear; + stbi__gif_lzw *p; + + lzw_cs = stbi__get8(s); + if (lzw_cs > 12) return NULL; + clear = 1 << lzw_cs; + first = 1; + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + bits = 0; + valid_bits = 0; + for (init_code = 0; init_code < clear; init_code++) { + g->codes[init_code].prefix = -1; + g->codes[init_code].first = (stbi_uc) init_code; + g->codes[init_code].suffix = (stbi_uc) init_code; + } + + // support no starting clear code + avail = clear+2; + oldcode = -1; + + len = 0; + for(;;) { + if (valid_bits < codesize) { + if (len == 0) { + len = stbi__get8(s); // start new block + if (len == 0) + return g->out; + } + --len; + bits |= (stbi__int32) stbi__get8(s) << valid_bits; + valid_bits += 8; + } else { + stbi__int32 code = bits & codemask; + bits >>= codesize; + valid_bits -= codesize; + // @OPTIMIZE: is there some way we can accelerate the non-clear path? + if (code == clear) { // clear code + codesize = lzw_cs + 1; + codemask = (1 << codesize) - 1; + avail = clear + 2; + oldcode = -1; + first = 0; + } else if (code == clear + 1) { // end of stream code + stbi__skip(s, len); + while ((len = stbi__get8(s)) > 0) + stbi__skip(s,len); + return g->out; + } else if (code <= avail) { + if (first) { + return stbi__errpuc("no clear code", "Corrupt GIF"); + } + + if (oldcode >= 0) { + p = &g->codes[avail++]; + if (avail > 8192) { + return stbi__errpuc("too many codes", "Corrupt GIF"); + } + + p->prefix = (stbi__int16) oldcode; + p->first = g->codes[oldcode].first; + p->suffix = (code == avail) ? p->first : g->codes[code].first; + } else if (code == avail) + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + + stbi__out_gif_code(g, (stbi__uint16) code); + + if ((avail & codemask) == 0 && avail <= 0x0FFF) { + codesize++; + codemask = (1 << codesize) - 1; + } + + oldcode = code; + } else { + return stbi__errpuc("illegal code in raster", "Corrupt GIF"); + } + } + } +} + +// this function is designed to support animated gifs, although stb_image doesn't support it +// two back is the image from two frames ago, used for a very specific disposal format +static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back) +{ + int dispose; + int first_frame; + int pi; + int pcount; + STBI_NOTUSED(req_comp); + + // on first frame, any non-written pixels get the background colour (non-transparent) + first_frame = 0; + if (g->out == 0) { + if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header + if (!stbi__mad3sizes_valid(4, g->w, g->h, 0)) + return stbi__errpuc("too large", "GIF image is too large"); + pcount = g->w * g->h; + g->out = (stbi_uc *) stbi__malloc(4 * pcount); + g->background = (stbi_uc *) stbi__malloc(4 * pcount); + g->history = (stbi_uc *) stbi__malloc(pcount); + if (!g->out || !g->background || !g->history) + return stbi__errpuc("outofmem", "Out of memory"); + + // image is treated as "transparent" at the start - ie, nothing overwrites the current background; + // background colour is only used for pixels that are not rendered first frame, after that "background" + // color refers to the color that was there the previous frame. + memset(g->out, 0x00, 4 * pcount); + memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent) + memset(g->history, 0x00, pcount); // pixels that were affected previous frame + first_frame = 1; + } else { + // second frame - how do we dispose of the previous one? + dispose = (g->eflags & 0x1C) >> 2; + pcount = g->w * g->h; + + if ((dispose == 3) && (two_back == 0)) { + dispose = 2; // if I don't have an image to revert back to, default to the old background + } + + if (dispose == 3) { // use previous graphic + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); + } + } + } else if (dispose == 2) { + // restore what was changed last frame to background before that frame; + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi]) { + memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); + } + } + } else { + // This is a non-disposal case eithe way, so just + // leave the pixels as is, and they will become the new background + // 1: do not dispose + // 0: not specified. + } + + // background is what out is after the undoing of the previou frame; + memcpy( g->background, g->out, 4 * g->w * g->h ); + } + + // clear my history; + memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame + + for (;;) { + int tag = stbi__get8(s); + switch (tag) { + case 0x2C: /* Image Descriptor */ + { + stbi__int32 x, y, w, h; + stbi_uc *o; + + x = stbi__get16le(s); + y = stbi__get16le(s); + w = stbi__get16le(s); + h = stbi__get16le(s); + if (((x + w) > (g->w)) || ((y + h) > (g->h))) + return stbi__errpuc("bad Image Descriptor", "Corrupt GIF"); + + g->line_size = g->w * 4; + g->start_x = x * 4; + g->start_y = y * g->line_size; + g->max_x = g->start_x + w * 4; + g->max_y = g->start_y + h * g->line_size; + g->cur_x = g->start_x; + g->cur_y = g->start_y; + + // if the width of the specified rectangle is 0, that means + // we may not see *any* pixels or the image is malformed; + // to make sure this is caught, move the current y down to + // max_y (which is what out_gif_code checks). + if (w == 0) + g->cur_y = g->max_y; + + g->lflags = stbi__get8(s); + + if (g->lflags & 0x40) { + g->step = 8 * g->line_size; // first interlaced spacing + g->parse = 3; + } else { + g->step = g->line_size; + g->parse = 0; + } + + if (g->lflags & 0x80) { + stbi__gif_parse_colortable(s,g->lpal, 2 << (g->lflags & 7), g->eflags & 0x01 ? g->transparent : -1); + g->color_table = (stbi_uc *) g->lpal; + } else if (g->flags & 0x80) { + g->color_table = (stbi_uc *) g->pal; + } else + return stbi__errpuc("missing color table", "Corrupt GIF"); + + o = stbi__process_gif_raster(s, g); + if (!o) return NULL; + + // if this was the first frame, + pcount = g->w * g->h; + if (first_frame && (g->bgindex > 0)) { + // if first frame, any pixel not drawn to gets the background color + for (pi = 0; pi < pcount; ++pi) { + if (g->history[pi] == 0) { + g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; + memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); + } + } + } + + return o; + } + + case 0x21: // Comment Extension. + { + int len; + int ext = stbi__get8(s); + if (ext == 0xF9) { // Graphic Control Extension. + len = stbi__get8(s); + if (len == 4) { + g->eflags = stbi__get8(s); + g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths. + + // unset old transparent + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 255; + } + if (g->eflags & 0x01) { + g->transparent = stbi__get8(s); + if (g->transparent >= 0) { + g->pal[g->transparent][3] = 0; + } + } else { + // don't need transparent + stbi__skip(s, 1); + g->transparent = -1; + } + } else { + stbi__skip(s, len); + break; + } + } + while ((len = stbi__get8(s)) != 0) { + stbi__skip(s, len); + } + break; + } + + case 0x3B: // gif stream termination code + return (stbi_uc *) s; // using '1' causes warning on some compilers + + default: + return stbi__errpuc("unknown code", "Corrupt GIF"); + } + } +} + +static void *stbi__load_gif_main_outofmem(stbi__gif *g, stbi_uc *out, int **delays) +{ + STBI_FREE(g->out); + STBI_FREE(g->history); + STBI_FREE(g->background); + + if (out) STBI_FREE(out); + if (delays && *delays) STBI_FREE(*delays); + return stbi__errpuc("outofmem", "Out of memory"); +} + +static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp) +{ + if (stbi__gif_test(s)) { + int layers = 0; + stbi_uc *u = 0; + stbi_uc *out = 0; + stbi_uc *two_back = 0; + stbi__gif g; + int stride; + int out_size = 0; + int delays_size = 0; + + STBI_NOTUSED(out_size); + STBI_NOTUSED(delays_size); + + memset(&g, 0, sizeof(g)); + if (delays) { + *delays = 0; + } + + do { + u = stbi__gif_load_next(s, &g, comp, req_comp, two_back); + if (u == (stbi_uc *) s) u = 0; // end of animated gif marker + + if (u) { + *x = g.w; + *y = g.h; + ++layers; + stride = g.w * g.h * 4; + + if (out) { + void *tmp = (stbi_uc*) STBI_REALLOC_SIZED( out, out_size, layers * stride ); + if (!tmp) + return stbi__load_gif_main_outofmem(&g, out, delays); + else { + out = (stbi_uc*) tmp; + out_size = layers * stride; + } + + if (delays) { + int *new_delays = (int*) STBI_REALLOC_SIZED( *delays, delays_size, sizeof(int) * layers ); + if (!new_delays) + return stbi__load_gif_main_outofmem(&g, out, delays); + *delays = new_delays; + delays_size = layers * sizeof(int); + } + } else { + out = (stbi_uc*)stbi__malloc( layers * stride ); + if (!out) + return stbi__load_gif_main_outofmem(&g, out, delays); + out_size = layers * stride; + if (delays) { + *delays = (int*) stbi__malloc( layers * sizeof(int) ); + if (!*delays) + return stbi__load_gif_main_outofmem(&g, out, delays); + delays_size = layers * sizeof(int); + } + } + memcpy( out + ((layers - 1) * stride), u, stride ); + if (layers >= 2) { + two_back = out - 2 * stride; + } + + if (delays) { + (*delays)[layers - 1U] = g.delay; + } + } + } while (u != 0); + + // free temp buffer; + STBI_FREE(g.out); + STBI_FREE(g.history); + STBI_FREE(g.background); + + // do the final conversion after loading everything; + if (req_comp && req_comp != 4) + out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h); + + *z = layers; + return out; + } else { + return stbi__errpuc("not GIF", "Image was not as a gif type."); + } +} + +static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *u = 0; + stbi__gif g; + memset(&g, 0, sizeof(g)); + STBI_NOTUSED(ri); + + u = stbi__gif_load_next(s, &g, comp, req_comp, 0); + if (u == (stbi_uc *) s) u = 0; // end of animated gif marker + if (u) { + *x = g.w; + *y = g.h; + + // moved conversion to after successful load so that the same + // can be done for multiple frames. + if (req_comp && req_comp != 4) + u = stbi__convert_format(u, 4, req_comp, g.w, g.h); + } else if (g.out) { + // if there was an error and we allocated an image buffer, free it! + STBI_FREE(g.out); + } + + // free buffers needed for multiple frame loading; + STBI_FREE(g.history); + STBI_FREE(g.background); + + return u; +} + +static int stbi__gif_info(stbi__context *s, int *x, int *y, int *comp) +{ + return stbi__gif_info_raw(s,x,y,comp); +} +#endif + +// ************************************************************************************************* +// Radiance RGBE HDR loader +// originally by Nicolas Schulz +#ifndef STBI_NO_HDR +static int stbi__hdr_test_core(stbi__context *s, const char *signature) +{ + int i; + for (i=0; signature[i]; ++i) + if (stbi__get8(s) != signature[i]) + return 0; + stbi__rewind(s); + return 1; +} + +static int stbi__hdr_test(stbi__context* s) +{ + int r = stbi__hdr_test_core(s, "#?RADIANCE\n"); + stbi__rewind(s); + if(!r) { + r = stbi__hdr_test_core(s, "#?RGBE\n"); + stbi__rewind(s); + } + return r; +} + +#define STBI__HDR_BUFLEN 1024 +static char *stbi__hdr_gettoken(stbi__context *z, char *buffer) +{ + int len=0; + char c = '\0'; + + c = (char) stbi__get8(z); + + while (!stbi__at_eof(z) && c != '\n') { + buffer[len++] = c; + if (len == STBI__HDR_BUFLEN-1) { + // flush to end of line + while (!stbi__at_eof(z) && stbi__get8(z) != '\n') + ; + break; + } + c = (char) stbi__get8(z); + } + + buffer[len] = 0; + return buffer; +} + +static void stbi__hdr_convert(float *output, stbi_uc *input, int req_comp) +{ + if ( input[3] != 0 ) { + float f1; + // Exponent + f1 = (float) ldexp(1.0f, input[3] - (int)(128 + 8)); + if (req_comp <= 2) + output[0] = (input[0] + input[1] + input[2]) * f1 / 3; + else { + output[0] = input[0] * f1; + output[1] = input[1] * f1; + output[2] = input[2] * f1; + } + if (req_comp == 2) output[1] = 1; + if (req_comp == 4) output[3] = 1; + } else { + switch (req_comp) { + case 4: output[3] = 1; /* fallthrough */ + case 3: output[0] = output[1] = output[2] = 0; + break; + case 2: output[1] = 1; /* fallthrough */ + case 1: output[0] = 0; + break; + } + } +} + +static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int width, height; + stbi_uc *scanline; + float *hdr_data; + int len; + unsigned char count, value; + int i, j, k, c1,c2, z; + const char *headerToken; + STBI_NOTUSED(ri); + + // Check identifier + headerToken = stbi__hdr_gettoken(s,buffer); + if (strcmp(headerToken, "#?RADIANCE") != 0 && strcmp(headerToken, "#?RGBE") != 0) + return stbi__errpf("not HDR", "Corrupt HDR image"); + + // Parse header + for(;;) { + token = stbi__hdr_gettoken(s,buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) return stbi__errpf("unsupported format", "Unsupported HDR format"); + + // Parse width and height + // can't use sscanf() if we're not using stdio! + token = stbi__hdr_gettoken(s,buffer); + if (strncmp(token, "-Y ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + height = (int) strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) return stbi__errpf("unsupported data layout", "Unsupported HDR format"); + token += 3; + width = (int) strtol(token, NULL, 10); + + if (height > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)"); + if (width > STBI_MAX_DIMENSIONS) return stbi__errpf("too large","Very large image (corrupt?)"); + + *x = width; + *y = height; + + if (comp) *comp = 3; + if (req_comp == 0) req_comp = 3; + + if (!stbi__mad4sizes_valid(width, height, req_comp, sizeof(float), 0)) + return stbi__errpf("too large", "HDR image is too large"); + + // Read data + hdr_data = (float *) stbi__malloc_mad4(width, height, req_comp, sizeof(float), 0); + if (!hdr_data) + return stbi__errpf("outofmem", "Out of memory"); + + // Load image data + // image data is stored as some number of sca + if ( width < 8 || width >= 32768) { + // Read flat data + for (j=0; j < height; ++j) { + for (i=0; i < width; ++i) { + stbi_uc rgbe[4]; + main_decode_loop: + stbi__getn(s, rgbe, 4); + stbi__hdr_convert(hdr_data + j * width * req_comp + i * req_comp, rgbe, req_comp); + } + } + } else { + // Read RLE-encoded data + scanline = NULL; + + for (j = 0; j < height; ++j) { + c1 = stbi__get8(s); + c2 = stbi__get8(s); + len = stbi__get8(s); + if (c1 != 2 || c2 != 2 || (len & 0x80)) { + // not run-length encoded, so we have to actually use THIS data as a decoded + // pixel (note this can't be a valid pixel--one of RGB must be >= 128) + stbi_uc rgbe[4]; + rgbe[0] = (stbi_uc) c1; + rgbe[1] = (stbi_uc) c2; + rgbe[2] = (stbi_uc) len; + rgbe[3] = (stbi_uc) stbi__get8(s); + stbi__hdr_convert(hdr_data, rgbe, req_comp); + i = 1; + j = 0; + STBI_FREE(scanline); + goto main_decode_loop; // yes, this makes no sense + } + len <<= 8; + len |= stbi__get8(s); + if (len != width) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("invalid decoded scanline length", "corrupt HDR"); } + if (scanline == NULL) { + scanline = (stbi_uc *) stbi__malloc_mad2(width, 4, 0); + if (!scanline) { + STBI_FREE(hdr_data); + return stbi__errpf("outofmem", "Out of memory"); + } + } + + for (k = 0; k < 4; ++k) { + int nleft; + i = 0; + while ((nleft = width - i) > 0) { + count = stbi__get8(s); + if (count > 128) { + // Run + value = stbi__get8(s); + count -= 128; + if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = value; + } else { + // Dump + if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); } + for (z = 0; z < count; ++z) + scanline[i++ * 4 + k] = stbi__get8(s); + } + } + } + for (i=0; i < width; ++i) + stbi__hdr_convert(hdr_data+(j*width + i)*req_comp, scanline + i*4, req_comp); + } + if (scanline) + STBI_FREE(scanline); + } + + return hdr_data; +} + +static int stbi__hdr_info(stbi__context *s, int *x, int *y, int *comp) +{ + char buffer[STBI__HDR_BUFLEN]; + char *token; + int valid = 0; + int dummy; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + if (stbi__hdr_test(s) == 0) { + stbi__rewind( s ); + return 0; + } + + for(;;) { + token = stbi__hdr_gettoken(s,buffer); + if (token[0] == 0) break; + if (strcmp(token, "FORMAT=32-bit_rle_rgbe") == 0) valid = 1; + } + + if (!valid) { + stbi__rewind( s ); + return 0; + } + token = stbi__hdr_gettoken(s,buffer); + if (strncmp(token, "-Y ", 3)) { + stbi__rewind( s ); + return 0; + } + token += 3; + *y = (int) strtol(token, &token, 10); + while (*token == ' ') ++token; + if (strncmp(token, "+X ", 3)) { + stbi__rewind( s ); + return 0; + } + token += 3; + *x = (int) strtol(token, NULL, 10); + *comp = 3; + return 1; +} +#endif // STBI_NO_HDR + +#ifndef STBI_NO_BMP +static int stbi__bmp_info(stbi__context *s, int *x, int *y, int *comp) +{ + void *p; + stbi__bmp_data info; + + info.all_a = 255; + p = stbi__bmp_parse_header(s, &info); + if (p == NULL) { + stbi__rewind( s ); + return 0; + } + if (x) *x = s->img_x; + if (y) *y = s->img_y; + if (comp) { + if (info.bpp == 24 && info.ma == 0xff000000) + *comp = 3; + else + *comp = info.ma ? 4 : 3; + } + return 1; +} +#endif + +#ifndef STBI_NO_PSD +static int stbi__psd_info(stbi__context *s, int *x, int *y, int *comp) +{ + int channelCount, dummy, depth; + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind( s ); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind( s ); + return 0; + } + *y = stbi__get32be(s); + *x = stbi__get32be(s); + depth = stbi__get16be(s); + if (depth != 8 && depth != 16) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 3) { + stbi__rewind( s ); + return 0; + } + *comp = 4; + return 1; +} + +static int stbi__psd_is16(stbi__context *s) +{ + int channelCount, depth; + if (stbi__get32be(s) != 0x38425053) { + stbi__rewind( s ); + return 0; + } + if (stbi__get16be(s) != 1) { + stbi__rewind( s ); + return 0; + } + stbi__skip(s, 6); + channelCount = stbi__get16be(s); + if (channelCount < 0 || channelCount > 16) { + stbi__rewind( s ); + return 0; + } + STBI_NOTUSED(stbi__get32be(s)); + STBI_NOTUSED(stbi__get32be(s)); + depth = stbi__get16be(s); + if (depth != 16) { + stbi__rewind( s ); + return 0; + } + return 1; +} +#endif + +#ifndef STBI_NO_PIC +static int stbi__pic_info(stbi__context *s, int *x, int *y, int *comp) +{ + int act_comp=0,num_packets=0,chained,dummy; + stbi__pic_packet packets[10]; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + if (!stbi__pic_is4(s,"\x53\x80\xF6\x34")) { + stbi__rewind(s); + return 0; + } + + stbi__skip(s, 88); + + *x = stbi__get16be(s); + *y = stbi__get16be(s); + if (stbi__at_eof(s)) { + stbi__rewind( s); + return 0; + } + if ( (*x) != 0 && (1 << 28) / (*x) < (*y)) { + stbi__rewind( s ); + return 0; + } + + stbi__skip(s, 8); + + do { + stbi__pic_packet *packet; + + if (num_packets==sizeof(packets)/sizeof(packets[0])) + return 0; + + packet = &packets[num_packets++]; + chained = stbi__get8(s); + packet->size = stbi__get8(s); + packet->type = stbi__get8(s); + packet->channel = stbi__get8(s); + act_comp |= packet->channel; + + if (stbi__at_eof(s)) { + stbi__rewind( s ); + return 0; + } + if (packet->size != 8) { + stbi__rewind( s ); + return 0; + } + } while (chained); + + *comp = (act_comp & 0x10 ? 4 : 3); + + return 1; +} +#endif + +// ************************************************************************************************* +// Portable Gray Map and Portable Pixel Map loader +// by Ken Miller +// +// PGM: http://netpbm.sourceforge.net/doc/pgm.html +// PPM: http://netpbm.sourceforge.net/doc/ppm.html +// +// Known limitations: +// Does not support comments in the header section +// Does not support ASCII image data (formats P2 and P3) + +#ifndef STBI_NO_PNM + +static int stbi__pnm_test(stbi__context *s) +{ + char p, t; + p = (char) stbi__get8(s); + t = (char) stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind( s ); + return 0; + } + return 1; +} + +static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri) +{ + stbi_uc *out; + STBI_NOTUSED(ri); + + ri->bits_per_channel = stbi__pnm_info(s, (int *)&s->img_x, (int *)&s->img_y, (int *)&s->img_n); + if (ri->bits_per_channel == 0) + return 0; + + if (s->img_y > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + if (s->img_x > STBI_MAX_DIMENSIONS) return stbi__errpuc("too large","Very large image (corrupt?)"); + + *x = s->img_x; + *y = s->img_y; + if (comp) *comp = s->img_n; + + if (!stbi__mad4sizes_valid(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0)) + return stbi__errpuc("too large", "PNM too large"); + + out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0); + if (!out) return stbi__errpuc("outofmem", "Out of memory"); + if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) { + STBI_FREE(out); + return stbi__errpuc("bad PNM", "PNM file truncated"); + } + + if (req_comp && req_comp != s->img_n) { + if (ri->bits_per_channel == 16) { + out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y); + } else { + out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y); + } + if (out == NULL) return out; // stbi__convert_format frees input on failure + } + return out; +} + +static int stbi__pnm_isspace(char c) +{ + return c == ' ' || c == '\t' || c == '\n' || c == '\v' || c == '\f' || c == '\r'; +} + +static void stbi__pnm_skip_whitespace(stbi__context *s, char *c) +{ + for (;;) { + while (!stbi__at_eof(s) && stbi__pnm_isspace(*c)) + *c = (char) stbi__get8(s); + + if (stbi__at_eof(s) || *c != '#') + break; + + while (!stbi__at_eof(s) && *c != '\n' && *c != '\r' ) + *c = (char) stbi__get8(s); + } +} + +static int stbi__pnm_isdigit(char c) +{ + return c >= '0' && c <= '9'; +} + +static int stbi__pnm_getinteger(stbi__context *s, char *c) +{ + int value = 0; + + while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) { + value = value*10 + (*c - '0'); + *c = (char) stbi__get8(s); + if((value > 214748364) || (value == 214748364 && *c > '7')) + return stbi__err("integer parse overflow", "Parsing an integer in the PPM header overflowed a 32-bit int"); + } + + return value; +} + +static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp) +{ + int maxv, dummy; + char c, p, t; + + if (!x) x = &dummy; + if (!y) y = &dummy; + if (!comp) comp = &dummy; + + stbi__rewind(s); + + // Get identifier + p = (char) stbi__get8(s); + t = (char) stbi__get8(s); + if (p != 'P' || (t != '5' && t != '6')) { + stbi__rewind(s); + return 0; + } + + *comp = (t == '6') ? 3 : 1; // '5' is 1-component .pgm; '6' is 3-component .ppm + + c = (char) stbi__get8(s); + stbi__pnm_skip_whitespace(s, &c); + + *x = stbi__pnm_getinteger(s, &c); // read width + if(*x == 0) + return stbi__err("invalid width", "PPM image header had zero or overflowing width"); + stbi__pnm_skip_whitespace(s, &c); + + *y = stbi__pnm_getinteger(s, &c); // read height + if (*y == 0) + return stbi__err("invalid width", "PPM image header had zero or overflowing width"); + stbi__pnm_skip_whitespace(s, &c); + + maxv = stbi__pnm_getinteger(s, &c); // read max value + if (maxv > 65535) + return stbi__err("max value > 65535", "PPM image supports only 8-bit and 16-bit images"); + else if (maxv > 255) + return 16; + else + return 8; +} + +static int stbi__pnm_is16(stbi__context *s) +{ + if (stbi__pnm_info(s, NULL, NULL, NULL) == 16) + return 1; + return 0; +} +#endif + +#if 0 /* not used in SDL */ +static int stbi__info_main(stbi__context *s, int *x, int *y, int *comp) +{ + #ifndef STBI_NO_JPEG + if (stbi__jpeg_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PNG + if (stbi__png_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_GIF + if (stbi__gif_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_BMP + if (stbi__bmp_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PSD + if (stbi__psd_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PIC + if (stbi__pic_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_PNM + if (stbi__pnm_info(s, x, y, comp)) return 1; + #endif + + #ifndef STBI_NO_HDR + if (stbi__hdr_info(s, x, y, comp)) return 1; + #endif + + // test tga last because it's a crappy test! + #ifndef STBI_NO_TGA + if (stbi__tga_info(s, x, y, comp)) + return 1; + #endif + return stbi__err("unknown image type", "Image not of any known type, or corrupt"); +} + +static int stbi__is_16_main(stbi__context *s) +{ + #ifndef STBI_NO_PNG + if (stbi__png_is16(s)) return 1; + #endif + + #ifndef STBI_NO_PSD + if (stbi__psd_is16(s)) return 1; + #endif + + #ifndef STBI_NO_PNM + if (stbi__pnm_is16(s)) return 1; + #endif + return 0; +} +#endif /**/ + +#ifndef STBI_NO_STDIO +STBIDEF int stbi_info(char const *filename, int *x, int *y, int *comp) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); + result = stbi_info_from_file(f, x, y, comp); + fclose(f); + return result; +} + +STBIDEF int stbi_info_from_file(FILE *f, int *x, int *y, int *comp) +{ + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__info_main(&s,x,y,comp); + fseek(f,pos,SEEK_SET); + return r; +} + +STBIDEF int stbi_is_16_bit(char const *filename) +{ + FILE *f = stbi__fopen(filename, "rb"); + int result; + if (!f) return stbi__err("can't fopen", "Unable to open file"); + result = stbi_is_16_bit_from_file(f); + fclose(f); + return result; +} + +STBIDEF int stbi_is_16_bit_from_file(FILE *f) +{ + int r; + stbi__context s; + long pos = ftell(f); + stbi__start_file(&s, f); + r = stbi__is_16_main(&s); + fseek(f,pos,SEEK_SET); + return r; +} +#endif // !STBI_NO_STDIO + +#if 0 /* not used in SDL */ +STBIDEF int stbi_info_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__info_main(&s,x,y,comp); +} + +STBIDEF int stbi_info_from_callbacks(stbi_io_callbacks const *c, void *user, int *x, int *y, int *comp) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); + return stbi__info_main(&s,x,y,comp); +} + +STBIDEF int stbi_is_16_bit_from_memory(stbi_uc const *buffer, int len) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__is_16_main(&s); +} + +STBIDEF int stbi_is_16_bit_from_callbacks(stbi_io_callbacks const *c, void *user) +{ + stbi__context s; + stbi__start_callbacks(&s, (stbi_io_callbacks *) c, user); + return stbi__is_16_main(&s); +} +#endif /**/ + +#endif // STB_IMAGE_IMPLEMENTATION + +/* + revision history: + 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs + 2.19 (2018-02-11) fix warning + 2.18 (2018-01-30) fix warnings + 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug + 1-bit BMP + *_is_16_bit api + avoid warnings + 2.16 (2017-07-23) all functions have 16-bit variants; + STBI_NO_STDIO works again; + compilation fixes; + fix rounding in unpremultiply; + optimize vertical flip; + disable raw_len validation; + documentation fixes + 2.15 (2017-03-18) fix png-1,2,4 bug; now all Imagenet JPGs decode; + warning fixes; disable run-time SSE detection on gcc; + uniform handling of optional "return" values; + thread-safe initialization of zlib tables + 2.14 (2017-03-03) remove deprecated STBI_JPEG_OLD; fixes for Imagenet JPGs + 2.13 (2016-11-29) add 16-bit API, only supported for PNG right now + 2.12 (2016-04-02) fix typo in 2.11 PSD fix that caused crashes + 2.11 (2016-04-02) allocate large structures on the stack + remove white matting for transparent PSD + fix reported channel count for PNG & BMP + re-enable SSE2 in non-gcc 64-bit + support RGB-formatted JPEG + read 16-bit PNGs (only as 8-bit) + 2.10 (2016-01-22) avoid warning introduced in 2.09 by STBI_REALLOC_SIZED + 2.09 (2016-01-16) allow comments in PNM files + 16-bit-per-pixel TGA (not bit-per-component) + info() for TGA could break due to .hdr handling + info() for BMP to shares code instead of sloppy parse + can use STBI_REALLOC_SIZED if allocator doesn't support realloc + code cleanup + 2.08 (2015-09-13) fix to 2.07 cleanup, reading RGB PSD as RGBA + 2.07 (2015-09-13) fix compiler warnings + partial animated GIF support + limited 16-bpc PSD support + #ifdef unused functions + bug with < 92 byte PIC,PNM,HDR,TGA + 2.06 (2015-04-19) fix bug where PSD returns wrong '*comp' value + 2.05 (2015-04-19) fix bug in progressive JPEG handling, fix warning + 2.04 (2015-04-15) try to re-enable SIMD on MinGW 64-bit + 2.03 (2015-04-12) extra corruption checking (mmozeiko) + stbi_set_flip_vertically_on_load (nguillemot) + fix NEON support; fix mingw support + 2.02 (2015-01-19) fix incorrect assert, fix warning + 2.01 (2015-01-17) fix various warnings; suppress SIMD on gcc 32-bit without -msse2 + 2.00b (2014-12-25) fix STBI_MALLOC in progressive JPEG + 2.00 (2014-12-25) optimize JPG, including x86 SSE2 & NEON SIMD (ryg) + progressive JPEG (stb) + PGM/PPM support (Ken Miller) + STBI_MALLOC,STBI_REALLOC,STBI_FREE + GIF bugfix -- seemingly never worked + STBI_NO_*, STBI_ONLY_* + 1.48 (2014-12-14) fix incorrectly-named assert() + 1.47 (2014-12-14) 1/2/4-bit PNG support, both direct and paletted (Omar Cornut & stb) + optimize PNG (ryg) + fix bug in interlaced PNG with user-specified channel count (stb) + 1.46 (2014-08-26) + fix broken tRNS chunk (colorkey-style transparency) in non-paletted PNG + 1.45 (2014-08-16) + fix MSVC-ARM internal compiler error by wrapping malloc + 1.44 (2014-08-07) + various warning fixes from Ronny Chevalier + 1.43 (2014-07-15) + fix MSVC-only compiler problem in code changed in 1.42 + 1.42 (2014-07-09) + don't define _CRT_SECURE_NO_WARNINGS (affects user code) + fixes to stbi__cleanup_jpeg path + added STBI_ASSERT to avoid requiring assert.h + 1.41 (2014-06-25) + fix search&replace from 1.36 that messed up comments/error messages + 1.40 (2014-06-22) + fix gcc struct-initialization warning + 1.39 (2014-06-15) + fix to TGA optimization when req_comp != number of components in TGA; + fix to GIF loading because BMP wasn't rewinding (whoops, no GIFs in my test suite) + add support for BMP version 5 (more ignored fields) + 1.38 (2014-06-06) + suppress MSVC warnings on integer casts truncating values + fix accidental rename of 'skip' field of I/O + 1.37 (2014-06-04) + remove duplicate typedef + 1.36 (2014-06-03) + convert to header file single-file library + if de-iphone isn't set, load iphone images color-swapped instead of returning NULL + 1.35 (2014-05-27) + various warnings + fix broken STBI_SIMD path + fix bug where stbi_load_from_file no longer left file pointer in correct place + fix broken non-easy path for 32-bit BMP (possibly never used) + TGA optimization by Arseny Kapoulkine + 1.34 (unknown) + use STBI_NOTUSED in stbi__resample_row_generic(), fix one more leak in tga failure case + 1.33 (2011-07-14) + make stbi_is_hdr work in STBI_NO_HDR (as specified), minor compiler-friendly improvements + 1.32 (2011-07-13) + support for "info" function for all supported filetypes (SpartanJ) + 1.31 (2011-06-20) + a few more leak fixes, bug in PNG handling (SpartanJ) + 1.30 (2011-06-11) + added ability to load files via callbacks to accomidate custom input streams (Ben Wenger) + removed deprecated format-specific test/load functions + removed support for installable file formats (stbi_loader) -- would have been broken for IO callbacks anyway + error cases in bmp and tga give messages and don't leak (Raymond Barbiero, grisha) + fix inefficiency in decoding 32-bit BMP (David Woo) + 1.29 (2010-08-16) + various warning fixes from Aurelien Pocheville + 1.28 (2010-08-01) + fix bug in GIF palette transparency (SpartanJ) + 1.27 (2010-08-01) + cast-to-stbi_uc to fix warnings + 1.26 (2010-07-24) + fix bug in file buffering for PNG reported by SpartanJ + 1.25 (2010-07-17) + refix trans_data warning (Won Chun) + 1.24 (2010-07-12) + perf improvements reading from files on platforms with lock-heavy fgetc() + minor perf improvements for jpeg + deprecated type-specific functions so we'll get feedback if they're needed + attempt to fix trans_data warning (Won Chun) + 1.23 fixed bug in iPhone support + 1.22 (2010-07-10) + removed image *writing* support + stbi_info support from Jetro Lauha + GIF support from Jean-Marc Lienher + iPhone PNG-extensions from James Brown + warning-fixes from Nicolas Schulz and Janez Zemva (i.stbi__err. Janez (U+017D)emva) + 1.21 fix use of 'stbi_uc' in header (reported by jon blow) + 1.20 added support for Softimage PIC, by Tom Seddon + 1.19 bug in interlaced PNG corruption check (found by ryg) + 1.18 (2008-08-02) + fix a threading bug (local mutable static) + 1.17 support interlaced PNG + 1.16 major bugfix - stbi__convert_format converted one too many pixels + 1.15 initialize some fields for thread safety + 1.14 fix threadsafe conversion bug + header-file-only version (#define STBI_HEADER_FILE_ONLY before including) + 1.13 threadsafe + 1.12 const qualifiers in the API + 1.11 Support installable IDCT, colorspace conversion routines + 1.10 Fixes for 64-bit (don't use "unsigned long") + optimized upsampling by Fabian "ryg" Giesen + 1.09 Fix format-conversion for PSD code (bad global variables!) + 1.08 Thatcher Ulrich's PSD code integrated by Nicolas Schulz + 1.07 attempt to fix C++ warning/errors again + 1.06 attempt to fix C++ warning/errors again + 1.05 fix TGA loading to return correct *comp and use good luminance calc + 1.04 default float alpha is 1, not 255; use 'void *' for stbi_image_free + 1.03 bugfixes to STBI_NO_STDIO, STBI_NO_HDR + 1.02 support for (subset of) HDR files, float interface for preferred access to them + 1.01 fix bug: possible bug in handling right-side up bmps... not sure + fix bug: the stbi__bmp_load() and stbi__tga_load() functions didn't work at all + 1.00 interface to zlib that skips zlib header + 0.99 correct handling of alpha in palette + 0.98 TGA loader by lonesock; dynamically add loaders (untested) + 0.97 jpeg errors on too large a file; also catch another malloc failure + 0.96 fix detection of invalid v value - particleman@mollyrocket forum + 0.95 during header scan, seek to markers in case of padding + 0.94 STBI_NO_STDIO to disable stdio usage; rename all #defines the same + 0.93 handle jpegtran output; verbose errors + 0.92 read 4,8,16,24,32-bit BMP files of several formats + 0.91 output 24-bit Windows 3.0 BMP files + 0.90 fix a few more warnings; bump version number to approach 1.0 + 0.61 bugfixes due to Marc LeBlanc, Christopher Lloyd + 0.60 fix compiling as c++ + 0.59 fix warnings: merge Dave Moore's -Wall fixes + 0.58 fix bug: zlib uncompressed mode len/nlen was wrong endian + 0.57 fix bug: jpg last huffman symbol before marker was >9 bits but less than 16 available + 0.56 fix bug: zlib uncompressed mode len vs. nlen + 0.55 fix bug: restart_interval not initialized to 0 + 0.54 allow NULL for 'int *comp' + 0.53 fix bug in png 3->4; speedup png decoding + 0.52 png handles req_comp=3,4 directly; minor cleanup; jpeg comments + 0.51 obey req_comp requests, 1-component jpegs return as 1-component, + on 'test' only check type, not whether we support this variant + 0.50 (2006-11-19) + first released version +*/ + + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +------------------------------------------------------------------------------ +*/ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.h new file mode 100644 index 0000000..77ccbfd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.h @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#import + +@interface SDLLaunchScreenController : UIViewController + +- (instancetype)init; +- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil; +- (void)loadView; + +@end + +@interface SDLUIKitDelegate : NSObject + ++ (id)sharedAppDelegate; ++ (NSString *)getAppDelegateClassName; + +- (void)hideLaunchScreen; + +/* This property is marked as optional, and is only intended to be used when + * the app's UI is storyboard-based. SDL is not storyboard-based, however + * several major third-party ad APIs (e.g. Google admob) incorrectly assume this + * property always exists, and will crash if it doesn't. */ +@property(nonatomic) UIWindow *window; + +@end diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.m new file mode 100644 index 0000000..6a37e51 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitappdelegate.m @@ -0,0 +1,519 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "../SDL_sysvideo.h" + +#import "SDL_uikitappdelegate.h" +#import "SDL_uikitmodes.h" +#import "SDL_uikitwindow.h" + +#include "../../events/SDL_events_c.h" + +#ifdef main +#undef main +#endif + +static SDL_main_func forward_main; +static int forward_argc; +static char **forward_argv; +static int exit_status; + +int SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved) +{ + int i; + + // store arguments + /* Note that we need to be careful about how we allocate/free memory here. + * If the application calls SDL_SetMemoryFunctions(), we can't rely on + * SDL_free() to use the same allocator after SDL_main() returns. + */ + forward_main = mainFunction; + forward_argc = argc; + forward_argv = (char **)malloc((argc + 1) * sizeof(char *)); // This should NOT be SDL_malloc() + for (i = 0; i < argc; i++) { + forward_argv[i] = malloc((strlen(argv[i]) + 1) * sizeof(char)); // This should NOT be SDL_malloc() + strcpy(forward_argv[i], argv[i]); + } + forward_argv[i] = NULL; + + // Give over control to run loop, SDLUIKitDelegate will handle most things from here + @autoreleasepool { + UIApplicationMain(argc, argv, nil, [SDLUIKitDelegate getAppDelegateClassName]); + } + + // free the memory we used to hold copies of argc and argv + for (i = 0; i < forward_argc; i++) { + free(forward_argv[i]); // This should NOT be SDL_free() + } + free(forward_argv); // This should NOT be SDL_free() + + return exit_status; +} + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) +// Load a launch image using the old UILaunchImageFile-era naming rules. +static UIImage *SDL_LoadLaunchImageNamed(NSString *name, int screenh) +{ + UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation; + UIUserInterfaceIdiom idiom = [UIDevice currentDevice].userInterfaceIdiom; + UIImage *image = nil; + + if (idiom == UIUserInterfaceIdiomPhone && screenh == 568) { + // The image name for the iPhone 5 uses its height as a suffix. + image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-568h", name]]; + } else if (idiom == UIUserInterfaceIdiomPad) { + // iPad apps can launch in any orientation. + if (UIInterfaceOrientationIsLandscape(curorient)) { + if (curorient == UIInterfaceOrientationLandscapeLeft) { + image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-LandscapeLeft", name]]; + } else { + image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-LandscapeRight", name]]; + } + if (!image) { + image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-Landscape", name]]; + } + } else { + if (curorient == UIInterfaceOrientationPortraitUpsideDown) { + image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-PortraitUpsideDown", name]]; + } + if (!image) { + image = [UIImage imageNamed:[NSString stringWithFormat:@"%@-Portrait", name]]; + } + } + } + + if (!image) { + image = [UIImage imageNamed:name]; + } + + return image; +} + +@interface SDLLaunchStoryboardViewController : UIViewController +@property(nonatomic, strong) UIViewController *storyboardViewController; +- (instancetype)initWithStoryboardViewController:(UIViewController *)storyboardViewController; +@end + +@implementation SDLLaunchStoryboardViewController + +- (instancetype)initWithStoryboardViewController:(UIViewController *)storyboardViewController +{ + self = [super init]; + self.storyboardViewController = storyboardViewController; + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + + [self addChildViewController:self.storyboardViewController]; + [self.view addSubview:self.storyboardViewController.view]; + self.storyboardViewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.storyboardViewController.view.frame = self.view.bounds; + [self.storyboardViewController didMoveToParentViewController:self]; + +#ifndef SDL_PLATFORM_VISIONOS + UIApplication.sharedApplication.statusBarHidden = self.prefersStatusBarHidden; + UIApplication.sharedApplication.statusBarStyle = self.preferredStatusBarStyle; +#endif +} + +- (BOOL)prefersStatusBarHidden +{ + return [[NSBundle.mainBundle objectForInfoDictionaryKey:@"UIStatusBarHidden"] boolValue]; +} + +- (UIStatusBarStyle)preferredStatusBarStyle +{ + NSString *statusBarStyle = [NSBundle.mainBundle objectForInfoDictionaryKey:@"UIStatusBarStyle"]; + if ([statusBarStyle isEqualToString:@"UIStatusBarStyleLightContent"]) { + return UIStatusBarStyleLightContent; + } + if (@available(iOS 13.0, *)) { + if ([statusBarStyle isEqualToString:@"UIStatusBarStyleDarkContent"]) { + return UIStatusBarStyleDarkContent; + } + } + return UIStatusBarStyleDefault; +} + +@end +#endif // !SDL_PLATFORM_TVOS + +@interface SDLLaunchScreenController () + +#ifndef SDL_PLATFORM_TVOS +- (NSUInteger)supportedInterfaceOrientations; +#endif + +@end + +@implementation SDLLaunchScreenController + +- (instancetype)init +{ + return [self initWithNibName:nil bundle:[NSBundle mainBundle]]; +} + +- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil +{ + if (!(self = [super initWithNibName:nil bundle:nil])) { + return nil; + } + + NSString *screenname = nibNameOrNil; + NSBundle *bundle = nibBundleOrNil; + + // A launch screen may not exist. Fall back to launch images in that case. + if (screenname) { + @try { + self.view = [bundle loadNibNamed:screenname owner:self options:nil][0]; + } + @catch (NSException *exception) { + /* If a launch screen name is specified but it fails to load, iOS + * displays a blank screen rather than falling back to an image. */ + return nil; + } + } + + if (!self.view) { + NSArray *launchimages = [bundle objectForInfoDictionaryKey:@"UILaunchImages"]; + NSString *imagename = nil; + UIImage *image = nil; + +#ifdef SDL_PLATFORM_VISIONOS + int screenw = SDL_XR_SCREENWIDTH; + int screenh = SDL_XR_SCREENHEIGHT; +#else + int screenw = (int)([UIScreen mainScreen].bounds.size.width + 0.5); + int screenh = (int)([UIScreen mainScreen].bounds.size.height + 0.5); +#endif + + + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + UIInterfaceOrientation curorient = [UIApplication sharedApplication].statusBarOrientation; + + // We always want portrait-oriented size, to match UILaunchImageSize. + if (screenw > screenh) { + int width = screenw; + screenw = screenh; + screenh = width; + } +#endif + + // Xcode 5 introduced a dictionary of launch images in Info.plist. + if (launchimages) { + for (NSDictionary *dict in launchimages) { + NSString *minversion = dict[@"UILaunchImageMinimumOSVersion"]; + NSString *sizestring = dict[@"UILaunchImageSize"]; + + // Ignore this image if the current version is too low. + if (minversion && !UIKit_IsSystemVersionAtLeast(minversion.doubleValue)) { + continue; + } + + // Ignore this image if the size doesn't match. + if (sizestring) { + CGSize size = CGSizeFromString(sizestring); + if ((int)(size.width + 0.5) != screenw || (int)(size.height + 0.5) != screenh) { + continue; + } + } + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + UIInterfaceOrientationMask orientmask = UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; + NSString *orientstring = dict[@"UILaunchImageOrientation"]; + + if (orientstring) { + if ([orientstring isEqualToString:@"PortraitUpsideDown"]) { + orientmask = UIInterfaceOrientationMaskPortraitUpsideDown; + } else if ([orientstring isEqualToString:@"Landscape"]) { + orientmask = UIInterfaceOrientationMaskLandscape; + } else if ([orientstring isEqualToString:@"LandscapeLeft"]) { + orientmask = UIInterfaceOrientationMaskLandscapeLeft; + } else if ([orientstring isEqualToString:@"LandscapeRight"]) { + orientmask = UIInterfaceOrientationMaskLandscapeRight; + } + } + + // Ignore this image if the orientation doesn't match. + if ((orientmask & (1 << curorient)) == 0) { + continue; + } +#endif + + imagename = dict[@"UILaunchImageName"]; + } + + if (imagename) { + image = [UIImage imageNamed:imagename]; + } + } +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + else { + imagename = [bundle objectForInfoDictionaryKey:@"UILaunchImageFile"]; + + if (imagename) { + image = SDL_LoadLaunchImageNamed(imagename, screenh); + } + + if (!image) { + image = SDL_LoadLaunchImageNamed(@"Default", screenh); + } + } +#endif + + if (image) { +#ifdef SDL_PLATFORM_VISIONOS + CGRect viewFrame = CGRectMake(0, 0, screenw, screenh); +#else + CGRect viewFrame = [UIScreen mainScreen].bounds; +#endif + UIImageView *view = [[UIImageView alloc] initWithFrame:viewFrame]; + UIImageOrientation imageorient = UIImageOrientationUp; + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + // Bugs observed / workaround tested in iOS 8.3. + if (UIInterfaceOrientationIsLandscape(curorient)) { + if (image.size.width < image.size.height) { + /* On iOS 8, portrait launch images displayed in forced- + * landscape mode (e.g. a standard Default.png on an iPhone + * when Info.plist only supports landscape orientations) need + * to be rotated to display in the expected orientation. */ + if (curorient == UIInterfaceOrientationLandscapeLeft) { + imageorient = UIImageOrientationRight; + } else if (curorient == UIInterfaceOrientationLandscapeRight) { + imageorient = UIImageOrientationLeft; + } + } + } +#endif + + // Create the properly oriented image. + view.image = [[UIImage alloc] initWithCGImage:image.CGImage scale:image.scale orientation:imageorient]; + + self.view = view; + } + } + + return self; +} + +- (void)loadView +{ + // Do nothing. +} + +#ifndef SDL_PLATFORM_TVOS +- (BOOL)shouldAutorotate +{ + // If YES, the launch image will be incorrectly rotated in some cases. + return NO; +} + +- (NSUInteger)supportedInterfaceOrientations +{ + /* We keep the supported orientations unrestricted to avoid the case where + * there are no common orientations between the ones set in Info.plist and + * the ones set here (it will cause an exception in that case.) */ + return UIInterfaceOrientationMaskAll; +} +#endif // !SDL_PLATFORM_TVOS + +@end + +@implementation SDLUIKitDelegate +{ + UIWindow *launchWindow; +} + +// convenience method ++ (id)sharedAppDelegate +{ + /* the delegate is set in UIApplicationMain(), which is guaranteed to be + * called before this method */ + return [UIApplication sharedApplication].delegate; +} + ++ (NSString *)getAppDelegateClassName +{ + /* subclassing notice: when you subclass this appdelegate, make sure to add + * a category to override this method and return the actual name of the + * delegate */ + return @"SDLUIKitDelegate"; +} + +- (void)hideLaunchScreen +{ + UIWindow *window = launchWindow; + + if (!window || window.hidden) { + return; + } + + launchWindow = nil; + + // Do a nice animated fade-out (roughly matches the real launch behavior.) + [UIView animateWithDuration:0.2 + animations:^{ + window.alpha = 0.0; + } + completion:^(BOOL finished) { + window.hidden = YES; + UIKit_ForceUpdateHomeIndicator(); // Wait for launch screen to hide so settings are applied to the actual view controller. + }]; +} + +- (void)postFinishLaunch +{ + /* Hide the launch screen the next time the run loop is run. SDL apps will + * have a chance to load resources while the launch screen is still up. */ + [self performSelector:@selector(hideLaunchScreen) withObject:nil afterDelay:0.0]; + + // run the user's application, passing argc and argv + SDL_SetiOSEventPump(true); + exit_status = forward_main(forward_argc, forward_argv); + SDL_SetiOSEventPump(false); + + if (launchWindow) { + launchWindow.hidden = YES; + launchWindow = nil; + } + + // exit, passing the return status from the user's application + /* We don't actually exit to support applications that do setup in their + * main function and then allow the Cocoa event loop to run. */ + // exit(exit_status); +} + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions +{ + NSBundle *bundle = [NSBundle mainBundle]; + +#ifdef SDL_IPHONE_LAUNCHSCREEN + /* The normal launch screen is displayed until didFinishLaunching returns, + * but SDL_main is called after that happens and there may be a noticeable + * delay between the start of SDL_main and when the first real frame is + * displayed (e.g. if resources are loaded before SDL_GL_SwapWindow is + * called), so we show the launch screen programmatically until the first + * time events are pumped. */ + UIViewController *vc = nil; + NSString *screenname = nil; + + // tvOS only uses a plain launch image. +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + screenname = [bundle objectForInfoDictionaryKey:@"UILaunchStoryboardName"]; + + if (screenname) { + @try { + /* The launch storyboard is actually a nib in some older versions of + * Xcode. We'll try to load it as a storyboard first, as it's more + * modern. */ + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:screenname bundle:bundle]; + __auto_type storyboardVc = [storyboard instantiateInitialViewController]; + vc = [[SDLLaunchStoryboardViewController alloc] initWithStoryboardViewController:storyboardVc]; + } + @catch (NSException *exception) { + // Do nothing (there's more code to execute below). + } + } +#endif + + if (vc == nil) { + vc = [[SDLLaunchScreenController alloc] initWithNibName:screenname bundle:bundle]; + } + + if (vc.view) { +#ifdef SDL_PLATFORM_VISIONOS + CGRect viewFrame = CGRectMake(0, 0, SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); +#else + CGRect viewFrame = [UIScreen mainScreen].bounds; +#endif + launchWindow = [[UIWindow alloc] initWithFrame:viewFrame]; + + /* We don't want the launch window immediately hidden when a real SDL + * window is shown - we fade it out ourselves when we're ready. */ + launchWindow.windowLevel = UIWindowLevelNormal + 1.0; + + /* Show the window but don't make it key. Events should always go to + * other windows when possible. */ + launchWindow.hidden = NO; + + launchWindow.rootViewController = vc; + } +#endif + + // Set working directory to resource path + [[NSFileManager defaultManager] changeCurrentDirectoryPath:[bundle resourcePath]]; + + SDL_SetMainReady(); + [self performSelector:@selector(postFinishLaunch) withObject:nil afterDelay:0.0]; + + return YES; +} + +- (UIWindow *)window +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + if (_this) { + SDL_Window *window = NULL; + for (window = _this->windows; window != NULL; window = window->next) { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + if (data != nil) { + return data.uiwindow; + } + } + } + return nil; +} + +- (void)setWindow:(UIWindow *)window +{ + // Do nothing. +} + +- (void)sendDropFileForURL:(NSURL *)url fromSourceApplication:(NSString *)sourceApplication +{ + NSURL *fileURL = url.filePathURL; + const char *sourceApplicationCString = sourceApplication ? [sourceApplication UTF8String] : NULL; + if (fileURL != nil) { + SDL_SendDropFile(NULL, sourceApplicationCString, fileURL.path.UTF8String); + } else { + SDL_SendDropFile(NULL, sourceApplicationCString, url.absoluteString.UTF8String); + } + SDL_SendDropComplete(NULL); +} + +- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary *)options +{ + // TODO: Handle options + [self sendDropFileForURL:url fromSourceApplication:NULL]; + return YES; +} + +@end + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.h new file mode 100644 index 0000000..1c538c2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_uikitclipboard_h_ +#define SDL_uikitclipboard_h_ + +#include "../SDL_sysvideo.h" + +extern bool UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text); +extern char *UIKit_GetClipboardText(SDL_VideoDevice *_this); +extern bool UIKit_HasClipboardText(SDL_VideoDevice *_this); + +extern void UIKit_InitClipboard(SDL_VideoDevice *_this); +extern void UIKit_QuitClipboard(SDL_VideoDevice *_this); + +#endif // SDL_uikitclipboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.m new file mode 100644 index 0000000..8ed4eb0 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitclipboard.m @@ -0,0 +1,105 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "SDL_uikitvideo.h" +#include "../../events/SDL_clipboardevents_c.h" + +#import + +bool UIKit_SetClipboardText(SDL_VideoDevice *_this, const char *text) +{ +#ifdef SDL_PLATFORM_TVOS + return SDL_SetError("The clipboard is not available on tvOS"); +#else + @autoreleasepool { + [UIPasteboard generalPasteboard].string = @(text); + return true; + } +#endif +} + +char *UIKit_GetClipboardText(SDL_VideoDevice *_this) +{ +#ifdef SDL_PLATFORM_TVOS + return SDL_strdup(""); // Unsupported. +#else + @autoreleasepool { + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + NSString *string = pasteboard.string; + + if (string != nil) { + return SDL_strdup(string.UTF8String); + } else { + return SDL_strdup(""); + } + } +#endif +} + +bool UIKit_HasClipboardText(SDL_VideoDevice *_this) +{ + @autoreleasepool { +#ifndef SDL_PLATFORM_TVOS + if ([UIPasteboard generalPasteboard].string != nil) { + return true; + } +#endif + return false; + } +} + +void UIKit_InitClipboard(SDL_VideoDevice *_this) +{ +#ifndef SDL_PLATFORM_TVOS + @autoreleasepool { + SDL_UIKitVideoData *data = (__bridge SDL_UIKitVideoData *)_this->internal; + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + id observer = [center addObserverForName:UIPasteboardChangedNotification + object:nil + queue:nil + usingBlock:^(NSNotification *note) { + // TODO: compute mime types + SDL_SendClipboardUpdate(false, NULL, 0); + }]; + + data.pasteboardObserver = observer; + } +#endif +} + +void UIKit_QuitClipboard(SDL_VideoDevice *_this) +{ + @autoreleasepool { + SDL_UIKitVideoData *data = (__bridge SDL_UIKitVideoData *)_this->internal; + + if (data.pasteboardObserver != nil) { + [[NSNotificationCenter defaultCenter] removeObserver:data.pasteboardObserver]; + } + + data.pasteboardObserver = nil; + } +} + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.h new file mode 100644 index 0000000..c767fb1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_uikitevents_h_ +#define SDL_uikitevents_h_ + +#import + +#include "../SDL_sysvideo.h" + +extern void SDL_UpdateLifecycleObserver(void); + +extern Uint64 UIKit_GetEventTimestamp(NSTimeInterval nsTimestamp); +extern void UIKit_PumpEvents(SDL_VideoDevice *_this); + +extern void SDL_InitGCKeyboard(void); +extern void SDL_QuitGCKeyboard(void); + +extern void SDL_InitGCMouse(void); +extern bool SDL_GCMouseRelativeMode(void); +extern void SDL_QuitGCMouse(void); + +#endif // SDL_uikitevents_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.m new file mode 100644 index 0000000..86224f7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitevents.m @@ -0,0 +1,461 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "../../events/SDL_events_c.h" +#include "../../main/SDL_main_callbacks.h" + +#include "SDL_uikitevents.h" +#include "SDL_uikitopengles.h" +#include "SDL_uikitvideo.h" +#include "SDL_uikitwindow.h" + +#import +#import + +static BOOL UIKit_EventPumpEnabled = YES; + +@interface SDL_LifecycleObserver : NSObject +@property(nonatomic, assign) BOOL isObservingNotifications; +@end + +@implementation SDL_LifecycleObserver + +- (void)update +{ + NSNotificationCenter *notificationCenter = NSNotificationCenter.defaultCenter; + bool wants_observation = (UIKit_EventPumpEnabled || SDL_HasMainCallbacks()); + if (!wants_observation) { + // Make sure no windows have active animation callbacks + int num_windows = 0; + SDL_free(SDL_GetWindows(&num_windows)); + if (num_windows > 0) { + wants_observation = true; + } + } + if (wants_observation && !self.isObservingNotifications) { + self.isObservingNotifications = YES; + [notificationCenter addObserver:self selector:@selector(applicationDidBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(applicationWillResignActive) name:UIApplicationWillResignActiveNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(applicationDidEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(applicationWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(applicationWillTerminate) name:UIApplicationWillTerminateNotification object:nil]; + [notificationCenter addObserver:self selector:@selector(applicationDidReceiveMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + [notificationCenter addObserver:self + selector:@selector(applicationDidChangeStatusBarOrientation) + name:UIApplicationDidChangeStatusBarOrientationNotification + object:nil]; +#endif + } else if (!wants_observation && self.isObservingNotifications) { + self.isObservingNotifications = NO; + [notificationCenter removeObserver:self]; + } +} + +- (void)applicationDidBecomeActive +{ + SDL_OnApplicationDidEnterForeground(); +} + +- (void)applicationWillResignActive +{ + SDL_OnApplicationWillEnterBackground(); +} + +- (void)applicationDidEnterBackground +{ + SDL_OnApplicationDidEnterBackground(); +} + +- (void)applicationWillEnterForeground +{ + SDL_OnApplicationWillEnterForeground(); +} + +- (void)applicationWillTerminate +{ + SDL_OnApplicationWillTerminate(); +} + +- (void)applicationDidReceiveMemoryWarning +{ + SDL_OnApplicationDidReceiveMemoryWarning(); +} + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) +- (void)applicationDidChangeStatusBarOrientation +{ + SDL_OnApplicationDidChangeStatusBarOrientation(); +} +#endif + +@end + +void SDL_UpdateLifecycleObserver(void) +{ + static SDL_LifecycleObserver *lifecycleObserver; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + lifecycleObserver = [SDL_LifecycleObserver new]; + }); + [lifecycleObserver update]; +} + +void SDL_SetiOSEventPump(bool enabled) +{ + UIKit_EventPumpEnabled = enabled; + + SDL_UpdateLifecycleObserver(); +} + +Uint64 UIKit_GetEventTimestamp(NSTimeInterval nsTimestamp) +{ + static Uint64 timestamp_offset; + Uint64 timestamp = (Uint64)(nsTimestamp * SDL_NS_PER_SECOND); + Uint64 now = SDL_GetTicksNS(); + + if (!timestamp_offset) { + timestamp_offset = (now - timestamp); + } + timestamp += timestamp_offset; + + if (timestamp > now) { + timestamp_offset -= (timestamp - now); + timestamp = now; + } + return timestamp; +} + +void UIKit_PumpEvents(SDL_VideoDevice *_this) +{ + if (!UIKit_EventPumpEnabled) { + return; + } + + /* Let the run loop run for a short amount of time: long enough for + touch events to get processed (which is important to get certain + elements of Game Center's GKLeaderboardViewController to respond + to touch input), but not long enough to introduce a significant + delay in the rest of the app. + */ + const CFTimeInterval seconds = 0.000002; + + // Pump most event types. + SInt32 result; + do { + result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, seconds, TRUE); + } while (result == kCFRunLoopRunHandledSource); + + // Make sure UIScrollView objects scroll properly. + do { + result = CFRunLoopRunInMode((CFStringRef)UITrackingRunLoopMode, seconds, TRUE); + } while (result == kCFRunLoopRunHandledSource); + + // See the comment in the function definition. +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + UIKit_GL_RestoreCurrentContext(); +#endif +} + +static id keyboard_connect_observer = nil; +static id keyboard_disconnect_observer = nil; + +static void OnGCKeyboardConnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) +{ + SDL_KeyboardID keyboardID = (SDL_KeyboardID)(uintptr_t)keyboard; + + SDL_AddKeyboard(keyboardID, NULL, true); + + keyboard.keyboardInput.keyChangedHandler = ^(GCKeyboardInput *kbrd, GCControllerButtonInput *key, GCKeyCode keyCode, BOOL pressed) { + Uint64 timestamp = SDL_GetTicksNS(); + SDL_SendKeyboardKey(timestamp, keyboardID, 0, (SDL_Scancode)keyCode, pressed); + }; + + dispatch_queue_t queue = dispatch_queue_create("org.libsdl.input.keyboard", DISPATCH_QUEUE_SERIAL); + dispatch_set_target_queue(queue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)); + keyboard.handlerQueue = queue; +} + +static void OnGCKeyboardDisconnected(GCKeyboard *keyboard) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) +{ + SDL_KeyboardID keyboardID = (SDL_KeyboardID)(uintptr_t)keyboard; + + SDL_RemoveKeyboard(keyboardID, true); + + keyboard.keyboardInput.keyChangedHandler = nil; +} + +void SDL_InitGCKeyboard(void) +{ + @autoreleasepool { + if (@available(iOS 14.0, tvOS 14.0, *)) { + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + keyboard_connect_observer = [center addObserverForName:GCKeyboardDidConnectNotification + object:nil + queue:nil + usingBlock:^(NSNotification *note) { + GCKeyboard *keyboard = note.object; + OnGCKeyboardConnected(keyboard); + }]; + + keyboard_disconnect_observer = [center addObserverForName:GCKeyboardDidDisconnectNotification + object:nil + queue:nil + usingBlock:^(NSNotification *note) { + GCKeyboard *keyboard = note.object; + OnGCKeyboardDisconnected(keyboard); + }]; + + if (GCKeyboard.coalescedKeyboard != nil) { + OnGCKeyboardConnected(GCKeyboard.coalescedKeyboard); + } + } + } +} + +void SDL_QuitGCKeyboard(void) +{ + @autoreleasepool { + if (@available(iOS 14.0, tvOS 14.0, *)) { + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + if (keyboard_connect_observer) { + [center removeObserver:keyboard_connect_observer name:GCKeyboardDidConnectNotification object:nil]; + keyboard_connect_observer = nil; + } + + if (keyboard_disconnect_observer) { + [center removeObserver:keyboard_disconnect_observer name:GCKeyboardDidDisconnectNotification object:nil]; + keyboard_disconnect_observer = nil; + } + + if (GCKeyboard.coalescedKeyboard != nil) { + OnGCKeyboardDisconnected(GCKeyboard.coalescedKeyboard); + } + } + } +} + +static id mouse_connect_observer = nil; +static id mouse_disconnect_observer = nil; +static bool mouse_relative_mode = false; +static SDL_MouseWheelDirection mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; + +static void UpdateScrollDirection(void) +{ +#if 0 // This code doesn't work for some reason + NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; + if ([userDefaults boolForKey:@"com.apple.swipescrolldirection"]) { + mouse_scroll_direction = SDL_MOUSEWHEEL_FLIPPED; + } else { + mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; + } +#else + Boolean keyExistsAndHasValidFormat = NO; + Boolean naturalScrollDirection = CFPreferencesGetAppBooleanValue(CFSTR("com.apple.swipescrolldirection"), kCFPreferencesAnyApplication, &keyExistsAndHasValidFormat); + if (!keyExistsAndHasValidFormat) { + // Couldn't read the preference, assume natural scrolling direction + naturalScrollDirection = YES; + } + if (naturalScrollDirection) { + mouse_scroll_direction = SDL_MOUSEWHEEL_FLIPPED; + } else { + mouse_scroll_direction = SDL_MOUSEWHEEL_NORMAL; + } +#endif +} + +static void UpdatePointerLock(void) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + SDL_Window *window; + + for (window = _this->windows; window != NULL; window = window->next) { + UIKit_UpdatePointerLock(_this, window); + } +} + +static bool SetGCMouseRelativeMode(bool enabled) +{ + mouse_relative_mode = enabled; + UpdatePointerLock(); + return true; +} + +static void OnGCMouseButtonChanged(SDL_MouseID mouseID, Uint8 button, BOOL pressed) +{ + Uint64 timestamp = SDL_GetTicksNS(); + SDL_SendMouseButton(timestamp, SDL_GetMouseFocus(), mouseID, button, pressed); +} + +static void OnGCMouseConnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) +{ + SDL_MouseID mouseID = (SDL_MouseID)(uintptr_t)mouse; + + SDL_AddMouse(mouseID, NULL, true); + + mouse.mouseInput.leftButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, SDL_BUTTON_LEFT, pressed); + }; + mouse.mouseInput.middleButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, SDL_BUTTON_MIDDLE, pressed); + }; + mouse.mouseInput.rightButton.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, SDL_BUTTON_RIGHT, pressed); + }; + + int auxiliary_button = SDL_BUTTON_X1; + for (GCControllerButtonInput *btn in mouse.mouseInput.auxiliaryButtons) { + btn.pressedChangedHandler = ^(GCControllerButtonInput *button, float value, BOOL pressed) { + OnGCMouseButtonChanged(mouseID, auxiliary_button, pressed); + }; + ++auxiliary_button; + } + + mouse.mouseInput.mouseMovedHandler = ^(GCMouseInput *mouseInput, float deltaX, float deltaY) { + Uint64 timestamp = SDL_GetTicksNS(); + + if (SDL_GCMouseRelativeMode()) { + SDL_SendMouseMotion(timestamp, SDL_GetMouseFocus(), mouseID, true, deltaX, -deltaY); + } + }; + + mouse.mouseInput.scroll.valueChangedHandler = ^(GCControllerDirectionPad *dpad, float xValue, float yValue) { + Uint64 timestamp = SDL_GetTicksNS(); + + /* Raw scroll values come in here, vertical values in the first axis, horizontal values in the second axis. + * The vertical values are negative moving the mouse wheel up and positive moving it down. + * The horizontal values are negative moving the mouse wheel left and positive moving it right. + * The vertical values are inverted compared to SDL, and the horizontal values are as expected. + */ + float vertical = -xValue; + float horizontal = yValue; + + if (mouse_scroll_direction == SDL_MOUSEWHEEL_FLIPPED) { + // Since these are raw values, we need to flip them ourselves + vertical = -vertical; + horizontal = -horizontal; + } + SDL_SendMouseWheel(timestamp, SDL_GetMouseFocus(), mouseID, horizontal, vertical, mouse_scroll_direction); + }; + UpdateScrollDirection(); + + dispatch_queue_t queue = dispatch_queue_create("org.libsdl.input.mouse", DISPATCH_QUEUE_SERIAL); + dispatch_set_target_queue(queue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)); + mouse.handlerQueue = queue; + + UpdatePointerLock(); +} + +static void OnGCMouseDisconnected(GCMouse *mouse) API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) +{ + SDL_MouseID mouseID = (SDL_MouseID)(uintptr_t)mouse; + + mouse.mouseInput.mouseMovedHandler = nil; + + mouse.mouseInput.leftButton.pressedChangedHandler = nil; + mouse.mouseInput.middleButton.pressedChangedHandler = nil; + mouse.mouseInput.rightButton.pressedChangedHandler = nil; + + for (GCControllerButtonInput *button in mouse.mouseInput.auxiliaryButtons) { + button.pressedChangedHandler = nil; + } + + UpdatePointerLock(); + + SDL_RemoveMouse(mouseID, true); +} + +void SDL_InitGCMouse(void) +{ + @autoreleasepool { + // There is a bug where mouse accumulates duplicate deltas over time in iOS 14.0 + if (@available(iOS 14.1, tvOS 14.1, *)) { + /* iOS will not send the new pointer touch events if you don't have this key, + * and we need them to differentiate between mouse events and real touch events. + */ + BOOL indirect_input_available = [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"UIApplicationSupportsIndirectInputEvents"] boolValue]; + if (indirect_input_available) { + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + mouse_connect_observer = [center addObserverForName:GCMouseDidConnectNotification + object:nil + queue:nil + usingBlock:^(NSNotification *note) { + GCMouse *mouse = note.object; + OnGCMouseConnected(mouse); + }]; + + mouse_disconnect_observer = [center addObserverForName:GCMouseDidDisconnectNotification + object:nil + queue:nil + usingBlock:^(NSNotification *note) { + GCMouse *mouse = note.object; + OnGCMouseDisconnected(mouse); + }]; + + for (GCMouse *mouse in [GCMouse mice]) { + OnGCMouseConnected(mouse); + } + + SDL_GetMouse()->SetRelativeMouseMode = SetGCMouseRelativeMode; + } else { + NSLog(@"You need UIApplicationSupportsIndirectInputEvents in your Info.plist for mouse support"); + } + } + } +} + +bool SDL_GCMouseRelativeMode(void) +{ + return mouse_relative_mode; +} + +void SDL_QuitGCMouse(void) +{ + @autoreleasepool { + if (@available(iOS 14.1, tvOS 14.1, *)) { + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + if (mouse_connect_observer) { + [center removeObserver:mouse_connect_observer name:GCMouseDidConnectNotification object:nil]; + mouse_connect_observer = nil; + } + + if (mouse_disconnect_observer) { + [center removeObserver:mouse_disconnect_observer name:GCMouseDidDisconnectNotification object:nil]; + mouse_disconnect_observer = nil; + } + + for (GCMouse *mouse in [GCMouse mice]) { + OnGCMouseDisconnected(mouse); + } + + SDL_GetMouse()->SetRelativeMouseMode = NULL; + } + } +} + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.h new file mode 100644 index 0000000..5c21f7c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +extern bool UIKit_ShowingMessageBox(void); +extern bool UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.m new file mode 100644 index 0000000..a57b3f7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmessagebox.m @@ -0,0 +1,154 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "SDL_uikitvideo.h" +#include "SDL_uikitwindow.h" + +// Display a UIKit message box + +static bool s_showingMessageBox = false; + +bool UIKit_ShowingMessageBox(void) +{ + return s_showingMessageBox; +} + +static void UIKit_WaitUntilMessageBoxClosed(const SDL_MessageBoxData *messageboxdata, int *clickedindex) +{ + *clickedindex = messageboxdata->numbuttons; + + @autoreleasepool { + // Run the main event loop until the alert has finished + // Note that this needs to be done on the main thread + s_showingMessageBox = true; + while ((*clickedindex) == messageboxdata->numbuttons) { + [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; + } + s_showingMessageBox = false; + } +} + +static BOOL UIKit_ShowMessageBoxAlertController(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + int i; + int __block clickedindex = messageboxdata->numbuttons; + UIWindow *window = nil; + UIWindow *alertwindow = nil; + + if (![UIAlertController class]) { + return NO; + } + + UIAlertController *alert; + alert = [UIAlertController alertControllerWithTitle:@(messageboxdata->title) + message:@(messageboxdata->message) + preferredStyle:UIAlertControllerStyleAlert]; + + for (i = 0; i < messageboxdata->numbuttons; i++) { + UIAlertAction *action; + UIAlertActionStyle style = UIAlertActionStyleDefault; + const SDL_MessageBoxButtonData *sdlButton; + + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { + sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i]; + } else { + sdlButton = &messageboxdata->buttons[i]; + } + + if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) { + style = UIAlertActionStyleCancel; + } + + action = [UIAlertAction actionWithTitle:@(sdlButton->text) + style:style + handler:^(UIAlertAction *alertAction) { + clickedindex = (int)(sdlButton - messageboxdata->buttons); + }]; + [alert addAction:action]; + + if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { + alert.preferredAction = action; + } + } + + if (messageboxdata->window) { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)messageboxdata->window->internal; + window = data.uiwindow; + } + + if (window == nil || window.rootViewController == nil) { +#ifdef SDL_PLATFORM_VISIONOS + alertwindow = [[UIWindow alloc] init]; +#else + alertwindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; +#endif + alertwindow.rootViewController = [UIViewController new]; + alertwindow.windowLevel = UIWindowLevelAlert; + + window = alertwindow; + + [alertwindow makeKeyAndVisible]; + } + + [window.rootViewController presentViewController:alert animated:YES completion:nil]; + UIKit_WaitUntilMessageBoxClosed(messageboxdata, &clickedindex); + + if (alertwindow) { + alertwindow.hidden = YES; + } + + UIKit_ForceUpdateHomeIndicator(); + + *buttonID = messageboxdata->buttons[clickedindex].buttonID; + return YES; +} + +static void UIKit_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonID, int *result) +{ + @autoreleasepool { + if (UIKit_ShowMessageBoxAlertController(messageboxdata, buttonID)) { + *result = true; + } else { + *result = SDL_SetError("Could not show message box."); + } + } +} + +bool UIKit_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + @autoreleasepool { + __block int result = true; + + if ([NSThread isMainThread]) { + UIKit_ShowMessageBoxImpl(messageboxdata, buttonID, &result); + } else { + dispatch_sync(dispatch_get_main_queue(), ^{ + UIKit_ShowMessageBoxImpl(messageboxdata, buttonID, &result); + }); + } + return result; + } +} + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.h new file mode 100644 index 0000000..20bcf7c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.h @@ -0,0 +1,54 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + */ + +/* + * @author Mark Callow, www.edgewise-consulting.com. + * + * Thanks to @slime73 on GitHub for their gist showing how to add a CAMetalLayer + * backed view. + */ + +#ifndef SDL_uikitmetalview_h_ +#define SDL_uikitmetalview_h_ + +#include "../SDL_sysvideo.h" +#include "SDL_uikitwindow.h" + +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) + +#import +#import +#import + +@interface SDL_uikitmetalview : SDL_uikitview + +- (instancetype)initWithFrame:(CGRect)frame + scale:(CGFloat)scale; + +@end + +SDL_MetalView UIKit_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window); +void UIKit_Metal_DestroyView(SDL_VideoDevice *_this, SDL_MetalView view); +void *UIKit_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view); + +#endif // SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) + +#endif // SDL_uikitmetalview_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.m new file mode 100644 index 0000000..010dae4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmetalview.m @@ -0,0 +1,140 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + */ + +/* + * @author Mark Callow, www.edgewise-consulting.com. + * + * Thanks to @slime73 on GitHub for their gist showing how to add a CAMetalLayer + * backed view. + */ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_VULKAN) || defined(SDL_VIDEO_METAL)) + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_windowevents_c.h" + +#import "SDL_uikitwindow.h" +#import "SDL_uikitmetalview.h" + +@implementation SDL_uikitmetalview + +// Returns a Metal-compatible layer. ++ (Class)layerClass +{ + return [CAMetalLayer class]; +} + +- (instancetype)initWithFrame:(CGRect)frame + scale:(CGFloat)scale +{ + if ((self = [super initWithFrame:frame])) { + self.tag = SDL_METALVIEW_TAG; + self.layer.contentsScale = scale; + [self updateDrawableSize]; + } + + return self; +} + +// Set the size of the metal drawables when the view is resized. +- (void)layoutSubviews +{ + [super layoutSubviews]; + [self updateDrawableSize]; +} + +- (void)updateDrawableSize +{ + CGSize size = self.bounds.size; + size.width *= self.layer.contentsScale; + size.height *= self.layer.contentsScale; + + CAMetalLayer *metallayer = ((CAMetalLayer *)self.layer); + if (metallayer.drawableSize.width != size.width || + metallayer.drawableSize.height != size.height) { + metallayer.drawableSize = size; + SDL_SendWindowEvent([self getSDLWindow], SDL_EVENT_WINDOW_METAL_VIEW_RESIZED, 0, 0); + } +} + +@end + +SDL_MetalView UIKit_Metal_CreateView(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + CGFloat scale = 1.0; + SDL_uikitmetalview *metalview; + + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + /* Set the scale to the natural scale factor of the screen - then + * the backing dimensions of the Metal view will match the pixel + * dimensions of the screen rather than the dimensions in points + * yielding high resolution on retine displays. + */ +#ifndef SDL_PLATFORM_VISIONOS + scale = data.uiwindow.screen.nativeScale; +#else + // VisionOS doesn't use the concept of "nativeScale" like other iOS devices. + // We use a fixed scale factor of 2.0 to achieve better pixel density. + // This is because VisionOS presents a virtual 1280x720 "screen", but we need + // to render at a higher resolution for optimal visual quality. + // TODO: Consider making this configurable or determining it dynamically + // based on the specific visionOS device capabilities. + scale = 2.0; +#endif + } + + metalview = [[SDL_uikitmetalview alloc] initWithFrame:data.uiwindow.bounds + scale:scale]; + if (metalview == nil) { + SDL_OutOfMemory(); + return NULL; + } + + [metalview setSDLWindow:window]; + + return (void *)CFBridgingRetain(metalview); + } +} + +void UIKit_Metal_DestroyView(SDL_VideoDevice *_this, SDL_MetalView view) +{ + @autoreleasepool { + SDL_uikitmetalview *metalview = CFBridgingRelease(view); + + if ([metalview isKindOfClass:[SDL_uikitmetalview class]]) { + [metalview setSDLWindow:NULL]; + } + } +} + +void *UIKit_Metal_GetLayer(SDL_VideoDevice *_this, SDL_MetalView view) +{ + @autoreleasepool { + SDL_uikitview *uiview = (__bridge SDL_uikitview *)view; + return (__bridge void *)uiview.layer; + } +} + +#endif // SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.h new file mode 100644 index 0000000..1b25cfd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.h @@ -0,0 +1,67 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_uikitmodes_h_ +#define SDL_uikitmodes_h_ + +#include "SDL_uikitvideo.h" + +@interface SDL_UIKitDisplayData : NSObject + +#ifndef SDL_PLATFORM_VISIONOS +- (instancetype)initWithScreen:(UIScreen *)screen; +@property(nonatomic, strong) UIScreen *uiscreen; +#endif + +@end + +@interface SDL_UIKitDisplayModeData : NSObject +#ifndef SDL_PLATFORM_VISIONOS +@property(nonatomic, strong) UIScreenMode *uiscreenmode; +#endif + +@end + +#ifndef SDL_PLATFORM_VISIONOS +extern bool UIKit_IsDisplayLandscape(UIScreen *uiscreen); +#endif + +extern bool UIKit_InitModes(SDL_VideoDevice *_this); +#ifndef SDL_PLATFORM_VISIONOS +extern bool UIKit_AddDisplay(UIScreen *uiscreen, bool send_event); +extern void UIKit_DelDisplay(UIScreen *uiscreen, bool send_event); +#endif +extern bool UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool UIKit_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern void UIKit_QuitModes(SDL_VideoDevice *_this); +extern bool UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); + +// because visionOS does not have a screen +// we create a fake display to maintain compatibility. +// By default, a window measures 1280x720 pt. +// https://developer.apple.com/design/human-interface-guidelines/windows#visionOS +#ifdef SDL_PLATFORM_VISIONOS +#define SDL_XR_SCREENWIDTH 1280 +#define SDL_XR_SCREENHEIGHT 720 +#endif + +#endif // SDL_uikitmodes_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.m new file mode 100644 index 0000000..d3247db --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitmodes.m @@ -0,0 +1,543 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "SDL_uikitmodes.h" + +#include "../../events/SDL_events_c.h" + +#import + +@implementation SDL_UIKitDisplayData + +#ifndef SDL_PLATFORM_VISIONOS +- (instancetype)initWithScreen:(UIScreen *)screen +{ + if (self = [super init]) { + self.uiscreen = screen; + } + return self; +} +@synthesize uiscreen; +#endif + +@end + +@implementation SDL_UIKitDisplayModeData + +#ifndef SDL_PLATFORM_VISIONOS +@synthesize uiscreenmode; +#endif + +@end + +@interface SDL_DisplayWatch : NSObject +@end + +#ifndef SDL_PLATFORM_VISIONOS +@implementation SDL_DisplayWatch + ++ (void)start +{ + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + [center addObserver:self + selector:@selector(screenConnected:) + name:UIScreenDidConnectNotification + object:nil]; + [center addObserver:self + selector:@selector(screenDisconnected:) + name:UIScreenDidDisconnectNotification + object:nil]; +} + ++ (void)stop +{ + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; + + [center removeObserver:self + name:UIScreenDidConnectNotification + object:nil]; + [center removeObserver:self + name:UIScreenDidDisconnectNotification + object:nil]; +} + ++ (void)screenConnected:(NSNotification *)notification +{ + UIScreen *uiscreen = [notification object]; + UIKit_AddDisplay(uiscreen, true); +} + ++ (void)screenDisconnected:(NSNotification *)notification +{ + UIScreen *uiscreen = [notification object]; + UIKit_DelDisplay(uiscreen, true); +} + +@end +#endif + +#ifndef SDL_PLATFORM_VISIONOS +static bool UIKit_AllocateDisplayModeData(SDL_DisplayMode *mode, + UIScreenMode *uiscreenmode) +{ + SDL_UIKitDisplayModeData *data = nil; + + if (uiscreenmode != nil) { + // Allocate the display mode data + data = [[SDL_UIKitDisplayModeData alloc] init]; + if (!data) { + return SDL_OutOfMemory(); + } + + data.uiscreenmode = uiscreenmode; + } + + mode->internal = (void *)CFBridgingRetain(data); + + return true; +} +#endif + +static void UIKit_FreeDisplayModeData(SDL_DisplayMode *mode) +{ + if (mode->internal != NULL) { + CFRelease(mode->internal); + mode->internal = NULL; + } +} + +#ifndef SDL_PLATFORM_VISIONOS +static float UIKit_GetDisplayModeRefreshRate(UIScreen *uiscreen) +{ + return (float)uiscreen.maximumFramesPerSecond; +} + +static bool UIKit_AddSingleDisplayMode(SDL_VideoDisplay *display, int w, int h, + UIScreen *uiscreen, UIScreenMode *uiscreenmode) +{ + SDL_DisplayMode mode; + + SDL_zero(mode); + if (!UIKit_AllocateDisplayModeData(&mode, uiscreenmode)) { + return false; + } + + mode.w = w; + mode.h = h; + mode.pixel_density = uiscreen.nativeScale; + mode.refresh_rate = UIKit_GetDisplayModeRefreshRate(uiscreen); + mode.format = SDL_PIXELFORMAT_ABGR8888; + + if (SDL_AddFullscreenDisplayMode(display, &mode)) { + return true; + } else { + UIKit_FreeDisplayModeData(&mode); + return false; + } +} + +static bool UIKit_AddDisplayMode(SDL_VideoDisplay *display, int w, int h, + UIScreen *uiscreen, UIScreenMode *uiscreenmode, bool addRotation) +{ + if (!UIKit_AddSingleDisplayMode(display, w, h, uiscreen, uiscreenmode)) { + return false; + } + + if (addRotation) { + // Add the rotated version + if (!UIKit_AddSingleDisplayMode(display, h, w, uiscreen, uiscreenmode)) { + return false; + } + } + + return true; +} + +static CGSize GetUIScreenModeSize(UIScreen *uiscreen, UIScreenMode *mode) +{ + /* For devices such as iPhone 6/7/8 Plus, the UIScreenMode reported by iOS + * isn't the physical pixels of the display, but rather the point size times + * the scale. For example, on iOS 12.2 on iPhone 8 Plus the physical pixel + * resolution is 1080x1920, the size reported by mode.size is 1242x2208, + * the size in points is 414x736, the scale property is 3.0, and the + * nativeScale property is ~2.6087 (ie 1920.0 / 736.0). + * + * What we want for the mode size is the point size, and the pixel density + * is the native scale. + * + * Note that the iOS Simulator doesn't have this behavior for those devices. + * https://github.com/libsdl-org/SDL/issues/3220 + */ + CGSize size = mode.size; + + size.width = SDL_round(size.width / uiscreen.scale); + size.height = SDL_round(size.height / uiscreen.scale); + + return size; +} + +bool UIKit_AddDisplay(UIScreen *uiscreen, bool send_event) +{ + UIScreenMode *uiscreenmode = uiscreen.currentMode; + CGSize size = GetUIScreenModeSize(uiscreen, uiscreenmode); + SDL_VideoDisplay display; + SDL_DisplayMode mode; + + // Make sure the width/height are oriented correctly + if (UIKit_IsDisplayLandscape(uiscreen) != (size.width > size.height)) { + CGFloat height = size.width; + size.width = size.height; + size.height = height; + } + + SDL_zero(mode); + mode.w = (int)size.width; + mode.h = (int)size.height; + mode.pixel_density = uiscreen.nativeScale; + mode.format = SDL_PIXELFORMAT_ABGR8888; + mode.refresh_rate = UIKit_GetDisplayModeRefreshRate(uiscreen); + + if (!UIKit_AllocateDisplayModeData(&mode, uiscreenmode)) { + return false; + } + + SDL_zero(display); +#ifndef SDL_PLATFORM_TVOS + if (uiscreen == [UIScreen mainScreen]) { + // The natural orientation (used by sensors) is portrait + display.natural_orientation = SDL_ORIENTATION_PORTRAIT; + } else +#endif + if (UIKit_IsDisplayLandscape(uiscreen)) { + display.natural_orientation = SDL_ORIENTATION_LANDSCAPE; + } else { + display.natural_orientation = SDL_ORIENTATION_PORTRAIT; + } + display.desktop_mode = mode; + + display.HDR.SDR_white_level = 1.0f; + display.HDR.HDR_headroom = 1.0f; + +#ifndef SDL_PLATFORM_TVOS + if (@available(iOS 16.0, *)) { + if (uiscreen.currentEDRHeadroom > 1.0f) { + display.HDR.HDR_headroom = uiscreen.currentEDRHeadroom; + } else { + display.HDR.HDR_headroom = uiscreen.potentialEDRHeadroom; + } + } +#endif // !SDL_PLATFORM_TVOS + + // Allocate the display data +#ifdef SDL_PLATFORM_VISIONOS + SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] init]; +#else + SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] initWithScreen:uiscreen]; +#endif + if (!data) { + UIKit_FreeDisplayModeData(&display.desktop_mode); + return SDL_OutOfMemory(); + } + + display.internal = (SDL_DisplayData *)CFBridgingRetain(data); + if (SDL_AddVideoDisplay(&display, send_event) == 0) { + return false; + } + return true; +} +#endif + +#ifdef SDL_PLATFORM_VISIONOS +bool UIKit_AddDisplay(bool send_event){ + CGSize size = CGSizeMake(SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); + SDL_VideoDisplay display; + SDL_DisplayMode mode; + + SDL_zero(mode); + mode.w = (int)size.width; + mode.h = (int)size.height; + mode.pixel_density = 1; + mode.format = SDL_PIXELFORMAT_ABGR8888; + mode.refresh_rate = 60.0f; + + display.natural_orientation = SDL_ORIENTATION_LANDSCAPE; + + display.desktop_mode = mode; + + SDL_UIKitDisplayData *data = [[SDL_UIKitDisplayData alloc] init]; + + if (!data) { + UIKit_FreeDisplayModeData(&display.desktop_mode); + return SDL_OutOfMemory(); + } + + display.internal = (SDL_DisplayData *)CFBridgingRetain(data); + if (SDL_AddVideoDisplay(&display, send_event) == 0) { + return false; + } + return true; +} +#endif + +#ifndef SDL_PLATFORM_VISIONOS + +void UIKit_DelDisplay(UIScreen *uiscreen, bool send_event) +{ + SDL_DisplayID *displays; + int i; + + displays = SDL_GetDisplays(NULL); + if (displays) { + for (i = 0; displays[i]; ++i) { + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displays[i]); + SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->internal; + + if (data && data.uiscreen == uiscreen) { + CFRelease(display->internal); + display->internal = NULL; + SDL_DelVideoDisplay(displays[i], send_event); + break; + } + } + SDL_free(displays); + } +} + +bool UIKit_IsDisplayLandscape(UIScreen *uiscreen) +{ +#ifndef SDL_PLATFORM_TVOS + if (uiscreen == [UIScreen mainScreen]) { + return UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); + } else +#endif // !SDL_PLATFORM_TVOS + { + CGSize size = uiscreen.bounds.size; + return (size.width > size.height); + } +} +#endif +bool UIKit_InitModes(SDL_VideoDevice *_this) +{ + @autoreleasepool { +#ifdef SDL_PLATFORM_VISIONOS + UIKit_AddDisplay(false); +#else + for (UIScreen *uiscreen in [UIScreen screens]) { + if (!UIKit_AddDisplay(uiscreen, false)) { + return false; + } + } +#endif + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + SDL_OnApplicationDidChangeStatusBarOrientation(); +#endif + +#ifndef SDL_PLATFORM_VISIONOS + [SDL_DisplayWatch start]; +#endif + } + + return true; +} + +bool UIKit_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ +#ifndef SDL_PLATFORM_VISIONOS + @autoreleasepool { + SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->internal; + + bool isLandscape = UIKit_IsDisplayLandscape(data.uiscreen); + bool addRotation = (data.uiscreen == [UIScreen mainScreen]); + NSArray *availableModes = nil; + +#ifdef SDL_PLATFORM_TVOS + addRotation = false; + availableModes = @[ data.uiscreen.currentMode ]; +#else + availableModes = data.uiscreen.availableModes; +#endif + + for (UIScreenMode *uimode in availableModes) { + CGSize size = GetUIScreenModeSize(data.uiscreen, uimode); + int w = (int)size.width; + int h = (int)size.height; + + // Make sure the width/height are oriented correctly + if (isLandscape != (w > h)) { + int tmp = w; + w = h; + h = tmp; + } + + UIKit_AddDisplayMode(display, w, h, data.uiscreen, uimode, addRotation); + } + } +#endif + return true; +} + +bool UIKit_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ +#ifndef SDL_PLATFORM_VISIONOS + @autoreleasepool { + SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->internal; + +#ifndef SDL_PLATFORM_TVOS + SDL_UIKitDisplayModeData *modedata = (__bridge SDL_UIKitDisplayModeData *)mode->internal; + [data.uiscreen setCurrentMode:modedata.uiscreenmode]; +#endif + + if (data.uiscreen == [UIScreen mainScreen]) { + /* [UIApplication setStatusBarOrientation:] no longer works reliably + * in recent iOS versions, so we can't rotate the screen when setting + * the display mode. */ + if (mode->w > mode->h) { + if (!UIKit_IsDisplayLandscape(data.uiscreen)) { + return SDL_SetError("Screen orientation does not match display mode size"); + } + } else if (mode->w < mode->h) { + if (UIKit_IsDisplayLandscape(data.uiscreen)) { + return SDL_SetError("Screen orientation does not match display mode size"); + } + } + } + } +#endif + return true; +} + +bool UIKit_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + @autoreleasepool { + SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->internal; +#ifdef SDL_PLATFORM_VISIONOS + CGRect frame = CGRectMake(0, 0, SDL_XR_SCREENWIDTH, SDL_XR_SCREENHEIGHT); +#else + CGRect frame = data.uiscreen.bounds; +#endif + + /* the default function iterates displays to make a fake offset, + as if all the displays were side-by-side, which is fine for iOS. */ + if (!SDL_GetDisplayBounds(display->id, rect)) { + return false; + } + + rect->x += (int)frame.origin.x; + rect->y += (int)frame.origin.y; + rect->w = (int)frame.size.width; + rect->h = (int)frame.size.height; + } + + return true; +} + +void UIKit_QuitModes(SDL_VideoDevice *_this) +{ +#ifndef SDL_PLATFORM_VISIONOS + [SDL_DisplayWatch stop]; +#endif + + // Release Objective-C objects, so higher level doesn't free() them. + int i, j; + @autoreleasepool { + for (i = 0; i < _this->num_displays; i++) { + SDL_VideoDisplay *display = _this->displays[i]; + + UIKit_FreeDisplayModeData(&display->desktop_mode); + for (j = 0; j < display->num_fullscreen_modes; j++) { + SDL_DisplayMode *mode = &display->fullscreen_modes[j]; + UIKit_FreeDisplayModeData(mode); + } + + if (display->internal != NULL) { + CFRelease(display->internal); + display->internal = NULL; + } + } + } +} + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) +void SDL_OnApplicationDidChangeStatusBarOrientation(void) +{ + BOOL isLandscape = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation); + SDL_VideoDisplay *display = SDL_GetVideoDisplay(SDL_GetPrimaryDisplay()); + + if (display) { + SDL_DisplayMode *mode = &display->desktop_mode; + SDL_DisplayOrientation orientation = SDL_ORIENTATION_UNKNOWN; + int i; + + /* The desktop display mode should be kept in sync with the screen + * orientation so that updating a window's fullscreen state to + * fullscreen desktop keeps the window dimensions in the + * correct orientation. */ + if (isLandscape != (mode->w > mode->h)) { + SDL_DisplayMode new_mode; + SDL_copyp(&new_mode, mode); + new_mode.w = mode->h; + new_mode.h = mode->w; + + // Make sure we don't free the current display mode data + mode->internal = NULL; + + SDL_SetDesktopDisplayMode(display, &new_mode); + } + + // Same deal with the fullscreen modes + for (i = 0; i < display->num_fullscreen_modes; ++i) { + mode = &display->fullscreen_modes[i]; + if (isLandscape != (mode->w > mode->h)) { + int height = mode->w; + mode->w = mode->h; + mode->h = height; + } + } + + switch ([UIApplication sharedApplication].statusBarOrientation) { + case UIInterfaceOrientationPortrait: + orientation = SDL_ORIENTATION_PORTRAIT; + break; + case UIInterfaceOrientationPortraitUpsideDown: + orientation = SDL_ORIENTATION_PORTRAIT_FLIPPED; + break; + case UIInterfaceOrientationLandscapeLeft: + // Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 + orientation = SDL_ORIENTATION_LANDSCAPE_FLIPPED; + break; + case UIInterfaceOrientationLandscapeRight: + // Bug: UIInterfaceOrientationLandscapeLeft/Right are reversed - http://openradar.appspot.com/7216046 + orientation = SDL_ORIENTATION_LANDSCAPE; + break; + default: + break; + } + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ORIENTATION, orientation, 0); + } +} +#endif // !SDL_PLATFORM_TVOS + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.h new file mode 100644 index 0000000..cc259f7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_uikitopengles_ +#define SDL_uikitopengles_ + +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + +#include "../SDL_sysvideo.h" + +extern bool UIKit_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, + SDL_GLContext context); +extern bool UIKit_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_GLContext UIKit_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool UIKit_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern SDL_FunctionPointer UIKit_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern bool UIKit_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); + +extern void UIKit_GL_RestoreCurrentContext(void); + +#endif // SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 + +#endif // SDL_uikitopengles_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.m new file mode 100644 index 0000000..a73588b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopengles.m @@ -0,0 +1,221 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)) + +#include "SDL_uikitopengles.h" +#import "SDL_uikitopenglview.h" +#include "SDL_uikitmodes.h" +#include "SDL_uikitwindow.h" +#include "SDL_uikitevents.h" +#include "../SDL_sysvideo.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../power/uikit/SDL_syspower.h" +#include + +@interface SDLEAGLContext : EAGLContext + +// The OpenGL ES context owns a view / drawable. +@property(nonatomic, strong) SDL_uikitopenglview *sdlView; + +@end + +@implementation SDLEAGLContext + +- (void)dealloc +{ + /* When the context is deallocated, its view should be removed from any + * SDL window that it's attached to. */ + [self.sdlView setSDLWindow:NULL]; +} + +@end + +SDL_FunctionPointer UIKit_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + /* Look through all SO's for the proc symbol. Here's why: + * -Looking for the path to the OpenGL Library seems not to work in the iOS Simulator. + * -We don't know that the path won't change in the future. */ + return dlsym(RTLD_DEFAULT, proc); +} + +/* + note that SDL_GL_DestroyContext makes it current without passing the window +*/ +bool UIKit_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + @autoreleasepool { + SDLEAGLContext *eaglcontext = (__bridge SDLEAGLContext *)context; + + if (![EAGLContext setCurrentContext:eaglcontext]) { + return SDL_SetError("Could not make EAGL context current"); + } + + if (eaglcontext) { + [eaglcontext.sdlView setSDLWindow:window]; + } + } + + return true; +} + +bool UIKit_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + /* We shouldn't pass a path to this function, since we've already loaded the + * library. */ + if (path != NULL) { + return SDL_SetError("iOS GL Load Library just here for compatibility"); + } + return true; +} + +bool UIKit_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDLEAGLContext *context = (__bridge SDLEAGLContext *)SDL_GL_GetCurrentContext(); + +#ifdef SDL_POWER_UIKIT + // Check once a frame to see if we should turn off the battery monitor. + SDL_UIKit_UpdateBatteryMonitoring(); +#endif + + [context.sdlView swapBuffers]; + + /* You need to pump events in order for the OS to make changes visible. + * We don't pump events here because we don't want iOS application events + * (low memory, terminate, etc.) to happen inside low level rendering. */ + } + return true; +} + +SDL_GLContext UIKit_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDLEAGLContext *context = nil; + SDL_uikitopenglview *view; + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); + EAGLSharegroup *sharegroup = nil; + CGFloat scale = 1.0; + int samples = 0; + int major = _this->gl_config.major_version; + int minor = _this->gl_config.minor_version; + + /* The EAGLRenderingAPI enum values currently map 1:1 to major GLES + * versions. */ + EAGLRenderingAPI api = major; + + // iOS currently doesn't support GLES >3.0. + if (major > 3 || (major == 3 && minor > 0)) { + SDL_SetError("OpenGL ES %d.%d context could not be created", major, minor); + return NULL; + } + + if (_this->gl_config.multisamplebuffers > 0) { + samples = _this->gl_config.multisamplesamples; + } + + if (_this->gl_config.share_with_current_context) { + EAGLContext *currContext = (__bridge EAGLContext *)SDL_GL_GetCurrentContext(); + sharegroup = currContext.sharegroup; + } + + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + /* Set the scale to the natural scale factor of the screen - the + * backing dimensions of the OpenGL view will match the pixel + * dimensions of the screen rather than the dimensions in points. */ + scale = data.uiwindow.screen.nativeScale; + } + + context = [[SDLEAGLContext alloc] initWithAPI:api sharegroup:sharegroup]; + if (!context) { + SDL_SetError("OpenGL ES %d context could not be created", _this->gl_config.major_version); + return NULL; + } + + // construct our view, passing in SDL's OpenGL configuration data + view = [[SDL_uikitopenglview alloc] initWithFrame:frame + scale:scale + retainBacking:_this->gl_config.retained_backing + rBits:_this->gl_config.red_size + gBits:_this->gl_config.green_size + bBits:_this->gl_config.blue_size + aBits:_this->gl_config.alpha_size + depthBits:_this->gl_config.depth_size + stencilBits:_this->gl_config.stencil_size + sRGB:_this->gl_config.framebuffer_srgb_capable + multisamples:samples + context:context]; + + if (!view) { + return NULL; + } + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_UIKIT_OPENGL_FRAMEBUFFER_NUMBER, view.drawableFramebuffer); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_UIKIT_OPENGL_RENDERBUFFER_NUMBER, view.drawableRenderbuffer); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_UIKIT_OPENGL_RESOLVE_FRAMEBUFFER_NUMBER, view.msaaResolveFramebuffer); + + // The context owns the view / drawable. + context.sdlView = view; + + if (!UIKit_GL_MakeCurrent(_this, window, (__bridge SDL_GLContext)context)) { + UIKit_GL_DestroyContext(_this, (SDL_GLContext)CFBridgingRetain(context)); + return NULL; + } + + /* We return a +1'd context. The window's internal owns the view (via + * MakeCurrent.) */ + return (SDL_GLContext)CFBridgingRetain(context); + } +} + +bool UIKit_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + @autoreleasepool { + /* The context was retained in SDL_GL_CreateContext, so we release it + * here. The context's view will be detached from its window when the + * context is deallocated. */ + CFRelease(context); + } + return true; +} + +void UIKit_GL_RestoreCurrentContext(void) +{ + @autoreleasepool { + /* Some iOS system functionality (such as Dictation on the on-screen + keyboard) uses its own OpenGL ES context but doesn't restore the + previous one when it's done. This is a workaround to make sure the + expected SDL-created OpenGL ES context is active after the OS is + finished running its own code for the frame. If this isn't done, the + app may crash or have other nasty symptoms when Dictation is used. + */ + EAGLContext *context = (__bridge EAGLContext *)SDL_GL_GetCurrentContext(); + if (context != NULL && [EAGLContext currentContext] != context) { + [EAGLContext setCurrentContext:context]; + } + } +} + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.h new file mode 100644 index 0000000..3286a16 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.h @@ -0,0 +1,62 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + +#import +#import +#import + +#import "SDL_uikitview.h" +#include "SDL_uikitvideo.h" + +@interface SDL_uikitopenglview : SDL_uikitview + +- (instancetype)initWithFrame:(CGRect)frame + scale:(CGFloat)scale + retainBacking:(BOOL)retained + rBits:(int)rBits + gBits:(int)gBits + bBits:(int)bBits + aBits:(int)aBits + depthBits:(int)depthBits + stencilBits:(int)stencilBits + sRGB:(BOOL)sRGB + multisamples:(int)multisamples + context:(EAGLContext *)glcontext; + +@property(nonatomic, readonly, weak) EAGLContext *context; + +// The width and height of the drawable in pixels (as opposed to points.) +@property(nonatomic, readonly) int backingWidth; +@property(nonatomic, readonly) int backingHeight; + +@property(nonatomic, readonly) GLuint drawableRenderbuffer; +@property(nonatomic, readonly) GLuint drawableFramebuffer; +@property(nonatomic, readonly) GLuint msaaResolveFramebuffer; + +- (void)swapBuffers; + +- (void)updateFrame; + +@end + +#endif // SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.m new file mode 100644 index 0000000..71d167f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitopenglview.m @@ -0,0 +1,377 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_UIKIT) && (defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2)) + +#include +#include +#import "SDL_uikitopenglview.h" +#include "SDL_uikitwindow.h" + +@implementation SDL_uikitopenglview +{ + // The renderbuffer and framebuffer used to render to this layer. + GLuint viewRenderbuffer, viewFramebuffer; + + // The depth buffer that is attached to viewFramebuffer, if it exists. + GLuint depthRenderbuffer; + + GLenum colorBufferFormat; + + // format of depthRenderbuffer + GLenum depthBufferFormat; + + // The framebuffer and renderbuffer used for rendering with MSAA. + GLuint msaaFramebuffer, msaaRenderbuffer; + + // The number of MSAA samples. + int samples; + + BOOL retainedBacking; +} + +@synthesize context; +@synthesize backingWidth; +@synthesize backingHeight; + ++ (Class)layerClass +{ + return [CAEAGLLayer class]; +} + +- (instancetype)initWithFrame:(CGRect)frame + scale:(CGFloat)scale + retainBacking:(BOOL)retained + rBits:(int)rBits + gBits:(int)gBits + bBits:(int)bBits + aBits:(int)aBits + depthBits:(int)depthBits + stencilBits:(int)stencilBits + sRGB:(BOOL)sRGB + multisamples:(int)multisamples + context:(EAGLContext *)glcontext +{ + if ((self = [super initWithFrame:frame])) { + const BOOL useStencilBuffer = (stencilBits != 0); + const BOOL useDepthBuffer = (depthBits != 0); + NSString *colorFormat = nil; + + context = glcontext; + samples = multisamples; + retainedBacking = retained; + + if (!context || ![EAGLContext setCurrentContext:context]) { + SDL_SetError("Could not create OpenGL ES drawable (could not make context current)"); + return nil; + } + + if (samples > 0) { + GLint maxsamples = 0; + glGetIntegerv(GL_MAX_SAMPLES, &maxsamples); + + // Clamp the samples to the max supported count. + samples = SDL_min(samples, maxsamples); + } + + if (sRGB) { + colorFormat = kEAGLColorFormatSRGBA8; + colorBufferFormat = GL_SRGB8_ALPHA8; + } else if (rBits >= 8 || gBits >= 8 || bBits >= 8 || aBits > 0) { + // if user specifically requests rbg888 or some color format higher than 16bpp + colorFormat = kEAGLColorFormatRGBA8; + colorBufferFormat = GL_RGBA8; + } else { + // default case (potentially faster) + colorFormat = kEAGLColorFormatRGB565; + colorBufferFormat = GL_RGB565; + } + + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = @{ + kEAGLDrawablePropertyRetainedBacking : @(retained), + kEAGLDrawablePropertyColorFormat : colorFormat + }; + + // Set the appropriate scale (for retina display support) + self.contentScaleFactor = scale; + + // Create the color Renderbuffer Object + glGenRenderbuffers(1, &viewRenderbuffer); + glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer); + + if (![context renderbufferStorage:GL_RENDERBUFFER fromDrawable:eaglLayer]) { + SDL_SetError("Failed to create OpenGL ES drawable"); + return nil; + } + + // Create the Framebuffer Object + glGenFramebuffers(1, &viewFramebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, viewFramebuffer); + + // attach the color renderbuffer to the FBO + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, viewRenderbuffer); + + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth); + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight); + + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + SDL_SetError("Failed creating OpenGL ES framebuffer"); + return nil; + } + + /* When MSAA is used we'll use a separate framebuffer for rendering to, + * since we'll need to do an explicit MSAA resolve before presenting. */ + if (samples > 0) { + glGenFramebuffers(1, &msaaFramebuffer); + glBindFramebuffer(GL_FRAMEBUFFER, msaaFramebuffer); + + glGenRenderbuffers(1, &msaaRenderbuffer); + glBindRenderbuffer(GL_RENDERBUFFER, msaaRenderbuffer); + + glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, colorBufferFormat, backingWidth, backingHeight); + + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaRenderbuffer); + } + + if (useDepthBuffer || useStencilBuffer) { + if (useStencilBuffer) { + // Apparently you need to pack stencil and depth into one buffer. + depthBufferFormat = GL_DEPTH24_STENCIL8_OES; + } else if (useDepthBuffer) { + /* iOS only uses 32-bit float (exposed as fixed point 24-bit) + * depth buffers. */ + depthBufferFormat = GL_DEPTH_COMPONENT24_OES; + } + + glGenRenderbuffers(1, &depthRenderbuffer); + glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer); + + if (samples > 0) { + glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, depthBufferFormat, backingWidth, backingHeight); + } else { + glRenderbufferStorage(GL_RENDERBUFFER, depthBufferFormat, backingWidth, backingHeight); + } + + if (useDepthBuffer) { + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer); + } + if (useStencilBuffer) { + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depthRenderbuffer); + } + } + + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + SDL_SetError("Failed creating OpenGL ES framebuffer"); + return nil; + } + + glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer); + + [self setDebugLabels]; + } + + return self; +} + +- (GLuint)drawableRenderbuffer +{ + return viewRenderbuffer; +} + +- (GLuint)drawableFramebuffer +{ + // When MSAA is used, the MSAA draw framebuffer is used for drawing. + if (msaaFramebuffer) { + return msaaFramebuffer; + } else { + return viewFramebuffer; + } +} + +- (GLuint)msaaResolveFramebuffer +{ + /* When MSAA is used, the MSAA draw framebuffer is used for drawing and the + * view framebuffer is used as a MSAA resolve framebuffer. */ + if (msaaFramebuffer) { + return viewFramebuffer; + } else { + return 0; + } +} + +- (void)updateFrame +{ + GLint prevRenderbuffer = 0; + glGetIntegerv(GL_RENDERBUFFER_BINDING, &prevRenderbuffer); + + glBindRenderbuffer(GL_RENDERBUFFER, viewRenderbuffer); + [context renderbufferStorage:GL_RENDERBUFFER fromDrawable:(CAEAGLLayer *)self.layer]; + + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_WIDTH, &backingWidth); + glGetRenderbufferParameteriv(GL_RENDERBUFFER, GL_RENDERBUFFER_HEIGHT, &backingHeight); + + if (msaaRenderbuffer != 0) { + glBindRenderbuffer(GL_RENDERBUFFER, msaaRenderbuffer); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, colorBufferFormat, backingWidth, backingHeight); + } + + if (depthRenderbuffer != 0) { + glBindRenderbuffer(GL_RENDERBUFFER, depthRenderbuffer); + + if (samples > 0) { + glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, depthBufferFormat, backingWidth, backingHeight); + } else { + glRenderbufferStorage(GL_RENDERBUFFER, depthBufferFormat, backingWidth, backingHeight); + } + } + + glBindRenderbuffer(GL_RENDERBUFFER, prevRenderbuffer); +} + +- (void)setDebugLabels +{ + if (viewFramebuffer != 0) { + glLabelObjectEXT(GL_FRAMEBUFFER, viewFramebuffer, 0, "context FBO"); + } + + if (viewRenderbuffer != 0) { + glLabelObjectEXT(GL_RENDERBUFFER, viewRenderbuffer, 0, "context color buffer"); + } + + if (depthRenderbuffer != 0) { + if (depthBufferFormat == GL_DEPTH24_STENCIL8_OES) { + glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth-stencil buffer"); + } else { + glLabelObjectEXT(GL_RENDERBUFFER, depthRenderbuffer, 0, "context depth buffer"); + } + } + + if (msaaFramebuffer != 0) { + glLabelObjectEXT(GL_FRAMEBUFFER, msaaFramebuffer, 0, "context MSAA FBO"); + } + + if (msaaRenderbuffer != 0) { + glLabelObjectEXT(GL_RENDERBUFFER, msaaRenderbuffer, 0, "context MSAA renderbuffer"); + } +} + +- (void)swapBuffers +{ + if (msaaFramebuffer) { + const GLenum attachments[] = { GL_COLOR_ATTACHMENT0 }; + + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, viewFramebuffer); + + /* OpenGL ES 3+ provides explicit MSAA resolves via glBlitFramebuffer. + * In OpenGL ES 1 and 2, MSAA resolves must be done via an extension. */ + if (context.API >= kEAGLRenderingAPIOpenGLES3) { + int w = backingWidth; + int h = backingHeight; + glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_NEAREST); + + if (!retainedBacking) { + // Discard the contents of the MSAA drawable color buffer. + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, 1, attachments); + } + } else { + glResolveMultisampleFramebufferAPPLE(); + + if (!retainedBacking) { + glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER, 1, attachments); + } + } + + /* We assume the "drawable framebuffer" (MSAA draw framebuffer) was + * previously bound... */ + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, msaaFramebuffer); + } + + /* viewRenderbuffer should always be bound here. Code that binds something + * else is responsible for rebinding viewRenderbuffer, to reduce duplicate + * state changes. */ + [context presentRenderbuffer:GL_RENDERBUFFER]; +} + +- (void)layoutSubviews +{ + [super layoutSubviews]; + + int width = (int)(self.bounds.size.width * self.contentScaleFactor); + int height = (int)(self.bounds.size.height * self.contentScaleFactor); + + // Update the color and depth buffer storage if the layer size has changed. + if (width != backingWidth || height != backingHeight) { + EAGLContext *prevContext = [EAGLContext currentContext]; + if (prevContext != context) { + [EAGLContext setCurrentContext:context]; + } + + [self updateFrame]; + + if (prevContext != context) { + [EAGLContext setCurrentContext:prevContext]; + } + } +} + +- (void)destroyFramebuffer +{ + if (viewFramebuffer != 0) { + glDeleteFramebuffers(1, &viewFramebuffer); + viewFramebuffer = 0; + } + + if (viewRenderbuffer != 0) { + glDeleteRenderbuffers(1, &viewRenderbuffer); + viewRenderbuffer = 0; + } + + if (depthRenderbuffer != 0) { + glDeleteRenderbuffers(1, &depthRenderbuffer); + depthRenderbuffer = 0; + } + + if (msaaFramebuffer != 0) { + glDeleteFramebuffers(1, &msaaFramebuffer); + msaaFramebuffer = 0; + } + + if (msaaRenderbuffer != 0) { + glDeleteRenderbuffers(1, &msaaRenderbuffer); + msaaRenderbuffer = 0; + } +} + +- (void)dealloc +{ + if (context && context == [EAGLContext currentContext]) { + [self destroyFramebuffer]; + [EAGLContext setCurrentContext:nil]; + } +} + +@end + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.h new file mode 100644 index 0000000..1e75589 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_uikitpen_h_ +#define SDL_uikitpen_h_ + +#include "SDL_uikitvideo.h" +#include "SDL_uikitwindow.h" + +extern bool UIKit_InitPen(SDL_VideoDevice *_this); +extern void UIKit_HandlePenMotion(SDL_uikitview *view, UITouch *pencil); +extern void UIKit_HandlePenPress(SDL_uikitview *view, UITouch *pencil); +extern void UIKit_HandlePenRelease(SDL_uikitview *view, UITouch *pencil); + +#if !defined(SDL_PLATFORM_TVOS) +extern void UIKit_HandlePenHover(SDL_uikitview *view, UIHoverGestureRecognizer *recognizer) API_AVAILABLE(ios(13.0)); +#endif + +extern void UIKit_QuitPen(SDL_VideoDevice *_this); + +#endif // SDL_uikitpen_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.m new file mode 100644 index 0000000..5209681 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitpen.m @@ -0,0 +1,214 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "SDL_uikitevents.h" +#include "SDL_uikitpen.h" +#include "SDL_uikitwindow.h" + +#include "../../events/SDL_pen_c.h" + +// Fix build errors when using an older SDK by defining these selectors +#if !defined(SDL_PLATFORM_TVOS) + +@interface UITouch (SDL) +#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 170500) +@property (nonatomic, readonly) CGFloat rollAngle; +#endif +@end + +@interface UIHoverGestureRecognizer (SDL) +#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 160100) +@property (nonatomic, readonly) CGFloat zOffset; +#endif +#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 160400) +- (CGFloat) azimuthAngleInView:(UIView *) view; + +@property (nonatomic, readonly) CGFloat altitudeAngle; +#endif +#if !(__IPHONE_OS_VERSION_MAX_ALLOWED >= 170500) +@property (nonatomic, readonly) CGFloat rollAngle; +#endif +@end + +#endif // !SDL_PLATFORM_TVOS + +static SDL_PenID apple_pencil_id = 0; + +bool UIKit_InitPen(SDL_VideoDevice *_this) +{ + return true; +} + +// we only have one Apple Pencil at a time, and it must be paired to the iOS device. +// We only know about its existence when it first sends an event, so add an single SDL pen +// device here if we haven't already. +static SDL_PenID UIKit_AddPenIfNecesary() +{ + if (!apple_pencil_id) { + SDL_PenInfo info; + SDL_zero(info); + info.capabilities = SDL_PEN_CAPABILITY_PRESSURE | SDL_PEN_CAPABILITY_XTILT | SDL_PEN_CAPABILITY_YTILT; + info.max_tilt = 90.0f; + info.num_buttons = 0; + info.subtype = SDL_PEN_TYPE_PENCIL; + + if (@available(iOS 17.5, *)) { // need rollAngle method. + info.capabilities |= SDL_PEN_CAPABILITY_ROTATION; + } + + if (@available(ios 16.1, *)) { // need zOffset method. + info.capabilities |= SDL_PEN_CAPABILITY_DISTANCE; + } + + // Apple Pencil and iOS can report when the pencil is being "squeezed" but it's a boolean thing, + // so we can't use it for tangential pressure. + + // There's only ever one Apple Pencil at most, so we just pass a non-zero value for the handle. + apple_pencil_id = SDL_AddPenDevice(0, "Apple Pencil", &info, (void *) (size_t) 0x1); + } + + return apple_pencil_id; +} + +static void UIKit_HandlePenAxes(SDL_Window *window, NSTimeInterval nstimestamp, float zOffset, const CGPoint *point, float force, + float maximumPossibleForce, float azimuthAngleInView, float altitudeAngle, float rollAngle) +{ + const SDL_PenID penId = UIKit_AddPenIfNecesary(); + if (penId) { + const Uint64 timestamp = UIKit_GetEventTimestamp(nstimestamp); + const float radians_to_degrees = 180.0f / SDL_PI_F; + + // Normalize force to 0.0f ... 1.0f range. + const float pressure = force / maximumPossibleForce; + + // azimuthAngleInView is in radians, with 0 being the pen's back end pointing due east on the screen when the + // tip is touching the screen, and negative when heading north from there, positive to the south. + // So convert to degrees, 0 being due east, etc. + const float azimuth_angle = azimuthAngleInView * radians_to_degrees; + + // altitudeAngle is in radians, with 0 being the pen laying flat on (parallel to) the device + // screen and PI/2 being it pointing straight up from (perpendicular to) the device screen. + // So convert to degrees, 0 being flat and 90 being straight up. + const float altitude_angle = altitudeAngle * radians_to_degrees; + + // the azimuth_angle goes from -180 to 180 (with abs(angle) moving from 180 to 0, left to right), but SDL wants + // it from -90 (back facing west) to 90 (back facing east). + const float xtilt = (180.0f - SDL_fabsf(azimuth_angle)) - 90.0f; + + // the altitude_angle goes from 0 to 90 regardless of which direction the pen is lifting off the device, but SDL wants + // it from -90 (flat facing north) to 90 (flat facing south). + const float ytilt = (azimuth_angle < 0.0f) ? -(90.0f - altitude_angle) : (90.0f - altitude_angle); + + // rotation is in radians, and only available on a later iOS. + const float rotation = rollAngle * radians_to_degrees; // !!! FIXME: this might need adjustment, I don't have a pencil that supports it. + + SDL_SendPenMotion(timestamp, penId, window, point->x, point->y); + SDL_SendPenAxis(timestamp, penId, window, SDL_PEN_AXIS_PRESSURE, pressure); + SDL_SendPenAxis(timestamp, penId, window, SDL_PEN_AXIS_XTILT, xtilt); + SDL_SendPenAxis(timestamp, penId, window, SDL_PEN_AXIS_YTILT, ytilt); + SDL_SendPenAxis(timestamp, penId, window, SDL_PEN_AXIS_ROTATION, rotation); + SDL_SendPenAxis(timestamp, penId, window, SDL_PEN_AXIS_DISTANCE, zOffset); + } +} + +#if !defined(SDL_PLATFORM_TVOS) +extern void UIKit_HandlePenHover(SDL_uikitview *view, UIHoverGestureRecognizer *recognizer) +{ + float zOffset = 0.0f; + if (@available(iOS 16.1, *)) { + zOffset = (float) [recognizer zOffset]; + } + + float azimuthAngleInView = 0.0f; + if (@available(iOS 16.4, *)) { + azimuthAngleInView = (float) [recognizer azimuthAngleInView:view]; + } + + float altitudeAngle = 0.0f; + if (@available(iOS 16.4, *)) { + altitudeAngle = (float) [recognizer altitudeAngle]; + } + + float rollAngle = 0.0f; + if (@available(iOS 17.5, *)) { + rollAngle = (float) [recognizer rollAngle]; + } + + SDL_Window *window = [view getSDLWindow]; + const CGPoint point = [recognizer locationInView:view]; + + // force is zero here; if you're here, you're not touching. + // !!! FIXME: no timestamp on these...? + UIKit_HandlePenAxes(window, 0, zOffset, &point, 0.0f, 1.0f, azimuthAngleInView, altitudeAngle, rollAngle); +} +#endif + +static void UIKit_HandlePenAxesFromUITouch(SDL_uikitview *view, UITouch *pencil) +{ + float rollAngle = 0.0f; +#if !defined(SDL_PLATFORM_TVOS) + if (@available(iOS 17.5, *)) { + rollAngle = (float) [pencil rollAngle]; + } +#endif + + SDL_Window *window = [view getSDLWindow]; + const CGPoint point = [pencil locationInView:view]; + + // zOffset is zero here; if you're here, you're touching. + UIKit_HandlePenAxes(window, [pencil timestamp], 0.0f, &point, [pencil force], [pencil maximumPossibleForce], [pencil azimuthAngleInView:view], [pencil altitudeAngle], rollAngle); +} + +void UIKit_HandlePenMotion(SDL_uikitview *view, UITouch *pencil) +{ + UIKit_HandlePenAxesFromUITouch(view, pencil); +} + +void UIKit_HandlePenPress(SDL_uikitview *view, UITouch *pencil) +{ + const SDL_PenID penId = UIKit_AddPenIfNecesary(); + if (penId) { + UIKit_HandlePenAxesFromUITouch(view, pencil); + SDL_SendPenTouch(UIKit_GetEventTimestamp([pencil timestamp]), penId, [view getSDLWindow], false, true); + } +} + +void UIKit_HandlePenRelease(SDL_uikitview *view, UITouch *pencil) +{ + const SDL_PenID penId = UIKit_AddPenIfNecesary(); + if (penId) { + SDL_SendPenTouch(UIKit_GetEventTimestamp([pencil timestamp]), penId, [view getSDLWindow], false, false); + UIKit_HandlePenAxesFromUITouch(view, pencil); + } +} + +void UIKit_QuitPen(SDL_VideoDevice *_this) +{ + if (apple_pencil_id) { + SDL_RemovePenDevice(0, apple_pencil_id); + apple_pencil_id = 0; + } +} + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.h new file mode 100644 index 0000000..927e646 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_uikitvideo_h_ +#define SDL_uikitvideo_h_ + +#include "../SDL_sysvideo.h" + +#ifdef __OBJC__ + +#include + +@interface SDL_UIKitVideoData : NSObject + +@property(nonatomic, assign) id pasteboardObserver; + +@end + +#ifdef SDL_PLATFORM_VISIONOS +CGRect UIKit_ComputeViewFrame(SDL_Window *window); +#else +CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen); +#endif + +#endif // __OBJC__ + +bool UIKit_SuspendScreenSaver(SDL_VideoDevice *_this); + +void UIKit_ForceUpdateHomeIndicator(void); + +bool UIKit_IsSystemVersionAtLeast(double version); + +SDL_SystemTheme UIKit_GetSystemTheme(void); + +#endif // SDL_uikitvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.m new file mode 100644 index 0000000..5c3987d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvideo.m @@ -0,0 +1,312 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#import + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_uikitvideo.h" +#include "SDL_uikitevents.h" +#include "SDL_uikitmodes.h" +#include "SDL_uikitwindow.h" +#include "SDL_uikitopengles.h" +#include "SDL_uikitclipboard.h" +#include "SDL_uikitvulkan.h" +#include "SDL_uikitmetalview.h" +#include "SDL_uikitmessagebox.h" + +#define UIKITVID_DRIVER_NAME "uikit" + +@implementation SDL_UIKitVideoData + +@end + +// Initialization/Query functions +static bool UIKit_VideoInit(SDL_VideoDevice *_this); +static void UIKit_VideoQuit(SDL_VideoDevice *_this); + +// DUMMY driver bootstrap functions + +static void UIKit_DeleteDevice(SDL_VideoDevice *device) +{ + @autoreleasepool { + if (device->internal){ + CFRelease(device->internal); + } + SDL_free(device); + } +} + +static SDL_VideoDevice *UIKit_CreateDevice(void) +{ + @autoreleasepool { + SDL_VideoDevice *device; + SDL_UIKitVideoData *data; + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + data = [SDL_UIKitVideoData new]; + + device->internal = (SDL_VideoData *)CFBridgingRetain(data); + device->system_theme = UIKit_GetSystemTheme(); + + // Set the function pointers + device->VideoInit = UIKit_VideoInit; + device->VideoQuit = UIKit_VideoQuit; + device->GetDisplayModes = UIKit_GetDisplayModes; + device->SetDisplayMode = UIKit_SetDisplayMode; + device->PumpEvents = UIKit_PumpEvents; + device->SuspendScreenSaver = UIKit_SuspendScreenSaver; + device->CreateSDLWindow = UIKit_CreateWindow; + device->SetWindowTitle = UIKit_SetWindowTitle; + device->ShowWindow = UIKit_ShowWindow; + device->HideWindow = UIKit_HideWindow; + device->RaiseWindow = UIKit_RaiseWindow; + device->SetWindowBordered = UIKit_SetWindowBordered; + device->SetWindowFullscreen = UIKit_SetWindowFullscreen; + device->DestroyWindow = UIKit_DestroyWindow; + device->GetDisplayUsableBounds = UIKit_GetDisplayUsableBounds; + device->GetWindowSizeInPixels = UIKit_GetWindowSizeInPixels; + +#ifdef SDL_IPHONE_KEYBOARD + device->HasScreenKeyboardSupport = UIKit_HasScreenKeyboardSupport; + device->StartTextInput = UIKit_StartTextInput; + device->StopTextInput = UIKit_StopTextInput; + device->SetTextInputProperties = UIKit_SetTextInputProperties; + device->IsScreenKeyboardShown = UIKit_IsScreenKeyboardShown; + device->UpdateTextInputArea = UIKit_UpdateTextInputArea; +#endif + + device->SetClipboardText = UIKit_SetClipboardText; + device->GetClipboardText = UIKit_GetClipboardText; + device->HasClipboardText = UIKit_HasClipboardText; + + // OpenGL (ES) functions +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + device->GL_MakeCurrent = UIKit_GL_MakeCurrent; + device->GL_SwapWindow = UIKit_GL_SwapWindow; + device->GL_CreateContext = UIKit_GL_CreateContext; + device->GL_DestroyContext = UIKit_GL_DestroyContext; + device->GL_GetProcAddress = UIKit_GL_GetProcAddress; + device->GL_LoadLibrary = UIKit_GL_LoadLibrary; +#endif + device->free = UIKit_DeleteDevice; + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = UIKit_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = UIKit_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = UIKit_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = UIKit_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = UIKit_Vulkan_DestroySurface; +#endif + +#ifdef SDL_VIDEO_METAL + device->Metal_CreateView = UIKit_Metal_CreateView; + device->Metal_DestroyView = UIKit_Metal_DestroyView; + device->Metal_GetLayer = UIKit_Metal_GetLayer; +#endif + + device->device_caps = VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; + + device->gl_config.accelerated = 1; + + return device; + } +} + +VideoBootStrap UIKIT_bootstrap = { + UIKITVID_DRIVER_NAME, "SDL UIKit video driver", + UIKit_CreateDevice, + UIKit_ShowMessageBox, + false +}; + +static bool UIKit_VideoInit(SDL_VideoDevice *_this) +{ + _this->gl_config.driver_loaded = 1; + + if (!UIKit_InitModes(_this)) { + return false; + } + + SDL_InitGCKeyboard(); + SDL_InitGCMouse(); + + UIKit_InitClipboard(_this); + + return true; +} + +static void UIKit_VideoQuit(SDL_VideoDevice *_this) +{ + UIKit_QuitClipboard(_this); + + SDL_QuitGCKeyboard(); + SDL_QuitGCMouse(); + + UIKit_QuitModes(_this); +} + +bool UIKit_SuspendScreenSaver(SDL_VideoDevice *_this) +{ + @autoreleasepool { + UIApplication *app = [UIApplication sharedApplication]; + + // Prevent the display from dimming and going to sleep. + app.idleTimerDisabled = (_this->suspend_screensaver != false); + } + return true; +} + +bool UIKit_IsSystemVersionAtLeast(double version) +{ + return [[UIDevice currentDevice].systemVersion doubleValue] >= version; +} + +SDL_SystemTheme UIKit_GetSystemTheme(void) +{ +#ifndef SDL_PLATFORM_VISIONOS + if (@available(iOS 12.0, tvOS 10.0, *)) { + switch ([UIScreen mainScreen].traitCollection.userInterfaceStyle) { + case UIUserInterfaceStyleDark: + return SDL_SYSTEM_THEME_DARK; + case UIUserInterfaceStyleLight: + return SDL_SYSTEM_THEME_LIGHT; + default: + break; + } + } +#endif + return SDL_SYSTEM_THEME_UNKNOWN; +} + +#ifdef SDL_PLATFORM_VISIONOS +CGRect UIKit_ComputeViewFrame(SDL_Window *window){ + return CGRectMake(window->x, window->y, window->w, window->h); +} +#else +CGRect UIKit_ComputeViewFrame(SDL_Window *window, UIScreen *screen) +{ + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + CGRect frame = screen.bounds; + + /* Use the UIWindow bounds instead of the UIScreen bounds, when possible. + * The uiwindow bounds may be smaller than the screen bounds when Split View + * is used on an iPad. */ + if (data != nil && data.uiwindow != nil) { + frame = data.uiwindow.bounds; + } + +#ifndef SDL_PLATFORM_TVOS + /* iOS 10 seems to have a bug where, in certain conditions, putting the + * device to sleep with the a landscape-only app open, re-orienting the + * device to portrait, and turning it back on will result in the screen + * bounds returning portrait orientation despite the app being in landscape. + * This is a workaround until a better solution can be found. + * https://bugzilla.libsdl.org/show_bug.cgi?id=3505 + * https://bugzilla.libsdl.org/show_bug.cgi?id=3465 + * https://forums.developer.apple.com/thread/65337 */ + UIInterfaceOrientation orient = [UIApplication sharedApplication].statusBarOrientation; + BOOL landscape = UIInterfaceOrientationIsLandscape(orient) || + !(UIKit_GetSupportedOrientations(window) & (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown)); + BOOL fullscreen = CGRectEqualToRect(screen.bounds, frame); + + /* The orientation flip doesn't make sense when the window is smaller + * than the screen (iPad Split View, for example). */ + if (fullscreen && (landscape != (frame.size.width > frame.size.height))) { + float height = frame.size.width; + frame.size.width = frame.size.height; + frame.size.height = height; + } +#endif + + return frame; +} + +#endif + +void UIKit_ForceUpdateHomeIndicator(void) +{ +#ifndef SDL_PLATFORM_TVOS + // Force the main SDL window to re-evaluate home indicator state + SDL_Window *focus = SDL_GetKeyboardFocus(); + if (focus) { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)focus->internal; + if (data != nil) { + [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfHomeIndicatorAutoHidden) withObject:nil waitUntilDone:NO]; + [data.viewcontroller performSelectorOnMainThread:@selector(setNeedsUpdateOfScreenEdgesDeferringSystemGestures) withObject:nil waitUntilDone:NO]; + } + } +#endif // !SDL_PLATFORM_TVOS +} + +/* + * iOS log support. + * + * This doesn't really have anything to do with the interfaces of the SDL video + * subsystem, but we need to stuff this into an Objective-C source code file. + * + * NOTE: This is copypasted from src/video/cocoa/SDL_cocoavideo.m! Thus, if + * Cocoa is supported, we use that one instead. Be sure both versions remain + * identical! + */ + +#ifndef SDL_VIDEO_DRIVER_COCOA +void SDL_NSLog(const char *prefix, const char *text) +{ + @autoreleasepool { + NSString *nsText = [NSString stringWithUTF8String:text]; + if (prefix && *prefix) { + NSString *nsPrefix = [NSString stringWithUTF8String:prefix]; + NSLog(@"%@%@", nsPrefix, nsText); + } else { + NSLog(@"%@", nsText); + } + } +} +#endif // SDL_VIDEO_DRIVER_COCOA + +/* + * iOS Tablet, etc, detection + * + * This doesn't really have anything to do with the interfaces of the SDL video + * subsystem, but we need to stuff this into an Objective-C source code file. + */ +bool SDL_IsIPad(void) +{ + return ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad); +} + +bool SDL_IsAppleTV(void) +{ + return ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomTV); +} + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.h new file mode 100644 index 0000000..78c2bed --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#import + +#include "../SDL_sysvideo.h" + +#if !defined(SDL_PLATFORM_TVOS) +@interface SDL_uikitview : UIView +#else +@interface SDL_uikitview : UIView +#endif + +- (instancetype)initWithFrame:(CGRect)frame; + +- (void)setSDLWindow:(SDL_Window *)window; +- (SDL_Window *)getSDLWindow; + +#if !defined(SDL_PLATFORM_TVOS) +- (void)pencilHovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0)); + +- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)); +- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)); +- (void)indirectPointerHovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.4)); +#endif + +- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize; +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; + +- (void)safeAreaInsetsDidChange; + +@end diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.m new file mode 100644 index 0000000..ba3b09b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitview.m @@ -0,0 +1,587 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "SDL_uikitview.h" + +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_uikitappdelegate.h" +#include "SDL_uikitevents.h" +#include "SDL_uikitmodes.h" +#include "SDL_uikitpen.h" +#include "SDL_uikitwindow.h" + +// The maximum number of mouse buttons we support +#define MAX_MOUSE_BUTTONS 5 + +// This is defined in SDL_sysjoystick.m +#ifndef SDL_JOYSTICK_DISABLED +extern int SDL_AppleTVRemoteOpenedAsJoystick; +#endif + +@implementation SDL_uikitview +{ + SDL_Window *sdlwindow; + + SDL_TouchID directTouchId; + SDL_TouchID indirectTouchId; + +#if !defined(SDL_PLATFORM_TVOS) + UIPointerInteraction *indirectPointerInteraction API_AVAILABLE(ios(13.4)); +#endif +} + +- (instancetype)initWithFrame:(CGRect)frame +{ + if ((self = [super initWithFrame:frame])) { +#ifdef SDL_PLATFORM_TVOS + // Apple TV Remote touchpad swipe gestures. + UISwipeGestureRecognizer *swipeUp = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; + swipeUp.direction = UISwipeGestureRecognizerDirectionUp; + [self addGestureRecognizer:swipeUp]; + + UISwipeGestureRecognizer *swipeDown = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; + swipeDown.direction = UISwipeGestureRecognizerDirectionDown; + [self addGestureRecognizer:swipeDown]; + + UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; + swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft; + [self addGestureRecognizer:swipeLeft]; + + UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeGesture:)]; + swipeRight.direction = UISwipeGestureRecognizerDirectionRight; + [self addGestureRecognizer:swipeRight]; +#endif + + self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; + self.autoresizesSubviews = YES; + + directTouchId = 1; + indirectTouchId = 2; + +#ifndef SDL_PLATFORM_TVOS + self.multipleTouchEnabled = YES; + SDL_AddTouch(directTouchId, SDL_TOUCH_DEVICE_DIRECT, ""); + + if (@available(iOS 13.0, *)) { + UIHoverGestureRecognizer *pencilRecognizer = [[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(pencilHovering:)]; + pencilRecognizer.allowedTouchTypes = @[@(UITouchTypePencil)]; + [self addGestureRecognizer:pencilRecognizer]; + } + + if (@available(iOS 13.4, *)) { + indirectPointerInteraction = [[UIPointerInteraction alloc] initWithDelegate:self]; + [self addInteraction:indirectPointerInteraction]; + + UIHoverGestureRecognizer *indirectPointerRecognizer = [[UIHoverGestureRecognizer alloc] initWithTarget:self action:@selector(indirectPointerHovering:)]; + indirectPointerRecognizer.allowedTouchTypes = @[@(UITouchTypeIndirectPointer)]; + [self addGestureRecognizer:indirectPointerRecognizer]; + } +#endif // !defined(SDL_PLATFORM_TVOS) + } + + return self; +} + +- (void)setSDLWindow:(SDL_Window *)window +{ + SDL_UIKitWindowData *data = nil; + + if (window == sdlwindow) { + return; + } + + // Remove ourself from the old window. + if (sdlwindow) { + SDL_uikitview *view = nil; + data = (__bridge SDL_UIKitWindowData *)sdlwindow->internal; + + [data.views removeObject:self]; + + [self removeFromSuperview]; + + // Restore the next-oldest view in the old window. + view = data.views.lastObject; + + data.viewcontroller.view = view; + + data.uiwindow.rootViewController = nil; + data.uiwindow.rootViewController = data.viewcontroller; + + [data.uiwindow layoutIfNeeded]; + } + + sdlwindow = window; + + // Add ourself to the new window. + if (window) { + data = (__bridge SDL_UIKitWindowData *)window->internal; + + // Make sure the SDL window has a strong reference to this view. + [data.views addObject:self]; + + // Replace the view controller's old view with this one. + [data.viewcontroller.view removeFromSuperview]; + data.viewcontroller.view = self; + + /* The root view controller handles rotation and the status bar. + * Assigning it also adds the controller's view to the window. We + * explicitly re-set it to make sure the view is properly attached to + * the window. Just adding the sub-view if the root view controller is + * already correct causes orientation issues on iOS 7 and below. */ + data.uiwindow.rootViewController = nil; + data.uiwindow.rootViewController = data.viewcontroller; + + /* The view's bounds may not be correct until the next event cycle. That + * might happen after the current dimensions are queried, so we force a + * layout now to immediately update the bounds. */ + [data.uiwindow layoutIfNeeded]; + } +} + +- (SDL_Window *)getSDLWindow +{ + return sdlwindow; +} + +#if !defined(SDL_PLATFORM_TVOS) + +- (UIPointerRegion *)pointerInteraction:(UIPointerInteraction *)interaction regionForRequest:(UIPointerRegionRequest *)request defaultRegion:(UIPointerRegion *)defaultRegion API_AVAILABLE(ios(13.4)) +{ + return [UIPointerRegion regionWithRect:self.bounds identifier:nil]; +} + +- (UIPointerStyle *)pointerInteraction:(UIPointerInteraction *)interaction styleForRegion:(UIPointerRegion *)region API_AVAILABLE(ios(13.4)) +{ + if (SDL_CursorVisible()) { + return nil; + } else { + return [UIPointerStyle hiddenPointerStyle]; + } +} + +- (void)indirectPointerHovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.4)) +{ + switch (recognizer.state) { + case UIGestureRecognizerStateBegan: + case UIGestureRecognizerStateChanged: + { + CGPoint point = [recognizer locationInView:self]; + SDL_SendMouseMotion(0, sdlwindow, SDL_GLOBAL_MOUSE_ID, false, point.x, point.y); + break; + } + + default: + break; + } +} + +- (void)indirectPointerMoving:(UITouch *)touch API_AVAILABLE(ios(13.4)) +{ + CGPoint locationInView = [self touchLocation:touch shouldNormalize:NO]; + SDL_SendMouseMotion(0, sdlwindow, SDL_GLOBAL_MOUSE_ID, false, locationInView.x, locationInView.y); +} + +- (void)indirectPointerPressed:(UITouch *)touch fromEvent:(UIEvent *)event API_AVAILABLE(ios(13.4)) +{ + if (!SDL_HasMouse()) { + int i; + + for (i = 1; i <= MAX_MOUSE_BUTTONS; ++i) { + if (event.buttonMask & SDL_BUTTON_MASK(i)) { + Uint8 button; + + switch (i) { + case 1: + button = SDL_BUTTON_LEFT; + break; + case 2: + button = SDL_BUTTON_RIGHT; + break; + case 3: + button = SDL_BUTTON_MIDDLE; + break; + default: + button = (Uint8)i; + break; + } + SDL_SendMouseButton(UIKit_GetEventTimestamp([touch timestamp]), sdlwindow, SDL_GLOBAL_MOUSE_ID, button, true); + } + } + } +} + +- (void)indirectPointerReleased:(UITouch *)touch fromEvent:(UIEvent *)event API_AVAILABLE(ios(13.4)) +{ + if (!SDL_HasMouse()) { + int i; + SDL_MouseButtonFlags buttons = SDL_GetMouseState(NULL, NULL); + + for (i = 0; i < MAX_MOUSE_BUTTONS; ++i) { + if (buttons & SDL_BUTTON_MASK(i)) { + SDL_SendMouseButton(UIKit_GetEventTimestamp([touch timestamp]), sdlwindow, SDL_GLOBAL_MOUSE_ID, (Uint8)i, false); + } + } + } +} + +- (void)pencilHovering:(UIHoverGestureRecognizer *)recognizer API_AVAILABLE(ios(13.0)) +{ + switch (recognizer.state) { + case UIGestureRecognizerStateBegan: + case UIGestureRecognizerStateChanged: + UIKit_HandlePenHover(self, recognizer); + break; + + case UIGestureRecognizerStateEnded: + case UIGestureRecognizerStateCancelled: + // we track touches elsewhere, so if a hover "ends" we'll deal with that there. + break; + + default: + break; + } +} + +- (void)pencilMoving:(UITouch *)touch +{ + UIKit_HandlePenMotion(self, touch); +} + +- (void)pencilPressed:(UITouch *)touch +{ + UIKit_HandlePenPress(self, touch); +} + +- (void)pencilReleased:(UITouch *)touch +{ + UIKit_HandlePenRelease(self, touch); +} + +#endif // !defined(SDL_PLATFORM_TVOS) + +- (SDL_TouchDeviceType)touchTypeForTouch:(UITouch *)touch +{ + if (touch.type == UITouchTypeIndirect) { + return SDL_TOUCH_DEVICE_INDIRECT_RELATIVE; + } + return SDL_TOUCH_DEVICE_DIRECT; +} + +- (SDL_TouchID)touchIdForType:(SDL_TouchDeviceType)type +{ + switch (type) { + case SDL_TOUCH_DEVICE_DIRECT: + default: + return directTouchId; + case SDL_TOUCH_DEVICE_INDIRECT_RELATIVE: + return indirectTouchId; + } +} + +- (CGPoint)touchLocation:(UITouch *)touch shouldNormalize:(BOOL)normalize +{ + CGPoint point = [touch locationInView:self]; + + if (normalize) { + CGRect bounds = self.bounds; + point.x /= bounds.size.width; + point.y /= bounds.size.height; + } + + return point; +} + +- (float)pressureForTouch:(UITouch *)touch +{ + return (float)touch.force; +} + +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + for (UITouch *touch in touches) { +#if !defined(SDL_PLATFORM_TVOS) + if (@available(iOS 13.0, *)) { + if (touch.type == UITouchTypePencil) { + [self pencilPressed:touch]; + continue; + } + } + + if (@available(iOS 13.4, *)) { + if (touch.type == UITouchTypeIndirectPointer) { + [self indirectPointerPressed:touch fromEvent:event]; + continue; + } + } +#endif // !defined(SDL_PLATFORM_TVOS) + + SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch]; + SDL_TouchID touchId = [self touchIdForType:touchType]; + float pressure = [self pressureForTouch:touch]; + + if (SDL_AddTouch(touchId, touchType, "") < 0) { + continue; + } + + // FIXME, need to send: int clicks = (int) touch.tapCount; ? + + CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; + SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]), + touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow, + SDL_EVENT_FINGER_DOWN, locationInView.x, locationInView.y, pressure); + } +} + +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + for (UITouch *touch in touches) { +#if !defined(SDL_PLATFORM_TVOS) + if (@available(iOS 13.0, *)) { + if (touch.type == UITouchTypePencil) { + [self pencilReleased:touch]; + continue; + } + } + + if (@available(iOS 13.4, *)) { + if (touch.type == UITouchTypeIndirectPointer) { + [self indirectPointerReleased:touch fromEvent:event]; + continue; + } + } +#endif // !defined(SDL_PLATFORM_TVOS) + + SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch]; + SDL_TouchID touchId = [self touchIdForType:touchType]; + float pressure = [self pressureForTouch:touch]; + + if (SDL_AddTouch(touchId, touchType, "") < 0) { + continue; + } + + // FIXME, need to send: int clicks = (int) touch.tapCount; ? + + CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; + SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]), + touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow, + SDL_EVENT_FINGER_UP, locationInView.x, locationInView.y, pressure); + } +} + +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event +{ + for (UITouch *touch in touches) { +#if !defined(SDL_PLATFORM_TVOS) + if (@available(iOS 13.0, *)) { + if (touch.type == UITouchTypePencil) { + [self pencilReleased:touch]; + continue; + } + } + + if (@available(iOS 13.4, *)) { + if (touch.type == UITouchTypeIndirectPointer) { + [self indirectPointerReleased:touch fromEvent:event]; + continue; + } + } +#endif // !defined(SDL_PLATFORM_TVOS) + + SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch]; + SDL_TouchID touchId = [self touchIdForType:touchType]; + float pressure = [self pressureForTouch:touch]; + + if (SDL_AddTouch(touchId, touchType, "") < 0) { + continue; + } + + CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; + SDL_SendTouch(UIKit_GetEventTimestamp([event timestamp]), + touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow, + SDL_EVENT_FINGER_CANCELED, locationInView.x, locationInView.y, pressure); + } +} + +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + for (UITouch *touch in touches) { +#if !defined(SDL_PLATFORM_TVOS) + if (@available(iOS 13.0, *)) { + if (touch.type == UITouchTypePencil) { + [self pencilMoving:touch]; + continue; + } + } + + if (@available(iOS 13.4, *)) { + if (touch.type == UITouchTypeIndirectPointer) { + [self indirectPointerMoving:touch]; + continue; + } + } +#endif // !defined(SDL_PLATFORM_TVOS) + + SDL_TouchDeviceType touchType = [self touchTypeForTouch:touch]; + SDL_TouchID touchId = [self touchIdForType:touchType]; + float pressure = [self pressureForTouch:touch]; + + if (SDL_AddTouch(touchId, touchType, "") < 0) { + continue; + } + + CGPoint locationInView = [self touchLocation:touch shouldNormalize:YES]; + SDL_SendTouchMotion(UIKit_GetEventTimestamp([event timestamp]), + touchId, (SDL_FingerID)(uintptr_t)touch, sdlwindow, + locationInView.x, locationInView.y, pressure); + } +} + +- (void)safeAreaInsetsDidChange +{ + // Update the safe area insets + SDL_SetWindowSafeAreaInsets(sdlwindow, + (int)SDL_ceilf(self.safeAreaInsets.left), + (int)SDL_ceilf(self.safeAreaInsets.right), + (int)SDL_ceilf(self.safeAreaInsets.top), + (int)SDL_ceilf(self.safeAreaInsets.bottom)); +} + +- (SDL_Scancode)scancodeFromPress:(UIPress *)press +{ + if (press.key != nil) { + return (SDL_Scancode)press.key.keyCode; + } + +#ifndef SDL_JOYSTICK_DISABLED + // Presses from Apple TV remote + if (!SDL_AppleTVRemoteOpenedAsJoystick) { + switch (press.type) { + case UIPressTypeUpArrow: + return SDL_SCANCODE_UP; + case UIPressTypeDownArrow: + return SDL_SCANCODE_DOWN; + case UIPressTypeLeftArrow: + return SDL_SCANCODE_LEFT; + case UIPressTypeRightArrow: + return SDL_SCANCODE_RIGHT; + case UIPressTypeSelect: + // HIG says: "primary button behavior" + return SDL_SCANCODE_RETURN; + case UIPressTypeMenu: + // HIG says: "returns to previous screen" + return SDL_SCANCODE_ESCAPE; + case UIPressTypePlayPause: + // HIG says: "secondary button behavior" + return SDL_SCANCODE_PAUSE; + default: + break; + } + } +#endif // !SDL_JOYSTICK_DISABLED + + return SDL_SCANCODE_UNKNOWN; +} + +- (void)pressesBegan:(NSSet *)presses withEvent:(UIPressesEvent *)event +{ + if (!SDL_HasKeyboard()) { + for (UIPress *press in presses) { + SDL_Scancode scancode = [self scancodeFromPress:press]; + SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), SDL_GLOBAL_KEYBOARD_ID, 0, scancode, true); + } + } + if (SDL_TextInputActive(sdlwindow)) { + [super pressesBegan:presses withEvent:event]; + } +} + +- (void)pressesEnded:(NSSet *)presses withEvent:(UIPressesEvent *)event +{ + if (!SDL_HasKeyboard()) { + for (UIPress *press in presses) { + SDL_Scancode scancode = [self scancodeFromPress:press]; + SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), SDL_GLOBAL_KEYBOARD_ID, 0, scancode, false); + } + } + if (SDL_TextInputActive(sdlwindow)) { + [super pressesEnded:presses withEvent:event]; + } +} + +- (void)pressesCancelled:(NSSet *)presses withEvent:(UIPressesEvent *)event +{ + if (!SDL_HasKeyboard()) { + for (UIPress *press in presses) { + SDL_Scancode scancode = [self scancodeFromPress:press]; + SDL_SendKeyboardKey(UIKit_GetEventTimestamp([event timestamp]), SDL_GLOBAL_KEYBOARD_ID, 0, scancode, false); + } + } + if (SDL_TextInputActive(sdlwindow)) { + [super pressesCancelled:presses withEvent:event]; + } +} + +- (void)pressesChanged:(NSSet *)presses withEvent:(UIPressesEvent *)event +{ + // This is only called when the force of a press changes. + if (SDL_TextInputActive(sdlwindow)) { + [super pressesChanged:presses withEvent:event]; + } +} + +#ifdef SDL_PLATFORM_TVOS +- (void)swipeGesture:(UISwipeGestureRecognizer *)gesture +{ + // Swipe gestures don't trigger begin states. + if (gesture.state == UIGestureRecognizerStateEnded) { +#ifndef SDL_JOYSTICK_DISABLED + if (!SDL_AppleTVRemoteOpenedAsJoystick) { + /* Send arrow key presses for now, as we don't have an external API + * which better maps to swipe gestures. */ + switch (gesture.direction) { + case UISwipeGestureRecognizerDirectionUp: + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_UP); + break; + case UISwipeGestureRecognizerDirectionDown: + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_DOWN); + break; + case UISwipeGestureRecognizerDirectionLeft: + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_LEFT); + break; + case UISwipeGestureRecognizerDirectionRight: + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_RIGHT); + break; + } + } +#endif // !SDL_JOYSTICK_DISABLED + } +} +#endif // SDL_PLATFORM_TVOS + +@end + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.h new file mode 100644 index 0000000..d52e478 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.h @@ -0,0 +1,96 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#import + +#include "../SDL_sysvideo.h" + +#ifdef SDL_PLATFORM_TVOS +#import +#define SDLRootViewController GCEventViewController +#else +#define SDLRootViewController UIViewController +#endif + +@interface SDLUITextField : UITextField +- (BOOL)canPerformAction:(SEL)action withSender:(id)sender; +@end + +#ifdef SDL_IPHONE_KEYBOARD +@interface SDL_uikitviewcontroller : SDLRootViewController +#else +@interface SDL_uikitviewcontroller : SDLRootViewController +#endif + +@property(nonatomic, assign) SDL_Window *window; + +- (instancetype)initWithSDLWindow:(SDL_Window *)_window; + +- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection; + +- (void)setAnimationCallback:(int)interval + callback:(void (*)(void *))callback + callbackParam:(void *)callbackParam; + +- (void)startAnimation; +- (void)stopAnimation; + +- (void)doLoop:(CADisplayLink *)sender; + +- (void)loadView; +- (void)viewDidLayoutSubviews; + +#ifndef SDL_PLATFORM_TVOS +- (NSUInteger)supportedInterfaceOrientations; +- (BOOL)prefersStatusBarHidden; +- (BOOL)prefersHomeIndicatorAutoHidden; +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures; + +@property(nonatomic, assign) int homeIndicatorHidden; +#endif + +#ifdef SDL_IPHONE_KEYBOARD +- (bool)startTextInput; +- (bool)stopTextInput; +- (void)initKeyboard; +- (void)deinitKeyboard; + +- (void)keyboardWillShow:(NSNotification *)notification; +- (void)keyboardWillHide:(NSNotification *)notification; + +- (void)updateKeyboard; + +@property(nonatomic, assign, getter=isTextFieldFocused) BOOL textFieldFocused; +@property(nonatomic, assign) SDL_Rect textInputRect; +@property(nonatomic, assign) int keyboardHeight; +#endif + +@end + +#ifdef SDL_IPHONE_KEYBOARD +bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +bool UIKit_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +bool UIKit_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); +void UIKit_SetTextInputProperties(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +bool UIKit_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); +#endif diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.m new file mode 100644 index 0000000..45f2d64 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitviewcontroller.m @@ -0,0 +1,736 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_uikitviewcontroller.h" +#include "SDL_uikitmessagebox.h" +#include "SDL_uikitevents.h" +#include "SDL_uikitvideo.h" +#include "SDL_uikitmodes.h" +#include "SDL_uikitwindow.h" +#include "SDL_uikitopengles.h" + +#ifdef SDL_PLATFORM_TVOS +static void SDLCALL SDL_AppleTVControllerUIHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + @autoreleasepool { + SDL_uikitviewcontroller *viewcontroller = (__bridge SDL_uikitviewcontroller *)userdata; + viewcontroller.controllerUserInteractionEnabled = hint && (*hint != '0'); + } +} +#endif + +#ifndef SDL_PLATFORM_TVOS +static void SDLCALL SDL_HideHomeIndicatorHintChanged(void *userdata, const char *name, const char *oldValue, const char *hint) +{ + @autoreleasepool { + SDL_uikitviewcontroller *viewcontroller = (__bridge SDL_uikitviewcontroller *)userdata; + viewcontroller.homeIndicatorHidden = (hint && *hint) ? SDL_atoi(hint) : -1; + [viewcontroller setNeedsUpdateOfHomeIndicatorAutoHidden]; + [viewcontroller setNeedsUpdateOfScreenEdgesDeferringSystemGestures]; + } +} +#endif + +@implementation SDLUITextField : UITextField +- (BOOL)canPerformAction:(SEL)action withSender:(id)sender +{ + if (action == @selector(paste:)) { + return NO; + } + + return [super canPerformAction:action withSender:sender]; +} +@end + +@implementation SDL_uikitviewcontroller +{ + CADisplayLink *displayLink; + int animationInterval; + void (*animationCallback)(void *); + void *animationCallbackParam; + +#ifdef SDL_IPHONE_KEYBOARD + SDLUITextField *textField; + BOOL hidingKeyboard; + BOOL rotatingOrientation; + NSString *committedText; + NSString *obligateForBackspace; +#endif +} + +@synthesize window; + +- (instancetype)initWithSDLWindow:(SDL_Window *)_window +{ + if (self = [super initWithNibName:nil bundle:nil]) { + self.window = _window; + +#ifdef SDL_IPHONE_KEYBOARD + [self initKeyboard]; + hidingKeyboard = NO; + rotatingOrientation = NO; +#endif + +#ifdef SDL_PLATFORM_TVOS + SDL_AddHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, + SDL_AppleTVControllerUIHintChanged, + (__bridge void *)self); +#endif + +#ifndef SDL_PLATFORM_TVOS + SDL_AddHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, + SDL_HideHomeIndicatorHintChanged, + (__bridge void *)self); +#endif + + // Enable high refresh rates on iOS + // To enable this on phones, you should add the following line to Info.plist: + // CADisableMinimumFrameDurationOnPhone + if (@available(iOS 15.0, tvOS 15.0, *)) { + const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(SDL_GetPrimaryDisplay()); + if (mode && mode->refresh_rate > 60.0f) { + int frame_rate = (int)mode->refresh_rate; + displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(doLoop:)]; + displayLink.preferredFrameRateRange = CAFrameRateRangeMake((frame_rate * 2) / 3, frame_rate, frame_rate); + [displayLink addToRunLoop:NSRunLoop.currentRunLoop forMode:NSDefaultRunLoopMode]; + } + } + } + return self; +} + +- (void)dealloc +{ +#ifdef SDL_IPHONE_KEYBOARD + [self deinitKeyboard]; +#endif + +#ifdef SDL_PLATFORM_TVOS + SDL_RemoveHintCallback(SDL_HINT_APPLE_TV_CONTROLLER_UI_EVENTS, + SDL_AppleTVControllerUIHintChanged, + (__bridge void *)self); +#endif + +#ifndef SDL_PLATFORM_TVOS + SDL_RemoveHintCallback(SDL_HINT_IOS_HIDE_HOME_INDICATOR, + SDL_HideHomeIndicatorHintChanged, + (__bridge void *)self); +#endif +} + +- (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection +{ + SDL_SetSystemTheme(UIKit_GetSystemTheme()); +} + +- (void)setAnimationCallback:(int)interval + callback:(void (*)(void *))callback + callbackParam:(void *)callbackParam +{ + [self stopAnimation]; + + if (interval <= 0) { + interval = 1; + } + animationInterval = interval; + animationCallback = callback; + animationCallbackParam = callbackParam; + + if (animationCallback) { + [self startAnimation]; + } +} + +- (void)startAnimation +{ + displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(doLoop:)]; + +#ifdef SDL_PLATFORM_VISIONOS + displayLink.preferredFramesPerSecond = 90 / animationInterval; //TODO: Get frame max frame rate on visionOS +#else + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + + displayLink.preferredFramesPerSecond = data.uiwindow.screen.maximumFramesPerSecond / animationInterval; +#endif + + [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; +} + +- (void)stopAnimation +{ + [displayLink invalidate]; + displayLink = nil; +} + +- (void)doLoop:(CADisplayLink *)sender +{ + // Don't run the game loop while a messagebox is up + if (animationCallback && !UIKit_ShowingMessageBox()) { + // See the comment in the function definition. +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + UIKit_GL_RestoreCurrentContext(); +#endif + + animationCallback(animationCallbackParam); + } +} + +- (void)loadView +{ + // Do nothing. +} + +- (void)viewDidLayoutSubviews +{ + const CGSize size = self.view.bounds.size; + int w = (int)size.width; + int h = (int)size.height; + + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, w, h); +} + +#ifndef SDL_PLATFORM_TVOS +- (NSUInteger)supportedInterfaceOrientations +{ + return UIKit_GetSupportedOrientations(window); +} + +- (BOOL)prefersStatusBarHidden +{ + BOOL hidden = (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) != 0; + return hidden; +} + +- (BOOL)prefersHomeIndicatorAutoHidden +{ + BOOL hidden = NO; + if (self.homeIndicatorHidden == 1) { + hidden = YES; + } + return hidden; +} + +- (UIRectEdge)preferredScreenEdgesDeferringSystemGestures +{ + if (self.homeIndicatorHidden >= 0) { + if (self.homeIndicatorHidden == 2) { + return UIRectEdgeAll; + } else { + return UIRectEdgeNone; + } + } + + // By default, fullscreen and borderless windows get all screen gestures + if ((window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) != 0) { + return UIRectEdgeAll; + } else { + return UIRectEdgeNone; + } +} + +- (BOOL)prefersPointerLocked +{ + return SDL_GCMouseRelativeMode() ? YES : NO; +} + +#endif // !SDL_PLATFORM_TVOS + +/* + ---- Keyboard related functionality below this line ---- + */ +#ifdef SDL_IPHONE_KEYBOARD + +@synthesize textInputRect; +@synthesize keyboardHeight; +@synthesize textFieldFocused; + +// Set ourselves up as a UITextFieldDelegate +- (void)initKeyboard +{ + obligateForBackspace = @" "; // 64 space + textField = [[SDLUITextField alloc] initWithFrame:CGRectZero]; + textField.delegate = self; + // placeholder so there is something to delete! + textField.text = obligateForBackspace; + committedText = textField.text; + + textField.hidden = YES; + textFieldFocused = NO; + + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; +#ifndef SDL_PLATFORM_TVOS + [center addObserver:self + selector:@selector(keyboardWillShow:) + name:UIKeyboardWillShowNotification + object:nil]; + [center addObserver:self + selector:@selector(keyboardWillHide:) + name:UIKeyboardWillHideNotification + object:nil]; + [center addObserver:self + selector:@selector(keyboardDidHide:) + name:UIKeyboardDidHideNotification + object:nil]; +#endif + [center addObserver:self + selector:@selector(textFieldTextDidChange:) + name:UITextFieldTextDidChangeNotification + object:nil]; +} + +- (NSArray *)keyCommands +{ + NSMutableArray *commands = [[NSMutableArray alloc] init]; + [commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputUpArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; + [commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputDownArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; + [commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputLeftArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; + [commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputRightArrow modifierFlags:kNilOptions action:@selector(handleCommand:)]]; + [commands addObject:[UIKeyCommand keyCommandWithInput:UIKeyInputEscape modifierFlags:kNilOptions action:@selector(handleCommand:)]]; + return [NSArray arrayWithArray:commands]; +} + +- (void)handleCommand:(UIKeyCommand *)keyCommand +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + NSString *input = keyCommand.input; + + if (input == UIKeyInputUpArrow) { + scancode = SDL_SCANCODE_UP; + } else if (input == UIKeyInputDownArrow) { + scancode = SDL_SCANCODE_DOWN; + } else if (input == UIKeyInputLeftArrow) { + scancode = SDL_SCANCODE_LEFT; + } else if (input == UIKeyInputRightArrow) { + scancode = SDL_SCANCODE_RIGHT; + } else if (input == UIKeyInputEscape) { + scancode = SDL_SCANCODE_ESCAPE; + } + + if (scancode != SDL_SCANCODE_UNKNOWN) { + SDL_SendKeyboardKeyAutoRelease(0, scancode); + } +} + +- (void)setView:(UIView *)view +{ + [super setView:view]; + + [view addSubview:textField]; + + if (textFieldFocused) { + /* startTextInput has been called before the text field was added to the view, + * call it again for the text field to actually become first responder. */ + [self startTextInput]; + } +} + +- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator +{ + [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; + rotatingOrientation = YES; + [coordinator + animateAlongsideTransition:^(id context) { + } + completion:^(id context) { + self->rotatingOrientation = NO; + }]; +} + +- (void)deinitKeyboard +{ + NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; +#ifndef SDL_PLATFORM_TVOS + [center removeObserver:self + name:UIKeyboardWillShowNotification + object:nil]; + [center removeObserver:self + name:UIKeyboardWillHideNotification + object:nil]; + [center removeObserver:self + name:UIKeyboardDidHideNotification + object:nil]; +#endif + [center removeObserver:self + name:UITextFieldTextDidChangeNotification + object:nil]; +} + +- (void)setTextFieldProperties:(SDL_PropertiesID) props +{ + textField.secureTextEntry = NO; + + switch (SDL_GetTextInputType(props)) { + default: + case SDL_TEXTINPUT_TYPE_TEXT: + textField.keyboardType = UIKeyboardTypeDefault; + textField.textContentType = nil; + break; + case SDL_TEXTINPUT_TYPE_TEXT_NAME: + textField.keyboardType = UIKeyboardTypeDefault; + textField.textContentType = UITextContentTypeName; + break; + case SDL_TEXTINPUT_TYPE_TEXT_EMAIL: + textField.keyboardType = UIKeyboardTypeEmailAddress; + textField.textContentType = UITextContentTypeEmailAddress; + break; + case SDL_TEXTINPUT_TYPE_TEXT_USERNAME: + textField.keyboardType = UIKeyboardTypeDefault; + textField.textContentType = UITextContentTypeUsername; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN: + textField.keyboardType = UIKeyboardTypeDefault; + textField.textContentType = UITextContentTypePassword; + textField.secureTextEntry = YES; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE: + textField.keyboardType = UIKeyboardTypeDefault; + textField.textContentType = UITextContentTypePassword; + break; + case SDL_TEXTINPUT_TYPE_NUMBER: + textField.keyboardType = UIKeyboardTypeDecimalPad; + textField.textContentType = nil; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + textField.keyboardType = UIKeyboardTypeNumberPad; + if (@available(iOS 12.0, tvOS 12.0, *)) { + textField.textContentType = UITextContentTypeOneTimeCode; + } else { + textField.textContentType = nil; + } + textField.secureTextEntry = YES; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE: + textField.keyboardType = UIKeyboardTypeNumberPad; + if (@available(iOS 12.0, tvOS 12.0, *)) { + textField.textContentType = UITextContentTypeOneTimeCode; + } else { + textField.textContentType = nil; + } + break; + } + + switch (SDL_GetTextInputCapitalization(props)) { + default: + case SDL_CAPITALIZE_NONE: + textField.autocapitalizationType = UITextAutocapitalizationTypeNone; + break; + case SDL_CAPITALIZE_LETTERS: + textField.autocapitalizationType = UITextAutocapitalizationTypeAllCharacters; + break; + case SDL_CAPITALIZE_WORDS: + textField.autocapitalizationType = UITextAutocapitalizationTypeWords; + break; + case SDL_CAPITALIZE_SENTENCES: + textField.autocapitalizationType = UITextAutocapitalizationTypeSentences; + break; + } + + if (SDL_GetTextInputAutocorrect(props)) { + textField.autocorrectionType = UITextAutocorrectionTypeYes; + textField.spellCheckingType = UITextSpellCheckingTypeYes; + } else { + textField.autocorrectionType = UITextAutocorrectionTypeNo; + textField.spellCheckingType = UITextSpellCheckingTypeNo; + } + + if (SDL_GetTextInputMultiline(props)) { + textField.enablesReturnKeyAutomatically = YES; + } else { + textField.enablesReturnKeyAutomatically = NO; + } + + if (!textField.window) { + /* textField has not been added to the view yet, + we don't have to do anything. */ + return; + } + + // the text field needs to be re-added to the view in order to update correctly. + UIView *superview = textField.superview; + [textField removeFromSuperview]; + [superview addSubview:textField]; + + if (SDL_TextInputActive(window)) { + [textField becomeFirstResponder]; + } +} + +/* requests the SDL text field to become focused and accept text input. + * also shows the onscreen virtual keyboard if no hardware keyboard is attached. */ +- (bool)startTextInput +{ + textFieldFocused = YES; + if (!textField.window) { + /* textField has not been added to the view yet, + * we will try again when that happens. */ + return true; + } + + return [textField becomeFirstResponder]; +} + +/* requests the SDL text field to lose focus and stop accepting text input. + * also hides the onscreen virtual keyboard if no hardware keyboard is attached. */ +- (bool)stopTextInput +{ + textFieldFocused = NO; + if (!textField.window) { + /* textField has not been added to the view yet, + * we will try again when that happens. */ + return true; + } + + [self resetTextState]; + return [textField resignFirstResponder]; +} + +- (void)keyboardWillShow:(NSNotification *)notification +{ +#ifndef SDL_PLATFORM_TVOS + CGRect kbrect = [[notification userInfo][UIKeyboardFrameEndUserInfoKey] CGRectValue]; + + /* The keyboard rect is in the coordinate space of the screen/window, but we + * want its height in the coordinate space of the view. */ + kbrect = [self.view convertRect:kbrect fromView:nil]; + + [self setKeyboardHeight:(int)kbrect.size.height]; +#endif + + /* A keyboard hide transition has been interrupted with a show (keyboardWillHide has been called but keyboardDidHide didn't). + * since text input was stopped by the hide, we have to start it again. */ + if (hidingKeyboard) { + SDL_StartTextInput(window); + hidingKeyboard = NO; + } +} + +- (void)keyboardWillHide:(NSNotification *)notification +{ + hidingKeyboard = YES; + [self setKeyboardHeight:0]; + + /* When the user dismisses the software keyboard by the "hide" button in the bottom right corner, + * we want to reflect that on SDL_TextInputActive by calling SDL_StopTextInput...on certain conditions */ + if (SDL_TextInputActive(window) + /* keyboardWillHide gets called when a hardware keyboard is attached, + * keep text input state active if hiding while there is a hardware keyboard. + * if the hardware keyboard gets detached, the software keyboard will appear anyway. */ + && !SDL_HasKeyboard() + /* When the device changes orientation, a sequence of hide and show transitions are triggered. + * keep text input state active in this case. */ + && !rotatingOrientation) { + SDL_StopTextInput(window); + } +} + +- (void)keyboardDidHide:(NSNotification *)notification +{ + hidingKeyboard = NO; +} + +- (void)textFieldTextDidChange:(NSNotification *)notification +{ + if (textField.markedTextRange == nil) { + NSUInteger compareLength = SDL_min(textField.text.length, committedText.length); + NSUInteger matchLength; + + // Backspace over characters that are no longer in the string + for (matchLength = 0; matchLength < compareLength; ++matchLength) { + if ([committedText characterAtIndex:matchLength] != [textField.text characterAtIndex:matchLength]) { + break; + } + } + if (matchLength < committedText.length) { + size_t deleteLength = SDL_utf8strlen([[committedText substringFromIndex:matchLength] UTF8String]); + while (deleteLength > 0) { + // Send distinct down and up events for each backspace action + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, true); + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_BACKSPACE, false); + --deleteLength; + } + } + + if (matchLength < textField.text.length) { + NSString *pendingText = [textField.text substringFromIndex:matchLength]; + if (!SDL_HardwareKeyboardKeyPressed()) { + /* Go through all the characters in the string we've been sent and + * convert them to key presses */ + NSUInteger i; + for (i = 0; i < pendingText.length; i++) { + SDL_SendKeyboardUnicodeKey(0, [pendingText characterAtIndex:i]); + } + } + SDL_SendKeyboardText([pendingText UTF8String]); + } + committedText = textField.text; + } +} + +- (void)updateKeyboard +{ + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *) window->internal; + + CGAffineTransform t = self.view.transform; + CGPoint offset = CGPointMake(0.0, 0.0); +#ifdef SDL_PLATFORM_VISIONOS + CGRect frame = UIKit_ComputeViewFrame(window); +#else + CGRect frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); +#endif + + if (self.keyboardHeight && self.textInputRect.h) { + int rectbottom = (int)(self.textInputRect.y + self.textInputRect.h); + int keybottom = (int)(self.view.bounds.size.height - self.keyboardHeight); + if (keybottom < rectbottom) { + offset.y = keybottom - rectbottom; + } + } + + /* Apply this view's transform (except any translation) to the offset, in + * order to orient it correctly relative to the frame's coordinate space. */ + t.tx = 0.0; + t.ty = 0.0; + offset = CGPointApplyAffineTransform(offset, t); + + // Apply the updated offset to the view's frame. + frame.origin.x += offset.x; + frame.origin.y += offset.y; + + self.view.frame = frame; +} + +- (void)setKeyboardHeight:(int)height +{ + keyboardHeight = height; + [self updateKeyboard]; +} + +// UITextFieldDelegate method. Invoked when user types something. +- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +{ + if (textField.markedTextRange == nil) { + if (textField.text.length < 16) { + [self resetTextState]; + } + } + return YES; +} + +// Terminates the editing session +- (BOOL)textFieldShouldReturn:(UITextField *)_textField +{ + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_RETURN); + if (textFieldFocused && + SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, false)) { + SDL_StopTextInput(window); + } + return YES; +} + +- (void)resetTextState +{ + textField.text = obligateForBackspace; + committedText = textField.text; +} + +#endif + +@end + +// iPhone keyboard addition functions +#ifdef SDL_IPHONE_KEYBOARD + +static SDL_uikitviewcontroller *GetWindowViewController(SDL_Window *window) +{ + if (!window || !window->internal) { + SDL_SetError("Invalid window"); + return nil; + } + + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + + return data.viewcontroller; +} + +bool UIKit_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + return true; +} + +bool UIKit_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + @autoreleasepool { + SDL_uikitviewcontroller *vc = GetWindowViewController(window); + return [vc startTextInput]; + } +} + +bool UIKit_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_uikitviewcontroller *vc = GetWindowViewController(window); + return [vc stopTextInput]; + } +} + +void UIKit_SetTextInputProperties(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + @autoreleasepool { + SDL_uikitviewcontroller *vc = GetWindowViewController(window); + [vc setTextFieldProperties:props]; + } +} + +bool UIKit_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_uikitviewcontroller *vc = GetWindowViewController(window); + if (vc != nil) { + return vc.textFieldFocused; + } + return false; + } +} + +bool UIKit_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_uikitviewcontroller *vc = GetWindowViewController(window); + if (vc != nil) { + vc.textInputRect = window->text_input_rect; + + if (vc.textFieldFocused) { + [vc updateKeyboard]; + } + } + } + return true; +} + +#endif // SDL_IPHONE_KEYBOARD + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.h new file mode 100644 index 0000000..6957670 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.h. + */ + +#include "SDL_internal.h" + +#ifndef SDL_uikitvulkan_h_ +#define SDL_uikitvulkan_h_ + +#include "../SDL_vulkan_internal.h" +#include "../SDL_sysvideo.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_UIKIT) + +extern bool UIKit_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void UIKit_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* UIKit_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool UIKit_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void UIKit_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); + +#endif + +#endif // SDL_uikitvulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.m new file mode 100644 index 0000000..332593b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitvulkan.m @@ -0,0 +1,265 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.c. + */ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_UIKIT) + +#include "SDL_uikitvideo.h" +#include "SDL_uikitwindow.h" + +#include "SDL_uikitvulkan.h" +#include "SDL_uikitmetalview.h" + +#include + +const char *defaultPaths[] = { + "libvulkan.dylib", +}; + +/* Since libSDL is static, could use RTLD_SELF. Using RTLD_DEFAULT is future + * proofing. */ +#define DEFAULT_HANDLE RTLD_DEFAULT + +bool UIKit_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasMetalSurfaceExtension = false; + bool hasIOSSurfaceExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan Portability library is already loaded."); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + + if (!path) { + // Handle the case where Vulkan Portability is linked statically. + vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)dlsym(DEFAULT_HANDLE, + "vkGetInstanceProcAddr"); + } + + if (vkGetInstanceProcAddr) { + _this->vulkan_config.loader_handle = DEFAULT_HANDLE; + } else { + const char **paths; + const char *foundPath = NULL; + int numPaths; + int i; + + if (path) { + paths = &path; + numPaths = 1; + } else { + // Look for the .dylib packaged with the application instead. + paths = defaultPaths; + numPaths = SDL_arraysize(defaultPaths); + } + + for (i = 0; i < numPaths && _this->vulkan_config.loader_handle == NULL; i++) { + foundPath = paths[i]; + _this->vulkan_config.loader_handle = SDL_LoadObject(foundPath); + } + + if (_this->vulkan_config.loader_handle == NULL) { + return SDL_SetError("Failed to load Vulkan Portability library"); + } + + SDL_strlcpy(_this->vulkan_config.loader_path, path, + SDL_arraysize(_this->vulkan_config.loader_path)); + vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, + "vkGetInstanceProcAddr"); + } + + if (!vkGetInstanceProcAddr) { + SDL_SetError("Failed to find %s in either executable or %s: %s", + "vkGetInstanceProcAddr", + "linked Vulkan Portability library", + (const char *)dlerror()); + goto fail; + } + + _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + SDL_SetError("No vkEnumerateInstanceExtensionProperties found."); + goto fail; + } + + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + + if (!extensions) { + goto fail; + } + + for (Uint32 i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_EXT_METAL_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasMetalSurfaceExtension = true; + } else if (SDL_strcmp(VK_MVK_IOS_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasIOSSurfaceExtension = true; + } + } + + SDL_free(extensions); + + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan Portability doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else if (!hasMetalSurfaceExtension && !hasIOSSurfaceExtension) { + SDL_SetError("Installed Vulkan Portability doesn't implement the " VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " VK_MVK_IOS_SURFACE_EXTENSION_NAME " extensions"); + goto fail; + } + + return true; + +fail: + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void UIKit_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + if (_this->vulkan_config.loader_handle != DEFAULT_HANDLE) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + } + _this->vulkan_config.loader_handle = NULL; + } +} + +char const* const* UIKit_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ + static const char *const extensionsForUIKit[] = { + VK_KHR_SURFACE_EXTENSION_NAME, VK_EXT_METAL_SURFACE_EXTENSION_NAME + }; + if(count) { + *count = SDL_arraysize(extensionsForUIKit); + } + return extensionsForUIKit; +} + +bool UIKit_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkCreateMetalSurfaceEXT vkCreateMetalSurfaceEXT = + (PFN_vkCreateMetalSurfaceEXT)vkGetInstanceProcAddr( + (VkInstance)instance, + "vkCreateMetalSurfaceEXT"); + PFN_vkCreateIOSSurfaceMVK vkCreateIOSSurfaceMVK = + (PFN_vkCreateIOSSurfaceMVK)vkGetInstanceProcAddr( + (VkInstance)instance, + "vkCreateIOSSurfaceMVK"); + VkResult result; + SDL_MetalView metalview; + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + if (!vkCreateMetalSurfaceEXT && !vkCreateIOSSurfaceMVK) { + return SDL_SetError(VK_EXT_METAL_SURFACE_EXTENSION_NAME " or " VK_MVK_IOS_SURFACE_EXTENSION_NAME + " extensions are not enabled in the Vulkan instance."); + } + + metalview = UIKit_Metal_CreateView(_this, window); + if (metalview == NULL) { + return false; + } + + if (vkCreateMetalSurfaceEXT) { + VkMetalSurfaceCreateInfoEXT createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.pLayer = (__bridge const CAMetalLayer *) + UIKit_Metal_GetLayer(_this, metalview); + result = vkCreateMetalSurfaceEXT(instance, &createInfo, allocator, surface); + if (result != VK_SUCCESS) { + UIKit_Metal_DestroyView(_this, metalview); + return SDL_SetError("vkCreateMetalSurfaceEXT failed: %s", SDL_Vulkan_GetResultString(result)); + } + } else { + VkIOSSurfaceCreateInfoMVK createInfo = {}; + createInfo.sType = VK_STRUCTURE_TYPE_IOS_SURFACE_CREATE_INFO_MVK; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.pView = (const void *)metalview; + result = vkCreateIOSSurfaceMVK(instance, &createInfo, + allocator, surface); + if (result != VK_SUCCESS) { + UIKit_Metal_DestroyView(_this, metalview); + return SDL_SetError("vkCreateIOSSurfaceMVK failed: %s", SDL_Vulkan_GetResultString(result)); + } + } + + /* Unfortunately there's no SDL_Vulkan_DestroySurface function we can call + * Metal_DestroyView from. Right now the metal view's ref count is +2 (one + * from returning a new view object in CreateView, and one because it's + * a subview of the window.) If we release the view here to make it +1, it + * will be destroyed when the window is destroyed. + * + * TODO: Now that we have SDL_Vulkan_DestroySurface someone with enough + * knowledge of Metal can proceed. */ + CFBridgingRelease(metalview); + + return true; +} + +void UIKit_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + // TODO: Add CFBridgingRelease(metalview) here perhaps? + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.h b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.h new file mode 100644 index 0000000..da1fb63 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.h @@ -0,0 +1,56 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_uikitwindow_h_ +#define SDL_uikitwindow_h_ + +#include "../SDL_sysvideo.h" +#import "SDL_uikitvideo.h" +#import "SDL_uikitview.h" +#import "SDL_uikitviewcontroller.h" + +extern bool UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void UIKit_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern void UIKit_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void UIKit_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void UIKit_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void UIKit_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern SDL_FullscreenResult UIKit_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); +extern void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window); +extern void UIKit_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); + +extern NSUInteger UIKit_GetSupportedOrientations(SDL_Window *window); + +#define SDL_METALVIEW_TAG 255 + +@class UIWindow; + +@interface SDL_UIKitWindowData : NSObject + +@property(nonatomic, strong) UIWindow *uiwindow; +@property(nonatomic, strong) SDL_uikitviewcontroller *viewcontroller; + +// Array of SDL_uikitviews owned by this window. +@property(nonatomic, copy) NSMutableArray *views; + +@end + +#endif // SDL_uikitwindow_h_ diff --git a/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.m b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.m new file mode 100644 index 0000000..2b258b1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/uikit/SDL_uikitwindow.m @@ -0,0 +1,471 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_UIKIT + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_uikitvideo.h" +#include "SDL_uikitevents.h" +#include "SDL_uikitmodes.h" +#include "SDL_uikitwindow.h" +#include "SDL_uikitappdelegate.h" +#include "SDL_uikitview.h" +#include "SDL_uikitopenglview.h" + +#include + +@implementation SDL_UIKitWindowData + +@synthesize uiwindow; +@synthesize viewcontroller; +@synthesize views; + +- (instancetype)init +{ + if ((self = [super init])) { + views = [NSMutableArray new]; + } + + return self; +} + +@end + +@interface SDL_uikitwindow : UIWindow + +- (void)layoutSubviews; + +@end + +@implementation SDL_uikitwindow + +- (void)layoutSubviews +{ +#ifndef SDL_PLATFORM_VISIONOS + // Workaround to fix window orientation issues in iOS 8. + /* As of July 1 2019, I haven't been able to reproduce any orientation + * issues with this disabled on iOS 12. The issue this is meant to fix might + * only happen on iOS 8, or it might have been fixed another way with other + * code... This code prevents split view (iOS 9+) from working on iPads, so + * we want to avoid using it if possible. */ + if (!UIKit_IsSystemVersionAtLeast(9.0)) { + self.frame = self.screen.bounds; + } +#endif + [super layoutSubviews]; +} + +@end + +static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, UIWindow *uiwindow, bool created) +{ + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->internal; + SDL_uikitview *view; + +#ifdef SDL_PLATFORM_VISIONOS + CGRect frame = UIKit_ComputeViewFrame(window); +#else + CGRect frame = UIKit_ComputeViewFrame(window, displaydata.uiscreen); +#endif + + int width = (int)frame.size.width; + int height = (int)frame.size.height; + + SDL_UIKitWindowData *data = [[SDL_UIKitWindowData alloc] init]; + if (!data) { + return SDL_OutOfMemory(); + } + + window->internal = (SDL_WindowData *)CFBridgingRetain(data); + + data.uiwindow = uiwindow; + +#ifndef SDL_PLATFORM_VISIONOS + if (displaydata.uiscreen != [UIScreen mainScreen]) { + window->flags &= ~SDL_WINDOW_RESIZABLE; // window is NEVER resizable + window->flags &= ~SDL_WINDOW_INPUT_FOCUS; // never has input focus + window->flags |= SDL_WINDOW_BORDERLESS; // never has a status bar. + } +#endif + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + if (displaydata.uiscreen == [UIScreen mainScreen]) { + NSUInteger orients = UIKit_GetSupportedOrientations(window); + BOOL supportsLandscape = (orients & UIInterfaceOrientationMaskLandscape) != 0; + BOOL supportsPortrait = (orients & (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown)) != 0; + + // Make sure the width/height are oriented correctly + if ((width > height && !supportsLandscape) || (height > width && !supportsPortrait)) { + int temp = width; + width = height; + height = temp; + } + } +#endif // !SDL_PLATFORM_TVOS + +#if 0 // Don't set the x/y position, it's already placed on a display + window->x = 0; + window->y = 0; +#endif + window->w = width; + window->h = height; + + /* The View Controller will handle rotating the view when the device + * orientation changes. This will trigger resize events, if appropriate. */ + data.viewcontroller = [[SDL_uikitviewcontroller alloc] initWithSDLWindow:window]; + + /* The window will initially contain a generic view so resizes, touch events, + * etc. can be handled without an active OpenGL view/context. */ + view = [[SDL_uikitview alloc] initWithFrame:frame]; + + /* Sets this view as the controller's view, and adds the view to the window + * hierarchy. */ + [view setSDLWindow:window]; + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_UIKIT_WINDOW_POINTER, (__bridge void *)data.uiwindow); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_UIKIT_METAL_VIEW_TAG_NUMBER, SDL_METALVIEW_TAG); + + return true; +} + +bool UIKit_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + @autoreleasepool { + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + SDL_UIKitDisplayData *data = (__bridge SDL_UIKitDisplayData *)display->internal; + SDL_Window *other; + + // We currently only handle a single window per display on iOS + for (other = _this->windows; other; other = other->next) { + if (other != window && SDL_GetVideoDisplayForWindow(other) == display) { + return SDL_SetError("Only one window allowed per display."); + } + } + + /* If monitor has a resolution of 0x0 (hasn't been explicitly set by the + * user, so it's in standby), try to force the display to a resolution + * that most closely matches the desired window size. */ +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + const CGSize origsize = data.uiscreen.currentMode.size; + if ((origsize.width == 0.0f) && (origsize.height == 0.0f)) { + SDL_DisplayMode bestmode; + bool include_high_density_modes = false; + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + include_high_density_modes = true; + } + if (SDL_GetClosestFullscreenDisplayMode(display->id, window->w, window->h, 0.0f, include_high_density_modes, &bestmode)) { + SDL_UIKitDisplayModeData *modedata = (__bridge SDL_UIKitDisplayModeData *)bestmode.internal; + [data.uiscreen setCurrentMode:modedata.uiscreenmode]; + + /* desktop_mode doesn't change here (the higher level will + * use it to set all the screens back to their defaults + * upon window destruction, SDL_Quit(), etc. */ + SDL_SetCurrentDisplayMode(display, &bestmode); + } + } + + if (data.uiscreen == [UIScreen mainScreen]) { + if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) { + [UIApplication sharedApplication].statusBarHidden = YES; + } else { + [UIApplication sharedApplication].statusBarHidden = NO; + } + } +#endif // !SDL_PLATFORM_TVOS + + // ignore the size user requested, and make a fullscreen window + // !!! FIXME: can we have a smaller view? +#ifdef SDL_PLATFORM_VISIONOS + UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:CGRectMake(window->x, window->y, window->w, window->h)]; +#else + UIWindow *uiwindow = [[SDL_uikitwindow alloc] initWithFrame:data.uiscreen.bounds]; +#endif + + // put the window on an external display if appropriate. +#ifndef SDL_PLATFORM_VISIONOS + if (data.uiscreen != [UIScreen mainScreen]) { + [uiwindow setScreen:data.uiscreen]; + } +#endif + + if (!SetupWindowData(_this, window, uiwindow, true)) { + return false; + } + } + + return true; +} + +void UIKit_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + data.viewcontroller.title = @(window->title); + } +} + +void UIKit_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + [data.uiwindow makeKeyAndVisible]; + + // Make this window the current mouse focus for touch input + SDL_VideoDisplay *display = SDL_GetVideoDisplayForWindow(window); + SDL_UIKitDisplayData *displaydata = (__bridge SDL_UIKitDisplayData *)display->internal; +#ifndef SDL_PLATFORM_VISIONOS + if (displaydata.uiscreen == [UIScreen mainScreen]) +#endif + { + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); + } + } +} + +void UIKit_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + data.uiwindow.hidden = YES; + } +} + +void UIKit_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) + /* We don't currently offer a concept of "raising" the SDL window, since + * we only allow one per display, in the iOS fashion. + * However, we use this entry point to rebind the context to the view + * during OnWindowRestored processing. */ + _this->GL_MakeCurrent(_this, _this->current_glwin, _this->current_glctx); +#endif +} + +static void UIKit_UpdateWindowBorder(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + SDL_uikitviewcontroller *viewcontroller = data.viewcontroller; + +#if !defined(SDL_PLATFORM_TVOS) && !defined(SDL_PLATFORM_VISIONOS) + if (data.uiwindow.screen == [UIScreen mainScreen]) { + if (window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS)) { + [UIApplication sharedApplication].statusBarHidden = YES; + } else { + [UIApplication sharedApplication].statusBarHidden = NO; + } + + [viewcontroller setNeedsStatusBarAppearanceUpdate]; + } + + // Update the view's frame to account for the status bar change. + viewcontroller.view.frame = UIKit_ComputeViewFrame(window, data.uiwindow.screen); +#endif // !SDL_PLATFORM_TVOS + +#ifdef SDL_IPHONE_KEYBOARD + // Make sure the view is offset correctly when the keyboard is visible. + [viewcontroller updateKeyboard]; +#endif + + [viewcontroller.view setNeedsLayout]; + [viewcontroller.view layoutIfNeeded]; +} + +void UIKit_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) +{ + @autoreleasepool { + if (bordered) { + window->flags &= ~SDL_WINDOW_BORDERLESS; + } else { + window->flags |= SDL_WINDOW_BORDERLESS; + } + UIKit_UpdateWindowBorder(_this, window); + } +} + +SDL_FullscreenResult UIKit_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) +{ + @autoreleasepool { + SDL_SendWindowEvent(window, fullscreen ? SDL_EVENT_WINDOW_ENTER_FULLSCREEN : SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + UIKit_UpdateWindowBorder(_this, window); + } + return SDL_FULLSCREEN_SUCCEEDED; +} + +void UIKit_UpdatePointerLock(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifndef SDL_PLATFORM_TVOS + @autoreleasepool { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + SDL_uikitviewcontroller *viewcontroller = data.viewcontroller; + if (@available(iOS 14.0, *)) { + [viewcontroller setNeedsUpdateOfPrefersPointerLocked]; + } + } +#endif // !SDL_PLATFORM_TVOS +} + +void UIKit_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + @autoreleasepool { + if (window->internal != NULL) { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + NSArray *views = nil; + + [data.viewcontroller stopAnimation]; + + /* Detach all views from this window. We use a copy of the array + * because setSDLWindow will remove the object from the original + * array, which would be undesirable if we were iterating over it. */ + views = [data.views copy]; + for (SDL_uikitview *view in views) { + [view setSDLWindow:NULL]; + } + + /* iOS may still hold a reference to the window after we release it. + * We want to make sure the SDL view controller isn't accessed in + * that case, because it would contain an invalid pointer to the old + * SDL window. */ + data.uiwindow.rootViewController = nil; + data.uiwindow.hidden = YES; + + CFRelease(window->internal); + window->internal = NULL; + } + } +} + +void UIKit_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) +{ + @autoreleasepool { + SDL_UIKitWindowData *windata = (__bridge SDL_UIKitWindowData *)window->internal; + UIView *view = windata.viewcontroller.view; + CGSize size = view.bounds.size; + CGFloat scale = 1.0; + + + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { +#ifndef SDL_PLATFORM_VISIONOS + scale = windata.uiwindow.screen.nativeScale; +#else + scale = 2.0; +#endif + } + + + /* Integer truncation of fractional values matches SDL_uikitmetalview and + * SDL_uikitopenglview. */ + *w = (int)(size.width * scale); + *h = (int)(size.height * scale); + } +} + +#ifndef SDL_PLATFORM_TVOS +NSUInteger +UIKit_GetSupportedOrientations(SDL_Window *window) +{ + const char *hint = SDL_GetHint(SDL_HINT_ORIENTATIONS); + NSUInteger validOrientations = UIInterfaceOrientationMaskAll; + NSUInteger orientationMask = 0; + + @autoreleasepool { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + UIApplication *app = [UIApplication sharedApplication]; + + /* Get all possible valid orientations. If the app delegate doesn't tell + * us, we get the orientations from Info.plist via UIApplication. */ + if ([app.delegate respondsToSelector:@selector(application:supportedInterfaceOrientationsForWindow:)]) { + validOrientations = [app.delegate application:app supportedInterfaceOrientationsForWindow:data.uiwindow]; + } else { + validOrientations = [app supportedInterfaceOrientationsForWindow:data.uiwindow]; + } + + if (hint != NULL) { + NSArray *orientations = [@(hint) componentsSeparatedByString:@" "]; + + if ([orientations containsObject:@"LandscapeLeft"]) { + orientationMask |= UIInterfaceOrientationMaskLandscapeLeft; + } + if ([orientations containsObject:@"LandscapeRight"]) { + orientationMask |= UIInterfaceOrientationMaskLandscapeRight; + } + if ([orientations containsObject:@"Portrait"]) { + orientationMask |= UIInterfaceOrientationMaskPortrait; + } + if ([orientations containsObject:@"PortraitUpsideDown"]) { + orientationMask |= UIInterfaceOrientationMaskPortraitUpsideDown; + } + } + + if (orientationMask == 0 && (window->flags & SDL_WINDOW_RESIZABLE)) { + // any orientation is okay. + orientationMask = UIInterfaceOrientationMaskAll; + } + + if (orientationMask == 0) { + if (window->floating.w >= window->floating.h) { + orientationMask |= UIInterfaceOrientationMaskLandscape; + } + if (window->floating.h >= window->floating.w) { + orientationMask |= (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown); + } + } + + // Don't allow upside-down orientation on phones, so answering calls is in the natural orientation + if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone) { + orientationMask &= ~UIInterfaceOrientationMaskPortraitUpsideDown; + } + + /* If none of the specified orientations are actually supported by the + * app, we'll revert to what the app supports. An exception would be + * thrown by the system otherwise. */ + if ((validOrientations & orientationMask) == 0) { + orientationMask = validOrientations; + } + } + + return orientationMask; +} +#endif // !SDL_PLATFORM_TVOS + +bool SDL_SetiOSAnimationCallback(SDL_Window *window, int interval, SDL_iOSAnimationCallback callback, void *callbackParam) +{ + if (!window || !window->internal) { + return SDL_SetError("Invalid window"); + } + + @autoreleasepool { + SDL_UIKitWindowData *data = (__bridge SDL_UIKitWindowData *)window->internal; + [data.viewcontroller setAnimationCallback:interval + callback:callback + callbackParam:callbackParam]; + } + + return true; +} + +#endif // SDL_VIDEO_DRIVER_UIKIT diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.c new file mode 100644 index 0000000..b9bfb50 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.c @@ -0,0 +1,116 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VITA + +#include "SDL_vitavideo.h" + +#include + +#define SCREEN_W 960 +#define SCREEN_H 544 +#define ALIGN(x, a) (((x) + ((a)-1)) & ~((a)-1)) +#define DISPLAY_PIXEL_FORMAT SCE_DISPLAY_PIXELFORMAT_A8B8G8R8 + +void *vita_gpu_alloc(unsigned int type, unsigned int size, SceUID *uid) +{ + void *mem; + + if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW) { + size = ALIGN(size, 256 * 1024); + } else { + size = ALIGN(size, 4 * 1024); + } + + *uid = sceKernelAllocMemBlock("gpu_mem", type, size, NULL); + + if (*uid < 0) { + return NULL; + } + + if (sceKernelGetMemBlockBase(*uid, &mem) < 0) { + return NULL; + } + + return mem; +} + +void vita_gpu_free(SceUID uid) +{ + void *mem = NULL; + if (sceKernelGetMemBlockBase(uid, &mem) < 0) { + return; + } + sceKernelFreeMemBlock(uid); +} + +bool VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_WindowData *data = window->internal; + SceDisplayFrameBuf framebuf; + + *format = SDL_PIXELFORMAT_ABGR8888; + *pitch = SCREEN_W * 4; + + data->buffer = vita_gpu_alloc( + SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW, + 4 * SCREEN_W * SCREEN_H, + &data->buffer_uid); + + // SDL_memset the buffer to black + SDL_memset(data->buffer, 0x0, SCREEN_W * SCREEN_H * 4); + + SDL_memset(&framebuf, 0x00, sizeof(SceDisplayFrameBuf)); + framebuf.size = sizeof(SceDisplayFrameBuf); + framebuf.base = data->buffer; + framebuf.pitch = SCREEN_W; + framebuf.pixelformat = DISPLAY_PIXEL_FORMAT; + framebuf.width = SCREEN_W; + framebuf.height = SCREEN_H; + sceDisplaySetFrameBuf(&framebuf, SCE_DISPLAY_SETBUF_NEXTFRAME); + + *pixels = data->buffer; + + return true; +} + +bool VITA_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + // do nothing + return true; +} + +void VITA_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + if (!data) { + // The window wasn't fully initialized + return; + } + + vita_gpu_free(data->buffer_uid); + data->buffer = NULL; + return; +} + +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.h new file mode 100644 index 0000000..b85e9c3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitaframebuffer.h @@ -0,0 +1,25 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +extern bool VITA_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool VITA_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void VITA_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr.c new file mode 100644 index 0000000..1255e4e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr.c @@ -0,0 +1,122 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_VITA) && defined(SDL_VIDEO_VITA_PVR) && defined(SDL_VIDEO_VITA_PVR_OGL) +#include +#include +#include +#include +#include + +#include "SDL_vitavideo.h" +#include "../SDL_egl_c.h" +#include "SDL_vitagl_pvr_c.h" + +#define MAX_PATH 256 // vita limits are somehow wrong + +// Defaults +static int FB_WIDTH = 960; +static int FB_HEIGHT = 544; + +static void getFBSize(int *width, int *height) +{ + *width = FB_WIDTH; + *height = FB_HEIGHT; +} + +bool VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + PVRSRV_PSP2_APPHINT hint; + char *default_path = "app0:module"; + char target_path[MAX_PATH]; + + if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_INIT, true)) { + const char *override = SDL_GetHint(SDL_HINT_VITA_MODULE_PATH); + + if (override && *override) { + default_path = override; + } + + sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); + + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + + PVRSRVInitializeAppHint(&hint); + + SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); + SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); + SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); + + PVRSRVCreateVirtualAppHint(&hint); + } + + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); +} + +SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + char gl_version[3]; + SDL_GLContext context = NULL; + int temp_major = _this->gl_config.major_version; + int temp_minor = _this->gl_config.minor_version; + int temp_profile = _this->gl_config.profile_mask; + + // Set version to 2.0 and PROFILE to ES + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 0; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; + + context = SDL_EGL_CreateContext(_this, window->internal->egl_surface); + + if (context != NULL) { + FB_WIDTH = window->w; + FB_HEIGHT = window->h; + set_getprocaddress((void *(*)(const char *))eglGetProcAddress); + set_getmainfbsize(getFBSize); + SDL_snprintf(gl_version, 3, "%d%d", temp_major, temp_minor); + gl4es_setenv("LIBGL_NOTEXRECT", "1", 1); // Currently broken in driver + gl4es_setenv("LIBGL_GL", gl_version, 1); + initialize_gl4es(); + } + + // Restore gl_config + _this->gl_config.major_version = temp_major; + _this->gl_config.minor_version = temp_minor; + _this->gl_config.profile_mask = temp_profile; + + return context; +} + +SDL_FunctionPointer VITA_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + return gl4es_GetProcAddress(proc); +} + +#endif // SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr_c.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr_c.h new file mode 100644 index 0000000..118602d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagl_pvr_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitagl_pvr_c_h_ +#define SDL_vitagl_pvr_c_h_ + +#include "SDL_vitavideo.h" + +extern SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern int VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_FunctionPointer VITA_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); + +#endif // SDL_vitagl_pvr_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles.c new file mode 100644 index 0000000..2c74447 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles.c @@ -0,0 +1,217 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_VITA) && defined(SDL_VIDEO_VITA_PIB) +#include +#include + +#include "SDL_vitavideo.h" +#include "SDL_vitagles_c.h" + +/*****************************************************************************/ +// SDL OpenGL/OpenGL ES functions +/*****************************************************************************/ +#define EGLCHK(stmt) \ + do { \ + EGLint err; \ + \ + stmt; \ + err = eglGetError(); \ + if (err != EGL_SUCCESS) { \ + SDL_SetError("EGL error %d", err); \ + return NULL; \ + } \ + } while (0) + +void VITA_GLES_KeyboardCallback(ScePigletPreSwapData *data) +{ + SceCommonDialogUpdateParam commonDialogParam; + SDL_zero(commonDialogParam); + commonDialogParam.renderTarget.colorFormat = data->colorFormat; + commonDialogParam.renderTarget.surfaceType = data->surfaceType; + commonDialogParam.renderTarget.colorSurfaceData = data->colorSurfaceData; + commonDialogParam.renderTarget.depthSurfaceData = data->depthSurfaceData; + commonDialogParam.renderTarget.width = data->width; + commonDialogParam.renderTarget.height = data->height; + commonDialogParam.renderTarget.strideInPixels = data->strideInPixels; + commonDialogParam.displaySyncObject = data->displaySyncObject; + + sceCommonDialogUpdate(&commonDialogParam); +} + +bool VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + pibInit(PIB_SHACCCG | PIB_GET_PROC_ADDR_CORE); + return true; +} + +SDL_FunctionPointer VITA_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + return eglGetProcAddress(proc); +} + +void VITA_GLES_UnloadLibrary(SDL_VideoDevice *_this) +{ + eglTerminate(_this->gl_data->display); +} + +static EGLint width = 960; +static EGLint height = 544; + +SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + + SDL_WindowData *wdata = window->internal; + + EGLint attribs[32]; + EGLDisplay display; + EGLContext context; + EGLSurface surface; + EGLConfig config; + EGLint num_configs; + PFNEGLPIGLETVITASETPRESWAPCALLBACKSCEPROC preSwapCallback; + int i; + + const EGLint contextAttribs[] = { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + + EGLCHK(display = eglGetDisplay(0)); + + EGLCHK(eglInitialize(display, NULL, NULL)); + wdata->uses_gles = true; + window->flags |= SDL_WINDOW_FULLSCREEN; + + EGLCHK(eglBindAPI(EGL_OPENGL_ES_API)); + + i = 0; + attribs[i++] = EGL_RED_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_GREEN_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_BLUE_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_DEPTH_SIZE; + attribs[i++] = 0; + attribs[i++] = EGL_ALPHA_SIZE; + attribs[i++] = 8; + attribs[i++] = EGL_STENCIL_SIZE; + attribs[i++] = 0; + + attribs[i++] = EGL_SURFACE_TYPE; + attribs[i++] = 5; + + attribs[i++] = EGL_RENDERABLE_TYPE; + attribs[i++] = EGL_OPENGL_ES2_BIT; + + attribs[i++] = EGL_CONFORMANT; + attribs[i++] = EGL_OPENGL_ES2_BIT; + + attribs[i++] = EGL_NONE; + + EGLCHK(eglChooseConfig(display, attribs, &config, 1, &num_configs)); + + if (num_configs == 0) { + SDL_SetError("No valid EGL configs for requested mode"); + return NULL; + } + + EGLCHK(surface = eglCreateWindowSurface(display, config, VITA_WINDOW_960X544, NULL)); + + EGLCHK(context = eglCreateContext(display, config, EGL_NO_CONTEXT, contextAttribs)); + + EGLCHK(eglMakeCurrent(display, surface, surface, context)); + + EGLCHK(eglQuerySurface(display, surface, EGL_WIDTH, &width)); + EGLCHK(eglQuerySurface(display, surface, EGL_HEIGHT, &height)); + + _this->gl_data->display = display; + _this->gl_data->context = context; + _this->gl_data->surface = surface; + + preSwapCallback = (PFNEGLPIGLETVITASETPRESWAPCALLBACKSCEPROC)eglGetProcAddress("eglPigletVitaSetPreSwapCallbackSCE"); + preSwapCallback(VITA_GLES_KeyboardCallback); + + return context; +} + +bool VITA_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + if (!eglMakeCurrent(_this->gl_data->display, _this->gl_data->surface, + _this->gl_data->surface, _this->gl_data->context)) { + return SDL_SetError("Unable to make EGL context current"); + } + return true; +} + +bool VITA_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + EGLBoolean status; + status = eglSwapInterval(_this->gl_data->display, interval); + if (status == EGL_TRUE) { + // Return success to upper level + _this->gl_data->swapinterval = interval; + return true; + } + // Failed to set swap interval + return SDL_SetError("Unable to set the EGL swap interval"); +} + +bool VITA_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + *interval = _this->gl_data->swapinterval; + return true; +} + +bool VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (!eglSwapBuffers(_this->gl_data->display, _this->gl_data->surface)) { + return SDL_SetError("eglSwapBuffers() failed"); + } + return true; +} + +bool VITA_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + SDL_VideoData *phdata = _this->internal; + EGLBoolean status; + + if (phdata->egl_initialized != true) { + return SDL_SetError("VITA: GLES initialization failed, no OpenGL ES support"); + } + + // Check if OpenGL ES connection has been initialized + if (_this->gl_data->display != EGL_NO_DISPLAY) { + if (context != EGL_NO_CONTEXT) { + status = eglDestroyContext(_this->gl_data->display, context); + if (status != EGL_TRUE) { + // Error during OpenGL ES context destroying + return SDL_SetError("VITA: OpenGL ES context destroy error"); + } + } + } + + return true; +} + +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_c.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_c.h new file mode 100644 index 0000000..44cb14d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_c.h @@ -0,0 +1,53 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitagles_c_h_ +#define SDL_vitagles_c_h_ + +#include +#include +#include +#include +#include + +#include "SDL_vitavideo.h" + +typedef struct SDL_GLDriverData +{ + EGLDisplay display; + EGLContext context; + EGLSurface surface; + uint32_t swapinterval; +} SDL_GLDriverData; + +extern SDL_FunctionPointer VITA_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern bool VITA_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern void VITA_GLES_SwapBuffers(SDL_VideoDevice *_this); + +extern bool VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); + +extern bool VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void VITA_GLES_UnloadLibrary(SDL_VideoDevice *_this); +extern bool VITA_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool VITA_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval); + +#endif // SDL_vitagles_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr.c new file mode 100644 index 0000000..4ba0573 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr.c @@ -0,0 +1,92 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_VITA) && defined(SDL_VIDEO_VITA_PVR) +#include +#include +#include +#include + +#include "SDL_vitavideo.h" +#include "../SDL_egl_c.h" +#include "SDL_vitagles_pvr_c.h" + +#define MAX_PATH 256 // vita limits are somehow wrong + +bool VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + PVRSRV_PSP2_APPHINT hint; + const char *default_path = "app0:module"; + char target_path[MAX_PATH]; + + if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_INIT, true)) { + const char *override = SDL_GetHint(SDL_HINT_VITA_MODULE_PATH); + + if (override && *override) { + default_path = override; + } + + sceKernelLoadStartModule("vs0:sys/external/libfios2.suprx", 0, NULL, 0, NULL, NULL); + sceKernelLoadStartModule("vs0:sys/external/libc.suprx", 0, NULL, 0, NULL, NULL); + + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libgpu_es4_ext.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + + SDL_snprintf(target_path, MAX_PATH, "%s/%s", default_path, "libIMGEGL.suprx"); + sceKernelLoadStartModule(target_path, 0, NULL, 0, NULL, NULL); + + PVRSRVInitializeAppHint(&hint); + + SDL_snprintf(hint.szGLES1, MAX_PATH, "%s/%s", default_path, "libGLESv1_CM.suprx"); + SDL_snprintf(hint.szGLES2, MAX_PATH, "%s/%s", default_path, "libGLESv2.suprx"); + SDL_snprintf(hint.szWindowSystem, MAX_PATH, "%s/%s", default_path, "libpvrPSP2_WSEGL.suprx"); + + PVRSRVCreateVirtualAppHint(&hint); + } + + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)0, 0); +} + +SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + return SDL_EGL_CreateContext(_this, window->internal->egl_surface); +} + +bool VITA_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + if (window && context) { + return SDL_EGL_MakeCurrent(_this, window->internal->egl_surface, context); + } else { + return SDL_EGL_MakeCurrent(_this, NULL, NULL); + } +} + +bool VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = _this->internal; + if (videodata->ime_active) { + sceImeUpdate(); + } + return SDL_EGL_SwapBuffers(_this, window->internal->egl_surface); +} + +#endif // SDL_VIDEO_DRIVER_VITA && SDL_VIDEO_VITA_PVR diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr_c.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr_c.h new file mode 100644 index 0000000..ad87212 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitagles_pvr_c.h @@ -0,0 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitagles_pvr_c_h_ +#define SDL_vitagles_pvr_c_h_ + +#include "SDL_vitavideo.h" + +extern bool VITA_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); + +#endif // SDL_vitagles_pvr_c_h_ diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.c new file mode 100644 index 0000000..9967756 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.c @@ -0,0 +1,190 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VITA + +#include +#include +#include + +#include "SDL_vitavideo.h" +#include "SDL_vitakeyboard.h" +#include "../../events/SDL_keyboard_c.h" + +SceHidKeyboardReport k_reports[SCE_HID_MAX_REPORT]; +int keyboard_hid_handle = 0; +Uint8 prev_keys[6] = { 0 }; +Uint8 prev_modifiers = 0; +Uint8 locks = 0; +Uint8 lock_key_down = 0; + +void VITA_InitKeyboard(void) +{ +#ifdef SDL_VIDEO_VITA_PVR + sceSysmoduleLoadModule(SCE_SYSMODULE_IME); /** For PVR OSK Support **/ +#endif + sceHidKeyboardEnumerate(&keyboard_hid_handle, 1); + + if (keyboard_hid_handle > 0) { + SDL_AddKeyboard((SDL_KeyboardID)keyboard_hid_handle, NULL, false); + } +} + +void VITA_PollKeyboard(void) +{ + // We skip polling keyboard if no window is created + if (!Vita_Window) { + return; + } + + if (keyboard_hid_handle > 0) { + SDL_KeyboardID keyboardID = (SDL_KeyboardID)keyboard_hid_handle; + int numReports = sceHidKeyboardRead(keyboard_hid_handle, (SceHidKeyboardReport **)&k_reports, SCE_HID_MAX_REPORT); + + if (numReports < 0) { + keyboard_hid_handle = 0; + } else if (numReports) { + // Numlock and Capslock state changes only on a pressed event + // The k_report only reports the state of the LED + if (k_reports[numReports - 1].modifiers[1] & 0x1) { + if (!(locks & 0x1)) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_NUMLOCKCLEAR, true); + locks |= 0x1; + } + } else { + if (locks & 0x1) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_NUMLOCKCLEAR, false); + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_NUMLOCKCLEAR, true); + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_NUMLOCKCLEAR, false); + locks &= ~0x1; + } + } + + if (k_reports[numReports - 1].modifiers[1] & 0x2) { + if (!(locks & 0x2)) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_CAPSLOCK, true); + locks |= 0x2; + } + } else { + if (locks & 0x2) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_CAPSLOCK, false); + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_CAPSLOCK, true); + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_CAPSLOCK, false); + locks &= ~0x2; + } + } + + if (k_reports[numReports - 1].modifiers[1] & 0x4) { + if (!(locks & 0x4)) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_SCROLLLOCK, true); + locks |= 0x4; + } + } else { + if (locks & 0x4) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_SCROLLLOCK, false); + locks &= ~0x4; + } + } + + { + Uint8 changed_modifiers = k_reports[numReports - 1].modifiers[0] ^ prev_modifiers; + + if (changed_modifiers & 0x01) { + if (prev_modifiers & 0x01) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LCTRL, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LCTRL, true); + } + } + if (changed_modifiers & 0x02) { + if (prev_modifiers & 0x02) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LSHIFT, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LSHIFT, true); + } + } + if (changed_modifiers & 0x04) { + if (prev_modifiers & 0x04) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LALT, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LALT, true); + } + } + if (changed_modifiers & 0x08) { + if (prev_modifiers & 0x08) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LGUI, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_LGUI, true); + } + } + if (changed_modifiers & 0x10) { + if (prev_modifiers & 0x10) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RCTRL, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RCTRL, true); + } + } + if (changed_modifiers & 0x20) { + if (prev_modifiers & 0x20) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RSHIFT, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RSHIFT, true); + } + } + if (changed_modifiers & 0x40) { + if (prev_modifiers & 0x40) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RALT, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RALT, true); + } + } + if (changed_modifiers & 0x80) { + if (prev_modifiers & 0x80) { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RGUI, false); + } else { + SDL_SendKeyboardKey(0, keyboardID, 0, SDL_SCANCODE_RGUI, true); + } + } + } + + prev_modifiers = k_reports[numReports - 1].modifiers[0]; + + for (int i = 0; i < 6; i++) { + + int keyCode = k_reports[numReports - 1].keycodes[i]; + + if (keyCode != prev_keys[i]) { + + if (prev_keys[i]) { + SDL_SendKeyboardKey(0, keyboardID, 0, prev_keys[i], false); + } + if (keyCode) { + SDL_SendKeyboardKey(0, keyboardID, 0, keyCode, true); + } + prev_keys[i] = keyCode; + } + } + } + } +} + +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.h new file mode 100644 index 0000000..4b52864 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitakeyboard.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitakeyboard_h +#define SDL_vitakeyboard_h + +#include "SDL_internal.h" + +// Keyboard functions +extern void VITA_InitKeyboard(void); +extern void VITA_PollKeyboard(void); + +#endif // SDL_vitakeyboard_h diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c new file mode 100644 index 0000000..a63e156 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.c @@ -0,0 +1,125 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VITA + +#include "SDL_vitavideo.h" +#include "SDL_vitamessagebox.h" +#include + +#ifdef SDL_VIDEO_RENDER_VITA_GXM +#include "../../render/vitagxm/SDL_render_vita_gxm_tools.h" +#endif // SDL_VIDEO_RENDER_VITA_GXM + +bool VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ +#ifdef SDL_VIDEO_RENDER_VITA_GXM + SceMsgDialogParam param; + SceMsgDialogUserMessageParam msgParam; + SceMsgDialogButtonsParam buttonParam; + SceDisplayFrameBuf dispparam; + char message[512]; + + SceMsgDialogResult dialog_result; + SceCommonDialogErrorCode init_result; + bool setup_minimal_gxm = false; + + if (messageboxdata->numbuttons > 3) { + return false; + } + + SDL_zero(param); + sceMsgDialogParamInit(¶m); + param.mode = SCE_MSG_DIALOG_MODE_USER_MSG; + + SDL_zero(msgParam); + SDL_snprintf(message, sizeof(message), "%s\r\n\r\n%s", messageboxdata->title, messageboxdata->message); + + msgParam.msg = (const SceChar8 *)message; + SDL_zero(buttonParam); + + if (messageboxdata->numbuttons == 3) { + msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_3BUTTONS; + msgParam.buttonParam = &buttonParam; + buttonParam.msg1 = messageboxdata->buttons[0].text; + buttonParam.msg2 = messageboxdata->buttons[1].text; + buttonParam.msg3 = messageboxdata->buttons[2].text; + } else if (messageboxdata->numbuttons == 2) { + msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_YESNO; + } else if (messageboxdata->numbuttons == 1) { + msgParam.buttonType = SCE_MSG_DIALOG_BUTTON_TYPE_OK; + } + param.userMsgParam = &msgParam; + + dispparam.size = sizeof(dispparam); + + init_result = sceMsgDialogInit(¶m); + + // Setup display if it hasn't been initialized before + if (init_result == SCE_COMMON_DIALOG_ERROR_GXM_IS_UNINITIALIZED) { + gxm_minimal_init_for_common_dialog(); + init_result = sceMsgDialogInit(¶m); + setup_minimal_gxm = true; + } + + gxm_init_for_common_dialog(); + + if (init_result >= 0) { + while (sceMsgDialogGetStatus() == SCE_COMMON_DIALOG_STATUS_RUNNING) { + gxm_swap_for_common_dialog(); + } + SDL_zero(dialog_result); + sceMsgDialogGetResult(&dialog_result); + + if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON1) { + *buttonID = messageboxdata->buttons[0].buttonID; + } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON2) { + *buttonID = messageboxdata->buttons[1].buttonID; + } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_BUTTON3) { + *buttonID = messageboxdata->buttons[2].buttonID; + } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_YES) { + *buttonID = messageboxdata->buttons[0].buttonID; + } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_NO) { + *buttonID = messageboxdata->buttons[1].buttonID; + } else if (dialog_result.buttonId == SCE_MSG_DIALOG_BUTTON_ID_OK) { + *buttonID = messageboxdata->buttons[0].buttonID; + } + sceMsgDialogTerm(); + } else { + return false; + } + + gxm_term_for_common_dialog(); + + if (setup_minimal_gxm) { + gxm_minimal_term_for_common_dialog(); + } + + return true; +#else + (void)messageboxdata; + (void)buttonID; + return SDL_Unsupported(); +#endif // SDL_VIDEO_RENDER_VITA_GXM +} + +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.h new file mode 100644 index 0000000..7e4148d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamessagebox.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitamessagebox_h_ +#define SDL_vitamessagebox_h_ + +#ifdef SDL_VIDEO_DRIVER_VITA + +extern bool VITA_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_VITA + +#endif // SDL_vitamessagebox_h_ diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse.c new file mode 100644 index 0000000..7181023 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse.c @@ -0,0 +1,105 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VITA + +#include +#include +#include + +#include "SDL_vitavideo.h" +#include "SDL_vitamouse_c.h" +#include "../../events/SDL_mouse_c.h" + +SceHidMouseReport m_reports[SCE_HID_MAX_REPORT]; +int mouse_hid_handle = 0; +Uint8 prev_buttons = 0; + +void VITA_InitMouse(void) +{ + sceHidMouseEnumerate(&mouse_hid_handle, 1); + + if (mouse_hid_handle > 0) { + SDL_AddMouse((SDL_MouseID)mouse_hid_handle, NULL, false); + } +} + +void VITA_PollMouse(void) +{ + // We skip polling mouse if no window is created + if (!Vita_Window) { + return; + } + + if (mouse_hid_handle > 0) { + SDL_MouseID mouseID = (SDL_MouseID)mouse_hid_handle; + int numReports = sceHidMouseRead(mouse_hid_handle, (SceHidMouseReport **)&m_reports, SCE_HID_MAX_REPORT); + if (numReports > 0) { + for (int i = 0; i <= numReports - 1; i++) { + Uint8 changed_buttons = m_reports[i].buttons ^ prev_buttons; + + if (changed_buttons & 0x1) { + if (prev_buttons & 0x1) + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_LEFT, false); + else + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_LEFT, true); + } + if (changed_buttons & 0x2) { + if (prev_buttons & 0x2) + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_RIGHT, false); + else + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_RIGHT, true); + } + if (changed_buttons & 0x4) { + if (prev_buttons & 0x4) + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_MIDDLE, false); + else + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_MIDDLE, true); + } + if (changed_buttons & 0x8) { + if (prev_buttons & 0x8) + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_X1, false); + else + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_X1, true); + } + if (changed_buttons & 0x10) { + if (prev_buttons & 0x10) + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_X2, false); + else + SDL_SendMouseButton(0, Vita_Window, mouseID, SDL_BUTTON_X2, true); + } + + prev_buttons = m_reports[i].buttons; + + if (m_reports[i].rel_x || m_reports[i].rel_y) { + SDL_SendMouseMotion(0, Vita_Window, mouseID, true, (float)m_reports[i].rel_x, (float)m_reports[i].rel_y); + } + + if (m_reports[i].tilt != 0 || m_reports[i].wheel != 0) { + SDL_SendMouseWheel(0, Vita_Window, mouseID, m_reports[i].tilt, m_reports[i].wheel, SDL_MOUSEWHEEL_NORMAL); + } + } + } + } +} + +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse_c.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse_c.h new file mode 100644 index 0000000..ef6a7c9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitamouse_c.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitamouse_h +#define SDL_vitamouse_h + +#include "SDL_internal.h" + +// mouse functions +extern void VITA_InitMouse(void); +extern void VITA_PollMouse(void); + +#endif // SDL_vitamouse_h diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.c new file mode 100644 index 0000000..ac6f764 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.c @@ -0,0 +1,186 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VITA + +#include +#include + +#include "SDL_vitavideo.h" +#include "SDL_vitatouch.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" + +SceTouchData touch_old[SCE_TOUCH_PORT_MAX_NUM]; +SceTouchData touch[SCE_TOUCH_PORT_MAX_NUM]; + +SDL_FRect area_info[SCE_TOUCH_PORT_MAX_NUM]; + +struct +{ + float min; + float range; +} force_info[SCE_TOUCH_PORT_MAX_NUM]; + +static bool disableFrontPoll; +static bool disableBackPoll; + +void VITA_InitTouch(void) +{ + disableFrontPoll = !SDL_GetHintBoolean(SDL_HINT_VITA_ENABLE_FRONT_TOUCH, true); + disableBackPoll = !SDL_GetHintBoolean(SDL_HINT_VITA_ENABLE_BACK_TOUCH, true); + + sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START); + sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START); + sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT); + sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK); + + for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) { + SceTouchPanelInfo panelinfo; + sceTouchGetPanelInfo(port, &panelinfo); + + area_info[port].x = (float)panelinfo.minAaX; + area_info[port].y = (float)panelinfo.minAaY; + area_info[port].w = (float)(panelinfo.maxAaX - panelinfo.minAaX); + area_info[port].h = (float)(panelinfo.maxAaY - panelinfo.minAaY); + + force_info[port].min = (float)panelinfo.minForce; + force_info[port].range = (float)(panelinfo.maxForce - panelinfo.minForce); + } + + // Support passing both front and back touch devices in events + SDL_AddTouch(1, SDL_TOUCH_DEVICE_DIRECT, "Front"); + SDL_AddTouch(2, SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE, "Back"); +} + +void VITA_QuitTouch(void) +{ + sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT); + sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK); +} + +void VITA_PollTouch(void) +{ + SDL_TouchID touch_id; + SDL_FingerID finger_id; + int port; + + // We skip polling touch if no window is created + if (!Vita_Window) { + return; + } + + SDL_memcpy(touch_old, touch, sizeof(touch_old)); + + for (port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) { + /** Skip polling of Touch Device if hint is set **/ + if (((port == 0) && disableFrontPoll) || ((port == 1) && disableBackPoll)) { + continue; + } + sceTouchPeek(port, &touch[port], 1); + + touch_id = (SDL_TouchID)(port + 1); + + if (touch[port].reportNum > 0) { + for (int i = 0; i < touch[port].reportNum; i++) { + // adjust coordinates and forces to return normalized values + // for the front, screen area is used as a reference (for direct touch) + // e.g. touch_x = 1.0 corresponds to screen_x = 960 + // for the back panel, the active touch area is used as reference + float x = 0; + float y = 0; + float force = (touch[port].report[i].force - force_info[port].min) / force_info[port].range; + int finger_down = 0; + + if (touch_old[port].reportNum > 0) { + for (int j = 0; j < touch_old[port].reportNum; j++) { + if (touch[port].report[i].id == touch_old[port].report[j].id) { + finger_down = 1; + } + } + } + + VITA_ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port); + finger_id = (SDL_FingerID)(touch[port].report[i].id + 1); + + // Skip if finger was already previously down + if (!finger_down) { + // Send an initial touch + SDL_SendTouch(0, touch_id, finger_id, Vita_Window, SDL_EVENT_FINGER_DOWN, x, y, force); + } + + // Always send the motion + SDL_SendTouchMotion(0, touch_id, finger_id, Vita_Window, x, y, force); + } + } + + // some fingers might have been let go + if (touch_old[port].reportNum > 0) { + for (int i = 0; i < touch_old[port].reportNum; i++) { + int finger_up = 1; + if (touch[port].reportNum > 0) { + for (int j = 0; j < touch[port].reportNum; j++) { + if (touch[port].report[j].id == touch_old[port].report[i].id) { + finger_up = 0; + } + } + } + if (finger_up == 1) { + float x = 0; + float y = 0; + float force = (touch_old[port].report[i].force - force_info[port].min) / force_info[port].range; + VITA_ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port); + finger_id = (SDL_FingerID)(touch_old[port].report[i].id + 1); + // Finger released from screen + SDL_SendTouch(0, touch_id, finger_id, Vita_Window, SDL_EVENT_FINGER_UP, x, y, force); + } + } + } + } +} + +void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) +{ + float x, y; + + if (area_info[port].w <= 1) { + x = 0.5f; + } else { + x = (vita_x - area_info[port].x) / (area_info[port].w - 1); + } + if (area_info[port].h <= 1) { + y = 0.5f; + } else { + y = (vita_y - area_info[port].y) / (area_info[port].h - 1); + } + + x = SDL_max(x, 0.0f); + x = SDL_min(x, 1.0f); + + y = SDL_max(y, 0.0f); + y = SDL_min(y, 1.0f); + + *sdl_x = x; + *sdl_y = y; +} + +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.h new file mode 100644 index 0000000..b94051a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitatouch.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitatouch_h +#define SDL_vitatouch_h + +#include "SDL_internal.h" + +// Touch functions +extern void VITA_InitTouch(void); +extern void VITA_QuitTouch(void); +extern void VITA_PollTouch(void); +void VITA_ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port); + +#endif // SDL_vitatouch_h diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.c b/contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.c new file mode 100644 index 0000000..6b5dbd7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.c @@ -0,0 +1,592 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VITA + +// SDL internals +#include "../SDL_sysvideo.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" + +// VITA declarations +#include +#include "SDL_vitavideo.h" +#include "SDL_vitatouch.h" +#include "SDL_vitakeyboard.h" +#include "SDL_vitamouse_c.h" +#include "SDL_vitaframebuffer.h" +#include "SDL_vitamessagebox.h" + +#ifdef SDL_VIDEO_VITA_PIB +#include "SDL_vitagles_c.h" +#elif defined(SDL_VIDEO_VITA_PVR) +#include "SDL_vitagles_pvr_c.h" +#ifdef SDL_VIDEO_VITA_PVR_OGL +#include "SDL_vitagl_pvr_c.h" +#endif +#define VITA_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define VITA_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define VITA_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define VITA_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define VITA_GLES_DestroyContext SDL_EGL_DestroyContext +#endif + +SDL_Window *Vita_Window; + +static void VITA_Destroy(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *VITA_Create(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *phdata; +#ifdef SDL_VIDEO_VITA_PIB + SDL_GLDriverData *gldata; +#endif + // Initialize SDL_VideoDevice structure + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Initialize internal VITA specific data + phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!phdata) { + SDL_free(device); + return NULL; + } +#ifdef SDL_VIDEO_VITA_PIB + + gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); + if (!gldata) { + SDL_free(device); + SDL_free(phdata); + return NULL; + } + device->gl_data = gldata; + phdata->egl_initialized = true; +#endif + phdata->ime_active = false; + + device->internal = phdata; + + // Setup amount of available displays and current display + device->num_displays = 0; + + // Set device free function + device->free = VITA_Destroy; + + // Setup all functions which we can handle + device->VideoInit = VITA_VideoInit; + device->VideoQuit = VITA_VideoQuit; + device->CreateSDLWindow = VITA_CreateWindow; + device->SetWindowTitle = VITA_SetWindowTitle; + device->SetWindowPosition = VITA_SetWindowPosition; + device->SetWindowSize = VITA_SetWindowSize; + device->ShowWindow = VITA_ShowWindow; + device->HideWindow = VITA_HideWindow; + device->RaiseWindow = VITA_RaiseWindow; + device->MaximizeWindow = VITA_MaximizeWindow; + device->MinimizeWindow = VITA_MinimizeWindow; + device->RestoreWindow = VITA_RestoreWindow; + device->SetWindowMouseGrab = VITA_SetWindowGrab; + device->SetWindowKeyboardGrab = VITA_SetWindowGrab; + device->DestroyWindow = VITA_DestroyWindow; + + /* + // Disabled, causes issues on high-framerate updates. SDL still emulates this. + device->CreateWindowFramebuffer = VITA_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = VITA_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = VITA_DestroyWindowFramebuffer; + */ + +#if defined(SDL_VIDEO_VITA_PIB) || defined(SDL_VIDEO_VITA_PVR) +#ifdef SDL_VIDEO_VITA_PVR_OGL + if (SDL_GetHintBoolean(SDL_HINT_VITA_PVR_OPENGL, false)) { + device->GL_LoadLibrary = VITA_GL_LoadLibrary; + device->GL_CreateContext = VITA_GL_CreateContext; + device->GL_GetProcAddress = VITA_GL_GetProcAddress; + } else { +#endif + device->GL_LoadLibrary = VITA_GLES_LoadLibrary; + device->GL_CreateContext = VITA_GLES_CreateContext; + device->GL_GetProcAddress = VITA_GLES_GetProcAddress; +#ifdef SDL_VIDEO_VITA_PVR_OGL + } +#endif + + device->GL_UnloadLibrary = VITA_GLES_UnloadLibrary; + device->GL_MakeCurrent = VITA_GLES_MakeCurrent; + device->GL_SetSwapInterval = VITA_GLES_SetSwapInterval; + device->GL_GetSwapInterval = VITA_GLES_GetSwapInterval; + device->GL_SwapWindow = VITA_GLES_SwapWindow; + device->GL_DestroyContext = VITA_GLES_DestroyContext; +#endif + + device->HasScreenKeyboardSupport = VITA_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = VITA_ShowScreenKeyboard; + device->HideScreenKeyboard = VITA_HideScreenKeyboard; + device->IsScreenKeyboardShown = VITA_IsScreenKeyboardShown; + + device->PumpEvents = VITA_PumpEvents; + + return device; +} + +VideoBootStrap VITA_bootstrap = { + "vita", + "VITA Video Driver", + VITA_Create, + VITA_ShowMessageBox, + false +}; + +/*****************************************************************************/ +// SDL Video and Display initialization/handling functions +/*****************************************************************************/ +bool VITA_VideoInit(SDL_VideoDevice *_this) +{ + SDL_DisplayMode mode; +#ifdef SDL_VIDEO_VITA_PVR + const char *res = SDL_GetHint(SDL_HINT_VITA_RESOLUTION); +#endif + SDL_zero(mode); + +#ifdef SDL_VIDEO_VITA_PVR + if (res) { + // 1088i for PSTV (Or Sharpscale) + if (SDL_strncmp(res, "1080", 4) == 0) { + mode.w = 1920; + mode.h = 1088; + } + // 725p for PSTV (Or Sharpscale) + else if (SDL_strncmp(res, "720", 3) == 0) { + mode.w = 1280; + mode.h = 725; + } + } + // 544p + else { +#endif + mode.w = 960; + mode.h = 544; +#ifdef SDL_VIDEO_VITA_PVR + } +#endif + + mode.refresh_rate = 60.0f; + + // 32 bpp for default + mode.format = SDL_PIXELFORMAT_ABGR8888; + + if (SDL_AddBasicVideoDisplay(&mode) == 0) { + return false; + } + + VITA_InitTouch(); + VITA_InitKeyboard(); + VITA_InitMouse(); + + return true; +} + +void VITA_VideoQuit(SDL_VideoDevice *_this) +{ + VITA_QuitTouch(); +} + +bool VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *wdata; +#ifdef SDL_VIDEO_VITA_PVR + Psp2NativeWindow win; + int temp_major = 2; + int temp_minor = 1; + int temp_profile = 0; +#endif + + // Allocate window internal data + wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!wdata) { + return false; + } + + // Setup driver data for this window + window->internal = wdata; + + // Vita can only have one window + if (Vita_Window) { + return SDL_SetError("Only one window supported"); + } + + Vita_Window = window; + +#ifdef SDL_VIDEO_VITA_PVR + win.type = PSP2_DRAWABLE_TYPE_WINDOW; + win.numFlipBuffers = 2; + win.flipChainThrdAffinity = 0x20000; + + // 1088i for PSTV (Or Sharpscale) + if (window->w == 1920) { + win.windowSize = PSP2_WINDOW_1920X1088; + } + // 725p for PSTV (Or Sharpscale) + else if (window->w == 1280) { + win.windowSize = PSP2_WINDOW_1280X725; + } + // 544p + else { + win.windowSize = PSP2_WINDOW_960X544; + } + if (window->flags & SDL_WINDOW_OPENGL) { + bool use_opengl = SDL_GetHintBoolean(SDL_HINT_VITA_PVR_OPENGL, false); + if (use_opengl) { + // Set version to 2.1 and PROFILE to ES + temp_major = _this->gl_config.major_version; + temp_minor = _this->gl_config.minor_version; + temp_profile = _this->gl_config.profile_mask; + + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 1; + _this->gl_config.profile_mask = SDL_GL_CONTEXT_PROFILE_ES; + } + wdata->egl_surface = SDL_EGL_CreateSurface(_this, window, &win); + if (wdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + if (use_opengl) { + // Revert + _this->gl_config.major_version = temp_major; + _this->gl_config.minor_version = temp_minor; + _this->gl_config.profile_mask = temp_profile; + } + } +#endif + + // fix input, we need to find a better way + SDL_SetKeyboardFocus(window); + + // Window has been successfully created + return true; +} + +void VITA_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +bool VITA_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + return SDL_Unsupported(); +} +void VITA_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void VITA_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void VITA_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void VITA_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void VITA_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void VITA_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +void VITA_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +} +bool VITA_SetWindowGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + return true; +} + +void VITA_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data; + + data = window->internal; + if (data) { + // TODO: should we destroy egl context? No one sane should recreate ogl window as non-ogl + SDL_free(data); + } + + window->internal = NULL; + Vita_Window = NULL; +} + +bool VITA_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + return true; +} + +#ifndef SCE_IME_LANGUAGE_ENGLISH_US +#define SCE_IME_LANGUAGE_ENGLISH_US SCE_IME_LANGUAGE_ENGLISH +#endif + +static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) +{ + int i; + for (i = 0; src[i]; i++) { + if (!(src[i] & 0xFF80)) { + *(dst++) = src[i] & 0xFF; + } else if (!(src[i] & 0xF800)) { + *(dst++) = ((src[i] >> 6) & 0xFF) | 0xC0; + *(dst++) = (src[i] & 0x3F) | 0x80; + } else if ((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) { + *(dst++) = (((src[i] + 64) >> 8) & 0x3) | 0xF0; + *(dst++) = (((src[i] >> 2) + 16) & 0x3F) | 0x80; + *(dst++) = ((src[i] >> 4) & 0x30) | 0x80 | ((src[i + 1] << 2) & 0xF); + *(dst++) = (src[i + 1] & 0x3F) | 0x80; + i += 1; + } else { + *(dst++) = ((src[i] >> 12) & 0xF) | 0xE0; + *(dst++) = ((src[i] >> 6) & 0x3F) | 0x80; + *(dst++) = (src[i] & 0x3F) | 0x80; + } + } + + *dst = '\0'; +} + +#ifdef SDL_VIDEO_VITA_PVR +SceWChar16 libime_out[SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1]; +char libime_initval[8] = { 1 }; +SceImeCaret caret_rev; + +void VITA_ImeEventHandler(void *arg, const SceImeEventData *e) +{ + SDL_VideoData *videodata = (SDL_VideoData *)arg; + uint8_t utf8_buffer[SCE_IME_MAX_TEXT_LENGTH]; + switch (e->id) { + case SCE_IME_EVENT_UPDATE_TEXT: + if (e->param.text.caretIndex == 0) { + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_BACKSPACE); + sceImeSetText((SceWChar16 *)libime_initval, 4); + } else { + utf16_to_utf8((SceWChar16 *)&libime_out[1], utf8_buffer); + if (utf8_buffer[0] == ' ') { + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_SPACE); + } else { + SDL_SendKeyboardText((const char *)utf8_buffer); + } + SDL_memset(&caret_rev, 0, sizeof(SceImeCaret)); + SDL_memset(libime_out, 0, ((SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1) * sizeof(SceWChar16))); + caret_rev.index = 1; + sceImeSetCaret(&caret_rev); + sceImeSetText((SceWChar16 *)libime_initval, 4); + } + break; + case SCE_IME_EVENT_PRESS_ENTER: + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_RETURN); + break; + case SCE_IME_EVENT_PRESS_CLOSE: + sceImeClose(); + videodata->ime_active = false; + break; + } +} +#endif + +void VITA_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + SDL_VideoData *videodata = _this->internal; + SceInt32 res; + +#ifdef SDL_VIDEO_VITA_PVR + + SceUInt32 libime_work[SCE_IME_WORK_BUFFER_SIZE / sizeof(SceInt32)]; + SceImeParam param; + + sceImeParamInit(¶m); + + SDL_memset(libime_out, 0, ((SCE_IME_MAX_PREEDIT_LENGTH + SCE_IME_MAX_TEXT_LENGTH + 1) * sizeof(SceWChar16))); + + param.supportedLanguages = SCE_IME_LANGUAGE_ENGLISH_US; + param.languagesForced = SCE_FALSE; + switch (SDL_GetTextInputType(props)) { + default: + case SDL_TEXTINPUT_TYPE_TEXT: + param.type = SCE_IME_TYPE_DEFAULT; + break; + case SDL_TEXTINPUT_TYPE_TEXT_NAME: + param.type = SCE_IME_TYPE_DEFAULT; + break; + case SDL_TEXTINPUT_TYPE_TEXT_EMAIL: + param.type = SCE_IME_TYPE_MAIL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_USERNAME: + param.type = SCE_IME_TYPE_DEFAULT; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN: + param.type = SCE_IME_TYPE_DEFAULT; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE: + param.type = SCE_IME_TYPE_DEFAULT; + break; + case SDL_TEXTINPUT_TYPE_NUMBER: + param.type = SCE_IME_TYPE_NUMBER; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + param.type = SCE_IME_TYPE_NUMBER; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE: + param.type = SCE_IME_TYPE_NUMBER; + break; + } + param.option = 0; + if (SDL_GetTextInputCapitalization(props) != SDL_CAPITALIZE_SENTENCES) { + param.option |= SCE_IME_OPTION_NO_AUTO_CAPITALIZATION; + } + if (!SDL_GetTextInputAutocorrect(props)) { + param.option |= SCE_IME_OPTION_NO_ASSISTANCE; + } + if (SDL_GetTextInputMultiline(props)) { + param.option |= SCE_IME_OPTION_MULTILINE; + } + param.inputTextBuffer = libime_out; + param.maxTextLength = SCE_IME_MAX_TEXT_LENGTH; + param.handler = VITA_ImeEventHandler; + param.filter = NULL; + param.initialText = (SceWChar16 *)libime_initval; + param.arg = videodata; + param.work = libime_work; + + res = sceImeOpen(¶m); + if (res < 0) { + SDL_SetError("Failed to init IME"); + return; + } + +#else + SceWChar16 *title = u""; + SceWChar16 *text = u""; + + SceImeDialogParam param; + sceImeDialogParamInit(¶m); + + param.supportedLanguages = 0; + param.languagesForced = SCE_FALSE; + param.type = SCE_IME_TYPE_DEFAULT; + param.option = 0; + param.textBoxMode = SCE_IME_DIALOG_TEXTBOX_MODE_WITH_CLEAR; + param.maxTextLength = SCE_IME_DIALOG_MAX_TEXT_LENGTH; + + param.title = title; + param.initialText = text; + param.inputTextBuffer = videodata->ime_buffer; + + res = sceImeDialogInit(¶m); + if (res < 0) { + SDL_SetError("Failed to init IME dialog"); + return; + } + +#endif + + videodata->ime_active = true; +} + +void VITA_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifndef SDL_VIDEO_VITA_PVR + SDL_VideoData *videodata = _this->internal; + + SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); + + switch (dialogStatus) { + default: + case SCE_COMMON_DIALOG_STATUS_NONE: + case SCE_COMMON_DIALOG_STATUS_RUNNING: + break; + case SCE_COMMON_DIALOG_STATUS_FINISHED: + sceImeDialogTerm(); + break; + } + + videodata->ime_active = false; +#endif +} + +bool VITA_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef SDL_VIDEO_VITA_PVR + SDL_VideoData *videodata = _this->internal; + return videodata->ime_active; +#else + SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); + return dialogStatus == SCE_COMMON_DIALOG_STATUS_RUNNING; +#endif +} + +void VITA_PumpEvents(SDL_VideoDevice *_this) +{ +#ifndef SDL_VIDEO_VITA_PVR + SDL_VideoData *videodata = _this->internal; +#endif + + if (_this->suspend_screensaver) { + // cancel all idle timers to prevent vita going to sleep + sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DEFAULT); + } + + VITA_PollTouch(); + VITA_PollKeyboard(); + VITA_PollMouse(); + +#ifndef SDL_VIDEO_VITA_PVR + if (videodata->ime_active == true) { + // update IME status. Terminate, if finished + SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); + if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { + uint8_t utf8_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; + + SceImeDialogResult result; + SDL_memset(&result, 0, sizeof(SceImeDialogResult)); + sceImeDialogGetResult(&result); + + // Convert UTF16 to UTF8 + utf16_to_utf8(videodata->ime_buffer, utf8_buffer); + + // Send SDL event + SDL_SendKeyboardText((const char *)utf8_buffer); + + // Send enter key only on enter + if (result.button == SCE_IME_DIALOG_BUTTON_ENTER) { + SDL_SendKeyboardKeyAutoRelease(0, SDL_SCANCODE_RETURN); + } + + sceImeDialogTerm(); + + videodata->ime_active = false; + } + } +#endif +} + +#endif // SDL_VIDEO_DRIVER_VITA diff --git a/contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.h b/contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.h new file mode 100644 index 0000000..268bed8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vita/SDL_vitavideo.h @@ -0,0 +1,106 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_vitavideo_h +#define SDL_vitavideo_h + +#include "SDL_internal.h" +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +#include +#include +#include +#include + +struct SDL_VideoData +{ + bool egl_initialized; // OpenGL device initialization status + uint32_t egl_refcount; // OpenGL reference count + + SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; + bool ime_active; +}; + +struct SDL_WindowData +{ + bool uses_gles; + SceUID buffer_uid; + void *buffer; +#ifdef SDL_VIDEO_VITA_PVR + EGLSurface egl_surface; + EGLContext egl_context; +#endif +}; + +extern SDL_Window *Vita_Window; + +/****************************************************************************/ +// SDL_VideoDevice functions declaration +/****************************************************************************/ + +// Display and window functions +extern bool VITA_VideoInit(SDL_VideoDevice *_this); +extern void VITA_VideoQuit(SDL_VideoDevice *_this); +extern bool VITA_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool VITA_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern bool VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void VITA_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VITA_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void VITA_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void VITA_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void VITA_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void VITA_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void VITA_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void VITA_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void VITA_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VITA_SetWindowGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern void VITA_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +#ifdef SDL_VIDEO_DRIVER_VITA +#ifdef SDL_VIDEO_VITA_PVR_OGL +// OpenGL functions +extern bool VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_GLContext VITA_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_FunctionPointer VITA_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +#endif + +// OpenGLES functions +extern bool VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_FunctionPointer VITA_GLES_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern void VITA_GLES_UnloadLibrary(SDL_VideoDevice *_this); +extern SDL_GLContext VITA_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VITA_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool VITA_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool VITA_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern bool VITA_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VITA_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +#endif + +// VITA on screen keyboard +extern bool VITA_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern void VITA_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern void VITA_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VITA_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); + +extern void VITA_PumpEvents(SDL_VideoDevice *_this); + +#endif // SDL_pspvideo_h diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c new file mode 100644 index 0000000..577711f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.c @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_VIVANTE) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "SDL_vivanteopengles.h" +#include "SDL_vivantevideo.h" + +// EGL implementation of SDL OpenGL support + +bool VIVANTE_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + SDL_DisplayData *displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay()); + + return SDL_EGL_LoadLibrary(_this, path, displaydata->native_display, 0); +} + +SDL_EGL_CreateContext_impl(VIVANTE) +SDL_EGL_SwapWindow_impl(VIVANTE) +SDL_EGL_MakeCurrent_impl(VIVANTE) + +#endif // SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h new file mode 100644 index 0000000..47cdc16 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteopengles.h @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_vivanteopengles_h_ +#define SDL_vivanteopengles_h_ + +#if defined(SDL_VIDEO_DRIVER_VIVANTE) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +// OpenGLES functions +#define VIVANTE_GLES_GetAttribute SDL_EGL_GetAttribute +#define VIVANTE_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define VIVANTE_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define VIVANTE_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define VIVANTE_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define VIVANTE_GLES_DestroyContext SDL_EGL_DestroyContext + +extern bool VIVANTE_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_GLContext VIVANTE_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VIVANTE_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool VIVANTE_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); + +#endif // SDL_VIDEO_DRIVER_VIVANTE && SDL_VIDEO_OPENGL_EGL + +#endif // SDL_vivanteopengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c new file mode 100644 index 0000000..5d1e6d9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.c @@ -0,0 +1,49 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VIVANTE + +#include "SDL_vivanteplatform.h" + +#ifdef VIVANTE_PLATFORM_GENERIC + +bool VIVANTE_SetupPlatform(SDL_VideoDevice *_this) +{ + return true; +} + +char *VIVANTE_GetDisplayName(SDL_VideoDevice *_this) +{ + return NULL; +} + +void VIVANTE_UpdateDisplayScale(SDL_VideoDevice *_this) +{ +} + +void VIVANTE_CleanupPlatform(SDL_VideoDevice *_this) +{ +} + +#endif // VIVANTE_PLATFORM_GENERIC + +#endif // SDL_VIDEO_DRIVER_VIVANTE diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h new file mode 100644 index 0000000..87babc0 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivanteplatform.h @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_vivanteplatform_h_ +#define SDL_vivanteplatform_h_ + +#ifdef SDL_VIDEO_DRIVER_VIVANTE + +#include "SDL_vivantevideo.h" + +#ifdef CAVIUM +#define VIVANTE_PLATFORM_CAVIUM +#elif defined(MARVELL) +#define VIVANTE_PLATFORM_MARVELL +#else +#define VIVANTE_PLATFORM_GENERIC +#endif + +extern bool VIVANTE_SetupPlatform(SDL_VideoDevice *_this); +extern char *VIVANTE_GetDisplayName(SDL_VideoDevice *_this); +extern void VIVANTE_UpdateDisplayScale(SDL_VideoDevice *_this); +extern void VIVANTE_CleanupPlatform(SDL_VideoDevice *_this); + +#endif // SDL_VIDEO_DRIVER_VIVANTE + +#endif // SDL_vivanteplatform_h_ diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c new file mode 100644 index 0000000..245c496 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.c @@ -0,0 +1,363 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_VIVANTE + +// SDL internals +#include "../SDL_sysvideo.h" +#include "../../events/SDL_events_c.h" + +#ifdef SDL_INPUT_LINUXEV +#include "../../core/linux/SDL_evdev.h" +#endif + +#include "SDL_vivantevideo.h" +#include "SDL_vivanteplatform.h" +#include "SDL_vivanteopengles.h" +#include "SDL_vivantevulkan.h" + +static void VIVANTE_Destroy(SDL_VideoDevice *device) +{ + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *VIVANTE_Create(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + + // Initialize SDL_VideoDevice structure + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + + // Initialize internal data + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!data) { + SDL_free(device); + return NULL; + } + + device->internal = data; + + // Setup amount of available displays + device->num_displays = 0; + + // Set device free function + device->free = VIVANTE_Destroy; + + // Setup all functions which we can handle + device->VideoInit = VIVANTE_VideoInit; + device->VideoQuit = VIVANTE_VideoQuit; + device->CreateSDLWindow = VIVANTE_CreateWindow; + device->SetWindowTitle = VIVANTE_SetWindowTitle; + device->SetWindowPosition = VIVANTE_SetWindowPosition; + device->SetWindowSize = VIVANTE_SetWindowSize; + device->ShowWindow = VIVANTE_ShowWindow; + device->HideWindow = VIVANTE_HideWindow; + device->DestroyWindow = VIVANTE_DestroyWindow; + +#ifdef SDL_VIDEO_OPENGL_EGL + device->GL_LoadLibrary = VIVANTE_GLES_LoadLibrary; + device->GL_GetProcAddress = VIVANTE_GLES_GetProcAddress; + device->GL_UnloadLibrary = VIVANTE_GLES_UnloadLibrary; + device->GL_CreateContext = VIVANTE_GLES_CreateContext; + device->GL_MakeCurrent = VIVANTE_GLES_MakeCurrent; + device->GL_SetSwapInterval = VIVANTE_GLES_SetSwapInterval; + device->GL_GetSwapInterval = VIVANTE_GLES_GetSwapInterval; + device->GL_SwapWindow = VIVANTE_GLES_SwapWindow; + device->GL_DestroyContext = VIVANTE_GLES_DestroyContext; +#endif + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = VIVANTE_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = VIVANTE_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = VIVANTE_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = VIVANTE_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = VIVANTE_Vulkan_DestroySurface; +#endif + + device->PumpEvents = VIVANTE_PumpEvents; + + return device; +} + +VideoBootStrap VIVANTE_bootstrap = { + "vivante", + "Vivante EGL Video Driver", + VIVANTE_Create, + NULL, // no ShowMessageBox implementation + false +}; + +/*****************************************************************************/ +// SDL Video and Display initialization/handling functions +/*****************************************************************************/ + +static bool VIVANTE_AddVideoDisplays(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + SDL_VideoDisplay display; + SDL_DisplayMode mode; + SDL_DisplayData *data; + int pitch = 0, bpp = 0; + unsigned long pixels = 0; + + data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); + if (!data) { + return false; + } + + SDL_zero(mode); +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + data->native_display = vdkGetDisplay(videodata->vdk_private); + + vdkGetDisplayInfo(data->native_display, &mode.w, &mode.h, &pixels, &pitch, + &bpp); +#else + data->native_display = videodata->fbGetDisplayByIndex(0); + + videodata->fbGetDisplayInfo(data->native_display, &mode.w, &mode.h, + &pixels, &pitch, &bpp); +#endif // SDL_VIDEO_DRIVER_VIVANTE_VDK + + switch (bpp) { + default: // Is another format used? + case 32: + mode.format = SDL_PIXELFORMAT_ARGB8888; + break; + case 16: + mode.format = SDL_PIXELFORMAT_RGB565; + break; + } + // FIXME: How do we query refresh rate? + mode.refresh_rate = 60.0f; + + SDL_zero(display); + display.name = VIVANTE_GetDisplayName(_this); + display.desktop_mode = mode; + display.internal = data; + if (SDL_AddVideoDisplay(&display, false) == 0) { + return false; + } + return true; +} + +bool VIVANTE_VideoInit(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + videodata->vdk_private = vdkInitialize(); + if (!videodata->vdk_private) { + return SDL_SetError("vdkInitialize() failed"); + } +#else + videodata->egl_handle = SDL_LoadObject("libEGL.so.1"); + if (!videodata->egl_handle) { + videodata->egl_handle = SDL_LoadObject("libEGL.so"); + if (!videodata->egl_handle) { + return false; + } + } +#define LOAD_FUNC(TYPE, NAME) \ + videodata->NAME = (TYPE)SDL_LoadFunction(videodata->egl_handle, #NAME); \ + if (!videodata->NAME) \ + return false; + + LOAD_FUNC(EGLNativeDisplayType (EGLAPIENTRY *)(void *), fbGetDisplay); + LOAD_FUNC(EGLNativeDisplayType (EGLAPIENTRY *)(int), fbGetDisplayByIndex); + LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeDisplayType, int *, int *), fbGetDisplayGeometry); + LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeDisplayType, int *, int *, unsigned long *, int *, int *), fbGetDisplayInfo); + LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeDisplayType), fbDestroyDisplay); + LOAD_FUNC(EGLNativeWindowType (EGLAPIENTRY *)(EGLNativeDisplayType, int, int, int, int), fbCreateWindow); + LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeWindowType, int *, int *, int *, int *), fbGetWindowGeometry); + LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeWindowType, int *, int *, int *, int *, int *, unsigned int *), fbGetWindowInfo); + LOAD_FUNC(void (EGLAPIENTRY *)(EGLNativeWindowType), fbDestroyWindow); +#endif + + if (!VIVANTE_SetupPlatform(_this)) { + return false; + } + + if (!VIVANTE_AddVideoDisplays(_this)) { + return false; + } + + VIVANTE_UpdateDisplayScale(_this); + +#ifdef SDL_INPUT_LINUXEV + if (!SDL_EVDEV_Init()) { + return false; + } +#endif + + return true; +} + +void VIVANTE_VideoQuit(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Quit(); +#endif + + VIVANTE_CleanupPlatform(_this); + +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + if (videodata->vdk_private) { + vdkExit(videodata->vdk_private); + videodata->vdk_private = NULL; + } +#else + if (videodata->egl_handle) { + SDL_UnloadObject(videodata->egl_handle); + videodata->egl_handle = NULL; + } +#endif +} + +bool VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_VideoData *videodata = _this->internal; + SDL_DisplayData *displaydata; + SDL_WindowData *data; + + displaydata = SDL_GetDisplayDriverData(SDL_GetPrimaryDisplay()); + + // Allocate window internal data + data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); + if (!data) { + return false; + } + + // Setup driver data for this window + window->internal = data; + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_VIVANTE_DISPLAY_POINTER, displaydata->native_display); + +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + data->native_window = vdkCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h); +#else + data->native_window = videodata->fbCreateWindow(displaydata->native_display, window->x, window->y, window->w, window->h); +#endif + if (!data->native_window) { + return SDL_SetError("VIVANTE: Can't create native window"); + } + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_VIVANTE_WINDOW_POINTER, data->native_window); + +#ifdef SDL_VIDEO_OPENGL_EGL + if (window->flags & SDL_WINDOW_OPENGL) { + data->egl_surface = SDL_EGL_CreateSurface(_this, window, data->native_window); + if (data->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("VIVANTE: Can't create EGL surface"); + } + } else { + data->egl_surface = EGL_NO_SURFACE; + } + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_VIVANTE_SURFACE_POINTER, data->egl_surface); +#endif + + // Window has been successfully created + return true; +} + +void VIVANTE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = _this->internal; + SDL_WindowData *data; + + data = window->internal; + if (data) { +#ifdef SDL_VIDEO_OPENGL_EGL + if (data->egl_surface != EGL_NO_SURFACE) { + SDL_EGL_DestroySurface(_this, data->egl_surface); + } +#endif + + if (data->native_window) { +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + vdkDestroyWindow(data->native_window); +#else + videodata->fbDestroyWindow(data->native_window); +#endif + } + + SDL_free(data); + } + window->internal = NULL; +} + +void VIVANTE_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + SDL_WindowData *data = window->internal; + vdkSetWindowTitle(data->native_window, window->title); +#endif +} + +bool VIVANTE_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + // FIXME + return SDL_Unsupported(); +} + +void VIVANTE_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + // FIXME +} + +void VIVANTE_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + SDL_WindowData *data = window->internal; + vdkShowWindow(data->native_window); +#endif + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); +} + +void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + SDL_WindowData *data = window->internal; + vdkHideWindow(data->native_window); +#endif + SDL_SetMouseFocus(NULL); + SDL_SetKeyboardFocus(NULL); +} + +/*****************************************************************************/ +// SDL event functions +/*****************************************************************************/ +void VIVANTE_PumpEvents(SDL_VideoDevice *_this) +{ +#ifdef SDL_INPUT_LINUXEV + SDL_EVDEV_Poll(); +#endif +} + +#endif // SDL_VIDEO_DRIVER_VIVANTE diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h new file mode 100644 index 0000000..44399d9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevideo.h @@ -0,0 +1,86 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_vivantevideo_h_ +#define SDL_vivantevideo_h_ + +#include "../SDL_sysvideo.h" + +// Set up definitions for Vivante EGL +#include + +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK +#include +#else +#include +#endif + +struct SDL_VideoData +{ +#ifdef SDL_VIDEO_DRIVER_VIVANTE_VDK + vdkPrivate vdk_private; +#else + SDL_SharedObject *egl_handle; // EGL shared library handle + EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplay)(void *context); + EGLNativeDisplayType(EGLAPIENTRY *fbGetDisplayByIndex)(int DisplayIndex); + void(EGLAPIENTRY *fbGetDisplayGeometry)(EGLNativeDisplayType Display, int *Width, int *Height); + void(EGLAPIENTRY *fbGetDisplayInfo)(EGLNativeDisplayType Display, int *Width, int *Height, unsigned long *Physical, int *Stride, int *bits_per_pixel); + void(EGLAPIENTRY *fbDestroyDisplay)(EGLNativeDisplayType Display); + EGLNativeWindowType(EGLAPIENTRY *fbCreateWindow)(EGLNativeDisplayType Display, int X, int Y, int Width, int Height); + void(EGLAPIENTRY *fbGetWindowGeometry)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height); + void(EGLAPIENTRY *fbGetWindowInfo)(EGLNativeWindowType Window, int *X, int *Y, int *Width, int *Height, int *bits_per_pixel, unsigned int *Offset); + void(EGLAPIENTRY *fbDestroyWindow)(EGLNativeWindowType Window); +#endif +}; + +struct SDL_DisplayData +{ + EGLNativeDisplayType native_display; +}; + +struct SDL_WindowData +{ + EGLNativeWindowType native_window; + EGLSurface egl_surface; +}; + +/****************************************************************************/ +// SDL_VideoDevice functions declaration +/****************************************************************************/ + +// Display and window functions +bool VIVANTE_VideoInit(SDL_VideoDevice *_this); +void VIVANTE_VideoQuit(SDL_VideoDevice *_this); +bool VIVANTE_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +bool VIVANTE_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +bool VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +void VIVANTE_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +bool VIVANTE_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +void VIVANTE_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +void VIVANTE_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +void VIVANTE_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +void VIVANTE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); + +// Event functions +void VIVANTE_PumpEvents(SDL_VideoDevice *_this); + +#endif // SDL_vivantevideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c new file mode 100644 index 0000000..a021a99 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.c @@ -0,0 +1,154 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +/* + * @author Wladimir J. van der Laan. Based on Jacob Lifshay's + * SDL_x11vulkan.c, Mark Callow's SDL_androidvulkan.c, and + * the FSL demo framework. + */ + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_VIVANTE) + +#include "../SDL_vulkan_internal.h" + +#include "SDL_vivantevideo.h" + +#include "SDL_vivantevulkan.h" + +bool VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 i, extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasDisplayExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan already loaded"); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + if (!path) { + // If no path set, try Vivante fb vulkan driver explicitly + path = "libvulkan-fb.so"; + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + if (!_this->vulkan_config.loader_handle) { + // If that couldn't be loaded, fall back to default name + path = "libvulkan.so"; + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + } + } else { + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + } + if (!_this->vulkan_config.loader_handle) { + return false; + } + SDL_strlcpy(_this->vulkan_config.loader_path, path, + SDL_arraysize(_this->vulkan_config.loader_path)); + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vivante: Loaded vulkan driver %s", path); + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + if (!vkGetInstanceProcAddr) { + goto fail; + } + _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + if (!extensions) { + goto fail; + } + for (i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_KHR_DISPLAY_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasDisplayExtension = true; + } + } + SDL_free(extensions); + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else if (!hasDisplayExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_DISPLAY_EXTENSION_NAME "extension"); + goto fail; + } + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void VIVANTE_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + } +} + +char const* const* VIVANTE_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ + static const char *const extensionsForVivante[] = { + VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_DISPLAY_EXTENSION_NAME + }; + if (count) { + *count = SDL_arraysize(extensionsForVivante); + } + return extensionsForVivante; +} + +bool VIVANTE_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + return SDL_Vulkan_Display_CreateSurface(_this->vulkan_config.vkGetInstanceProcAddr, instance, allocator, surface); +} + +void VIVANTE_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h new file mode 100644 index 0000000..49f14d3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/vivante/SDL_vivantevulkan.h @@ -0,0 +1,51 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +/* + * @author Wladimir J. van der Laan. Based on Jacob Lifshay's + * SDL_x11vulkan.h and Mark Callow's SDL_vivantevulkan.h + */ + +#ifndef SDL_vivantevulkan_h_ +#define SDL_vivantevulkan_h_ + +#include "../SDL_vulkan_internal.h" +#include "../SDL_sysvideo.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_VIVANTE) + +extern bool VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void VIVANTE_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* VIVANTE_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool VIVANTE_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void VIVANTE_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); + +#endif + +#endif // SDL_vivantevulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.c new file mode 100644 index 0000000..6218733 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.c @@ -0,0 +1,174 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include "SDL_waylanddatamanager.h" +#include "SDL_waylandevents_c.h" +#include "SDL_waylandclipboard.h" +#include "../SDL_clipboard_c.h" +#include "../../events/SDL_events_c.h" + + +bool Wayland_SetClipboardData(SDL_VideoDevice *_this) +{ + SDL_VideoData *video_data = _this->internal; + SDL_WaylandDataDevice *data_device = NULL; + bool result = true; + + if (video_data->input && video_data->input->data_device) { + data_device = video_data->input->data_device; + + if (_this->clipboard_callback && _this->clipboard_mime_types) { + SDL_WaylandDataSource *source = Wayland_data_source_create(_this); + Wayland_data_source_set_callback(source, _this->clipboard_callback, _this->clipboard_userdata, _this->clipboard_sequence); + + result = Wayland_data_device_set_selection(data_device, source, (const char **)_this->clipboard_mime_types, _this->num_clipboard_mime_types); + if (!result) { + Wayland_data_source_destroy(source); + } + } else { + result = Wayland_data_device_clear_selection(data_device); + } + } + + return result; +} + +void *Wayland_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length) +{ + SDL_VideoData *video_data = _this->internal; + SDL_WaylandDataDevice *data_device = NULL; + void *buffer = NULL; + + if (video_data->input && video_data->input->data_device) { + data_device = video_data->input->data_device; + if (data_device->selection_source) { + buffer = SDL_GetInternalClipboardData(_this, mime_type, length); + } else if (Wayland_data_offer_has_mime(data_device->selection_offer, mime_type)) { + buffer = Wayland_data_offer_receive(data_device->selection_offer, mime_type, length); + } + } + + return buffer; +} + +bool Wayland_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +{ + SDL_VideoData *video_data = _this->internal; + SDL_WaylandDataDevice *data_device = NULL; + bool result = false; + + if (video_data->input && video_data->input->data_device) { + data_device = video_data->input->data_device; + if (data_device->selection_source) { + result = SDL_HasInternalClipboardData(_this, mime_type); + } else { + result = Wayland_data_offer_has_mime(data_device->selection_offer, mime_type); + } + } + return result; +} + +static const char *text_mime_types[] = { + TEXT_MIME, + "text/plain", + "TEXT", + "UTF8_STRING", + "STRING" +}; + +const char **Wayland_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types) +{ + *num_mime_types = SDL_arraysize(text_mime_types); + return text_mime_types; +} + +bool Wayland_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *text) +{ + SDL_VideoData *video_data = _this->internal; + SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; + bool result; + + if (video_data->input && video_data->input->primary_selection_device) { + primary_selection_device = video_data->input->primary_selection_device; + if (text[0] != '\0') { + SDL_WaylandPrimarySelectionSource *source = Wayland_primary_selection_source_create(_this); + Wayland_primary_selection_source_set_callback(source, SDL_ClipboardTextCallback, SDL_strdup(text)); + + result = Wayland_primary_selection_device_set_selection(primary_selection_device, + source, + text_mime_types, + SDL_arraysize(text_mime_types)); + if (!result) { + Wayland_primary_selection_source_destroy(source); + } + } else { + result = Wayland_primary_selection_device_clear_selection(primary_selection_device); + } + } else { + result = SDL_SetError("Primary selection not supported"); + } + return result; +} + +char *Wayland_GetPrimarySelectionText(SDL_VideoDevice *_this) +{ + SDL_VideoData *video_data = _this->internal; + SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; + char *text = NULL; + size_t length = 0; + + if (video_data->input && video_data->input->primary_selection_device) { + primary_selection_device = video_data->input->primary_selection_device; + if (primary_selection_device->selection_source) { + text = Wayland_primary_selection_source_get_data(primary_selection_device->selection_source, TEXT_MIME, &length); + } else if (Wayland_primary_selection_offer_has_mime(primary_selection_device->selection_offer, TEXT_MIME)) { + text = Wayland_primary_selection_offer_receive(primary_selection_device->selection_offer, TEXT_MIME, &length); + } + } + + if (!text) { + text = SDL_strdup(""); + } + + return text; +} + +bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this) +{ + SDL_VideoData *video_data = _this->internal; + SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; + bool result = false; + + if (video_data->input && video_data->input->primary_selection_device) { + primary_selection_device = video_data->input->primary_selection_device; + if (primary_selection_device->selection_source) { + result = true; + } else { + result = Wayland_primary_selection_offer_has_mime(primary_selection_device->selection_offer, TEXT_MIME); + } + } + return result; +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.h new file mode 100644 index 0000000..ed6546f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandclipboard.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_waylandclipboard_h_ +#define SDL_waylandclipboard_h_ + +extern const char **Wayland_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types); +extern bool Wayland_SetClipboardData(SDL_VideoDevice *_this); +extern void *Wayland_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length); +extern bool Wayland_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern bool Wayland_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *text); +extern char *Wayland_GetPrimarySelectionText(SDL_VideoDevice *_this); +extern bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this); + +#endif // SDL_waylandclipboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.c new file mode 100644 index 0000000..dfc69bb --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.c @@ -0,0 +1,303 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include "SDL_waylandcolor.h" +#include "SDL_waylandvideo.h" +#include "SDL_waylandwindow.h" +#include "color-management-v1-client-protocol.h" +#include "../../events/SDL_windowevents_c.h" + +typedef struct Wayland_ColorInfoState +{ + struct wp_image_description_v1 *wp_image_description; + struct wp_image_description_info_v1 *wp_image_description_info; + + union + { + SDL_WindowData *window_data; + SDL_DisplayData *display_data; + }; + + enum + { + WAYLAND_COLOR_OBJECT_TYPE_WINDOW, + WAYLAND_COLOR_OBJECT_TYPE_DISPLAY + } object_type; + + SDL_HDROutputProperties HDR; + + // The ICC fd is only valid if the size is non-zero. + int icc_fd; + Uint32 icc_size; + + bool deferred_event_processing; +} Wayland_ColorInfoState; + +static void Wayland_CancelColorInfoRequest(Wayland_ColorInfoState *state) +{ + if (state) { + if (state->wp_image_description_info) { + wp_image_description_info_v1_destroy(state->wp_image_description_info); + state->wp_image_description_info = NULL; + } + if (state->wp_image_description) { + wp_image_description_v1_destroy(state->wp_image_description); + state->wp_image_description = NULL; + } + } +} + +void Wayland_FreeColorInfoState(Wayland_ColorInfoState *state) +{ + if (state) { + Wayland_CancelColorInfoRequest(state); + + switch (state->object_type) { + case WAYLAND_COLOR_OBJECT_TYPE_WINDOW: + state->window_data->color_info_state = NULL; + break; + case WAYLAND_COLOR_OBJECT_TYPE_DISPLAY: + state->display_data->color_info_state = NULL; + break; + } + + SDL_free(state); + } +} + +static void image_description_info_handle_done(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1) +{ + Wayland_ColorInfoState *state = (Wayland_ColorInfoState *)data; + Wayland_CancelColorInfoRequest(state); + + switch (state->object_type) { + case WAYLAND_COLOR_OBJECT_TYPE_WINDOW: + { + SDL_SetWindowHDRProperties(state->window_data->sdlwindow, &state->HDR, true); + if (state->icc_size) { + state->window_data->icc_fd = state->icc_fd; + state->window_data->icc_size = state->icc_size; + SDL_SendWindowEvent(state->window_data->sdlwindow, SDL_EVENT_WINDOW_ICCPROF_CHANGED, 0, 0); + } + } break; + case WAYLAND_COLOR_OBJECT_TYPE_DISPLAY: + { + SDL_copyp(&state->display_data->HDR, &state->HDR); + } break; + } +} + +static void image_description_info_handle_icc_file(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + int32_t icc, uint32_t icc_size) +{ + Wayland_ColorInfoState *state = (Wayland_ColorInfoState *)data; + + state->icc_fd = icc; + state->icc_size = icc_size; +} + +static void image_description_info_handle_primaries(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + int32_t r_x, int32_t r_y, + int32_t g_x, int32_t g_y, + int32_t b_x, int32_t b_y, + int32_t w_x, int32_t w_y) +{ + // NOP +} + +static void image_description_info_handle_primaries_named(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t primaries) +{ + // NOP +} + +static void image_description_info_handle_tf_power(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t eexp) +{ + // NOP +} + +static void image_description_info_handle_tf_named(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t tf) +{ + // NOP +} + +static void image_description_info_handle_luminances(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t min_lum, + uint32_t max_lum, + uint32_t reference_lum) +{ + Wayland_ColorInfoState *state = (Wayland_ColorInfoState *)data; + state->HDR.HDR_headroom = (float)max_lum / (float)reference_lum; +} + +static void image_description_info_handle_target_primaries(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + int32_t r_x, int32_t r_y, + int32_t g_x, int32_t g_y, + int32_t b_x, int32_t b_y, + int32_t w_x, int32_t w_y) +{ + // NOP +} + +static void image_description_info_handle_target_luminance(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t min_lum, + uint32_t max_lum) +{ + // NOP +} + +static void image_description_info_handle_target_max_cll(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t max_cll) +{ + // NOP +} + +static void image_description_info_handle_target_max_fall(void *data, + struct wp_image_description_info_v1 *wp_image_description_info_v1, + uint32_t max_fall) +{ + // NOP +} + +static const struct wp_image_description_info_v1_listener image_description_info_listener = { + image_description_info_handle_done, + image_description_info_handle_icc_file, + image_description_info_handle_primaries, + image_description_info_handle_primaries_named, + image_description_info_handle_tf_power, + image_description_info_handle_tf_named, + image_description_info_handle_luminances, + image_description_info_handle_target_primaries, + image_description_info_handle_target_luminance, + image_description_info_handle_target_max_cll, + image_description_info_handle_target_max_fall +}; + +static void PumpColorspaceEvents(Wayland_ColorInfoState *state) +{ + SDL_VideoData *vid = SDL_GetVideoDevice()->internal; + + // Run the image description sequence to completion in its own queue. + struct wl_event_queue *queue = WAYLAND_wl_display_create_queue(vid->display); + if (state->deferred_event_processing) { + WAYLAND_wl_proxy_set_queue((struct wl_proxy *)state->wp_image_description_info, queue); + } else { + WAYLAND_wl_proxy_set_queue((struct wl_proxy *)state->wp_image_description, queue); + } + + while (state->wp_image_description) { + WAYLAND_wl_display_dispatch_queue(vid->display, queue); + } + + WAYLAND_wl_event_queue_destroy(queue); + Wayland_FreeColorInfoState(state); +} + +static void image_description_handle_failed(void *data, + struct wp_image_description_v1 *wp_image_description_v1, + uint32_t cause, + const char *msg) +{ + Wayland_ColorInfoState *state = (Wayland_ColorInfoState *)data; + Wayland_CancelColorInfoRequest(state); + + if (state->deferred_event_processing) { + Wayland_FreeColorInfoState(state); + } +} + +static void image_description_handle_ready(void *data, + struct wp_image_description_v1 *wp_image_description_v1, + uint32_t identity) +{ + Wayland_ColorInfoState *state = (Wayland_ColorInfoState *)data; + + // This will inherit the queue of the factory image description object. + state->wp_image_description_info = wp_image_description_v1_get_information(state->wp_image_description); + wp_image_description_info_v1_add_listener(state->wp_image_description_info, &image_description_info_listener, data); + + if (state->deferred_event_processing) { + PumpColorspaceEvents(state); + } +} + +static const struct wp_image_description_v1_listener image_description_listener = { + image_description_handle_failed, + image_description_handle_ready +}; + +void Wayland_GetColorInfoForWindow(SDL_WindowData *window_data, bool defer_event_processing) +{ + // Cancel any pending request, as it is out-of-date. + Wayland_FreeColorInfoState(window_data->color_info_state); + Wayland_ColorInfoState *state = SDL_calloc(1, sizeof(Wayland_ColorInfoState)); + + if (state) { + window_data->color_info_state = state; + state->window_data = window_data; + state->object_type = WAYLAND_COLOR_OBJECT_TYPE_WINDOW; + state->deferred_event_processing = defer_event_processing; + state->wp_image_description = wp_color_management_surface_feedback_v1_get_preferred(window_data->wp_color_management_surface_feedback); + wp_image_description_v1_add_listener(state->wp_image_description, &image_description_listener, state); + + if (!defer_event_processing) { + PumpColorspaceEvents(state); + } + } +} + +void Wayland_GetColorInfoForOutput(SDL_DisplayData *display_data, bool defer_event_processing) +{ + // Cancel any pending request, as it is out-of-date. + Wayland_FreeColorInfoState(display_data->color_info_state); + Wayland_ColorInfoState *state = SDL_calloc(1, sizeof(Wayland_ColorInfoState)); + + if (state) { + display_data->color_info_state = state; + state->display_data = display_data; + state->object_type = WAYLAND_COLOR_OBJECT_TYPE_DISPLAY; + state->deferred_event_processing = defer_event_processing; + state->wp_image_description = wp_color_management_output_v1_get_image_description(display_data->wp_color_management_output); + wp_image_description_v1_add_listener(state->wp_image_description, &image_description_listener, state); + + if (!defer_event_processing) { + PumpColorspaceEvents(state); + } + } +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.h new file mode 100644 index 0000000..bef5d8c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandcolor.h @@ -0,0 +1,35 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_waylandcolor_h_ +#define SDL_waylandcolor_h_ + +#include "../SDL_sysvideo.h" + +struct Wayland_ColorInfoState; + +extern void Wayland_FreeColorInfoState(struct Wayland_ColorInfoState *state); +extern void Wayland_GetColorInfoForWindow(SDL_WindowData *window_data, bool defer_event_processing); +extern void Wayland_GetColorInfoForOutput(SDL_DisplayData *display_data, bool defer_event_processing); + +#endif // SDL_waylandcolor_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.c new file mode 100644 index 0000000..6f5b32b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.c @@ -0,0 +1,619 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include +#include +#include +#include + +#include "../../core/unix/SDL_poll.h" +#include "../../events/SDL_events_c.h" +#include "../SDL_clipboard_c.h" + +#include "SDL_waylandvideo.h" +#include "SDL_waylanddatamanager.h" +#include "primary-selection-unstable-v1-client-protocol.h" + +/* FIXME: This is arbitrary, but we want this to be less than a frame because + * any longer can potentially spin an infinite loop of PumpEvents (!) + */ +#define PIPE_TIMEOUT_NS SDL_MS_TO_NS(14) + +static ssize_t write_pipe(int fd, const void *buffer, size_t total_length, size_t *pos) +{ + int ready = 0; + ssize_t bytes_written = 0; + ssize_t length = total_length - *pos; + + sigset_t sig_set; + sigset_t old_sig_set; + struct timespec zerotime = { 0 }; + + ready = SDL_IOReady(fd, SDL_IOR_WRITE, PIPE_TIMEOUT_NS); + + sigemptyset(&sig_set); + sigaddset(&sig_set, SIGPIPE); + +#ifdef SDL_THREADS_DISABLED + sigprocmask(SIG_BLOCK, &sig_set, &old_sig_set); +#else + pthread_sigmask(SIG_BLOCK, &sig_set, &old_sig_set); +#endif + + if (ready == 0) { + bytes_written = SDL_SetError("Pipe timeout"); + } else if (ready < 0) { + bytes_written = SDL_SetError("Pipe select error"); + } else { + if (length > 0) { + bytes_written = write(fd, (Uint8 *)buffer + *pos, SDL_min(length, PIPE_BUF)); + } + + if (bytes_written > 0) { + *pos += bytes_written; + } + } + + sigtimedwait(&sig_set, 0, &zerotime); + +#ifdef SDL_THREADS_DISABLED + sigprocmask(SIG_SETMASK, &old_sig_set, NULL); +#else + pthread_sigmask(SIG_SETMASK, &old_sig_set, NULL); +#endif + + return bytes_written; +} + +static ssize_t read_pipe(int fd, void **buffer, size_t *total_length) +{ + int ready = 0; + void *output_buffer = NULL; + char temp[PIPE_BUF]; + size_t new_buffer_length = 0; + ssize_t bytes_read = 0; + size_t pos = 0; + + ready = SDL_IOReady(fd, SDL_IOR_READ, PIPE_TIMEOUT_NS); + + if (ready == 0) { + bytes_read = SDL_SetError("Pipe timeout"); + } else if (ready < 0) { + bytes_read = SDL_SetError("Pipe select error"); + } else { + bytes_read = read(fd, temp, sizeof(temp)); + } + + if (bytes_read > 0) { + pos = *total_length; + *total_length += bytes_read; + + new_buffer_length = *total_length + sizeof(Uint32); + + if (!*buffer) { + output_buffer = SDL_malloc(new_buffer_length); + } else { + output_buffer = SDL_realloc(*buffer, new_buffer_length); + } + + if (!output_buffer) { + bytes_read = -1; + } else { + SDL_memcpy((Uint8 *)output_buffer + pos, temp, bytes_read); + SDL_memset((Uint8 *)output_buffer + (new_buffer_length - sizeof(Uint32)), 0, sizeof(Uint32)); + + *buffer = output_buffer; + } + } + + return bytes_read; +} + +static SDL_MimeDataList *mime_data_list_find(struct wl_list *list, + const char *mime_type) +{ + SDL_MimeDataList *found = NULL; + + SDL_MimeDataList *mime_list = NULL; + wl_list_for_each (mime_list, list, link) { + if (SDL_strcmp(mime_list->mime_type, mime_type) == 0) { + found = mime_list; + break; + } + } + return found; +} + +static bool mime_data_list_add(struct wl_list *list, + const char *mime_type, + const void *buffer, size_t length) +{ + bool result = true; + size_t mime_type_length = 0; + SDL_MimeDataList *mime_data = NULL; + void *internal_buffer = NULL; + + if (buffer) { + internal_buffer = SDL_malloc(length); + if (!internal_buffer) { + return false; + } + SDL_memcpy(internal_buffer, buffer, length); + } + + mime_data = mime_data_list_find(list, mime_type); + + if (!mime_data) { + mime_data = SDL_calloc(1, sizeof(*mime_data)); + if (!mime_data) { + result = false; + } else { + WAYLAND_wl_list_insert(list, &(mime_data->link)); + + mime_type_length = SDL_strlen(mime_type) + 1; + mime_data->mime_type = SDL_malloc(mime_type_length); + if (!mime_data->mime_type) { + result = false; + } else { + SDL_memcpy(mime_data->mime_type, mime_type, mime_type_length); + } + } + } + + if (mime_data && buffer && length > 0) { + if (mime_data->data) { + SDL_free(mime_data->data); + } + mime_data->data = internal_buffer; + mime_data->length = length; + } else { + SDL_free(internal_buffer); + } + + return result; +} + +static void mime_data_list_free(struct wl_list *list) +{ + SDL_MimeDataList *mime_data = NULL; + SDL_MimeDataList *next = NULL; + + wl_list_for_each_safe (mime_data, next, list, link) { + if (mime_data->data) { + SDL_free(mime_data->data); + } + if (mime_data->mime_type) { + SDL_free(mime_data->mime_type); + } + SDL_free(mime_data); + } +} + +static size_t Wayland_send_data(const void *data, size_t length, int fd) +{ + size_t result = 0; + + if (length > 0 && data) { + while (write_pipe(fd, data, length, &result) > 0) { + // Just keep spinning + } + } + close(fd); + + return result; +} + +ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, const char *mime_type, int fd) +{ + const void *data = NULL; + size_t length = 0; + + if (source->callback) { + data = source->callback(source->userdata.data, mime_type, &length); + } + + return Wayland_send_data(data, length, fd); +} + +ssize_t Wayland_primary_selection_source_send(SDL_WaylandPrimarySelectionSource *source, const char *mime_type, int fd) +{ + const void *data = NULL; + size_t length = 0; + + if (source->callback) { + data = source->callback(source->userdata.data, mime_type, &length); + } + + return Wayland_send_data(data, length, fd); +} + +void Wayland_data_source_set_callback(SDL_WaylandDataSource *source, + SDL_ClipboardDataCallback callback, + void *userdata, + Uint32 sequence) +{ + if (source) { + source->callback = callback; + source->userdata.sequence = sequence; + source->userdata.data = userdata; + } +} + +void Wayland_primary_selection_source_set_callback(SDL_WaylandPrimarySelectionSource *source, + SDL_ClipboardDataCallback callback, + void *userdata) +{ + if (source) { + source->callback = callback; + source->userdata.sequence = 0; + source->userdata.data = userdata; + } +} + +static void *Wayland_clone_data_buffer(const void *buffer, const size_t *len) +{ + void *clone = NULL; + if (*len > 0 && buffer) { + clone = SDL_malloc((*len)+sizeof(Uint32)); + if (clone) { + SDL_memcpy(clone, buffer, *len); + SDL_memset((Uint8 *)clone + *len, 0, sizeof(Uint32)); + } + } + return clone; +} + +void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, + const char *mime_type, size_t *length) +{ + void *buffer = NULL; + const void *internal_buffer; + *length = 0; + + if (!source) { + SDL_SetError("Invalid data source"); + } else if (source->callback) { + internal_buffer = source->callback(source->userdata.data, mime_type, length); + buffer = Wayland_clone_data_buffer(internal_buffer, length); + } + + return buffer; +} + +void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source, + const char *mime_type, size_t *length) +{ + void *buffer = NULL; + const void *internal_buffer; + *length = 0; + + if (!source) { + SDL_SetError("Invalid primary selection source"); + } else if (source->callback) { + internal_buffer = source->callback(source->userdata.data, mime_type, length); + buffer = Wayland_clone_data_buffer(internal_buffer, length); + } + + return buffer; +} + +void Wayland_data_source_destroy(SDL_WaylandDataSource *source) +{ + if (source) { + SDL_WaylandDataDevice *data_device = (SDL_WaylandDataDevice *)source->data_device; + if (data_device && (data_device->selection_source == source)) { + data_device->selection_source = NULL; + } + wl_data_source_destroy(source->source); + if (source->userdata.sequence) { + SDL_CancelClipboardData(source->userdata.sequence); + } else { + SDL_free(source->userdata.data); + } + SDL_free(source); + } +} + +void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source) +{ + if (source) { + SDL_WaylandPrimarySelectionDevice *primary_selection_device = (SDL_WaylandPrimarySelectionDevice *)source->primary_selection_device; + if (primary_selection_device && (primary_selection_device->selection_source == source)) { + primary_selection_device->selection_source = NULL; + } + zwp_primary_selection_source_v1_destroy(source->source); + if (source->userdata.sequence == 0) { + SDL_free(source->userdata.data); + } + SDL_free(source); + } +} + +void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, + const char *mime_type, size_t *length) +{ + SDL_WaylandDataDevice *data_device = NULL; + + int pipefd[2]; + void *buffer = NULL; + *length = 0; + + if (!offer) { + SDL_SetError("Invalid data offer"); + return NULL; + } + data_device = offer->data_device; + if (!data_device) { + SDL_SetError("Data device not initialized"); + } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { + SDL_SetError("Could not read pipe"); + } else { + wl_data_offer_receive(offer->offer, mime_type, pipefd[1]); + + // TODO: Needs pump and flush? + WAYLAND_wl_display_flush(data_device->video_data->display); + + close(pipefd[1]); + + while (read_pipe(pipefd[0], &buffer, length) > 0) { + } + close(pipefd[0]); + } + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Wayland_data_offer_receive for '%s', buffer (%zu) at %p", + mime_type, *length, buffer); + return buffer; +} + +void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, + const char *mime_type, size_t *length) +{ + SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; + + int pipefd[2]; + void *buffer = NULL; + *length = 0; + + if (!offer) { + SDL_SetError("Invalid data offer"); + return NULL; + } + primary_selection_device = offer->primary_selection_device; + if (!primary_selection_device) { + SDL_SetError("Primary selection device not initialized"); + } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { + SDL_SetError("Could not read pipe"); + } else { + zwp_primary_selection_offer_v1_receive(offer->offer, mime_type, pipefd[1]); + + // TODO: Needs pump and flush? + WAYLAND_wl_display_flush(primary_selection_device->video_data->display); + + close(pipefd[1]); + + while (read_pipe(pipefd[0], &buffer, length) > 0) { + } + close(pipefd[0]); + } + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Wayland_primary_selection_offer_receive for '%s', buffer (%zu) at %p", + mime_type, *length, buffer); + return buffer; +} + +bool Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, + const char *mime_type) +{ + return mime_data_list_add(&offer->mimes, mime_type, NULL, 0); +} + +bool Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *offer, + const char *mime_type) +{ + return mime_data_list_add(&offer->mimes, mime_type, NULL, 0); +} + +bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, + const char *mime_type) +{ + bool found = false; + + if (offer) { + found = mime_data_list_find(&offer->mimes, mime_type) != NULL; + } + return found; +} + +bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer, + const char *mime_type) +{ + bool found = false; + + if (offer) { + found = mime_data_list_find(&offer->mimes, mime_type) != NULL; + } + return found; +} + +void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) +{ + if (offer) { + wl_data_offer_destroy(offer->offer); + mime_data_list_free(&offer->mimes); + SDL_free(offer); + } +} + +void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer) +{ + if (offer) { + zwp_primary_selection_offer_v1_destroy(offer->offer); + mime_data_list_free(&offer->mimes); + SDL_free(offer); + } +} + +bool Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device) +{ + bool result = true; + + if (!data_device || !data_device->data_device) { + result = SDL_SetError("Invalid Data Device"); + } else if (data_device->selection_source) { + wl_data_device_set_selection(data_device->data_device, NULL, 0); + Wayland_data_source_destroy(data_device->selection_source); + data_device->selection_source = NULL; + } + return result; +} + +bool Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device) +{ + bool result = true; + + if (!primary_selection_device || !primary_selection_device->primary_selection_device) { + result = SDL_SetError("Invalid Primary Selection Device"); + } else if (primary_selection_device->selection_source) { + zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, + NULL, 0); + Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); + primary_selection_device->selection_source = NULL; + } + return result; +} + +bool Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, + SDL_WaylandDataSource *source, + const char **mime_types, + size_t mime_count) +{ + bool result = true; + + if (!data_device) { + result = SDL_SetError("Invalid Data Device"); + } else if (!source) { + result = SDL_SetError("Invalid source"); + } else { + size_t index = 0; + const char *mime_type; + + for (index = 0; index < mime_count; ++index) { + mime_type = mime_types[index]; + wl_data_source_offer(source->source, + mime_type); + } + + if (index == 0) { + Wayland_data_device_clear_selection(data_device); + result = SDL_SetError("No mime data"); + } else { + // Only set if there is a valid serial if not set it later + if (data_device->selection_serial != 0) { + wl_data_device_set_selection(data_device->data_device, + source->source, + data_device->selection_serial); + } + if (data_device->selection_source) { + Wayland_data_source_destroy(data_device->selection_source); + } + data_device->selection_source = source; + source->data_device = data_device; + } + } + + return result; +} + +bool Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *primary_selection_device, + SDL_WaylandPrimarySelectionSource *source, + const char **mime_types, + size_t mime_count) +{ + bool result = true; + + if (!primary_selection_device) { + result = SDL_SetError("Invalid Primary Selection Device"); + } else if (!source) { + result = SDL_SetError("Invalid source"); + } else { + size_t index = 0; + const char *mime_type = mime_types[index]; + + for (index = 0; index < mime_count; ++index) { + mime_type = mime_types[index]; + zwp_primary_selection_source_v1_offer(source->source, mime_type); + } + + if (index == 0) { + Wayland_primary_selection_device_clear_selection(primary_selection_device); + result = SDL_SetError("No mime data"); + } else { + // Only set if there is a valid serial if not set it later + if (primary_selection_device->selection_serial != 0) { + zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, + source->source, + primary_selection_device->selection_serial); + } + if (primary_selection_device->selection_source) { + Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); + } + primary_selection_device->selection_source = source; + source->primary_selection_device = primary_selection_device; + } + } + + return result; +} + +void Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, uint32_t serial) +{ + if (data_device) { + // If there was no serial and there is a pending selection set it now. + if (data_device->selection_serial == 0 && data_device->selection_source) { + wl_data_device_set_selection(data_device->data_device, + data_device->selection_source->source, + data_device->selection_serial); + } + + data_device->selection_serial = serial; + } +} + +void Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *primary_selection_device, + uint32_t serial) +{ + if (primary_selection_device) { + // If there was no serial and there is a pending selection set it now. + if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source) { + zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, + primary_selection_device->selection_source->source, + primary_selection_device->selection_serial); + } + + primary_selection_device->selection_serial = serial; + } +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h new file mode 100644 index 0000000..adca17b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddatamanager.h @@ -0,0 +1,162 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_waylanddatamanager_h_ +#define SDL_waylanddatamanager_h_ + +#include "SDL_waylandvideo.h" +#include "SDL_waylandwindow.h" + +#define TEXT_MIME "text/plain;charset=utf-8" +#define FILE_MIME "text/uri-list" +#define FILE_PORTAL_MIME "application/vnd.portal.filetransfer" + +typedef struct +{ + char *mime_type; + void *data; + size_t length; + struct wl_list link; +} SDL_MimeDataList; + +typedef struct SDL_WaylandUserdata +{ + Uint32 sequence; + void *data; +} SDL_WaylandUserdata; + +typedef struct +{ + struct wl_data_source *source; + void *data_device; + SDL_ClipboardDataCallback callback; + SDL_WaylandUserdata userdata; +} SDL_WaylandDataSource; + +typedef struct +{ + struct zwp_primary_selection_source_v1 *source; + void *data_device; + void *primary_selection_device; + SDL_ClipboardDataCallback callback; + SDL_WaylandUserdata userdata; +} SDL_WaylandPrimarySelectionSource; + +typedef struct +{ + struct wl_data_offer *offer; + struct wl_list mimes; + void *data_device; +} SDL_WaylandDataOffer; + +typedef struct +{ + struct zwp_primary_selection_offer_v1 *offer; + struct wl_list mimes; + void *primary_selection_device; +} SDL_WaylandPrimarySelectionOffer; + +typedef struct +{ + struct wl_data_device *data_device; + SDL_VideoData *video_data; + + // Drag and Drop + uint32_t drag_serial; + SDL_WaylandDataOffer *drag_offer; + SDL_WaylandDataOffer *selection_offer; + bool has_mime_file, has_mime_text; + SDL_Window *dnd_window; + + // Clipboard and Primary Selection + uint32_t selection_serial; + SDL_WaylandDataSource *selection_source; +} SDL_WaylandDataDevice; + +typedef struct +{ + struct zwp_primary_selection_device_v1 *primary_selection_device; + SDL_VideoData *video_data; + + uint32_t selection_serial; + SDL_WaylandPrimarySelectionSource *selection_source; + SDL_WaylandPrimarySelectionOffer *selection_offer; +} SDL_WaylandPrimarySelectionDevice; + +// Wayland Data Source / Primary Selection Source - (Sending) +extern SDL_WaylandDataSource *Wayland_data_source_create(SDL_VideoDevice *_this); +extern SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(SDL_VideoDevice *_this); +extern ssize_t Wayland_data_source_send(SDL_WaylandDataSource *source, + const char *mime_type, int fd); +extern ssize_t Wayland_primary_selection_source_send(SDL_WaylandPrimarySelectionSource *source, + const char *mime_type, int fd); +extern void Wayland_data_source_set_callback(SDL_WaylandDataSource *source, + SDL_ClipboardDataCallback callback, + void *userdata, + Uint32 sequence); +extern void Wayland_primary_selection_source_set_callback(SDL_WaylandPrimarySelectionSource *source, + SDL_ClipboardDataCallback callback, + void *userdata); +extern void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, + const char *mime_type, + size_t *length); +extern void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSource *source, + const char *mime_type, + size_t *length); +extern void Wayland_data_source_destroy(SDL_WaylandDataSource *source); +extern void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source); + +// Wayland Data / Primary Selection Offer - (Receiving) +extern void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, + const char *mime_type, + size_t *length); +extern void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer *offer, + const char *mime_type, + size_t *length); +extern bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, + const char *mime_type); +extern bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOffer *offer, + const char *mime_type); +extern bool Wayland_data_offer_add_mime(SDL_WaylandDataOffer *offer, + const char *mime_type); +extern bool Wayland_primary_selection_offer_add_mime(SDL_WaylandPrimarySelectionOffer *offer, + const char *mime_type); +extern void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer); +extern void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer); + +// Clipboard / Primary Selection +extern bool Wayland_data_device_clear_selection(SDL_WaylandDataDevice *device); +extern bool Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelectionDevice *device); +extern bool Wayland_data_device_set_selection(SDL_WaylandDataDevice *device, + SDL_WaylandDataSource *source, + const char **mime_types, + size_t mime_count); +extern bool Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDevice *device, + SDL_WaylandPrimarySelectionSource *source, + const char **mime_types, + size_t mime_count); +extern void Wayland_data_device_set_serial(SDL_WaylandDataDevice *device, + uint32_t serial); +extern void Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevice *device, + uint32_t serial); +#endif // SDL_waylanddatamanager_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.c new file mode 100644 index 0000000..7d6d42f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.c @@ -0,0 +1,176 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#define DEBUG_DYNAMIC_WAYLAND 0 + +#include "SDL_waylanddyn.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + +typedef struct +{ + SDL_SharedObject *lib; + const char *libname; +} waylanddynlib; + +static waylanddynlib waylandlibs[] = { + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC }, +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_EGL }, +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_CURSOR }, +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_XKBCOMMON }, +#endif +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR + { NULL, SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR }, +#endif + { NULL, NULL } +}; + +static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, bool required) +{ + void *fn = NULL; + waylanddynlib *dynlib; + for (dynlib = waylandlibs; dynlib->libname; dynlib++) { + if (dynlib->lib) { + fn = SDL_LoadFunction(dynlib->lib, fnname); + if (fn) { + break; + } + } + } + +#if DEBUG_DYNAMIC_WAYLAND + if (fn) { + SDL_Log("WAYLAND: Found '%s' in %s (%p)", fnname, dynlib->libname, fn); + } else { + SDL_Log("WAYLAND: Symbol '%s' NOT FOUND!", fnname); + } +#endif + + if (!fn && required) { + *pHasModule = 0; // kill this module. + } + + return fn; +} + +#else + +#include + +#endif // SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + +// Define all the function pointers and wrappers... +#define SDL_WAYLAND_MODULE(modname) int SDL_WAYLAND_HAVE_##modname = 0; +#define SDL_WAYLAND_SYM(rc, fn, params) SDL_DYNWAYLANDFN_##fn WAYLAND_##fn = NULL; +#define SDL_WAYLAND_SYM_OPT(rc, fn, params) SDL_DYNWAYLANDFN_##fn WAYLAND_##fn = NULL; +#define SDL_WAYLAND_INTERFACE(iface) const struct wl_interface *WAYLAND_##iface = NULL; +#include "SDL_waylandsym.h" + +static int wayland_load_refcount = 0; + +void SDL_WAYLAND_UnloadSymbols(void) +{ + // Don't actually unload if more than one module is using the libs... + if (wayland_load_refcount > 0) { + if (--wayland_load_refcount == 0) { +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + int i; +#endif + + // set all the function pointers to NULL. +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 0; +#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = NULL; +#define SDL_WAYLAND_SYM_OPT(rc, fn, params) WAYLAND_##fn = NULL; +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = NULL; +#include "SDL_waylandsym.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + for (i = 0; i < SDL_arraysize(waylandlibs); i++) { + if (waylandlibs[i].lib) { + SDL_UnloadObject(waylandlibs[i].lib); + waylandlibs[i].lib = NULL; + } + } +#endif + } + } +} + +// returns non-zero if all needed symbols were loaded. +bool SDL_WAYLAND_LoadSymbols(void) +{ + bool result = true; // always succeed if not using Dynamic WAYLAND stuff. + + // deal with multiple modules (dga, wayland, etc) needing these symbols... + if (wayland_load_refcount++ == 0) { +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + int i; + int *thismod = NULL; + for (i = 0; i < SDL_arraysize(waylandlibs); i++) { + if (waylandlibs[i].libname) { + waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname); + } + } + +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; // default yes +#include "SDL_waylandsym.h" + +#define SDL_WAYLAND_MODULE(modname) thismod = &SDL_WAYLAND_HAVE_##modname; +#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn)WAYLAND_GetSym(#fn, thismod, true); +#define SDL_WAYLAND_SYM_OPT(rc, fn, params) WAYLAND_##fn = (SDL_DYNWAYLANDFN_##fn)WAYLAND_GetSym(#fn, thismod, false); +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = (struct wl_interface *)WAYLAND_GetSym(#iface, thismod, true); +#include "SDL_waylandsym.h" + + if (SDL_WAYLAND_HAVE_WAYLAND_CLIENT && + SDL_WAYLAND_HAVE_WAYLAND_CURSOR && + SDL_WAYLAND_HAVE_WAYLAND_EGL && + SDL_WAYLAND_HAVE_WAYLAND_XKB) { + // All required symbols loaded, only libdecor is optional. + SDL_ClearError(); + } else { + // in case something got loaded... + SDL_WAYLAND_UnloadSymbols(); + result = false; + } + +#else // no dynamic WAYLAND + +#define SDL_WAYLAND_MODULE(modname) SDL_WAYLAND_HAVE_##modname = 1; // default yes +#define SDL_WAYLAND_SYM(rc, fn, params) WAYLAND_##fn = fn; +#define SDL_WAYLAND_SYM_OPT(rc, fn, params) WAYLAND_##fn = fn; +#define SDL_WAYLAND_INTERFACE(iface) WAYLAND_##iface = &iface; +#include "SDL_waylandsym.h" + +#endif + } + + return result; +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.h new file mode 100644 index 0000000..fd85a7c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylanddyn.h @@ -0,0 +1,195 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_waylanddyn_h_ +#define SDL_waylanddyn_h_ + +#include "SDL_internal.h" + +/* We can't include wayland-client.h here + * but we need some structs from it + */ +struct wl_interface; +struct wl_proxy; +struct wl_event_queue; +struct wl_display; +struct wl_surface; +struct wl_shm; + +// We also need some for libdecor +struct wl_seat; +struct wl_output; +struct libdecor; +struct libdecor_frame; +struct libdecor_state; +struct libdecor_configuration; +struct libdecor_interface; +struct libdecor_frame_interface; +enum libdecor_resize_edge; +enum libdecor_capabilities; +enum libdecor_window_state; + +#include "wayland-cursor.h" +#include "wayland-util.h" +#include "xkbcommon/xkbcommon.h" +#include "xkbcommon/xkbcommon-compose.h" + +// Must be included before our #defines, see Bugzilla #4957 +#include "wayland-client-core.h" + +#define SDL_WAYLAND_CHECK_VERSION(x, y, z) \ + (WAYLAND_VERSION_MAJOR > x || \ + (WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR > y) || \ + (WAYLAND_VERSION_MAJOR == x && WAYLAND_VERSION_MINOR == y && WAYLAND_VERSION_MICRO >= z)) + +#ifdef HAVE_LIBDECOR_H +#define SDL_LIBDECOR_CHECK_VERSION(x, y, z) \ + (SDL_LIBDECOR_VERSION_MAJOR > x || \ + (SDL_LIBDECOR_VERSION_MAJOR == x && SDL_LIBDECOR_VERSION_MINOR > y) || \ + (SDL_LIBDECOR_VERSION_MAJOR == x && SDL_LIBDECOR_VERSION_MINOR == y && SDL_LIBDECOR_VERSION_PATCH >= z)) +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern bool SDL_WAYLAND_LoadSymbols(void); +extern void SDL_WAYLAND_UnloadSymbols(void); + +#define SDL_WAYLAND_MODULE(modname) extern int SDL_WAYLAND_HAVE_##modname; +#define SDL_WAYLAND_SYM(rc, fn, params) \ + typedef rc(*SDL_DYNWAYLANDFN_##fn) params; \ + extern SDL_DYNWAYLANDFN_##fn WAYLAND_##fn; +#define SDL_WAYLAND_SYM_OPT(rc, fn, params) \ + typedef rc(*SDL_DYNWAYLANDFN_##fn) params; \ + extern SDL_DYNWAYLANDFN_##fn WAYLAND_##fn; +#define SDL_WAYLAND_INTERFACE(iface) extern const struct wl_interface *WAYLAND_##iface; +#include "SDL_waylandsym.h" + +#ifdef __cplusplus +} +#endif + +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + +#if defined(_WAYLAND_CLIENT_H) || defined(WAYLAND_CLIENT_H) +#error Do not include wayland-client ahead of SDL_waylanddyn.h in dynamic loading mode +#endif + +/* wayland-client-protocol.h included from wayland-client.h + * has inline functions that require these to be defined in dynamic loading mode + */ + +#define wl_proxy_create (*WAYLAND_wl_proxy_create) +#define wl_proxy_destroy (*WAYLAND_wl_proxy_destroy) +#define wl_proxy_marshal (*WAYLAND_wl_proxy_marshal) +#define wl_proxy_set_user_data (*WAYLAND_wl_proxy_set_user_data) +#define wl_proxy_get_user_data (*WAYLAND_wl_proxy_get_user_data) +#define wl_proxy_get_version (*WAYLAND_wl_proxy_get_version) +#define wl_proxy_add_listener (*WAYLAND_wl_proxy_add_listener) +#define wl_proxy_marshal_constructor (*WAYLAND_wl_proxy_marshal_constructor) +#define wl_proxy_marshal_constructor_versioned (*WAYLAND_wl_proxy_marshal_constructor_versioned) +#define wl_proxy_set_tag (*WAYLAND_wl_proxy_set_tag) +#define wl_proxy_get_tag (*WAYLAND_wl_proxy_get_tag) +#define wl_proxy_marshal_flags (*WAYLAND_wl_proxy_marshal_flags) +#define wl_proxy_marshal_array_flags (*WAYLAND_wl_proxy_marshal_array_flags) +#define wl_display_reconnect (*WAYLAND_wl_display_reconnect) + +#define wl_seat_interface (*WAYLAND_wl_seat_interface) +#define wl_surface_interface (*WAYLAND_wl_surface_interface) +#define wl_shm_pool_interface (*WAYLAND_wl_shm_pool_interface) +#define wl_buffer_interface (*WAYLAND_wl_buffer_interface) +#define wl_registry_interface (*WAYLAND_wl_registry_interface) +#define wl_region_interface (*WAYLAND_wl_region_interface) +#define wl_pointer_interface (*WAYLAND_wl_pointer_interface) +#define wl_keyboard_interface (*WAYLAND_wl_keyboard_interface) +#define wl_compositor_interface (*WAYLAND_wl_compositor_interface) +#define wl_output_interface (*WAYLAND_wl_output_interface) +#define wl_shm_interface (*WAYLAND_wl_shm_interface) +#define wl_data_device_interface (*WAYLAND_wl_data_device_interface) +#define wl_data_offer_interface (*WAYLAND_wl_data_offer_interface) +#define wl_data_source_interface (*WAYLAND_wl_data_source_interface) +#define wl_data_device_manager_interface (*WAYLAND_wl_data_device_manager_interface) + +/* + * These must be included before libdecor.h, otherwise the libdecor header + * pulls in the system Wayland protocol headers instead of ours. + */ +#include "wayland-client-protocol.h" +#include "wayland-egl.h" + +#ifdef HAVE_LIBDECOR_H +// Must be included before our defines +#include + +#define libdecor_unref (*WAYLAND_libdecor_unref) +#define libdecor_new (*WAYLAND_libdecor_new) +#define libdecor_decorate (*WAYLAND_libdecor_decorate) +#define libdecor_frame_unref (*WAYLAND_libdecor_frame_unref) +#define libdecor_frame_set_title (*WAYLAND_libdecor_frame_set_title) +#define libdecor_frame_set_app_id (*WAYLAND_libdecor_frame_set_app_id) +#define libdecor_frame_set_max_content_size (*WAYLAND_libdecor_frame_set_max_content_size) +#define libdecor_frame_get_max_content_size (*WAYLAND_libdecor_frame_get_max_content_size) +#define libdecor_frame_set_min_content_size (*WAYLAND_libdecor_frame_set_min_content_size) +#define libdecor_frame_get_min_content_size (*WAYLAND_libdecor_frame_get_min_content_size) +#define libdecor_frame_resize (*WAYLAND_libdecor_frame_resize) +#define libdecor_frame_move (*WAYLAND_libdecor_frame_move) +#define libdecor_frame_commit (*WAYLAND_libdecor_frame_commit) +#define libdecor_frame_set_minimized (*WAYLAND_libdecor_frame_set_minimized) +#define libdecor_frame_set_maximized (*WAYLAND_libdecor_frame_set_maximized) +#define libdecor_frame_unset_maximized (*WAYLAND_libdecor_frame_unset_maximized) +#define libdecor_frame_set_fullscreen (*WAYLAND_libdecor_frame_set_fullscreen) +#define libdecor_frame_unset_fullscreen (*WAYLAND_libdecor_frame_unset_fullscreen) +#define libdecor_frame_set_capabilities (*WAYLAND_libdecor_frame_set_capabilities) +#define libdecor_frame_unset_capabilities (*WAYLAND_libdecor_frame_unset_capabilities) +#define libdecor_frame_has_capability (*WAYLAND_libdecor_frame_has_capability) +#define libdecor_frame_set_visibility (*WAYLAND_libdecor_frame_set_visibility) +#define libdecor_frame_is_visible (*WAYLAND_libdecor_frame_is_visible) +#define libdecor_frame_is_floating (*WAYLAND_libdecor_frame_is_floating) +#define libdecor_frame_set_parent (*WAYLAND_libdecor_frame_set_parent) +#define libdecor_frame_show_window_menu (*WAYLAND_libdecor_frame_show_window_menu) +#define libdecor_frame_get_wm_capabilities (*WAYLAND_libdecor_frame_get_wm_capabilities) +#define libdecor_frame_get_xdg_surface (*WAYLAND_libdecor_frame_get_xdg_surface) +#define libdecor_frame_get_xdg_toplevel (*WAYLAND_libdecor_frame_get_xdg_toplevel) +#define libdecor_frame_translate_coordinate (*WAYLAND_libdecor_frame_translate_coordinate) +#define libdecor_frame_map (*WAYLAND_libdecor_frame_map) +#define libdecor_state_new (*WAYLAND_libdecor_state_new) +#define libdecor_state_free (*WAYLAND_libdecor_state_free) +#define libdecor_configuration_get_content_size (*WAYLAND_libdecor_configuration_get_content_size) +#define libdecor_configuration_get_window_state (*WAYLAND_libdecor_configuration_get_window_state) +#define libdecor_dispatch (*WAYLAND_libdecor_dispatch) +#endif + +#else // SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + +/* + * These must be included before libdecor.h, otherwise the libdecor header + * pulls in the system Wayland protocol headers instead of ours. + */ +#include "wayland-client-protocol.h" +#include "wayland-egl.h" + +#ifdef HAVE_LIBDECOR_H +#include +#endif + +#endif // SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC + +#endif // SDL_waylanddyn_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents.c new file mode 100644 index 0000000..83c414f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents.c @@ -0,0 +1,3408 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include "../../core/unix/SDL_poll.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_scancode_tables_c.h" +#include "../../events/SDL_keysym_to_keycode_c.h" +#include "../../core/linux/SDL_system_theme.h" +#include "../SDL_sysvideo.h" + +#include "SDL_waylandvideo.h" +#include "SDL_waylandevents_c.h" +#include "SDL_waylandwindow.h" +#include "SDL_waylandmouse.h" + +#include "pointer-constraints-unstable-v1-client-protocol.h" +#include "relative-pointer-unstable-v1-client-protocol.h" +#include "xdg-shell-client-protocol.h" +#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h" +#include "text-input-unstable-v3-client-protocol.h" +#include "tablet-v2-client-protocol.h" +#include "primary-selection-unstable-v1-client-protocol.h" +#include "input-timestamps-unstable-v1-client-protocol.h" + +#ifdef HAVE_LIBDECOR_H +#include +#endif + +#ifdef SDL_INPUT_LINUXEV +#include +#else +#define BTN_LEFT (0x110) +#define BTN_RIGHT (0x111) +#define BTN_MIDDLE (0x112) +#define BTN_SIDE (0x113) +#define BTN_EXTRA (0x114) +#endif +#include "../../events/SDL_keysym_to_scancode_c.h" +#include "../../events/imKStoUCS.h" +#include +#include +#include +#include +#include +#include "cursor-shape-v1-client-protocol.h" + +// Weston uses a ratio of 10 units per scroll tick +#define WAYLAND_WHEEL_AXIS_UNIT 10 + +#ifndef XKB_MOD_NAME_MOD3 +#define XKB_MOD_NAME_MOD3 "Mod3" +#endif + +#ifndef XKB_MOD_NAME_MOD5 +#define XKB_MOD_NAME_MOD5 "Mod5" +#endif + +// Keyboard and mouse names to match XWayland +#define WAYLAND_DEFAULT_KEYBOARD_NAME "Virtual core keyboard" +#define WAYLAND_DEFAULT_POINTER_NAME "Virtual core pointer" + +// Focus clickthrough timeout +#define WAYLAND_FOCUS_CLICK_TIMEOUT_NS SDL_MS_TO_NS(10) + +struct SDL_WaylandTouchPoint +{ + SDL_TouchID id; + wl_fixed_t fx; + wl_fixed_t fy; + struct wl_surface *surface; + + struct wl_list link; +}; + +static struct wl_list touch_points; + +static void touch_add(SDL_TouchID id, wl_fixed_t fx, wl_fixed_t fy, struct wl_surface *surface) +{ + struct SDL_WaylandTouchPoint *tp = SDL_malloc(sizeof(struct SDL_WaylandTouchPoint)); + + SDL_zerop(tp); + tp->id = id; + tp->fx = fx; + tp->fy = fy; + tp->surface = surface; + + WAYLAND_wl_list_insert(&touch_points, &tp->link); +} + +static void touch_update(SDL_TouchID id, wl_fixed_t fx, wl_fixed_t fy, struct wl_surface **surface) +{ + struct SDL_WaylandTouchPoint *tp; + + wl_list_for_each (tp, &touch_points, link) { + if (tp->id == id) { + tp->fx = fx; + tp->fy = fy; + if (surface) { + *surface = tp->surface; + } + break; + } + } +} + +static void touch_del(SDL_TouchID id, wl_fixed_t *fx, wl_fixed_t *fy, struct wl_surface **surface) +{ + struct SDL_WaylandTouchPoint *tp; + + wl_list_for_each (tp, &touch_points, link) { + if (tp->id == id) { + if (fx) { + *fx = tp->fx; + } + if (fy) { + *fy = tp->fy; + } + if (surface) { + *surface = tp->surface; + } + + WAYLAND_wl_list_remove(&tp->link); + SDL_free(tp); + break; + } + } +} + +static bool Wayland_SurfaceHasActiveTouches(struct wl_surface *surface) +{ + struct SDL_WaylandTouchPoint *tp; + + wl_list_for_each (tp, &touch_points, link) { + if (tp->surface == surface) { + return true; + } + } + + return false; +} + +static Uint64 Wayland_GetEventTimestamp(Uint64 nsTimestamp) +{ + static Uint64 last; + static Uint64 timestamp_offset; + const Uint64 now = SDL_GetTicksNS(); + + if (nsTimestamp < last) { + // 32-bit timer rollover, bump the offset + timestamp_offset += SDL_MS_TO_NS(0x100000000LLU); + } + last = nsTimestamp; + + if (!timestamp_offset) { + timestamp_offset = (now - nsTimestamp); + } + nsTimestamp += timestamp_offset; + + if (nsTimestamp > now) { + timestamp_offset -= (nsTimestamp - now); + nsTimestamp = now; + } + + return nsTimestamp; +} + +static void Wayland_input_timestamp_listener(void *data, struct zwp_input_timestamps_v1 *zwp_input_timestamps_v1, + uint32_t tv_sec_hi, uint32_t tv_sec_lo, uint32_t tv_nsec) +{ + *((Uint64 *)data) = ((((Uint64)tv_sec_hi << 32) | (Uint64)tv_sec_lo) * SDL_NS_PER_SECOND) + tv_nsec; +} + +static const struct zwp_input_timestamps_v1_listener timestamp_listener = { + Wayland_input_timestamp_listener +}; + +static Uint64 Wayland_GetKeyboardTimestamp(struct SDL_WaylandInput *input, Uint32 wl_timestamp_ms) +{ + if (wl_timestamp_ms) { + return Wayland_GetEventTimestamp(input->keyboard_timestamp_ns ? input->keyboard_timestamp_ns : SDL_MS_TO_NS(wl_timestamp_ms)); + } + + return 0; +} + +static Uint64 Wayland_GetKeyboardTimestampRaw(struct SDL_WaylandInput *input, Uint32 wl_timestamp_ms) +{ + if (wl_timestamp_ms) { + return input->keyboard_timestamp_ns ? input->keyboard_timestamp_ns : SDL_MS_TO_NS(wl_timestamp_ms); + } + + return 0; +} + +static Uint64 Wayland_GetPointerTimestamp(struct SDL_WaylandInput *input, Uint32 wl_timestamp_ms) +{ + if (wl_timestamp_ms) { + return Wayland_GetEventTimestamp(input->pointer_timestamp_ns ? input->pointer_timestamp_ns : SDL_MS_TO_NS(wl_timestamp_ms)); + } + + return 0; +} + +Uint64 Wayland_GetTouchTimestamp(struct SDL_WaylandInput *input, Uint32 wl_timestamp_ms) +{ + if (wl_timestamp_ms) { + return Wayland_GetEventTimestamp(input->touch_timestamp_ns ? input->touch_timestamp_ns : SDL_MS_TO_NS(wl_timestamp_ms)); + } + + return 0; +} + +void Wayland_RegisterTimestampListeners(struct SDL_WaylandInput *input) +{ + SDL_VideoData *viddata = input->display; + + if (viddata->input_timestamps_manager) { + if (input->keyboard && !input->keyboard_timestamps) { + input->keyboard_timestamps = zwp_input_timestamps_manager_v1_get_keyboard_timestamps(viddata->input_timestamps_manager, input->keyboard); + zwp_input_timestamps_v1_add_listener(input->keyboard_timestamps, ×tamp_listener, &input->keyboard_timestamp_ns); + } + + if (input->pointer && !input->pointer_timestamps) { + input->pointer_timestamps = zwp_input_timestamps_manager_v1_get_pointer_timestamps(viddata->input_timestamps_manager, input->pointer); + zwp_input_timestamps_v1_add_listener(input->pointer_timestamps, ×tamp_listener, &input->pointer_timestamp_ns); + } + + if (input->touch && !input->touch_timestamps) { + input->touch_timestamps = zwp_input_timestamps_manager_v1_get_touch_timestamps(viddata->input_timestamps_manager, input->touch); + zwp_input_timestamps_v1_add_listener(input->touch_timestamps, ×tamp_listener, &input->touch_timestamp_ns); + } + } +} + +void Wayland_CreateCursorShapeDevice(struct SDL_WaylandInput *input) +{ + SDL_VideoData *viddata = input->display; + + if (viddata->cursor_shape_manager) { + if (input->pointer && !input->cursor_shape) { + input->cursor_shape = wp_cursor_shape_manager_v1_get_pointer(viddata->cursor_shape_manager, input->pointer); + } + } +} + +// Returns true if a key repeat event was due +static bool keyboard_repeat_handle(SDL_WaylandKeyboardRepeat *repeat_info, Uint64 elapsed) +{ + bool ret = false; + while (elapsed >= repeat_info->next_repeat_ns) { + if (repeat_info->scancode != SDL_SCANCODE_UNKNOWN) { + const Uint64 timestamp = repeat_info->wl_press_time_ns + repeat_info->next_repeat_ns; + SDL_SendKeyboardKeyIgnoreModifiers(Wayland_GetEventTimestamp(timestamp), repeat_info->keyboard_id, repeat_info->key, repeat_info->scancode, true); + } + if (repeat_info->text[0]) { + SDL_SendKeyboardText(repeat_info->text); + } + repeat_info->next_repeat_ns += SDL_NS_PER_SECOND / (Uint64)repeat_info->repeat_rate; + ret = true; + } + return ret; +} + +static void keyboard_repeat_clear(SDL_WaylandKeyboardRepeat *repeat_info) +{ + if (!repeat_info->is_initialized) { + return; + } + repeat_info->is_key_down = false; +} + +static void keyboard_repeat_set(SDL_WaylandKeyboardRepeat *repeat_info, Uint32 keyboard_id, uint32_t key, Uint64 wl_press_time_ns, + uint32_t scancode, bool has_text, char text[8]) +{ + if (!repeat_info->is_initialized || !repeat_info->repeat_rate) { + return; + } + repeat_info->is_key_down = true; + repeat_info->keyboard_id = keyboard_id; + repeat_info->key = key; + repeat_info->wl_press_time_ns = wl_press_time_ns; + repeat_info->sdl_press_time_ns = SDL_GetTicksNS(); + repeat_info->next_repeat_ns = SDL_MS_TO_NS(repeat_info->repeat_delay_ms); + repeat_info->scancode = scancode; + if (has_text) { + SDL_copyp(repeat_info->text, text); + } else { + repeat_info->text[0] = '\0'; + } +} + +static uint32_t keyboard_repeat_get_key(SDL_WaylandKeyboardRepeat *repeat_info) +{ + if (repeat_info->is_initialized && repeat_info->is_key_down) { + return repeat_info->key; + } + + return 0; +} + +static void keyboard_repeat_set_text(SDL_WaylandKeyboardRepeat *repeat_info, const char text[8]) +{ + if (repeat_info->is_initialized) { + SDL_copyp(repeat_info->text, text); + } +} + +static bool keyboard_repeat_is_set(SDL_WaylandKeyboardRepeat *repeat_info) +{ + return repeat_info->is_initialized && repeat_info->is_key_down; +} + +static bool keyboard_repeat_key_is_set(SDL_WaylandKeyboardRepeat *repeat_info, uint32_t key) +{ + return repeat_info->is_initialized && repeat_info->is_key_down && key == repeat_info->key; +} + +static void sync_done_handler(void *data, struct wl_callback *callback, uint32_t callback_data) +{ + // Nothing to do, just destroy the callback + wl_callback_destroy(callback); +} + +static struct wl_callback_listener sync_listener = { + sync_done_handler +}; + +void Wayland_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *d = _this->internal; + + /* Queue a sync event to unblock the event queue fd if it's empty and being waited on. + * TODO: Maybe use a pipe to avoid the compositor roundtrip? + */ + struct wl_callback *cb = wl_display_sync(d->display); + wl_callback_add_listener(cb, &sync_listener, NULL); + WAYLAND_wl_display_flush(d->display); +} + +static int dispatch_queued_events(SDL_VideoData *viddata) +{ + int rc; + + /* + * NOTE: When reconnection is implemented, check if libdecor needs to be + * involved in the reconnection process. + */ +#ifdef HAVE_LIBDECOR_H + if (viddata->shell.libdecor) { + libdecor_dispatch(viddata->shell.libdecor, 0); + } +#endif + + rc = WAYLAND_wl_display_dispatch_pending(viddata->display); + return rc >= 0 ? 1 : rc; +} + +int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) +{ + SDL_VideoData *d = _this->internal; + struct SDL_WaylandInput *input = d->input; + bool key_repeat_active = false; + + WAYLAND_wl_display_flush(d->display); + +#ifdef SDL_USE_IME + SDL_Window *keyboard_focus = SDL_GetKeyboardFocus(); + if (!d->text_input_manager && keyboard_focus && SDL_TextInputActive(keyboard_focus)) { + SDL_IME_PumpEvents(); + } +#endif + +#ifdef SDL_USE_LIBDBUS + SDL_DBus_PumpEvents(); +#endif + + // If key repeat is active, we'll need to cap our maximum wait time to handle repeats + if (input && keyboard_repeat_is_set(&input->keyboard_repeat)) { + const Uint64 elapsed = SDL_GetTicksNS() - input->keyboard_repeat.sdl_press_time_ns; + if (keyboard_repeat_handle(&input->keyboard_repeat, elapsed)) { + // A repeat key event was already due + return 1; + } else { + const Uint64 next_repeat_wait_time = (input->keyboard_repeat.next_repeat_ns - elapsed) + 1; + if (timeoutNS >= 0) { + timeoutNS = SDL_min(timeoutNS, next_repeat_wait_time); + } else { + timeoutNS = next_repeat_wait_time; + } + key_repeat_active = true; + } + } + + /* wl_display_prepare_read() will return -1 if the default queue is not empty. + * If the default queue is empty, it will prepare us for our SDL_IOReady() call. */ + if (WAYLAND_wl_display_prepare_read(d->display) == 0) { + // Use SDL_IOR_NO_RETRY to ensure SIGINT will break us out of our wait + int err = SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_IOR_READ | SDL_IOR_NO_RETRY, timeoutNS); + if (err > 0) { + // There are new events available to read + WAYLAND_wl_display_read_events(d->display); + return dispatch_queued_events(d); + } else if (err == 0) { + // No events available within the timeout + WAYLAND_wl_display_cancel_read(d->display); + + // If key repeat is active, we might have woken up to generate a key event + if (key_repeat_active) { + const Uint64 elapsed = SDL_GetTicksNS() - input->keyboard_repeat.sdl_press_time_ns; + if (keyboard_repeat_handle(&input->keyboard_repeat, elapsed)) { + return 1; + } + } + + return 0; + } else { + // Error returned from poll()/select() + WAYLAND_wl_display_cancel_read(d->display); + + if (errno == EINTR) { + /* If the wait was interrupted by a signal, we may have generated a + * SDL_EVENT_QUIT event. Let the caller know to call SDL_PumpEvents(). */ + return 1; + } else { + return err; + } + } + } else { + // We already had pending events + return dispatch_queued_events(d); + } +} + +void Wayland_PumpEvents(SDL_VideoDevice *_this) +{ + SDL_VideoData *d = _this->internal; + struct SDL_WaylandInput *input = d->input; + int err; + +#ifdef SDL_USE_IME + SDL_Window *keyboard_focus = SDL_GetKeyboardFocus(); + if (!d->text_input_manager && keyboard_focus && SDL_TextInputActive(keyboard_focus)) { + SDL_IME_PumpEvents(); + } +#endif + +#ifdef SDL_USE_LIBDBUS + SDL_DBus_PumpEvents(); +#endif + +#ifdef HAVE_LIBDECOR_H + if (d->shell.libdecor) { + libdecor_dispatch(d->shell.libdecor, 0); + } +#endif + + WAYLAND_wl_display_flush(d->display); + + /* wl_display_prepare_read() will return -1 if the default queue is not empty. + * If the default queue is empty, it will prepare us for our SDL_IOReady() call. */ + if (WAYLAND_wl_display_prepare_read(d->display) == 0) { + if (SDL_IOReady(WAYLAND_wl_display_get_fd(d->display), SDL_IOR_READ, 0) > 0) { + WAYLAND_wl_display_read_events(d->display); + } else { + WAYLAND_wl_display_cancel_read(d->display); + } + } + + // Dispatch any pre-existing pending events or new events we may have read + err = WAYLAND_wl_display_dispatch_pending(d->display); + + if (input && keyboard_repeat_is_set(&input->keyboard_repeat)) { + const Uint64 elapsed = SDL_GetTicksNS() - input->keyboard_repeat.sdl_press_time_ns; + keyboard_repeat_handle(&input->keyboard_repeat, elapsed); + } + + if (err < 0 && !d->display_disconnected) { + /* Something has failed with the Wayland connection -- for example, + * the compositor may have shut down and closed its end of the socket, + * or there is a library-specific error. + * + * Try to recover once, then quit. + */ + if (!Wayland_VideoReconnect(_this)) { + d->display_disconnected = 1; + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Wayland display connection closed by server (fatal)"); + + /* Only send a single quit message, as application shutdown might call + * SDL_PumpEvents + */ + SDL_SendQuit(); + } + } +} + +static void pointer_handle_motion(void *data, struct wl_pointer *pointer, + uint32_t time, wl_fixed_t sx_w, wl_fixed_t sy_w) +{ + struct SDL_WaylandInput *input = data; + SDL_WindowData *window_data = input->pointer_focus; + SDL_Window *window = window_data ? window_data->sdlwindow : NULL; + + input->sx_w = sx_w; + input->sy_w = sy_w; + if (input->pointer_focus) { + const float sx = (float)(wl_fixed_to_double(sx_w) * window_data->pointer_scale.x); + const float sy = (float)(wl_fixed_to_double(sy_w) * window_data->pointer_scale.y); + SDL_SendMouseMotion(Wayland_GetPointerTimestamp(input, time), window_data->sdlwindow, input->pointer_id, false, sx, sy); + } + + if (window && window->hit_test) { + const SDL_Point point = { (int)SDL_floor(wl_fixed_to_double(sx_w) * window_data->pointer_scale.x), + (int)SDL_floor(wl_fixed_to_double(sy_w) * window_data->pointer_scale.y) }; + SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); + if (rc == window_data->hit_test_result) { + return; + } + + Wayland_SetHitTestCursor(rc); + window_data->hit_test_result = rc; + } +} + +static void pointer_handle_enter(void *data, struct wl_pointer *pointer, + uint32_t serial, struct wl_surface *surface, + wl_fixed_t sx_w, wl_fixed_t sy_w) +{ + struct SDL_WaylandInput *input = data; + SDL_WindowData *window; + + if (!surface) { + // enter event for a window we've just destroyed + return; + } + + /* This handler will be called twice in Wayland 1.4 + * Once for the window surface which has valid user data + * and again for the mouse cursor surface which does not have valid user data + * We ignore the later + */ + window = Wayland_GetWindowDataForOwnedSurface(surface); + + if (window) { + input->pointer_focus = window; + input->pointer_enter_serial = serial; + SDL_SetMouseFocus(window->sdlwindow); + /* In the case of e.g. a pointer confine warp, we may receive an enter + * event with no following motion event, but with the new coordinates + * as part of the enter event. + * + * FIXME: This causes a movement event with an anomalous timestamp when + * the cursor enters the window. + */ + pointer_handle_motion(data, pointer, 0, sx_w, sy_w); + /* If the cursor was changed while our window didn't have pointer + * focus, we might need to trigger another call to + * wl_pointer_set_cursor() for the new cursor to be displayed. */ + Wayland_SetHitTestCursor(window->hit_test_result); + } +} + +static void pointer_handle_leave(void *data, struct wl_pointer *pointer, + uint32_t serial, struct wl_surface *surface) +{ + struct SDL_WaylandInput *input = data; + + if (!surface) { + return; + } + + if (input->pointer_focus) { + SDL_WindowData *wind = Wayland_GetWindowDataForOwnedSurface(surface); + + if (wind) { + // Clear the capture flag and raise all buttons + wind->sdlwindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; + + input->buttons_pressed = 0; + SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, input->pointer_id, SDL_BUTTON_LEFT, false); + SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, input->pointer_id, SDL_BUTTON_RIGHT, false); + SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, input->pointer_id, SDL_BUTTON_MIDDLE, false); + SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, input->pointer_id, SDL_BUTTON_X1, false); + SDL_SendMouseButton(Wayland_GetPointerTimestamp(input, 0), wind->sdlwindow, input->pointer_id, SDL_BUTTON_X2, false); + } + + /* A pointer leave event may be emitted if the compositor hides the pointer in response to receiving a touch event. + * Don't relinquish focus if the surface has active touches, as the compositor is just transitioning from mouse to touch mode. + */ + if (!Wayland_SurfaceHasActiveTouches(surface)) { + SDL_SetMouseFocus(NULL); + } + input->pointer_focus = NULL; + } +} + +static bool ProcessHitTest(SDL_WindowData *window_data, + struct wl_seat *seat, + wl_fixed_t sx_w, wl_fixed_t sy_w, + uint32_t serial) +{ + SDL_Window *window = window_data->sdlwindow; + + if (window->hit_test) { + static const uint32_t directions[] = { + XDG_TOPLEVEL_RESIZE_EDGE_TOP_LEFT, XDG_TOPLEVEL_RESIZE_EDGE_TOP, + XDG_TOPLEVEL_RESIZE_EDGE_TOP_RIGHT, XDG_TOPLEVEL_RESIZE_EDGE_RIGHT, + XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_RIGHT, XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM, + XDG_TOPLEVEL_RESIZE_EDGE_BOTTOM_LEFT, XDG_TOPLEVEL_RESIZE_EDGE_LEFT + }; + +#ifdef HAVE_LIBDECOR_H + static const uint32_t directions_libdecor[] = { + LIBDECOR_RESIZE_EDGE_TOP_LEFT, LIBDECOR_RESIZE_EDGE_TOP, + LIBDECOR_RESIZE_EDGE_TOP_RIGHT, LIBDECOR_RESIZE_EDGE_RIGHT, + LIBDECOR_RESIZE_EDGE_BOTTOM_RIGHT, LIBDECOR_RESIZE_EDGE_BOTTOM, + LIBDECOR_RESIZE_EDGE_BOTTOM_LEFT, LIBDECOR_RESIZE_EDGE_LEFT + }; +#endif + + switch (window_data->hit_test_result) { + case SDL_HITTEST_DRAGGABLE: +#ifdef HAVE_LIBDECOR_H + if (window_data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (window_data->shell_surface.libdecor.frame) { + libdecor_frame_move(window_data->shell_surface.libdecor.frame, + seat, + serial); + } + } else +#endif + if (window_data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (window_data->shell_surface.xdg.toplevel.xdg_toplevel) { + xdg_toplevel_move(window_data->shell_surface.xdg.toplevel.xdg_toplevel, + seat, + serial); + } + } + return true; + + case SDL_HITTEST_RESIZE_TOPLEFT: + case SDL_HITTEST_RESIZE_TOP: + case SDL_HITTEST_RESIZE_TOPRIGHT: + case SDL_HITTEST_RESIZE_RIGHT: + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: + case SDL_HITTEST_RESIZE_BOTTOM: + case SDL_HITTEST_RESIZE_BOTTOMLEFT: + case SDL_HITTEST_RESIZE_LEFT: +#ifdef HAVE_LIBDECOR_H + if (window_data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (window_data->shell_surface.libdecor.frame) { + libdecor_frame_resize(window_data->shell_surface.libdecor.frame, + seat, + serial, + directions_libdecor[window_data->hit_test_result - SDL_HITTEST_RESIZE_TOPLEFT]); + } + } else +#endif + if (window_data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (window_data->shell_surface.xdg.toplevel.xdg_toplevel) { + xdg_toplevel_resize(window_data->shell_surface.xdg.toplevel.xdg_toplevel, + seat, + serial, + directions[window_data->hit_test_result - SDL_HITTEST_RESIZE_TOPLEFT]); + } + } + return true; + + default: + return false; + } + } + + return false; +} + +static void pointer_handle_button_common(struct SDL_WaylandInput *input, uint32_t serial, + uint32_t time, uint32_t button, uint32_t state_w) +{ + SDL_WindowData *window = input->pointer_focus; + enum wl_pointer_button_state state = state_w; + Uint64 timestamp = Wayland_GetPointerTimestamp(input, time); + Uint8 sdl_button; + const bool down = (state != 0); + + switch (button) { + case BTN_LEFT: + sdl_button = SDL_BUTTON_LEFT; + break; + case BTN_MIDDLE: + sdl_button = SDL_BUTTON_MIDDLE; + break; + case BTN_RIGHT: + sdl_button = SDL_BUTTON_RIGHT; + break; + case BTN_SIDE: + sdl_button = SDL_BUTTON_X1; + break; + case BTN_EXTRA: + sdl_button = SDL_BUTTON_X2; + break; + default: + return; + } + + if (window) { + SDL_VideoData *viddata = window->waylandData; + bool ignore_click = false; + + if (state) { + Wayland_UpdateImplicitGrabSerial(input, serial); + input->buttons_pressed |= SDL_BUTTON_MASK(sdl_button); + } else { + input->buttons_pressed &= ~(SDL_BUTTON_MASK(sdl_button)); + } + + if (sdl_button == SDL_BUTTON_LEFT && + ProcessHitTest(input->pointer_focus, input->seat, input->sx_w, input->sy_w, serial)) { + return; // don't pass this event on to app. + } + + // Possibly ignore this click if it was to gain focus. + if (window->last_focus_event_time_ns) { + if (state == WL_POINTER_BUTTON_STATE_PRESSED && + (SDL_GetTicksNS() - window->last_focus_event_time_ns) < WAYLAND_FOCUS_CLICK_TIMEOUT_NS) { + ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); + } + + window->last_focus_event_time_ns = 0; + } + + /* Wayland won't let you "capture" the mouse, but it will automatically track + * the mouse outside the window if you drag outside of it, until you let go + * of all buttons (even if you add or remove presses outside the window, as + * long as any button is still down, the capture remains). + * + * The mouse is not captured in relative mode. + */ + if (!viddata->relative_mouse_mode) { + if (input->buttons_pressed != 0) { + window->sdlwindow->flags |= SDL_WINDOW_MOUSE_CAPTURE; + } else { + window->sdlwindow->flags &= ~SDL_WINDOW_MOUSE_CAPTURE; + } + } + + if (!ignore_click) { + SDL_SendMouseButton(timestamp, window->sdlwindow, input->pointer_id, sdl_button, down); + } + } +} + +static void pointer_handle_button(void *data, struct wl_pointer *pointer, uint32_t serial, + uint32_t time, uint32_t button, uint32_t state_w) +{ + struct SDL_WaylandInput *input = data; + + pointer_handle_button_common(input, serial, time, button, state_w); +} + +static void pointer_handle_axis_common_v1(struct SDL_WaylandInput *input, + uint32_t time, uint32_t axis, wl_fixed_t value) +{ + SDL_WindowData *window = input->pointer_focus; + const Uint64 timestamp = Wayland_GetPointerTimestamp(input, time); + const enum wl_pointer_axis a = axis; + + if (input->pointer_focus) { + float x, y; + + switch (a) { + case WL_POINTER_AXIS_VERTICAL_SCROLL: + x = 0; + y = 0 - (float)wl_fixed_to_double(value); + break; + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + x = (float)wl_fixed_to_double(value); + y = 0; + break; + default: + return; + } + + x /= WAYLAND_WHEEL_AXIS_UNIT; + y /= WAYLAND_WHEEL_AXIS_UNIT; + + SDL_SendMouseWheel(timestamp, window->sdlwindow, input->pointer_id, x, y, SDL_MOUSEWHEEL_NORMAL); + } +} + +static void pointer_handle_axis_common(struct SDL_WaylandInput *input, enum SDL_WaylandAxisEvent type, + uint32_t axis, wl_fixed_t value) +{ + const enum wl_pointer_axis a = axis; + + if (input->pointer_focus) { + switch (a) { + case WL_POINTER_AXIS_VERTICAL_SCROLL: + switch (type) { + case AXIS_EVENT_VALUE120: + /* + * High resolution scroll event. The spec doesn't state that axis_value120 + * events are limited to one per frame, so the values are accumulated. + */ + if (input->pointer_curr_axis_info.y_axis_type != AXIS_EVENT_VALUE120) { + input->pointer_curr_axis_info.y_axis_type = AXIS_EVENT_VALUE120; + input->pointer_curr_axis_info.y = 0.0f; + } + input->pointer_curr_axis_info.y += 0 - (float)wl_fixed_to_double(value); + break; + case AXIS_EVENT_DISCRETE: + /* + * This is a discrete axis event, so we process it and set the + * flag to ignore future continuous axis events in this frame. + */ + if (input->pointer_curr_axis_info.y_axis_type != AXIS_EVENT_DISCRETE) { + input->pointer_curr_axis_info.y_axis_type = AXIS_EVENT_DISCRETE; + input->pointer_curr_axis_info.y = 0 - (float)wl_fixed_to_double(value); + } + break; + case AXIS_EVENT_CONTINUOUS: + // Only process continuous events if no discrete events have been received. + if (input->pointer_curr_axis_info.y_axis_type == AXIS_EVENT_CONTINUOUS) { + input->pointer_curr_axis_info.y = 0 - (float)wl_fixed_to_double(value); + } + break; + } + break; + case WL_POINTER_AXIS_HORIZONTAL_SCROLL: + switch (type) { + case AXIS_EVENT_VALUE120: + /* + * High resolution scroll event. The spec doesn't state that axis_value120 + * events are limited to one per frame, so the values are accumulated. + */ + if (input->pointer_curr_axis_info.x_axis_type != AXIS_EVENT_VALUE120) { + input->pointer_curr_axis_info.x_axis_type = AXIS_EVENT_VALUE120; + input->pointer_curr_axis_info.x = 0.0f; + } + input->pointer_curr_axis_info.x += (float)wl_fixed_to_double(value); + break; + case AXIS_EVENT_DISCRETE: + /* + * This is a discrete axis event, so we process it and set the + * flag to ignore future continuous axis events in this frame. + */ + if (input->pointer_curr_axis_info.x_axis_type != AXIS_EVENT_DISCRETE) { + input->pointer_curr_axis_info.x_axis_type = AXIS_EVENT_DISCRETE; + input->pointer_curr_axis_info.x = (float)wl_fixed_to_double(value); + } + break; + case AXIS_EVENT_CONTINUOUS: + // Only process continuous events if no discrete events have been received. + if (input->pointer_curr_axis_info.x_axis_type == AXIS_EVENT_CONTINUOUS) { + input->pointer_curr_axis_info.x = (float)wl_fixed_to_double(value); + } + break; + } + break; + } + } +} + +static void pointer_handle_axis(void *data, struct wl_pointer *pointer, + uint32_t time, uint32_t axis, wl_fixed_t value) +{ + struct SDL_WaylandInput *input = data; + + if (wl_seat_get_version(input->seat) >= WL_POINTER_FRAME_SINCE_VERSION) { + input->pointer_curr_axis_info.timestamp_ns = Wayland_GetPointerTimestamp(input, time); + pointer_handle_axis_common(input, AXIS_EVENT_CONTINUOUS, axis, value); + } else { + pointer_handle_axis_common_v1(input, time, axis, value); + } +} + +static void pointer_handle_axis_relative_direction(void *data, struct wl_pointer *pointer, + uint32_t axis, uint32_t axis_relative_direction) +{ + struct SDL_WaylandInput *input = data; + if (axis != WL_POINTER_AXIS_VERTICAL_SCROLL) { + return; + } + switch (axis_relative_direction) { + case WL_POINTER_AXIS_RELATIVE_DIRECTION_IDENTICAL: + input->pointer_curr_axis_info.direction = SDL_MOUSEWHEEL_NORMAL; + break; + case WL_POINTER_AXIS_RELATIVE_DIRECTION_INVERTED: + input->pointer_curr_axis_info.direction = SDL_MOUSEWHEEL_FLIPPED; + break; + } +} + +static void pointer_handle_frame(void *data, struct wl_pointer *pointer) +{ + struct SDL_WaylandInput *input = data; + SDL_WindowData *window = input->pointer_focus; + float x, y; + SDL_MouseWheelDirection direction = input->pointer_curr_axis_info.direction; + + switch (input->pointer_curr_axis_info.x_axis_type) { + case AXIS_EVENT_CONTINUOUS: + x = input->pointer_curr_axis_info.x / WAYLAND_WHEEL_AXIS_UNIT; + break; + case AXIS_EVENT_DISCRETE: + x = input->pointer_curr_axis_info.x; + break; + case AXIS_EVENT_VALUE120: + x = input->pointer_curr_axis_info.x / 120.0f; + break; + default: + x = 0.0f; + break; + } + + switch (input->pointer_curr_axis_info.y_axis_type) { + case AXIS_EVENT_CONTINUOUS: + y = input->pointer_curr_axis_info.y / WAYLAND_WHEEL_AXIS_UNIT; + break; + case AXIS_EVENT_DISCRETE: + y = input->pointer_curr_axis_info.y; + break; + case AXIS_EVENT_VALUE120: + y = input->pointer_curr_axis_info.y / 120.0f; + break; + default: + y = 0.0f; + break; + } + + // clear pointer_curr_axis_info for next frame + SDL_memset(&input->pointer_curr_axis_info, 0, sizeof(input->pointer_curr_axis_info)); + + if (x != 0.0f || y != 0.0f) { + SDL_SendMouseWheel(input->pointer_curr_axis_info.timestamp_ns, + window->sdlwindow, input->pointer_id, x, y, direction); + } +} + +static void pointer_handle_axis_source(void *data, struct wl_pointer *pointer, + uint32_t axis_source) +{ + // unimplemented +} + +static void pointer_handle_axis_stop(void *data, struct wl_pointer *pointer, + uint32_t time, uint32_t axis) +{ + // unimplemented +} + +static void pointer_handle_axis_discrete(void *data, struct wl_pointer *pointer, + uint32_t axis, int32_t discrete) +{ + struct SDL_WaylandInput *input = data; + + pointer_handle_axis_common(input, AXIS_EVENT_DISCRETE, axis, wl_fixed_from_int(discrete)); +} + +static void pointer_handle_axis_value120(void *data, struct wl_pointer *pointer, + uint32_t axis, int32_t value120) +{ + struct SDL_WaylandInput *input = data; + + pointer_handle_axis_common(input, AXIS_EVENT_VALUE120, axis, wl_fixed_from_int(value120)); +} + +static const struct wl_pointer_listener pointer_listener = { + pointer_handle_enter, + pointer_handle_leave, + pointer_handle_motion, + pointer_handle_button, + pointer_handle_axis, + pointer_handle_frame, // Version 5 + pointer_handle_axis_source, // Version 5 + pointer_handle_axis_stop, // Version 5 + pointer_handle_axis_discrete, // Version 5 + pointer_handle_axis_value120, // Version 8 + pointer_handle_axis_relative_direction // Version 9 +}; + +static void relative_pointer_handle_relative_motion(void *data, + struct zwp_relative_pointer_v1 *pointer, + uint32_t time_hi, + uint32_t time_lo, + wl_fixed_t dx_w, + wl_fixed_t dy_w, + wl_fixed_t dx_unaccel_w, + wl_fixed_t dy_unaccel_w) +{ + struct SDL_WaylandInput *input = data; + SDL_VideoData *d = input->display; + SDL_WindowData *window = input->pointer_focus; + + // Relative pointer event times are in microsecond granularity. + const Uint64 timestamp = Wayland_GetEventTimestamp(SDL_US_TO_NS(((Uint64)time_hi << 32) | (Uint64)time_lo)); + + if (input->pointer_focus && d->relative_mouse_mode) { + double dx; + double dy; + if (!SDL_GetMouse()->enable_relative_system_scale) { + dx = wl_fixed_to_double(dx_unaccel_w); + dy = wl_fixed_to_double(dy_unaccel_w); + } else { + dx = wl_fixed_to_double(dx_w); + dy = wl_fixed_to_double(dy_w); + } + + SDL_SendMouseMotion(timestamp, window->sdlwindow, input->pointer_id, true, (float)dx, (float)dy); + } +} + +static const struct zwp_relative_pointer_v1_listener relative_pointer_listener = { + relative_pointer_handle_relative_motion, +}; + +static void locked_pointer_locked(void *data, + struct zwp_locked_pointer_v1 *locked_pointer) +{ +} + +static void locked_pointer_unlocked(void *data, + struct zwp_locked_pointer_v1 *locked_pointer) +{ +} + +static const struct zwp_locked_pointer_v1_listener locked_pointer_listener = { + locked_pointer_locked, + locked_pointer_unlocked, +}; + +bool Wayland_input_lock_pointer(struct SDL_WaylandInput *input, SDL_Window *window) +{ + SDL_WindowData *w = window->internal; + SDL_VideoData *d = input->display; + + if (!d->pointer_constraints || !input->pointer) { + return false; + } + + if (!w->locked_pointer) { + if (w->confined_pointer) { + // If the pointer is already confined to the surface, the lock will fail with a protocol error. + Wayland_input_unconfine_pointer(input, window); + } + + w->locked_pointer = zwp_pointer_constraints_v1_lock_pointer(d->pointer_constraints, + w->surface, + input->pointer, + NULL, + ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT); + zwp_locked_pointer_v1_add_listener(w->locked_pointer, + &locked_pointer_listener, + window); + } + + return true; +} + +bool Wayland_input_unlock_pointer(struct SDL_WaylandInput *input, SDL_Window *window) +{ + SDL_WindowData *w = window->internal; + + if (w->locked_pointer) { + zwp_locked_pointer_v1_destroy(w->locked_pointer); + w->locked_pointer = NULL; + } + + // Restore existing pointer confinement. + Wayland_input_confine_pointer(input, window); + + return true; +} + +static void pointer_confine_destroy(SDL_Window *window) +{ + SDL_WindowData *w = window->internal; + if (w->confined_pointer) { + zwp_confined_pointer_v1_destroy(w->confined_pointer); + w->confined_pointer = NULL; + } +} + +static void confined_pointer_confined(void *data, + struct zwp_confined_pointer_v1 *confined_pointer) +{ +} + +static void confined_pointer_unconfined(void *data, + struct zwp_confined_pointer_v1 *confined_pointer) +{ +} + +static const struct zwp_confined_pointer_v1_listener confined_pointer_listener = { + confined_pointer_confined, + confined_pointer_unconfined, +}; + +static void touch_handler_down(void *data, struct wl_touch *touch, uint32_t serial, + uint32_t timestamp, struct wl_surface *surface, + int id, wl_fixed_t fx, wl_fixed_t fy) +{ + struct SDL_WaylandInput *input = (struct SDL_WaylandInput *)data; + SDL_WindowData *window_data; + + // Check that this surface is valid. + if (!surface) { + return; + } + + touch_add(id, fx, fy, surface); + Wayland_UpdateImplicitGrabSerial(input, serial); + window_data = Wayland_GetWindowDataForOwnedSurface(surface); + + if (window_data) { + float x, y; + + if (window_data->current.logical_width <= 1) { + x = 0.5f; + } else { + x = (float)wl_fixed_to_double(fx) / (window_data->current.logical_width - 1); + } + if (window_data->current.logical_height <= 1) { + y = 0.5f; + } else { + y = (float)wl_fixed_to_double(fy) / (window_data->current.logical_height - 1); + } + + SDL_SetMouseFocus(window_data->sdlwindow); + + SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch, + (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_EVENT_FINGER_DOWN, x, y, 1.0f); + } +} + +static void touch_handler_up(void *data, struct wl_touch *touch, uint32_t serial, + uint32_t timestamp, int id) +{ + struct SDL_WaylandInput *input = (struct SDL_WaylandInput *)data; + wl_fixed_t fx = 0, fy = 0; + struct wl_surface *surface = NULL; + + touch_del(id, &fx, &fy, &surface); + + if (surface) { + SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface); + + if (window_data) { + const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width; + const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height; + + SDL_SendTouch(Wayland_GetTouchTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch, + (SDL_FingerID)(id + 1), window_data->sdlwindow, SDL_EVENT_FINGER_UP, x, y, 0.0f); + + /* If the seat lacks pointer focus, the seat's keyboard focus is another window or NULL, this window currently + * has mouse focus, and the surface has no active touch events, consider mouse focus to be lost. + */ + if (!input->pointer_focus && input->keyboard_focus != window_data && + SDL_GetMouseFocus() == window_data->sdlwindow && !Wayland_SurfaceHasActiveTouches(surface)) { + SDL_SetMouseFocus(NULL); + } + } + } +} + +static void touch_handler_motion(void *data, struct wl_touch *touch, uint32_t timestamp, + int id, wl_fixed_t fx, wl_fixed_t fy) +{ + struct SDL_WaylandInput *input = (struct SDL_WaylandInput *)data; + struct wl_surface *surface = NULL; + + touch_update(id, fx, fy, &surface); + + if (surface) { + SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(surface); + + if (window_data) { + const float x = (float)wl_fixed_to_double(fx) / window_data->current.logical_width; + const float y = (float)wl_fixed_to_double(fy) / window_data->current.logical_height; + + SDL_SendTouchMotion(Wayland_GetPointerTimestamp(input, timestamp), (SDL_TouchID)(uintptr_t)touch, + (SDL_FingerID)(id + 1), window_data->sdlwindow, x, y, 1.0f); + } + } +} + +static void touch_handler_frame(void *data, struct wl_touch *touch) +{ +} + +static void touch_handler_cancel(void *data, struct wl_touch *touch) +{ + struct SDL_WaylandInput *input = (struct SDL_WaylandInput *)data; + struct SDL_WaylandTouchPoint *tp, *temp; + + wl_list_for_each_safe (tp, temp, &touch_points, link) { + bool removed = false; + + if (tp->surface) { + SDL_WindowData *window_data = (SDL_WindowData *)wl_surface_get_user_data(tp->surface); + + if (window_data) { + const float x = (float)(wl_fixed_to_double(tp->fx) / window_data->current.logical_width); + const float y = (float)(wl_fixed_to_double(tp->fy) / window_data->current.logical_height); + + SDL_SendTouch(0, (SDL_TouchID)(uintptr_t)touch, + (SDL_FingerID)(tp->id + 1), window_data->sdlwindow, SDL_EVENT_FINGER_CANCELED, x, y, 0.0f); + + // Remove the touch from the list before checking for still-active touches on the surface. + WAYLAND_wl_list_remove(&tp->link); + removed = true; + + /* If the seat lacks pointer focus, the seat's keyboard focus is another window or NULL, this window currently + * has mouse focus, and the surface has no active touch events, consider mouse focus to be lost. + */ + if (!input->pointer_focus && input->keyboard_focus != window_data && + SDL_GetMouseFocus() == window_data->sdlwindow && !Wayland_SurfaceHasActiveTouches(tp->surface)) { + SDL_SetMouseFocus(NULL); + } + } + } + + if (!removed) { + WAYLAND_wl_list_remove(&tp->link); + } + SDL_free(tp); + } +} + +static const struct wl_touch_listener touch_listener = { + touch_handler_down, + touch_handler_up, + touch_handler_motion, + touch_handler_frame, + touch_handler_cancel, + NULL, // shape + NULL, // orientation +}; + +typedef struct Wayland_Keymap +{ + SDL_Keymap *keymap; + struct xkb_state *state; + SDL_Keymod modstate; +} Wayland_Keymap; + +static void Wayland_keymap_iter(struct xkb_keymap *keymap, xkb_keycode_t key, void *data) +{ + Wayland_Keymap *sdlKeymap = (Wayland_Keymap *)data; + const xkb_keysym_t *syms; + const SDL_Scancode scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_XFREE86_2, (key - 8)); + if (scancode == SDL_SCANCODE_UNKNOWN) { + return; + } + + if (WAYLAND_xkb_state_key_get_syms(sdlKeymap->state, key, &syms) > 0) { + SDL_Keycode keycode = SDL_GetKeyCodeFromKeySym(syms[0], key, sdlKeymap->modstate); + + if (!keycode) { + switch (scancode) { + case SDL_SCANCODE_RETURN: + keycode = SDLK_RETURN; + break; + case SDL_SCANCODE_ESCAPE: + keycode = SDLK_ESCAPE; + break; + case SDL_SCANCODE_BACKSPACE: + keycode = SDLK_BACKSPACE; + break; + case SDL_SCANCODE_DELETE: + keycode = SDLK_DELETE; + break; + default: + keycode = SDL_SCANCODE_TO_KEYCODE(scancode); + break; + } + } + + SDL_SetKeymapEntry(sdlKeymap->keymap, scancode, sdlKeymap->modstate, keycode); + } +} + +static void Wayland_UpdateKeymap(struct SDL_WaylandInput *input) +{ + struct Keymod_masks + { + SDL_Keymod sdl_mask; + xkb_mod_mask_t xkb_mask; + } const keymod_masks[] = { + { SDL_KMOD_NONE, 0 }, + { SDL_KMOD_SHIFT, input->xkb.idx_shift }, + { SDL_KMOD_CAPS, input->xkb.idx_caps }, + { SDL_KMOD_SHIFT | SDL_KMOD_CAPS, input->xkb.idx_shift | input->xkb.idx_caps }, + { SDL_KMOD_MODE, input->xkb.idx_mod5 }, + { SDL_KMOD_MODE | SDL_KMOD_SHIFT, input->xkb.idx_mod5 | input->xkb.idx_shift }, + { SDL_KMOD_MODE | SDL_KMOD_CAPS, input->xkb.idx_mod5 | input->xkb.idx_caps }, + { SDL_KMOD_MODE | SDL_KMOD_SHIFT | SDL_KMOD_CAPS, input->xkb.idx_mod5 | input->xkb.idx_shift | input->xkb.idx_caps }, + { SDL_KMOD_LEVEL5, input->xkb.idx_mod3 }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_SHIFT, input->xkb.idx_mod3 | input->xkb.idx_shift }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_CAPS, input->xkb.idx_mod3 | input->xkb.idx_caps }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_SHIFT | SDL_KMOD_CAPS, input->xkb.idx_mod3 | input->xkb.idx_shift | input->xkb.idx_caps }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE, input->xkb.idx_mod3 | input->xkb.idx_mod5 }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE | SDL_KMOD_SHIFT, input->xkb.idx_mod3 | input->xkb.idx_mod5 | input->xkb.idx_shift }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE | SDL_KMOD_CAPS, input->xkb.idx_mod3 | input->xkb.idx_mod5 | input->xkb.idx_caps }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE | SDL_KMOD_SHIFT | SDL_KMOD_CAPS, input->xkb.idx_mod3 | input->xkb.idx_mod5 | input->xkb.idx_shift | input->xkb.idx_caps }, + }; + + if (!input->keyboard_is_virtual) { + Wayland_Keymap keymap; + + keymap.keymap = SDL_CreateKeymap(); + if (!keymap.keymap) { + return; + } + + keymap.state = WAYLAND_xkb_state_new(input->xkb.keymap); + if (!keymap.state) { + SDL_SetError("failed to create XKB state"); + SDL_DestroyKeymap(keymap.keymap); + return; + } + + for (int i = 0; i < SDL_arraysize(keymod_masks); ++i) { + keymap.modstate = keymod_masks[i].sdl_mask; + WAYLAND_xkb_state_update_mask(keymap.state, + keymod_masks[i].xkb_mask & (input->xkb.idx_shift | input->xkb.idx_mod5 | input->xkb.idx_mod3), 0, keymod_masks[i].xkb_mask & input->xkb.idx_caps, + 0, 0, input->xkb.current_group); + WAYLAND_xkb_keymap_key_for_each(input->xkb.keymap, + Wayland_keymap_iter, + &keymap); + } + + WAYLAND_xkb_state_unref(keymap.state); + SDL_SetKeymap(keymap.keymap, true); + } else { + // Virtual keyboards use the default keymap. + SDL_SetKeymap(NULL, true); + } +} + +static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, + uint32_t format, int fd, uint32_t size) +{ + struct SDL_WaylandInput *input = data; + char *map_str; + const char *locale; + + if (!data) { + close(fd); + return; + } + + if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { + close(fd); + return; + } + + map_str = mmap(NULL, size, PROT_READ, MAP_PRIVATE, fd, 0); + if (map_str == MAP_FAILED) { + close(fd); + return; + } + + if (input->xkb.keymap != NULL) { + /* if there's already a keymap loaded, throw it away rather than leaking it before + * parsing the new one + */ + WAYLAND_xkb_keymap_unref(input->xkb.keymap); + input->xkb.keymap = NULL; + } + input->xkb.keymap = WAYLAND_xkb_keymap_new_from_string(input->display->xkb_context, + map_str, + XKB_KEYMAP_FORMAT_TEXT_V1, + 0); + munmap(map_str, size); + close(fd); + + if (!input->xkb.keymap) { + SDL_SetError("failed to compile keymap"); + return; + } + +#define GET_MOD_INDEX(mod) \ + WAYLAND_xkb_keymap_mod_get_index(input->xkb.keymap, XKB_MOD_NAME_##mod) + input->xkb.idx_shift = 1 << GET_MOD_INDEX(SHIFT); + input->xkb.idx_ctrl = 1 << GET_MOD_INDEX(CTRL); + input->xkb.idx_alt = 1 << GET_MOD_INDEX(ALT); + input->xkb.idx_gui = 1 << GET_MOD_INDEX(LOGO); + input->xkb.idx_mod3 = 1 << GET_MOD_INDEX(MOD3); + input->xkb.idx_mod5 = 1 << GET_MOD_INDEX(MOD5); + input->xkb.idx_num = 1 << GET_MOD_INDEX(NUM); + input->xkb.idx_caps = 1 << GET_MOD_INDEX(CAPS); +#undef GET_MOD_INDEX + + if (input->xkb.state != NULL) { + /* if there's already a state, throw it away rather than leaking it before + * trying to create a new one with the new keymap. + */ + WAYLAND_xkb_state_unref(input->xkb.state); + input->xkb.state = NULL; + } + input->xkb.state = WAYLAND_xkb_state_new(input->xkb.keymap); + if (!input->xkb.state) { + SDL_SetError("failed to create XKB state"); + WAYLAND_xkb_keymap_unref(input->xkb.keymap); + input->xkb.keymap = NULL; + return; + } + + /* + * Assume that a nameless layout implies a virtual keyboard with an arbitrary layout. + * TODO: Use a better method of detection? + */ + input->keyboard_is_virtual = WAYLAND_xkb_keymap_layout_get_name(input->xkb.keymap, 0) == NULL; + + // Update the keymap if changed. + if (input->xkb.current_group != XKB_GROUP_INVALID) { + Wayland_UpdateKeymap(input); + } + + /* + * See https://blogs.s-osg.org/compose-key-support-weston/ + * for further explanation on dead keys in Wayland. + */ + + // Look up the preferred locale, falling back to "C" as default + locale = SDL_getenv("LC_ALL"); + if (!locale) { + locale = SDL_getenv("LC_CTYPE"); + if (!locale) { + locale = SDL_getenv("LANG"); + if (!locale) { + locale = "C"; + } + } + } + + // Set up XKB compose table + if (input->xkb.compose_table != NULL) { + WAYLAND_xkb_compose_table_unref(input->xkb.compose_table); + input->xkb.compose_table = NULL; + } + input->xkb.compose_table = WAYLAND_xkb_compose_table_new_from_locale(input->display->xkb_context, + locale, XKB_COMPOSE_COMPILE_NO_FLAGS); + if (input->xkb.compose_table) { + // Set up XKB compose state + if (input->xkb.compose_state != NULL) { + WAYLAND_xkb_compose_state_unref(input->xkb.compose_state); + input->xkb.compose_state = NULL; + } + input->xkb.compose_state = WAYLAND_xkb_compose_state_new(input->xkb.compose_table, + XKB_COMPOSE_STATE_NO_FLAGS); + if (!input->xkb.compose_state) { + SDL_SetError("could not create XKB compose state"); + WAYLAND_xkb_compose_table_unref(input->xkb.compose_table); + input->xkb.compose_table = NULL; + } + } +} + +/* + * Virtual keyboards can have arbitrary layouts, arbitrary scancodes/keycodes, etc... + * Key presses from these devices must be looked up by their keysym value. + */ +static SDL_Scancode Wayland_GetScancodeForKey(struct SDL_WaylandInput *input, uint32_t key) +{ + SDL_Scancode scancode = SDL_SCANCODE_UNKNOWN; + + if (!input->keyboard_is_virtual) { + scancode = SDL_GetScancodeFromTable(SDL_SCANCODE_TABLE_XFREE86_2, key); + } else { + const xkb_keysym_t *syms; + if (WAYLAND_xkb_keymap_key_get_syms_by_level(input->xkb.keymap, key + 8, input->xkb.current_group, 0, &syms) > 0) { + scancode = SDL_GetScancodeFromKeySym(syms[0], key); + } + } + + return scancode; +} + +static void Wayland_ReconcileModifiers(struct SDL_WaylandInput *input, bool key_pressed) +{ + /* Handle explicit pressed modifier state. This will correct the modifier state + * if common modifier keys were remapped and the modifiers presumed to be set + * during a key press event were incorrect, or if the modifier was set to the + * pressed state via means other than pressing the physical key. + */ + if (!key_pressed) { + if (input->xkb.wl_pressed_modifiers & input->xkb.idx_shift) { + if (!(input->pressed_modifiers & SDL_KMOD_SHIFT)) { + input->pressed_modifiers |= SDL_KMOD_SHIFT; + } + } else { + input->pressed_modifiers &= ~SDL_KMOD_SHIFT; + } + + if (input->xkb.wl_pressed_modifiers & input->xkb.idx_ctrl) { + if (!(input->pressed_modifiers & SDL_KMOD_CTRL)) { + input->pressed_modifiers |= SDL_KMOD_CTRL; + } + } else { + input->pressed_modifiers &= ~SDL_KMOD_CTRL; + } + + if (input->xkb.wl_pressed_modifiers & input->xkb.idx_alt) { + if (!(input->pressed_modifiers & SDL_KMOD_ALT)) { + input->pressed_modifiers |= SDL_KMOD_ALT; + } + } else { + input->pressed_modifiers &= ~SDL_KMOD_ALT; + } + + if (input->xkb.wl_pressed_modifiers & input->xkb.idx_gui) { + if (!(input->pressed_modifiers & SDL_KMOD_GUI)) { + input->pressed_modifiers |= SDL_KMOD_GUI; + } + } else { + input->pressed_modifiers &= ~SDL_KMOD_GUI; + } + + /* Note: This is not backwards: in the default keymap, Mod5 is typically + * level 3 shift, and Mod3 is typically level 5 shift. + */ + if (input->xkb.wl_pressed_modifiers & input->xkb.idx_mod3) { + if (!(input->pressed_modifiers & SDL_KMOD_LEVEL5)) { + input->pressed_modifiers |= SDL_KMOD_LEVEL5; + } + } else { + input->pressed_modifiers &= ~SDL_KMOD_LEVEL5; + } + + if (input->xkb.wl_pressed_modifiers & input->xkb.idx_mod5) { + if (!(input->pressed_modifiers & SDL_KMOD_MODE)) { + input->pressed_modifiers |= SDL_KMOD_MODE; + } + } else { + input->pressed_modifiers &= ~SDL_KMOD_MODE; + } + } + + /* If a latch or lock was activated by a keypress, the latch/lock will + * be tied to the specific left/right key that initiated it. Otherwise, + * the ambiguous left/right combo is used. + * + * The modifier will remain active until the latch/lock is released by + * the system. + */ + if (input->xkb.wl_locked_modifiers & input->xkb.idx_shift) { + if (input->pressed_modifiers & SDL_KMOD_SHIFT) { + input->locked_modifiers &= ~SDL_KMOD_SHIFT; + input->locked_modifiers |= (input->pressed_modifiers & SDL_KMOD_SHIFT); + } else if (!(input->locked_modifiers & SDL_KMOD_SHIFT)) { + input->locked_modifiers |= SDL_KMOD_SHIFT; + } + } else { + input->locked_modifiers &= ~SDL_KMOD_SHIFT; + } + + if (input->xkb.wl_locked_modifiers & input->xkb.idx_ctrl) { + if (input->pressed_modifiers & SDL_KMOD_CTRL) { + input->locked_modifiers &= ~SDL_KMOD_CTRL; + input->locked_modifiers |= (input->pressed_modifiers & SDL_KMOD_CTRL); + } else if (!(input->locked_modifiers & SDL_KMOD_CTRL)) { + input->locked_modifiers |= SDL_KMOD_CTRL; + } + } else { + input->locked_modifiers &= ~SDL_KMOD_CTRL; + } + + if (input->xkb.wl_locked_modifiers & input->xkb.idx_alt) { + if (input->pressed_modifiers & SDL_KMOD_ALT) { + input->locked_modifiers &= ~SDL_KMOD_ALT; + input->locked_modifiers |= (input->pressed_modifiers & SDL_KMOD_ALT); + } else if (!(input->locked_modifiers & SDL_KMOD_ALT)) { + input->locked_modifiers |= SDL_KMOD_ALT; + } + } else { + input->locked_modifiers &= ~SDL_KMOD_ALT; + } + + if (input->xkb.wl_locked_modifiers & input->xkb.idx_gui) { + if (input->pressed_modifiers & SDL_KMOD_GUI) { + input->locked_modifiers &= ~SDL_KMOD_GUI; + input->locked_modifiers |= (input->pressed_modifiers & SDL_KMOD_GUI); + } else if (!(input->locked_modifiers & SDL_KMOD_GUI)) { + input->locked_modifiers |= SDL_KMOD_GUI; + } + } else { + input->locked_modifiers &= ~SDL_KMOD_GUI; + } + + // As above, this is correct: Mod3 is typically level 5 shift, and Mod5 is typically level 3 shift. + if (input->xkb.wl_locked_modifiers & input->xkb.idx_mod3) { + input->locked_modifiers |= SDL_KMOD_LEVEL5; + } else { + input->locked_modifiers &= ~SDL_KMOD_LEVEL5; + } + + if (input->xkb.wl_locked_modifiers & input->xkb.idx_mod5) { + input->locked_modifiers |= SDL_KMOD_MODE; + } else { + input->locked_modifiers &= ~SDL_KMOD_MODE; + } + + // Capslock and Numlock can only be locked, not pressed. + if (input->xkb.wl_locked_modifiers & input->xkb.idx_caps) { + input->locked_modifiers |= SDL_KMOD_CAPS; + } else { + input->locked_modifiers &= ~SDL_KMOD_CAPS; + } + + if (input->xkb.wl_locked_modifiers & input->xkb.idx_num) { + input->locked_modifiers |= SDL_KMOD_NUM; + } else { + input->locked_modifiers &= ~SDL_KMOD_NUM; + } + + SDL_SetModState(input->pressed_modifiers | input->locked_modifiers); +} + +static void Wayland_HandleModifierKeys(struct SDL_WaylandInput *input, SDL_Scancode scancode, bool pressed) +{ + const SDL_Keycode keycode = SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false); + SDL_Keymod mod; + + /* SDL clients expect modifier state to be activated at the same time as the + * source keypress, so we set pressed modifier state with the usual modifier + * keys here, as the explicit modifier event won't arrive until after the + * keypress event. If this is wrong, it will be corrected when the explicit + * modifier state is sent at a later time. + */ + switch (keycode) { + case SDLK_LSHIFT: + mod = SDL_KMOD_LSHIFT; + break; + case SDLK_RSHIFT: + mod = SDL_KMOD_RSHIFT; + break; + case SDLK_LCTRL: + mod = SDL_KMOD_LCTRL; + break; + case SDLK_RCTRL: + mod = SDL_KMOD_RCTRL; + break; + case SDLK_LALT: + mod = SDL_KMOD_LALT; + break; + case SDLK_RALT: + mod = SDL_KMOD_RALT; + break; + case SDLK_LGUI: + mod = SDL_KMOD_LGUI; + break; + case SDLK_RGUI: + mod = SDL_KMOD_RGUI; + break; + case SDLK_MODE: + mod = SDL_KMOD_MODE; + break; + case SDLK_LEVEL5_SHIFT: + mod = SDL_KMOD_LEVEL5; + break; + default: + return; + } + + if (pressed) { + input->pressed_modifiers |= mod; + } else { + input->pressed_modifiers &= ~mod; + } + + Wayland_ReconcileModifiers(input, true); +} + +static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, + uint32_t serial, struct wl_surface *surface, + struct wl_array *keys) +{ + struct SDL_WaylandInput *input = data; + SDL_WindowData *window; + uint32_t *key; + + if (!surface) { + // enter event for a window we've just destroyed + return; + } + + window = Wayland_GetWindowDataForOwnedSurface(surface); + + if (!window) { + return; + } + + input->keyboard_focus = window; + window->keyboard_device = input; + + // Restore the keyboard focus to the child popup that was holding it + SDL_SetKeyboardFocus(window->keyboard_focus ? window->keyboard_focus : window->sdlwindow); + +#ifdef SDL_USE_IME + if (!input->text_input) { + SDL_IME_SetFocus(true); + } +#endif + + Uint64 timestamp = SDL_GetTicksNS(); + window->last_focus_event_time_ns = timestamp; + + wl_array_for_each (key, keys) { + const SDL_Scancode scancode = Wayland_GetScancodeForKey(input, *key); + const SDL_Keycode keycode = SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false); + + switch (keycode) { + case SDLK_LSHIFT: + case SDLK_RSHIFT: + case SDLK_LCTRL: + case SDLK_RCTRL: + case SDLK_LALT: + case SDLK_RALT: + case SDLK_LGUI: + case SDLK_RGUI: + case SDLK_MODE: + case SDLK_LEVEL5_SHIFT: + Wayland_HandleModifierKeys(input, scancode, true); + SDL_SendKeyboardKeyIgnoreModifiers(timestamp, input->keyboard_id, *key, scancode, true); + break; + default: + break; + } + } +} + +static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, + uint32_t serial, struct wl_surface *surface) +{ + struct SDL_WaylandInput *input = data; + SDL_WindowData *wind; + SDL_Window *window = NULL; + + if (!surface) { + return; + } + + wind = Wayland_GetWindowDataForOwnedSurface(surface); + if (!wind) { + return; + } + + wind->keyboard_device = NULL; + window = wind->sdlwindow; + + // Stop key repeat before clearing keyboard focus + keyboard_repeat_clear(&input->keyboard_repeat); + + // This will release any keys still pressed + SDL_SetKeyboardFocus(NULL); + input->keyboard_focus = NULL; + + // Clear the pressed modifiers. + input->pressed_modifiers = SDL_KMOD_NONE; + +#ifdef SDL_USE_IME + if (!input->text_input) { + SDL_IME_SetFocus(false); + } +#endif + + /* If the surface had a pointer leave event while still having active touch events, it retained mouse focus. + * Clear it now if all touch events are raised. + */ + if (!input->pointer_focus && SDL_GetMouseFocus() == window && !Wayland_SurfaceHasActiveTouches(surface)) { + SDL_SetMouseFocus(NULL); + } +} + +static bool keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint32_t key, bool down, bool *handled_by_ime) +{ + SDL_WindowData *window = input->keyboard_focus; + const xkb_keysym_t *syms; + xkb_keysym_t sym; + + if (!window || window->keyboard_device != input || !input->xkb.state) { + return false; + } + + // TODO: Can this happen? + if (WAYLAND_xkb_state_key_get_syms(input->xkb.state, key + 8, &syms) != 1) { + return false; + } + sym = syms[0]; + +#ifdef SDL_USE_IME + if (SDL_IME_ProcessKeyEvent(sym, key + 8, down)) { + if (handled_by_ime) { + *handled_by_ime = true; + } + return true; + } +#endif + + if (!down) { + return false; + } + + if (input->xkb.compose_state && WAYLAND_xkb_compose_state_feed(input->xkb.compose_state, sym) == XKB_COMPOSE_FEED_ACCEPTED) { + switch (WAYLAND_xkb_compose_state_get_status(input->xkb.compose_state)) { + case XKB_COMPOSE_COMPOSING: + if (handled_by_ime) { + *handled_by_ime = true; + } + return true; + case XKB_COMPOSE_CANCELLED: + default: + sym = XKB_KEY_NoSymbol; + break; + case XKB_COMPOSE_NOTHING: + break; + case XKB_COMPOSE_COMPOSED: + sym = WAYLAND_xkb_compose_state_get_one_sym(input->xkb.compose_state); + break; + } + } + + return WAYLAND_xkb_keysym_to_utf8(sym, text, 8) > 0; +} + +static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, + uint32_t serial, uint32_t time, uint32_t key, + uint32_t state_w) +{ + struct SDL_WaylandInput *input = data; + enum wl_keyboard_key_state state = state_w; + char text[8]; + bool has_text = false; + bool handled_by_ime = false; + const Uint64 timestamp_raw_ns = Wayland_GetKeyboardTimestampRaw(input, time); + + Wayland_UpdateImplicitGrabSerial(input, serial); + + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { + SDL_Window *keyboard_focus = SDL_GetKeyboardFocus(); + if (keyboard_focus && SDL_TextInputActive(keyboard_focus)) { + has_text = keyboard_input_get_text(text, input, key, true, &handled_by_ime); + } + } else { + if (keyboard_repeat_key_is_set(&input->keyboard_repeat, key)) { + /* Send any due key repeat events before stopping the repeat and generating the key up event. + * Compute time based on the Wayland time, as it reports when the release event happened. + * Using SDL_GetTicks would be wrong, as it would report when the release event is processed, + * which may be off if the application hasn't pumped events for a while. + */ + keyboard_repeat_handle(&input->keyboard_repeat, timestamp_raw_ns - input->keyboard_repeat.wl_press_time_ns); + keyboard_repeat_clear(&input->keyboard_repeat); + } + keyboard_input_get_text(text, input, key, false, &handled_by_ime); + } + + const SDL_Scancode scancode = Wayland_GetScancodeForKey(input, key); + Wayland_HandleModifierKeys(input, scancode, state == WL_KEYBOARD_KEY_STATE_PRESSED); + Uint64 timestamp = Wayland_GetKeyboardTimestamp(input, time); + + SDL_SendKeyboardKeyIgnoreModifiers(timestamp, input->keyboard_id, key, scancode, state == WL_KEYBOARD_KEY_STATE_PRESSED); + + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { + if (has_text && !(SDL_GetModState() & SDL_KMOD_CTRL)) { + if (!handled_by_ime) { + SDL_SendKeyboardText(text); + } + } + if (input->xkb.keymap && WAYLAND_xkb_keymap_key_repeats(input->xkb.keymap, key + 8)) { + keyboard_repeat_set(&input->keyboard_repeat, input->keyboard_id, key, timestamp_raw_ns, scancode, has_text, text); + } + } +} + +static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, + uint32_t serial, uint32_t mods_depressed, + uint32_t mods_latched, uint32_t mods_locked, + uint32_t group) +{ + struct SDL_WaylandInput *input = data; + + if (input->xkb.state == NULL) { + /* if we get a modifier notification before the keymap, there's nothing we can do with the information + */ + return; + } + + WAYLAND_xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, + mods_locked, 0, 0, group); + + input->xkb.wl_pressed_modifiers = mods_depressed; + input->xkb.wl_locked_modifiers = mods_latched | mods_locked; + + Wayland_ReconcileModifiers(input, false); + + // If a key is repeating, update the text to apply the modifier. + if (keyboard_repeat_is_set(&input->keyboard_repeat)) { + char text[8]; + const uint32_t key = keyboard_repeat_get_key(&input->keyboard_repeat); + + if (keyboard_input_get_text(text, input, key, true, NULL)) { + keyboard_repeat_set_text(&input->keyboard_repeat, text); + } + } + + if (group == input->xkb.current_group) { + return; + } + + // The layout changed, remap and fire an event. Virtual keyboards use the default keymap. + input->xkb.current_group = group; + Wayland_UpdateKeymap(input); +} + +static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard, + int32_t rate, int32_t delay) +{ + struct SDL_WaylandInput *input = data; + input->keyboard_repeat.repeat_rate = SDL_clamp(rate, 0, 1000); + input->keyboard_repeat.repeat_delay_ms = delay; + input->keyboard_repeat.is_initialized = true; +} + +static const struct wl_keyboard_listener keyboard_listener = { + keyboard_handle_keymap, + keyboard_handle_enter, + keyboard_handle_leave, + keyboard_handle_key, + keyboard_handle_modifiers, + keyboard_handle_repeat_info, // Version 4 +}; + +void Wayland_input_init_relative_pointer(SDL_VideoData *d) +{ + struct SDL_WaylandInput *input = d->input; + + if (!d->relative_pointer_manager) { + return; + } + + if (input->pointer && !input->relative_pointer) { + input->relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(input->display->relative_pointer_manager, input->pointer); + zwp_relative_pointer_v1_add_listener(input->relative_pointer, + &relative_pointer_listener, + input); + } +} + +static void seat_handle_capabilities(void *data, struct wl_seat *seat, + enum wl_seat_capability caps) +{ + struct SDL_WaylandInput *input = data; + + if ((caps & WL_SEAT_CAPABILITY_POINTER) && !input->pointer) { + input->pointer = wl_seat_get_pointer(seat); + SDL_memset(&input->pointer_curr_axis_info, 0, sizeof(input->pointer_curr_axis_info)); + input->display->pointer = input->pointer; + + Wayland_CreateCursorShapeDevice(input); + + wl_pointer_set_user_data(input->pointer, input); + wl_pointer_add_listener(input->pointer, &pointer_listener, input); + + Wayland_input_init_relative_pointer(input->display); + + input->pointer_id = SDL_GetNextObjectID(); + SDL_AddMouse(input->pointer_id, WAYLAND_DEFAULT_POINTER_NAME, !input->display->initializing); + } else if (!(caps & WL_SEAT_CAPABILITY_POINTER) && input->pointer) { + if (input->relative_pointer) { + zwp_relative_pointer_v1_destroy(input->relative_pointer); + input->relative_pointer = NULL; + } + if (input->cursor_shape) { + wp_cursor_shape_device_v1_destroy(input->cursor_shape); + input->cursor_shape = NULL; + } + if (wl_pointer_get_version(input->pointer) >= WL_POINTER_RELEASE_SINCE_VERSION) { + wl_pointer_release(input->pointer); + } else { + wl_pointer_destroy(input->pointer); + } + input->pointer = NULL; + input->display->pointer = NULL; + + SDL_RemoveMouse(input->pointer_id, true); + input->pointer_id = 0; + } + + if ((caps & WL_SEAT_CAPABILITY_TOUCH) && !input->touch) { + input->touch = wl_seat_get_touch(seat); + SDL_AddTouch((SDL_TouchID)(uintptr_t)input->touch, SDL_TOUCH_DEVICE_DIRECT, "wayland_touch"); + wl_touch_set_user_data(input->touch, input); + wl_touch_add_listener(input->touch, &touch_listener, + input); + } else if (!(caps & WL_SEAT_CAPABILITY_TOUCH) && input->touch) { + SDL_DelTouch((SDL_TouchID)(intptr_t)input->touch); + wl_touch_destroy(input->touch); + input->touch = NULL; + } + + if ((caps & WL_SEAT_CAPABILITY_KEYBOARD) && !input->keyboard) { + input->keyboard = wl_seat_get_keyboard(seat); + wl_keyboard_set_user_data(input->keyboard, input); + wl_keyboard_add_listener(input->keyboard, &keyboard_listener, + input); + + input->keyboard_id = SDL_GetNextObjectID(); + SDL_AddKeyboard(input->keyboard_id, WAYLAND_DEFAULT_KEYBOARD_NAME, !input->display->initializing); + } else if (!(caps & WL_SEAT_CAPABILITY_KEYBOARD) && input->keyboard) { + wl_keyboard_destroy(input->keyboard); + input->keyboard = NULL; + + SDL_RemoveKeyboard(input->keyboard_id, true); + input->keyboard_id = 0; + } + + Wayland_RegisterTimestampListeners(input); +} + +static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) +{ + // unimplemented +} + +static const struct wl_seat_listener seat_listener = { + seat_handle_capabilities, + seat_handle_name, // Version 2 +}; + +static void data_source_handle_target(void *data, struct wl_data_source *wl_data_source, + const char *mime_type) +{ +} + +static void data_source_handle_send(void *data, struct wl_data_source *wl_data_source, + const char *mime_type, int32_t fd) +{ + Wayland_data_source_send((SDL_WaylandDataSource *)data, mime_type, fd); +} + +static void data_source_handle_cancelled(void *data, struct wl_data_source *wl_data_source) +{ + SDL_WaylandDataSource *source = data; + if (source) { + Wayland_data_source_destroy(source); + } +} + +static void data_source_handle_dnd_drop_performed(void *data, struct wl_data_source *wl_data_source) +{ +} + +static void data_source_handle_dnd_finished(void *data, struct wl_data_source *wl_data_source) +{ +} + +static void data_source_handle_action(void *data, struct wl_data_source *wl_data_source, + uint32_t dnd_action) +{ +} + +static const struct wl_data_source_listener data_source_listener = { + data_source_handle_target, + data_source_handle_send, + data_source_handle_cancelled, + data_source_handle_dnd_drop_performed, // Version 3 + data_source_handle_dnd_finished, // Version 3 + data_source_handle_action, // Version 3 +}; + +static void primary_selection_source_send(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1, + const char *mime_type, int32_t fd) +{ + Wayland_primary_selection_source_send((SDL_WaylandPrimarySelectionSource *)data, + mime_type, fd); +} + +static void primary_selection_source_cancelled(void *data, struct zwp_primary_selection_source_v1 *zwp_primary_selection_source_v1) +{ + Wayland_primary_selection_source_destroy(data); +} + +static const struct zwp_primary_selection_source_v1_listener primary_selection_source_listener = { + primary_selection_source_send, + primary_selection_source_cancelled, +}; + +SDL_WaylandDataSource *Wayland_data_source_create(SDL_VideoDevice *_this) +{ + SDL_WaylandDataSource *data_source = NULL; + SDL_VideoData *driver_data = NULL; + struct wl_data_source *id = NULL; + + if (!_this || !_this->internal) { + SDL_SetError("Video driver uninitialized"); + } else { + driver_data = _this->internal; + + if (driver_data->data_device_manager) { + id = wl_data_device_manager_create_data_source( + driver_data->data_device_manager); + } + + if (!id) { + SDL_SetError("Wayland unable to create data source"); + } else { + data_source = SDL_calloc(1, sizeof(*data_source)); + if (!data_source) { + wl_data_source_destroy(id); + } else { + data_source->source = id; + wl_data_source_set_user_data(id, data_source); + wl_data_source_add_listener(id, &data_source_listener, + data_source); + } + } + } + return data_source; +} + +SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(SDL_VideoDevice *_this) +{ + SDL_WaylandPrimarySelectionSource *primary_selection_source = NULL; + SDL_VideoData *driver_data = NULL; + struct zwp_primary_selection_source_v1 *id = NULL; + + if (!_this || !_this->internal) { + SDL_SetError("Video driver uninitialized"); + } else { + driver_data = _this->internal; + + if (driver_data->primary_selection_device_manager) { + id = zwp_primary_selection_device_manager_v1_create_source( + driver_data->primary_selection_device_manager); + } + + if (!id) { + SDL_SetError("Wayland unable to create primary selection source"); + } else { + primary_selection_source = SDL_calloc(1, sizeof(*primary_selection_source)); + if (!primary_selection_source) { + zwp_primary_selection_source_v1_destroy(id); + } else { + primary_selection_source->source = id; + zwp_primary_selection_source_v1_add_listener(id, &primary_selection_source_listener, + primary_selection_source); + } + } + } + return primary_selection_source; +} + +static void data_offer_handle_offer(void *data, struct wl_data_offer *wl_data_offer, + const char *mime_type) +{ + SDL_WaylandDataOffer *offer = data; + Wayland_data_offer_add_mime(offer, mime_type); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_offer_listener . data_offer_handle_offer on data_offer 0x%08x for MIME '%s'", + (wl_data_offer ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)wl_data_offer) : -1), + mime_type); +} + +static void data_offer_handle_source_actions(void *data, struct wl_data_offer *wl_data_offer, + uint32_t source_actions) +{ + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_offer_listener . data_offer_handle_source_actions on data_offer 0x%08x for Source Actions '%d'", + (wl_data_offer ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)wl_data_offer) : -1), + source_actions); +} + +static void data_offer_handle_actions(void *data, struct wl_data_offer *wl_data_offer, + uint32_t dnd_action) +{ + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_offer_listener . data_offer_handle_actions on data_offer 0x%08x for DND Actions '%d'", + (wl_data_offer ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)wl_data_offer) : -1), + dnd_action); +} + +static const struct wl_data_offer_listener data_offer_listener = { + data_offer_handle_offer, + data_offer_handle_source_actions, // Version 3 + data_offer_handle_actions, // Version 3 +}; + +static void primary_selection_offer_handle_offer(void *data, struct zwp_primary_selection_offer_v1 *zwp_primary_selection_offer_v1, + const char *mime_type) +{ + SDL_WaylandPrimarySelectionOffer *offer = data; + Wayland_primary_selection_offer_add_mime(offer, mime_type); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In zwp_primary_selection_offer_v1_listener . primary_selection_offer_handle_offer on primary_selection_offer 0x%08x for MIME '%s'", + (zwp_primary_selection_offer_v1 ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)zwp_primary_selection_offer_v1) : -1), + mime_type); +} + +static const struct zwp_primary_selection_offer_v1_listener primary_selection_offer_listener = { + primary_selection_offer_handle_offer, +}; + +static void data_device_handle_data_offer(void *data, struct wl_data_device *wl_data_device, + struct wl_data_offer *id) +{ + SDL_WaylandDataOffer *data_offer = SDL_calloc(1, sizeof(*data_offer)); + if (data_offer) { + data_offer->offer = id; + data_offer->data_device = data; + WAYLAND_wl_list_init(&(data_offer->mimes)); + wl_data_offer_set_user_data(id, data_offer); + wl_data_offer_add_listener(id, &data_offer_listener, data_offer); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_data_offer on data_offer 0x%08x", + (id ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)id) : -1)); + } +} + +static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_device, + uint32_t serial, struct wl_surface *surface, + wl_fixed_t x, wl_fixed_t y, struct wl_data_offer *id) +{ + SDL_WaylandDataDevice *data_device = data; + data_device->has_mime_file = false; + data_device->has_mime_text = false; + uint32_t dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_NONE; + + data_device->drag_serial = serial; + + if (id) { + data_device->drag_offer = wl_data_offer_get_user_data(id); + + // TODO: SDL Support more mime types +#ifdef SDL_USE_LIBDBUS + if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_PORTAL_MIME)) { + data_device->has_mime_file = true; + wl_data_offer_accept(id, serial, FILE_PORTAL_MIME); + } +#endif + if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_MIME)) { + data_device->has_mime_file = true; + wl_data_offer_accept(id, serial, FILE_MIME); + } + + if (Wayland_data_offer_has_mime(data_device->drag_offer, TEXT_MIME)) { + data_device->has_mime_text = true; + wl_data_offer_accept(id, serial, TEXT_MIME); + } + + // SDL only supports "copy" style drag and drop + if (data_device->has_mime_file || data_device->has_mime_text) { + dnd_action = WL_DATA_DEVICE_MANAGER_DND_ACTION_COPY; + } else { + // drag_mime is NULL this will decline the offer + wl_data_offer_accept(id, serial, NULL); + } + if (wl_data_offer_get_version(data_device->drag_offer->offer) >= + WL_DATA_OFFER_SET_ACTIONS_SINCE_VERSION) { + wl_data_offer_set_actions(data_device->drag_offer->offer, + dnd_action, dnd_action); + } + + // find the current window + if (surface) { + SDL_WindowData *window = Wayland_GetWindowDataForOwnedSurface(surface); + if (window) { + data_device->dnd_window = window->sdlwindow; + const float dx = (float)wl_fixed_to_double(x); + const float dy = (float)wl_fixed_to_double(y); + SDL_SendDropPosition(data_device->dnd_window, dx, dy); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_enter on data_offer 0x%08x at %d x %d into window %d for serial %d", + WAYLAND_wl_proxy_get_id((struct wl_proxy *)id), + wl_fixed_to_int(x), wl_fixed_to_int(y), SDL_GetWindowID(data_device->dnd_window), serial); + } else { + data_device->dnd_window = NULL; + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_enter on data_offer 0x%08x at %d x %d for serial %d", + WAYLAND_wl_proxy_get_id((struct wl_proxy *)id), + wl_fixed_to_int(x), wl_fixed_to_int(y), serial); + } + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_enter on data_offer 0x%08x at %d x %d for serial %d", + WAYLAND_wl_proxy_get_id((struct wl_proxy *)id), + wl_fixed_to_int(x), wl_fixed_to_int(y), serial); + } + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_enter on data_offer 0x%08x at %d x %d for serial %d", + -1, wl_fixed_to_int(x), wl_fixed_to_int(y), serial); + } +} + +static void data_device_handle_leave(void *data, struct wl_data_device *wl_data_device) +{ + SDL_WaylandDataDevice *data_device = data; + + if (data_device->drag_offer) { + if (data_device->dnd_window) { + SDL_SendDropComplete(data_device->dnd_window); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_leave on data_offer 0x%08x from window %d for serial %d", + WAYLAND_wl_proxy_get_id((struct wl_proxy *)data_device->drag_offer->offer), + SDL_GetWindowID(data_device->dnd_window), data_device->drag_serial); + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_leave on data_offer 0x%08x for serial %d", + WAYLAND_wl_proxy_get_id((struct wl_proxy *)data_device->drag_offer->offer), + data_device->drag_serial); + } + Wayland_data_offer_destroy(data_device->drag_offer); + data_device->drag_offer = NULL; + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_leave on data_offer 0x%08x for serial %d", + -1, -1); + } + data_device->has_mime_file = false; + data_device->has_mime_text = false; +} + +static void data_device_handle_motion(void *data, struct wl_data_device *wl_data_device, + uint32_t time, wl_fixed_t x, wl_fixed_t y) +{ + SDL_WaylandDataDevice *data_device = data; + + if (data_device->drag_offer && data_device->dnd_window && (data_device->has_mime_file || data_device->has_mime_text)) { + const float dx = (float)wl_fixed_to_double(x); + const float dy = (float)wl_fixed_to_double(y); + + /* XXX: Send the filename here if the event system ever starts passing it though. + * Any future implementation should cache the filenames, as otherwise this could + * hammer the DBus interface hundreds or even thousands of times per second. + */ + SDL_SendDropPosition(data_device->dnd_window, dx, dy); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_motion on data_offer 0x%08x at %d x %d in window %d serial %d", + WAYLAND_wl_proxy_get_id((struct wl_proxy *)data_device->drag_offer->offer), + wl_fixed_to_int(x), wl_fixed_to_int(y), + SDL_GetWindowID(data_device->dnd_window), data_device->drag_serial); + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_motion on data_offer 0x%08x at %d x %d serial %d", + -1, wl_fixed_to_int(x), wl_fixed_to_int(y), -1); + } +} + +static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_device) +{ + SDL_WaylandDataDevice *data_device = data; + + if (data_device->drag_offer && data_device->dnd_window && (data_device->has_mime_file || data_device->has_mime_text)) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_drop on data_offer 0x%08x in window %d serial %d", + WAYLAND_wl_proxy_get_id((struct wl_proxy *)data_device->drag_offer->offer), + SDL_GetWindowID(data_device->dnd_window), data_device->drag_serial); + // TODO: SDL Support more mime types + size_t length; + bool drop_handled = false; +#ifdef SDL_USE_LIBDBUS + if (Wayland_data_offer_has_mime(data_device->drag_offer, FILE_PORTAL_MIME)) { + void *buffer = Wayland_data_offer_receive(data_device->drag_offer, + FILE_PORTAL_MIME, &length); + if (buffer) { + SDL_DBusContext *dbus = SDL_DBus_GetContext(); + if (dbus) { + int path_count = 0; + char **paths = SDL_DBus_DocumentsPortalRetrieveFiles(buffer, &path_count); + // If dropped files contain a directory the list is empty + if (paths && path_count > 0) { + int i; + for (i = 0; i < path_count; i++) { + SDL_SendDropFile(data_device->dnd_window, NULL, paths[i]); + } + dbus->free_string_array(paths); + SDL_SendDropComplete(data_device->dnd_window); + drop_handled = true; + } + } + SDL_free(buffer); + } + } +#endif + /* If XDG document portal fails fallback. + * When running a flatpak sandbox this will most likely be a list of + * non paths that are not visible to the application + */ + if (!drop_handled) { + const char *mime_type = data_device->has_mime_file ? FILE_MIME : (data_device->has_mime_text ? TEXT_MIME : ""); + void *buffer = Wayland_data_offer_receive(data_device->drag_offer, + mime_type, &length); + if (data_device->has_mime_file) { + if (buffer) { + char *saveptr = NULL; + char *token = SDL_strtok_r((char *)buffer, "\r\n", &saveptr); + while (token) { + if (SDL_URIToLocal(token, token) >= 0) { + SDL_SendDropFile(data_device->dnd_window, NULL, token); + } + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + SDL_free(buffer); + SDL_SendDropComplete(data_device->dnd_window); + } else { + SDL_SendDropComplete(data_device->dnd_window); + } + drop_handled = true; + } else if (data_device->has_mime_text) { + if (buffer) { + char *saveptr = NULL; + char *token = SDL_strtok_r((char *)buffer, "\r\n", &saveptr); + while (token) { + SDL_SendDropText(data_device->dnd_window, token); + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + SDL_free(buffer); + SDL_SendDropComplete(data_device->dnd_window); + } else { + /* Even though there has been a valid data offer, + * and there have been valid Enter, Motion, and Drop callbacks, + * Wayland_data_offer_receive may return an empty buffer, + * because the data is actually in the primary selection device, + * not in the data device. + */ + SDL_SendDropComplete(data_device->dnd_window); + } + drop_handled = true; + } + } + + if (drop_handled && wl_data_offer_get_version(data_device->drag_offer->offer) >= WL_DATA_OFFER_FINISH_SINCE_VERSION) { + wl_data_offer_finish(data_device->drag_offer->offer); + } + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In wl_data_device_listener . data_device_handle_drop on data_offer 0x%08x serial %d", + -1, -1); + } + + Wayland_data_offer_destroy(data_device->drag_offer); + data_device->drag_offer = NULL; +} + +static void notifyFromMimes(struct wl_list *mimes) +{ + int nformats = 0; + char **new_mime_types = NULL; + if (mimes) { + nformats = WAYLAND_wl_list_length(mimes); + size_t alloc_size = (nformats + 1) * sizeof(char *); + + /* do a first pass to compute allocation size */ + SDL_MimeDataList *item = NULL; + wl_list_for_each(item, mimes, link) { + alloc_size += SDL_strlen(item->mime_type) + 1; + } + + new_mime_types = SDL_AllocateTemporaryMemory(alloc_size); + if (!new_mime_types) { + SDL_LogError(SDL_LOG_CATEGORY_INPUT, "unable to allocate new_mime_types"); + return; + } + + /* second pass to fill*/ + char *strPtr = (char *)(new_mime_types + nformats + 1); + item = NULL; + int i = 0; + wl_list_for_each(item, mimes, link) { + new_mime_types[i] = strPtr; + strPtr = stpcpy(strPtr, item->mime_type) + 1; + i++; + } + new_mime_types[nformats] = NULL; + } + + SDL_SendClipboardUpdate(false, new_mime_types, nformats); +} + +static void data_device_handle_selection(void *data, struct wl_data_device *wl_data_device, + struct wl_data_offer *id) +{ + SDL_WaylandDataDevice *data_device = data; + SDL_WaylandDataOffer *offer = NULL; + + if (id) { + offer = wl_data_offer_get_user_data(id); + } + + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In data_device_listener . data_device_handle_selection on data_offer 0x%08x", + (id ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)id) : -1)); + if (data_device->selection_offer != offer) { + Wayland_data_offer_destroy(data_device->selection_offer); + data_device->selection_offer = offer; + } + + notifyFromMimes(offer ? &offer->mimes : NULL); +} + +static const struct wl_data_device_listener data_device_listener = { + data_device_handle_data_offer, + data_device_handle_enter, + data_device_handle_leave, + data_device_handle_motion, + data_device_handle_drop, + data_device_handle_selection +}; + +static void primary_selection_device_handle_offer(void *data, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, + struct zwp_primary_selection_offer_v1 *id) +{ + SDL_WaylandPrimarySelectionOffer *primary_selection_offer = SDL_calloc(1, sizeof(*primary_selection_offer)); + if (primary_selection_offer) { + primary_selection_offer->offer = id; + primary_selection_offer->primary_selection_device = data; + WAYLAND_wl_list_init(&(primary_selection_offer->mimes)); + zwp_primary_selection_offer_v1_set_user_data(id, primary_selection_offer); + zwp_primary_selection_offer_v1_add_listener(id, &primary_selection_offer_listener, primary_selection_offer); + } + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In zwp_primary_selection_device_v1_listener . primary_selection_device_handle_offer on primary_selection_offer 0x%08x", + (id ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)id) : -1)); +} + +static void primary_selection_device_handle_selection(void *data, struct zwp_primary_selection_device_v1 *zwp_primary_selection_device_v1, + struct zwp_primary_selection_offer_v1 *id) +{ + SDL_WaylandPrimarySelectionDevice *primary_selection_device = data; + SDL_WaylandPrimarySelectionOffer *offer = NULL; + + if (id) { + offer = zwp_primary_selection_offer_v1_get_user_data(id); + } + + if (primary_selection_device->selection_offer != offer) { + Wayland_primary_selection_offer_destroy(primary_selection_device->selection_offer); + primary_selection_device->selection_offer = offer; + } + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In zwp_primary_selection_device_v1_listener . primary_selection_device_handle_selection on primary_selection_offer 0x%08x", + (id ? WAYLAND_wl_proxy_get_id((struct wl_proxy *)id) : -1)); +} + +static const struct zwp_primary_selection_device_v1_listener primary_selection_device_listener = { + primary_selection_device_handle_offer, + primary_selection_device_handle_selection +}; + +static void text_input_enter(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + struct wl_surface *surface) +{ + // No-op +} + +static void text_input_leave(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + struct wl_surface *surface) +{ + // No-op +} + +static void text_input_preedit_string(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + const char *text, + int32_t cursor_begin, + int32_t cursor_end) +{ + SDL_WaylandTextInput *text_input = data; + text_input->has_preedit = true; + if (text) { + int cursor_begin_utf8 = cursor_begin >= 0 ? (int)SDL_utf8strnlen(text, cursor_begin) : -1; + int cursor_end_utf8 = cursor_end >= 0 ? (int)SDL_utf8strnlen(text, cursor_end) : -1; + int cursor_size_utf8; + if (cursor_end_utf8 >= 0) { + if (cursor_begin_utf8 >= 0) { + cursor_size_utf8 = cursor_end_utf8 - cursor_begin_utf8; + } else { + cursor_size_utf8 = cursor_end_utf8; + } + } else { + cursor_size_utf8 = -1; + } + SDL_SendEditingText(text, cursor_begin_utf8, cursor_size_utf8); + } else { + SDL_SendEditingText("", 0, 0); + } +} + +static void text_input_commit_string(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + const char *text) +{ + SDL_SendKeyboardText(text); +} + +static void text_input_delete_surrounding_text(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t before_length, + uint32_t after_length) +{ + // FIXME: Do we care about this event? +} + +static void text_input_done(void *data, + struct zwp_text_input_v3 *zwp_text_input_v3, + uint32_t serial) +{ + SDL_WaylandTextInput *text_input = data; + if (!text_input->has_preedit) { + SDL_SendEditingText("", 0, 0); + } + text_input->has_preedit = false; +} + +static const struct zwp_text_input_v3_listener text_input_listener = { + text_input_enter, + text_input_leave, + text_input_preedit_string, + text_input_commit_string, + text_input_delete_surrounding_text, + text_input_done +}; + +void Wayland_create_data_device(SDL_VideoData *d) +{ + SDL_WaylandDataDevice *data_device = NULL; + + if (!d->input->seat) { + // No seat yet, will be initialized later. + return; + } + + data_device = SDL_calloc(1, sizeof(*data_device)); + if (!data_device) { + return; + } + + data_device->data_device = wl_data_device_manager_get_data_device( + d->data_device_manager, d->input->seat); + data_device->video_data = d; + + if (!data_device->data_device) { + SDL_free(data_device); + } else { + wl_data_device_set_user_data(data_device->data_device, data_device); + wl_data_device_add_listener(data_device->data_device, + &data_device_listener, data_device); + d->input->data_device = data_device; + } +} + +void Wayland_create_primary_selection_device(SDL_VideoData *d) +{ + SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; + + if (!d->input->seat) { + // No seat yet, will be initialized later. + return; + } + + primary_selection_device = SDL_calloc(1, sizeof(*primary_selection_device)); + if (!primary_selection_device) { + return; + } + + primary_selection_device->primary_selection_device = zwp_primary_selection_device_manager_v1_get_device( + d->primary_selection_device_manager, d->input->seat); + primary_selection_device->video_data = d; + + if (!primary_selection_device->primary_selection_device) { + SDL_free(primary_selection_device); + } else { + zwp_primary_selection_device_v1_set_user_data(primary_selection_device->primary_selection_device, + primary_selection_device); + zwp_primary_selection_device_v1_add_listener(primary_selection_device->primary_selection_device, + &primary_selection_device_listener, primary_selection_device); + d->input->primary_selection_device = primary_selection_device; + } +} + +static void Wayland_create_text_input(SDL_VideoData *d) +{ + SDL_WaylandTextInput *text_input = NULL; + + if (!d->input->seat) { + // No seat yet, will be initialized later. + return; + } + + text_input = SDL_calloc(1, sizeof(*text_input)); + if (!text_input) { + return; + } + + text_input->text_input = zwp_text_input_manager_v3_get_text_input( + d->text_input_manager, d->input->seat); + + if (!text_input->text_input) { + SDL_free(text_input); + } else { + zwp_text_input_v3_set_user_data(text_input->text_input, text_input); + zwp_text_input_v3_add_listener(text_input->text_input, + &text_input_listener, text_input); + d->input->text_input = text_input; + } +} + +void Wayland_create_text_input_manager(SDL_VideoData *d, uint32_t id) +{ +#ifdef HAVE_FCITX + const char *im_module = SDL_getenv("SDL_IM_MODULE"); + if (im_module && SDL_strcmp(im_module, "fcitx") == 0) { + /* Override the Wayland text-input protocol when Fcitx is enabled, like how GTK_IM_MODULE does. + * + * The Fcitx wiki discourages enabling it under Wayland via SDL_IM_MODULE, so its presence must + * be intentional, and this workaround is needed for fixing key repeat detection. + */ + return; + } +#endif + + d->text_input_manager = wl_registry_bind(d->registry, id, &zwp_text_input_manager_v3_interface, 1); + Wayland_create_text_input(d); +} + +// Pen/Tablet support... + +typedef struct SDL_WaylandPenTool // a stylus, etc, on a tablet. +{ + SDL_PenID instance_id; + SDL_PenInfo info; + SDL_Window *tool_focus; + struct zwp_tablet_tool_v2 *wltool; + float x; + float y; + bool frame_motion_set; + float frame_axes[SDL_PEN_AXIS_COUNT]; + Uint32 frame_axes_set; + int frame_pen_down; + int frame_buttons[3]; +} SDL_WaylandPenTool; + +static void tablet_tool_handle_type(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t type) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + switch (type) { + #define CASE(typ) case ZWP_TABLET_TOOL_V2_TYPE_##typ: sdltool->info.subtype = SDL_PEN_TYPE_##typ; return + CASE(ERASER); + CASE(PEN); + CASE(PENCIL); + CASE(AIRBRUSH); + CASE(BRUSH); + #undef CASE + default: sdltool->info.subtype = SDL_PEN_TYPE_UNKNOWN; // we'll decline to add this when the `done` event comes through. + } +} + +static void tablet_tool_handle_hardware_serial(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial_hi, uint32_t serial_lo) +{ + // don't care about this atm. +} + +static void tablet_tool_handle_hardware_id_wacom(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t id_hi, uint32_t id_lo) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->info.wacom_id = id_lo; +} + +static void tablet_tool_handle_capability(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t capability) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + switch (capability) { + #define CASE(wltyp,sdltyp) case ZWP_TABLET_TOOL_V2_CAPABILITY_##wltyp: sdltool->info.capabilities |= sdltyp; return + CASE(TILT, SDL_PEN_CAPABILITY_XTILT | SDL_PEN_CAPABILITY_YTILT); + CASE(PRESSURE, SDL_PEN_CAPABILITY_PRESSURE); + CASE(DISTANCE, SDL_PEN_CAPABILITY_DISTANCE); + CASE(ROTATION, SDL_PEN_CAPABILITY_ROTATION); + CASE(SLIDER, SDL_PEN_CAPABILITY_SLIDER); + #undef CASE + default: break; // unsupported here. + } +} + +static void tablet_tool_handle_done(void *data, struct zwp_tablet_tool_v2 *tool) +{ +} + +static void tablet_tool_handle_removed(void *data, struct zwp_tablet_tool_v2 *tool) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + if (sdltool->instance_id) { + SDL_RemovePenDevice(0, sdltool->instance_id); + } + zwp_tablet_tool_v2_destroy(tool); + SDL_free(sdltool); +} + +static void tablet_tool_handle_proximity_in(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial, struct zwp_tablet_v2 *tablet, struct wl_surface *surface) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + SDL_WindowData *windowdata = surface ? Wayland_GetWindowDataForOwnedSurface(surface) : NULL; + sdltool->tool_focus = windowdata ? windowdata->sdlwindow : NULL; + + SDL_assert(sdltool->instance_id == 0); // shouldn't be added at this point. + if (sdltool->info.subtype != SDL_PEN_TYPE_UNKNOWN) { // don't tell SDL about it if we don't know its role. + sdltool->instance_id = SDL_AddPenDevice(0, NULL, &sdltool->info, sdltool); + } + + // According to the docs, this should be followed by a motion event, where we'll send our SDL events. +} + +static void tablet_tool_handle_proximity_out(void *data, struct zwp_tablet_tool_v2 *tool) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->tool_focus = NULL; + + if (sdltool->instance_id) { + SDL_RemovePenDevice(0, sdltool->instance_id); + sdltool->instance_id = 0; + } +} + +static void tablet_tool_handle_down(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->frame_pen_down = 1; +} + +static void tablet_tool_handle_up(void *data, struct zwp_tablet_tool_v2 *tool) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->frame_pen_down = 0; +} + +static void tablet_tool_handle_motion(void *data, struct zwp_tablet_tool_v2 *tool, wl_fixed_t sx_w, wl_fixed_t sy_w) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + SDL_Window *window = sdltool->tool_focus; + if (window) { + const SDL_WindowData *windowdata = window->internal; + sdltool->x = (float)(wl_fixed_to_double(sx_w) * windowdata->pointer_scale.x); + sdltool->y = (float)(wl_fixed_to_double(sy_w) * windowdata->pointer_scale.y); + sdltool->frame_motion_set = true; + } +} + +static void tablet_tool_handle_pressure(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t pressure) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->frame_axes[SDL_PEN_AXIS_PRESSURE] = ((float) pressure) / 65535.0f; + sdltool->frame_axes_set |= (1u << SDL_PEN_AXIS_PRESSURE); + if (pressure) { + sdltool->frame_axes[SDL_PEN_AXIS_DISTANCE] = 0.0f; + sdltool->frame_axes_set |= (1u << SDL_PEN_AXIS_DISTANCE); + } +} + +static void tablet_tool_handle_distance(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t distance) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->frame_axes[SDL_PEN_AXIS_DISTANCE] = ((float) distance) / 65535.0f; + sdltool->frame_axes_set |= (1u << SDL_PEN_AXIS_DISTANCE); + if (distance) { + sdltool->frame_axes[SDL_PEN_AXIS_PRESSURE] = 0.0f; + sdltool->frame_axes_set |= (1u << SDL_PEN_AXIS_PRESSURE); + } +} + +static void tablet_tool_handle_tilt(void *data, struct zwp_tablet_tool_v2 *tool, wl_fixed_t xtilt, wl_fixed_t ytilt) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->frame_axes[SDL_PEN_AXIS_XTILT] = (float)(wl_fixed_to_double(xtilt)); + sdltool->frame_axes[SDL_PEN_AXIS_YTILT] = (float)(wl_fixed_to_double(ytilt)); + sdltool->frame_axes_set |= (1u << SDL_PEN_AXIS_XTILT) | (1u << SDL_PEN_AXIS_YTILT); +} + +static void tablet_tool_handle_button(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t serial, uint32_t button, uint32_t state) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + int sdlbutton; + + switch (button) { + // see %{_includedir}/linux/input-event-codes.h + case 0x14b: // BTN_STYLUS + sdlbutton = 1; + break; + case 0x14c: // BTN_STYLUS2 + sdlbutton = 2; + break; + case 0x149: // BTN_STYLUS3 + sdlbutton = 3; + break; + default: + return; // don't care about this button, I guess. + } + + SDL_assert((sdlbutton >= 1) && (sdlbutton <= SDL_arraysize(sdltool->frame_buttons))); + sdltool->frame_buttons[sdlbutton-1] = (state == ZWP_TABLET_PAD_V2_BUTTON_STATE_PRESSED) ? 1 : 0; +} + +static void tablet_tool_handle_rotation(void *data, struct zwp_tablet_tool_v2 *tool, wl_fixed_t degrees) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + const float rotation = (float)(wl_fixed_to_double(degrees)); + sdltool->frame_axes[SDL_PEN_AXIS_ROTATION] = (rotation > 180.0f) ? (rotation - 360.0f) : rotation; // map to -180.0f ... 179.0f range + sdltool->frame_axes_set |= (1u << SDL_PEN_AXIS_ROTATION); +} + +static void tablet_tool_handle_slider(void *data, struct zwp_tablet_tool_v2 *tool, int32_t position) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + sdltool->frame_axes[SDL_PEN_AXIS_SLIDER] = position / 65535.f; + sdltool->frame_axes_set |= (1u << SDL_PEN_AXIS_SLIDER); +} + +static void tablet_tool_handle_wheel(void *data, struct zwp_tablet_tool_v2 *tool, int32_t degrees, int32_t clicks) +{ + // not supported at the moment +} + +static void tablet_tool_handle_frame(void *data, struct zwp_tablet_tool_v2 *tool, uint32_t time) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) data; + + if (!sdltool->instance_id) { + return; // Not a pen we report on. + } + + const Uint64 timestamp = Wayland_GetEventTimestamp(SDL_MS_TO_NS(time)); + const SDL_PenID instance_id = sdltool->instance_id; + SDL_Window *window = sdltool->tool_focus; + + // I don't know if this is necessary (or makes sense), but send motion before pen downs, but after pen ups, so you don't get unexpected lines drawn. + if (sdltool->frame_motion_set && (sdltool->frame_pen_down != -1)) { + if (sdltool->frame_pen_down) { + SDL_SendPenMotion(timestamp, instance_id, window, sdltool->x, sdltool->y); + SDL_SendPenTouch(timestamp, instance_id, window, false, true); // !!! FIXME: how do we know what tip is in use? + } else { + SDL_SendPenTouch(timestamp, instance_id, window, false, false); // !!! FIXME: how do we know what tip is in use? + SDL_SendPenMotion(timestamp, instance_id, window, sdltool->x, sdltool->y); + } + } else { + if (sdltool->frame_pen_down != -1) { + SDL_SendPenTouch(timestamp, instance_id, window, false, (sdltool->frame_pen_down != 0)); // !!! FIXME: how do we know what tip is in use? + } + + if (sdltool->frame_motion_set) { + SDL_SendPenMotion(timestamp, instance_id, window, sdltool->x, sdltool->y); + } + } + + for (SDL_PenAxis i = 0; i < SDL_PEN_AXIS_COUNT; i++) { + if (sdltool->frame_axes_set & (1u << i)) { + SDL_SendPenAxis(timestamp, instance_id, window, i, sdltool->frame_axes[i]); + } + } + + for (int i = 0; i < SDL_arraysize(sdltool->frame_buttons); i++) { + const int state = sdltool->frame_buttons[i]; + if (state != -1) { + SDL_SendPenButton(timestamp, instance_id, window, (Uint8)(i + 1), (state != 0)); + sdltool->frame_buttons[i] = -1; + } + } + + // reset for next frame. + sdltool->frame_pen_down = -1; + sdltool->frame_motion_set = false; + sdltool->frame_axes_set = 0; +} + +static const struct zwp_tablet_tool_v2_listener tablet_tool_listener = { + tablet_tool_handle_type, + tablet_tool_handle_hardware_serial, + tablet_tool_handle_hardware_id_wacom, + tablet_tool_handle_capability, + tablet_tool_handle_done, + tablet_tool_handle_removed, + tablet_tool_handle_proximity_in, + tablet_tool_handle_proximity_out, + tablet_tool_handle_down, + tablet_tool_handle_up, + tablet_tool_handle_motion, + tablet_tool_handle_pressure, + tablet_tool_handle_distance, + tablet_tool_handle_tilt, + tablet_tool_handle_rotation, + tablet_tool_handle_slider, + tablet_tool_handle_wheel, + tablet_tool_handle_button, + tablet_tool_handle_frame +}; + + +static void tablet_seat_handle_tablet_added(void *data, struct zwp_tablet_seat_v2 *seat, struct zwp_tablet_v2 *tablet) +{ + // don't care atm. +} + +static void tablet_seat_handle_tool_added(void *data, struct zwp_tablet_seat_v2 *seat, struct zwp_tablet_tool_v2 *tool) +{ + SDL_WaylandPenTool *sdltool = SDL_calloc(1, sizeof(*sdltool)); + + if (sdltool) { // if allocation failed, oh well, we won't report this device. + sdltool->wltool = tool; + sdltool->info.max_tilt = -1.0f; + sdltool->info.num_buttons = -1; + sdltool->frame_pen_down = -1; + for (int i = 0; i < SDL_arraysize(sdltool->frame_buttons); i++) { + sdltool->frame_buttons[i] = -1; + } + + // this will send a bunch of zwp_tablet_tool_v2 events right up front to tell + // us device details, with a "done" event to let us know we have everything. + zwp_tablet_tool_v2_add_listener(tool, &tablet_tool_listener, sdltool); + } +} + +static void tablet_seat_handle_pad_added(void *data, struct zwp_tablet_seat_v2 *seat, struct zwp_tablet_pad_v2 *pad) +{ + // we don't care atm. +} + +static const struct zwp_tablet_seat_v2_listener tablet_seat_listener = { + tablet_seat_handle_tablet_added, + tablet_seat_handle_tool_added, + tablet_seat_handle_pad_added +}; + +void Wayland_input_init_tablet_support(struct SDL_WaylandInput *input, struct zwp_tablet_manager_v2 *tablet_manager) +{ + if (!tablet_manager || !input->seat) { + return; + } + + SDL_WaylandTabletInput *tablet_input = SDL_calloc(1, sizeof(*tablet_input)); + if (!tablet_input) { + return; + } + + tablet_input->input = input; + tablet_input->seat = zwp_tablet_manager_v2_get_tablet_seat(tablet_manager, input->seat); + + zwp_tablet_seat_v2_add_listener(tablet_input->seat, &tablet_seat_listener, tablet_input); + + input->tablet_input = tablet_input; +} + +static void Wayland_remove_all_pens_callback(SDL_PenID instance_id, void *handle, void *userdata) +{ + SDL_WaylandPenTool *sdltool = (SDL_WaylandPenTool *) handle; + zwp_tablet_tool_v2_destroy(sdltool->wltool); + SDL_free(sdltool); +} + +void Wayland_input_quit_tablet_support(struct SDL_WaylandInput *input) +{ + SDL_RemoveAllPenDevices(Wayland_remove_all_pens_callback, NULL); + + if (input && input->tablet_input) { + zwp_tablet_seat_v2_destroy(input->tablet_input->seat); + SDL_free(input->tablet_input); + input->tablet_input = NULL; + } +} + +void Wayland_input_initialize_seat(SDL_VideoData *d) +{ + struct SDL_WaylandInput *input = d->input; + + WAYLAND_wl_list_init(&touch_points); + + if (d->data_device_manager) { + Wayland_create_data_device(d); + } + if (d->primary_selection_device_manager) { + Wayland_create_primary_selection_device(d); + } + if (d->text_input_manager) { + Wayland_create_text_input(d); + } + + wl_seat_add_listener(input->seat, &seat_listener, input); + wl_seat_set_user_data(input->seat, input); + + if (d->tablet_manager) { + Wayland_input_init_tablet_support(d->input, d->tablet_manager); + } + + WAYLAND_wl_display_flush(d->display); +} + +void Wayland_display_destroy_input(SDL_VideoData *d) +{ + struct SDL_WaylandInput *input = d->input; + + if (input->keyboard_timestamps) { + zwp_input_timestamps_v1_destroy(input->keyboard_timestamps); + } + if (input->pointer_timestamps) { + zwp_input_timestamps_v1_destroy(input->pointer_timestamps); + } + if (input->touch_timestamps) { + zwp_input_timestamps_v1_destroy(input->touch_timestamps); + } + + if (input->data_device) { + Wayland_data_device_clear_selection(input->data_device); + if (input->data_device->selection_offer) { + Wayland_data_offer_destroy(input->data_device->selection_offer); + } + if (input->data_device->drag_offer) { + Wayland_data_offer_destroy(input->data_device->drag_offer); + } + if (input->data_device->data_device) { + if (wl_data_device_get_version(input->data_device->data_device) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION) { + wl_data_device_release(input->data_device->data_device); + } else { + wl_data_device_destroy(input->data_device->data_device); + } + } + SDL_free(input->data_device); + } + + if (input->primary_selection_device) { + if (input->primary_selection_device->selection_offer) { + Wayland_primary_selection_offer_destroy(input->primary_selection_device->selection_offer); + } + if (input->primary_selection_device->selection_source) { + Wayland_primary_selection_source_destroy(input->primary_selection_device->selection_source); + } + if (input->primary_selection_device->primary_selection_device) { + zwp_primary_selection_device_v1_destroy(input->primary_selection_device->primary_selection_device); + } + SDL_free(input->primary_selection_device); + } + + if (input->text_input) { + zwp_text_input_v3_destroy(input->text_input->text_input); + SDL_free(input->text_input); + } + + if (input->keyboard) { + if (wl_keyboard_get_version(input->keyboard) >= WL_KEYBOARD_RELEASE_SINCE_VERSION) { + wl_keyboard_release(input->keyboard); + } else { + wl_keyboard_destroy(input->keyboard); + } + } + + if (input->relative_pointer) { + zwp_relative_pointer_v1_destroy(input->relative_pointer); + } + + if (input->cursor_shape) { + wp_cursor_shape_device_v1_destroy(input->cursor_shape); + } + + if (input->pointer) { + if (wl_pointer_get_version(input->pointer) >= WL_POINTER_RELEASE_SINCE_VERSION) { + wl_pointer_release(input->pointer); + } else { + wl_pointer_destroy(input->pointer); + } + } + + if (input->touch) { + struct SDL_WaylandTouchPoint *tp, *tmp; + + SDL_DelTouch(1); + if (wl_touch_get_version(input->touch) >= WL_TOUCH_RELEASE_SINCE_VERSION) { + wl_touch_release(input->touch); + } else { + wl_touch_destroy(input->touch); + } + + wl_list_for_each_safe (tp, tmp, &touch_points, link) { + WAYLAND_wl_list_remove(&tp->link); + SDL_free(tp); + } + } + + if (input->tablet_input) { + Wayland_input_quit_tablet_support(input); + } + + if (input->seat) { + if (wl_seat_get_version(input->seat) >= WL_SEAT_RELEASE_SINCE_VERSION) { + wl_seat_release(input->seat); + } else { + wl_seat_destroy(input->seat); + } + } + + if (input->xkb.compose_state) { + WAYLAND_xkb_compose_state_unref(input->xkb.compose_state); + } + + if (input->xkb.compose_table) { + WAYLAND_xkb_compose_table_unref(input->xkb.compose_table); + } + + if (input->xkb.state) { + WAYLAND_xkb_state_unref(input->xkb.state); + } + + if (input->xkb.keymap) { + WAYLAND_xkb_keymap_unref(input->xkb.keymap); + } + + SDL_free(input); + d->input = NULL; +} + +bool Wayland_input_enable_relative_pointer(struct SDL_WaylandInput *input) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *d = input->display; + SDL_Window *window; + + if (!d->relative_pointer_manager) { + return false; + } + + if (!d->pointer_constraints) { + return false; + } + + if (!input->pointer) { + return false; + } + + /* If we have a pointer confine active, we must destroy it here because + * creating a locked pointer otherwise would be a protocol error. + */ + for (window = vd->windows; window; window = window->next) { + pointer_confine_destroy(window); + } + + for (window = vd->windows; window; window = window->next) { + Wayland_input_lock_pointer(input, window); + } + + d->relative_mouse_mode = 1; + + return true; +} + +bool Wayland_input_disable_relative_pointer(struct SDL_WaylandInput *input) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *d = input->display; + SDL_Window *window; + + for (window = vd->windows; window; window = window->next) { + Wayland_input_unlock_pointer(input, window); + } + + d->relative_mouse_mode = 0; + + for (window = vd->windows; window; window = window->next) { + Wayland_input_confine_pointer(input, window); + } + + return true; +} + +bool Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *window) +{ + SDL_WindowData *w = window->internal; + SDL_VideoData *d = input->display; + struct wl_region *confine_rect; + + if (!d->pointer_constraints) { + return SDL_SetError("Failed to confine pointer: compositor lacks support for the required zwp_pointer_constraints_v1 protocol"); + } + + if (!input->pointer) { + return SDL_SetError("No pointer to confine"); + } + + /* A confine may already be active, in which case we should destroy it and + * create a new one. + */ + pointer_confine_destroy(window); + + /* We cannot create a confine if the pointer is already locked. Defer until + * the pointer is unlocked. + */ + if (d->relative_mouse_mode) { + return true; + } + + // Don't confine the pointer if it shouldn't be confined. + if (SDL_RectEmpty(&window->mouse_rect) && !(window->flags & SDL_WINDOW_MOUSE_GRABBED)) { + return true; + } + + if (SDL_RectEmpty(&window->mouse_rect)) { + confine_rect = NULL; + } else { + SDL_Rect scaled_mouse_rect; + + scaled_mouse_rect.x = (int)SDL_floor(window->mouse_rect.x / w->pointer_scale.x); + scaled_mouse_rect.y = (int)SDL_floor(window->mouse_rect.y / w->pointer_scale.y); + scaled_mouse_rect.w = (int)SDL_ceil(window->mouse_rect.w / w->pointer_scale.x); + scaled_mouse_rect.h = (int)SDL_ceil(window->mouse_rect.h / w->pointer_scale.y); + + confine_rect = wl_compositor_create_region(d->compositor); + wl_region_add(confine_rect, + scaled_mouse_rect.x, + scaled_mouse_rect.y, + scaled_mouse_rect.w, + scaled_mouse_rect.h); + } + + struct zwp_confined_pointer_v1 *confined_pointer = + zwp_pointer_constraints_v1_confine_pointer(d->pointer_constraints, + w->surface, + input->pointer, + confine_rect, + ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT); + zwp_confined_pointer_v1_add_listener(confined_pointer, + &confined_pointer_listener, + window); + + if (confine_rect) { + wl_region_destroy(confine_rect); + } + + w->confined_pointer = confined_pointer; + return true; +} + +bool Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input, SDL_Window *window) +{ + pointer_confine_destroy(window); + return true; +} + +bool Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input) +{ + SDL_WindowData *w = window->internal; + SDL_VideoData *d = input->display; + + if (!d->key_inhibitor_manager) { + return SDL_SetError("Failed to grab keyboard: compositor lacks support for the required zwp_keyboard_shortcuts_inhibit_manager_v1 protocol"); + } + + if (w->key_inhibitor) { + return true; + } + + w->key_inhibitor = + zwp_keyboard_shortcuts_inhibit_manager_v1_inhibit_shortcuts(d->key_inhibitor_manager, + w->surface, + input->seat); + + return true; +} + +bool Wayland_input_ungrab_keyboard(SDL_Window *window) +{ + SDL_WindowData *w = window->internal; + + if (w->key_inhibitor) { + zwp_keyboard_shortcuts_inhibitor_v1_destroy(w->key_inhibitor); + w->key_inhibitor = NULL; + } + + return true; +} + +void Wayland_UpdateImplicitGrabSerial(struct SDL_WaylandInput *input, Uint32 serial) +{ + if (serial > input->last_implicit_grab_serial) { + input->last_implicit_grab_serial = serial; + Wayland_data_device_set_serial(input->data_device, serial); + Wayland_primary_selection_device_set_serial(input->primary_selection_device, serial); + } +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h new file mode 100644 index 0000000..6158882 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandevents_c.h @@ -0,0 +1,195 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_waylandevents_h_ +#define SDL_waylandevents_h_ + +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_pen_c.h" + +#include "SDL_waylandvideo.h" +#include "SDL_waylandwindow.h" +#include "SDL_waylanddatamanager.h" +#include "SDL_waylandkeyboard.h" + +enum SDL_WaylandAxisEvent +{ + AXIS_EVENT_CONTINUOUS = 0, + AXIS_EVENT_DISCRETE, + AXIS_EVENT_VALUE120 +}; + +struct SDL_WaylandTabletSeat; + +typedef struct SDL_WaylandTabletInput +{ + struct SDL_WaylandInput *input; + struct zwp_tablet_seat_v2 *seat; +} SDL_WaylandTabletInput; + +typedef struct +{ + int32_t repeat_rate; // Repeat rate in range of [1, 1000] character(s) per second + int32_t repeat_delay_ms; // Time to first repeat event in milliseconds + Uint32 keyboard_id; // ID of the source keyboard. + bool is_initialized; + + bool is_key_down; + uint32_t key; + Uint64 wl_press_time_ns; // Key press time as reported by the Wayland API + Uint64 sdl_press_time_ns; // Key press time expressed in SDL ticks + Uint64 next_repeat_ns; // Next repeat event in nanoseconds + uint32_t scancode; + char text[8]; +} SDL_WaylandKeyboardRepeat; + +struct SDL_WaylandInput +{ + SDL_VideoData *display; + struct wl_seat *seat; + struct wl_pointer *pointer; + struct wl_touch *touch; + struct wl_keyboard *keyboard; + SDL_WaylandDataDevice *data_device; + SDL_WaylandPrimarySelectionDevice *primary_selection_device; + SDL_WaylandTextInput *text_input; + struct wp_cursor_shape_device_v1 *cursor_shape; + struct zwp_relative_pointer_v1 *relative_pointer; + struct zwp_input_timestamps_v1 *keyboard_timestamps; + struct zwp_input_timestamps_v1 *pointer_timestamps; + struct zwp_input_timestamps_v1 *touch_timestamps; + SDL_WindowData *pointer_focus; + SDL_WindowData *keyboard_focus; + SDL_CursorData *current_cursor; + SDL_KeyboardID keyboard_id; + SDL_MouseID pointer_id; + uint32_t pointer_enter_serial; + + // High-resolution event timestamps + Uint64 keyboard_timestamp_ns; + Uint64 pointer_timestamp_ns; + Uint64 touch_timestamp_ns; + + // Last motion location + wl_fixed_t sx_w; + wl_fixed_t sy_w; + + SDL_MouseButtonFlags buttons_pressed; + + // The serial of the last implicit grab event for window activation and selection data. + Uint32 last_implicit_grab_serial; + + struct + { + struct xkb_keymap *keymap; + struct xkb_state *state; + struct xkb_compose_table *compose_table; + struct xkb_compose_state *compose_state; + + // Keyboard layout "group" + uint32_t current_group; + + // Modifier bitshift values + uint32_t idx_shift; + uint32_t idx_ctrl; + uint32_t idx_alt; + uint32_t idx_gui; + uint32_t idx_mod3; + uint32_t idx_mod5; + uint32_t idx_num; + uint32_t idx_caps; + + // Current system modifier flags + uint32_t wl_pressed_modifiers; + uint32_t wl_locked_modifiers; + } xkb; + + // information about axis events on current frame + struct + { + enum SDL_WaylandAxisEvent x_axis_type; + float x; + + enum SDL_WaylandAxisEvent y_axis_type; + float y; + + // Event timestamp in nanoseconds + Uint64 timestamp_ns; + SDL_MouseWheelDirection direction; + } pointer_curr_axis_info; + + SDL_WaylandKeyboardRepeat keyboard_repeat; + + SDL_WaylandTabletInput *tablet_input; + + bool keyboard_is_virtual; + + // Current SDL modifier flags + SDL_Keymod pressed_modifiers; + SDL_Keymod locked_modifiers; +}; + + +extern Uint64 Wayland_GetTouchTimestamp(struct SDL_WaylandInput *input, Uint32 wl_timestamp_ms); + +extern void Wayland_PumpEvents(SDL_VideoDevice *_this); +extern void Wayland_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); +extern int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); + +extern void Wayland_create_data_device(SDL_VideoData *d); +extern void Wayland_create_primary_selection_device(SDL_VideoData *d); + +extern void Wayland_create_text_input_manager(SDL_VideoData *d, uint32_t id); + +extern void Wayland_input_initialize_seat(SDL_VideoData *d); +extern void Wayland_display_destroy_input(SDL_VideoData *d); + +extern void Wayland_input_init_relative_pointer(SDL_VideoData *d); +extern bool Wayland_input_enable_relative_pointer(struct SDL_WaylandInput *input); +extern bool Wayland_input_disable_relative_pointer(struct SDL_WaylandInput *input); + +extern bool Wayland_input_lock_pointer(struct SDL_WaylandInput *input, SDL_Window *window); +extern bool Wayland_input_unlock_pointer(struct SDL_WaylandInput *input, SDL_Window *window); + +extern bool Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *window); +extern bool Wayland_input_unconfine_pointer(struct SDL_WaylandInput *input, SDL_Window *window); + +extern bool Wayland_input_grab_keyboard(SDL_Window *window, struct SDL_WaylandInput *input); +extern bool Wayland_input_ungrab_keyboard(SDL_Window *window); + +extern void Wayland_input_init_tablet_support(struct SDL_WaylandInput *input, struct zwp_tablet_manager_v2 *tablet_manager); +extern void Wayland_input_quit_tablet_support(struct SDL_WaylandInput *input); + +extern void Wayland_RegisterTimestampListeners(struct SDL_WaylandInput *input); +extern void Wayland_CreateCursorShapeDevice(struct SDL_WaylandInput *input); + +/* The implicit grab serial needs to be updated on: + * - Keyboard key down/up + * - Mouse button down + * - Touch event down + * - Tablet tool down + * - Tablet tool button down/up + */ +extern void Wayland_UpdateImplicitGrabSerial(struct SDL_WaylandInput *input, Uint32 serial); + +#endif // SDL_waylandevents_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.c new file mode 100644 index 0000000..df1628c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.c @@ -0,0 +1,209 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if SDL_VIDEO_DRIVER_WAYLAND + +#include "../SDL_sysvideo.h" +#include "SDL_waylandvideo.h" +#include "SDL_waylandevents_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "text-input-unstable-v3-client-protocol.h" + +bool Wayland_InitKeyboard(SDL_VideoDevice *_this) +{ +#ifdef SDL_USE_IME + SDL_VideoData *internal = _this->internal; + if (!internal->text_input_manager) { + SDL_IME_Init(); + } +#endif + SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); + + return true; +} + +void Wayland_QuitKeyboard(SDL_VideoDevice *_this) +{ +#ifdef SDL_USE_IME + SDL_VideoData *internal = _this->internal; + if (!internal->text_input_manager) { + SDL_IME_Quit(); + } +#endif +} + +bool Wayland_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + SDL_VideoData *internal = _this->internal; + struct SDL_WaylandInput *input = internal->input; + + if (internal->text_input_manager) { + if (input && input->text_input) { + const SDL_Rect *rect = &input->text_input->cursor_rect; + enum zwp_text_input_v3_content_hint hint = ZWP_TEXT_INPUT_V3_CONTENT_HINT_NONE; + enum zwp_text_input_v3_content_purpose purpose; + + switch (SDL_GetTextInputType(props)) { + default: + case SDL_TEXTINPUT_TYPE_TEXT: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_NAME: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NAME; + break; + case SDL_TEXTINPUT_TYPE_TEXT_EMAIL: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_EMAIL; + break; + case SDL_TEXTINPUT_TYPE_TEXT_USERNAME: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NORMAL; + hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_SENSITIVE_DATA; + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_HIDDEN: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PASSWORD; + hint |= (ZWP_TEXT_INPUT_V3_CONTENT_HINT_HIDDEN_TEXT | ZWP_TEXT_INPUT_V3_CONTENT_HINT_SENSITIVE_DATA); + break; + case SDL_TEXTINPUT_TYPE_TEXT_PASSWORD_VISIBLE: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PASSWORD; + hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_SENSITIVE_DATA; + break; + case SDL_TEXTINPUT_TYPE_NUMBER: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_NUMBER; + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PIN; + hint |= (ZWP_TEXT_INPUT_V3_CONTENT_HINT_HIDDEN_TEXT | ZWP_TEXT_INPUT_V3_CONTENT_HINT_SENSITIVE_DATA); + break; + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE: + purpose = ZWP_TEXT_INPUT_V3_CONTENT_PURPOSE_PIN; + hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_SENSITIVE_DATA; + break; + } + + switch (SDL_GetTextInputCapitalization(props)) { + default: + case SDL_CAPITALIZE_NONE: + break; + case SDL_CAPITALIZE_LETTERS: + hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_UPPERCASE; + break; + case SDL_CAPITALIZE_WORDS: + hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_TITLECASE; + break; + case SDL_CAPITALIZE_SENTENCES: + hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_AUTO_CAPITALIZATION; + break; + } + + if (SDL_GetTextInputAutocorrect(props)) { + hint |= (ZWP_TEXT_INPUT_V3_CONTENT_HINT_COMPLETION | ZWP_TEXT_INPUT_V3_CONTENT_HINT_SPELLCHECK); + } + if (SDL_GetTextInputMultiline(props)) { + hint |= ZWP_TEXT_INPUT_V3_CONTENT_HINT_MULTILINE; + } + + zwp_text_input_v3_enable(input->text_input->text_input); + + // Now that it's enabled, set the input properties + zwp_text_input_v3_set_content_type(input->text_input->text_input, hint, purpose); + if (!SDL_RectEmpty(rect)) { + // This gets reset on enable so we have to cache it + zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, + rect->x, + rect->y, + rect->w, + rect->h); + } + zwp_text_input_v3_commit(input->text_input->text_input); + } + } + + if (input && input->xkb.compose_state) { + // Reset compose state so composite and dead keys don't carry over + WAYLAND_xkb_compose_state_reset(input->xkb.compose_state); + } + + return Wayland_UpdateTextInputArea(_this, window); +} + +bool Wayland_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *internal = _this->internal; + struct SDL_WaylandInput *input = internal->input; + + if (internal->text_input_manager) { + if (input && input->text_input) { + zwp_text_input_v3_disable(input->text_input->text_input); + zwp_text_input_v3_commit(input->text_input->text_input); + } + } +#ifdef SDL_USE_IME + else { + SDL_IME_Reset(); + } +#endif + + if (input && input->xkb.compose_state) { + // Reset compose state so composite and dead keys don't carry over + WAYLAND_xkb_compose_state_reset(input->xkb.compose_state); + } + return true; +} + +bool Wayland_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *internal = _this->internal; + if (internal->text_input_manager) { + struct SDL_WaylandInput *input = internal->input; + if (input && input->text_input) { + if (!SDL_RectsEqual(&window->text_input_rect, &input->text_input->cursor_rect)) { + SDL_copyp(&input->text_input->cursor_rect, &window->text_input_rect); + zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, + window->text_input_rect.x, + window->text_input_rect.y, + window->text_input_rect.w, + window->text_input_rect.h); + zwp_text_input_v3_commit(input->text_input->text_input); + } + } + } + +#ifdef SDL_USE_IME + else { + SDL_IME_UpdateTextInputArea(window); + } +#endif + return true; +} + +bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + /* In reality we just want to return true when the screen keyboard is the + * _only_ way to get text input. So, in addition to checking for the text + * input protocol, make sure we don't have any physical keyboards either. + */ + SDL_VideoData *internal = _this->internal; + bool haskeyboard = (internal->input != NULL) && (internal->input->keyboard != NULL); + bool hastextmanager = (internal->text_input_manager != NULL); + return !haskeyboard && hastextmanager; +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.h new file mode 100644 index 0000000..f570edb --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandkeyboard.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_waylandkeyboard_h_ +#define SDL_waylandkeyboard_h_ + +typedef struct SDL_WaylandTextInput +{ + struct zwp_text_input_v3 *text_input; + SDL_Rect cursor_rect; + bool has_preedit; +} SDL_WaylandTextInput; + +extern bool Wayland_InitKeyboard(SDL_VideoDevice *_this); +extern void Wayland_QuitKeyboard(SDL_VideoDevice *_this); +extern bool Wayland_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern bool Wayland_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_HasScreenKeyboardSupport(SDL_VideoDevice *_this); + +#endif // SDL_waylandkeyboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.c new file mode 100644 index 0000000..3d6f1f8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.c @@ -0,0 +1,196 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include "SDL_waylandmessagebox.h" + +#define ZENITY_VERSION_LEN 32 // Number of bytes to read from zenity --version (including NUL) + +#define MAX_BUTTONS 8 // Maximum number of buttons supported + +static bool parse_zenity_version(const char *version, int *major, int *minor) +{ + /* We expect the version string is in the form of MAJOR.MINOR.MICRO + * as described in meson.build. We'll ignore everything after that. + */ + const char *version_ptr = version; + char *end_ptr = NULL; + int tmp = (int) SDL_strtol(version_ptr, &end_ptr, 10); + if (tmp == 0 && end_ptr == version_ptr) { + return SDL_SetError("failed to get zenity major version number"); + } + *major = tmp; + + if (*end_ptr == '.') { + version_ptr = end_ptr + 1; // skip the dot + tmp = (int) SDL_strtol(version_ptr, &end_ptr, 10); + if (tmp == 0 && end_ptr == version_ptr) { + return SDL_SetError("failed to get zenity minor version number"); + } + *minor = tmp; + } else { + *minor = 0; + } + return true; +} + +static bool get_zenity_version(int *major, int *minor) +{ + const char *argv[] = { "zenity", "--version", NULL }; + bool result = false; + + SDL_Process *process = SDL_CreateProcess(argv, true); + if (!process) { + return false; + } + + char *output = SDL_ReadProcess(process, NULL, NULL); + if (output) { + result = parse_zenity_version(output, major, minor); + SDL_free(output); + } + SDL_DestroyProcess(process); + + return result; +} + +bool Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + int zenity_major = 0, zenity_minor = 0, output_len = 0; + int argc = 5, i; + const char *argv[5 + 2 /* icon name */ + 2 /* title */ + 2 /* message */ + 2 * MAX_BUTTONS + 1 /* NULL */] = { + "zenity", "--question", "--switch", "--no-wrap", "--no-markup" + }; + SDL_Process *process; + + // Are we trying to connect to or are currently in a Wayland session? + if (!SDL_getenv("WAYLAND_DISPLAY")) { + const char *session = SDL_getenv("XDG_SESSION_TYPE"); + if (session && SDL_strcasecmp(session, "wayland") != 0) { + return SDL_SetError("Not on a wayland display"); + } + } + + if (messageboxdata->numbuttons > MAX_BUTTONS) { + return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS); + } + + // get zenity version so we know which arg to use + if (!get_zenity_version(&zenity_major, &zenity_minor)) { + return false; // get_zenity_version() calls SDL_SetError(), so message is already set + } + + /* https://gitlab.gnome.org/GNOME/zenity/-/commit/c686bdb1b45e95acf010efd9ca0c75527fbb4dea + * This commit removed --icon-name without adding a deprecation notice. + * We need to handle it gracefully, otherwise no message box will be shown. + */ + argv[argc++] = zenity_major > 3 || (zenity_major == 3 && zenity_minor >= 90) ? "--icon" : "--icon-name"; + switch (messageboxdata->flags & (SDL_MESSAGEBOX_ERROR | SDL_MESSAGEBOX_WARNING | SDL_MESSAGEBOX_INFORMATION)) { + case SDL_MESSAGEBOX_ERROR: + argv[argc++] = "dialog-error"; + break; + case SDL_MESSAGEBOX_WARNING: + argv[argc++] = "dialog-warning"; + break; + case SDL_MESSAGEBOX_INFORMATION: + default: + argv[argc++] = "dialog-information"; + break; + } + + if (messageboxdata->title && messageboxdata->title[0]) { + argv[argc++] = "--title"; + argv[argc++] = messageboxdata->title; + } else { + argv[argc++] = "--title="; + } + + if (messageboxdata->message && messageboxdata->message[0]) { + argv[argc++] = "--text"; + argv[argc++] = messageboxdata->message; + } else { + argv[argc++] = "--text="; + } + + for (i = 0; i < messageboxdata->numbuttons; ++i) { + if (messageboxdata->buttons[i].text && messageboxdata->buttons[i].text[0]) { + int len = SDL_strlen(messageboxdata->buttons[i].text); + if (len > output_len) { + output_len = len; + } + + argv[argc++] = "--extra-button"; + argv[argc++] = messageboxdata->buttons[i].text; + } else { + argv[argc++] = "--extra-button="; + } + } + if (messageboxdata->numbuttons == 0) { + argv[argc++] = "--extra-button=OK"; + } + argv[argc] = NULL; + + SDL_PropertiesID props = SDL_CreateProperties(); + if (!props) { + return false; + } + SDL_SetPointerProperty(props, SDL_PROP_PROCESS_CREATE_ARGS_POINTER, argv); + // If buttonID is set we need to wait and read the results + if (buttonID) { + SDL_SetNumberProperty(props, SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER, SDL_PROCESS_STDIO_APP); + } else { + SDL_SetNumberProperty(props, SDL_PROP_PROCESS_CREATE_STDOUT_NUMBER, SDL_PROCESS_STDIO_NULL); + } + process = SDL_CreateProcessWithProperties(props); + SDL_DestroyProperties(props); + if (!process) { + return false; + } + if (buttonID) { + char *output = SDL_ReadProcess(process, NULL, NULL); + if (output) { + // It likes to add a newline... + char *tmp = SDL_strrchr(output, '\n'); + if (tmp) { + *tmp = '\0'; + } + + // Check which button got pressed + for (i = 0; i < messageboxdata->numbuttons; i += 1) { + if (messageboxdata->buttons[i].text) { + if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) { + *buttonID = messageboxdata->buttons[i].buttonID; + break; + } + } + } + SDL_free(output); + } + } + SDL_DestroyProcess(process); + + return true; +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.h new file mode 100644 index 0000000..af3012f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmessagebox.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_waylandmessagebox_h_ +#define SDL_waylandmessagebox_h_ + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +extern bool Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_WAYLAND + +#endif // SDL_waylandmessagebox_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.c new file mode 100644 index 0000000..8075c3a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.c @@ -0,0 +1,1057 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include "../SDL_sysvideo.h" +#include "../SDL_video_c.h" + +#include "../../events/SDL_mouse_c.h" +#include "SDL_waylandvideo.h" +#include "../SDL_pixels_c.h" +#include "SDL_waylandevents_c.h" + +#include "wayland-cursor.h" +#include "SDL_waylandmouse.h" +#include "SDL_waylandshmbuffer.h" + +#include "cursor-shape-v1-client-protocol.h" +#include "pointer-constraints-unstable-v1-client-protocol.h" +#include "viewporter-client-protocol.h" + +#include "../../SDL_hints_c.h" + +static SDL_Cursor *sys_cursors[SDL_HITTEST_RESIZE_LEFT + 1]; + +static bool Wayland_SetRelativeMouseMode(bool enabled); + +typedef struct +{ + struct Wayland_SHMBuffer shmBuffer; + double scale; + struct wl_list node; +} Wayland_ScaledCustomCursor; + +typedef struct +{ + SDL_Surface *sdl_cursor_surface; + int hot_x; + int hot_y; + struct wl_list scaled_cursor_cache; +} Wayland_CustomCursor; + +typedef struct +{ + struct wl_buffer *wl_buffer; + Uint32 duration; +} Wayland_SystemCursorFrame; + +typedef struct +{ + Wayland_SystemCursorFrame *frames; + struct wl_callback *frame_callback; + Uint64 last_frame_callback_time_ms; + Uint64 current_frame_time_ms; + Uint32 total_duration; + int num_frames; + int current_frame; + SDL_SystemCursor id; +} Wayland_SystemCursor; + +struct SDL_CursorData +{ + union + { + Wayland_CustomCursor custom; + Wayland_SystemCursor system; + } cursor_data; + + struct wl_surface *surface; + struct wp_viewport *viewport; + + bool is_system_cursor; +}; + +static int dbus_cursor_size; +static char *dbus_cursor_theme; + +static void Wayland_FreeCursorThemes(SDL_VideoData *vdata) +{ + for (int i = 0; i < vdata->num_cursor_themes; i += 1) { + WAYLAND_wl_cursor_theme_destroy(vdata->cursor_themes[i].theme); + } + vdata->num_cursor_themes = 0; + SDL_free(vdata->cursor_themes); + vdata->cursor_themes = NULL; +} + +#ifdef SDL_USE_LIBDBUS + +#include "../../core/linux/SDL_dbus.h" + +#define CURSOR_NODE "org.freedesktop.portal.Desktop" +#define CURSOR_PATH "/org/freedesktop/portal/desktop" +#define CURSOR_INTERFACE "org.freedesktop.portal.Settings" +#define CURSOR_NAMESPACE "org.gnome.desktop.interface" +#define CURSOR_SIGNAL_NAME "SettingChanged" +#define CURSOR_SIZE_KEY "cursor-size" +#define CURSOR_THEME_KEY "cursor-theme" + +static DBusMessage *Wayland_ReadDBusProperty(SDL_DBusContext *dbus, const char *key) +{ + static const char *iface = "org.gnome.desktop.interface"; + + DBusMessage *reply = NULL; + DBusMessage *msg = dbus->message_new_method_call(CURSOR_NODE, + CURSOR_PATH, + CURSOR_INTERFACE, + "Read"); // Method + + if (msg) { + if (dbus->message_append_args(msg, DBUS_TYPE_STRING, &iface, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) { + reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, DBUS_TIMEOUT_USE_DEFAULT, NULL); + } + dbus->message_unref(msg); + } + + return reply; +} + +static bool Wayland_ParseDBusReply(SDL_DBusContext *dbus, DBusMessage *reply, int type, void *value) +{ + DBusMessageIter iter[3]; + + dbus->message_iter_init(reply, &iter[0]); + if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_VARIANT) { + return false; + } + + dbus->message_iter_recurse(&iter[0], &iter[1]); + if (dbus->message_iter_get_arg_type(&iter[1]) != DBUS_TYPE_VARIANT) { + return false; + } + + dbus->message_iter_recurse(&iter[1], &iter[2]); + if (dbus->message_iter_get_arg_type(&iter[2]) != type) { + return false; + } + + dbus->message_iter_get_basic(&iter[2], value); + + return true; +} + +static DBusHandlerResult Wayland_DBusCursorMessageFilter(DBusConnection *conn, DBusMessage *msg, void *data) +{ + SDL_DBusContext *dbus = SDL_DBus_GetContext(); + SDL_VideoData *vdata = (SDL_VideoData *)data; + + if (dbus->message_is_signal(msg, CURSOR_INTERFACE, CURSOR_SIGNAL_NAME)) { + DBusMessageIter signal_iter, variant_iter; + const char *namespace, *key; + + dbus->message_iter_init(msg, &signal_iter); + // Check if the parameters are what we expect + if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_STRING) { + goto not_our_signal; + } + dbus->message_iter_get_basic(&signal_iter, &namespace); + if (SDL_strcmp(CURSOR_NAMESPACE, namespace) != 0) { + goto not_our_signal; + } + if (!dbus->message_iter_next(&signal_iter)) { + goto not_our_signal; + } + if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_STRING) { + goto not_our_signal; + } + dbus->message_iter_get_basic(&signal_iter, &key); + if (SDL_strcmp(CURSOR_SIZE_KEY, key) == 0) { + int new_cursor_size; + + if (!dbus->message_iter_next(&signal_iter)) { + goto not_our_signal; + } + if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_VARIANT) { + goto not_our_signal; + } + dbus->message_iter_recurse(&signal_iter, &variant_iter); + if (dbus->message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_INT32) { + goto not_our_signal; + } + dbus->message_iter_get_basic(&variant_iter, &new_cursor_size); + + if (dbus_cursor_size != new_cursor_size) { + dbus_cursor_size = new_cursor_size; + SDL_SetCursor(NULL); // Force cursor update + } + } else if (SDL_strcmp(CURSOR_THEME_KEY, key) == 0) { + const char *new_cursor_theme = NULL; + + if (!dbus->message_iter_next(&signal_iter)) { + goto not_our_signal; + } + if (dbus->message_iter_get_arg_type(&signal_iter) != DBUS_TYPE_VARIANT) { + goto not_our_signal; + } + dbus->message_iter_recurse(&signal_iter, &variant_iter); + if (dbus->message_iter_get_arg_type(&variant_iter) != DBUS_TYPE_STRING) { + goto not_our_signal; + } + dbus->message_iter_get_basic(&variant_iter, &new_cursor_theme); + + if (!dbus_cursor_theme || !new_cursor_theme || SDL_strcmp(dbus_cursor_theme, new_cursor_theme) != 0) { + SDL_free(dbus_cursor_theme); + if (new_cursor_theme) { + dbus_cursor_theme = SDL_strdup(new_cursor_theme); + } else { + dbus_cursor_theme = NULL; + } + + // Purge the current cached themes and force a cursor refresh. + Wayland_FreeCursorThemes(vdata); + SDL_SetCursor(NULL); + } + } else { + goto not_our_signal; + } + + return DBUS_HANDLER_RESULT_HANDLED; + } + +not_our_signal: + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; +} + +static void Wayland_DBusInitCursorProperties(SDL_VideoData *vdata) +{ + DBusMessage *reply; + SDL_DBusContext *dbus = SDL_DBus_GetContext(); + bool add_filter = false; + + if (!dbus) { + return; + } + + if ((reply = Wayland_ReadDBusProperty(dbus, CURSOR_SIZE_KEY))) { + if (Wayland_ParseDBusReply(dbus, reply, DBUS_TYPE_INT32, &dbus_cursor_size)) { + add_filter = true; + } + dbus->message_unref(reply); + } + + if ((reply = Wayland_ReadDBusProperty(dbus, CURSOR_THEME_KEY))) { + const char *temp = NULL; + if (Wayland_ParseDBusReply(dbus, reply, DBUS_TYPE_STRING, &temp)) { + add_filter = true; + + if (temp) { + dbus_cursor_theme = SDL_strdup(temp); + } + } + dbus->message_unref(reply); + } + + // Only add the filter if at least one of the settings we want is present. + if (add_filter) { + dbus->bus_add_match(dbus->session_conn, + "type='signal', interface='" CURSOR_INTERFACE "'," + "member='" CURSOR_SIGNAL_NAME "', arg0='" CURSOR_NAMESPACE "'", + NULL); + dbus->connection_add_filter(dbus->session_conn, &Wayland_DBusCursorMessageFilter, vdata, NULL); + dbus->connection_flush(dbus->session_conn); + } +} + +static void Wayland_DBusFinishCursorProperties(void) +{ + SDL_free(dbus_cursor_theme); + dbus_cursor_theme = NULL; +} + +#endif + +static void cursor_frame_done(void *data, struct wl_callback *cb, uint32_t time); +struct wl_callback_listener cursor_frame_listener = { + cursor_frame_done +}; + +static void cursor_frame_done(void *data, struct wl_callback *cb, uint32_t time) +{ + SDL_CursorData *c = (SDL_CursorData *)data; + + const Uint64 now = SDL_GetTicks(); + const Uint64 elapsed = (now - c->cursor_data.system.last_frame_callback_time_ms) % c->cursor_data.system.total_duration; + Uint64 advance = 0; + int next = c->cursor_data.system.current_frame; + + wl_callback_destroy(cb); + c->cursor_data.system.frame_callback = wl_surface_frame(c->surface); + wl_callback_add_listener(c->cursor_data.system.frame_callback, &cursor_frame_listener, data); + + c->cursor_data.system.current_frame_time_ms += elapsed; + + // Calculate the next frame based on the elapsed duration. + for (Uint64 t = c->cursor_data.system.frames[next].duration; t <= c->cursor_data.system.current_frame_time_ms; t += c->cursor_data.system.frames[next].duration) { + next = (next + 1) % c->cursor_data.system.num_frames; + advance = t; + + // Make sure we don't end up in an infinite loop if a cursor has frame durations of 0. + if (!c->cursor_data.system.frames[next].duration) { + break; + } + } + + c->cursor_data.system.current_frame_time_ms -= advance; + c->cursor_data.system.last_frame_callback_time_ms = now; + c->cursor_data.system.current_frame = next; + wl_surface_attach(c->surface, c->cursor_data.system.frames[next].wl_buffer, 0, 0); + if (wl_surface_get_version(c->surface) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) { + wl_surface_damage_buffer(c->surface, 0, 0, SDL_MAX_SINT32, SDL_MAX_SINT32); + } else { + wl_surface_damage(c->surface, 0, 0, SDL_MAX_SINT32, SDL_MAX_SINT32); + } + wl_surface_commit(c->surface); +} + +static bool Wayland_GetSystemCursor(SDL_VideoData *vdata, SDL_CursorData *cdata, int *scale, int *dst_size, int *hot_x, int *hot_y) +{ + struct wl_cursor_theme *theme = NULL; + struct wl_cursor *cursor; + const char *css_name = "default"; + const char *fallback_name = NULL; + double scale_factor = 1.0; + int theme_size = dbus_cursor_size; + + // Fallback envvar if the DBus properties don't exist + if (theme_size <= 0) { + const char *xcursor_size = SDL_getenv("XCURSOR_SIZE"); + if (xcursor_size) { + theme_size = SDL_atoi(xcursor_size); + } + } + if (theme_size <= 0) { + theme_size = 24; + } + // First, find the appropriate theme based on the current scale... + SDL_Window *focus = SDL_GetMouse()->focus; + if (focus) { + // TODO: Use the fractional scale once GNOME supports viewports on cursor surfaces. + scale_factor = SDL_ceil(focus->internal->scale_factor); + } + + const int scaled_size = (int)SDL_lround(theme_size * scale_factor); + for (int i = 0; i < vdata->num_cursor_themes; ++i) { + if (vdata->cursor_themes[i].size == scaled_size) { + theme = vdata->cursor_themes[i].theme; + break; + } + } + if (!theme) { + const char *xcursor_theme = dbus_cursor_theme; + + SDL_WaylandCursorTheme *new_cursor_themes = SDL_realloc(vdata->cursor_themes, + sizeof(SDL_WaylandCursorTheme) * (vdata->num_cursor_themes + 1)); + if (!new_cursor_themes) { + return false; + } + vdata->cursor_themes = new_cursor_themes; + + // Fallback envvar if the DBus properties don't exist + if (!xcursor_theme) { + xcursor_theme = SDL_getenv("XCURSOR_THEME"); + } + + theme = WAYLAND_wl_cursor_theme_load(xcursor_theme, scaled_size, vdata->shm); + vdata->cursor_themes[vdata->num_cursor_themes].size = scaled_size; + vdata->cursor_themes[vdata->num_cursor_themes++].theme = theme; + } + + css_name = SDL_GetCSSCursorName(cdata->cursor_data.system.id, &fallback_name); + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, css_name); + if (!cursor && fallback_name) { + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, fallback_name); + } + + // Fallback to the default cursor if the chosen one wasn't found + if (!cursor) { + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "default"); + } + // Try the old X11 name as a last resort + if (!cursor) { + cursor = WAYLAND_wl_cursor_theme_get_cursor(theme, "left_ptr"); + } + if (!cursor) { + return false; + } + + if (cdata->cursor_data.system.num_frames != cursor->image_count) { + SDL_free(cdata->cursor_data.system.frames); + cdata->cursor_data.system.frames = SDL_calloc(cursor->image_count, sizeof(Wayland_SystemCursorFrame)); + if (!cdata->cursor_data.system.frames) { + return false; + } + } + + // ... Set the cursor data, finally. + cdata->cursor_data.system.num_frames = cursor->image_count; + cdata->cursor_data.system.total_duration = 0; + for (int i = 0; i < cursor->image_count; ++i) { + cdata->cursor_data.system.frames[i].wl_buffer = WAYLAND_wl_cursor_image_get_buffer(cursor->images[i]); + cdata->cursor_data.system.frames[i].duration = cursor->images[i]->delay; + cdata->cursor_data.system.total_duration += cursor->images[i]->delay; + } + + *scale = SDL_ceil(scale_factor) == scale_factor ? (int)scale_factor : 0; + + if (scaled_size != cursor->images[0]->width) { + /* If the cursor size isn't an exact match for the target size, use a viewport + * to avoid a possible "Buffer size is not divisible by scale" protocol error. + * + * If viewports are unavailable, find an integer scale that works. + */ + if (vdata->viewporter) { + // A scale of 0 indicates that a viewport set to the destination size should be used. + *scale = 0; + } else { + for (; *scale > 1; --*scale) { + if (cursor->images[0]->width % *scale == 0) { + break; + } + } + // Set the scale factor to the new value for the hotspot calculations. + scale_factor = *scale; + } + } + + *dst_size = (int)SDL_lround(cursor->images[0]->width / scale_factor); + + *hot_x = (int)SDL_lround(cursor->images[0]->hotspot_x / scale_factor); + *hot_y = (int)SDL_lround(cursor->images[0]->hotspot_y / scale_factor); + + return true; +} + +static Wayland_ScaledCustomCursor *Wayland_CacheScaledCustomCursor(SDL_CursorData *cdata, double scale) +{ + Wayland_ScaledCustomCursor *cache = NULL; + + // Is this cursor already cached at the target scale? + if (!WAYLAND_wl_list_empty(&cdata->cursor_data.custom.scaled_cursor_cache)) { + Wayland_ScaledCustomCursor *c = NULL; + wl_list_for_each (c, &cdata->cursor_data.custom.scaled_cursor_cache, node) { + if (c->scale == scale) { + cache = c; + break; + } + } + } + + if (!cache) { + cache = SDL_calloc(1, sizeof(Wayland_ScaledCustomCursor)); + if (!cache) { + return NULL; + } + + SDL_Surface *surface = SDL_GetSurfaceImage(cdata->cursor_data.custom.sdl_cursor_surface, (float)scale); + if (!surface) { + SDL_free(cache); + return NULL; + } + + // Allocate the shared memory buffer for this cursor. + if (!Wayland_AllocSHMBuffer(surface->w, surface->h, &cache->shmBuffer)) { + SDL_free(cache); + SDL_DestroySurface(surface); + return NULL; + } + + // Wayland requires premultiplied alpha for its surfaces. + SDL_PremultiplyAlpha(surface->w, surface->h, + surface->format, surface->pixels, surface->pitch, + SDL_PIXELFORMAT_ARGB8888, cache->shmBuffer.shm_data, surface->w * 4, true); + + cache->scale = scale; + WAYLAND_wl_list_insert(&cdata->cursor_data.custom.scaled_cursor_cache, &cache->node); + SDL_DestroySurface(surface); + } + + return cache; +} + +static bool Wayland_GetCustomCursor(SDL_Cursor *cursor, struct wl_buffer **buffer, int *scale, int *dst_width, int *dst_height, int *hot_x, int *hot_y) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *wd = vd->internal; + SDL_CursorData *data = cursor->internal; + SDL_Window *focus = SDL_GetMouseFocus(); + double scale_factor = 1.0; + + if (focus && SDL_SurfaceHasAlternateImages(data->cursor_data.custom.sdl_cursor_surface)) { + scale_factor = focus->internal->scale_factor; + } + + // Only use fractional scale values if viewports are available. + if (!wd->viewporter) { + scale_factor = SDL_ceil(scale_factor); + } + + Wayland_ScaledCustomCursor *c = Wayland_CacheScaledCustomCursor(data, scale_factor); + if (!c) { + return false; + } + + *buffer = c->shmBuffer.wl_buffer; + *scale = SDL_ceil(scale_factor) == scale_factor ? (int)scale_factor : 0; + *dst_width = data->cursor_data.custom.sdl_cursor_surface->w; + *dst_height = data->cursor_data.custom.sdl_cursor_surface->h; + *hot_x = data->cursor_data.custom.hot_x; + *hot_y = data->cursor_data.custom.hot_y; + + return true; +} + +static SDL_Cursor *Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *wd = vd->internal; + + SDL_Cursor *cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + SDL_CursorData *data = SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_free(cursor); + return NULL; + } + cursor->internal = data; + WAYLAND_wl_list_init(&data->cursor_data.custom.scaled_cursor_cache); + data->cursor_data.custom.hot_x = hot_x; + data->cursor_data.custom.hot_y = hot_y; + data->surface = wl_compositor_create_surface(wd->compositor); + + data->cursor_data.custom.sdl_cursor_surface = surface; + ++surface->refcount; + + // If the cursor has only one size, just prepare it now. + if (!SDL_SurfaceHasAlternateImages(surface)) { + Wayland_CacheScaledCustomCursor(data, 1.0); + } + } + + return cursor; +} + +static SDL_Cursor *Wayland_CreateSystemCursor(SDL_SystemCursor id) +{ + SDL_VideoData *data = SDL_GetVideoDevice()->internal; + SDL_Cursor *cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + SDL_CursorData *cdata = SDL_calloc(1, sizeof(*cdata)); + if (!cdata) { + SDL_free(cursor); + return NULL; + } + cursor->internal = cdata; + + /* The surface is only necessary if the cursor shape manager is not present. + * + * Note that we can't actually set any other cursor properties, as this + * is window-specific. See Wayland_GetSystemCursor for the rest! + */ + if (!data->cursor_shape_manager) { + cdata->surface = wl_compositor_create_surface(data->compositor); + wl_surface_set_user_data(cdata->surface, NULL); + } + + cdata->cursor_data.system.id = id; + cdata->is_system_cursor = true; + } + + return cursor; +} + +static SDL_Cursor *Wayland_CreateDefaultCursor(void) +{ + SDL_SystemCursor id = SDL_GetDefaultSystemCursor(); + return Wayland_CreateSystemCursor(id); +} + +static void Wayland_FreeCursorData(SDL_CursorData *d) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + struct SDL_WaylandInput *input = vd->internal->input; + + if (input->current_cursor == d) { + input->current_cursor = NULL; + } + + // Buffers for system cursors must not be destroyed. + if (d->is_system_cursor) { + if (d->cursor_data.system.frame_callback) { + wl_callback_destroy(d->cursor_data.system.frame_callback); + } + SDL_free(d->cursor_data.system.frames); + } else { + Wayland_ScaledCustomCursor *c, *temp; + wl_list_for_each_safe(c, temp, &d->cursor_data.custom.scaled_cursor_cache, node) { + Wayland_ReleaseSHMBuffer(&c->shmBuffer); + SDL_free(c); + } + + SDL_DestroySurface(d->cursor_data.custom.sdl_cursor_surface); + } + + if (d->viewport) { + wp_viewport_destroy(d->viewport); + d->viewport = NULL; + } + + if (d->surface) { + wl_surface_destroy(d->surface); + d->surface = NULL; + } +} + +static void Wayland_FreeCursor(SDL_Cursor *cursor) +{ + if (!cursor) { + return; + } + + // Probably not a cursor we own + if (!cursor->internal) { + return; + } + + Wayland_FreeCursorData(cursor->internal); + + SDL_free(cursor->internal); + SDL_free(cursor); +} + +static void Wayland_SetSystemCursorShape(struct SDL_WaylandInput *input, SDL_SystemCursor id) +{ + Uint32 shape; + + switch (id) { + case SDL_SYSTEM_CURSOR_DEFAULT: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT; + break; + case SDL_SYSTEM_CURSOR_TEXT: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_TEXT; + break; + case SDL_SYSTEM_CURSOR_WAIT: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_WAIT; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_CROSSHAIR; + break; + case SDL_SYSTEM_CURSOR_PROGRESS: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_PROGRESS; + break; + case SDL_SYSTEM_CURSOR_NWSE_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NWSE_RESIZE; + break; + case SDL_SYSTEM_CURSOR_NESW_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NESW_RESIZE; + break; + case SDL_SYSTEM_CURSOR_EW_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_EW_RESIZE; + break; + case SDL_SYSTEM_CURSOR_NS_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NS_RESIZE; + break; + case SDL_SYSTEM_CURSOR_MOVE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_ALL_SCROLL; + break; + case SDL_SYSTEM_CURSOR_NOT_ALLOWED: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NOT_ALLOWED; + break; + case SDL_SYSTEM_CURSOR_POINTER: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_POINTER; + break; + case SDL_SYSTEM_CURSOR_NW_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NW_RESIZE; + break; + case SDL_SYSTEM_CURSOR_N_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_N_RESIZE; + break; + case SDL_SYSTEM_CURSOR_NE_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_NE_RESIZE; + break; + case SDL_SYSTEM_CURSOR_E_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_E_RESIZE; + break; + case SDL_SYSTEM_CURSOR_SE_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SE_RESIZE; + break; + case SDL_SYSTEM_CURSOR_S_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_S_RESIZE; + break; + case SDL_SYSTEM_CURSOR_SW_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_SW_RESIZE; + break; + case SDL_SYSTEM_CURSOR_W_RESIZE: + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_W_RESIZE; + break; + default: + SDL_assert(0); // Should never be here... + shape = WP_CURSOR_SHAPE_DEVICE_V1_SHAPE_DEFAULT; + } + + wp_cursor_shape_device_v1_set_shape(input->cursor_shape, input->pointer_enter_serial, shape); +} + +static bool Wayland_ShowCursor(SDL_Cursor *cursor) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *d = vd->internal; + struct SDL_WaylandInput *input = d->input; + struct wl_pointer *pointer = d->pointer; + struct wl_buffer *buffer = NULL; + int scale = 1; + int dst_width = 0; + int dst_height = 0; + int hot_x; + int hot_y; + + if (!pointer) { + return false; + } + + // Stop the frame callback for old animated cursors. + if (input->current_cursor && input->current_cursor->is_system_cursor && + input->current_cursor->cursor_data.system.frame_callback) { + wl_callback_destroy(input->current_cursor->cursor_data.system.frame_callback); + input->current_cursor->cursor_data.system.frame_callback = NULL; + } + + if (cursor) { + SDL_CursorData *data = cursor->internal; + + if (data->is_system_cursor) { + // If the cursor shape protocol is supported, the compositor will draw nicely scaled cursors for us, so nothing more to do. + if (input->cursor_shape) { + Wayland_SetSystemCursorShape(input, data->cursor_data.system.id); + input->current_cursor = data; + return true; + } + + if (!Wayland_GetSystemCursor(d, data, &scale, &dst_width, &hot_x, &hot_y)) { + return false; + } + + dst_height = dst_width; + wl_surface_attach(data->surface, data->cursor_data.system.frames[0].wl_buffer, 0, 0); + + // If more than one frame is available, create a frame callback to run the animation. + if (data->cursor_data.system.num_frames > 1) { + data->cursor_data.system.last_frame_callback_time_ms = SDL_GetTicks(); + data->cursor_data.system.current_frame_time_ms = 0; + data->cursor_data.system.current_frame = 0; + data->cursor_data.system.frame_callback = wl_surface_frame(data->surface); + wl_callback_add_listener(data->cursor_data.system.frame_callback, &cursor_frame_listener, data); + } + } else { + if (!Wayland_GetCustomCursor(cursor, &buffer, &scale, &dst_width, &dst_height, &hot_x, &hot_y)) { + return false; + } + + wl_surface_attach(data->surface, buffer, 0, 0); + } + + // A scale value of 0 indicates that a viewport with the returned destination size should be used. + if (!scale) { + if (!data->viewport) { + data->viewport = wp_viewporter_get_viewport(d->viewporter, data->surface); + } + wl_surface_set_buffer_scale(data->surface, 1); + wp_viewport_set_source(data->viewport, wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1), wl_fixed_from_int(-1)); + wp_viewport_set_destination(data->viewport, dst_width, dst_height); + } else { + if (data->viewport) { + wp_viewport_destroy(data->viewport); + data->viewport = NULL; + } + wl_surface_set_buffer_scale(data->surface, scale); + } + + wl_pointer_set_cursor(pointer, input->pointer_enter_serial, data->surface, hot_x, hot_y); + + if (wl_surface_get_version(data->surface) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) { + wl_surface_damage_buffer(data->surface, 0, 0, SDL_MAX_SINT32, SDL_MAX_SINT32); + } else { + wl_surface_damage(data->surface, 0, 0, SDL_MAX_SINT32, SDL_MAX_SINT32); + } + + wl_surface_commit(data->surface); + input->current_cursor = data; + } else { + input->current_cursor = NULL; + wl_pointer_set_cursor(pointer, input->pointer_enter_serial, NULL, 0, 0); + } + + return true; +} + +static bool Wayland_WarpMouse(SDL_Window *window, float x, float y) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *d = vd->internal; + SDL_WindowData *wind = window->internal; + struct SDL_WaylandInput *input = d->input; + + if (d->pointer_constraints) { + const bool toggle_lock = !wind->locked_pointer; + + /* The pointer confinement protocol allows setting a hint to warp the pointer, + * but only when the pointer is locked. + * + * Lock the pointer, set the position hint, unlock, and hope for the best. + */ + if (toggle_lock) { + Wayland_input_lock_pointer(input, window); + } + if (wind->locked_pointer) { + const wl_fixed_t f_x = wl_fixed_from_double(x / wind->pointer_scale.x); + const wl_fixed_t f_y = wl_fixed_from_double(y / wind->pointer_scale.y); + zwp_locked_pointer_v1_set_cursor_position_hint(wind->locked_pointer, f_x, f_y); + wl_surface_commit(wind->surface); + } + if (toggle_lock) { + Wayland_input_unlock_pointer(input, window); + } + + /* NOTE: There is a pending warp event under discussion that should replace this when available. + * https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/340 + */ + SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); + } else { + return SDL_SetError("wayland: mouse warp failed; compositor lacks support for the required zwp_pointer_confinement_v1 protocol"); + } + + return true; +} + +static bool Wayland_WarpMouseGlobal(float x, float y) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *d = vd->internal; + struct SDL_WaylandInput *input = d->input; + SDL_WindowData *wind = input->pointer_focus; + + // If the client wants the coordinates warped to within the focused window, just convert the coordinates to relative. + if (wind) { + SDL_Window *window = wind->sdlwindow; + return Wayland_WarpMouse(window, x - (float)window->x, y - (float)window->y); + } + + return SDL_SetError("wayland: can't warp the mouse when a window does not have focus"); +} + +static bool Wayland_SetRelativeMouseMode(bool enabled) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *data = vd->internal; + + if (enabled) { + return Wayland_input_enable_relative_pointer(data->input); + } else { + return Wayland_input_disable_relative_pointer(data->input); + } +} + +/* Wayland doesn't support getting the true global cursor position, but it can + * be faked well enough for what most applications use it for: querying the + * global cursor coordinates and transforming them to the window-relative + * coordinates manually. + * + * The global position is derived by taking the cursor position relative to the + * toplevel window, and offsetting it by the origin of the output the window is + * currently considered to be on. The cursor position and button state when the + * cursor is outside an application window are unknown, but this gives 'correct' + * coordinates when the window has focus, which is good enough for most + * applications. + */ +static SDL_MouseButtonFlags SDLCALL Wayland_GetGlobalMouseState(float *x, float *y) +{ + SDL_Window *focus = SDL_GetMouseFocus(); + SDL_MouseButtonFlags result = 0; + + if (focus) { + SDL_VideoData *viddata = SDL_GetVideoDevice()->internal; + int off_x, off_y; + + result = viddata->input->buttons_pressed; + SDL_RelativeToGlobalForWindow(focus, focus->x, focus->y, &off_x, &off_y); + *x += off_x; + *y += off_y; + } + + return result; +} + +#if 0 // TODO RECONNECT: See waylandvideo.c for more information! +static void Wayland_RecreateCursor(SDL_Cursor *cursor, SDL_VideoData *vdata) +{ + SDL_CursorData *cdata = cursor->internal; + + // Probably not a cursor we own + if (cdata == NULL) { + return; + } + + Wayland_FreeCursorData(cdata); + + // We're not currently freeing this, so... yolo? + if (cdata->shm_data != NULL) { + void *old_data_pointer = cdata->shm_data; + int stride = cdata->w * 4; + + create_buffer_from_shm(cdata, cdata->w, cdata->h, WL_SHM_FORMAT_ARGB8888); + + SDL_memcpy(cdata->shm_data, old_data_pointer, stride * cdata->h); + } + cdata->surface = wl_compositor_create_surface(vdata->compositor); + wl_surface_set_user_data(cdata->surface, NULL); +} + +void Wayland_RecreateCursors(void) +{ + SDL_Cursor *cursor; + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_VideoData *vdata = SDL_GetVideoDevice()->internal; + + if (vdata && vdata->cursor_themes) { + SDL_free(vdata->cursor_themes); + vdata->cursor_themes = NULL; + vdata->num_cursor_themes = 0; + } + + if (mouse == NULL) { + return; + } + + for (cursor = mouse->cursors; cursor != NULL; cursor = cursor->next) { + Wayland_RecreateCursor(cursor, vdata); + } + if (mouse->def_cursor) { + Wayland_RecreateCursor(mouse->def_cursor, vdata); + } + if (mouse->cur_cursor) { + Wayland_RecreateCursor(mouse->cur_cursor, vdata); + if (mouse->cursor_shown) { + Wayland_ShowCursor(mouse->cur_cursor); + } + } +} +#endif // 0 + +void Wayland_InitMouse(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *d = vd->internal; + + mouse->CreateCursor = Wayland_CreateCursor; + mouse->CreateSystemCursor = Wayland_CreateSystemCursor; + mouse->ShowCursor = Wayland_ShowCursor; + mouse->FreeCursor = Wayland_FreeCursor; + mouse->WarpMouse = Wayland_WarpMouse; + mouse->WarpMouseGlobal = Wayland_WarpMouseGlobal; + mouse->SetRelativeMouseMode = Wayland_SetRelativeMouseMode; + mouse->GetGlobalMouseState = Wayland_GetGlobalMouseState; + + SDL_HitTestResult r = SDL_HITTEST_NORMAL; + while (r <= SDL_HITTEST_RESIZE_LEFT) { + switch (r) { + case SDL_HITTEST_NORMAL: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); + break; + case SDL_HITTEST_DRAGGABLE: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); + break; + case SDL_HITTEST_RESIZE_TOPLEFT: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_NW_RESIZE); + break; + case SDL_HITTEST_RESIZE_TOP: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_N_RESIZE); + break; + case SDL_HITTEST_RESIZE_TOPRIGHT: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_NE_RESIZE); + break; + case SDL_HITTEST_RESIZE_RIGHT: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_E_RESIZE); + break; + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_SE_RESIZE); + break; + case SDL_HITTEST_RESIZE_BOTTOM: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_S_RESIZE); + break; + case SDL_HITTEST_RESIZE_BOTTOMLEFT: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_SW_RESIZE); + break; + case SDL_HITTEST_RESIZE_LEFT: + sys_cursors[r] = Wayland_CreateSystemCursor(SDL_SYSTEM_CURSOR_W_RESIZE); + break; + } + r++; + } + +#ifdef SDL_USE_LIBDBUS + /* The DBus cursor properties are only needed when manually loading themes and cursors. + * If the cursor shape protocol is present, the compositor will handle it internally. + */ + if (!d->cursor_shape_manager) { + Wayland_DBusInitCursorProperties(d); + } +#endif + + SDL_SetDefaultCursor(Wayland_CreateDefaultCursor()); +} + +void Wayland_FiniMouse(SDL_VideoData *data) +{ + Wayland_FreeCursorThemes(data); + +#ifdef SDL_USE_LIBDBUS + Wayland_DBusFinishCursorProperties(); +#endif + + for (int i = 0; i < SDL_arraysize(sys_cursors); i++) { + Wayland_FreeCursor(sys_cursors[i]); + sys_cursors[i] = NULL; + } +} + +void Wayland_SetHitTestCursor(SDL_HitTestResult rc) +{ + if (rc == SDL_HITTEST_NORMAL || rc == SDL_HITTEST_DRAGGABLE) { + SDL_SetCursor(NULL); + } else { + Wayland_ShowCursor(sys_cursors[rc]); + } +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.h new file mode 100644 index 0000000..58188c0 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandmouse.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_waylandmouse_h_ +#define SDL_waylandmouse_h_ + +extern void Wayland_InitMouse(void); +extern void Wayland_FiniMouse(SDL_VideoData *data); +extern void Wayland_SetHitTestCursor(SDL_HitTestResult rc); +#if 0 // TODO RECONNECT: See waylandvideo.c for more information! +extern void Wayland_RecreateCursors(void); +#endif // 0 + +#endif diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.c new file mode 100644 index 0000000..ac2b06d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.c @@ -0,0 +1,220 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WAYLAND) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "../../core/unix/SDL_poll.h" +#include "../SDL_sysvideo.h" +#include "../../events/SDL_windowevents_c.h" +#include "SDL_waylandvideo.h" +#include "SDL_waylandopengles.h" +#include "SDL_waylandwindow.h" +#include "SDL_waylandevents_c.h" + +#include "xdg-shell-client-protocol.h" + +// EGL implementation of SDL OpenGL ES support + +bool Wayland_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + bool result; + SDL_VideoData *data = _this->internal; + + result = SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display, _this->gl_config.egl_platform); + + Wayland_PumpEvents(_this); + WAYLAND_wl_display_flush(data->display); + + return result; +} + +SDL_GLContext Wayland_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_GLContext context; + context = SDL_EGL_CreateContext(_this, window->internal->egl_surface); + WAYLAND_wl_display_flush(_this->internal->display); + + return context; +} + +/* Wayland wants to tell you when to provide new frames, and if you have a non-zero + swap interval, Mesa will block until a callback tells it to do so. On some + compositors, they might decide that a minimized window _never_ gets a callback, + which causes apps to hang during swapping forever. So we always set the official + eglSwapInterval to zero to avoid blocking inside EGL, and manage this ourselves. + If a swap blocks for too long waiting on a callback, we just go on, under the + assumption the frame will be wasted, but this is better than freezing the app. + I frown upon platforms that dictate this sort of control inversion (the callback + is intended for _rendering_, not stalling until vsync), but we can work around + this for now. --ryan. */ +/* Addendum: several recent APIs demand this sort of control inversion: Emscripten, + libretro, Wayland, probably others...it feels like we're eventually going to have + to give in with a future SDL API revision, since we can bend the other APIs to + this style, but this style is much harder to bend the other way. :/ */ +bool Wayland_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + /* technically, this is _all_ adaptive vsync (-1), because we can't + actually wait for the _next_ vsync if you set 1, but things that + request 1 probably won't care _that_ much. I hope. No matter what + you do, though, you never see tearing on Wayland. */ + if (interval > 1) { + interval = 1; + } else if (interval < -1) { + interval = -1; + } + + // !!! FIXME: technically, this should be per-context, right? + _this->egl_data->egl_swapinterval = interval; + _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); + return true; +} + +bool Wayland_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + if (!_this->egl_data) { + return SDL_SetError("EGL not initialized"); + } + + *interval =_this->egl_data->egl_swapinterval; + return true; +} + +bool Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + const int swap_interval = _this->egl_data->egl_swapinterval; + + /* For windows that we know are hidden, skip swaps entirely, if we don't do + * this compositors will intentionally stall us indefinitely and there's no + * way for an end user to show the window, unlike other situations (i.e. + * the window is minimized, behind another window, etc.). + * + * FIXME: Request EGL_WAYLAND_swap_buffers_with_timeout. + * -flibit + */ + if (data->shell_surface_status != WAYLAND_SHELL_SURFACE_STATUS_SHOWN && + data->shell_surface_status != WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME) { + return true; + } + + /* By default, we wait for the Wayland frame callback and then issue the pageflip (eglSwapBuffers), + * but if we want low latency (double buffer scheme), we issue the pageflip and then wait + * immediately for the Wayland frame callback. + */ + if (data->double_buffer) { + // Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. + if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) { + return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); + } + + WAYLAND_wl_display_flush(data->waylandData->display); + } + + // Control swap interval ourselves. See comments on Wayland_GLES_SetSwapInterval + if (swap_interval != 0 && data->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_SHOWN) { + SDL_VideoData *videodata = _this->internal; + struct wl_display *display = videodata->display; + // 20hz, so we'll progress even if throttled to zero. + const Uint64 max_wait = SDL_GetTicksNS() + (SDL_NS_PER_SECOND / 20); + while (SDL_GetAtomicInt(&data->swap_interval_ready) == 0) { + Uint64 now; + + WAYLAND_wl_display_flush(display); + + /* wl_display_prepare_read_queue() will return false if the event queue is not empty. + * If the event queue is empty, it will prepare us for our SDL_IOReady() call. */ + if (WAYLAND_wl_display_prepare_read_queue(display, data->gles_swap_frame_event_queue) != 0) { + // We have some pending events. Check if the frame callback happened. + WAYLAND_wl_display_dispatch_queue_pending(display, data->gles_swap_frame_event_queue); + continue; + } + + // Beyond this point, we must either call wl_display_cancel_read() or wl_display_read_events() + + now = SDL_GetTicksNS(); + if (now >= max_wait) { + // Timeout expired. Cancel the read. + WAYLAND_wl_display_cancel_read(display); + break; + } + + if (SDL_IOReady(WAYLAND_wl_display_get_fd(display), SDL_IOR_READ, max_wait - now) <= 0) { + // Error or timeout expired without any events for us. Cancel the read. + WAYLAND_wl_display_cancel_read(display); + break; + } + + // We have events. Read and dispatch them. + WAYLAND_wl_display_read_events(display); + WAYLAND_wl_display_dispatch_queue_pending(display, data->gles_swap_frame_event_queue); + } + SDL_SetAtomicInt(&data->swap_interval_ready, 0); + } + + if (!data->double_buffer) { + // Feed the frame to Wayland. This will set it so the wl_surface_frame callback can fire again. + if (!_this->egl_data->eglSwapBuffers(_this->egl_data->egl_display, data->egl_surface)) { + return SDL_EGL_SetError("unable to show color buffer in an OS-native window", "eglSwapBuffers"); + } + + WAYLAND_wl_display_flush(data->waylandData->display); + } + + return true; +} + +bool Wayland_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + bool result; + + if (window && context) { + result = SDL_EGL_MakeCurrent(_this, window->internal->egl_surface, context); + } else { + result = SDL_EGL_MakeCurrent(_this, NULL, NULL); + } + + WAYLAND_wl_display_flush(_this->internal->display); + + _this->egl_data->eglSwapInterval(_this->egl_data->egl_display, 0); // see comments on Wayland_GLES_SetSwapInterval. + + return result; +} + +bool Wayland_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + bool result = SDL_EGL_DestroyContext(_this, context); + WAYLAND_wl_display_flush(_this->internal->display); + return result; +} + +EGLSurface Wayland_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *windowdata = window->internal; + + return windowdata->egl_surface; +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND && SDL_VIDEO_OPENGL_EGL diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.h new file mode 100644 index 0000000..ed2e927 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandopengles.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_waylandopengles_h_ +#define SDL_waylandopengles_h_ + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +typedef struct SDL_PrivateGLESData +{ + int dummy; +} SDL_PrivateGLESData; + +// OpenGLES functions +#define Wayland_GLES_GetAttribute SDL_EGL_GetAttribute +#define Wayland_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define Wayland_GLES_UnloadLibrary SDL_EGL_UnloadLibrary + +extern bool Wayland_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_GLContext Wayland_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_GLES_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool Wayland_GLES_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern bool Wayland_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool Wayland_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern SDL_EGLSurface Wayland_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_waylandopengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.c new file mode 100644 index 0000000..8fc6d9e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.c @@ -0,0 +1,170 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include +#include +#include +#include +#include +#include + +#include "SDL_waylandshmbuffer.h" +#include "SDL_waylandvideo.h" + +static bool SetTempFileSize(int fd, off_t size) +{ +#ifdef HAVE_POSIX_FALLOCATE + sigset_t set, old_set; + int ret; + + /* SIGALRM can potentially block a large posix_fallocate() operation + * from succeeding, so block it. + */ + sigemptyset(&set); + sigaddset(&set, SIGALRM); + sigprocmask(SIG_BLOCK, &set, &old_set); + + do { + ret = posix_fallocate(fd, 0, size); + } while (ret == EINTR); + + sigprocmask(SIG_SETMASK, &old_set, NULL); + + if (ret == 0) { + return true; + } else if (ret != EINVAL && errno != EOPNOTSUPP) { + return false; + } +#endif + + if (ftruncate(fd, size) < 0) { + return false; + } + return true; +} + +static int CreateTempFD(off_t size) +{ + int fd; + +#ifdef HAVE_MEMFD_CREATE + fd = memfd_create("SDL", MFD_CLOEXEC | MFD_ALLOW_SEALING); + if (fd >= 0) { + fcntl(fd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_SEAL); + } else +#endif + { + static const char template[] = "/sdl-shared-XXXXXX"; + const char *xdg_path; + char tmp_path[PATH_MAX]; + + xdg_path = SDL_getenv("XDG_RUNTIME_DIR"); + if (!xdg_path) { + return -1; + } + + SDL_strlcpy(tmp_path, xdg_path, PATH_MAX); + SDL_strlcat(tmp_path, template, PATH_MAX); + + fd = mkostemp(tmp_path, O_CLOEXEC); + if (fd < 0) { + return -1; + } + + // Need to manually unlink the temp files, or they can persist after close and fill up the temp storage. + unlink(tmp_path); + } + + if (!SetTempFileSize(fd, size)) { + close(fd); + return -1; + } + + return fd; +} + +static void buffer_handle_release(void *data, struct wl_buffer *wl_buffer) +{ + // NOP +} + +static struct wl_buffer_listener buffer_listener = { + buffer_handle_release +}; + +bool Wayland_AllocSHMBuffer(int width, int height, struct Wayland_SHMBuffer *shmBuffer) +{ + SDL_VideoDevice *vd = SDL_GetVideoDevice(); + SDL_VideoData *data = vd->internal; + struct wl_shm_pool *shm_pool; + const Uint32 SHM_FMT = WL_SHM_FORMAT_ARGB8888; + + if (!shmBuffer) { + return SDL_InvalidParamError("shmBuffer"); + } + + const int stride = width * 4; + shmBuffer->shm_data_size = stride * height; + + const int shm_fd = CreateTempFD(shmBuffer->shm_data_size); + if (shm_fd < 0) { + return SDL_SetError("Creating SHM buffer failed."); + } + + shmBuffer->shm_data = mmap(NULL, shmBuffer->shm_data_size, PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0); + if (shmBuffer->shm_data == MAP_FAILED) { + shmBuffer->shm_data = NULL; + close(shm_fd); + return SDL_SetError("mmap() failed."); + } + + SDL_assert(shmBuffer->shm_data != NULL); + + shm_pool = wl_shm_create_pool(data->shm, shm_fd, shmBuffer->shm_data_size); + shmBuffer->wl_buffer = wl_shm_pool_create_buffer(shm_pool, 0, width, height, stride, SHM_FMT); + wl_buffer_add_listener(shmBuffer->wl_buffer, &buffer_listener, shmBuffer); + + wl_shm_pool_destroy(shm_pool); + close(shm_fd); + + return true; +} + +void Wayland_ReleaseSHMBuffer(struct Wayland_SHMBuffer *shmBuffer) +{ + if (shmBuffer) { + if (shmBuffer->wl_buffer) { + wl_buffer_destroy(shmBuffer->wl_buffer); + shmBuffer->wl_buffer = NULL; + } + if (shmBuffer->shm_data) { + munmap(shmBuffer->shm_data, shmBuffer->shm_data_size); + shmBuffer->shm_data = NULL; + } + shmBuffer->shm_data_size = 0; + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.h new file mode 100644 index 0000000..f6f49a4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandshmbuffer.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_waylandshmbuffer_h_ +#define SDL_waylandshmbuffer_h_ + +struct Wayland_SHMBuffer +{ + struct wl_buffer *wl_buffer; + void *shm_data; + int shm_data_size; +}; + +// Allocates an SHM buffer with the format WL_SHM_FORMAT_ARGB8888 +extern bool Wayland_AllocSHMBuffer(int width, int height, struct Wayland_SHMBuffer *shmBuffer); +extern void Wayland_ReleaseSHMBuffer(struct Wayland_SHMBuffer *shmBuffer); + +#endif diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandsym.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandsym.h new file mode 100644 index 0000000..846c876 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandsym.h @@ -0,0 +1,242 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* *INDENT-OFF* */ // clang-format off + +#ifndef SDL_WAYLAND_MODULE +#define SDL_WAYLAND_MODULE(modname) +#endif + +#ifndef SDL_WAYLAND_SYM +#define SDL_WAYLAND_SYM(rc,fn,params) +#endif + +#ifndef SDL_WAYLAND_SYM_OPT +#define SDL_WAYLAND_SYM_OPT(rc,fn,params) +#endif + +#ifndef SDL_WAYLAND_INTERFACE +#define SDL_WAYLAND_INTERFACE(iface) +#endif + +SDL_WAYLAND_MODULE(WAYLAND_CLIENT) +SDL_WAYLAND_SYM(void, wl_proxy_marshal, (struct wl_proxy *, uint32_t, ...)) +SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_create, (struct wl_proxy *, const struct wl_interface *)) +SDL_WAYLAND_SYM(void, wl_proxy_destroy, (struct wl_proxy *)) +SDL_WAYLAND_SYM(int, wl_proxy_add_listener, (struct wl_proxy *, void (**)(void), void *)) +SDL_WAYLAND_SYM(void, wl_proxy_set_user_data, (struct wl_proxy *, void *)) +SDL_WAYLAND_SYM(void *, wl_proxy_get_user_data, (struct wl_proxy *)) +SDL_WAYLAND_SYM(uint32_t, wl_proxy_get_version, (struct wl_proxy *)) +SDL_WAYLAND_SYM(uint32_t, wl_proxy_get_id, (struct wl_proxy *)) +SDL_WAYLAND_SYM(const char *, wl_proxy_get_class, (struct wl_proxy *)) +SDL_WAYLAND_SYM(void, wl_proxy_set_queue, (struct wl_proxy *, struct wl_event_queue *)) +SDL_WAYLAND_SYM(void *, wl_proxy_create_wrapper, (void *)) +SDL_WAYLAND_SYM(void, wl_proxy_wrapper_destroy, (void *)) +SDL_WAYLAND_SYM(struct wl_display *, wl_display_connect, (const char *)) +SDL_WAYLAND_SYM(struct wl_display *, wl_display_connect_to_fd, (int)) +SDL_WAYLAND_SYM(void, wl_display_disconnect, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_get_fd, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_dispatch, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_dispatch_queue, (struct wl_display *, struct wl_event_queue *)) +SDL_WAYLAND_SYM(int, wl_display_dispatch_queue_pending, (struct wl_display *, struct wl_event_queue *)) +SDL_WAYLAND_SYM(int, wl_display_dispatch_pending, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_prepare_read, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_prepare_read_queue, (struct wl_display *, struct wl_event_queue *)) +SDL_WAYLAND_SYM(int, wl_display_read_events, (struct wl_display *)) +SDL_WAYLAND_SYM(void, wl_display_cancel_read, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_get_error, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_flush, (struct wl_display *)) +SDL_WAYLAND_SYM(int, wl_display_roundtrip, (struct wl_display *)) +SDL_WAYLAND_SYM(struct wl_event_queue *, wl_display_create_queue, (struct wl_display *)) +SDL_WAYLAND_SYM(void, wl_event_queue_destroy, (struct wl_event_queue *)) +SDL_WAYLAND_SYM(void, wl_log_set_handler_client, (wl_log_func_t)) +SDL_WAYLAND_SYM(void, wl_list_init, (struct wl_list *)) +SDL_WAYLAND_SYM(void, wl_list_insert, (struct wl_list *, struct wl_list *) ) +SDL_WAYLAND_SYM(void, wl_list_remove, (struct wl_list *)) +SDL_WAYLAND_SYM(int, wl_list_length, (const struct wl_list *)) +SDL_WAYLAND_SYM(int, wl_list_empty, (const struct wl_list *)) +SDL_WAYLAND_SYM(void, wl_list_insert_list, (struct wl_list *, struct wl_list *)) +SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_marshal_constructor, (struct wl_proxy *, uint32_t opcode, const struct wl_interface *interface, ...)) +SDL_WAYLAND_SYM(struct wl_proxy *, wl_proxy_marshal_constructor_versioned, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, ...)) +SDL_WAYLAND_SYM(void, wl_proxy_set_tag, (struct wl_proxy *, const char * const *)) +SDL_WAYLAND_SYM(const char * const *, wl_proxy_get_tag, (struct wl_proxy *)) + +#if SDL_WAYLAND_CHECK_VERSION(1, 20, 0) +/* wayland-scanner 1.20 generates code that will call these, so these are + * non-optional when we are compiling against Wayland 1.20. We don't + * explicitly call them ourselves, though, so if we are only compiling + * against Wayland 1.18, they're unnecessary. */ +SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interfac, uint32_t version, uint32_t flags, ...)) +SDL_WAYLAND_SYM(struct wl_proxy*, wl_proxy_marshal_array_flags, (struct wl_proxy *proxy, uint32_t opcode, const struct wl_interface *interface, uint32_t version, uint32_t flags, union wl_argument *args)) +#endif + +#if 0 // TODO RECONNECT: See waylandvideo.c for more information! +#if SDL_WAYLAND_CHECK_VERSION(broken, on, purpose) +SDL_WAYLAND_SYM(int, wl_display_reconnect, (struct wl_display*)) +#endif +#endif // 0 + +SDL_WAYLAND_INTERFACE(wl_seat_interface) +SDL_WAYLAND_INTERFACE(wl_surface_interface) +SDL_WAYLAND_INTERFACE(wl_shm_pool_interface) +SDL_WAYLAND_INTERFACE(wl_buffer_interface) +SDL_WAYLAND_INTERFACE(wl_registry_interface) +SDL_WAYLAND_INTERFACE(wl_region_interface) +SDL_WAYLAND_INTERFACE(wl_pointer_interface) +SDL_WAYLAND_INTERFACE(wl_keyboard_interface) +SDL_WAYLAND_INTERFACE(wl_compositor_interface) +SDL_WAYLAND_INTERFACE(wl_output_interface) +SDL_WAYLAND_INTERFACE(wl_shm_interface) +SDL_WAYLAND_INTERFACE(wl_data_device_interface) +SDL_WAYLAND_INTERFACE(wl_data_source_interface) +SDL_WAYLAND_INTERFACE(wl_data_offer_interface) +SDL_WAYLAND_INTERFACE(wl_data_device_manager_interface) + +SDL_WAYLAND_MODULE(WAYLAND_EGL) +SDL_WAYLAND_SYM(struct wl_egl_window *, wl_egl_window_create, (struct wl_surface *, int, int)) +SDL_WAYLAND_SYM(void, wl_egl_window_destroy, (struct wl_egl_window *)) +SDL_WAYLAND_SYM(void, wl_egl_window_resize, (struct wl_egl_window *, int, int, int, int)) +SDL_WAYLAND_SYM(void, wl_egl_window_get_attached_size, (struct wl_egl_window *, int *, int *)) + +SDL_WAYLAND_MODULE(WAYLAND_CURSOR) +SDL_WAYLAND_SYM(struct wl_cursor_theme *, wl_cursor_theme_load, (const char *, int , struct wl_shm *)) +SDL_WAYLAND_SYM(void, wl_cursor_theme_destroy, (struct wl_cursor_theme *)) +SDL_WAYLAND_SYM(struct wl_cursor *, wl_cursor_theme_get_cursor, (struct wl_cursor_theme *, const char *)) +SDL_WAYLAND_SYM(struct wl_buffer *, wl_cursor_image_get_buffer, (struct wl_cursor_image *)) +SDL_WAYLAND_SYM(int, wl_cursor_frame, (struct wl_cursor *, uint32_t)) + +SDL_WAYLAND_MODULE(WAYLAND_XKB) +SDL_WAYLAND_SYM(int, xkb_state_key_get_syms, (struct xkb_state *, xkb_keycode_t, const xkb_keysym_t **)) +SDL_WAYLAND_SYM(int, xkb_keysym_to_utf8, (xkb_keysym_t, char *, size_t) ) +SDL_WAYLAND_SYM(struct xkb_keymap *, xkb_keymap_new_from_string, (struct xkb_context *, const char *, enum xkb_keymap_format, enum xkb_keymap_compile_flags)) +SDL_WAYLAND_SYM(struct xkb_state *, xkb_state_new, (struct xkb_keymap *) ) +SDL_WAYLAND_SYM(int, xkb_keymap_key_repeats, (struct xkb_keymap *keymap, xkb_keycode_t key) ) +SDL_WAYLAND_SYM(void, xkb_keymap_unref, (struct xkb_keymap *) ) +SDL_WAYLAND_SYM(void, xkb_state_unref, (struct xkb_state *) ) +SDL_WAYLAND_SYM(void, xkb_context_unref, (struct xkb_context *) ) +SDL_WAYLAND_SYM(struct xkb_context *, xkb_context_new, (enum xkb_context_flags flags) ) +SDL_WAYLAND_SYM(enum xkb_state_component, xkb_state_update_mask, (struct xkb_state *state,\ + xkb_mod_mask_t depressed_mods,\ + xkb_mod_mask_t latched_mods,\ + xkb_mod_mask_t locked_mods,\ + xkb_layout_index_t depressed_layout,\ + xkb_layout_index_t latched_layout,\ + xkb_layout_index_t locked_layout) ) +SDL_WAYLAND_SYM(struct xkb_compose_table *, xkb_compose_table_new_from_locale, (struct xkb_context *,\ + const char *locale, enum xkb_compose_compile_flags) ) +SDL_WAYLAND_SYM(void, xkb_compose_state_reset, (struct xkb_compose_state *) ) +SDL_WAYLAND_SYM(void, xkb_compose_table_unref, (struct xkb_compose_table *) ) +SDL_WAYLAND_SYM(struct xkb_compose_state *, xkb_compose_state_new, (struct xkb_compose_table *, enum xkb_compose_state_flags) ) +SDL_WAYLAND_SYM(void, xkb_compose_state_unref, (struct xkb_compose_state *) ) +SDL_WAYLAND_SYM(enum xkb_compose_feed_result, xkb_compose_state_feed, (struct xkb_compose_state *, xkb_keysym_t) ) +SDL_WAYLAND_SYM(enum xkb_compose_status, xkb_compose_state_get_status, (struct xkb_compose_state *) ) +SDL_WAYLAND_SYM(xkb_keysym_t, xkb_compose_state_get_one_sym, (struct xkb_compose_state *) ) +SDL_WAYLAND_SYM(void, xkb_keymap_key_for_each, (struct xkb_keymap *, xkb_keymap_key_iter_t, void*) ) +SDL_WAYLAND_SYM(int, xkb_keymap_key_get_syms_by_level, (struct xkb_keymap *, + xkb_keycode_t, + xkb_layout_index_t, + xkb_layout_index_t, + const xkb_keysym_t **) ) +SDL_WAYLAND_SYM(uint32_t, xkb_keysym_to_utf32, (xkb_keysym_t) ) +SDL_WAYLAND_SYM(uint32_t, xkb_keymap_mod_get_index, (struct xkb_keymap *, + const char *) ) +SDL_WAYLAND_SYM(const char *, xkb_keymap_layout_get_name, (struct xkb_keymap*, xkb_layout_index_t)) + +#ifdef HAVE_LIBDECOR_H +SDL_WAYLAND_MODULE(WAYLAND_LIBDECOR) +SDL_WAYLAND_SYM(void, libdecor_unref, (struct libdecor *)) +SDL_WAYLAND_SYM(struct libdecor *, libdecor_new, (struct wl_display *, struct libdecor_interface *)) +SDL_WAYLAND_SYM(struct libdecor_frame *, libdecor_decorate, (struct libdecor *,\ + struct wl_surface *,\ + struct libdecor_frame_interface *,\ + void *)) +SDL_WAYLAND_SYM(void, libdecor_frame_unref, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_title, (struct libdecor_frame *, const char *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_app_id, (struct libdecor_frame *, const char *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_max_content_size, (struct libdecor_frame *frame,\ + int content_width,\ + int content_height)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_min_content_size, (struct libdecor_frame *frame,\ + int content_width,\ + int content_height)) +SDL_WAYLAND_SYM(void, libdecor_frame_resize, (struct libdecor_frame *,\ + struct wl_seat *,\ + uint32_t,\ + enum libdecor_resize_edge)) +SDL_WAYLAND_SYM(void, libdecor_frame_move, (struct libdecor_frame *,\ + struct wl_seat *,\ + uint32_t)) +SDL_WAYLAND_SYM(void, libdecor_frame_commit, (struct libdecor_frame *,\ + struct libdecor_state *,\ + struct libdecor_configuration *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_minimized, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_maximized, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_unset_maximized, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_fullscreen, (struct libdecor_frame *, struct wl_output *)) +SDL_WAYLAND_SYM(void, libdecor_frame_unset_fullscreen, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_capabilities, (struct libdecor_frame *, \ + enum libdecor_capabilities)) +SDL_WAYLAND_SYM(void, libdecor_frame_unset_capabilities, (struct libdecor_frame *, \ + enum libdecor_capabilities)) +SDL_WAYLAND_SYM(bool, libdecor_frame_has_capability, (struct libdecor_frame *, \ + enum libdecor_capabilities)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_visibility, (struct libdecor_frame *, bool)) +SDL_WAYLAND_SYM(bool, libdecor_frame_is_visible, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(bool, libdecor_frame_is_floating, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_set_parent, (struct libdecor_frame *,\ + struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_show_window_menu, (struct libdecor_frame *, struct wl_seat *, uint32_t, int, int)) +SDL_WAYLAND_SYM(struct xdg_surface *, libdecor_frame_get_xdg_surface, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(struct xdg_toplevel *, libdecor_frame_get_xdg_toplevel, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(void, libdecor_frame_translate_coordinate, (struct libdecor_frame *, int, int, int *, int *)) +SDL_WAYLAND_SYM(void, libdecor_frame_map, (struct libdecor_frame *)) +SDL_WAYLAND_SYM(struct libdecor_state *, libdecor_state_new, (int, int)) +SDL_WAYLAND_SYM(void, libdecor_state_free, (struct libdecor_state *)) +SDL_WAYLAND_SYM(bool, libdecor_configuration_get_content_size, (struct libdecor_configuration *,\ + struct libdecor_frame *,\ + int *,\ + int *)) +SDL_WAYLAND_SYM(bool, libdecor_configuration_get_window_state, (struct libdecor_configuration *,\ + enum libdecor_window_state *)) +SDL_WAYLAND_SYM(int, libdecor_dispatch, (struct libdecor *, int)) + +#if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) || SDL_LIBDECOR_CHECK_VERSION(0, 2, 0) +// Only found in libdecor 0.1.1 or higher, so failure to load them is not fatal. +SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_min_content_size, (const struct libdecor_frame *,\ + int *,\ + int *)) +SDL_WAYLAND_SYM_OPT(void, libdecor_frame_get_max_content_size, (const struct libdecor_frame *,\ + int *,\ + int *)) +#endif + +#if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) || SDL_LIBDECOR_CHECK_VERSION(0, 3, 0) +SDL_WAYLAND_SYM_OPT(enum libdecor_wm_capabilities, libdecor_frame_get_wm_capabilities, (struct libdecor_frame *)) +#endif + +#endif + +#undef SDL_WAYLAND_MODULE +#undef SDL_WAYLAND_SYM +#undef SDL_WAYLAND_SYM_OPT +#undef SDL_WAYLAND_INTERFACE + +/* *INDENT-ON* */ // clang-format on diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.c new file mode 100644 index 0000000..4301953 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.c @@ -0,0 +1,1692 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include "../../core/linux/SDL_system_theme.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_waylandclipboard.h" +#include "SDL_waylandcolor.h" +#include "SDL_waylandevents_c.h" +#include "SDL_waylandkeyboard.h" +#include "SDL_waylandmessagebox.h" +#include "SDL_waylandmouse.h" +#include "SDL_waylandopengles.h" +#include "SDL_waylandvideo.h" +#include "SDL_waylandvulkan.h" +#include "SDL_waylandwindow.h" + +#include +#include +#include +#include + +#include + +#include "alpha-modifier-v1-client-protocol.h" +#include "cursor-shape-v1-client-protocol.h" +#include "fractional-scale-v1-client-protocol.h" +#include "frog-color-management-v1-client-protocol.h" +#include "idle-inhibit-unstable-v1-client-protocol.h" +#include "input-timestamps-unstable-v1-client-protocol.h" +#include "keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h" +#include "pointer-constraints-unstable-v1-client-protocol.h" +#include "primary-selection-unstable-v1-client-protocol.h" +#include "relative-pointer-unstable-v1-client-protocol.h" +#include "tablet-v2-client-protocol.h" +#include "text-input-unstable-v3-client-protocol.h" +#include "viewporter-client-protocol.h" +#include "xdg-activation-v1-client-protocol.h" +#include "xdg-decoration-unstable-v1-client-protocol.h" +#include "xdg-dialog-v1-client-protocol.h" +#include "xdg-foreign-unstable-v2-client-protocol.h" +#include "xdg-output-unstable-v1-client-protocol.h" +#include "xdg-shell-client-protocol.h" +#include "xdg-toplevel-icon-v1-client-protocol.h" +#include "color-management-v1-client-protocol.h" + +#ifdef HAVE_LIBDECOR_H +#include +#endif + +#define WAYLANDVID_DRIVER_NAME "wayland" + +// Clamp certain core protocol versions on older versions of libwayland. +#if SDL_WAYLAND_CHECK_VERSION(1, 22, 0) +#define SDL_WL_COMPOSITOR_VERSION 6 +#else +#define SDL_WL_COMPOSITOR_VERSION 4 +#endif + +#if SDL_WAYLAND_CHECK_VERSION(1, 22, 0) +#define SDL_WL_SEAT_VERSION 9 +#elif SDL_WAYLAND_CHECK_VERSION(1, 21, 0) +#define SDL_WL_SEAT_VERSION 8 +#else +#define SDL_WL_SEAT_VERSION 5 +#endif + +#if SDL_WAYLAND_CHECK_VERSION(1, 20, 0) +#define SDL_WL_OUTPUT_VERSION 4 +#else +#define SDL_WL_OUTPUT_VERSION 3 +#endif + +#ifdef SDL_USE_LIBDBUS +#include "../../core/linux/SDL_dbus.h" + +#define DISPLAY_INFO_NODE "org.gnome.Mutter.DisplayConfig" +#define DISPLAY_INFO_PATH "/org/gnome/Mutter/DisplayConfig" +#define DISPLAY_INFO_METHOD "GetCurrentState" +#endif + +/* GNOME doesn't expose displays in any particular order, but we can find the + * primary display and its logical coordinates via a DBus method. + */ +static bool Wayland_GetGNOMEPrimaryDisplayCoordinates(int *x, int *y) +{ +#ifdef SDL_USE_LIBDBUS + SDL_DBusContext *dbus = SDL_DBus_GetContext(); + if (dbus == NULL) { + return false; + } + DBusMessage *reply = NULL; + DBusMessageIter iter[3]; + DBusMessage *msg = dbus->message_new_method_call(DISPLAY_INFO_NODE, + DISPLAY_INFO_PATH, + DISPLAY_INFO_NODE, + DISPLAY_INFO_METHOD); + + if (msg) { + reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, DBUS_TIMEOUT_USE_DEFAULT, NULL); + dbus->message_unref(msg); + } + + if (reply) { + // Serial (don't care) + dbus->message_iter_init(reply, &iter[0]); + if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_UINT32) { + goto error; + } + + // Physical monitor array (don't care) + dbus->message_iter_next(&iter[0]); + if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_ARRAY) { + goto error; + } + + // Logical monitor array of structs + dbus->message_iter_next(&iter[0]); + if (dbus->message_iter_get_arg_type(&iter[0]) != DBUS_TYPE_ARRAY) { + goto error; + } + + // First logical monitor struct + dbus->message_iter_recurse(&iter[0], &iter[1]); + if (dbus->message_iter_get_arg_type(&iter[1]) != DBUS_TYPE_STRUCT) { + goto error; + } + + do { + int logical_x, logical_y; + dbus_bool_t primary; + + // Logical X + dbus->message_iter_recurse(&iter[1], &iter[2]); + if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_INT32) { + goto error; + } + dbus->message_iter_get_basic(&iter[2], &logical_x); + + // Logical Y + dbus->message_iter_next(&iter[2]); + if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_INT32) { + goto error; + } + dbus->message_iter_get_basic(&iter[2], &logical_y); + + // Scale (don't care) + dbus->message_iter_next(&iter[2]); + if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_DOUBLE) { + goto error; + } + + // Transform (don't care) + dbus->message_iter_next(&iter[2]); + if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_UINT32) { + goto error; + } + + // Primary display boolean + dbus->message_iter_next(&iter[2]); + if (dbus->message_iter_get_arg_type(&iter[2]) != DBUS_TYPE_BOOLEAN) { + goto error; + } + dbus->message_iter_get_basic(&iter[2], &primary); + + if (primary) { + *x = logical_x; + *y = logical_y; + + // We found the primary display: success. + dbus->message_unref(reply); + return true; + } + } while (dbus->message_iter_next(&iter[1])); + } + +error: + if (reply) { + dbus->message_unref(reply); + } +#endif + return false; +} + +// Sort the list of displays into a deterministic order +static int SDLCALL Wayland_DisplayPositionCompare(const void *a, const void *b) +{ + const SDL_DisplayData *da = *(SDL_DisplayData **)a; + const SDL_DisplayData *db = *(SDL_DisplayData **)b; + + const bool a_at_origin = da->x == 0 && da->y == 0; + const bool b_at_origin = db->x == 0 && db->y == 0; + + // Sort the display at 0,0 to be beginning of the list, as that will be the fallback primary. + if (a_at_origin && !b_at_origin) { + return -1; + } + if (b_at_origin && !a_at_origin) { + return 1; + } + if (da->x < db->x) { + return -1; + } + if (da->x > db->x) { + return 1; + } + if (da->y < db->y) { + return -1; + } + if (da->y > db->y) { + return 1; + } + + // If no position information is available, use the connector name. + if (da->wl_output_name && db->wl_output_name) { + return SDL_strcmp(da->wl_output_name, db->wl_output_name); + } + + return 0; +} + +/* Wayland doesn't have the native concept of a primary display, but there are clients that + * will base their resolution lists on, or automatically make themselves fullscreen on, the + * first listed output, which can lead to problems if the first listed output isn't + * necessarily the best display for this. This attempts to find a primary display, first by + * querying the GNOME DBus property, then trying to determine the 'best' display if that fails. + * If all displays are equal, the one at position 0,0 will become the primary. + * + * The primary is determined by the following criteria, in order: + * - Landscape is preferred over portrait + * - The highest native resolution + * - A higher HDR range is preferred + * - Higher refresh is preferred (ignoring small differences) + * - Lower scale values are preferred (larger display) + */ +static int Wayland_GetPrimaryDisplay(SDL_VideoData *vid) +{ + static const int REFRESH_DELTA = 4000; + + // Query the DBus interface to see if the coordinates of the primary display are exposed. + int x, y; + if (Wayland_GetGNOMEPrimaryDisplayCoordinates(&x, &y)) { + for (int i = 0; i < vid->output_count; ++i) { + if (vid->output_list[i]->x == x && vid->output_list[i]->y == y) { + return i; + } + } + } + + // Otherwise, choose the 'best' display. + int best_width = 0; + int best_height = 0; + double best_scale = 0.0; + float best_headroom = 0.0f; + int best_refresh = 0; + bool best_is_landscape = false; + int best_index = 0; + + for (int i = 0; i < vid->output_count; ++i) { + const SDL_DisplayData *d = vid->output_list[i]; + const bool is_landscape = d->orientation != SDL_ORIENTATION_PORTRAIT && d->orientation != SDL_ORIENTATION_PORTRAIT_FLIPPED; + bool have_new_best = false; + + if (!best_is_landscape && is_landscape) { // Favor landscape over portrait displays. + have_new_best = true; + } else if (!best_is_landscape || is_landscape) { // Ignore portrait displays if a landscape was already found. + if (d->pixel_width > best_width || d->pixel_height > best_height) { + have_new_best = true; + } else if (d->pixel_width == best_width && d->pixel_height == best_height) { + if (d->HDR.HDR_headroom > best_headroom) { // Favor a higher HDR luminance range + have_new_best = true; + } else if (d->HDR.HDR_headroom == best_headroom) { + if (d->refresh - best_refresh > REFRESH_DELTA) { // Favor a higher refresh rate, but ignore small differences (e.g. 59.97 vs 60.1) + have_new_best = true; + } else if (d->scale_factor < best_scale && SDL_abs(d->refresh - best_refresh) <= REFRESH_DELTA) { + // Prefer a lower scale display if the difference in refresh rate is small. + have_new_best = true; + } + } + } + } + + if (have_new_best) { + best_width = d->pixel_width; + best_height = d->pixel_height; + best_scale = d->scale_factor; + best_headroom = d->HDR.HDR_headroom; + best_refresh = d->refresh; + best_is_landscape = is_landscape; + best_index = i; + } + } + + return best_index; +} + +static void Wayland_SortOutputsByPriorityHint(SDL_VideoData *vid) +{ + const char *name_hint = SDL_GetHint(SDL_HINT_VIDEO_DISPLAY_PRIORITY); + + if (name_hint) { + char *saveptr; + char *str = SDL_strdup(name_hint); + SDL_DisplayData **sorted_list = SDL_malloc(sizeof(SDL_DisplayData *) * vid->output_count); + + if (str && sorted_list) { + int sorted_index = 0; + + // Sort the requested displays to the front of the list. + const char *token = SDL_strtok_r(str, ",", &saveptr); + while (token) { + for (int i = 0; i < vid->output_count; ++i) { + SDL_DisplayData *d = vid->output_list[i]; + if (d && d->wl_output_name && SDL_strcmp(token, d->wl_output_name) == 0) { + sorted_list[sorted_index++] = d; + vid->output_list[i] = NULL; + break; + } + } + + token = SDL_strtok_r(NULL, ",", &saveptr); + } + + // Append the remaining outputs to the end of the list. + for (int i = 0; i < vid->output_count; ++i) { + if (vid->output_list[i]) { + sorted_list[sorted_index++] = vid->output_list[i]; + } + } + + // Copy the sorted list to the output list. + SDL_memcpy(vid->output_list, sorted_list, sizeof(SDL_DisplayData *) * vid->output_count); + } + + SDL_free(str); + SDL_free(sorted_list); + } +} + +static void Wayland_SortOutputs(SDL_VideoData *vid) +{ + // Sort by position or connector name, so the order of outputs is deterministic. + SDL_qsort(vid->output_list, vid->output_count, sizeof(SDL_DisplayData *), Wayland_DisplayPositionCompare); + + // Find a suitable primary display and move it to the front of the list. + const int primary_index = Wayland_GetPrimaryDisplay(vid); + if (primary_index) { + SDL_DisplayData *primary = vid->output_list[primary_index]; + SDL_memmove(&vid->output_list[1], &vid->output_list[0], sizeof(SDL_DisplayData *) * primary_index); + vid->output_list[0] = primary; + } + + // Apply the ordering hint, if specified. + Wayland_SortOutputsByPriorityHint(vid); +} + +static void display_handle_done(void *data, struct wl_output *output); + +// Initialization/Query functions +static bool Wayland_VideoInit(SDL_VideoDevice *_this); +static bool Wayland_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); +static void Wayland_VideoQuit(SDL_VideoDevice *_this); + +static const char *SDL_WAYLAND_surface_tag = "sdl-window"; +static const char *SDL_WAYLAND_output_tag = "sdl-output"; + +void SDL_WAYLAND_register_surface(struct wl_surface *surface) +{ + wl_proxy_set_tag((struct wl_proxy *)surface, &SDL_WAYLAND_surface_tag); +} + +void SDL_WAYLAND_register_output(struct wl_output *output) +{ + wl_proxy_set_tag((struct wl_proxy *)output, &SDL_WAYLAND_output_tag); +} + +bool SDL_WAYLAND_own_surface(struct wl_surface *surface) +{ + return wl_proxy_get_tag((struct wl_proxy *)surface) == &SDL_WAYLAND_surface_tag; +} + +bool SDL_WAYLAND_own_output(struct wl_output *output) +{ + return wl_proxy_get_tag((struct wl_proxy *)output) == &SDL_WAYLAND_output_tag; +} + +/* External surfaces may have their own user data attached, the modification of which + * can cause problems with external toolkits. Instead, external windows are kept in + * their own list, and a search is conducted to find a matching surface. + */ +static struct wl_list external_window_list; + +void Wayland_AddWindowDataToExternalList(SDL_WindowData *data) +{ + WAYLAND_wl_list_insert(&external_window_list, &data->external_window_list_link); +} + +void Wayland_RemoveWindowDataFromExternalList(SDL_WindowData *data) +{ + WAYLAND_wl_list_remove(&data->external_window_list_link); +} + +SDL_WindowData *Wayland_GetWindowDataForOwnedSurface(struct wl_surface *surface) +{ + if (SDL_WAYLAND_own_surface(surface)) { + return (SDL_WindowData *)wl_surface_get_user_data(surface); + } else if (!WAYLAND_wl_list_empty(&external_window_list)) { + SDL_WindowData *p; + wl_list_for_each (p, &external_window_list, external_window_list_link) { + if (p->surface == surface) { + return p; + } + } + } + + return NULL; +} + +static void Wayland_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_VideoData *data = device->internal; + if (data->display && !data->display_externally_owned) { + WAYLAND_wl_display_flush(data->display); + WAYLAND_wl_display_disconnect(data->display); + SDL_ClearProperty(SDL_GetGlobalProperties(), SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER); + } + if (device->wakeup_lock) { + SDL_DestroyMutex(device->wakeup_lock); + } + SDL_free(data); + SDL_free(device); + SDL_WAYLAND_UnloadSymbols(); +} + +typedef struct +{ + bool has_fifo_v1; +} SDL_WaylandPreferredData; + +static void wayland_preferred_check_handle_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) +{ + SDL_WaylandPreferredData *d = data; + + if (SDL_strcmp(interface, "wp_fifo_manager_v1") == 0) { + d->has_fifo_v1 = true; + } +} + +static void wayland_preferred_check_remove_global(void *data, struct wl_registry *registry, uint32_t id) +{ + // No need to do anything here. +} + +static const struct wl_registry_listener preferred_registry_listener = { + wayland_preferred_check_handle_global, + wayland_preferred_check_remove_global +}; + +static bool Wayland_IsPreferred(struct wl_display *display) +{ + struct wl_registry *registry = wl_display_get_registry(display); + SDL_WaylandPreferredData preferred_data = { 0 }; + + if (!registry) { + SDL_SetError("Failed to get the Wayland registry"); + return false; + } + + wl_registry_add_listener(registry, &preferred_registry_listener, &preferred_data); + + WAYLAND_wl_display_roundtrip(display); + + wl_registry_destroy(registry); + + return preferred_data.has_fifo_v1; +} + +static SDL_VideoDevice *Wayland_CreateDevice(bool require_preferred_protocols) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + struct SDL_WaylandInput *input; + struct wl_display *display = SDL_GetPointerProperty(SDL_GetGlobalProperties(), + SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER, NULL); + bool display_is_external = !!display; + + // Are we trying to connect to or are currently in a Wayland session? + if (!SDL_getenv("WAYLAND_DISPLAY")) { + const char *session = SDL_getenv("XDG_SESSION_TYPE"); + if (session && SDL_strcasecmp(session, "wayland") != 0) { + return NULL; + } + } + + if (!SDL_WAYLAND_LoadSymbols()) { + return NULL; + } + + if (!display) { + display = WAYLAND_wl_display_connect(NULL); + if (!display) { + SDL_WAYLAND_UnloadSymbols(); + return NULL; + } + } + + /* + * If we are checking for preferred Wayland, then let's query for + * fifo-v1's existence, so we don't regress GPU-bound performance + * and frame-pacing by default due to swapchain starvation. + */ + if (require_preferred_protocols && !Wayland_IsPreferred(display)) { + if (!display_is_external) { + WAYLAND_wl_display_disconnect(display); + } + SDL_WAYLAND_UnloadSymbols(); + return NULL; + } + + data = SDL_calloc(1, sizeof(*data)); + if (!data) { + if (!display_is_external) { + WAYLAND_wl_display_disconnect(display); + } + SDL_WAYLAND_UnloadSymbols(); + return NULL; + } + + input = SDL_calloc(1, sizeof(*input)); + if (!input) { + SDL_free(data); + if (!display_is_external) { + WAYLAND_wl_display_disconnect(display); + } + SDL_WAYLAND_UnloadSymbols(); + return NULL; + } + + input->display = data; + input->sx_w = wl_fixed_from_int(0); + input->sy_w = wl_fixed_from_int(0); + input->xkb.current_group = XKB_GROUP_INVALID; + + data->initializing = true; + data->display = display; + data->input = input; + data->display_externally_owned = display_is_external; + data->scale_to_display_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_SCALE_TO_DISPLAY, false); + WAYLAND_wl_list_init(&external_window_list); + + // Initialize all variables that we clean on shutdown + device = SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + SDL_free(input); + SDL_free(data); + if (!display_is_external) { + WAYLAND_wl_display_disconnect(display); + } + SDL_WAYLAND_UnloadSymbols(); + return NULL; + } + + if (!display_is_external) { + SDL_SetPointerProperty(SDL_GetGlobalProperties(), + SDL_PROP_GLOBAL_VIDEO_WAYLAND_WL_DISPLAY_POINTER, display); + } + + device->internal = data; + device->wakeup_lock = SDL_CreateMutex(); + + // Set the function pointers + device->VideoInit = Wayland_VideoInit; + device->VideoQuit = Wayland_VideoQuit; + device->GetDisplayBounds = Wayland_GetDisplayBounds; + device->SuspendScreenSaver = Wayland_SuspendScreenSaver; + + device->PumpEvents = Wayland_PumpEvents; + device->WaitEventTimeout = Wayland_WaitEventTimeout; + device->SendWakeupEvent = Wayland_SendWakeupEvent; + +#ifdef SDL_VIDEO_OPENGL_EGL + device->GL_SwapWindow = Wayland_GLES_SwapWindow; + device->GL_GetSwapInterval = Wayland_GLES_GetSwapInterval; + device->GL_SetSwapInterval = Wayland_GLES_SetSwapInterval; + device->GL_MakeCurrent = Wayland_GLES_MakeCurrent; + device->GL_CreateContext = Wayland_GLES_CreateContext; + device->GL_LoadLibrary = Wayland_GLES_LoadLibrary; + device->GL_UnloadLibrary = Wayland_GLES_UnloadLibrary; + device->GL_GetProcAddress = Wayland_GLES_GetProcAddress; + device->GL_DestroyContext = Wayland_GLES_DestroyContext; + device->GL_GetEGLSurface = Wayland_GLES_GetEGLSurface; +#endif + + device->CreateSDLWindow = Wayland_CreateWindow; + device->ShowWindow = Wayland_ShowWindow; + device->HideWindow = Wayland_HideWindow; + device->RaiseWindow = Wayland_RaiseWindow; + device->SetWindowFullscreen = Wayland_SetWindowFullscreen; + device->MaximizeWindow = Wayland_MaximizeWindow; + device->MinimizeWindow = Wayland_MinimizeWindow; + device->SetWindowMouseRect = Wayland_SetWindowMouseRect; + device->SetWindowMouseGrab = Wayland_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = Wayland_SetWindowKeyboardGrab; + device->RestoreWindow = Wayland_RestoreWindow; + device->SetWindowBordered = Wayland_SetWindowBordered; + device->SetWindowResizable = Wayland_SetWindowResizable; + device->SetWindowPosition = Wayland_SetWindowPosition; + device->SetWindowSize = Wayland_SetWindowSize; + device->SetWindowMinimumSize = Wayland_SetWindowMinimumSize; + device->SetWindowMaximumSize = Wayland_SetWindowMaximumSize; + device->SetWindowParent = Wayland_SetWindowParent; + device->SetWindowModal = Wayland_SetWindowModal; + device->SetWindowOpacity = Wayland_SetWindowOpacity; + device->SetWindowTitle = Wayland_SetWindowTitle; + device->SetWindowIcon = Wayland_SetWindowIcon; + device->GetWindowSizeInPixels = Wayland_GetWindowSizeInPixels; + device->GetWindowContentScale = Wayland_GetWindowContentScale; + device->GetWindowICCProfile = Wayland_GetWindowICCProfile; + device->GetDisplayForWindow = Wayland_GetDisplayForWindow; + device->DestroyWindow = Wayland_DestroyWindow; + device->SetWindowHitTest = Wayland_SetWindowHitTest; + device->FlashWindow = Wayland_FlashWindow; + device->HasScreenKeyboardSupport = Wayland_HasScreenKeyboardSupport; + device->ShowWindowSystemMenu = Wayland_ShowWindowSystemMenu; + device->SyncWindow = Wayland_SyncWindow; + +#ifdef SDL_USE_LIBDBUS + if (SDL_SystemTheme_Init()) + device->system_theme = SDL_SystemTheme_Get(); +#endif + + device->GetTextMimeTypes = Wayland_GetTextMimeTypes; + device->SetClipboardData = Wayland_SetClipboardData; + device->GetClipboardData = Wayland_GetClipboardData; + device->HasClipboardData = Wayland_HasClipboardData; + device->StartTextInput = Wayland_StartTextInput; + device->StopTextInput = Wayland_StopTextInput; + device->UpdateTextInputArea = Wayland_UpdateTextInputArea; + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = Wayland_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = Wayland_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = Wayland_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = Wayland_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = Wayland_Vulkan_DestroySurface; + device->Vulkan_GetPresentationSupport = Wayland_Vulkan_GetPresentationSupport; +#endif + + device->free = Wayland_DeleteDevice; + + device->device_caps = VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED | + VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT | + VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS | + VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES | + VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS | + VIDEO_DEVICE_CAPS_SENDS_HDR_CHANGES; + + return device; +} + +static SDL_VideoDevice *Wayland_Preferred_CreateDevice(void) +{ + return Wayland_CreateDevice(true); +} + +static SDL_VideoDevice *Wayland_Fallback_CreateDevice(void) +{ + return Wayland_CreateDevice(false); +} + +VideoBootStrap Wayland_preferred_bootstrap = { + WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver", + Wayland_Preferred_CreateDevice, + Wayland_ShowMessageBox, + true +}; + +VideoBootStrap Wayland_bootstrap = { + WAYLANDVID_DRIVER_NAME, "SDL Wayland video driver", + Wayland_Fallback_CreateDevice, + Wayland_ShowMessageBox, + false +}; + +static void xdg_output_handle_logical_position(void *data, struct zxdg_output_v1 *xdg_output, + int32_t x, int32_t y) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + internal->x = x; + internal->y = y; + internal->has_logical_position = true; +} + +static void xdg_output_handle_logical_size(void *data, struct zxdg_output_v1 *xdg_output, + int32_t width, int32_t height) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + internal->logical_width = width; + internal->logical_height = height; + internal->has_logical_size = true; +} + +static void xdg_output_handle_done(void *data, struct zxdg_output_v1 *xdg_output) +{ + SDL_DisplayData *internal = data; + + /* + * xdg-output.done events are deprecated and only apply below version 3 of the protocol. + * A wl-output.done event will be emitted in version 3 or higher. + */ + if (zxdg_output_v1_get_version(internal->xdg_output) < 3) { + display_handle_done(data, internal->output); + } +} + +static void xdg_output_handle_name(void *data, struct zxdg_output_v1 *xdg_output, + const char *name) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + // Deprecated as of wl_output v4. + if (wl_output_get_version(internal->output) < WL_OUTPUT_NAME_SINCE_VERSION && + internal->display == 0) { + SDL_free(internal->wl_output_name); + internal->wl_output_name = SDL_strdup(name); + } +} + +static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg_output, + const char *description) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + // Deprecated as of wl_output v4. + if (wl_output_get_version(internal->output) < WL_OUTPUT_DESCRIPTION_SINCE_VERSION && + internal->display == 0) { + // xdg-output descriptions, if available, supersede wl-output model names. + SDL_free(internal->placeholder.name); + internal->placeholder.name = SDL_strdup(description); + } +} + +static const struct zxdg_output_v1_listener xdg_output_listener = { + xdg_output_handle_logical_position, + xdg_output_handle_logical_size, + xdg_output_handle_done, + xdg_output_handle_name, + xdg_output_handle_description, +}; + +static void AddEmulatedModes(SDL_DisplayData *dispdata, int native_width, int native_height) +{ + struct EmulatedMode + { + int w; + int h; + }; + + // Resolution lists courtesy of XWayland + const struct EmulatedMode mode_list[] = { + // 16:9 (1.77) + { 7680, 4320 }, + { 6144, 3160 }, + { 5120, 2880 }, + { 4096, 2304 }, + { 3840, 2160 }, + { 3200, 1800 }, + { 2880, 1620 }, + { 2560, 1440 }, + { 2048, 1152 }, + { 1920, 1080 }, + { 1600, 900 }, + { 1368, 768 }, + { 1280, 720 }, + { 864, 486 }, + + // 16:10 (1.6) + { 2560, 1600 }, + { 1920, 1200 }, + { 1680, 1050 }, + { 1440, 900 }, + { 1280, 800 }, + + // 3:2 (1.5) + { 720, 480 }, + + // 4:3 (1.33) + { 2048, 1536 }, + { 1920, 1440 }, + { 1600, 1200 }, + { 1440, 1080 }, + { 1400, 1050 }, + { 1280, 1024 }, + { 1280, 960 }, + { 1152, 864 }, + { 1024, 768 }, + { 800, 600 }, + { 640, 480 } + }; + + int i; + SDL_DisplayMode mode; + SDL_VideoDisplay *dpy = dispdata->display ? SDL_GetVideoDisplay(dispdata->display) : &dispdata->placeholder; + const bool rot_90 = native_width < native_height; // Reverse width/height for portrait displays. + + for (i = 0; i < SDL_arraysize(mode_list); ++i) { + SDL_zero(mode); + mode.format = dpy->desktop_mode.format; + mode.refresh_rate_numerator = dpy->desktop_mode.refresh_rate_numerator; + mode.refresh_rate_denominator = dpy->desktop_mode.refresh_rate_denominator; + + if (rot_90) { + mode.w = mode_list[i].h; + mode.h = mode_list[i].w; + } else { + mode.w = mode_list[i].w; + mode.h = mode_list[i].h; + } + + // Only add modes that are smaller than the native mode. + if ((mode.w < native_width && mode.h < native_height) || + (mode.w < native_width && mode.h == native_height) || + (mode.w == native_width && mode.h < native_height)) { + SDL_AddFullscreenDisplayMode(dpy, &mode); + } + } +} + +static void display_handle_geometry(void *data, + struct wl_output *output, + int x, int y, + int physical_width, + int physical_height, + int subpixel, + const char *make, + const char *model, + int transform) + +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + // Apply the change from wl-output only if xdg-output is not supported + if (!internal->has_logical_position) { + internal->x = x; + internal->y = y; + } + internal->physical_width_mm = physical_width; + internal->physical_height_mm = physical_height; + + // The model is only used for the output name if wl_output or xdg-output haven't provided a description. + if (internal->display == 0 && !internal->placeholder.name) { + internal->placeholder.name = SDL_strdup(model); + } + + internal->transform = transform; +#define TF_CASE(in, out) \ + case WL_OUTPUT_TRANSFORM_##in: \ + internal->orientation = SDL_ORIENTATION_##out; \ + break; + if (internal->physical_width_mm >= internal->physical_height_mm) { + switch (transform) { + TF_CASE(NORMAL, LANDSCAPE) + TF_CASE(90, PORTRAIT) + TF_CASE(180, LANDSCAPE_FLIPPED) + TF_CASE(270, PORTRAIT_FLIPPED) + TF_CASE(FLIPPED, LANDSCAPE_FLIPPED) + TF_CASE(FLIPPED_90, PORTRAIT_FLIPPED) + TF_CASE(FLIPPED_180, LANDSCAPE) + TF_CASE(FLIPPED_270, PORTRAIT) + } + } else { + switch (transform) { + TF_CASE(NORMAL, PORTRAIT) + TF_CASE(90, LANDSCAPE) + TF_CASE(180, PORTRAIT_FLIPPED) + TF_CASE(270, LANDSCAPE_FLIPPED) + TF_CASE(FLIPPED, PORTRAIT_FLIPPED) + TF_CASE(FLIPPED_90, LANDSCAPE_FLIPPED) + TF_CASE(FLIPPED_180, PORTRAIT) + TF_CASE(FLIPPED_270, LANDSCAPE) + } + } +#undef TF_CASE +} + +static void display_handle_mode(void *data, + struct wl_output *output, + uint32_t flags, + int width, + int height, + int refresh) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + if (flags & WL_OUTPUT_MODE_CURRENT) { + internal->pixel_width = width; + internal->pixel_height = height; + + /* + * Don't rotate this yet, wl-output coordinates are transformed in + * handle_done and xdg-output coordinates are pre-transformed. + */ + if (!internal->has_logical_size) { + internal->logical_width = width; + internal->logical_height = height; + } + + internal->refresh = refresh; + } +} + +static void display_handle_done(void *data, + struct wl_output *output) +{ + const bool mode_emulation_enabled = SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_MODE_EMULATION, true); + SDL_DisplayData *internal = (SDL_DisplayData *)data; + SDL_VideoData *video = internal->videodata; + SDL_DisplayMode native_mode, desktop_mode; + + /* + * When using xdg-output, two wl-output.done events will be emitted: + * one at the completion of wl-display and one at the completion of xdg-output. + * + * All required events must be received before proceeding. + */ + const int event_await_count = 1 + (internal->xdg_output != NULL); + + internal->wl_output_done_count = SDL_min(internal->wl_output_done_count + 1, event_await_count + 1); + + if (internal->wl_output_done_count < event_await_count) { + return; + } + + // If the display was already created, reset and rebuild the mode list. + SDL_VideoDisplay *dpy = SDL_GetVideoDisplay(internal->display); + if (dpy) { + SDL_ResetFullscreenDisplayModes(dpy); + } + + // The native display resolution + SDL_zero(native_mode); + native_mode.format = SDL_PIXELFORMAT_XRGB8888; + + // Transform the pixel values, if necessary. + if (internal->transform & WL_OUTPUT_TRANSFORM_90) { + native_mode.w = internal->pixel_height; + native_mode.h = internal->pixel_width; + } else { + native_mode.w = internal->pixel_width; + native_mode.h = internal->pixel_height; + } + native_mode.refresh_rate_numerator = internal->refresh; + native_mode.refresh_rate_denominator = 1000; + + if (internal->has_logical_size) { // If xdg-output is present... + if (native_mode.w != internal->logical_width || native_mode.h != internal->logical_height) { + // ...and the compositor scales the logical viewport... + if (video->viewporter) { + // ...and viewports are supported, calculate the true scale of the output. + internal->scale_factor = (double)native_mode.w / (double)internal->logical_width; + } else { + // ...otherwise, the 'native' pixel values are a multiple of the logical screen size. + internal->pixel_width = internal->logical_width * (int)internal->scale_factor; + internal->pixel_height = internal->logical_height * (int)internal->scale_factor; + } + } else { + /* ...and the output viewport is not scaled in the global compositing + * space, the output dimensions need to be divided by the scale factor. + */ + internal->logical_width /= (int)internal->scale_factor; + internal->logical_height /= (int)internal->scale_factor; + } + } else { + /* Calculate the points from the pixel values, if xdg-output isn't present. + * Use the native mode pixel values since they are pre-transformed. + */ + internal->logical_width = native_mode.w / (int)internal->scale_factor; + internal->logical_height = native_mode.h / (int)internal->scale_factor; + } + + // The scaled desktop mode + SDL_zero(desktop_mode); + desktop_mode.format = SDL_PIXELFORMAT_XRGB8888; + + if (!video->scale_to_display_enabled) { + desktop_mode.w = internal->logical_width; + desktop_mode.h = internal->logical_height; + desktop_mode.pixel_density = (float)internal->scale_factor; + } else { + desktop_mode.w = native_mode.w; + desktop_mode.h = native_mode.h; + desktop_mode.pixel_density = 1.0f; + } + + desktop_mode.refresh_rate_numerator = internal->refresh; + desktop_mode.refresh_rate_denominator = 1000; + + if (internal->display > 0) { + dpy = SDL_GetVideoDisplay(internal->display); + } else { + dpy = &internal->placeholder; + } + + if (video->scale_to_display_enabled) { + SDL_SetDisplayContentScale(dpy, (float)internal->scale_factor); + } + + // Set the desktop display mode. + SDL_SetDesktopDisplayMode(dpy, &desktop_mode); + + // Expose the unscaled, native resolution if the scale is 1.0 or viewports are available... + if (internal->scale_factor == 1.0 || video->viewporter) { + SDL_AddFullscreenDisplayMode(dpy, &native_mode); + if (native_mode.w != desktop_mode.w || + native_mode.h != desktop_mode.h) { + SDL_AddFullscreenDisplayMode(dpy, &desktop_mode); + } + } else { + // ...otherwise expose the integer scaled variants of the desktop resolution down to 1. + int i; + + desktop_mode.pixel_density = 1.0f; + + for (i = (int)internal->scale_factor; i > 0; --i) { + desktop_mode.w = internal->logical_width * i; + desktop_mode.h = internal->logical_height * i; + SDL_AddFullscreenDisplayMode(dpy, &desktop_mode); + } + } + + // Add emulated modes if wp_viewporter is supported and mode emulation is enabled. + if (video->viewporter && mode_emulation_enabled) { + // The transformed display pixel width/height must be used here. + AddEmulatedModes(internal, native_mode.w, native_mode.h); + } + + SDL_SetDisplayHDRProperties(dpy, &internal->HDR); + + if (internal->display == 0) { + // First time getting display info, initialize the VideoDisplay + if (internal->physical_width_mm >= internal->physical_height_mm) { + internal->placeholder.natural_orientation = SDL_ORIENTATION_LANDSCAPE; + } else { + internal->placeholder.natural_orientation = SDL_ORIENTATION_PORTRAIT; + } + internal->placeholder.current_orientation = internal->orientation; + internal->placeholder.internal = internal; + + // During initialization, the displays will be added after enumeration is complete. + if (!video->initializing) { + internal->display = SDL_AddVideoDisplay(&internal->placeholder, true); + SDL_free(internal->placeholder.name); + SDL_zero(internal->placeholder); + } + } else { + SDL_SendDisplayEvent(dpy, SDL_EVENT_DISPLAY_ORIENTATION, internal->orientation, 0); + } +} + +static void display_handle_scale(void *data, + struct wl_output *output, + int32_t factor) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + internal->scale_factor = factor; +} + +static void display_handle_name(void *data, struct wl_output *wl_output, const char *name) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + SDL_free(internal->wl_output_name); + internal->wl_output_name = SDL_strdup(name); +} + +static void display_handle_description(void *data, struct wl_output *wl_output, const char *description) +{ + SDL_DisplayData *internal = (SDL_DisplayData *)data; + + if (internal->display == 0) { + // The description, if available, supersedes the model name. + SDL_free(internal->placeholder.name); + internal->placeholder.name = SDL_strdup(description); + } +} + +static const struct wl_output_listener output_listener = { + display_handle_geometry, // Version 1 + display_handle_mode, // Version 1 + display_handle_done, // Version 2 + display_handle_scale, // Version 2 + display_handle_name, // Version 4 + display_handle_description // Version 4 +}; + +static void handle_output_image_description_changed(void *data, + struct wp_color_management_output_v1 *wp_color_management_output_v1) +{ + SDL_DisplayData *display = (SDL_DisplayData *)data; + // wl_display.done is called after this event, so the display HDR status will be updated there. + Wayland_GetColorInfoForOutput(display, false); +} + +static const struct wp_color_management_output_v1_listener wp_color_management_output_listener = { + handle_output_image_description_changed +}; + +static bool Wayland_add_display(SDL_VideoData *d, uint32_t id, uint32_t version) +{ + struct wl_output *output; + SDL_DisplayData *data; + + output = wl_registry_bind(d->registry, id, &wl_output_interface, version); + if (!output) { + return SDL_SetError("Failed to retrieve output."); + } + data = (SDL_DisplayData *)SDL_calloc(1, sizeof(*data)); + data->videodata = d; + data->output = output; + data->registry_id = id; + data->scale_factor = 1.0f; + + wl_output_add_listener(output, &output_listener, data); + SDL_WAYLAND_register_output(output); + + // Keep a list of outputs for sorting and deferred protocol initialization. + if (d->output_count == d->output_max) { + d->output_max += 4; + d->output_list = SDL_realloc(d->output_list, sizeof(SDL_DisplayData *) * d->output_max); + } + d->output_list[d->output_count++] = data; + + if (data->videodata->xdg_output_manager) { + data->xdg_output = zxdg_output_manager_v1_get_xdg_output(data->videodata->xdg_output_manager, output); + zxdg_output_v1_add_listener(data->xdg_output, &xdg_output_listener, data); + } + if (data->videodata->wp_color_manager_v1) { + data->wp_color_management_output = wp_color_manager_v1_get_output(data->videodata->wp_color_manager_v1, output); + wp_color_management_output_v1_add_listener(data->wp_color_management_output, &wp_color_management_output_listener, data); + Wayland_GetColorInfoForOutput(data, true); + } + return true; +} + +static void Wayland_free_display(SDL_VideoDisplay *display, bool send_event) +{ + if (display) { + SDL_DisplayData *display_data = display->internal; + + /* A preceding surface leave event is not guaranteed when an output is removed, + * so ensure that no window continues to hold a reference to a removed output. + */ + for (SDL_Window *window = SDL_GetVideoDevice()->windows; window; window = window->next) { + Wayland_RemoveOutputFromWindow(window->internal, display_data); + } + + SDL_free(display_data->wl_output_name); + + if (display_data->wp_color_management_output) { + Wayland_FreeColorInfoState(display_data->color_info_state); + wp_color_management_output_v1_destroy(display_data->wp_color_management_output); + } + + if (display_data->xdg_output) { + zxdg_output_v1_destroy(display_data->xdg_output); + } + + if (wl_output_get_version(display_data->output) >= WL_OUTPUT_RELEASE_SINCE_VERSION) { + wl_output_release(display_data->output); + } else { + wl_output_destroy(display_data->output); + } + + SDL_DelVideoDisplay(display->id, send_event); + } +} + +static void Wayland_FinalizeDisplays(SDL_VideoData *vid) +{ + Wayland_SortOutputs(vid); + for(int i = 0; i < vid->output_count; ++i) { + SDL_DisplayData *d = vid->output_list[i]; + d->display = SDL_AddVideoDisplay(&d->placeholder, false); + SDL_free(d->placeholder.name); + SDL_zero(d->placeholder); + } +} + +static void Wayland_init_xdg_output(SDL_VideoData *d) +{ + for (int i = 0; i < d->output_count; ++i) { + SDL_DisplayData *disp = d->output_list[i]; + disp->xdg_output = zxdg_output_manager_v1_get_xdg_output(disp->videodata->xdg_output_manager, disp->output); + zxdg_output_v1_add_listener(disp->xdg_output, &xdg_output_listener, disp); + } +} + +static void Wayland_InitColorManager(SDL_VideoData *d) +{ + for (int i = 0; i < d->output_count; ++i) { + SDL_DisplayData *disp = d->output_list[i]; + disp->wp_color_management_output = wp_color_manager_v1_get_output(disp->videodata->wp_color_manager_v1, disp->output); + wp_color_management_output_v1_add_listener(disp->wp_color_management_output, &wp_color_management_output_listener, disp); + Wayland_GetColorInfoForOutput(disp, true); + } +} + +static void handle_ping_xdg_wm_base(void *data, struct xdg_wm_base *xdg, uint32_t serial) +{ + xdg_wm_base_pong(xdg, serial); +} + +static const struct xdg_wm_base_listener shell_listener_xdg = { + handle_ping_xdg_wm_base +}; + +#ifdef HAVE_LIBDECOR_H +static void libdecor_error(struct libdecor *context, + enum libdecor_error error, + const char *message) +{ + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "libdecor error (%d): %s", error, message); +} + +static struct libdecor_interface libdecor_interface = { + libdecor_error, +}; +#endif + +static void display_handle_global(void *data, struct wl_registry *registry, uint32_t id, + const char *interface, uint32_t version) +{ + SDL_VideoData *d = data; + + // printf("WAYLAND INTERFACE: %s\n", interface); + + if (SDL_strcmp(interface, "wl_compositor") == 0) { + d->compositor = wl_registry_bind(d->registry, id, &wl_compositor_interface, SDL_min(SDL_WL_COMPOSITOR_VERSION, version)); + } else if (SDL_strcmp(interface, "wl_output") == 0) { + Wayland_add_display(d, id, SDL_min(version, SDL_WL_OUTPUT_VERSION)); + } else if (SDL_strcmp(interface, "wl_seat") == 0) { + d->input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, SDL_min(SDL_WL_SEAT_VERSION, version)); + Wayland_input_initialize_seat(d); + } else if (SDL_strcmp(interface, "xdg_wm_base") == 0) { + d->shell.xdg = wl_registry_bind(d->registry, id, &xdg_wm_base_interface, SDL_min(version, 6)); + xdg_wm_base_add_listener(d->shell.xdg, &shell_listener_xdg, NULL); + } else if (SDL_strcmp(interface, "wl_shm") == 0) { + d->shm = wl_registry_bind(registry, id, &wl_shm_interface, 1); + } else if (SDL_strcmp(interface, "zwp_relative_pointer_manager_v1") == 0) { + d->relative_pointer_manager = wl_registry_bind(d->registry, id, &zwp_relative_pointer_manager_v1_interface, 1); + Wayland_input_init_relative_pointer(d); + } else if (SDL_strcmp(interface, "zwp_pointer_constraints_v1") == 0) { + d->pointer_constraints = wl_registry_bind(d->registry, id, &zwp_pointer_constraints_v1_interface, 1); + } else if (SDL_strcmp(interface, "zwp_keyboard_shortcuts_inhibit_manager_v1") == 0) { + d->key_inhibitor_manager = wl_registry_bind(d->registry, id, &zwp_keyboard_shortcuts_inhibit_manager_v1_interface, 1); + } else if (SDL_strcmp(interface, "zwp_idle_inhibit_manager_v1") == 0) { + d->idle_inhibit_manager = wl_registry_bind(d->registry, id, &zwp_idle_inhibit_manager_v1_interface, 1); + } else if (SDL_strcmp(interface, "xdg_activation_v1") == 0) { + d->activation_manager = wl_registry_bind(d->registry, id, &xdg_activation_v1_interface, 1); + } else if (SDL_strcmp(interface, "zwp_text_input_manager_v3") == 0) { + Wayland_create_text_input_manager(d, id); + } else if (SDL_strcmp(interface, "wl_data_device_manager") == 0) { + d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version)); + Wayland_create_data_device(d); + } else if (SDL_strcmp(interface, "zwp_primary_selection_device_manager_v1") == 0) { + d->primary_selection_device_manager = wl_registry_bind(d->registry, id, &zwp_primary_selection_device_manager_v1_interface, 1); + Wayland_create_primary_selection_device(d); + } else if (SDL_strcmp(interface, "zxdg_decoration_manager_v1") == 0) { + d->decoration_manager = wl_registry_bind(d->registry, id, &zxdg_decoration_manager_v1_interface, 1); + } else if (SDL_strcmp(interface, "zwp_tablet_manager_v2") == 0) { + d->tablet_manager = wl_registry_bind(d->registry, id, &zwp_tablet_manager_v2_interface, 1); + Wayland_input_init_tablet_support(d->input, d->tablet_manager); + } else if (SDL_strcmp(interface, "zxdg_output_manager_v1") == 0) { + version = SDL_min(version, 3); // Versions 1 through 3 are supported. + d->xdg_output_manager = wl_registry_bind(d->registry, id, &zxdg_output_manager_v1_interface, version); + Wayland_init_xdg_output(d); + } else if (SDL_strcmp(interface, "wp_viewporter") == 0) { + d->viewporter = wl_registry_bind(d->registry, id, &wp_viewporter_interface, 1); + } else if (SDL_strcmp(interface, "wp_fractional_scale_manager_v1") == 0) { + d->fractional_scale_manager = wl_registry_bind(d->registry, id, &wp_fractional_scale_manager_v1_interface, 1); + } else if (SDL_strcmp(interface, "zwp_input_timestamps_manager_v1") == 0) { + d->input_timestamps_manager = wl_registry_bind(d->registry, id, &zwp_input_timestamps_manager_v1_interface, 1); + if (d->input) { + Wayland_RegisterTimestampListeners(d->input); + } + } else if (SDL_strcmp(interface, "wp_cursor_shape_manager_v1") == 0) { + d->cursor_shape_manager = wl_registry_bind(d->registry, id, &wp_cursor_shape_manager_v1_interface, 1); + if (d->input) { + Wayland_CreateCursorShapeDevice(d->input); + } + } else if (SDL_strcmp(interface, "zxdg_exporter_v2") == 0) { + d->zxdg_exporter_v2 = wl_registry_bind(d->registry, id, &zxdg_exporter_v2_interface, 1); + } else if (SDL_strcmp(interface, "xdg_wm_dialog_v1") == 0) { + d->xdg_wm_dialog_v1 = wl_registry_bind(d->registry, id, &xdg_wm_dialog_v1_interface, 1); + } else if (SDL_strcmp(interface, "wp_alpha_modifier_v1") == 0) { + d->wp_alpha_modifier_v1 = wl_registry_bind(d->registry, id, &wp_alpha_modifier_v1_interface, 1); + } else if (SDL_strcmp(interface, "xdg_toplevel_icon_manager_v1") == 0) { + d->xdg_toplevel_icon_manager_v1 = wl_registry_bind(d->registry, id, &xdg_toplevel_icon_manager_v1_interface, 1); + } else if (SDL_strcmp(interface, "frog_color_management_factory_v1") == 0) { + d->frog_color_management_factory_v1 = wl_registry_bind(d->registry, id, &frog_color_management_factory_v1_interface, 1); + } else if (SDL_strcmp(interface, "wp_color_manager_v1") == 0) { + d->wp_color_manager_v1 = wl_registry_bind(d->registry, id, &wp_color_manager_v1_interface, 1); + Wayland_InitColorManager(d); + } +} + +static void display_remove_global(void *data, struct wl_registry *registry, uint32_t id) +{ + SDL_VideoData *d = data; + + // We don't get an interface, just an ID, so assume it's a wl_output :shrug: + for (int i = 0; i < d->output_count; ++i) { + SDL_DisplayData *disp = d->output_list[i]; + if (disp->registry_id == id) { + Wayland_free_display(SDL_GetVideoDisplay(disp->display), true); + + if (i < d->output_count) { + SDL_memmove(&d->output_list[i], &d->output_list[i + 1], sizeof(SDL_DisplayData *) * (d->output_count - i - 1)); + } + + d->output_count--; + break; + } + } +} + +static const struct wl_registry_listener registry_listener = { + display_handle_global, + display_remove_global +}; + +#ifdef HAVE_LIBDECOR_H +static bool should_use_libdecor(SDL_VideoData *data, bool ignore_xdg) +{ + if (!SDL_WAYLAND_HAVE_WAYLAND_LIBDECOR) { + return false; + } + + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_ALLOW_LIBDECOR, true)) { + return false; + } + + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_WAYLAND_PREFER_LIBDECOR, false)) { + return true; + } + + if (ignore_xdg) { + return true; + } + + if (data->decoration_manager) { + return false; + } + + return true; +} +#endif + +bool Wayland_LoadLibdecor(SDL_VideoData *data, bool ignore_xdg) +{ +#ifdef HAVE_LIBDECOR_H + if (data->shell.libdecor != NULL) { + return true; // Already loaded! + } + if (should_use_libdecor(data, ignore_xdg)) { + data->shell.libdecor = libdecor_new(data->display, &libdecor_interface); + return data->shell.libdecor != NULL; + } +#endif + return false; +} + +bool Wayland_VideoInit(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + data->xkb_context = WAYLAND_xkb_context_new(0); + if (!data->xkb_context) { + return SDL_SetError("Failed to create XKB context"); + } + + data->registry = wl_display_get_registry(data->display); + if (!data->registry) { + return SDL_SetError("Failed to get the Wayland registry"); + } + + wl_registry_add_listener(data->registry, ®istry_listener, data); + + // First roundtrip to receive all registry objects. + WAYLAND_wl_display_roundtrip(data->display); + + // Require viewports and xdg-output for display scaling. + if (data->scale_to_display_enabled) { + if (!data->viewporter) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "wayland: Display scaling requires the missing 'wp_viewporter' protocol: disabling"); + data->scale_to_display_enabled = false; + } + if (!data->xdg_output_manager) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "wayland: Display scaling requires the missing 'zxdg_output_manager_v1' protocol: disabling"); + data->scale_to_display_enabled = false; + } + } + + // Now that we have all the protocols, load libdecor if applicable + Wayland_LoadLibdecor(data, false); + + // Second roundtrip to receive all output events. + WAYLAND_wl_display_roundtrip(data->display); + + Wayland_FinalizeDisplays(data); + + Wayland_InitMouse(); + + WAYLAND_wl_display_flush(data->display); + + Wayland_InitKeyboard(_this); + + if (data->primary_selection_device_manager) { + _this->SetPrimarySelectionText = Wayland_SetPrimarySelectionText; + _this->GetPrimarySelectionText = Wayland_GetPrimarySelectionText; + _this->HasPrimarySelectionText = Wayland_HasPrimarySelectionText; + } + + data->initializing = false; + + return true; +} + +static bool Wayland_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + SDL_VideoData *viddata = _this->internal; + SDL_DisplayData *internal = display->internal; + rect->x = internal->x; + rect->y = internal->y; + + // When an emulated, exclusive fullscreen window has focus, treat the mode dimensions as the display bounds. + if (display->fullscreen_window && + display->fullscreen_window->fullscreen_exclusive && + display->fullscreen_window->internal->active && + display->fullscreen_window->current_fullscreen_mode.w != 0 && + display->fullscreen_window->current_fullscreen_mode.h != 0) { + rect->w = display->fullscreen_window->current_fullscreen_mode.w; + rect->h = display->fullscreen_window->current_fullscreen_mode.h; + } else { + if (!viddata->scale_to_display_enabled) { + rect->w = display->current_mode->w; + rect->h = display->current_mode->h; + } else if (internal->transform & WL_OUTPUT_TRANSFORM_90) { + rect->w = internal->pixel_height; + rect->h = internal->pixel_width; + } else { + rect->w = internal->pixel_width; + rect->h = internal->pixel_height; + } + } + return true; +} + +static void Wayland_VideoCleanup(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + int i; + + Wayland_FiniMouse(data); + + for (i = _this->num_displays - 1; i >= 0; --i) { + SDL_VideoDisplay *display = _this->displays[i]; + Wayland_free_display(display, false); + } + SDL_free(data->output_list); + + Wayland_display_destroy_input(data); + + if (data->pointer_constraints) { + zwp_pointer_constraints_v1_destroy(data->pointer_constraints); + data->pointer_constraints = NULL; + } + + if (data->relative_pointer_manager) { + zwp_relative_pointer_manager_v1_destroy(data->relative_pointer_manager); + data->relative_pointer_manager = NULL; + } + + if (data->activation_manager) { + xdg_activation_v1_destroy(data->activation_manager); + data->activation_manager = NULL; + } + + if (data->idle_inhibit_manager) { + zwp_idle_inhibit_manager_v1_destroy(data->idle_inhibit_manager); + data->idle_inhibit_manager = NULL; + } + + if (data->key_inhibitor_manager) { + zwp_keyboard_shortcuts_inhibit_manager_v1_destroy(data->key_inhibitor_manager); + data->key_inhibitor_manager = NULL; + } + + Wayland_QuitKeyboard(_this); + + if (data->text_input_manager) { + zwp_text_input_manager_v3_destroy(data->text_input_manager); + data->text_input_manager = NULL; + } + + if (data->xkb_context) { + WAYLAND_xkb_context_unref(data->xkb_context); + data->xkb_context = NULL; + } + + if (data->tablet_manager) { + zwp_tablet_manager_v2_destroy((struct zwp_tablet_manager_v2 *)data->tablet_manager); + data->tablet_manager = NULL; + } + + if (data->data_device_manager) { + wl_data_device_manager_destroy(data->data_device_manager); + data->data_device_manager = NULL; + } + + if (data->shm) { + wl_shm_destroy(data->shm); + data->shm = NULL; + } + + if (data->shell.xdg) { + xdg_wm_base_destroy(data->shell.xdg); + data->shell.xdg = NULL; + } + + if (data->decoration_manager) { + zxdg_decoration_manager_v1_destroy(data->decoration_manager); + data->decoration_manager = NULL; + } + + if (data->xdg_output_manager) { + zxdg_output_manager_v1_destroy(data->xdg_output_manager); + data->xdg_output_manager = NULL; + } + + if (data->viewporter) { + wp_viewporter_destroy(data->viewporter); + data->viewporter = NULL; + } + + if (data->primary_selection_device_manager) { + zwp_primary_selection_device_manager_v1_destroy(data->primary_selection_device_manager); + data->primary_selection_device_manager = NULL; + } + + if (data->fractional_scale_manager) { + wp_fractional_scale_manager_v1_destroy(data->fractional_scale_manager); + data->fractional_scale_manager = NULL; + } + + if (data->input_timestamps_manager) { + zwp_input_timestamps_manager_v1_destroy(data->input_timestamps_manager); + data->input_timestamps_manager = NULL; + } + + if (data->cursor_shape_manager) { + wp_cursor_shape_manager_v1_destroy(data->cursor_shape_manager); + data->cursor_shape_manager = NULL; + } + + if (data->zxdg_exporter_v2) { + zxdg_exporter_v2_destroy(data->zxdg_exporter_v2); + data->zxdg_exporter_v2 = NULL; + } + + if (data->xdg_wm_dialog_v1) { + xdg_wm_dialog_v1_destroy(data->xdg_wm_dialog_v1); + data->xdg_wm_dialog_v1 = NULL; + } + + if (data->wp_alpha_modifier_v1) { + wp_alpha_modifier_v1_destroy(data->wp_alpha_modifier_v1); + data->wp_alpha_modifier_v1 = NULL; + } + + if (data->xdg_toplevel_icon_manager_v1) { + xdg_toplevel_icon_manager_v1_destroy(data->xdg_toplevel_icon_manager_v1); + data->xdg_toplevel_icon_manager_v1 = NULL; + } + + if (data->frog_color_management_factory_v1) { + frog_color_management_factory_v1_destroy(data->frog_color_management_factory_v1); + data->frog_color_management_factory_v1 = NULL; + } + + if (data->wp_color_manager_v1) { + wp_color_manager_v1_destroy(data->wp_color_manager_v1); + data->wp_color_manager_v1 = NULL; + } + + if (data->compositor) { + wl_compositor_destroy(data->compositor); + data->compositor = NULL; + } + + if (data->registry) { + wl_registry_destroy(data->registry); + data->registry = NULL; + } +} + +bool Wayland_VideoReconnect(SDL_VideoDevice *_this) +{ +#if 0 // TODO RECONNECT: Uncomment all when https://invent.kde.org/plasma/kwin/-/wikis/Restarting is completed + SDL_VideoData *data = _this->internal; + + SDL_Window *window = NULL; + + SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); + SDL_Window *current_window = SDL_GL_GetCurrentWindow(); + + SDL_GL_MakeCurrent(NULL, NULL); + Wayland_VideoCleanup(_this); + + SDL_ResetKeyboard(); + SDL_ResetMouse(); + if (WAYLAND_wl_display_reconnect(data->display) < 0) { + return false; + } + + Wayland_VideoInit(_this); + + window = _this->windows; + while (window) { + /* We're going to cheat _just_ for a second and strip the OpenGL flag. + * The Wayland driver actually forces it in CreateWindow, and + * RecreateWindow does a bunch of unloading/loading of libGL, so just + * strip the flag so RecreateWindow doesn't mess with the GL context, + * and CreateWindow will add it right back! + * -flibit + */ + window->flags &= ~SDL_WINDOW_OPENGL; + + SDL_RecreateWindow(window, window->flags); + window = window->next; + } + + Wayland_RecreateCursors(); + + if (current_window && current_ctx) { + SDL_GL_MakeCurrent (current_window, current_ctx); + } + return true; +#else + return false; +#endif // 0 +} + +void Wayland_VideoQuit(SDL_VideoDevice *_this) +{ + Wayland_VideoCleanup(_this); + +#ifdef HAVE_LIBDECOR_H + SDL_VideoData *data = _this->internal; + if (data->shell.libdecor) { + libdecor_unref(data->shell.libdecor); + data->shell.libdecor = NULL; + } +#endif +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.h new file mode 100644 index 0000000..8cde64c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvideo.h @@ -0,0 +1,140 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_waylandvideo_h_ +#define SDL_waylandvideo_h_ + +#include +#include "wayland-util.h" + +#include "../SDL_sysvideo.h" +#include "../../core/linux/SDL_dbus.h" +#include "../../core/linux/SDL_ime.h" + +struct xkb_context; +struct SDL_WaylandInput; + +typedef struct +{ + struct wl_cursor_theme *theme; + int size; +} SDL_WaylandCursorTheme; + +typedef struct +{ + struct wl_list link; + char wl_output_name[]; +} SDL_WaylandConnectorName; + +struct SDL_VideoData +{ + bool initializing; + struct wl_display *display; + int display_disconnected; + struct wl_registry *registry; + struct wl_compositor *compositor; + struct wl_shm *shm; + SDL_WaylandCursorTheme *cursor_themes; + int num_cursor_themes; + struct wl_pointer *pointer; + struct + { + struct xdg_wm_base *xdg; +#ifdef HAVE_LIBDECOR_H + struct libdecor *libdecor; +#endif + } shell; + struct zwp_relative_pointer_manager_v1 *relative_pointer_manager; + struct zwp_pointer_constraints_v1 *pointer_constraints; + struct wp_cursor_shape_manager_v1 *cursor_shape_manager; + struct wl_data_device_manager *data_device_manager; + struct zwp_primary_selection_device_manager_v1 *primary_selection_device_manager; + struct zxdg_decoration_manager_v1 *decoration_manager; + struct zwp_keyboard_shortcuts_inhibit_manager_v1 *key_inhibitor_manager; + struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager; + struct xdg_activation_v1 *activation_manager; + struct zwp_text_input_manager_v3 *text_input_manager; + struct zxdg_output_manager_v1 *xdg_output_manager; + struct wp_viewporter *viewporter; + struct wp_fractional_scale_manager_v1 *fractional_scale_manager; + struct zwp_input_timestamps_manager_v1 *input_timestamps_manager; + struct zxdg_exporter_v2 *zxdg_exporter_v2; + struct xdg_wm_dialog_v1 *xdg_wm_dialog_v1; + struct wp_alpha_modifier_v1 *wp_alpha_modifier_v1; + struct xdg_toplevel_icon_manager_v1 *xdg_toplevel_icon_manager_v1; + struct frog_color_management_factory_v1 *frog_color_management_factory_v1; + struct wp_color_manager_v1 *wp_color_manager_v1; + struct zwp_tablet_manager_v2 *tablet_manager; + + struct xkb_context *xkb_context; + struct SDL_WaylandInput *input; + SDL_DisplayData **output_list; + int output_count; + int output_max; + + int relative_mouse_mode; + bool display_externally_owned; + + bool scale_to_display_enabled; +}; + +struct SDL_DisplayData +{ + SDL_VideoData *videodata; + struct wl_output *output; + struct zxdg_output_v1 *xdg_output; + struct wp_color_management_output_v1 *wp_color_management_output; + char *wl_output_name; + double scale_factor; + uint32_t registry_id; + int logical_width, logical_height; + int pixel_width, pixel_height; + int x, y, refresh, transform; + SDL_DisplayOrientation orientation; + int physical_width_mm, physical_height_mm; + bool has_logical_position, has_logical_size; + bool running_colorspace_event_queue; + SDL_HDROutputProperties HDR; + SDL_DisplayID display; + SDL_VideoDisplay placeholder; + int wl_output_done_count; + struct Wayland_ColorInfoState *color_info_state; +}; + +// Needed here to get wl_surface declaration, fixes GitHub#4594 +#include "SDL_waylanddyn.h" + +extern void SDL_WAYLAND_register_surface(struct wl_surface *surface); +extern void SDL_WAYLAND_register_output(struct wl_output *output); +extern bool SDL_WAYLAND_own_surface(struct wl_surface *surface); +extern bool SDL_WAYLAND_own_output(struct wl_output *output); + +extern SDL_WindowData *Wayland_GetWindowDataForOwnedSurface(struct wl_surface *surface); +void Wayland_AddWindowDataToExternalList(SDL_WindowData *data); +void Wayland_RemoveWindowDataFromExternalList(SDL_WindowData *data); + +extern bool Wayland_LoadLibdecor(SDL_VideoData *data, bool ignore_xdg); + +extern bool Wayland_VideoReconnect(SDL_VideoDevice *_this); + +#endif // SDL_waylandvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.c new file mode 100644 index 0000000..956be46 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.c @@ -0,0 +1,203 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.c. + */ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WAYLAND) + +#include "../SDL_vulkan_internal.h" + +#include "SDL_waylandvideo.h" +#include "SDL_waylandwindow.h" + +#include "SDL_waylandvulkan.h" + +#ifdef SDL_PLATFORM_OPENBSD +#define DEFAULT_VULKAN "libvulkan.so" +#else +#define DEFAULT_VULKAN "libvulkan.so.1" +#endif + +bool Wayland_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 i, extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasWaylandSurfaceExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan already loaded"); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + if (!path) { + path = DEFAULT_VULKAN; + } + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + if (!_this->vulkan_config.loader_handle) { + return false; + } + SDL_strlcpy(_this->vulkan_config.loader_path, path, + SDL_arraysize(_this->vulkan_config.loader_path)); + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + if (!vkGetInstanceProcAddr) { + goto fail; + } + _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + if (!extensions) { + goto fail; + } + for (i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasWaylandSurfaceExtension = true; + } + } + SDL_free(extensions); + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else if (!hasWaylandSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME "extension"); + goto fail; + } + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void Wayland_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + } +} + +char const* const* Wayland_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count) +{ + static const char *const extensionsForWayland[] = { + VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME + }; + + if (count) { + *count = SDL_arraysize(extensionsForWayland); + } + + return extensionsForWayland; +} + +bool Wayland_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + SDL_WindowData *windowData = window->internal; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkCreateWaylandSurfaceKHR vkCreateWaylandSurfaceKHR = + (PFN_vkCreateWaylandSurfaceKHR)vkGetInstanceProcAddr( + instance, + "vkCreateWaylandSurfaceKHR"); + VkWaylandSurfaceCreateInfoKHR createInfo; + VkResult result; + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + if (!vkCreateWaylandSurfaceKHR) { + return SDL_SetError(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME + " extension is not enabled in the Vulkan instance."); + } + SDL_zero(createInfo); + createInfo.sType = VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.display = windowData->waylandData->display; + createInfo.surface = windowData->surface; + result = vkCreateWaylandSurfaceKHR(instance, &createInfo, allocator, surface); + if (result != VK_SUCCESS) { + return SDL_SetError("vkCreateWaylandSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); + } + return true; +} + +void Wayland_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + } +} + +bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, + VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex) +{ + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR vkGetPhysicalDeviceWaylandPresentationSupportKHR = + (PFN_vkGetPhysicalDeviceWaylandPresentationSupportKHR)vkGetInstanceProcAddr( + instance, + "vkGetPhysicalDeviceWaylandPresentationSupportKHR"); + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + if (!vkGetPhysicalDeviceWaylandPresentationSupportKHR) { + return SDL_SetError(VK_KHR_WAYLAND_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); + } + + return vkGetPhysicalDeviceWaylandPresentationSupportKHR(physicalDevice, + queueFamilyIndex, + _this->internal->display); +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.h new file mode 100644 index 0000000..58be0bc --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandvulkan.h @@ -0,0 +1,55 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.h. + */ + +#include "SDL_internal.h" + +#ifndef SDL_waylandvulkan_h_ +#define SDL_waylandvulkan_h_ + +#include + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WAYLAND) + +extern bool Wayland_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void Wayland_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* Wayland_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool Wayland_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void Wayland_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); +extern bool Wayland_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, + VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex); + +#endif + +#endif // SDL_waylandvulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.c b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.c new file mode 100644 index 0000000..212fd54 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.c @@ -0,0 +1,3125 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WAYLAND + +#include + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_events_c.h" +#include "../../core/unix/SDL_appid.h" +#include "../SDL_egl_c.h" +#include "SDL_waylandevents_c.h" +#include "SDL_waylandwindow.h" +#include "SDL_waylandvideo.h" +#include "../../SDL_hints_c.h" +#include "SDL_waylandcolor.h" + +#include "alpha-modifier-v1-client-protocol.h" +#include "xdg-shell-client-protocol.h" +#include "xdg-decoration-unstable-v1-client-protocol.h" +#include "idle-inhibit-unstable-v1-client-protocol.h" +#include "xdg-activation-v1-client-protocol.h" +#include "viewporter-client-protocol.h" +#include "fractional-scale-v1-client-protocol.h" +#include "xdg-foreign-unstable-v2-client-protocol.h" +#include "xdg-dialog-v1-client-protocol.h" +#include "frog-color-management-v1-client-protocol.h" +#include "xdg-toplevel-icon-v1-client-protocol.h" +#include "color-management-v1-client-protocol.h" + +#ifdef HAVE_LIBDECOR_H +#include +#endif + +static double GetWindowScale(SDL_Window *window) +{ + return (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) || window->internal->scale_to_display ? window->internal->scale_factor : 1.0; +} + +// These are point->pixel->point round trip safe; the inverse is not round trip safe due to rounding. +static int PointToPixel(SDL_Window *window, int point) +{ + /* Rounds halfway away from zero as per the Wayland fractional scaling protocol spec. + * Wayland scale units are in units of 1/120, so the offset is required to correct for + * rounding errors when using certain scale values. + */ + return point ? SDL_max((int)SDL_lround((double)point * GetWindowScale(window) + 1e-6), 1) : 0; +} + +static int PixelToPoint(SDL_Window *window, int pixel) +{ + return pixel ? SDL_max((int)SDL_lround((double)pixel / GetWindowScale(window)), 1) : 0; +} + +/* According to the Wayland spec: + * + * "If the [fullscreen] surface doesn't cover the whole output, the compositor will + * position the surface in the center of the output and compensate with border fill + * covering the rest of the output. The content of the border fill is undefined, but + * should be assumed to be in some way that attempts to blend into the surrounding area + * (e.g. solid black)." + * + * - KDE, as of 5.27, still doesn't do this + * - GNOME prior to 43 didn't do this (older versions are still found in many LTS distros) + * + * Default to 'stretch' for now, until things have moved forward enough that the default + * can be changed to 'aspect'. + */ +enum WaylandModeScale +{ + WAYLAND_MODE_SCALE_UNDEFINED, + WAYLAND_MODE_SCALE_ASPECT, + WAYLAND_MODE_SCALE_STRETCH, + WAYLAND_MODE_SCALE_NONE +}; + +static enum WaylandModeScale GetModeScaleMethod(void) +{ + static enum WaylandModeScale scale_mode = WAYLAND_MODE_SCALE_UNDEFINED; + + if (scale_mode == WAYLAND_MODE_SCALE_UNDEFINED) { + const char *scale_hint = SDL_GetHint(SDL_HINT_VIDEO_WAYLAND_MODE_SCALING); + + if (scale_hint) { + if (!SDL_strcasecmp(scale_hint, "aspect")) { + scale_mode = WAYLAND_MODE_SCALE_ASPECT; + } else if (!SDL_strcasecmp(scale_hint, "none")) { + scale_mode = WAYLAND_MODE_SCALE_NONE; + } else { + scale_mode = WAYLAND_MODE_SCALE_STRETCH; + } + } else { + scale_mode = WAYLAND_MODE_SCALE_STRETCH; + } + } + + return scale_mode; +} + +static void GetBufferSize(SDL_Window *window, int *width, int *height) +{ + SDL_WindowData *data = window->internal; + int buf_width; + int buf_height; + + // Exclusive fullscreen modes always have a pixel density of 1 + if (data->is_fullscreen && window->fullscreen_exclusive) { + buf_width = window->current_fullscreen_mode.w; + buf_height = window->current_fullscreen_mode.h; + } else if (!data->scale_to_display) { + // Round fractional backbuffer sizes halfway away from zero. + buf_width = PointToPixel(window, data->requested.logical_width); + buf_height = PointToPixel(window, data->requested.logical_height); + } else { + buf_width = data->requested.pixel_width; + buf_height = data->requested.pixel_height; + } + + if (width) { + *width = buf_width; + } + if (height) { + *height = buf_height; + } +} + +static void SetMinMaxDimensions(SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + int min_width, min_height, max_width, max_height; + + if ((window->flags & SDL_WINDOW_FULLSCREEN) || wind->fullscreen_deadline_count) { + min_width = 0; + min_height = 0; + max_width = 0; + max_height = 0; + } else if (window->flags & SDL_WINDOW_RESIZABLE) { + int adj_w = SDL_max(window->min_w, wind->system_limits.min_width); + int adj_h = SDL_max(window->min_h, wind->system_limits.min_height); + if (wind->scale_to_display) { + adj_w = PixelToPoint(window, adj_w); + adj_h = PixelToPoint(window, adj_h); + } + min_width = adj_w; + min_height = adj_h; + + adj_w = window->max_w ? SDL_max(window->max_w, wind->system_limits.min_width) : 0; + adj_h = window->max_h ? SDL_max(window->max_h, wind->system_limits.min_height) : 0; + if (wind->scale_to_display) { + adj_w = PixelToPoint(window, adj_w); + adj_h = PixelToPoint(window, adj_h); + } + max_width = adj_w; + max_height = adj_h; + } else { + min_width = wind->current.logical_width; + min_height = wind->current.logical_height; + max_width = wind->current.logical_width; + max_height = wind->current.logical_height; + } + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (!wind->shell_surface.libdecor.initial_configure_seen || !wind->shell_surface.libdecor.frame) { + return; // Can't do anything yet, wait for ShowWindow + } + /* No need to change these values if the window is non-resizable, + * as libdecor will just overwrite them internally. + */ + if (libdecor_frame_has_capability(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE)) { + libdecor_frame_set_min_content_size(wind->shell_surface.libdecor.frame, + min_width, + min_height); + libdecor_frame_set_max_content_size(wind->shell_surface.libdecor.frame, + max_width, + max_height); + } + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (wind->shell_surface.xdg.toplevel.xdg_toplevel == NULL) { + return; // Can't do anything yet, wait for ShowWindow + } + xdg_toplevel_set_min_size(wind->shell_surface.xdg.toplevel.xdg_toplevel, + min_width, + min_height); + xdg_toplevel_set_max_size(wind->shell_surface.xdg.toplevel.xdg_toplevel, + max_width, + max_height); + } +} + +static void EnsurePopupPositionIsValid(SDL_Window *window, int *x, int *y) +{ + int adj_count = 0; + + /* Per the xdg-positioner spec, child popup windows must intersect or at + * least be partially adjacent to the parent window. + * + * Failure to ensure this on a compositor that enforces this restriction + * can result in behavior ranging from the window being spuriously closed + * to a protocol violation. + */ + if (*x + window->w < 0) { + *x = -window->w; + ++adj_count; + } + if (*y + window->h < 0) { + *y = -window->h; + ++adj_count; + } + if (*x > window->parent->w) { + *x = window->parent->w; + ++adj_count; + } + if (*y > window->parent->h) { + *y = window->parent->h; + ++adj_count; + } + + /* If adjustment was required on the x and y axes, the popup is aligned with + * the parent corner-to-corner and is neither overlapping nor adjacent, so it + * must be nudged by 1 to be considered adjacent. + */ + if (adj_count > 1) { + *x += *x < 0 ? 1 : -1; + } +} + +static void AdjustPopupOffset(SDL_Window *popup, int *x, int *y) +{ + // Adjust the popup positioning, if necessary +#ifdef HAVE_LIBDECOR_H + if (popup->parent->internal->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + int adj_x, adj_y; + libdecor_frame_translate_coordinate(popup->parent->internal->shell_surface.libdecor.frame, + *x, *y, &adj_x, &adj_y); + *x = adj_x; + *y = adj_y; + } +#endif +} + +static void RepositionPopup(SDL_Window *window, bool use_current_position) +{ + SDL_WindowData *wind = window->internal; + + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP && + wind->shell_surface.xdg.popup.xdg_positioner && + xdg_popup_get_version(wind->shell_surface.xdg.popup.xdg_popup) >= XDG_POPUP_REPOSITION_SINCE_VERSION) { + int x = use_current_position ? window->x : window->pending.x; + int y = use_current_position ? window->y : window->pending.y; + + EnsurePopupPositionIsValid(window, &x, &y); + if (wind->scale_to_display) { + x = PixelToPoint(window->parent, x); + y = PixelToPoint(window->parent, y); + } + AdjustPopupOffset(window, &x, &y); + xdg_positioner_set_anchor_rect(wind->shell_surface.xdg.popup.xdg_positioner, 0, 0, window->parent->internal->current.logical_width, window->parent->internal->current.logical_height); + xdg_positioner_set_size(wind->shell_surface.xdg.popup.xdg_positioner, wind->current.logical_width, wind->current.logical_height); + xdg_positioner_set_offset(wind->shell_surface.xdg.popup.xdg_positioner, x, y); + xdg_popup_reposition(wind->shell_surface.xdg.popup.xdg_popup, + wind->shell_surface.xdg.popup.xdg_positioner, + 0); + } +} + +static void SetSurfaceOpaqueRegion(SDL_WindowData *wind, bool is_opaque) +{ + SDL_VideoData *viddata = wind->waylandData; + + if (is_opaque) { + struct wl_region *region = wl_compositor_create_region(viddata->compositor); + wl_region_add(region, 0, 0, + wind->current.logical_width, wind->current.logical_height); + wl_surface_set_opaque_region(wind->surface, region); + wl_region_destroy(region); + } else { + wl_surface_set_opaque_region(wind->surface, NULL); + } +} + +static bool ConfigureWindowGeometry(SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + const double scale_factor = GetWindowScale(window); + const int old_pixel_width = data->current.pixel_width; + const int old_pixel_height = data->current.pixel_height; + int window_width, window_height; + bool window_size_changed; + + // Throttle interactive resize events to once per refresh cycle to prevent lag. + if (data->resizing) { + data->resizing = false; + + if (data->drop_interactive_resizes) { + return false; + } else { + data->drop_interactive_resizes = true; + } + } + + // Set the drawable backbuffer size. + GetBufferSize(window, &data->current.pixel_width, &data->current.pixel_height); + const bool buffer_size_changed = data->current.pixel_width != old_pixel_width || + data->current.pixel_height != old_pixel_height; + + if (data->egl_window && buffer_size_changed) { + WAYLAND_wl_egl_window_resize(data->egl_window, + data->current.pixel_width, + data->current.pixel_height, + 0, 0); + } + + if (data->is_fullscreen && window->fullscreen_exclusive) { + int output_width; + int output_height; + window_width = window->current_fullscreen_mode.w; + window_height = window->current_fullscreen_mode.h; + + output_width = data->requested.logical_width; + output_height = data->requested.logical_height; + + switch (GetModeScaleMethod()) { + case WAYLAND_MODE_SCALE_NONE: + /* The Wayland spec states that the advertised fullscreen dimensions are a maximum. + * Windows can request a smaller size, but exceeding these dimensions is a protocol violation, + * thus, modes that exceed the output size still need to be scaled with a viewport. + */ + if (window_width <= output_width && window_height <= output_height) { + output_width = window_width; + output_height = window_height; + + break; + } + SDL_FALLTHROUGH; + case WAYLAND_MODE_SCALE_ASPECT: + { + const float output_ratio = (float)output_width / (float)output_height; + const float mode_ratio = (float)window_width / (float)window_height; + + if (output_ratio > mode_ratio) { + output_width = SDL_lroundf((float)window_width * ((float)output_height / (float)window_height)); + } else if (output_ratio < mode_ratio) { + output_height = SDL_lroundf((float)window_height * ((float)output_width / (float)window_width)); + } + } break; + default: + break; + } + + window_size_changed = window_width != window->w || window_height != window->h || + data->current.logical_width != output_width || data->current.logical_height != output_height; + + if (window_size_changed || buffer_size_changed) { + if (data->viewport) { + wp_viewport_set_destination(data->viewport, output_width, output_height); + + data->current.logical_width = output_width; + data->current.logical_height = output_height; + } else { + // Calculate the integer scale from the mode and output. + const int32_t int_scale = SDL_max(window->current_fullscreen_mode.w / output_width, 1); + + wl_surface_set_buffer_scale(data->surface, int_scale); + data->current.logical_width = window->current_fullscreen_mode.w; + data->current.logical_height = window->current_fullscreen_mode.h; + } + + data->pointer_scale.x = (double)window_width / (double)data->current.logical_width; + data->pointer_scale.y = (double)window_height / (double)data->current.logical_height; + } + } else { + window_width = data->requested.logical_width; + window_height = data->requested.logical_height; + + window_size_changed = window_width != data->current.logical_width || window_height != data->current.logical_height; + + if (window_size_changed || buffer_size_changed) { + if (data->viewport) { + wp_viewport_set_destination(data->viewport, window_width, window_height); + } else if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY) { + // Don't change this if the DPI awareness flag is unset, as an application may have set this manually on a custom or external surface. + wl_surface_set_buffer_scale(data->surface, (int32_t)scale_factor); + } + + // Clamp the physical window size to the system minimum required size. + data->current.logical_width = SDL_max(window_width, data->system_limits.min_width); + data->current.logical_height = SDL_max(window_height, data->system_limits.min_height); + + if (!data->scale_to_display) { + data->pointer_scale.x = 1.0; + data->pointer_scale.y = 1.0; + } else { + data->pointer_scale.x = scale_factor; + data->pointer_scale.y = scale_factor; + } + } + } + + /* + * The surface geometry, opaque region and pointer confinement region only + * need to be recalculated if the output size has changed. + */ + if (window_size_changed) { + /* XXX: This is a hack and only set on the xdg-toplevel path when viewports + * aren't supported to avoid a potential protocol violation if a buffer + * with an old size is committed. + */ + if (!data->viewport && data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL && data->shell_surface.xdg.surface) { + xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->current.logical_width, data->current.logical_height); + } + + SetSurfaceOpaqueRegion(data, !(window->flags & SDL_WINDOW_TRANSPARENT) && window->opacity == 1.0f); + + // Ensure that child popup windows are still in bounds. + for (SDL_Window *child = window->first_child; child; child = child->next_sibling) { + RepositionPopup(child, true); + } + } + + /* Update the min/max dimensions, primarily if the state was changed, and for non-resizable + * xdg-toplevel windows where the limits should match the window size. + */ + SetMinMaxDimensions(window); + + // Unconditionally send the window and drawable size, the video core will deduplicate when required. + if (!data->scale_to_display) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, window_width, window_height); + } else { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, data->current.pixel_width, data->current.pixel_height); + } + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED, data->current.pixel_width, data->current.pixel_height); + + /* Send an exposure event if the window is in the shown state and the size has changed, + * even if the window is occluded, as the client needs to commit a new frame for the + * changes to take effect. + * + * The occlusion state is immediately set again afterward, if necessary. + */ + if (data->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_SHOWN) { + if ((buffer_size_changed || window_size_changed) || + (!data->suspended && (window->flags & SDL_WINDOW_OCCLUDED))) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } + + if (data->suspended) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_OCCLUDED, 0, 0); + } + } + + return true; +} + +static void CommitLibdecorFrame(SDL_Window *window) +{ +#ifdef HAVE_LIBDECOR_H + SDL_WindowData *wind = window->internal; + + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR && wind->shell_surface.libdecor.frame) { + struct libdecor_state *state = libdecor_state_new(wind->current.logical_width, wind->current.logical_height); + libdecor_frame_commit(wind->shell_surface.libdecor.frame, state, NULL); + libdecor_state_free(state); + } +#endif +} + +static void fullscreen_deadline_handler(void *data, struct wl_callback *callback, uint32_t callback_data) +{ + // Get the window from the ID as it may have been destroyed + SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data); + SDL_Window *window = SDL_GetWindowFromID(windowID); + + if (window && window->internal) { + window->internal->fullscreen_deadline_count--; + } + + wl_callback_destroy(callback); +} + +static struct wl_callback_listener fullscreen_deadline_listener = { + fullscreen_deadline_handler +}; + +static void maximized_restored_deadline_handler(void *data, struct wl_callback *callback, uint32_t callback_data) +{ + // Get the window from the ID as it may have been destroyed + SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data); + SDL_Window *window = SDL_GetWindowFromID(windowID); + + if (window && window->internal) { + window->internal->maximized_restored_deadline_count--; + } + + wl_callback_destroy(callback); +} + +static struct wl_callback_listener maximized_restored_deadline_listener = { + maximized_restored_deadline_handler +}; + +static void FlushPendingEvents(SDL_Window *window) +{ + // Serialize and restore the pending flags, as they may be overwritten while flushing. + const bool last_position_pending = window->last_position_pending; + const bool last_size_pending = window->last_size_pending; + + while (window->internal->fullscreen_deadline_count || window->internal->maximized_restored_deadline_count) { + WAYLAND_wl_display_roundtrip(window->internal->waylandData->display); + } + + window->last_position_pending = last_position_pending; + window->last_size_pending = last_size_pending; +} + +/* While we can't get window position from the compositor, we do at least know + * what monitor we're on, so let's send move events that put the window at the + * center of the whatever display the wl_surface_listener events give us. + */ +static void Wayland_move_window(SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + SDL_DisplayData *display; + SDL_DisplayID *displays; + + if (wind->outputs && wind->num_outputs) { + display = wind->outputs[wind->num_outputs - 1]; + } else { + // A window may not be on any displays if minimized. + return; + } + + displays = SDL_GetDisplays(NULL); + if (displays) { + for (int i = 0; displays[i]; ++i) { + if (SDL_GetDisplayDriverData(displays[i]) == display) { + /* We want to send a very very specific combination here: + * + * 1. A coordinate that tells the application what display we're on + * 2. Exactly (0, 0) + * + * Part 1 is useful information but is also really important for + * ensuring we end up on the right display for fullscreen, while + * part 2 is important because numerous applications use a specific + * combination of GetWindowPosition and GetGlobalMouseState, and of + * course neither are supported by Wayland. Since global mouse will + * fall back to just GetMouseState, we need the window position to + * be zero so the cursor math works without it going off in some + * random direction. See UE5 Editor for a notable example of this! + * + * This may be an issue some day if we're ever able to implement + * SDL_GetDisplayUsableBounds! + * + * -flibit + */ + + if (wind->last_displayID != displays[i]) { + wind->last_displayID = displays[i]; + if (wind->shell_surface_type != WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, display->x, display->y); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_DISPLAY_CHANGED, wind->last_displayID, 0); + } + } + break; + } + } + SDL_free(displays); + } +} + +static void SetFullscreen(SDL_Window *window, struct wl_output *output) +{ + SDL_WindowData *wind = window->internal; + SDL_VideoData *viddata = wind->waylandData; + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (!wind->shell_surface.libdecor.frame) { + return; // Can't do anything yet, wait for ShowWindow + } + + wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false; + ++wind->fullscreen_deadline_count; + if (output) { + Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true); + wl_surface_commit(wind->surface); + + libdecor_frame_set_fullscreen(wind->shell_surface.libdecor.frame, output); + } else { + libdecor_frame_unset_fullscreen(wind->shell_surface.libdecor.frame); + } + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (wind->shell_surface.xdg.toplevel.xdg_toplevel == NULL) { + return; // Can't do anything yet, wait for ShowWindow + } + + wind->fullscreen_exclusive = output ? window->fullscreen_exclusive : false; + ++wind->fullscreen_deadline_count; + if (output) { + Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, true); + wl_surface_commit(wind->surface); + + xdg_toplevel_set_fullscreen(wind->shell_surface.xdg.toplevel.xdg_toplevel, output); + } else { + xdg_toplevel_unset_fullscreen(wind->shell_surface.xdg.toplevel.xdg_toplevel); + } + } + + // Queue a deadline event + struct wl_callback *cb = wl_display_sync(viddata->display); + wl_callback_add_listener(cb, &fullscreen_deadline_listener, (void *)((uintptr_t)window->id)); +} + +static void UpdateWindowFullscreen(SDL_Window *window, bool fullscreen) +{ + SDL_WindowData *wind = window->internal; + + wind->is_fullscreen = fullscreen; + + if (fullscreen) { + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + SDL_copyp(&window->current_fullscreen_mode, &window->requested_fullscreen_mode); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, false); + + /* Set the output for exclusive fullscreen windows when entering fullscreen from a + * compositor event, or if the fullscreen parameters were changed between the initial + * fullscreen request and now, to ensure that the window is on the correct output, + * as requested by the client. + */ + if (window->fullscreen_exclusive && (!wind->fullscreen_exclusive || !wind->fullscreen_was_positioned)) { + SDL_VideoDisplay *disp = SDL_GetVideoDisplay(window->current_fullscreen_mode.displayID); + if (disp) { + wind->fullscreen_was_positioned = true; + SetFullscreen(window, disp->internal->output); + } + } + } + } else { + // Don't change the fullscreen flags if the window is hidden or being hidden. + if ((window->flags & SDL_WINDOW_FULLSCREEN) && !window->is_hiding && !(window->flags & SDL_WINDOW_HIDDEN)) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_LEAVE, false); + wind->fullscreen_was_positioned = false; + + /* Send a move event, in case it was deferred while the fullscreen window was moving and + * on multiple outputs. + */ + Wayland_move_window(window); + } + } +} + +static const struct wl_callback_listener surface_frame_listener; + +static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + + /* XXX: This is needed to work around an Nvidia egl-wayland bug due to buffer coordinates + * being used with wl_surface_damage, which causes part of the output to not be + * updated when using a viewport with an output region larger than the source region. + */ + if (wl_compositor_get_version(wind->waylandData->compositor) >= WL_SURFACE_DAMAGE_BUFFER_SINCE_VERSION) { + wl_surface_damage_buffer(wind->surface, 0, 0, SDL_MAX_SINT32, SDL_MAX_SINT32); + } else { + wl_surface_damage(wind->surface, 0, 0, SDL_MAX_SINT32, SDL_MAX_SINT32); + } + + wind->drop_interactive_resizes = false; + + if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME) { + wind->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_SHOWN; + + // If any child windows are waiting on this window to be shown, show them now + for (SDL_Window *w = wind->sdlwindow->first_child; w; w = w->next_sibling) { + if (w->internal->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_SHOW_PENDING) { + Wayland_ShowWindow(SDL_GetVideoDevice(), w); + } else if (w->internal->reparenting_required) { + Wayland_SetWindowParent(SDL_GetVideoDevice(), w, w->parent); + if (w->flags & SDL_WINDOW_MODAL) { + Wayland_SetWindowModal(SDL_GetVideoDevice(), w, true); + } + } + } + + /* If the window was initially set to the suspended state, send the occluded event now, + * as we don't want to mark the window as occluded until at least one frame has been submitted. + */ + if (wind->suspended) { + SDL_SendWindowEvent(wind->sdlwindow, SDL_EVENT_WINDOW_OCCLUDED, 0, 0); + } + } + + wl_callback_destroy(cb); + wind->surface_frame_callback = wl_surface_frame(wind->surface); + wl_callback_add_listener(wind->surface_frame_callback, &surface_frame_listener, data); +} + +static const struct wl_callback_listener surface_frame_listener = { + surface_frame_done +}; + +static const struct wl_callback_listener gles_swap_frame_listener; + +static void gles_swap_frame_done(void *data, struct wl_callback *cb, uint32_t time) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + SDL_SetAtomicInt(&wind->swap_interval_ready, 1); // mark window as ready to present again. + + // reset this callback to fire again once a new frame was presented and compositor wants the next one. + wind->gles_swap_frame_callback = wl_surface_frame(wind->gles_swap_frame_surface_wrapper); + wl_callback_destroy(cb); + wl_callback_add_listener(wind->gles_swap_frame_callback, &gles_swap_frame_listener, data); +} + +static const struct wl_callback_listener gles_swap_frame_listener = { + gles_swap_frame_done +}; + +static void handle_configure_xdg_shell_surface(void *data, struct xdg_surface *xdg, uint32_t serial) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + SDL_Window *window = wind->sdlwindow; + + if (ConfigureWindowGeometry(window)) { + xdg_surface_ack_configure(xdg, serial); + } + + wind->shell_surface.xdg.initial_configure_seen = true; +} + +static const struct xdg_surface_listener shell_surface_listener_xdg = { + handle_configure_xdg_shell_surface +}; + +static void handle_configure_xdg_toplevel(void *data, + struct xdg_toplevel *xdg_toplevel, + int32_t width, + int32_t height, + struct wl_array *states) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + SDL_Window *window = wind->sdlwindow; + + enum xdg_toplevel_state *state; + bool fullscreen = false; + bool maximized = false; + bool floating = true; + bool tiled = false; + bool active = false; + bool resizing = false; + bool suspended = false; + wl_array_for_each (state, states) { + switch (*state) { + case XDG_TOPLEVEL_STATE_FULLSCREEN: + fullscreen = true; + floating = false; + break; + case XDG_TOPLEVEL_STATE_MAXIMIZED: + maximized = true; + floating = false; + break; + case XDG_TOPLEVEL_STATE_RESIZING: + resizing = true; + break; + case XDG_TOPLEVEL_STATE_ACTIVATED: + active = true; + break; + case XDG_TOPLEVEL_STATE_TILED_LEFT: + case XDG_TOPLEVEL_STATE_TILED_RIGHT: + case XDG_TOPLEVEL_STATE_TILED_TOP: + case XDG_TOPLEVEL_STATE_TILED_BOTTOM: + tiled = true; + floating = false; + break; + case XDG_TOPLEVEL_STATE_SUSPENDED: + suspended = true; + break; + default: + break; + } + } + + UpdateWindowFullscreen(window, fullscreen); + + /* Always send a maximized/restore event; if the event is redundant it will + * automatically be discarded (see src/events/SDL_windowevents.c) + * + * No, we do not get minimize events from xdg-shell, however, the minimized + * state can be programmatically set. The meaning of 'minimized' is compositor + * dependent, but in general, we can assume that the flag should remain set until + * the next focused configure event occurs. + */ + if (active || !(window->flags & SDL_WINDOW_MINIMIZED)) { + if (window->flags & SDL_WINDOW_MINIMIZED) { + // If we were minimized, send a restored event before possibly sending maximized. + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + } + SDL_SendWindowEvent(window, + (maximized && !fullscreen) ? SDL_EVENT_WINDOW_MAXIMIZED : SDL_EVENT_WINDOW_RESTORED, + 0, 0); + } + + if (!fullscreen) { + /* xdg_toplevel spec states that this is a suggestion. + * Ignore if less than or greater than max/min size. + */ + if (window->flags & SDL_WINDOW_RESIZABLE) { + if (width == 0 || height == 0) { + /* This happens when the compositor indicates that the size is + * up to the client, so use the cached window size here. + */ + if (floating) { + width = window->floating.w; + height = window->floating.h; + + // Clamp the window to the toplevel bounds, if any are set. + if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE && + wind->toplevel_bounds.width && wind->toplevel_bounds.height) { + width = SDL_min(wind->toplevel_bounds.width, width); + height = SDL_min(wind->toplevel_bounds.height, height); + } + } else { + width = window->windowed.w; + height = window->windowed.h; + } + + if (!wind->scale_to_display) { + wind->requested.logical_width = width; + wind->requested.logical_height = height; + } else { + wind->requested.pixel_width = width; + wind->requested.pixel_height = height; + width = wind->requested.logical_width = PixelToPoint(window, width); + height = wind->requested.logical_height = PixelToPoint(window, height); + } + } else { + /* Don't apply the supplied dimensions if they haven't changed from the last configuration + * event, or a newer size set programmatically can be overwritten by old data. + */ + if (width != wind->last_configure.width || height != wind->last_configure.height) { + wind->requested.logical_width = width; + wind->requested.logical_height = height; + + if (wind->scale_to_display) { + wind->requested.pixel_width = PointToPixel(window, width); + wind->requested.pixel_height = PointToPixel(window, height); + } + } + } + } else { + /* If we're a fixed-size window, we know our size for sure. + * Always assume the configure is wrong. + */ + if (!wind->scale_to_display) { + width = wind->requested.logical_width = window->floating.w; + height = wind->requested.logical_height = window->floating.h; + } else { + wind->requested.pixel_width = window->floating.w; + wind->requested.pixel_height = window->floating.h; + width = wind->requested.logical_width = PixelToPoint(window, window->floating.w); + height = wind->requested.logical_height = PixelToPoint(window, window->floating.h); + } + } + + /* Notes on the spec: + * + * - The content limits are only a hint, which the compositor is free to ignore, + * so apply them manually when appropriate. + * + * - Maximized windows must have their exact dimensions respected, thus they must + * not be resized, or a protocol violation can occur. + * + * - When resizing a window, the width/height are maximum values, so aspect ratio + * correction can't resize beyond the existing dimensions, or a protocol violation + * can occur. In practice, nothing seems to kill clients that do this, but doing + * so causes GNOME to glitch out. + */ + if (!maximized) { + if (!wind->scale_to_display) { + if (window->max_w > 0) { + wind->requested.logical_width = SDL_min(wind->requested.logical_width, window->max_w); + } + wind->requested.logical_width = SDL_max(wind->requested.logical_width, window->min_w); + + if (window->max_h > 0) { + wind->requested.logical_height = SDL_min(wind->requested.logical_height, window->max_h); + } + wind->requested.logical_height = SDL_max(wind->requested.logical_height, window->min_h); + + // Aspect correction. + const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height; + + if (window->min_aspect != 0.f && aspect < window->min_aspect) { + wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect); + } else if (window->max_aspect != 0.f && aspect > window->max_aspect) { + wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect); + } + } else { + if (window->max_w > 0) { + wind->requested.pixel_width = SDL_min(wind->requested.pixel_width, window->max_w); + } + wind->requested.pixel_width = SDL_max(wind->requested.pixel_width, window->min_w); + + if (window->max_h > 0) { + wind->requested.pixel_height = SDL_min(wind->requested.pixel_height, window->max_h); + } + wind->requested.pixel_height = SDL_max(wind->requested.pixel_height, window->min_h); + + // Aspect correction. + const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height; + + if (window->min_aspect != 0.f && aspect < window->min_aspect) { + wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect); + } else if (window->max_aspect != 0.f && aspect > window->max_aspect) { + wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect); + } + + wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width); + wind->requested.logical_height = PixelToPoint(window, wind->requested.pixel_height); + } + } + } else { + // Fullscreen windows know their exact size. + if (width == 0 || height == 0) { + width = wind->requested.logical_width; + height = wind->requested.logical_height; + } else { + wind->requested.logical_width = width; + wind->requested.logical_height = height; + } + + if (wind->scale_to_display) { + wind->requested.pixel_width = PointToPixel(window, width); + wind->requested.pixel_height = PointToPixel(window, height); + } + } + + wind->last_configure.width = width; + wind->last_configure.height = height; + wind->floating = floating; + wind->suspended = suspended; + wind->active = active; + window->tiled = tiled; + wind->resizing = resizing; + + if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE) { + wind->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME; + } +} + +static void handle_close_xdg_toplevel(void *data, struct xdg_toplevel *xdg_toplevel) +{ + SDL_WindowData *window = (SDL_WindowData *)data; + SDL_SendWindowEvent(window->sdlwindow, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); +} + +static void handle_xdg_configure_toplevel_bounds(void *data, + struct xdg_toplevel *xdg_toplevel, + int32_t width, int32_t height) +{ + SDL_WindowData *window = (SDL_WindowData *)data; + window->toplevel_bounds.width = width; + window->toplevel_bounds.height = height; +} + +static void handle_xdg_toplevel_wm_capabilities(void *data, + struct xdg_toplevel *xdg_toplevel, + struct wl_array *capabilities) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + enum xdg_toplevel_wm_capabilities *wm_cap; + + wind->wm_caps = 0; + + wl_array_for_each (wm_cap, capabilities) { + switch (*wm_cap) { + case XDG_TOPLEVEL_WM_CAPABILITIES_WINDOW_MENU: + wind->wm_caps |= WAYLAND_WM_CAPS_WINDOW_MENU; + break; + case XDG_TOPLEVEL_WM_CAPABILITIES_MAXIMIZE: + wind->wm_caps |= WAYLAND_WM_CAPS_MAXIMIZE; + break; + case XDG_TOPLEVEL_WM_CAPABILITIES_FULLSCREEN: + wind->wm_caps |= WAYLAND_WM_CAPS_FULLSCREEN; + break; + case XDG_TOPLEVEL_WM_CAPABILITIES_MINIMIZE: + wind->wm_caps |= WAYLAND_WM_CAPS_MINIMIZE; + break; + default: + break; + } + } +} + +static const struct xdg_toplevel_listener toplevel_listener_xdg = { + handle_configure_xdg_toplevel, + handle_close_xdg_toplevel, + handle_xdg_configure_toplevel_bounds, // Version 4 + handle_xdg_toplevel_wm_capabilities // Version 5 +}; + +static void handle_configure_xdg_popup(void *data, + struct xdg_popup *xdg_popup, + int32_t x, + int32_t y, + int32_t width, + int32_t height) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + int offset_x = 0, offset_y = 0; + + // Adjust the position if it was offset for libdecor + AdjustPopupOffset(wind->sdlwindow, &offset_x, &offset_y); + x -= offset_x; + y -= offset_y; + + /* This happens when the compositor indicates that the size is + * up to the client, so use the cached window size here. + */ + if (width == 0 || height == 0) { + width = wind->sdlwindow->floating.w; + height = wind->sdlwindow->floating.h; + } + + /* Don't apply the supplied dimensions if they haven't changed from the last configuration + * event, or a newer size set programmatically can be overwritten by old data. + */ + if (width != wind->last_configure.width || height != wind->last_configure.height) { + wind->requested.logical_width = width; + wind->requested.logical_height = height; + + if (wind->scale_to_display) { + wind->requested.pixel_width = PointToPixel(wind->sdlwindow, width); + wind->requested.pixel_height = PointToPixel(wind->sdlwindow, height); + } + } + + if (wind->scale_to_display) { + x = PointToPixel(wind->sdlwindow->parent, x); + y = PointToPixel(wind->sdlwindow->parent, y); + } + + SDL_SendWindowEvent(wind->sdlwindow, SDL_EVENT_WINDOW_MOVED, x, y); + + wind->last_configure.width = width; + wind->last_configure.height = height; + + if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE) { + wind->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME; + } +} + +static void handle_done_xdg_popup(void *data, struct xdg_popup *xdg_popup) +{ + SDL_WindowData *window = (SDL_WindowData *)data; + SDL_SendWindowEvent(window->sdlwindow, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); +} + +static void handle_repositioned_xdg_popup(void *data, + struct xdg_popup *xdg_popup, + uint32_t token) +{ + // No-op, configure does all the work we care about +} + +static const struct xdg_popup_listener popup_listener_xdg = { + handle_configure_xdg_popup, + handle_done_xdg_popup, + handle_repositioned_xdg_popup +}; + +static void handle_configure_zxdg_decoration(void *data, + struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, + uint32_t mode) +{ + SDL_Window *window = (SDL_Window *)data; + SDL_WindowData *internal = window->internal; + SDL_VideoDevice *device = SDL_GetVideoDevice(); + + /* If the compositor tries to force CSD anyway, bail on direct XDG support + * and fall back to libdecor, it will handle these events from then on. + * + * To do this we have to fully unmap, then map with libdecor loaded. + */ + if (mode == ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE) { + if (window->flags & SDL_WINDOW_BORDERLESS) { + // borderless windows do request CSD, so we got what we wanted + return; + } + if (!Wayland_LoadLibdecor(internal->waylandData, true)) { + // libdecor isn't available, so no borders for you... oh well + return; + } + WAYLAND_wl_display_roundtrip(internal->waylandData->display); + + Wayland_HideWindow(device, window); + SDL_zero(internal->shell_surface); + internal->shell_surface_type = WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR; + + Wayland_ShowWindow(device, window); + } +} + +static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = { + handle_configure_zxdg_decoration +}; + +#ifdef HAVE_LIBDECOR_H +/* + * XXX: Hack for older versions of libdecor that lack the function to query the + * minimum content size limit. The internal limits must always be overridden + * to ensure that very small windows don't cause errors or crashes. + * + * On libdecor >= 0.1.2, which exposes the function to get the minimum content + * size limit, this function is a no-op. + * + * Can be removed if the minimum required version of libdecor is raised to + * 0.1.2 or higher. + */ +static void OverrideLibdecorLimits(SDL_Window *window) +{ +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR + if (!libdecor_frame_get_min_content_size) { + libdecor_frame_set_min_content_size(window->internal->shell_surface.libdecor.frame, window->min_w, window->min_h); + } +#elif !SDL_LIBDECOR_CHECK_VERSION(0, 2, 0) + libdecor_frame_set_min_content_size(window->internal->shell_surface.libdecor.frame, window->min_w, window->min_h); +#endif +} + +/* + * NOTE: Retrieves the minimum content size limits, if the function for doing so is available. + * On versions of libdecor that lack the minimum content size retrieval function, this + * function is a no-op. + * + * Can be replaced with a direct call if the minimum required version of libdecor is raised + * to 0.1.2 or higher. + */ +static void LibdecorGetMinContentSize(struct libdecor_frame *frame, int *min_w, int *min_h) +{ +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR + if (libdecor_frame_get_min_content_size != NULL) { + libdecor_frame_get_min_content_size(frame, min_w, min_h); + } +#elif SDL_LIBDECOR_CHECK_VERSION(0, 2, 0) + libdecor_frame_get_min_content_size(frame, min_w, min_h); +#endif +} + +static void decoration_frame_configure(struct libdecor_frame *frame, + struct libdecor_configuration *configuration, + void *user_data) +{ + SDL_WindowData *wind = (SDL_WindowData *)user_data; + SDL_Window *window = wind->sdlwindow; + + enum libdecor_window_state window_state; + int width, height; + + bool prev_fullscreen = wind->is_fullscreen; + bool active = false; + bool fullscreen = false; + bool maximized = false; + bool tiled = false; + bool suspended = false; + bool resizing = false; + + static const enum libdecor_window_state tiled_states = (LIBDECOR_WINDOW_STATE_TILED_LEFT | LIBDECOR_WINDOW_STATE_TILED_RIGHT | + LIBDECOR_WINDOW_STATE_TILED_TOP | LIBDECOR_WINDOW_STATE_TILED_BOTTOM); + + // Window State + if (libdecor_configuration_get_window_state(configuration, &window_state)) { + fullscreen = (window_state & LIBDECOR_WINDOW_STATE_FULLSCREEN) != 0; + maximized = (window_state & LIBDECOR_WINDOW_STATE_MAXIMIZED) != 0; + active = (window_state & LIBDECOR_WINDOW_STATE_ACTIVE) != 0; + tiled = (window_state & tiled_states) != 0; +#if SDL_LIBDECOR_CHECK_VERSION(0, 2, 0) + suspended = (window_state & LIBDECOR_WINDOW_STATE_SUSPENDED) != 0; +#endif +#if SDL_LIBDECOR_CHECK_VERSION(0, 3, 0) + resizing = (window_state & LIBDECOR_WINDOW_STATE_RESIZING) != 0; +#endif + } + const bool floating = !(fullscreen || maximized || tiled); + + UpdateWindowFullscreen(window, fullscreen); + + /* Always send a maximized/restore event; if the event is redundant it will + * automatically be discarded (see src/events/SDL_windowevents.c) + * + * No, we do not get minimize events from libdecor, however, the minimized + * state can be programmatically set. The meaning of 'minimized' is compositor + * dependent, but in general, we can assume that the flag should remain set until + * the next focused configure event occurs. + */ + if (active || !(window->flags & SDL_WINDOW_MINIMIZED)) { + if (window->flags & SDL_WINDOW_MINIMIZED) { + // If we were minimized, send a restored event before possibly sending maximized. + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + } + SDL_SendWindowEvent(window, + (maximized && !fullscreen) ? SDL_EVENT_WINDOW_MAXIMIZED : SDL_EVENT_WINDOW_RESTORED, + 0, 0); + } + + /* For fullscreen or fixed-size windows we know our size. + * Always assume the configure is wrong. + */ + if (fullscreen) { + if (!libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { + width = wind->requested.logical_width; + height = wind->requested.logical_height; + } else { + // Fullscreen windows know their exact size. + wind->requested.logical_width = width; + wind->requested.logical_height = height; + + if (wind->scale_to_display) { + wind->requested.pixel_width = PointToPixel(window, width); + wind->requested.pixel_height = PointToPixel(window, height); + } + } + } else { + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + /* If we're a fixed-size window, we know our size for sure. + * Always assume the configure is wrong. + */ + if (!wind->scale_to_display) { + width = wind->requested.logical_width = window->floating.w; + height = wind->requested.logical_height = window->floating.h; + } else { + wind->requested.pixel_width = window->floating.w; + wind->requested.pixel_height = window->floating.h; + width = wind->requested.logical_width = PixelToPoint(window, window->floating.w); + height = wind->requested.logical_height = PixelToPoint(window, window->floating.h); + } + + OverrideLibdecorLimits(window); + } else { + /* XXX: The libdecor cairo plugin sends bogus content sizes that add the + * height of the title bar when transitioning from a fixed-size to + * floating state. Ignore the sent window dimensions in this case, + * in favor of the cached value to avoid the window increasing in + * size after every state transition. + * + * https://gitlab.freedesktop.org/libdecor/libdecor/-/issues/34 + */ + if ((floating && (!wind->floating && !(window->flags & SDL_WINDOW_BORDERLESS))) || + !libdecor_configuration_get_content_size(configuration, frame, &width, &height)) { + /* This happens when we're being restored from a non-floating state, + * or the compositor indicates that the size is up to the client, so + * used the cached window size here. + */ + if (floating) { + width = window->floating.w; + height = window->floating.h; + } else { + width = window->windowed.w; + height = window->windowed.h; + } + + if (!wind->scale_to_display) { + wind->requested.logical_width = width; + wind->requested.logical_height = height; + } else { + wind->requested.pixel_width = width; + wind->requested.pixel_height = height; + width = wind->requested.logical_width = PixelToPoint(window, width); + height = wind->requested.logical_height = PixelToPoint(window, height); + } + } else { + /* Don't apply the supplied dimensions if they haven't changed from the last configuration + * event, or a newer size set programmatically can be overwritten by old data. + */ + if (width != wind->last_configure.width || height != wind->last_configure.height) { + wind->requested.logical_width = width; + wind->requested.logical_height = height; + + if (wind->scale_to_display) { + wind->requested.pixel_width = PointToPixel(window, width); + wind->requested.pixel_height = PointToPixel(window, height); + } + } + } + } + + /* Notes on the spec: + * + * - The content limits are only a hint, which the compositor is free to ignore, + * so apply them manually when appropriate. + * + * - Maximized windows must have their exact dimensions respected, thus they must + * not be resized, or a protocol violation can occur. + * + * - When resizing a window, the width/height are maximum values, so aspect ratio + * correction can't resize beyond the existing dimensions, or a protocol violation + * can occur. In practice, nothing seems to kill clients that do this, but doing + * so causes GNOME to glitch out. + */ + if (!maximized) { + if (!wind->scale_to_display) { + if (window->max_w > 0) { + wind->requested.logical_width = SDL_min(wind->requested.logical_width, window->max_w); + } + wind->requested.logical_width = SDL_max(wind->requested.logical_width, window->min_w); + + if (window->max_h > 0) { + wind->requested.logical_height = SDL_min(wind->requested.logical_height, window->max_h); + } + wind->requested.logical_height = SDL_max(wind->requested.logical_height, window->min_h); + + // Aspect correction. + const float aspect = (float)wind->requested.logical_width / (float)wind->requested.logical_height; + + if (window->min_aspect != 0.f && aspect < window->min_aspect) { + wind->requested.logical_height = SDL_lroundf((float)wind->requested.logical_width / window->min_aspect); + } else if (window->max_aspect != 0.f && aspect > window->max_aspect) { + wind->requested.logical_width = SDL_lroundf((float)wind->requested.logical_height * window->max_aspect); + } + } else { + if (window->max_w > 0) { + wind->requested.pixel_width = SDL_min(wind->requested.pixel_width, window->max_w); + } + wind->requested.pixel_width = SDL_max(wind->requested.pixel_width, window->min_w); + + if (window->max_h > 0) { + wind->requested.pixel_height = SDL_min(wind->requested.pixel_height, window->max_h); + } + wind->requested.pixel_height = SDL_max(wind->requested.pixel_height, window->min_h); + + // Aspect correction. + const float aspect = (float)wind->requested.pixel_width / (float)wind->requested.pixel_height; + + if (window->min_aspect != 0.f && aspect < window->min_aspect) { + wind->requested.pixel_height = SDL_lroundf((float)wind->requested.pixel_width / window->min_aspect); + } else if (window->max_aspect != 0.f && aspect > window->max_aspect) { + wind->requested.pixel_width = SDL_lroundf((float)wind->requested.pixel_height * window->max_aspect); + } + + wind->requested.logical_width = PixelToPoint(window, wind->requested.pixel_width); + wind->requested.logical_height = PixelToPoint(window, wind->requested.pixel_height); + } + } + } + + // Store the new state. + wind->last_configure.width = width; + wind->last_configure.height = height; + wind->floating = floating; + wind->suspended = suspended; + wind->active = active; + window->tiled = tiled; + wind->resizing = resizing; + + // Update the window manager capabilities. +#if SDL_LIBDECOR_CHECK_VERSION(0, 3, 0) + enum libdecor_wm_capabilities caps; +#ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR + if (libdecor_frame_get_wm_capabilities) { + caps = libdecor_frame_get_wm_capabilities(wind->shell_surface.libdecor.frame); +#else + caps = libdecor_frame_get_wm_capabilities(wind->shell_surface.libdecor.frame); + { +#endif + wind->wm_caps = 0; + wind->wm_caps |= caps & LIBDECOR_WM_CAPABILITIES_WINDOW_MENU ? WAYLAND_WM_CAPS_WINDOW_MENU : 0; + wind->wm_caps |= caps & LIBDECOR_WM_CAPABILITIES_MAXIMIZE ? WAYLAND_WM_CAPS_MAXIMIZE : 0; + wind->wm_caps |= caps & LIBDECOR_WM_CAPABILITIES_FULLSCREEN ? WAYLAND_WM_CAPS_FULLSCREEN : 0; + wind->wm_caps |= caps & LIBDECOR_WM_CAPABILITIES_MINIMIZE ? WAYLAND_WM_CAPS_MINIMIZE : 0; + } +#endif + + // Calculate the new window geometry + if (ConfigureWindowGeometry(window)) { + // ... then commit the changes on the libdecor side. + struct libdecor_state *state = libdecor_state_new(wind->current.logical_width, wind->current.logical_height); + libdecor_frame_commit(frame, state, configuration); + libdecor_state_free(state); + } + + if (!wind->shell_surface.libdecor.initial_configure_seen) { + LibdecorGetMinContentSize(frame, &wind->system_limits.min_width, &wind->system_limits.min_height); + wind->shell_surface.libdecor.initial_configure_seen = true; + } + if (wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE) { + wind->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME; + } + + /* Update the resize capability if this config event was the result of the + * compositor taking a window out of fullscreen. Since this will change the + * capabilities and commit a new frame state with the last known content + * dimension, this has to be called after the new state has been committed + * and the new content dimensions were updated. + */ + if (prev_fullscreen && !wind->is_fullscreen) { + Wayland_SetWindowResizable(SDL_GetVideoDevice(), window, + !!(window->flags & SDL_WINDOW_RESIZABLE)); + } +} + +static void decoration_frame_close(struct libdecor_frame *frame, void *user_data) +{ + SDL_SendWindowEvent(((SDL_WindowData *)user_data)->sdlwindow, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); +} + +static void decoration_frame_commit(struct libdecor_frame *frame, void *user_data) +{ + /* libdecor decoration subsurfaces are synchronous, so the client needs to + * commit a frame to trigger an update of the decoration surfaces. + */ + SDL_WindowData *wind = (SDL_WindowData *)user_data; + if (!wind->suspended && wind->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_SHOWN) { + SDL_SendWindowEvent(wind->sdlwindow, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } +} + +static void decoration_dismiss_popup(struct libdecor_frame *frame, const char *seat_name, void *user_data) +{ + // NOP +} + +static struct libdecor_frame_interface libdecor_frame_interface = { + decoration_frame_configure, + decoration_frame_close, + decoration_frame_commit, + decoration_dismiss_popup +}; +#endif + +static void Wayland_HandlePreferredScaleChanged(SDL_WindowData *window_data, double factor) +{ + const double old_factor = window_data->scale_factor; + + // Round the scale factor if viewports aren't available. + if (!window_data->viewport) { + factor = SDL_ceil(factor); + } + + if (factor != old_factor) { + window_data->scale_factor = factor; + + if (window_data->scale_to_display) { + /* If the window is in the floating state with a user/application specified size, calculate the new + * logical size from the backbuffer size. Otherwise, use the fixed underlying logical size to calculate + * the new backbuffer dimensions. + */ + if (window_data->floating) { + window_data->requested.logical_width = PixelToPoint(window_data->sdlwindow, window_data->requested.pixel_width); + window_data->requested.logical_height = PixelToPoint(window_data->sdlwindow, window_data->requested.pixel_height); + } else { + window_data->requested.pixel_width = PointToPixel(window_data->sdlwindow, window_data->requested.logical_width); + window_data->requested.pixel_height = PointToPixel(window_data->sdlwindow, window_data->requested.logical_height); + } + } + + if (window_data->sdlwindow->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY || window_data->scale_to_display) { + ConfigureWindowGeometry(window_data->sdlwindow); + CommitLibdecorFrame(window_data->sdlwindow); + } + } +} + +static void Wayland_MaybeUpdateScaleFactor(SDL_WindowData *window) +{ + double factor; + int i; + + /* If the fractional scale protocol is present or the core protocol supports the + * preferred buffer scale event, the compositor will explicitly tell the application + * what scale it wants via these events, so don't try to determine the scale factor + * from which displays the surface has entered. + */ + if (window->fractional_scale || wl_surface_get_version(window->surface) >= WL_SURFACE_PREFERRED_BUFFER_SCALE_SINCE_VERSION) { + return; + } + + if (window->num_outputs != 0) { + // Check every display's factor, use the highest + factor = 0.0; + for (i = 0; i < window->num_outputs; i++) { + SDL_DisplayData *internal = window->outputs[i]; + factor = SDL_max(factor, internal->scale_factor); + } + } else { + // All outputs removed, just fall back. + factor = window->scale_factor; + } + + Wayland_HandlePreferredScaleChanged(window, factor); +} + +void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, SDL_DisplayData *display_data) +{ + for (int i = 0; i < window->num_outputs; i++) { + if (window->outputs[i] == display_data) { // remove this one + if (i == (window->num_outputs - 1)) { + window->outputs[i] = NULL; + } else { + SDL_memmove(&window->outputs[i], + &window->outputs[i + 1], + sizeof(SDL_DisplayData *) * ((window->num_outputs - i) - 1)); + } + window->num_outputs--; + i--; + } + } + + if (window->num_outputs == 0) { + SDL_free(window->outputs); + window->outputs = NULL; + } else if (!window->is_fullscreen || window->num_outputs == 1) { + Wayland_move_window(window->sdlwindow); + Wayland_MaybeUpdateScaleFactor(window); + } +} + +static void handle_surface_enter(void *data, struct wl_surface *surface, struct wl_output *output) +{ + SDL_WindowData *window = data; + SDL_DisplayData *internal = wl_output_get_user_data(output); + SDL_DisplayData **new_outputs; + + if (!SDL_WAYLAND_own_output(output) || !SDL_WAYLAND_own_surface(surface)) { + return; + } + + new_outputs = SDL_realloc(window->outputs, + sizeof(SDL_DisplayData *) * (window->num_outputs + 1)); + if (!new_outputs) { + return; + } + window->outputs = new_outputs; + window->outputs[window->num_outputs++] = internal; + + // Update the scale factor after the move so that fullscreen outputs are updated. + if (!window->is_fullscreen || window->num_outputs == 1) { + Wayland_move_window(window->sdlwindow); + Wayland_MaybeUpdateScaleFactor(window); + } +} + +static void handle_surface_leave(void *data, struct wl_surface *surface, struct wl_output *output) +{ + SDL_WindowData *window = (SDL_WindowData *)data; + + if (!SDL_WAYLAND_own_output(output) || !SDL_WAYLAND_own_surface(surface)) { + return; + } + + Wayland_RemoveOutputFromWindow(window, (SDL_DisplayData *)wl_output_get_user_data(output)); +} + +static void handle_preferred_buffer_scale(void *data, struct wl_surface *wl_surface, int32_t factor) +{ + SDL_WindowData *wind = data; + + /* The spec is unclear on how this interacts with the fractional scaling protocol, + * so, for now, assume that the fractional scaling protocol takes priority and + * only listen to this event if the fractional scaling protocol is not present. + */ + if (!wind->fractional_scale) { + Wayland_HandlePreferredScaleChanged(data, (double)factor); + } +} + +static void handle_preferred_buffer_transform(void *data, struct wl_surface *wl_surface, uint32_t transform) +{ + // Nothing to do here. +} + +static const struct wl_surface_listener surface_listener = { + handle_surface_enter, + handle_surface_leave, + handle_preferred_buffer_scale, + handle_preferred_buffer_transform +}; + +static void handle_preferred_fractional_scale(void *data, struct wp_fractional_scale_v1 *wp_fractional_scale_v1, uint32_t scale) +{ + const double factor = (double)scale / 120.; // 120 is a magic number defined in the spec as a common denominator + Wayland_HandlePreferredScaleChanged(data, factor); +} + +static const struct wp_fractional_scale_v1_listener fractional_scale_listener = { + handle_preferred_fractional_scale +}; + +static void frog_preferred_metadata_handler(void *data, struct frog_color_managed_surface *frog_color_managed_surface, uint32_t transfer_function, + uint32_t output_display_primary_red_x, uint32_t output_display_primary_red_y, + uint32_t output_display_primary_green_x, uint32_t output_display_primary_green_y, + uint32_t output_display_primary_blue_x, uint32_t output_display_primary_blue_y, + uint32_t output_white_point_x, uint32_t output_white_point_y, + uint32_t max_luminance, uint32_t min_luminance, + uint32_t max_full_frame_luminance) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + SDL_HDROutputProperties HDR; + + SDL_zero(HDR); + + switch (transfer_function) { + case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_ST2084_PQ: + /* ITU-R BT.2408-7 (Sept 2023) has the reference PQ white level at 203 nits, + * while older Dolby documentation claims a reference level of 100 nits. + * + * Use 203 nits for now. + */ + HDR.HDR_headroom = max_luminance / 203.0f; + break; + case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SCRGB_LINEAR: + HDR.HDR_headroom = max_luminance / 80.0f; + break; + case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_UNDEFINED: + case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_SRGB: + case FROG_COLOR_MANAGED_SURFACE_TRANSFER_FUNCTION_GAMMA_22: + default: + HDR.HDR_headroom = 1.0f; + break; + } + + HDR.SDR_white_level = 1.0f; + SDL_SetWindowHDRProperties(wind->sdlwindow, &HDR, true); +} + +static const struct frog_color_managed_surface_listener frog_surface_listener = { + frog_preferred_metadata_handler +}; + +static void feedback_surface_preferred_changed(void *data, + struct wp_color_management_surface_feedback_v1 *wp_color_management_surface_feedback_v1, + uint32_t identity) +{ + SDL_WindowData *wind = (SDL_WindowData *)data; + Wayland_GetColorInfoForWindow(wind, false); +} + +static const struct wp_color_management_surface_feedback_v1_listener color_management_surface_feedback_listener = { + feedback_surface_preferred_changed +}; + +static void SetKeyboardFocus(SDL_Window *window, bool set_focus) +{ + SDL_Window *toplevel = window; + + // Find the toplevel parent + while (SDL_WINDOW_IS_POPUP(toplevel)) { + toplevel = toplevel->parent; + } + + toplevel->internal->keyboard_focus = window; + + if (set_focus && !window->is_hiding && !window->is_destroying) { + SDL_SetKeyboardFocus(window); + } +} + +bool Wayland_SetWindowHitTest(SDL_Window *window, bool enabled) +{ + return true; // just succeed, the real work is done elsewhere. +} + +static struct xdg_toplevel *GetToplevelForWindow(SDL_WindowData *wind) +{ + if (wind) { + /* Libdecor crashes on attempts to unset the parent by passing null, which is allowed by the + * toplevel spec, so just use the raw xdg-toplevel instead (that's what libdecor does + * internally anyways). + */ +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR && wind->shell_surface.libdecor.frame) { + return libdecor_frame_get_xdg_toplevel(wind->shell_surface.libdecor.frame); + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL && wind->shell_surface.xdg.toplevel.xdg_toplevel) { + return wind->shell_surface.xdg.toplevel.xdg_toplevel; + } + } + + return NULL; +} + +bool Wayland_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent_window) +{ + SDL_WindowData *child_data = window->internal; + SDL_WindowData *parent_data = parent_window ? parent_window->internal : NULL; + + child_data->reparenting_required = false; + + if (parent_data && parent_data->shell_surface_status != WAYLAND_SHELL_SURFACE_STATUS_SHOWN) { + // Need to wait for the parent to become mapped, or it's the same as setting a null parent. + child_data->reparenting_required = true; + return true; + } + + struct xdg_toplevel *child_toplevel = GetToplevelForWindow(child_data); + struct xdg_toplevel *parent_toplevel = GetToplevelForWindow(parent_data); + + if (child_toplevel) { + xdg_toplevel_set_parent(child_toplevel, parent_toplevel); + } + + return true; +} + +bool Wayland_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal) +{ + SDL_VideoData *viddata = _this->internal; + SDL_WindowData *data = window->internal; + SDL_WindowData *parent_data = window->parent->internal; + + if (parent_data->shell_surface_status != WAYLAND_SHELL_SURFACE_STATUS_SHOWN) { + // Need to wait for the parent to become mapped before changing modal status. + data->reparenting_required = true; + return true; + } else { + data->reparenting_required = false; + } + + struct xdg_toplevel *toplevel = GetToplevelForWindow(data); + + if (toplevel) { + if (viddata->xdg_wm_dialog_v1) { + if (modal) { + if (!data->xdg_dialog_v1) { + data->xdg_dialog_v1 = xdg_wm_dialog_v1_get_xdg_dialog(viddata->xdg_wm_dialog_v1, toplevel); + } + + xdg_dialog_v1_set_modal(data->xdg_dialog_v1); + } else if (data->xdg_dialog_v1) { + xdg_dialog_v1_unset_modal(data->xdg_dialog_v1); + } + } + } + + return true; +} + +static void show_hide_sync_handler(void *data, struct wl_callback *callback, uint32_t callback_data) +{ + // Get the window from the ID as it may have been destroyed + SDL_WindowID windowID = (SDL_WindowID)((uintptr_t)data); + SDL_Window *window = SDL_GetWindowFromID(windowID); + + if (window && window->internal) { + SDL_WindowData *wind = window->internal; + wind->show_hide_sync_required = false; + } + + wl_callback_destroy(callback); +} + +static struct wl_callback_listener show_hide_sync_listener = { + show_hide_sync_handler +}; + +static void exported_handle_handler(void *data, struct zxdg_exported_v2 *zxdg_exported_v2, const char *handle) +{ + SDL_WindowData *wind = (SDL_WindowData*)data; + SDL_PropertiesID props = SDL_GetWindowProperties(wind->sdlwindow); + + SDL_SetStringProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING, handle); +} + +static struct zxdg_exported_v2_listener exported_v2_listener = { + exported_handle_handler +}; + +void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *c = _this->internal; + SDL_WindowData *data = window->internal; + SDL_PropertiesID props = SDL_GetWindowProperties(window); + + // Custom surfaces don't get toplevels and are always considered 'shown'; nothing to do here. + if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_CUSTOM) { + return; + } + + /* If this is a child window, the parent *must* be in the final shown state, + * meaning that it has received a configure event, followed by a frame callback. + * If not, a race condition can result, with effects ranging from the child + * window to spuriously closing to protocol errors. + * + * If waiting on the parent window, set the pending status and the window will + * be shown when the parent is in the shown state. + */ + if (window->parent) { + if (window->parent->internal->shell_surface_status != WAYLAND_SHELL_SURFACE_STATUS_SHOWN) { + data->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_SHOW_PENDING; + return; + } + } + + /* The window was hidden, but the sync point hasn't yet been reached. + * Pump events to avoid a possible protocol violation. + */ + if (data->show_hide_sync_required) { + WAYLAND_wl_display_roundtrip(c->display); + } + + data->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE; + + /* Detach any previous buffers before resetting everything, otherwise when + * calling this a second time you'll get an annoying protocol error! + * + * FIXME: This was originally moved to HideWindow, which _should_ make + * sense, but for whatever reason UE5's popups require that this actually + * be in both places at once? Possibly from renderers making commits? I can't + * fully remember if this location caused crashes or if I was fixing a pair + * of Hide/Show calls. In any case, UE gives us a pretty good test and having + * both detach calls passes. This bug may be relevant if I'm wrong: + * + * https://bugs.kde.org/show_bug.cgi?id=448856 + * + * -flibit + */ + wl_surface_attach(data->surface, NULL, 0, 0); + wl_surface_commit(data->surface); + + // Create the shell surface and map the toplevel/popup +#ifdef HAVE_LIBDECOR_H + if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + data->shell_surface.libdecor.frame = libdecor_decorate(c->shell.libdecor, + data->surface, + &libdecor_frame_interface, + data); + if (!data->shell_surface.libdecor.frame) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); + } else { + libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, data->app_id); + libdecor_frame_map(data->shell_surface.libdecor.frame); + if (window->flags & SDL_WINDOW_BORDERLESS) { + // Note: Calling this with 'true' immediately after mapping will cause the libdecor Cairo plugin to crash. + libdecor_frame_set_visibility(data->shell_surface.libdecor.frame, false); + } + + if (c->zxdg_exporter_v2) { + data->exported = zxdg_exporter_v2_export_toplevel(c->zxdg_exporter_v2, data->surface); + zxdg_exported_v2_add_listener(data->exported, &exported_v2_listener, data); + } + + if (c->xdg_toplevel_icon_manager_v1 && data->xdg_toplevel_icon_v1) { + xdg_toplevel_icon_manager_v1_set_icon(_this->internal->xdg_toplevel_icon_manager_v1, + libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame), + data->xdg_toplevel_icon_v1); + } + + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER, libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame)); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER, libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame)); + } + } else +#endif + if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL || data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + data->shell_surface.xdg.surface = xdg_wm_base_get_xdg_surface(c->shell.xdg, data->surface); + xdg_surface_set_user_data(data->shell_surface.xdg.surface, data); + xdg_surface_add_listener(data->shell_surface.xdg.surface, &shell_surface_listener_xdg, data); + SDL_SetPointerProperty(SDL_GetWindowProperties(window), SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER, data->shell_surface.xdg.surface); + + if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + SDL_Window *parent = window->parent; + SDL_WindowData *parent_data = parent->internal; + struct xdg_surface *parent_xdg_surface = NULL; + int position_x = 0, position_y = 0; + + // Configure the popup parameters +#ifdef HAVE_LIBDECOR_H + if (parent_data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + parent_xdg_surface = libdecor_frame_get_xdg_surface(parent_data->shell_surface.libdecor.frame); + } else +#endif + if (parent_data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL || + parent_data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + parent_xdg_surface = parent_data->shell_surface.xdg.surface; + } + + // Set up the positioner for the popup and configure the constraints + data->shell_surface.xdg.popup.xdg_positioner = xdg_wm_base_create_positioner(c->shell.xdg); + xdg_positioner_set_anchor(data->shell_surface.xdg.popup.xdg_positioner, XDG_POSITIONER_ANCHOR_TOP_LEFT); + xdg_positioner_set_anchor_rect(data->shell_surface.xdg.popup.xdg_positioner, 0, 0, parent->internal->current.logical_width, parent->internal->current.logical_width); + xdg_positioner_set_constraint_adjustment(data->shell_surface.xdg.popup.xdg_positioner, + XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_X | XDG_POSITIONER_CONSTRAINT_ADJUSTMENT_SLIDE_Y); + xdg_positioner_set_gravity(data->shell_surface.xdg.popup.xdg_positioner, XDG_POSITIONER_GRAVITY_BOTTOM_RIGHT); + xdg_positioner_set_size(data->shell_surface.xdg.popup.xdg_positioner, data->current.logical_width, data->current.logical_height); + + // Set the popup initial position + position_x = window->last_position_pending ? window->pending.x : window->x; + position_y = window->last_position_pending ? window->pending.y : window->y; + EnsurePopupPositionIsValid(window, &position_x, &position_y); + if (data->scale_to_display) { + position_x = PixelToPoint(window->parent, position_x); + position_y = PixelToPoint(window->parent, position_y); + } + AdjustPopupOffset(window, &position_x, &position_y); + xdg_positioner_set_offset(data->shell_surface.xdg.popup.xdg_positioner, position_x, position_y); + + // Assign the popup role + data->shell_surface.xdg.popup.xdg_popup = xdg_surface_get_popup(data->shell_surface.xdg.surface, + parent_xdg_surface, + data->shell_surface.xdg.popup.xdg_positioner); + xdg_popup_add_listener(data->shell_surface.xdg.popup.xdg_popup, &popup_listener_xdg, data); + + if (window->flags & SDL_WINDOW_TOOLTIP) { + struct wl_region *region; + + // Tooltips can't be interacted with, so turn off the input region to avoid blocking anything behind them + region = wl_compositor_create_region(c->compositor); + wl_region_add(region, 0, 0, 0, 0); + wl_surface_set_input_region(data->surface, region); + wl_region_destroy(region); + } else if (window->flags & SDL_WINDOW_POPUP_MENU) { + SetKeyboardFocus(window, window->parent == SDL_GetKeyboardFocus()); + } + + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER, data->shell_surface.xdg.popup.xdg_popup); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER, data->shell_surface.xdg.popup.xdg_positioner); + } else { + data->shell_surface.xdg.toplevel.xdg_toplevel = xdg_surface_get_toplevel(data->shell_surface.xdg.surface); + xdg_toplevel_set_app_id(data->shell_surface.xdg.toplevel.xdg_toplevel, data->app_id); + xdg_toplevel_add_listener(data->shell_surface.xdg.toplevel.xdg_toplevel, &toplevel_listener_xdg, data); + + // Create the window decorations + if (c->decoration_manager) { + data->server_decoration = zxdg_decoration_manager_v1_get_toplevel_decoration(c->decoration_manager, data->shell_surface.xdg.toplevel.xdg_toplevel); + zxdg_toplevel_decoration_v1_add_listener(data->server_decoration, &decoration_listener, window); + const enum zxdg_toplevel_decoration_v1_mode mode = !(window->flags & SDL_WINDOW_BORDERLESS) ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; + zxdg_toplevel_decoration_v1_set_mode(data->server_decoration, mode); + } + + if (c->zxdg_exporter_v2) { + data->exported = zxdg_exporter_v2_export_toplevel(c->zxdg_exporter_v2, data->surface); + zxdg_exported_v2_add_listener(data->exported, &exported_v2_listener, data); + } + + if (c->xdg_toplevel_icon_manager_v1 && data->xdg_toplevel_icon_v1) { + xdg_toplevel_icon_manager_v1_set_icon(_this->internal->xdg_toplevel_icon_manager_v1, + data->shell_surface.xdg.toplevel.xdg_toplevel, + data->xdg_toplevel_icon_v1); + } + + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER, data->shell_surface.xdg.toplevel.xdg_toplevel); + } + } + + // Restore state that was set prior to this call + Wayland_SetWindowParent(_this, window, window->parent); + + if (window->flags & SDL_WINDOW_MODAL) { + Wayland_SetWindowModal(_this, window, true); + } + + Wayland_SetWindowTitle(_this, window); + + /* We have to wait until the surface gets a "configure" event, or use of + * this surface will fail. This is a new rule for xdg_shell. + */ +#ifdef HAVE_LIBDECOR_H + if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (data->shell_surface.libdecor.frame) { + while (!data->shell_surface.libdecor.initial_configure_seen) { + WAYLAND_wl_display_flush(c->display); + WAYLAND_wl_display_dispatch(c->display); + } + } + } else +#endif + if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP || data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + /* Unlike libdecor we need to call this explicitly to prevent a deadlock. + * libdecor will call this as part of their configure event! + * -flibit + */ + wl_surface_commit(data->surface); + if (data->shell_surface.xdg.surface) { + while (!data->shell_surface.xdg.initial_configure_seen) { + WAYLAND_wl_display_flush(c->display); + WAYLAND_wl_display_dispatch(c->display); + } + } + } else { + // Nothing to see here, just commit. + wl_surface_commit(data->surface); + } + + // Make sure the window can't be resized to 0 or it can be spuriously closed by the window manager. + data->system_limits.min_width = SDL_max(data->system_limits.min_width, 1); + data->system_limits.min_height = SDL_max(data->system_limits.min_height, 1); + + /* Unlike the rest of window state we have to set this _after_ flushing the + * display, because we need to create the decorations before possibly hiding + * them immediately afterward. + */ +#ifdef HAVE_LIBDECOR_H + if (data->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + // Libdecor plugins can enforce minimum window sizes, so adjust if the initial window size is too small. + if (window->windowed.w < data->system_limits.min_width || + window->windowed.h < data->system_limits.min_height) { + + // Warn if the window frame will be larger than the content surface. + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, + "Window dimensions (%i, %i) are smaller than the system enforced minimum (%i, %i); window borders will be larger than the content surface.", + window->windowed.w, window->windowed.h, data->system_limits.min_width, data->system_limits.min_height); + + data->current.logical_width = SDL_max(window->windowed.w, data->system_limits.min_width); + data->current.logical_height = SDL_max(window->windowed.h, data->system_limits.min_height); + CommitLibdecorFrame(window); + } + } +#endif + Wayland_SetWindowResizable(_this, window, !!(window->flags & SDL_WINDOW_RESIZABLE)); + + // We're finally done putting the window together, raise if possible + if (c->activation_manager) { + /* Note that we don't check for empty strings, as that is still + * considered a valid activation token! + */ + const char *activation_token = SDL_getenv("XDG_ACTIVATION_TOKEN"); + if (activation_token) { + xdg_activation_v1_activate(c->activation_manager, + activation_token, + data->surface); + + // Clear this variable, per the protocol's request + SDL_unsetenv_unsafe("XDG_ACTIVATION_TOKEN"); + } + } + + data->show_hide_sync_required = true; + struct wl_callback *cb = wl_display_sync(_this->internal->display); + wl_callback_add_listener(cb, &show_hide_sync_listener, (void*)((uintptr_t)window->id)); + + // Send an exposure event to signal that the client should draw. + if (data->shell_surface_status == WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } +} + +static void Wayland_ReleasePopup(SDL_VideoDevice *_this, SDL_Window *popup) +{ + SDL_WindowData *popupdata; + + // Basic sanity checks to weed out the weird popup closures + if (!SDL_ObjectValid(popup, SDL_OBJECT_TYPE_WINDOW)) { + return; + } + popupdata = popup->internal; + if (!popupdata) { + return; + } + + // This may already be freed by a parent popup! + if (popupdata->shell_surface.xdg.popup.xdg_popup == NULL) { + return; + } + + if (popup->flags & SDL_WINDOW_POPUP_MENU) { + SDL_Window *new_focus = popup->parent; + bool set_focus = popup == SDL_GetKeyboardFocus(); + + // Find the highest level window, up to the toplevel parent, that isn't being hidden or destroyed. + while (SDL_WINDOW_IS_POPUP(new_focus) && (new_focus->is_hiding || new_focus->is_destroying)) { + new_focus = new_focus->parent; + + // If some window in the chain currently had focus, set it to the new lowest-level window. + if (!set_focus) { + set_focus = new_focus == SDL_GetKeyboardFocus(); + } + } + + SetKeyboardFocus(new_focus, set_focus); + } + + xdg_popup_destroy(popupdata->shell_surface.xdg.popup.xdg_popup); + xdg_positioner_destroy(popupdata->shell_surface.xdg.popup.xdg_positioner); + popupdata->shell_surface.xdg.popup.xdg_popup = NULL; + popupdata->shell_surface.xdg.popup.xdg_positioner = NULL; + + SDL_PropertiesID props = SDL_GetWindowProperties(popup); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_POPUP_POINTER, NULL); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_POSITIONER_POINTER, NULL); +} + +void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *data = _this->internal; + SDL_WindowData *wind = window->internal; + SDL_PropertiesID props = SDL_GetWindowProperties(window); + + // Custom surfaces have nothing to destroy and are always considered to be 'shown'; nothing to do here. + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_CUSTOM) { + return; + } + + /* The window was shown, but the sync point hasn't yet been reached. + * Pump events to avoid a possible protocol violation. + */ + if (wind->show_hide_sync_required) { + WAYLAND_wl_display_roundtrip(data->display); + } + + wind->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_HIDDEN; + + if (wind->server_decoration) { + zxdg_toplevel_decoration_v1_destroy(wind->server_decoration); + wind->server_decoration = NULL; + } + + // Be sure to detach after this is done, otherwise ShowWindow crashes! + if (wind->shell_surface_type != WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + wl_surface_attach(wind->surface, NULL, 0, 0); + wl_surface_commit(wind->surface); + } + + // Clean up the export handle. + if (wind->exported) { + zxdg_exported_v2_destroy(wind->exported); + wind->exported = NULL; + + SDL_SetStringProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_EXPORT_HANDLE_STRING, NULL); + } + + if (wind->xdg_dialog_v1) { + xdg_dialog_v1_destroy(wind->xdg_dialog_v1); + wind->xdg_dialog_v1 = NULL; + } + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (wind->shell_surface.libdecor.frame) { + libdecor_frame_unref(wind->shell_surface.libdecor.frame); + wind->shell_surface.libdecor.frame = NULL; + + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER, NULL); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER, NULL); + } + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + Wayland_ReleasePopup(_this, window); + } else if (wind->shell_surface.xdg.toplevel.xdg_toplevel) { + xdg_toplevel_destroy(wind->shell_surface.xdg.toplevel.xdg_toplevel); + wind->shell_surface.xdg.toplevel.xdg_toplevel = NULL; + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_TOPLEVEL_POINTER, NULL); + } + if (wind->shell_surface.xdg.surface) { + xdg_surface_destroy(wind->shell_surface.xdg.surface); + wind->shell_surface.xdg.surface = NULL; + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_XDG_SURFACE_POINTER, NULL); + } + + wind->show_hide_sync_required = true; + struct wl_callback *cb = wl_display_sync(_this->internal->display); + wl_callback_add_listener(cb, &show_hide_sync_listener, (void*)((uintptr_t)window->id)); +} + +static void handle_xdg_activation_done(void *data, + struct xdg_activation_token_v1 *xdg_activation_token_v1, + const char *token) +{ + SDL_WindowData *window = data; + if (xdg_activation_token_v1 == window->activation_token) { + xdg_activation_v1_activate(window->waylandData->activation_manager, + token, + window->surface); + xdg_activation_token_v1_destroy(window->activation_token); + window->activation_token = NULL; + } +} + +static const struct xdg_activation_token_v1_listener activation_listener_xdg = { + handle_xdg_activation_done +}; + +/* The xdg-activation protocol considers "activation" to be one of two things: + * + * 1: Raising a window to the top and flashing the titlebar + * 2: Flashing the titlebar while keeping the window where it is + * + * As you might expect from Wayland, the general policy is to go with #2 unless + * the client can prove to the compositor beyond a reasonable doubt that raising + * the window will not be malicuous behavior. + * + * For SDL this means RaiseWindow and FlashWindow both use the same protocol, + * but in different ways: RaiseWindow will provide as _much_ information as + * possible while FlashWindow will provide as _little_ information as possible, + * to nudge the compositor into doing what we want. + * + * This isn't _strictly_ what the protocol says will happen, but this is what + * current implementations are doing (as of writing, YMMV in the far distant + * future). + * + * -flibit + */ +static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_wind, bool set_serial) +{ + struct SDL_WaylandInput * input = data->input; + SDL_Window *focus = SDL_GetKeyboardFocus(); + struct wl_surface *requesting_surface = focus ? focus->internal->surface : NULL; + + if (data->activation_manager) { + if (target_wind->activation_token) { + // We're about to overwrite this with a new request + xdg_activation_token_v1_destroy(target_wind->activation_token); + } + + target_wind->activation_token = xdg_activation_v1_get_activation_token(data->activation_manager); + xdg_activation_token_v1_add_listener(target_wind->activation_token, + &activation_listener_xdg, + target_wind); + + /* Note that we are not setting the app_id here. + * + * Hypothetically we could set the app_id from data->classname, but + * that part of the API is for _external_ programs, not ourselves. + * + * -flibit + */ + if (requesting_surface) { + // This specifies the surface from which the activation request is originating, not the activation target surface. + xdg_activation_token_v1_set_surface(target_wind->activation_token, requesting_surface); + } + if (set_serial && input && input->seat) { + xdg_activation_token_v1_set_serial(target_wind->activation_token, input->last_implicit_grab_serial, input->seat); + } + xdg_activation_token_v1_commit(target_wind->activation_token); + } +} + +void Wayland_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + Wayland_activate_window(_this->internal, window->internal, true); +} + +bool Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation) +{ + /* Not setting the serial will specify 'urgency' without switching focus as per + * https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/9#note_854977 + */ + Wayland_activate_window(_this->internal, window->internal, false); + return true; +} + +SDL_FullscreenResult Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, + SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) +{ + SDL_WindowData *wind = window->internal; + struct wl_output *output = display->internal->output; + + // Custom surfaces have no toplevel to make fullscreen. + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_CUSTOM) { + return SDL_FULLSCREEN_FAILED; + } + + if (wind->show_hide_sync_required) { + WAYLAND_wl_display_roundtrip(_this->internal->display); + } + + // Flushing old events pending a new one, ignore this request. + if (wind->drop_fullscreen_requests) { + return SDL_FULLSCREEN_SUCCEEDED; + } + + wind->drop_fullscreen_requests = true; + FlushPendingEvents(window); + wind->drop_fullscreen_requests = false; + + // Nothing to do if the window is not fullscreen, and this isn't an explicit enter request. + if (!wind->is_fullscreen) { + if (fullscreen == SDL_FULLSCREEN_OP_UPDATE) { + // Request was out of date; signal the video core not to update any state. + return SDL_FULLSCREEN_PENDING; + } else if (fullscreen == SDL_FULLSCREEN_OP_LEAVE) { + // Already not fullscreen; nothing to do. + return SDL_FULLSCREEN_SUCCEEDED; + } + } + + // Don't send redundant fullscreen set/unset events. + if (fullscreen != wind->is_fullscreen) { + wind->fullscreen_was_positioned = fullscreen; + SetFullscreen(window, fullscreen ? output : NULL); + } else if (wind->is_fullscreen) { + /* + * If the window is already fullscreen, this is likely a request to switch between + * fullscreen and fullscreen desktop, change outputs, or change the video mode. + * + * If the window is already positioned on the target output, just update the + * window geometry. + */ + if (wind->last_displayID != display->id) { + wind->fullscreen_was_positioned = true; + SetFullscreen(window, output); + } else { + ConfigureWindowGeometry(window); + CommitLibdecorFrame(window); + + return SDL_FULLSCREEN_SUCCEEDED; + } + } + + return SDL_FULLSCREEN_PENDING; +} + +void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + + // Not currently fullscreen or maximized, and no state pending; nothing to do. + if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED)) && + !wind->fullscreen_deadline_count && !wind->maximized_restored_deadline_count) { + return; + } + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (!wind->shell_surface.libdecor.frame) { + return; // Can't do anything yet, wait for ShowWindow + } + libdecor_frame_unset_maximized(wind->shell_surface.libdecor.frame); + + ++wind->maximized_restored_deadline_count; + struct wl_callback *cb = wl_display_sync(_this->internal->display); + wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id)); + } else +#endif + // Note that xdg-shell does NOT provide a way to unset minimize! + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (wind->shell_surface.xdg.toplevel.xdg_toplevel == NULL) { + return; // Can't do anything yet, wait for ShowWindow + } + xdg_toplevel_unset_maximized(wind->shell_surface.xdg.toplevel.xdg_toplevel); + + ++wind->maximized_restored_deadline_count; + struct wl_callback *cb = wl_display_sync(_this->internal->display); + wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id)); + } +} + +void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) +{ + SDL_WindowData *wind = window->internal; + const SDL_VideoData *viddata = (const SDL_VideoData *)_this->internal; + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (wind->shell_surface.libdecor.frame) { + libdecor_frame_set_visibility(wind->shell_surface.libdecor.frame, bordered); + } + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if ((viddata->decoration_manager) && (wind->server_decoration)) { + const enum zxdg_toplevel_decoration_v1_mode mode = bordered ? ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE : ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE; + zxdg_toplevel_decoration_v1_set_mode(wind->server_decoration, mode); + } + } +} + +void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) +{ +#ifdef HAVE_LIBDECOR_H + const SDL_WindowData *wind = window->internal; + + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (!wind->shell_surface.libdecor.frame) { + return; // Can't do anything yet, wait for ShowWindow + } + if (libdecor_frame_has_capability(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE)) { + if (!resizable) { + libdecor_frame_unset_capabilities(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE); + } + } else if (resizable) { + libdecor_frame_set_capabilities(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE); + } + } +#endif + + /* When changing the resize capability on libdecor windows, the limits must always + * be reapplied, as when libdecor changes states, it overwrites the values internally. + */ + SetMinMaxDimensions(window); + CommitLibdecorFrame(window); +} + +void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *viddata = _this->internal; + SDL_WindowData *wind = window->internal; + + if (wind->show_hide_sync_required) { + WAYLAND_wl_display_roundtrip(_this->internal->display); + } + + // Not fullscreen, already maximized, and no state pending; nothing to do. + if (!(window->flags & SDL_WINDOW_FULLSCREEN) && (window->flags & SDL_WINDOW_MAXIMIZED) && + !wind->fullscreen_deadline_count && !wind->maximized_restored_deadline_count) { + return; + } + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (!wind->shell_surface.libdecor.frame) { + return; // Can't do anything yet, wait for ShowWindow + } + + // Commit to preserve any pending size data. + wl_surface_commit(wind->surface); + libdecor_frame_set_maximized(wind->shell_surface.libdecor.frame); + + ++wind->maximized_restored_deadline_count; + struct wl_callback *cb = wl_display_sync(viddata->display); + wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id)); + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (wind->shell_surface.xdg.toplevel.xdg_toplevel == NULL) { + return; // Can't do anything yet, wait for ShowWindow + } + + // Commit to preserve any pending size data. + wl_surface_commit(wind->surface); + xdg_toplevel_set_maximized(wind->shell_surface.xdg.toplevel.xdg_toplevel); + + ++wind->maximized_restored_deadline_count; + struct wl_callback *cb = wl_display_sync(viddata->display); + wl_callback_add_listener(cb, &maximized_restored_deadline_listener, (void *)((uintptr_t)window->id)); + } +} + +void Wayland_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + + if (!(wind->wm_caps & WAYLAND_WM_CAPS_MINIMIZE)) { + return; + } + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (!wind->shell_surface.libdecor.frame) { + return; // Can't do anything yet, wait for ShowWindow + } + libdecor_frame_set_minimized(wind->shell_surface.libdecor.frame); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (wind->shell_surface.xdg.toplevel.xdg_toplevel == NULL) { + return; // Can't do anything yet, wait for ShowWindow + } + xdg_toplevel_set_minimized(wind->shell_surface.xdg.toplevel.xdg_toplevel); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); + } +} + +bool Wayland_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *data = _this->internal; + + /* This may look suspiciously like SetWindowGrab, despite SetMouseRect not + * implicitly doing a grab. And you're right! Wayland doesn't let us mess + * around with mouse focus whatsoever, so it just happens to be that the + * work that we can do in these two functions ends up being the same. + * + * Just know that this call lets you confine with a rect, SetWindowGrab + * lets you confine without a rect. + */ + if (SDL_RectEmpty(&window->mouse_rect) && !(window->flags & SDL_WINDOW_MOUSE_GRABBED)) { + return Wayland_input_unconfine_pointer(data->input, window); + } else { + return Wayland_input_confine_pointer(data->input, window); + } +} + +bool Wayland_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + SDL_VideoData *data = _this->internal; + + if (grabbed) { + return Wayland_input_confine_pointer(data->input, window); + } else if (SDL_RectEmpty(&window->mouse_rect)) { + return Wayland_input_unconfine_pointer(data->input, window); + } + + return true; +} + +bool Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + SDL_VideoData *data = _this->internal; + + if (grabbed) { + return Wayland_input_grab_keyboard(window, data->input); + } else { + return Wayland_input_ungrab_keyboard(window); + } +} + +bool Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + SDL_WindowData *data; + SDL_VideoData *c = _this->internal; + struct wl_surface *external_surface = (struct wl_surface *)SDL_GetPointerProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_WL_SURFACE_POINTER, + (struct wl_surface *)SDL_GetPointerProperty(create_props, "sdl2-compat.external_window", NULL)); + const bool custom_surface_role = (external_surface != NULL) || SDL_GetBooleanProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_SURFACE_ROLE_CUSTOM_BOOLEAN, false); + const bool create_egl_window = !!(window->flags & SDL_WINDOW_OPENGL) || + SDL_GetBooleanProperty(create_props, SDL_PROP_WINDOW_CREATE_WAYLAND_CREATE_EGL_WINDOW_BOOLEAN, false); + + data = SDL_calloc(1, sizeof(*data)); + if (!data) { + return false; + } + + window->internal = data; + + if (window->x == SDL_WINDOWPOS_UNDEFINED) { + window->x = 0; + } + if (window->y == SDL_WINDOWPOS_UNDEFINED) { + window->y = 0; + } + + data->waylandData = c; + data->sdlwindow = window; + + // Default to all capabilities + data->wm_caps = WAYLAND_WM_CAPS_ALL; + + data->scale_factor = 1.0; + + if (SDL_WINDOW_IS_POPUP(window)) { + data->scale_to_display = window->parent->internal->scale_to_display; + data->scale_factor = window->parent->internal->scale_factor; + EnsurePopupPositionIsValid(window, &window->x, &window->y); + } else { + for (int i = 0; i < _this->num_displays; i++) { + data->scale_factor = SDL_max(data->scale_factor, _this->displays[i]->internal->scale_factor); + } + } + + data->outputs = NULL; + data->num_outputs = 0; + data->scale_to_display = c->scale_to_display_enabled; + + // Cache the app_id at creation time, as it may change before the window is mapped. + data->app_id = SDL_strdup(SDL_GetAppID()); + + if (!data->scale_to_display) { + data->requested.logical_width = window->floating.w; + data->requested.logical_height = window->floating.h; + } else { + data->requested.logical_width = PixelToPoint(window, window->floating.w); + data->requested.logical_height = PixelToPoint(window, window->floating.h); + data->requested.pixel_width = window->floating.w; + data->requested.pixel_height = window->floating.h; + } + + if (!external_surface) { + data->surface = wl_compositor_create_surface(c->compositor); + wl_surface_add_listener(data->surface, &surface_listener, data); + wl_surface_set_user_data(data->surface, data); + SDL_WAYLAND_register_surface(data->surface); + } else { + window->flags |= SDL_WINDOW_EXTERNAL; + data->surface = external_surface; + + /* External surfaces are registered by being put in a list, as changing tags or userdata + * can cause problems with external toolkits. + */ + Wayland_AddWindowDataToExternalList(data); + } + + /* Always attach a viewport and fractional scale manager if available and the surface is not custom/external, + * or the custom/external surface was explicitly flagged as high pixel density aware, which signals that the + * application wants SDL to handle scaling. + */ + if (!custom_surface_role || (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY)) { + if (c->viewporter) { + data->viewport = wp_viewporter_get_viewport(c->viewporter, data->surface); + + // The viewport always uses the entire buffer. + wp_viewport_set_source(data->viewport, + wl_fixed_from_int(-1), wl_fixed_from_int(-1), + wl_fixed_from_int(-1), wl_fixed_from_int(-1)); + } + if (c->fractional_scale_manager) { + data->fractional_scale = wp_fractional_scale_manager_v1_get_fractional_scale(c->fractional_scale_manager, data->surface); + wp_fractional_scale_v1_add_listener(data->fractional_scale, &fractional_scale_listener, data); + } + } + + if (!custom_surface_role) { + if (c->wp_color_manager_v1) { + data->wp_color_management_surface_feedback = wp_color_manager_v1_get_surface_feedback(c->wp_color_manager_v1, data->surface); + wp_color_management_surface_feedback_v1_add_listener(data->wp_color_management_surface_feedback, &color_management_surface_feedback_listener, data); + Wayland_GetColorInfoForWindow(data, true); + } else if (c->frog_color_management_factory_v1) { + data->frog_color_managed_surface = frog_color_management_factory_v1_get_color_managed_surface(c->frog_color_management_factory_v1, data->surface); + frog_color_managed_surface_add_listener(data->frog_color_managed_surface, &frog_surface_listener, data); + } + + if (c->wp_alpha_modifier_v1) { + data->wp_alpha_modifier_surface_v1 = wp_alpha_modifier_v1_get_surface(c->wp_alpha_modifier_v1, data->surface); + wp_alpha_modifier_surface_v1_set_multiplier(data->wp_alpha_modifier_surface_v1, SDL_MAX_UINT32); + } + } + + // Must be called before EGL configuration to set the drawable backbuffer size. + ConfigureWindowGeometry(window); + + /* Fire a callback when the compositor wants a new frame rendered. + * Right now this only matters for OpenGL; we use this callback to add a + * wait timeout that avoids getting deadlocked by the compositor when the + * window isn't visible. + */ + if (window->flags & SDL_WINDOW_OPENGL) { + data->gles_swap_frame_event_queue = WAYLAND_wl_display_create_queue(data->waylandData->display); + data->gles_swap_frame_surface_wrapper = WAYLAND_wl_proxy_create_wrapper(data->surface); + WAYLAND_wl_proxy_set_queue((struct wl_proxy *)data->gles_swap_frame_surface_wrapper, data->gles_swap_frame_event_queue); + data->gles_swap_frame_callback = wl_surface_frame(data->gles_swap_frame_surface_wrapper); + wl_callback_add_listener(data->gles_swap_frame_callback, &gles_swap_frame_listener, data); + } + + // No frame callback on external surfaces as it may already have one attached. + if (!external_surface) { + // Fire a callback when the compositor wants a new frame to set the surface damage region. + data->surface_frame_callback = wl_surface_frame(data->surface); + wl_callback_add_listener(data->surface_frame_callback, &surface_frame_listener, data); + } + + if (window->flags & SDL_WINDOW_TRANSPARENT) { + if (_this->gl_config.alpha_size == 0) { + _this->gl_config.alpha_size = 8; + } + } + + if (create_egl_window) { + data->egl_window = WAYLAND_wl_egl_window_create(data->surface, data->current.pixel_width, data->current.pixel_height); + } + +#ifdef SDL_VIDEO_OPENGL_EGL + if (window->flags & SDL_WINDOW_OPENGL) { + // Create the GLES window surface + data->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)data->egl_window); + + if (data->egl_surface == EGL_NO_SURFACE) { + return false; // SDL_EGL_CreateSurface should have set error + } + } +#endif + + if (c->relative_mouse_mode) { + Wayland_input_enable_relative_pointer(c->input); + } + + // We may need to create an idle inhibitor for this new window + Wayland_SuspendScreenSaver(_this); + + if (!custom_surface_role) { +#ifdef HAVE_LIBDECOR_H + if (c->shell.libdecor && !SDL_WINDOW_IS_POPUP(window)) { + data->shell_surface_type = WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR; + } else +#endif + if (c->shell.xdg) { + if (SDL_WINDOW_IS_POPUP(window)) { + data->shell_surface_type = WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP; + } else { + data->shell_surface_type = WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL; + } + } // All other cases will be WAYLAND_SURFACE_UNKNOWN + } else { + // Roleless and external surfaces are always considered to be in the shown state by the backend. + data->shell_surface_type = WAYLAND_SHELL_SURFACE_TYPE_CUSTOM; + data->shell_surface_status = WAYLAND_SHELL_SURFACE_STATUS_SHOWN; + } + + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_DOUBLE_BUFFER, false)) { + data->double_buffer = true; + } + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_DISPLAY_POINTER, data->waylandData->display); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_SURFACE_POINTER, data->surface); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_VIEWPORT_POINTER, data->viewport); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WAYLAND_EGL_WINDOW_POINTER, data->egl_window); + + data->hit_test_result = SDL_HITTEST_NORMAL; + + return true; +} + +void Wayland_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + // Will be committed when Wayland_SetWindowSize() is called by the video core. + SetMinMaxDimensions(window); +} + +void Wayland_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + // Will be committed when Wayland_SetWindowSize() is called by the video core. + SetMinMaxDimensions(window); +} + +bool Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + + // Only popup windows can be positioned relative to the parent. + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP) { + if (wind->shell_surface.xdg.popup.xdg_popup && + xdg_popup_get_version(wind->shell_surface.xdg.popup.xdg_popup) < XDG_POPUP_REPOSITION_SINCE_VERSION) { + return SDL_Unsupported(); + } + + RepositionPopup(window, false); + return true; + } else if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR || wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + /* Catch up on any pending state before attempting to change the fullscreen window + * display via a set fullscreen call to make sure the window doesn't have a pending + * leave fullscreen event that it might override. + */ + FlushPendingEvents(window); + + if (wind->is_fullscreen) { + SDL_VideoDisplay *display = SDL_GetVideoDisplayForFullscreenWindow(window); + if (display && wind->last_displayID != display->id) { + struct wl_output *output = display->internal->output; + SetFullscreen(window, output); + + return true; + } + } + } + return SDL_SetError("wayland cannot position non-popup windows"); +} + +void Wayland_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + + /* Flush any pending state operations, as fullscreen windows do not get + * explicitly resized, not strictly obeying the size of a maximized window + * is a protocol violation, and pending restore events might result in a + * configure event overwriting the requested size. + * + * Calling this on a custom surface is informative, so the size must + * always be passed through. + */ + FlushPendingEvents(window); + + // Maximized and fullscreen windows don't get resized. + if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED)) || + wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_CUSTOM) { + if (!wind->scale_to_display) { + wind->requested.logical_width = window->pending.w; + wind->requested.logical_height = window->pending.h; + } else { + wind->requested.logical_width = PixelToPoint(window, window->pending.w); + wind->requested.logical_height = PixelToPoint(window, window->pending.h); + wind->requested.pixel_width = window->pending.w; + wind->requested.pixel_height = window->pending.h; + } + + ConfigureWindowGeometry(window); + } else { + // Can't resize the window. + window->last_size_pending = false; + } + + // Always commit, as this may be in response to a min/max limit change. + CommitLibdecorFrame(window); +} + +void Wayland_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) +{ + SDL_WindowData *data = window->internal; + + *w = data->current.pixel_width; + *h = data->current.pixel_height; +} + +float Wayland_GetWindowContentScale(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + + if (window->flags & SDL_WINDOW_HIGH_PIXEL_DENSITY || wind->scale_to_display || wind->fullscreen_exclusive) { + return (float)wind->scale_factor; + } + + return 1.0f; +} + +SDL_DisplayID Wayland_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + + if (wind) { + return wind->last_displayID; + } + + return 0; +} + +bool Wayland_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity) +{ + SDL_WindowData *wind = window->internal; + + if (wind->wp_alpha_modifier_surface_v1) { + SetSurfaceOpaqueRegion(wind, !(window->flags & SDL_WINDOW_TRANSPARENT) && opacity == 1.0f); + wp_alpha_modifier_surface_v1_set_multiplier(wind->wp_alpha_modifier_surface_v1, (Uint32)((double)SDL_MAX_UINT32 * (double)opacity)); + + return true; + } + + return SDL_SetError("wayland: set window opacity failed; compositor lacks support for the required wp_alpha_modifier_v1 protocol"); +} + +void Wayland_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + const char *title = window->title ? window->title : ""; + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR && wind->shell_surface.libdecor.frame) { + libdecor_frame_set_title(wind->shell_surface.libdecor.frame, title); + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL && wind->shell_surface.xdg.toplevel.xdg_toplevel) { + xdg_toplevel_set_title(wind->shell_surface.xdg.toplevel.xdg_toplevel, title); + } +} + +bool Wayland_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon) +{ + SDL_WindowData *wind = window->internal; + struct xdg_toplevel *toplevel = NULL; + + if (!_this->internal->xdg_toplevel_icon_manager_v1) { + return SDL_SetError("wayland: cannot set icon; required xdg_toplevel_icon_v1 protocol not supported"); + } + + if (icon->w != icon->h) { + return SDL_SetError("wayland: icon width and height must be equal, got %ix%i", icon->w, icon->h); + } + + int image_count = 0; + SDL_Surface **images = SDL_GetSurfaceImages(icon, &image_count); + if (!images || !image_count) { + return false; + } + + // Release the old icon resources. + if (wind->xdg_toplevel_icon_v1) { + xdg_toplevel_icon_v1_destroy(wind->xdg_toplevel_icon_v1); + wind->xdg_toplevel_icon_v1 = NULL; + } + + for (int i = 0; i < wind->icon_buffer_count; ++i) { + Wayland_ReleaseSHMBuffer(&wind->icon_buffers[i]); + } + SDL_free(wind->icon_buffers); + wind->icon_buffer_count = 0; + + wind->xdg_toplevel_icon_v1 = xdg_toplevel_icon_manager_v1_create_icon(_this->internal->xdg_toplevel_icon_manager_v1); + wind->icon_buffers = SDL_calloc(image_count, sizeof(struct Wayland_SHMBuffer)); + if (!wind->icon_buffers) { + goto failure_cleanup; + } + + for (int i = 0; i < image_count; ++i) { + if (images[i]->w == images[i]->h) { + struct Wayland_SHMBuffer *buffer = &wind->icon_buffers[wind->icon_buffer_count]; + + if (!Wayland_AllocSHMBuffer(images[i]->w, images[i]->h, buffer)) { + SDL_SetError("wayland: failed to allocate SHM buffer for the icon"); + goto failure_cleanup; + } + + SDL_PremultiplyAlpha(images[i]->w, images[i]->h, images[i]->format, images[i]->pixels, images[i]->pitch, SDL_PIXELFORMAT_ARGB8888, buffer->shm_data, images[i]->w * 4, true); + const int scale = (int)SDL_ceil((double)images[i]->w / (double)icon->w); + xdg_toplevel_icon_v1_add_buffer(wind->xdg_toplevel_icon_v1, buffer->wl_buffer, scale); + wind->icon_buffer_count++; + } else { + SDL_LogWarn(SDL_LOG_CATEGORY_VIDEO, "wayland: icon width and height must be equal, got %ix%i for image level %i; skipping", images[i]->w, images[i]->h, i); + } + } + + SDL_free(images); + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR && wind->shell_surface.libdecor.frame) { + toplevel = libdecor_frame_get_xdg_toplevel(wind->shell_surface.libdecor.frame); + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL && wind->shell_surface.xdg.toplevel.xdg_toplevel) { + toplevel = wind->shell_surface.xdg.toplevel.xdg_toplevel; + } + + if (toplevel) { + xdg_toplevel_icon_manager_v1_set_icon(_this->internal->xdg_toplevel_icon_manager_v1, toplevel, wind->xdg_toplevel_icon_v1); + } + + return true; + +failure_cleanup: + + if (wind->xdg_toplevel_icon_v1) { + xdg_toplevel_icon_v1_destroy(wind->xdg_toplevel_icon_v1); + wind->xdg_toplevel_icon_v1 = NULL; + } + + for (int i = 0; i < wind->icon_buffer_count; ++i) { + Wayland_ReleaseSHMBuffer(&wind->icon_buffers[i]); + } + SDL_free(wind->icon_buffers); + wind->icon_buffers = NULL; + wind->icon_buffer_count = 0; + + return false; +} + +void *Wayland_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size) +{ + SDL_WindowData *wind = window->internal; + void *ret = NULL; + + if (wind->icc_size > 0) { + void *icc_map = mmap(NULL, wind->icc_size, PROT_READ, MAP_PRIVATE, wind->icc_fd, 0); + if (icc_map != MAP_FAILED) { + ret = SDL_malloc(wind->icc_size); + if (ret) { + *size = wind->icc_size; + SDL_memcpy(ret, icc_map, *size); + } + munmap(icc_map, wind->icc_size); + } + } + + return ret; +} + +bool Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *wind = window->internal; + + do { + WAYLAND_wl_display_roundtrip(_this->internal->display); + } while (wind->fullscreen_deadline_count || wind->maximized_restored_deadline_count); + + return true; +} + +void Wayland_ShowWindowSystemMenu(SDL_Window *window, int x, int y) +{ + SDL_WindowData *wind = window->internal; + + if (wind->scale_to_display) { + x = PixelToPoint(window, x); + y = PixelToPoint(window, y); + } + +#ifdef HAVE_LIBDECOR_H + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR) { + if (wind->shell_surface.libdecor.frame) { + libdecor_frame_show_window_menu(wind->shell_surface.libdecor.frame, wind->waylandData->input->seat, wind->waylandData->input->last_implicit_grab_serial, x, y); + } + } else +#endif + if (wind->shell_surface_type == WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL) { + if (wind->shell_surface.xdg.toplevel.xdg_toplevel) { + xdg_toplevel_show_window_menu(wind->shell_surface.xdg.toplevel.xdg_toplevel, wind->waylandData->input->seat, wind->waylandData->input->last_implicit_grab_serial, x, y); + } + } +} + +bool Wayland_SuspendScreenSaver(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + +#ifdef SDL_USE_LIBDBUS + if (SDL_DBus_ScreensaverInhibit(_this->suspend_screensaver)) { + return true; + } +#endif + + /* The idle_inhibit_unstable_v1 protocol suspends the screensaver + on a per wl_surface basis, but SDL assumes that suspending + the screensaver can be done independently of any window. + + To reconcile these differences, we propagate the idle inhibit + state to each window. If there is no window active, we will + be able to inhibit idle once the first window is created. + */ + if (data->idle_inhibit_manager) { + SDL_Window *window = _this->windows; + while (window) { + SDL_WindowData *win_data = window->internal; + + if (_this->suspend_screensaver && !win_data->idle_inhibitor) { + win_data->idle_inhibitor = + zwp_idle_inhibit_manager_v1_create_inhibitor(data->idle_inhibit_manager, + win_data->surface); + } else if (!_this->suspend_screensaver && win_data->idle_inhibitor) { + zwp_idle_inhibitor_v1_destroy(win_data->idle_inhibitor); + win_data->idle_inhibitor = NULL; + } + + window = window->next; + } + } + + return true; +} + +void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *data = _this->internal; + SDL_WindowData *wind = window->internal; + + if (data && wind) { + /* Roundtrip before destroying the window to make sure that it has received input leave events, so that + * no internal structures are left pointing to the destroyed window. + */ + if (wind->show_hide_sync_required) { + WAYLAND_wl_display_roundtrip(data->display); + } + +#ifdef SDL_VIDEO_OPENGL_EGL + if (wind->egl_surface) { + SDL_EGL_DestroySurface(_this, wind->egl_surface); + } +#endif + if (wind->egl_window) { + WAYLAND_wl_egl_window_destroy(wind->egl_window); + } + + if (wind->idle_inhibitor) { + zwp_idle_inhibitor_v1_destroy(wind->idle_inhibitor); + } + + if (wind->activation_token) { + xdg_activation_token_v1_destroy(wind->activation_token); + } + + if (wind->viewport) { + wp_viewport_destroy(wind->viewport); + } + + if (wind->fractional_scale) { + wp_fractional_scale_v1_destroy(wind->fractional_scale); + } + + if (wind->wp_alpha_modifier_surface_v1) { + wp_alpha_modifier_surface_v1_destroy(wind->wp_alpha_modifier_surface_v1); + } + + if (wind->frog_color_managed_surface) { + frog_color_managed_surface_destroy(wind->frog_color_managed_surface); + } + + if (wind->wp_color_management_surface_feedback) { + Wayland_FreeColorInfoState(wind->color_info_state); + wp_color_management_surface_feedback_v1_destroy(wind->wp_color_management_surface_feedback); + } + + SDL_free(wind->outputs); + SDL_free(wind->app_id); + + if (wind->gles_swap_frame_callback) { + wl_callback_destroy(wind->gles_swap_frame_callback); + WAYLAND_wl_proxy_wrapper_destroy(wind->gles_swap_frame_surface_wrapper); + WAYLAND_wl_event_queue_destroy(wind->gles_swap_frame_event_queue); + } + + if (wind->surface_frame_callback) { + wl_callback_destroy(wind->surface_frame_callback); + } + + if (!(window->flags & SDL_WINDOW_EXTERNAL)) { + wl_surface_destroy(wind->surface); + } else { + Wayland_RemoveWindowDataFromExternalList(wind); + } + + if (wind->xdg_toplevel_icon_v1) { + xdg_toplevel_icon_v1_destroy(wind->xdg_toplevel_icon_v1); + } + + for (int i = 0; i < wind->icon_buffer_count; ++i) { + Wayland_ReleaseSHMBuffer(&wind->icon_buffers[i]); + } + SDL_free(wind->icon_buffers); + wind->icon_buffer_count = 0; + + SDL_free(wind); + WAYLAND_wl_display_flush(data->display); + } + window->internal = NULL; +} + +#endif // SDL_VIDEO_DRIVER_WAYLAND diff --git a/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.h b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.h new file mode 100644 index 0000000..619fd79 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/wayland/SDL_waylandwindow.h @@ -0,0 +1,248 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_waylandwindow_h_ +#define SDL_waylandwindow_h_ + +#include "../SDL_sysvideo.h" +#include "../../events/SDL_touch_c.h" + +#include "SDL_waylandvideo.h" +#include "SDL_waylandshmbuffer.h" + +struct SDL_WaylandInput; + +struct SDL_WindowData +{ + SDL_Window *sdlwindow; + SDL_VideoData *waylandData; + struct wl_surface *surface; + struct wl_callback *gles_swap_frame_callback; + struct wl_event_queue *gles_swap_frame_event_queue; + struct wl_surface *gles_swap_frame_surface_wrapper; + struct wl_callback *surface_frame_callback; + + union + { +#ifdef HAVE_LIBDECOR_H + struct + { + struct libdecor_frame *frame; + bool initial_configure_seen; + } libdecor; +#endif + struct + { + struct xdg_surface *surface; + union + { + struct + { + struct xdg_toplevel *xdg_toplevel; + } toplevel; + struct + { + struct xdg_popup *xdg_popup; + struct xdg_positioner *xdg_positioner; + } popup; + }; + bool initial_configure_seen; + } xdg; + } shell_surface; + enum + { + WAYLAND_SHELL_SURFACE_TYPE_UNKNOWN = 0, + WAYLAND_SHELL_SURFACE_TYPE_XDG_TOPLEVEL, + WAYLAND_SHELL_SURFACE_TYPE_XDG_POPUP, + WAYLAND_SHELL_SURFACE_TYPE_LIBDECOR, + WAYLAND_SHELL_SURFACE_TYPE_CUSTOM + } shell_surface_type; + enum + { + WAYLAND_SHELL_SURFACE_STATUS_HIDDEN = 0, + WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_CONFIGURE, + WAYLAND_SHELL_SURFACE_STATUS_WAITING_FOR_FRAME, + WAYLAND_SHELL_SURFACE_STATUS_SHOW_PENDING, + WAYLAND_SHELL_SURFACE_STATUS_SHOWN + } shell_surface_status; + enum + { + WAYLAND_WM_CAPS_WINDOW_MENU = 0x01, + WAYLAND_WM_CAPS_MAXIMIZE = 0x02, + WAYLAND_WM_CAPS_FULLSCREEN = 0x04, + WAYLAND_WM_CAPS_MINIMIZE = 0x08, + + WAYLAND_WM_CAPS_ALL = WAYLAND_WM_CAPS_WINDOW_MENU | + WAYLAND_WM_CAPS_MAXIMIZE | + WAYLAND_WM_CAPS_FULLSCREEN | + WAYLAND_WM_CAPS_MINIMIZE + } wm_caps; + + struct wl_egl_window *egl_window; + struct SDL_WaylandInput *keyboard_device; +#ifdef SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif + struct zwp_locked_pointer_v1 *locked_pointer; + struct zwp_confined_pointer_v1 *confined_pointer; + struct zxdg_toplevel_decoration_v1 *server_decoration; + struct zwp_keyboard_shortcuts_inhibitor_v1 *key_inhibitor; + struct zwp_idle_inhibitor_v1 *idle_inhibitor; + struct xdg_activation_token_v1 *activation_token; + struct wp_viewport *viewport; + struct wp_fractional_scale_v1 *fractional_scale; + struct zxdg_exported_v2 *exported; + struct xdg_dialog_v1 *xdg_dialog_v1; + struct wp_alpha_modifier_surface_v1 *wp_alpha_modifier_surface_v1; + struct xdg_toplevel_icon_v1 *xdg_toplevel_icon_v1; + struct frog_color_managed_surface *frog_color_managed_surface; + struct wp_color_management_surface_feedback_v1 *wp_color_management_surface_feedback; + + struct Wayland_ColorInfoState *color_info_state; + + SDL_AtomicInt swap_interval_ready; + + SDL_DisplayData **outputs; + int num_outputs; + + SDL_Window *keyboard_focus; + + char *app_id; + double scale_factor; + + struct Wayland_SHMBuffer *icon_buffers; + int icon_buffer_count; + + struct + { + double x; + double y; + } pointer_scale; + + // The in-flight window size request. + struct + { + // The requested logical window size. + int logical_width; + int logical_height; + + // The size of the window in pixels, when using screen space scaling. + int pixel_width; + int pixel_height; + } requested; + + // The current size of the window and drawable backing store. + struct + { + // The size of the underlying window. + int logical_width; + int logical_height; + + // The size of the window backbuffer in pixels. + int pixel_width; + int pixel_height; + } current; + + // The last compositor requested parameters; used for deduplication of window geometry configuration. + struct + { + int width; + int height; + } last_configure; + + // System enforced window size limits. + struct + { + // Minimum allowed logical window size. + int min_width; + int min_height; + } system_limits; + + struct + { + int width; + int height; + } toplevel_bounds; + + SDL_DisplayID last_displayID; + int fullscreen_deadline_count; + int maximized_restored_deadline_count; + Uint64 last_focus_event_time_ns; + int icc_fd; + Uint32 icc_size; + bool floating; + bool suspended; + bool resizing; + bool active; + bool drop_interactive_resizes; + bool is_fullscreen; + bool fullscreen_exclusive; + bool drop_fullscreen_requests; + bool fullscreen_was_positioned; + bool show_hide_sync_required; + bool scale_to_display; + bool reparenting_required; + bool double_buffer; + + SDL_HitTestResult hit_test_result; + + struct wl_list external_window_list_link; +}; + +extern void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_FullscreenResult Wayland_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *_display, SDL_FullscreenOp fullscreen); +extern void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern bool Wayland_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern bool Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern bool Wayland_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h); +extern SDL_DisplayID Wayland_GetDisplayForWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent_window); +extern bool Wayland_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); +extern bool Wayland_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity); +extern void Wayland_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern void Wayland_ShowWindowSystemMenu(SDL_Window *window, int x, int y); +extern void Wayland_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool Wayland_SuspendScreenSaver(SDL_VideoDevice *_this); +extern bool Wayland_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); +extern float Wayland_GetWindowContentScale(SDL_VideoDevice *_this, SDL_Window *window); +extern void *Wayland_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); + +extern bool Wayland_SetWindowHitTest(SDL_Window *window, bool enabled); +extern bool Wayland_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); +extern bool Wayland_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); + +extern void Wayland_RemoveOutputFromWindow(SDL_WindowData *window, SDL_DisplayData *display_data); + +#endif // SDL_waylandwindow_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_msctf.h b/contrib/SDL-3.2.8/src/video/windows/SDL_msctf.h new file mode 100644 index 0000000..0c9ed01 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_msctf.h @@ -0,0 +1,246 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_msctf_h_ +#define SDL_msctf_h_ + +#include + +#define TF_INVALID_COOKIE (0xffffffff) +#define TF_IPSINK_FLAG_ACTIVE 0x0001 +#define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004 + +/* *INDENT-OFF* */ // clang-format off + +typedef struct ITfThreadMgr ITfThreadMgr; +typedef struct ITfDocumentMgr ITfDocumentMgr; +typedef struct ITfClientId ITfClientId; + +typedef struct IEnumTfDocumentMgrs IEnumTfDocumentMgrs; +typedef struct IEnumTfFunctionProviders IEnumTfFunctionProviders; +typedef struct ITfFunctionProvider ITfFunctionProvider; +typedef struct ITfCompartmentMgr ITfCompartmentMgr; +typedef struct ITfContext ITfContext; +typedef struct IEnumTfContexts IEnumTfContexts; +typedef struct ITfUIElementSink ITfUIElementSink; +typedef struct ITfUIElement ITfUIElement; +typedef struct ITfUIElementMgr ITfUIElementMgr; +typedef struct IEnumTfUIElements IEnumTfUIElements; +typedef struct ITfThreadMgrEx ITfThreadMgrEx; +typedef struct ITfCandidateListUIElement ITfCandidateListUIElement; +typedef struct ITfReadingInformationUIElement ITfReadingInformationUIElement; +typedef struct ITfInputProcessorProfileActivationSink ITfInputProcessorProfileActivationSink; +typedef struct ITfSource ITfSource; + +typedef DWORD TfClientId; +typedef DWORD TfEditCookie; + +typedef struct ITfThreadMgrVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgr *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgr *); + ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgr *); + HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgr *, TfClientId *); + HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgr *); + HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgr *); + HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgr *, IEnumTfDocumentMgrs **); + HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgr *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgr *, ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgr *, HWND, ITfDocumentMgr *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgr *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgr *, REFCLSID, ITfFunctionProvider **); + HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgr *, IEnumTfFunctionProviders **); + HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgr *, ITfCompartmentMgr **); +} ITfThreadMgrVtbl; + +struct ITfThreadMgr +{ + const struct ITfThreadMgrVtbl *lpVtbl; +}; + +typedef struct ITfThreadMgrExVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgrEx *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgrEx *); + ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgrEx *); + HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgrEx *, TfClientId *); + HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgrEx *); + HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgrEx *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgrEx *, IEnumTfDocumentMgrs **); + HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgrEx *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgrEx *, ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgrEx *, ITfDocumentMgr *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgrEx *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgrEx *, REFCLSID, ITfFunctionProvider **); + HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgrEx *, IEnumTfFunctionProviders **); + HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgrEx *, ITfCompartmentMgr **); + HRESULT (STDMETHODCALLTYPE *ActivateEx)(ITfThreadMgrEx *, TfClientId *, DWORD); + HRESULT (STDMETHODCALLTYPE *GetActiveFlags)(ITfThreadMgrEx *, DWORD *); +} ITfThreadMgrExVtbl; + +struct ITfThreadMgrEx +{ + const struct ITfThreadMgrExVtbl *lpVtbl; +}; + +typedef struct ITfDocumentMgrVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfDocumentMgr *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfDocumentMgr *); + ULONG (STDMETHODCALLTYPE *Release)(ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *CreateContext)(ITfDocumentMgr *, TfClientId, DWORD, IUnknown *, ITfContext **, TfEditCookie *); + HRESULT (STDMETHODCALLTYPE *Push)(ITfDocumentMgr *, ITfContext *); + HRESULT (STDMETHODCALLTYPE *Pop)(ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *GetTop)(ITfDocumentMgr *, ITfContext **); + HRESULT (STDMETHODCALLTYPE *GetBase)(ITfDocumentMgr *, ITfContext **); + HRESULT (STDMETHODCALLTYPE *EnumContexts)(ITfDocumentMgr *, IEnumTfContexts **); +} ITfDocumentMgrVtbl; + +struct ITfDocumentMgr +{ + const struct ITfDocumentMgrVtbl *lpVtbl; +}; + +typedef struct ITfUIElementSinkVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementSink *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementSink *); + ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementSink *); + HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementSink *, DWORD, BOOL *); + HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementSink *, DWORD); + HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementSink *, DWORD); +} ITfUIElementSinkVtbl; + +struct ITfUIElementSink +{ + const struct ITfUIElementSinkVtbl *lpVtbl; +}; + +typedef struct ITfUIElementMgrVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementMgr *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementMgr *); + ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementMgr *); + HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementMgr *, ITfUIElement *, BOOL *, DWORD *); + HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementMgr *, DWORD); + HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementMgr *, DWORD); + HRESULT (STDMETHODCALLTYPE *GetUIElement)(ITfUIElementMgr *, DWORD, ITfUIElement **); + HRESULT (STDMETHODCALLTYPE *EnumUIElements)(ITfUIElementMgr *, IEnumTfUIElements **); +} ITfUIElementMgrVtbl; + +struct ITfUIElementMgr +{ + const struct ITfUIElementMgrVtbl *lpVtbl; +}; + +typedef struct ITfCandidateListUIElementVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfCandidateListUIElement *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfCandidateListUIElement *); + ULONG (STDMETHODCALLTYPE *Release)(ITfCandidateListUIElement *); + HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfCandidateListUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfCandidateListUIElement *, GUID *); + HRESULT (STDMETHODCALLTYPE *Show)(ITfCandidateListUIElement *, BOOL); + HRESULT (STDMETHODCALLTYPE *IsShown)(ITfCandidateListUIElement *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfCandidateListUIElement *, DWORD *); + HRESULT (STDMETHODCALLTYPE *GetDocumentMgr)(ITfCandidateListUIElement *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *GetCount)(ITfCandidateListUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *GetSelection)(ITfCandidateListUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *GetString)(ITfCandidateListUIElement *, UINT, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT, UINT *); + HRESULT (STDMETHODCALLTYPE *SetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT); + HRESULT (STDMETHODCALLTYPE *GetCurrentPage)(ITfCandidateListUIElement *, UINT *); +} ITfCandidateListUIElementVtbl; + +struct ITfCandidateListUIElement +{ + const struct ITfCandidateListUIElementVtbl *lpVtbl; +}; + +typedef struct ITfReadingInformationUIElementVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfReadingInformationUIElement *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfReadingInformationUIElement *); + ULONG (STDMETHODCALLTYPE *Release)(ITfReadingInformationUIElement *); + HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfReadingInformationUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfReadingInformationUIElement *, GUID *); + HRESULT (STDMETHODCALLTYPE *Show)(ITfReadingInformationUIElement *, BOOL); + HRESULT (STDMETHODCALLTYPE *IsShown)(ITfReadingInformationUIElement *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfReadingInformationUIElement *, DWORD *); + HRESULT (STDMETHODCALLTYPE *GetContext)(ITfReadingInformationUIElement *, ITfContext **); + HRESULT (STDMETHODCALLTYPE *GetString)(ITfReadingInformationUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetMaxReadingStringLength)(ITfReadingInformationUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *GetErrorIndex)(ITfReadingInformationUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *IsVerticalOrderPreferred)(ITfReadingInformationUIElement *, BOOL *); +} ITfReadingInformationUIElementVtbl; + +struct ITfReadingInformationUIElement +{ + const struct ITfReadingInformationUIElementVtbl *lpVtbl; +}; + +typedef struct ITfUIElementVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElement *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElement *); + ULONG (STDMETHODCALLTYPE *Release)(ITfUIElement *); + HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfUIElement *, GUID *); + HRESULT (STDMETHODCALLTYPE *Show)(ITfUIElement *, BOOL); + HRESULT (STDMETHODCALLTYPE *IsShown)(ITfUIElement *, BOOL *); +} ITfUIElementVtbl; + +struct ITfUIElement +{ + const struct ITfUIElementVtbl *lpVtbl; +}; + +typedef struct ITfInputProcessorProfileActivationSinkVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfInputProcessorProfileActivationSink *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfInputProcessorProfileActivationSink *); + ULONG (STDMETHODCALLTYPE *Release)(ITfInputProcessorProfileActivationSink *); + HRESULT (STDMETHODCALLTYPE *OnActivated)(ITfInputProcessorProfileActivationSink *, DWORD, LANGID, REFCLSID, REFGUID, REFGUID, HKL, DWORD); + +} ITfInputProcessorProfileActivationSinkVtbl; + +struct ITfInputProcessorProfileActivationSink +{ + const struct ITfInputProcessorProfileActivationSinkVtbl *lpVtbl; +}; + +typedef struct ITfSourceVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfSource *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfSource *); + ULONG (STDMETHODCALLTYPE *Release)(ITfSource *); + HRESULT (STDMETHODCALLTYPE *AdviseSink)(ITfSource *, REFIID, IUnknown *, DWORD *); + HRESULT (STDMETHODCALLTYPE *UnadviseSink)(ITfSource *, DWORD); +} ITfSourceVtbl; + +struct ITfSource +{ + const struct ITfSourceVtbl *lpVtbl; +}; + +/* *INDENT-ON* */ // clang-format on + +#endif // SDL_msctf_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.c b/contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.c new file mode 100644 index 0000000..7f9245c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.c @@ -0,0 +1,97 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_surface_utils.h" + +#include "../SDL_surface_c.h" + +#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) +HICON CreateIconFromSurface(SDL_Surface *surface) +{ + SDL_Surface *s = SDL_ConvertSurface(surface, SDL_PIXELFORMAT_ARGB8888); + if (!s) { + return NULL; + } + + /* The dimensions will be needed after s is freed */ + const int width = s->w; + const int height = s->h; + + BITMAPINFO bmpInfo; + SDL_zero(bmpInfo); + bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmpInfo.bmiHeader.biWidth = width; + bmpInfo.bmiHeader.biHeight = -height; /* Top-down bitmap */ + bmpInfo.bmiHeader.biPlanes = 1; + bmpInfo.bmiHeader.biBitCount = 32; + bmpInfo.bmiHeader.biCompression = BI_RGB; + + HDC hdc = GetDC(NULL); + void* pBits = NULL; + HBITMAP hBitmap = CreateDIBSection(hdc, &bmpInfo, DIB_RGB_COLORS, &pBits, NULL, 0); + if (!hBitmap) { + ReleaseDC(NULL, hdc); + SDL_DestroySurface(s); + return NULL; + } + + SDL_memcpy(pBits, s->pixels, width * height * 4); + + SDL_DestroySurface(s); + + HBITMAP hMask = CreateBitmap(width, height, 1, 1, NULL); + if (!hMask) { + DeleteObject(hBitmap); + ReleaseDC(NULL, hdc); + return NULL; + } + + HDC hdcMem = CreateCompatibleDC(hdc); + HGDIOBJ oldBitmap = SelectObject(hdcMem, hMask); + + for (int y = 0; y < height; y++) { + for (int x = 0; x < width; x++) { + BYTE* pixel = (BYTE*)pBits + (y * width + x) * 4; + BYTE alpha = pixel[3]; + COLORREF maskColor = (alpha == 0) ? RGB(0, 0, 0) : RGB(255, 255, 255); + SetPixel(hdcMem, x, y, maskColor); + } + } + + ICONINFO iconInfo; + iconInfo.fIcon = TRUE; + iconInfo.xHotspot = 0; + iconInfo.yHotspot = 0; + iconInfo.hbmMask = hMask; + iconInfo.hbmColor = hBitmap; + + HICON hIcon = CreateIconIndirect(&iconInfo); + + SelectObject(hdcMem, oldBitmap); + DeleteDC(hdcMem); + DeleteObject(hBitmap); + DeleteObject(hMask); + ReleaseDC(NULL, hdc); + + return hIcon; +} +#endif diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.h b/contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.h new file mode 100644 index 0000000..a793cdc --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_surface_utils.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_surface_utils_h_ +#define SDL_surface_utils_h_ + +#include "../../core/windows/SDL_windows.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern HICON CreateIconFromSurface(SDL_Surface *surface); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.c new file mode 100644 index 0000000..39f86ef --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.c @@ -0,0 +1,442 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsvideo.h" +#include "SDL_windowswindow.h" +#include "../SDL_clipboard_c.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_clipboardevents_c.h" + +#ifdef UNICODE +#define TEXT_FORMAT CF_UNICODETEXT +#else +#define TEXT_FORMAT CF_TEXT +#endif + +#define IMAGE_FORMAT CF_DIB +#define IMAGE_MIME_TYPE "image/bmp" +#define BFT_BITMAP 0x4d42 // 'BM' + +// Assume we can directly read and write BMP fields without byte swapping +SDL_COMPILE_TIME_ASSERT(verify_byte_order, SDL_BYTEORDER == SDL_LIL_ENDIAN); + +static BOOL WIN_OpenClipboard(SDL_VideoDevice *_this) +{ + // Retry to open the clipboard in case another application has it open + const int MAX_ATTEMPTS = 3; + int attempt; + HWND hwnd = NULL; + + if (_this->windows) { + hwnd = _this->windows->internal->hwnd; + } + for (attempt = 0; attempt < MAX_ATTEMPTS; ++attempt) { + if (OpenClipboard(hwnd)) { + return TRUE; + } + SDL_Delay(10); + } + return FALSE; +} + +static void WIN_CloseClipboard(void) +{ + CloseClipboard(); +} + +static HANDLE WIN_ConvertBMPtoDIB(const void *bmp, size_t bmp_size) +{ + HANDLE hMem = NULL; + + if (bmp && bmp_size > sizeof(BITMAPFILEHEADER) && ((BITMAPFILEHEADER *)bmp)->bfType == BFT_BITMAP) { + BITMAPFILEHEADER *pbfh = (BITMAPFILEHEADER *)bmp; + BITMAPINFOHEADER *pbih = (BITMAPINFOHEADER *)((Uint8 *)bmp + sizeof(BITMAPFILEHEADER)); + size_t bih_size = pbih->biSize + pbih->biClrUsed * sizeof(RGBQUAD); + size_t pixels_size = pbih->biSizeImage; + + if (pbfh->bfOffBits >= (sizeof(BITMAPFILEHEADER) + bih_size) && + (pbfh->bfOffBits + pixels_size) <= bmp_size) { + const Uint8 *pixels = (const Uint8 *)bmp + pbfh->bfOffBits; + size_t dib_size = bih_size + pixels_size; + hMem = GlobalAlloc(GMEM_MOVEABLE, dib_size); + if (hMem) { + LPVOID dst = GlobalLock(hMem); + if (dst) { + SDL_memcpy(dst, pbih, bih_size); + SDL_memcpy((Uint8 *)dst + bih_size, pixels, pixels_size); + GlobalUnlock(hMem); + } else { + WIN_SetError("GlobalLock()"); + GlobalFree(hMem); + hMem = NULL; + } + } else { + SDL_OutOfMemory(); + } + } else { + SDL_SetError("Invalid BMP data"); + } + } else { + SDL_SetError("Invalid BMP data"); + } + return hMem; +} + +static void *WIN_ConvertDIBtoBMP(HANDLE hMem, size_t *size) +{ + void *bmp = NULL; + size_t mem_size = GlobalSize(hMem); + + if (mem_size > sizeof(BITMAPINFOHEADER)) { + LPVOID dib = GlobalLock(hMem); + if (dib) { + BITMAPINFOHEADER *pbih = (BITMAPINFOHEADER *)dib; + + // https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapinfoheader#color-tables + size_t color_table_size; + switch (pbih->biCompression) { + case BI_RGB: + if (pbih->biBitCount <= 8) { + color_table_size = sizeof(RGBQUAD) * (pbih->biClrUsed == 0 ? 1 << pbih->biBitCount : pbih->biClrUsed); + } else { + color_table_size = 0; + } + break; + case BI_BITFIELDS: + color_table_size = 3 * sizeof(DWORD); + break; + case 6 /* BI_ALPHABITFIELDS */: + // https://learn.microsoft.com/en-us/previous-versions/windows/embedded/aa452885(v=msdn.10) + color_table_size = 4 * sizeof(DWORD); + break; + default: // FOURCC + color_table_size = sizeof(RGBQUAD) * pbih->biClrUsed; + } + + size_t bih_size = pbih->biSize + color_table_size; + size_t dib_size = bih_size + pbih->biSizeImage; + if (dib_size <= mem_size) { + size_t bmp_size = sizeof(BITMAPFILEHEADER) + mem_size; + bmp = SDL_malloc(bmp_size); + if (bmp) { + BITMAPFILEHEADER *pbfh = (BITMAPFILEHEADER *)bmp; + pbfh->bfType = BFT_BITMAP; + pbfh->bfSize = (DWORD)bmp_size; + pbfh->bfReserved1 = 0; + pbfh->bfReserved2 = 0; + pbfh->bfOffBits = (DWORD)(sizeof(BITMAPFILEHEADER) + pbih->biSize + color_table_size); + SDL_memcpy((Uint8 *)bmp + sizeof(BITMAPFILEHEADER), dib, dib_size); + *size = bmp_size; + } + } else { + SDL_SetError("Invalid BMP data"); + } + GlobalUnlock(hMem); + } else { + WIN_SetError("GlobalLock()"); + } + } else { + SDL_SetError("Invalid BMP data"); + } + return bmp; +} + +static bool WIN_SetClipboardImage(SDL_VideoDevice *_this) +{ + HANDLE hMem; + size_t clipboard_data_size; + const void *clipboard_data; + bool result = true; + + clipboard_data = _this->clipboard_callback(_this->clipboard_userdata, IMAGE_MIME_TYPE, &clipboard_data_size); + hMem = WIN_ConvertBMPtoDIB(clipboard_data, clipboard_data_size); + if (hMem) { + // Save the image to the clipboard + if (!SetClipboardData(IMAGE_FORMAT, hMem)) { + result = WIN_SetError("Couldn't set clipboard data"); + } + } else { + // WIN_ConvertBMPtoDIB() set the error + result = false; + } + return result; +} + +static bool WIN_SetClipboardText(SDL_VideoDevice *_this, const char *mime_type) +{ + HANDLE hMem; + size_t clipboard_data_size; + const void *clipboard_data; + bool result = true; + + clipboard_data = _this->clipboard_callback(_this->clipboard_userdata, mime_type, &clipboard_data_size); + if (clipboard_data && clipboard_data_size > 0) { + SIZE_T i, size; + LPTSTR tstr = (WCHAR *)SDL_iconv_string("UTF-16LE", "UTF-8", (const char *)clipboard_data, clipboard_data_size); + if (!tstr) { + return SDL_SetError("Couldn't convert text from UTF-8"); + } + + // Find out the size of the data + for (size = 0, i = 0; tstr[i]; ++i, ++size) { + if (tstr[i] == '\n' && (i == 0 || tstr[i - 1] != '\r')) { + // We're going to insert a carriage return + ++size; + } + } + size = (size + 1) * sizeof(*tstr); + + // Save the data to the clipboard + hMem = GlobalAlloc(GMEM_MOVEABLE, size); + if (hMem) { + LPTSTR dst = (LPTSTR)GlobalLock(hMem); + if (dst) { + // Copy the text over, adding carriage returns as necessary + for (i = 0; tstr[i]; ++i) { + if (tstr[i] == '\n' && (i == 0 || tstr[i - 1] != '\r')) { + *dst++ = '\r'; + } + *dst++ = tstr[i]; + } + *dst = 0; + GlobalUnlock(hMem); + } + + if (!SetClipboardData(TEXT_FORMAT, hMem)) { + result = WIN_SetError("Couldn't set clipboard data"); + } + } else { + result = SDL_OutOfMemory(); + } + SDL_free(tstr); + } + return result; +} + +bool WIN_SetClipboardData(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + size_t i; + bool result = true; + + /* I investigated delayed clipboard rendering, and at least with text and image + * formats you have to use an output window, not SDL_HelperWindow, and the system + * requests them being rendered immediately, so there isn't any benefit. + */ + + if (WIN_OpenClipboard(_this)) { + EmptyClipboard(); + + // Set the clipboard text + for (i = 0; i < _this->num_clipboard_mime_types; ++i) { + const char *mime_type = _this->clipboard_mime_types[i]; + + if (SDL_IsTextMimeType(mime_type)) { + if (!WIN_SetClipboardText(_this, mime_type)) { + result = false; + } + // Only set the first clipboard text + break; + } + } + + // Set the clipboard image + for (i = 0; i < _this->num_clipboard_mime_types; ++i) { + const char *mime_type = _this->clipboard_mime_types[i]; + + if (SDL_strcmp(mime_type, IMAGE_MIME_TYPE) == 0) { + if (!WIN_SetClipboardImage(_this)) { + result = false; + } + break; + } + } + + data->clipboard_count = GetClipboardSequenceNumber(); + WIN_CloseClipboard(); + } else { + result = WIN_SetError("Couldn't open clipboard"); + } + return result; +} + +void *WIN_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size) +{ + void *data = NULL; + + if (SDL_IsTextMimeType(mime_type)) { + char *text = NULL; + + if (IsClipboardFormatAvailable(TEXT_FORMAT)) { + if (WIN_OpenClipboard(_this)) { + HANDLE hMem; + LPTSTR tstr; + + hMem = GetClipboardData(TEXT_FORMAT); + if (hMem) { + tstr = (LPTSTR)GlobalLock(hMem); + if (tstr) { + text = WIN_StringToUTF8(tstr); + GlobalUnlock(hMem); + } else { + WIN_SetError("Couldn't lock clipboard data"); + } + } else { + WIN_SetError("Couldn't get clipboard data"); + } + WIN_CloseClipboard(); + } + } + if (!text) { + text = SDL_strdup(""); + } + data = text; + *size = SDL_strlen(text); + + } else if (SDL_strcmp(mime_type, IMAGE_MIME_TYPE) == 0) { + if (IsClipboardFormatAvailable(IMAGE_FORMAT)) { + if (WIN_OpenClipboard(_this)) { + HANDLE hMem; + + hMem = GetClipboardData(IMAGE_FORMAT); + if (hMem) { + data = WIN_ConvertDIBtoBMP(hMem, size); + } else { + WIN_SetError("Couldn't get clipboard data"); + } + WIN_CloseClipboard(); + } + } + } else { + data = SDL_GetInternalClipboardData(_this, mime_type, size); + } + return data; +} + +bool WIN_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +{ + if (SDL_IsTextMimeType(mime_type)) { + if (IsClipboardFormatAvailable(TEXT_FORMAT)) { + return true; + } + } else if (SDL_strcmp(mime_type, IMAGE_MIME_TYPE) == 0) { + if (IsClipboardFormatAvailable(IMAGE_FORMAT)) { + return true; + } + } else { + if (SDL_HasInternalClipboardData(_this, mime_type)) { + return true; + } + } + return false; +} + +static int GetClipboardFormatMimeType(UINT format, char *name) +{ + static struct + { + UINT format; + const char *mime_type; + } mime_types[] = { + { TEXT_FORMAT, "text/plain;charset=utf-8" }, + { IMAGE_FORMAT, IMAGE_MIME_TYPE }, + }; + + for (int i = 0; i < SDL_arraysize(mime_types); ++i) { + if (format == mime_types[i].format) { + size_t len = SDL_strlen(mime_types[i].mime_type) + 1; + if (name) { + SDL_memcpy(name, mime_types[i].mime_type, len); + } + return (int)len; + } + } + return 0; +} + +static char **GetMimeTypes(int *pnformats) +{ + char **new_mime_types = NULL; + + *pnformats = 0; + + if (WIN_OpenClipboard(SDL_GetVideoDevice())) { + int nformats = 0; + UINT format = 0; + int formatsSz = 0; + for ( ; ; ) { + format = EnumClipboardFormats(format); + if (!format) { + break; + } + + int len = GetClipboardFormatMimeType(format, NULL); + if (len > 0) { + ++nformats; + formatsSz += len; + } + } + + new_mime_types = SDL_AllocateTemporaryMemory((nformats + 1) * sizeof(char *) + formatsSz); + if (new_mime_types) { + format = 0; + char *strPtr = (char *)(new_mime_types + nformats + 1); + int i = 0; + for ( ; ; ) { + format = EnumClipboardFormats(format); + if (!format) { + break; + } + + int len = GetClipboardFormatMimeType(format, strPtr); + if (len > 0) { + new_mime_types[i++] = strPtr; + strPtr += len; + } + } + + new_mime_types[nformats] = NULL; + *pnformats = nformats; + } + WIN_CloseClipboard(); + } + return new_mime_types; +} + +void WIN_CheckClipboardUpdate(struct SDL_VideoData *data) +{ + DWORD count = GetClipboardSequenceNumber(); + if (count != data->clipboard_count) { + if (count) { + int nformats = 0; + char **new_mime_types = GetMimeTypes(&nformats); + if (new_mime_types) { + SDL_SendClipboardUpdate(false, new_mime_types, nformats); + } + } + data->clipboard_count = count; + } +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.h new file mode 100644 index 0000000..4b14ffe --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsclipboard.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsclipboard_h_ +#define SDL_windowsclipboard_h_ + +// Forward declaration +struct SDL_VideoData; + +extern bool WIN_SetClipboardData(SDL_VideoDevice *_this); +extern void *WIN_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *size); +extern bool WIN_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern void WIN_CheckClipboardUpdate(struct SDL_VideoData *data); + +#endif // SDL_windowsclipboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.c new file mode 100644 index 0000000..f271db8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.c @@ -0,0 +1,2734 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_windowsvideo.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_touch_c.h" +#include "../../events/scancodes_windows.h" +#include "../../main/SDL_main_callbacks.h" +#include "../../core/windows/SDL_hid.h" + +// Dropfile support +#include + +// Device names +#include + +// For GET_X_LPARAM, GET_Y_LPARAM. +#include + +// For WM_TABLET_QUERYSYSTEMGESTURESTATUS et. al. +#ifdef HAVE_TPCSHRD_H +#include +#endif // HAVE_TPCSHRD_H + +#if 0 +#define WMMSG_DEBUG +#endif +#ifdef WMMSG_DEBUG +#include +#include "wmmsg.h" +#endif + +#ifdef SDL_PLATFORM_GDK +#include "../../core/gdk/SDL_gdk.h" +#endif + +// #define HIGHDPI_DEBUG + +// Make sure XBUTTON stuff is defined that isn't in older Platform SDKs... +#ifndef WM_XBUTTONDOWN +#define WM_XBUTTONDOWN 0x020B +#endif +#ifndef WM_XBUTTONUP +#define WM_XBUTTONUP 0x020C +#endif +#ifndef GET_XBUTTON_WPARAM +#define GET_XBUTTON_WPARAM(w) (HIWORD(w)) +#endif +#ifndef WM_INPUT +#define WM_INPUT 0x00ff +#endif +#ifndef WM_TOUCH +#define WM_TOUCH 0x0240 +#endif +#ifndef WM_MOUSEHWHEEL +#define WM_MOUSEHWHEEL 0x020E +#endif +#ifndef RI_MOUSE_HWHEEL +#define RI_MOUSE_HWHEEL 0x0800 +#endif +#ifndef WM_POINTERUPDATE +#define WM_POINTERUPDATE 0x0245 +#endif +#ifndef WM_POINTERDOWN +#define WM_POINTERDOWN 0x0246 +#endif +#ifndef WM_POINTERUP +#define WM_POINTERUP 0x0247 +#endif +#ifndef WM_POINTERENTER +#define WM_POINTERENTER 0x0249 +#endif +#ifndef WM_POINTERLEAVE +#define WM_POINTERLEAVE 0x024A +#endif +#ifndef WM_POINTERCAPTURECHANGED +#define WM_POINTERCAPTURECHANGED 0x024C +#endif +#ifndef WM_UNICHAR +#define WM_UNICHAR 0x0109 +#endif +#ifndef WM_DPICHANGED +#define WM_DPICHANGED 0x02E0 +#endif +#ifndef WM_GETDPISCALEDSIZE +#define WM_GETDPISCALEDSIZE 0x02E4 +#endif +#ifndef TOUCHEVENTF_PEN +#define TOUCHEVENTF_PEN 0x0040 +#endif + +#ifndef MAPVK_VK_TO_VSC_EX +#define MAPVK_VK_TO_VSC_EX 4 +#endif + +#ifndef WC_ERR_INVALID_CHARS +#define WC_ERR_INVALID_CHARS 0x00000080 +#endif + +#ifndef IS_HIGH_SURROGATE +#define IS_HIGH_SURROGATE(x) (((x) >= 0xd800) && ((x) <= 0xdbff)) +#endif + +#ifndef USER_TIMER_MINIMUM +#define USER_TIMER_MINIMUM 0x0000000A +#endif + +// Used to compare Windows message timestamps +#define SDL_TICKS_PASSED(A, B) ((Sint32)((B) - (A)) <= 0) + +#ifdef _WIN64 +typedef Uint64 QWORD; // Needed for NEXTRAWINPUTBLOCK() +#endif + +static bool SDL_processing_messages; +static DWORD message_tick; +static Uint64 timestamp_offset; + +static void WIN_SetMessageTick(DWORD tick) +{ + message_tick = tick; +} + +static Uint64 WIN_GetEventTimestamp(void) +{ + const Uint64 TIMESTAMP_WRAP_OFFSET = SDL_MS_TO_NS(0x100000000LL); + Uint64 timestamp, now; + + if (!SDL_processing_messages) { + // message_tick isn't valid, just use the current time + return 0; + } + + now = SDL_GetTicksNS(); + timestamp = SDL_MS_TO_NS(message_tick); + timestamp += timestamp_offset; + if (!timestamp_offset) { + // Initializing timestamp offset + //SDL_Log("Initializing timestamp offset"); + timestamp_offset = (now - timestamp); + timestamp = now; + } else if ((Sint64)(now - timestamp - TIMESTAMP_WRAP_OFFSET) >= 0) { + // The windows message tick wrapped + //SDL_Log("Adjusting timestamp offset for wrapping tick"); + timestamp_offset += TIMESTAMP_WRAP_OFFSET; + timestamp += TIMESTAMP_WRAP_OFFSET; + } else if (timestamp > now) { + // We got a newer timestamp, but it can't be newer than now, so adjust our offset + //SDL_Log("Adjusting timestamp offset, %.2f ms newer", (double)(timestamp - now) / SDL_NS_PER_MS); + timestamp_offset -= (timestamp - now); + timestamp = now; + } + return timestamp; +} + +// A message hook called before TranslateMessage() +static SDL_WindowsMessageHook g_WindowsMessageHook = NULL; +static void *g_WindowsMessageHookData = NULL; + +void SDL_SetWindowsMessageHook(SDL_WindowsMessageHook callback, void *userdata) +{ + g_WindowsMessageHook = callback; + g_WindowsMessageHookData = userdata; +} + +static SDL_Scancode WindowsScanCodeToSDLScanCode(LPARAM lParam, WPARAM wParam, Uint16 *rawcode, bool *virtual_key) +{ + SDL_Scancode code; + Uint8 index; + Uint16 keyFlags = HIWORD(lParam); + Uint16 scanCode = LOBYTE(keyFlags); + + /* On-Screen Keyboard can send wrong scan codes with high-order bit set (key break code). + * Strip high-order bit. */ + scanCode &= ~0x80; + + *virtual_key = (scanCode == 0); + + if (scanCode != 0) { + if ((keyFlags & KF_EXTENDED) == KF_EXTENDED) { + scanCode = MAKEWORD(scanCode, 0xe0); + } else if (scanCode == 0x45) { + // Pause + scanCode = 0xe046; + } + } else { + Uint16 vkCode = LOWORD(wParam); + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + /* Windows may not report scan codes for some buttons (multimedia buttons etc). + * Get scan code from the VK code.*/ + scanCode = LOWORD(MapVirtualKey(vkCode, WIN_IsWindowsXP() ? MAPVK_VK_TO_VSC : MAPVK_VK_TO_VSC_EX)); +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + /* Pause/Break key have a special scan code with 0xe1 prefix. + * Use Pause scan code that is used in Win32. */ + if (scanCode == 0xe11d) { + scanCode = 0xe046; + } + } + + // Pack scan code into one byte to make the index. + index = LOBYTE(scanCode) | (HIBYTE(scanCode) ? 0x80 : 0x00); + code = windows_scancode_table[index]; + *rawcode = scanCode; + + return code; +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +static bool WIN_ShouldIgnoreFocusClick(SDL_WindowData *data) +{ + return !SDL_WINDOW_IS_POPUP(data->window) && + !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); +} + +static void WIN_CheckWParamMouseButton(Uint64 timestamp, bool bwParamMousePressed, Uint32 mouseFlags, bool bSwapButtons, SDL_WindowData *data, Uint8 button, SDL_MouseID mouseID) +{ + if (bSwapButtons) { + if (button == SDL_BUTTON_LEFT) { + button = SDL_BUTTON_RIGHT; + } else if (button == SDL_BUTTON_RIGHT) { + button = SDL_BUTTON_LEFT; + } + } + + if (data->focus_click_pending & SDL_BUTTON_MASK(button)) { + // Ignore the button click for activation + if (!bwParamMousePressed) { + data->focus_click_pending &= ~SDL_BUTTON_MASK(button); + WIN_UpdateClipCursor(data->window); + } + return; + } + + if (bwParamMousePressed && !(mouseFlags & SDL_BUTTON_MASK(button))) { + SDL_SendMouseButton(timestamp, data->window, mouseID, button, true); + } else if (!bwParamMousePressed && (mouseFlags & SDL_BUTTON_MASK(button))) { + SDL_SendMouseButton(timestamp, data->window, mouseID, button, false); + } +} + +/* + * Some windows systems fail to send a WM_LBUTTONDOWN sometimes, but each mouse move contains the current button state also + * so this function reconciles our view of the world with the current buttons reported by windows + */ +static void WIN_CheckWParamMouseButtons(Uint64 timestamp, WPARAM wParam, SDL_WindowData *data, SDL_MouseID mouseID) +{ + if (wParam != data->mouse_button_flags) { + SDL_MouseButtonFlags mouseFlags = SDL_GetMouseState(NULL, NULL); + + // WM_LBUTTONDOWN and friends handle button swapping for us. No need to check SM_SWAPBUTTON here. + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_LBUTTON), mouseFlags, false, data, SDL_BUTTON_LEFT, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_MBUTTON), mouseFlags, false, data, SDL_BUTTON_MIDDLE, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_RBUTTON), mouseFlags, false, data, SDL_BUTTON_RIGHT, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_XBUTTON1), mouseFlags, false, data, SDL_BUTTON_X1, mouseID); + WIN_CheckWParamMouseButton(timestamp, (wParam & MK_XBUTTON2), mouseFlags, false, data, SDL_BUTTON_X2, mouseID); + + data->mouse_button_flags = wParam; + } +} + +static void WIN_CheckAsyncMouseRelease(Uint64 timestamp, SDL_WindowData *data) +{ + SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID; + Uint32 mouseFlags; + SHORT keyState; + bool swapButtons; + + /* mouse buttons may have changed state here, we need to resync them, + but we will get a WM_MOUSEMOVE right away which will fix things up if in non raw mode also + */ + mouseFlags = SDL_GetMouseState(NULL, NULL); + swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + + keyState = GetAsyncKeyState(VK_LBUTTON); + if (!(keyState & 0x8000)) { + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_LEFT, mouseID); + } + keyState = GetAsyncKeyState(VK_RBUTTON); + if (!(keyState & 0x8000)) { + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_RIGHT, mouseID); + } + keyState = GetAsyncKeyState(VK_MBUTTON); + if (!(keyState & 0x8000)) { + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_MIDDLE, mouseID); + } + keyState = GetAsyncKeyState(VK_XBUTTON1); + if (!(keyState & 0x8000)) { + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_X1, mouseID); + } + keyState = GetAsyncKeyState(VK_XBUTTON2); + if (!(keyState & 0x8000)) { + WIN_CheckWParamMouseButton(timestamp, false, mouseFlags, swapButtons, data, SDL_BUTTON_X2, mouseID); + } + data->mouse_button_flags = (WPARAM)-1; +} + +static void WIN_UpdateMouseCapture(void) +{ + SDL_Window *focusWindow = SDL_GetKeyboardFocus(); + + if (focusWindow && (focusWindow->flags & SDL_WINDOW_MOUSE_CAPTURE)) { + SDL_WindowData *data = focusWindow->internal; + + if (!data->mouse_tracked) { + POINT cursorPos; + + if (GetCursorPos(&cursorPos) && ScreenToClient(data->hwnd, &cursorPos)) { + bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + SDL_MouseID mouseID = SDL_GLOBAL_MOUSE_ID; + + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, mouseID, false, (float)cursorPos.x, (float)cursorPos.y); + SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, + !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT, + (GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0); + SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, + !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT, + (GetAsyncKeyState(VK_RBUTTON) & 0x8000) != 0); + SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, + SDL_BUTTON_MIDDLE, + (GetAsyncKeyState(VK_MBUTTON) & 0x8000) != 0); + SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, + SDL_BUTTON_X1, + (GetAsyncKeyState(VK_XBUTTON1) & 0x8000) != 0); + SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, + SDL_BUTTON_X2, + (GetAsyncKeyState(VK_XBUTTON2) & 0x8000) != 0); + } + } + } +} + +static void WIN_UpdateFocus(SDL_Window *window, bool expect_focus) +{ + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + bool had_focus = (SDL_GetKeyboardFocus() == window); + bool has_focus = (GetForegroundWindow() == hwnd); + + if (had_focus == has_focus || has_focus != expect_focus) { + return; + } + + if (has_focus) { + POINT cursorPos; + + if (WIN_ShouldIgnoreFocusClick(data) && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { + bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + if (GetAsyncKeyState(VK_LBUTTON)) { + data->focus_click_pending |= !swapButtons ? SDL_BUTTON_LMASK : SDL_BUTTON_RMASK; + } + if (GetAsyncKeyState(VK_RBUTTON)) { + data->focus_click_pending |= !swapButtons ? SDL_BUTTON_RMASK : SDL_BUTTON_LMASK; + } + if (GetAsyncKeyState(VK_MBUTTON)) { + data->focus_click_pending |= SDL_BUTTON_MMASK; + } + if (GetAsyncKeyState(VK_XBUTTON1)) { + data->focus_click_pending |= SDL_BUTTON_X1MASK; + } + if (GetAsyncKeyState(VK_XBUTTON2)) { + data->focus_click_pending |= SDL_BUTTON_X2MASK; + } + } + + SDL_SetKeyboardFocus(data->keyboard_focus ? data->keyboard_focus : window); + + // In relative mode we are guaranteed to have mouse focus if we have keyboard focus + if (!SDL_GetMouse()->relative_mode) { + GetCursorPos(&cursorPos); + ScreenToClient(hwnd, &cursorPos); + SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, SDL_GLOBAL_MOUSE_ID, false, (float)cursorPos.x, (float)cursorPos.y); + } + + WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data); + WIN_UpdateClipCursor(window); + + /* + * FIXME: Update keyboard state + */ + WIN_CheckClipboardUpdate(data->videodata); + + SDL_ToggleModState(SDL_KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? true : false); + + WIN_UpdateWindowICCProfile(data->window, true); + } else { + data->in_window_deactivation = true; + + SDL_SetKeyboardFocus(NULL); + // In relative mode we are guaranteed to not have mouse focus if we don't have keyboard focus + if (SDL_GetMouse()->relative_mode) { + SDL_SetMouseFocus(NULL); + } + WIN_ResetDeadKeys(); + + WIN_UnclipCursorForWindow(window); + + data->in_window_deactivation = false; + } +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +static bool ShouldGenerateWindowCloseOnAltF4(void) +{ + return SDL_GetHintBoolean(SDL_HINT_WINDOWS_CLOSE_ON_ALT_F4, true); +} + +static bool ShouldClearWindowOnEraseBackground(SDL_WindowData *data) +{ + switch (data->hint_erase_background_mode) { + case SDL_ERASEBACKGROUNDMODE_NEVER: + return false; + case SDL_ERASEBACKGROUNDMODE_INITIAL: + return !data->videodata->cleared; + case SDL_ERASEBACKGROUNDMODE_ALWAYS: + return true; + default: + // Unexpected value, fallback to default behaviour + return !data->videodata->cleared; + } +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +// We want to generate mouse events from mouse and pen, and touch events from touchscreens +#define MI_WP_SIGNATURE 0xFF515700 +#define MI_WP_SIGNATURE_MASK 0xFFFFFF00 +#define IsTouchEvent(dw) ((dw)&MI_WP_SIGNATURE_MASK) == MI_WP_SIGNATURE + +typedef enum +{ + SDL_MOUSE_EVENT_SOURCE_UNKNOWN, + SDL_MOUSE_EVENT_SOURCE_MOUSE, + SDL_MOUSE_EVENT_SOURCE_TOUCH, + SDL_MOUSE_EVENT_SOURCE_PEN, +} SDL_MOUSE_EVENT_SOURCE; + +static SDL_MOUSE_EVENT_SOURCE GetMouseMessageSource(ULONG extrainfo) +{ + // Mouse data (ignoring synthetic mouse events generated for touchscreens) + /* Versions below Vista will set the low 7 bits to the Mouse ID and don't use bit 7: + Check bits 8-31 for the signature (which will indicate a Tablet PC Pen or Touch Device). + Only check bit 7 when Vista and up(Cleared=Pen, Set=Touch(which we need to filter out)), + when the signature is set. The Mouse ID will be zero for an actual mouse. */ + if (IsTouchEvent(extrainfo)) { + if (extrainfo & 0x80) { + return SDL_MOUSE_EVENT_SOURCE_TOUCH; + } else { + return SDL_MOUSE_EVENT_SOURCE_PEN; + } + } + /* Sometimes WM_INPUT events won't have the correct touch signature, + so we have to rely purely on the touch bit being set. */ + if (SDL_TouchDevicesAvailable() && extrainfo & 0x80) { + return SDL_MOUSE_EVENT_SOURCE_TOUCH; + } + return SDL_MOUSE_EVENT_SOURCE_MOUSE; +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +static SDL_WindowData *WIN_GetWindowDataFromHWND(HWND hwnd) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + SDL_Window *window; + + if (_this) { + for (window = _this->windows; window; window = window->next) { + SDL_WindowData *data = window->internal; + if (data && data->hwnd == hwnd) { + return data; + } + } + } + return NULL; +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +LRESULT CALLBACK +WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + KBDLLHOOKSTRUCT *hookData = (KBDLLHOOKSTRUCT *)lParam; + SDL_VideoData *data = SDL_GetVideoDevice()->internal; + SDL_Scancode scanCode; + + if (nCode < 0 || nCode != HC_ACTION) { + return CallNextHookEx(NULL, nCode, wParam, lParam); + } + if (hookData->scanCode == 0x21d) { + // Skip fake LCtrl when RAlt is pressed + return 1; + } + + switch (hookData->vkCode) { + case VK_LWIN: + scanCode = SDL_SCANCODE_LGUI; + break; + case VK_RWIN: + scanCode = SDL_SCANCODE_RGUI; + break; + case VK_LMENU: + scanCode = SDL_SCANCODE_LALT; + break; + case VK_RMENU: + scanCode = SDL_SCANCODE_RALT; + break; + case VK_LCONTROL: + scanCode = SDL_SCANCODE_LCTRL; + break; + case VK_RCONTROL: + scanCode = SDL_SCANCODE_RCTRL; + break; + + // These are required to intercept Alt+Tab and Alt+Esc on Windows 7 + case VK_TAB: + scanCode = SDL_SCANCODE_TAB; + break; + case VK_ESCAPE: + scanCode = SDL_SCANCODE_ESCAPE; + break; + + default: + return CallNextHookEx(NULL, nCode, wParam, lParam); + } + + if (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN) { + if (!data->raw_keyboard_enabled) { + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, hookData->scanCode, scanCode, true); + } + } else { + if (!data->raw_keyboard_enabled) { + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, hookData->scanCode, scanCode, false); + } + + /* If the key was down prior to our hook being installed, allow the + key up message to pass normally the first time. This ensures other + windows have a consistent view of the key state, and avoids keys + being stuck down in those windows if they are down when the grab + happens and raised while grabbed. */ + if (hookData->vkCode <= 0xFF && data->pre_hook_key_state[hookData->vkCode]) { + data->pre_hook_key_state[hookData->vkCode] = 0; + return CallNextHookEx(NULL, nCode, wParam, lParam); + } + } + + return 1; +} + +static bool WIN_SwapButtons(HANDLE hDevice) +{ + if (hDevice == NULL) { + // Touchpad, already has buttons swapped + return false; + } + return GetSystemMetrics(SM_SWAPBUTTON) != 0; +} + +static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDLE hDevice, RAWMOUSE *rawmouse) +{ + static struct { + USHORT usButtonFlags; + Uint8 button; + bool down; + } raw_buttons[] = { + { RI_MOUSE_LEFT_BUTTON_DOWN, SDL_BUTTON_LEFT, true }, + { RI_MOUSE_LEFT_BUTTON_UP, SDL_BUTTON_LEFT, false }, + { RI_MOUSE_RIGHT_BUTTON_DOWN, SDL_BUTTON_RIGHT, true }, + { RI_MOUSE_RIGHT_BUTTON_UP, SDL_BUTTON_RIGHT, false }, + { RI_MOUSE_MIDDLE_BUTTON_DOWN, SDL_BUTTON_MIDDLE, true }, + { RI_MOUSE_MIDDLE_BUTTON_UP, SDL_BUTTON_MIDDLE, false }, + { RI_MOUSE_BUTTON_4_DOWN, SDL_BUTTON_X1, true }, + { RI_MOUSE_BUTTON_4_UP, SDL_BUTTON_X1, false }, + { RI_MOUSE_BUTTON_5_DOWN, SDL_BUTTON_X2, true }, + { RI_MOUSE_BUTTON_5_UP, SDL_BUTTON_X2, false } + }; + + int dx = (int)rawmouse->lLastX; + int dy = (int)rawmouse->lLastY; + bool haveMotion = (dx || dy); + bool haveButton = (rawmouse->usButtonFlags != 0); + bool isAbsolute = ((rawmouse->usFlags & MOUSE_MOVE_ABSOLUTE) != 0); + SDL_MouseID mouseID = (SDL_MouseID)(uintptr_t)hDevice; + + // Check whether relative mode should also receive events from the rawinput stream + if (!data->raw_mouse_enabled) { + return; + } + + // Relative mouse motion is delivered to the window with keyboard focus + SDL_Window *window = SDL_GetKeyboardFocus(); + if (!window) { + return; + } + + if (GetMouseMessageSource(rawmouse->ulExtraInformation) != SDL_MOUSE_EVENT_SOURCE_MOUSE) { + return; + } + + SDL_WindowData *windowdata = window->internal; + + if (haveMotion) { + if (!isAbsolute) { + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)dx, (float)dy); + } else { + /* This is absolute motion, either using a tablet or mouse over RDP + + Notes on how RDP appears to work, as of Windows 10 2004: + - SetCursorPos() calls are cached, with multiple calls coalesced into a single call that's sent to the RDP client. If the last call to SetCursorPos() has the same value as the last one that was sent to the client, it appears to be ignored and not sent. This means that we need to jitter the SetCursorPos() position slightly in order for the recentering to work correctly. + - User mouse motion is coalesced with SetCursorPos(), so the WM_INPUT positions we see will not necessarily match the position we requested with SetCursorPos(). + - SetCursorPos() outside of the bounds of the focus window appears not to do anything. + - SetCursorPos() while the cursor is NULL doesn't do anything + + We handle this by creating a safe area within the application window, and when the mouse leaves that safe area, we warp back to the opposite side. Any single motion > 50% of the safe area is assumed to be a warp and ignored. + */ + bool remote_desktop = (GetSystemMetrics(SM_REMOTESESSION) == TRUE); + bool virtual_desktop = ((rawmouse->usFlags & MOUSE_VIRTUAL_DESKTOP) != 0); + bool raw_coordinates = ((rawmouse->usFlags & 0x40) != 0); + int w = GetSystemMetrics(virtual_desktop ? SM_CXVIRTUALSCREEN : SM_CXSCREEN); + int h = GetSystemMetrics(virtual_desktop ? SM_CYVIRTUALSCREEN : SM_CYSCREEN); + int x = raw_coordinates ? dx : (int)(((float)dx / 65535.0f) * w); + int y = raw_coordinates ? dy : (int)(((float)dy / 65535.0f) * h); + int relX, relY; + + /* Calculate relative motion */ + if (data->last_raw_mouse_position.x == 0 && data->last_raw_mouse_position.y == 0) { + data->last_raw_mouse_position.x = x; + data->last_raw_mouse_position.y = y; + } + relX = x - data->last_raw_mouse_position.x; + relY = y - data->last_raw_mouse_position.y; + + if (remote_desktop) { + if (!windowdata->in_title_click && !windowdata->focus_click_pending) { + static int wobble; + float floatX = (float)x / w; + float floatY = (float)y / h; + + /* See if the mouse is at the edge of the screen, or in the RDP title bar area */ + if (floatX <= 0.01f || floatX >= 0.99f || floatY <= 0.01f || floatY >= 0.99f || y < 32) { + /* Wobble the cursor position so it's not ignored if the last warp didn't have any effect */ + RECT rect = windowdata->cursor_clipped_rect; + int warpX = rect.left + ((rect.right - rect.left) / 2) + wobble; + int warpY = rect.top + ((rect.bottom - rect.top) / 2); + + WIN_SetCursorPos(warpX, warpY); + + ++wobble; + if (wobble > 1) { + wobble = -1; + } + } else { + /* Send relative motion if we didn't warp last frame (had good position data) + We also sometimes get large deltas due to coalesced mouse motion and warping, + so ignore those. + */ + const int MAX_RELATIVE_MOTION = (h / 6); + if (SDL_abs(relX) < MAX_RELATIVE_MOTION && + SDL_abs(relY) < MAX_RELATIVE_MOTION) { + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)relX, (float)relY); + } + } + } + } else { + const int MAXIMUM_TABLET_RELATIVE_MOTION = 32; + if (SDL_abs(relX) > MAXIMUM_TABLET_RELATIVE_MOTION || + SDL_abs(relY) > MAXIMUM_TABLET_RELATIVE_MOTION) { + /* Ignore this motion, probably a pen lift and drop */ + } else { + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)relX, (float)relY); + } + } + + data->last_raw_mouse_position.x = x; + data->last_raw_mouse_position.y = y; + } + } + + if (haveButton) { + for (int i = 0; i < SDL_arraysize(raw_buttons); ++i) { + if (rawmouse->usButtonFlags & raw_buttons[i].usButtonFlags) { + Uint8 button = raw_buttons[i].button; + bool down = raw_buttons[i].down; + + if (button == SDL_BUTTON_LEFT) { + if (WIN_SwapButtons(hDevice)) { + button = SDL_BUTTON_RIGHT; + } + } else if (button == SDL_BUTTON_RIGHT) { + if (WIN_SwapButtons(hDevice)) { + button = SDL_BUTTON_LEFT; + } + } + + if (windowdata->focus_click_pending & SDL_BUTTON_MASK(button)) { + // Ignore the button click for activation + if (!down) { + windowdata->focus_click_pending &= ~SDL_BUTTON_MASK(button); + WIN_UpdateClipCursor(window); + } + continue; + } + + SDL_SendMouseButton(timestamp, window, mouseID, button, down); + } + } + + if (rawmouse->usButtonFlags & RI_MOUSE_WHEEL) { + SHORT amount = (SHORT)rawmouse->usButtonData; + float fAmount = (float)amount / WHEEL_DELTA; + SDL_SendMouseWheel(WIN_GetEventTimestamp(), window, mouseID, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL); + } else if (rawmouse->usButtonFlags & RI_MOUSE_HWHEEL) { + SHORT amount = (SHORT)rawmouse->usButtonData; + float fAmount = (float)amount / WHEEL_DELTA; + SDL_SendMouseWheel(WIN_GetEventTimestamp(), window, mouseID, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL); + } + } +} + +static void WIN_HandleRawKeyboardInput(Uint64 timestamp, SDL_VideoData *data, HANDLE hDevice, RAWKEYBOARD *rawkeyboard) +{ + SDL_KeyboardID keyboardID = (SDL_KeyboardID)(uintptr_t)hDevice; + + if (!data->raw_keyboard_enabled) { + return; + } + + if (rawkeyboard->Flags & RI_KEY_E1) { + // First key in a Ctrl+{key} sequence + data->pending_E1_key_sequence = true; + return; + } + + if ((rawkeyboard->Flags & RI_KEY_E0) && rawkeyboard->MakeCode == 0x2A) { + // 0xE02A make code prefix, ignored + return; + } + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (!rawkeyboard->MakeCode) { + rawkeyboard->MakeCode = LOWORD(MapVirtualKey(rawkeyboard->VKey, WIN_IsWindowsXP() ? MAPVK_VK_TO_VSC : MAPVK_VK_TO_VSC_EX)); + } +#endif + if (!rawkeyboard->MakeCode) { + return; + } + + bool down = !(rawkeyboard->Flags & RI_KEY_BREAK); + SDL_Scancode code; + USHORT rawcode = rawkeyboard->MakeCode; + if (data->pending_E1_key_sequence) { + rawcode |= 0xE100; + if (rawkeyboard->MakeCode == 0x45) { + // Ctrl+NumLock == Pause + code = SDL_SCANCODE_PAUSE; + } else { + // Ctrl+ScrollLock == Break (no SDL scancode?) + code = SDL_SCANCODE_UNKNOWN; + } + data->pending_E1_key_sequence = false; + } else { + // The code is in the lower 7 bits, the high bit is set for the E0 prefix + Uint8 index = (Uint8)rawkeyboard->MakeCode; + if (rawkeyboard->Flags & RI_KEY_E0) { + rawcode |= 0xE000; + index |= 0x80; + } + code = windows_scancode_table[index]; + } + + if (down) { + SDL_Window *focus = SDL_GetKeyboardFocus(); + if (!focus || focus->text_input_active) { + return; + } + } + + SDL_SendKeyboardKey(timestamp, keyboardID, rawcode, code, down); +} + +void WIN_PollRawInput(SDL_VideoDevice *_this, Uint64 poll_start) +{ + SDL_VideoData *data = _this->internal; + UINT size, i, count, total = 0; + RAWINPUT *input; + Uint64 poll_finish; + + if (data->rawinput_offset == 0) { + BOOL isWow64; + + data->rawinput_offset = sizeof(RAWINPUTHEADER); + if (IsWow64Process(GetCurrentProcess(), &isWow64) && isWow64) { + // We're going to get 64-bit data, so use the 64-bit RAWINPUTHEADER size + data->rawinput_offset += 8; + } + } + + // Get all available events + input = (RAWINPUT *)data->rawinput; + for (;;) { + size = data->rawinput_size - (UINT)((BYTE *)input - data->rawinput); + count = GetRawInputBuffer(input, &size, sizeof(RAWINPUTHEADER)); + poll_finish = SDL_GetTicksNS(); + if (count == 0 || count == (UINT)-1) { + if (!data->rawinput || (count == (UINT)-1 && GetLastError() == ERROR_INSUFFICIENT_BUFFER)) { + const UINT RAWINPUT_BUFFER_SIZE_INCREMENT = 96; // 2 64-bit raw mouse packets + BYTE *rawinput = (BYTE *)SDL_realloc(data->rawinput, data->rawinput_size + RAWINPUT_BUFFER_SIZE_INCREMENT); + if (!rawinput) { + break; + } + input = (RAWINPUT *)(rawinput + ((BYTE *)input - data->rawinput)); + data->rawinput = rawinput; + data->rawinput_size += RAWINPUT_BUFFER_SIZE_INCREMENT; + } else { + break; + } + } else { + total += count; + + // Advance input to the end of the buffer + while (count--) { + input = NEXTRAWINPUTBLOCK(input); + } + } + } + + if (total > 0) { + Uint64 delta = poll_finish - poll_start; + UINT mouse_total = 0; + for (i = 0, input = (RAWINPUT *)data->rawinput; i < total; ++i, input = NEXTRAWINPUTBLOCK(input)) { + if (input->header.dwType == RIM_TYPEMOUSE) { + mouse_total += 1; + } + } + int mouse_index = 0; + for (i = 0, input = (RAWINPUT *)data->rawinput; i < total; ++i, input = NEXTRAWINPUTBLOCK(input)) { + if (input->header.dwType == RIM_TYPEMOUSE) { + mouse_index += 1; // increment first so that it starts at one + RAWMOUSE *rawmouse = (RAWMOUSE *)((BYTE *)input + data->rawinput_offset); + Uint64 time = poll_finish - (delta * (mouse_total - mouse_index)) / mouse_total; + WIN_HandleRawMouseInput(time, data, input->header.hDevice, rawmouse); + } else if (input->header.dwType == RIM_TYPEKEYBOARD) { + RAWKEYBOARD *rawkeyboard = (RAWKEYBOARD *)((BYTE *)input + data->rawinput_offset); + WIN_HandleRawKeyboardInput(poll_finish, data, input->header.hDevice, rawkeyboard); + } + } + } + data->last_rawinput_poll = poll_finish; +} + +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count) +{ + int new_count = (*count + 1); + Uint32 *new_list = (Uint32 *)SDL_realloc(*list, new_count * sizeof(*new_list)); + if (!new_list) { + // Oh well, we'll drop this one + return; + } + new_list[new_count - 1] = deviceID; + + *count = new_count; + *list = new_list; +} + +static bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count) +{ + for (int i = 0; i < count; ++i) { + if (deviceID == list[i]) { + return true; + } + } + return false; +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +static char *GetDeviceName(HANDLE hDevice, HDEVINFO devinfo, const char *instance, const char *default_name, bool hid_loaded) +{ + char *vendor_name = NULL; + char *product_name = NULL; + char *name = NULL; + + // These are 126 for USB, but can be longer for Bluetooth devices + WCHAR vend[256], prod[256]; + vend[0] = 0; + prod[0] = 0; + + + HIDD_ATTRIBUTES attr; + attr.VendorID = 0; + attr.ProductID = 0; + attr.Size = sizeof(attr); + + if (hid_loaded) { + char devName[MAX_PATH + 1]; + UINT cap = sizeof(devName) - 1; + UINT len = GetRawInputDeviceInfoA(hDevice, RIDI_DEVICENAME, devName, &cap); + if (len != (UINT)-1) { + devName[len] = '\0'; + + // important: for devices with exclusive access mode as per + // https://learn.microsoft.com/en-us/windows-hardware/drivers/hid/top-level-collections-opened-by-windows-for-system-use + // they can only be opened with a desired access of none instead of generic read. + HANDLE hFile = CreateFileA(devName, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); + if (hFile != INVALID_HANDLE_VALUE) { + SDL_HidD_GetAttributes(hFile, &attr); + SDL_HidD_GetManufacturerString(hFile, vend, sizeof(vend)); + SDL_HidD_GetProductString(hFile, prod, sizeof(prod)); + CloseHandle(hFile); + } + } + } + + if (vend[0]) { + vendor_name = WIN_StringToUTF8W(vend); + } + + if (prod[0]) { + product_name = WIN_StringToUTF8W(prod); + } else { + SP_DEVINFO_DATA data; + SDL_zero(data); + data.cbSize = sizeof(data); + for (DWORD i = 0;; ++i) { + if (!SetupDiEnumDeviceInfo(devinfo, i, &data)) { + if (GetLastError() == ERROR_NO_MORE_ITEMS) { + break; + } else { + continue; + } + } + + char DeviceInstanceId[64]; + if (!SetupDiGetDeviceInstanceIdA(devinfo, &data, DeviceInstanceId, sizeof(DeviceInstanceId), NULL)) + continue; + + if (SDL_strcasecmp(instance, DeviceInstanceId) == 0) { + DWORD size = 0; + if (SetupDiGetDeviceRegistryPropertyW(devinfo, &data, SPDRP_DEVICEDESC, NULL, (PBYTE)prod, sizeof(prod), &size)) { + // Make sure the device description is null terminated + size /= sizeof(*prod); + if (size >= SDL_arraysize(prod)) { + // Truncated description... + size = (SDL_arraysize(prod) - 1); + } + prod[size] = 0; + + if (attr.VendorID || attr.ProductID) { + SDL_asprintf(&product_name, "%S (0x%.4x/0x%.4x)", prod, attr.VendorID, attr.ProductID); + } else { + product_name = WIN_StringToUTF8W(prod); + } + } + break; + } + } + } + + if (!product_name && (attr.VendorID || attr.ProductID)) { + SDL_asprintf(&product_name, "%s (0x%.4x/0x%.4x)", default_name, attr.VendorID, attr.ProductID); + } + name = SDL_CreateDeviceName(attr.VendorID, attr.ProductID, vendor_name, product_name, default_name); + SDL_free(vendor_name); + SDL_free(product_name); + + return name; +} + +void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check) +{ + PRAWINPUTDEVICELIST raw_devices = NULL; + UINT raw_device_count = 0; + int old_keyboard_count = 0; + SDL_KeyboardID *old_keyboards = NULL; + int new_keyboard_count = 0; + SDL_KeyboardID *new_keyboards = NULL; + int old_mouse_count = 0; + SDL_MouseID *old_mice = NULL; + int new_mouse_count = 0; + SDL_MouseID *new_mice = NULL; + bool send_event = !initial_check; + + // Check to see if anything has changed + static Uint64 s_last_device_change; + Uint64 last_device_change = WIN_GetLastDeviceNotification(); + if (!initial_check && last_device_change == s_last_device_change) { + return; + } + s_last_device_change = last_device_change; + + if ((GetRawInputDeviceList(NULL, &raw_device_count, sizeof(RAWINPUTDEVICELIST)) == -1) || (!raw_device_count)) { + return; // oh well. + } + + raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count); + if (!raw_devices) { + return; // oh well. + } + + raw_device_count = GetRawInputDeviceList(raw_devices, &raw_device_count, sizeof(RAWINPUTDEVICELIST)); + if (raw_device_count == (UINT)-1) { + SDL_free(raw_devices); + raw_devices = NULL; + return; // oh well. + } + + HDEVINFO devinfo = SetupDiGetClassDevsA(NULL, NULL, NULL, (DIGCF_ALLCLASSES | DIGCF_PRESENT)); + + old_keyboards = SDL_GetKeyboards(&old_keyboard_count); + old_mice = SDL_GetMice(&old_mouse_count); + + bool hid_loaded = WIN_LoadHIDDLL(); + for (UINT i = 0; i < raw_device_count; i++) { + RID_DEVICE_INFO rdi; + char devName[MAX_PATH] = { 0 }; + UINT rdiSize = sizeof(rdi); + UINT nameSize = SDL_arraysize(devName); + int vendor = 0, product = 0; + DWORD dwType = raw_devices[i].dwType; + char *instance, *ptr, *name; + + if (dwType != RIM_TYPEKEYBOARD && dwType != RIM_TYPEMOUSE) { + continue; + } + + rdi.cbSize = sizeof(rdi); + if (GetRawInputDeviceInfoA(raw_devices[i].hDevice, RIDI_DEVICEINFO, &rdi, &rdiSize) == ((UINT)-1) || + GetRawInputDeviceInfoA(raw_devices[i].hDevice, RIDI_DEVICENAME, devName, &nameSize) == ((UINT)-1)) { + continue; + } + + // Extract the device instance + instance = devName; + while (*instance == '\\' || *instance == '?') { + ++instance; + } + for (ptr = instance; *ptr; ++ptr) { + if (*ptr == '#') { + *ptr = '\\'; + } + if (*ptr == '{') { + if (ptr > instance && ptr[-1] == '\\') { + --ptr; + } + break; + } + } + *ptr = '\0'; + + SDL_sscanf(instance, "HID\\VID_%X&PID_%X&", &vendor, &product); + + switch (dwType) { + case RIM_TYPEKEYBOARD: + if (SDL_IsKeyboard((Uint16)vendor, (Uint16)product, rdi.keyboard.dwNumberOfKeysTotal)) { + SDL_KeyboardID keyboardID = (Uint32)(uintptr_t)raw_devices[i].hDevice; + AddDeviceID(keyboardID, &new_keyboards, &new_keyboard_count); + if (!HasDeviceID(keyboardID, old_keyboards, old_keyboard_count)) { + name = GetDeviceName(raw_devices[i].hDevice, devinfo, instance, "Keyboard", hid_loaded); + SDL_AddKeyboard(keyboardID, name, send_event); + SDL_free(name); + } + } + break; + case RIM_TYPEMOUSE: + if (SDL_IsMouse((Uint16)vendor, (Uint16)product)) { + SDL_MouseID mouseID = (Uint32)(uintptr_t)raw_devices[i].hDevice; + AddDeviceID(mouseID, &new_mice, &new_mouse_count); + if (!HasDeviceID(mouseID, old_mice, old_mouse_count)) { + name = GetDeviceName(raw_devices[i].hDevice, devinfo, instance, "Mouse", hid_loaded); + SDL_AddMouse(mouseID, name, send_event); + SDL_free(name); + } + } + break; + default: + break; + } + } + if (hid_loaded) { + WIN_UnloadHIDDLL(); + } + + for (int i = old_keyboard_count; i--;) { + if (!HasDeviceID(old_keyboards[i], new_keyboards, new_keyboard_count)) { + SDL_RemoveKeyboard(old_keyboards[i], send_event); + } + } + + for (int i = old_mouse_count; i--;) { + if (!HasDeviceID(old_mice[i], new_mice, new_mouse_count)) { + SDL_RemoveMouse(old_mice[i], send_event); + } + } + + SDL_free(old_keyboards); + SDL_free(new_keyboards); + SDL_free(old_mice); + SDL_free(new_mice); + + SetupDiDestroyDeviceInfoList(devinfo); + + SDL_free(raw_devices); +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +// Return true if spurious LCtrl is pressed +// LCtrl is sent when RAltGR is pressed +static bool SkipAltGrLeftControl(WPARAM wParam, LPARAM lParam) +{ + if (wParam != VK_CONTROL) { + return false; + } + + // Is this an extended key (i.e. right key)? + if (lParam & 0x01000000) { + return false; + } + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + // Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only + // want the RALT message, so we try to see if the next message + // is a RALT message. In that case, this is a false LCTRL! + MSG next_msg; + DWORD msg_time = GetMessageTime(); + if (PeekMessage(&next_msg, NULL, 0, 0, PM_NOREMOVE)) { + if (next_msg.message == WM_KEYDOWN || + next_msg.message == WM_SYSKEYDOWN) { + if (next_msg.wParam == VK_MENU && (next_msg.lParam & 0x01000000) && next_msg.time == msg_time) { + // Next message is a RALT down message, which means that this is NOT a proper LCTRL message! + return true; + } + } + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + return false; +} + +static bool DispatchModalLoopMessageHook(HWND *hwnd, UINT *msg, WPARAM *wParam, LPARAM *lParam) +{ + MSG dummy; + + SDL_zero(dummy); + dummy.hwnd = *hwnd; + dummy.message = *msg; + dummy.wParam = *wParam; + dummy.lParam = *lParam; + if (g_WindowsMessageHook(g_WindowsMessageHookData, &dummy)) { + // Can't modify the hwnd, but everything else is fair game + *msg = dummy.message; + *wParam = dummy.wParam; + *lParam = dummy.lParam; + return true; + } + return false; +} + +LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + SDL_WindowData *data; + LRESULT returnCode = -1; + + // Get the window data for the window + data = WIN_GetWindowDataFromHWND(hwnd); +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (!data) { + // Fallback + data = (SDL_WindowData *)GetProp(hwnd, TEXT("SDL_WindowData")); + } +#endif + if (!data) { + return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); + } + +#ifdef WMMSG_DEBUG + { + char message[1024]; + if (msg > MAX_WMMSG) { + SDL_snprintf(message, sizeof(message), "Received windows message: %p UNKNOWN (%d) -- 0x%x, 0x%x\r\n", hwnd, msg, wParam, lParam); + } else { + SDL_snprintf(message, sizeof(message), "Received windows message: %p %s -- 0x%x, 0x%x\r\n", hwnd, wmtab[msg], wParam, lParam); + } + OutputDebugStringA(message); + } +#endif // WMMSG_DEBUG + + + if (g_WindowsMessageHook && data->in_modal_loop) { + // Synthesize a message for window hooks so they can modify the message if desired + if (!DispatchModalLoopMessageHook(&hwnd, &msg, &wParam, &lParam)) { + return 0; + } + } + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (WIN_HandleIMEMessage(hwnd, msg, wParam, &lParam, data->videodata)) { + return 0; + } +#endif + + switch (msg) { + + case WM_SHOWWINDOW: + { + if (wParam) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_SHOWN, 0, 0); + } else { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); + } + } break; + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + case WM_NCACTIVATE: + { + // Don't immediately clip the cursor in case we're clicking minimize/maximize buttons + // This is the only place that this flag is set. This causes all subsequent calls to + // WIN_UpdateClipCursor for this window to be no-ops in this frame's message-pumping. + // This flag is unset at the end of message pumping each frame for every window, and + // should never be carried over between frames. + data->skip_update_clipcursor = true; + + /* Update the focus here, since it's possible to get WM_ACTIVATE and WM_SETFOCUS without + actually being the foreground window, but this appears to get called in all cases where + the global foreground window changes to and from this window. */ + WIN_UpdateFocus(data->window, !!wParam); + } break; + + case WM_ACTIVATE: + { + // Update the focus in case we changed focus to a child window and then away from the application + WIN_UpdateFocus(data->window, !!LOWORD(wParam)); + } break; + + case WM_MOUSEACTIVATE: + { + if (SDL_WINDOW_IS_POPUP(data->window)) { + return MA_NOACTIVATE; + } + + // Check parents to see if they are in relative mouse mode and focused + SDL_Window *parent = data->window->parent; + while (parent) { + if ((parent->flags & SDL_WINDOW_INPUT_FOCUS) && + (parent->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE)) { + return MA_NOACTIVATE; + } + parent = parent->parent; + } + } break; + + case WM_SETFOCUS: + { + // Update the focus in case it's changing between top-level windows in the same application + WIN_UpdateFocus(data->window, true); + } break; + + case WM_KILLFOCUS: + case WM_ENTERIDLE: + { + // Update the focus in case it's changing between top-level windows in the same application + WIN_UpdateFocus(data->window, false); + } break; + + case WM_POINTERENTER: + { + if (!data->videodata->GetPointerType) { + break; // Not on Windows8 or later? We shouldn't get this event, but just in case... + } + + const UINT32 pointerid = GET_POINTERID_WPARAM(wParam); + void *hpointer = (void *) (size_t) pointerid; + POINTER_INPUT_TYPE pointer_type = PT_POINTER; + if (!data->videodata->GetPointerType(pointerid, &pointer_type)) { + break; // oh well. + } else if (pointer_type != PT_PEN) { + break; // we only care about pens here. + } else if (SDL_FindPenByHandle(hpointer)) { + break; // we already have this one, don't readd it. + } + + // one can use GetPointerPenInfo() to get the current state of the pen, and check POINTER_PEN_INFO::penMask, + // but the docs aren't clear if these masks are _always_ set for pens with specific features, or if they + // could be unset at this moment because Windows is still deciding what capabilities the pen has, and/or + // doesn't yet have valid data for them. As such, just say everything that the interface supports is + // available...we don't expose this information through the public API at the moment anyhow. + SDL_PenInfo info; + SDL_zero(info); + info.capabilities = SDL_PEN_CAPABILITY_PRESSURE | SDL_PEN_CAPABILITY_XTILT | SDL_PEN_CAPABILITY_YTILT | SDL_PEN_CAPABILITY_DISTANCE | SDL_PEN_CAPABILITY_ROTATION | SDL_PEN_CAPABILITY_ERASER; + info.max_tilt = 90.0f; + info.num_buttons = 1; + info.subtype = SDL_PEN_TYPE_PENCIL; + SDL_AddPenDevice(0, NULL, &info, hpointer); + returnCode = 0; + } break; + + case WM_POINTERCAPTURECHANGED: + case WM_POINTERLEAVE: + { + const UINT32 pointerid = GET_POINTERID_WPARAM(wParam); + void *hpointer = (void *) (size_t) pointerid; + const SDL_PenID pen = SDL_FindPenByHandle(hpointer); + if (pen == 0) { + break; // not a pen, or not a pen we already knew about. + } + + // if this just left the _window_, we don't care. If this is no longer visible to the tablet, time to remove it! + if ((msg == WM_POINTERCAPTURECHANGED) || !IS_POINTER_INCONTACT_WPARAM(wParam)) { + SDL_RemovePenDevice(WIN_GetEventTimestamp(), pen); + } + returnCode = 0; + } break; + + case WM_POINTERUPDATE: { + POINTER_INPUT_TYPE pointer_type = PT_POINTER; + if (!data->videodata->GetPointerType || !data->videodata->GetPointerType(GET_POINTERID_WPARAM(wParam), &pointer_type)) { + break; // oh well. + } + + if (pointer_type == PT_MOUSE) { + data->last_pointer_update = lParam; + returnCode = 0; + break; + } + } + SDL_FALLTHROUGH; + + case WM_POINTERDOWN: + case WM_POINTERUP: { + POINTER_PEN_INFO pen_info; + const UINT32 pointerid = GET_POINTERID_WPARAM(wParam); + void *hpointer = (void *) (size_t) pointerid; + const SDL_PenID pen = SDL_FindPenByHandle(hpointer); + if (pen == 0) { + break; // not a pen, or not a pen we already knew about. + } else if (!data->videodata->GetPointerPenInfo || !data->videodata->GetPointerPenInfo(pointerid, &pen_info)) { + break; // oh well. + } + + const Uint64 timestamp = WIN_GetEventTimestamp(); + SDL_Window *window = data->window; + + // if lifting off, do it first, so any motion changes don't cause app issues. + if (msg == WM_POINTERUP) { + SDL_SendPenTouch(timestamp, pen, window, (pen_info.penFlags & PEN_FLAG_INVERTED) != 0, false); + } + + POINT position; + position.x = (LONG) GET_X_LPARAM(lParam); + position.y = (LONG) GET_Y_LPARAM(lParam); + ScreenToClient(data->hwnd, &position); + + SDL_SendPenMotion(timestamp, pen, window, (float) position.x, (float) position.y); + SDL_SendPenButton(timestamp, pen, window, 1, (pen_info.penFlags & PEN_FLAG_BARREL) != 0); + SDL_SendPenButton(timestamp, pen, window, 2, (pen_info.penFlags & PEN_FLAG_ERASER) != 0); + + if (pen_info.penMask & PEN_MASK_PRESSURE) { + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_PRESSURE, ((float) pen_info.pressure) / 1024.0f); // pen_info.pressure is in the range 0..1024. + } + + if (pen_info.penMask & PEN_MASK_ROTATION) { + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_ROTATION, ((float) pen_info.rotation)); // it's already in the range of 0 to 359. + } + + if (pen_info.penMask & PEN_MASK_TILT_X) { + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_XTILT, ((float) pen_info.tiltX)); // it's already in the range of -90 to 90.. + } + + if (pen_info.penMask & PEN_MASK_TILT_Y) { + SDL_SendPenAxis(timestamp, pen, window, SDL_PEN_AXIS_YTILT, ((float) pen_info.tiltY)); // it's already in the range of -90 to 90.. + } + + // if setting down, do it last, so the pen is positioned correctly from the first contact. + if (msg == WM_POINTERDOWN) { + SDL_SendPenTouch(timestamp, pen, window, (pen_info.penFlags & PEN_FLAG_INVERTED) != 0, true); + } + + returnCode = 0; + } break; + + case WM_MOUSEMOVE: + { + SDL_Window *window = data->window; + + if (window->flags & SDL_WINDOW_INPUT_FOCUS) { + bool wish_clip_cursor = ( + window->flags & (SDL_WINDOW_MOUSE_RELATIVE_MODE | SDL_WINDOW_MOUSE_GRABBED) || + (window->mouse_rect.w > 0 && window->mouse_rect.h > 0) + ); + if (wish_clip_cursor) { + data->skip_update_clipcursor = false; + WIN_UpdateClipCursor(window); + } + } + + if (!data->mouse_tracked) { + TRACKMOUSEEVENT trackMouseEvent; + + trackMouseEvent.cbSize = sizeof(TRACKMOUSEEVENT); + trackMouseEvent.dwFlags = TME_LEAVE; + trackMouseEvent.hwndTrack = data->hwnd; + + if (TrackMouseEvent(&trackMouseEvent)) { + data->mouse_tracked = true; + } + + WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data); + } + + if (!data->videodata->raw_mouse_enabled) { + // Only generate mouse events for real mouse + if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) == SDL_MOUSE_EVENT_SOURCE_MOUSE && + lParam != data->last_pointer_update) { + SDL_SendMouseMotion(WIN_GetEventTimestamp(), window, SDL_GLOBAL_MOUSE_ID, false, (float)GET_X_LPARAM(lParam), (float)GET_Y_LPARAM(lParam)); + } + } + } break; + + case WM_LBUTTONUP: + case WM_RBUTTONUP: + case WM_MBUTTONUP: + case WM_XBUTTONUP: + case WM_LBUTTONDOWN: + case WM_LBUTTONDBLCLK: + case WM_RBUTTONDOWN: + case WM_RBUTTONDBLCLK: + case WM_MBUTTONDOWN: + case WM_MBUTTONDBLCLK: + case WM_XBUTTONDOWN: + case WM_XBUTTONDBLCLK: + { + /* SDL_Mouse *mouse = SDL_GetMouse(); */ + if (!data->videodata->raw_mouse_enabled) { + if (GetMouseMessageSource((ULONG)GetMessageExtraInfo()) == SDL_MOUSE_EVENT_SOURCE_MOUSE && + lParam != data->last_pointer_update) { + WIN_CheckWParamMouseButtons(WIN_GetEventTimestamp(), wParam, data, SDL_GLOBAL_MOUSE_ID); + } + } + } break; + +#if 0 // We handle raw input all at once instead of using a syscall for each mouse event + case WM_INPUT: + { + HRAWINPUT hRawInput = (HRAWINPUT)lParam; + RAWINPUT inp; + UINT size = sizeof(inp); + + // Relative mouse motion is delivered to the window with keyboard focus + if (data->window != SDL_GetKeyboardFocus()) { + break; + } + + GetRawInputData(hRawInput, RID_INPUT, &inp, &size, sizeof(RAWINPUTHEADER)); + if (inp.header.dwType == RIM_TYPEMOUSE) { + WIN_HandleRawMouseInput(WIN_GetEventTimestamp(), data, inp.header.hDevice, &inp.data.mouse); + } else if (inp.header.dwType == RIM_TYPEKEYBOARD) { + WIN_HandleRawKeyboardInput(WIN_GetEventTimestamp(), data, inp.header.hDevice, &inp.data.keyboard); + } + } break; +#endif + + case WM_MOUSEWHEEL: + case WM_MOUSEHWHEEL: + { + if (!data->videodata->raw_mouse_enabled) { + short amount = GET_WHEEL_DELTA_WPARAM(wParam); + float fAmount = (float)amount / WHEEL_DELTA; + if (msg == WM_MOUSEWHEEL) { + SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, 0.0f, fAmount, SDL_MOUSEWHEEL_NORMAL); + } else { + SDL_SendMouseWheel(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, fAmount, 0.0f, SDL_MOUSEWHEEL_NORMAL); + } + } + } break; + + case WM_MOUSELEAVE: + if (!(data->window->flags & SDL_WINDOW_MOUSE_CAPTURE)) { + if (SDL_GetMouseFocus() == data->window && !SDL_GetMouse()->relative_mode && !IsIconic(hwnd)) { + SDL_Mouse *mouse; + POINT cursorPos; + GetCursorPos(&cursorPos); + ScreenToClient(hwnd, &cursorPos); + mouse = SDL_GetMouse(); + if (!mouse->was_touch_mouse_events) { // we're not a touch handler causing a mouse leave? + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, false, (float)cursorPos.x, (float)cursorPos.y); + } else { // touch handling? + mouse->was_touch_mouse_events = false; // not anymore + if (mouse->touch_mouse_events) { // convert touch to mouse events + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_TOUCH_MOUSEID, false, (float)cursorPos.x, (float)cursorPos.y); + } else { // normal handling + SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, SDL_GLOBAL_MOUSE_ID, false, (float)cursorPos.x, (float)cursorPos.y); + } + } + } + + if (!SDL_GetMouse()->relative_mode) { + // When WM_MOUSELEAVE is fired we can be assured that the cursor has left the window + SDL_SetMouseFocus(NULL); + } + } + + // Once we get WM_MOUSELEAVE we're guaranteed that the window is no longer tracked + data->mouse_tracked = false; + + returnCode = 0; + break; +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + { + if (SkipAltGrLeftControl(wParam, lParam)) { + returnCode = 0; + break; + } + + bool virtual_key = false; + Uint16 rawcode = 0; + SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam, &rawcode, &virtual_key); + + // Detect relevant keyboard shortcuts + if (code == SDL_SCANCODE_F4 && (SDL_GetModState() & SDL_KMOD_ALT)) { + // ALT+F4: Close window + if (ShouldGenerateWindowCloseOnAltF4()) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); + } + } + + if (virtual_key || !data->videodata->raw_keyboard_enabled || data->window->text_input_active) { + SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, rawcode, code, true); + } + } + + returnCode = 0; + break; + + case WM_SYSKEYUP: + case WM_KEYUP: + { + if (SkipAltGrLeftControl(wParam, lParam)) { + returnCode = 0; + break; + } + + bool virtual_key = false; + Uint16 rawcode = 0; + SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam, &rawcode, &virtual_key); + const bool *keyboardState = SDL_GetKeyboardState(NULL); + + if (virtual_key || !data->videodata->raw_keyboard_enabled || data->window->text_input_active) { + if (code == SDL_SCANCODE_PRINTSCREEN && !keyboardState[code]) { + SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, rawcode, code, true); + } + SDL_SendKeyboardKey(WIN_GetEventTimestamp(), SDL_GLOBAL_KEYBOARD_ID, rawcode, code, false); + } + } + returnCode = 0; + break; + + case WM_UNICHAR: + if (wParam == UNICODE_NOCHAR) { + returnCode = 1; + } else { + if (SDL_TextInputActive(data->window)) { + char text[5]; + char *end = SDL_UCS4ToUTF8((Uint32)wParam, text); + *end = '\0'; + SDL_SendKeyboardText(text); + } + returnCode = 0; + } + break; + + case WM_CHAR: + if (SDL_TextInputActive(data->window)) { + /* Characters outside Unicode Basic Multilingual Plane (BMP) + * are coded as so called "surrogate pair" in two separate UTF-16 character events. + * Cache high surrogate until next character event. */ + if (IS_HIGH_SURROGATE(wParam)) { + data->high_surrogate = (WCHAR)wParam; + } else { + WCHAR utf16[3]; + + utf16[0] = data->high_surrogate ? data->high_surrogate : (WCHAR)wParam; + utf16[1] = data->high_surrogate ? (WCHAR)wParam : L'\0'; + utf16[2] = L'\0'; + + char utf8[5]; + int result = WIN_WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, utf16, -1, utf8, sizeof(utf8), NULL, NULL); + if (result > 0) { + SDL_SendKeyboardText(utf8); + } + data->high_surrogate = L'\0'; + } + } else { + data->high_surrogate = L'\0'; + } + + returnCode = 0; + break; + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#ifdef WM_INPUTLANGCHANGE + case WM_INPUTLANGCHANGE: + { + WIN_UpdateKeymap(true); + } + returnCode = 1; + break; +#endif // WM_INPUTLANGCHANGE + + case WM_NCLBUTTONDOWN: + { + data->in_title_click = true; + + // Fix for 500ms hang after user clicks on the title bar, but before moving mouse + // Reference: https://gamedev.net/forums/topic/672094-keeping-things-moving-during-win32-moveresize-events/5254386/ + if (SendMessage(hwnd, WM_NCHITTEST, wParam, lParam) == HTCAPTION) { + POINT cursorPos; + GetCursorPos(&cursorPos); + ScreenToClient(hwnd, &cursorPos); + PostMessage(hwnd, WM_MOUSEMOVE, 0, cursorPos.x | cursorPos.y << 16); + } + } break; + + case WM_CAPTURECHANGED: + { + data->in_title_click = false; + + // The mouse may have been released during a modal loop + WIN_CheckAsyncMouseRelease(WIN_GetEventTimestamp(), data); + } break; + +#ifdef WM_GETMINMAXINFO + case WM_GETMINMAXINFO: + { + MINMAXINFO *info; + RECT size; + int x, y; + int w, h; + int min_w, min_h; + int max_w, max_h; + BOOL constrain_max_size; + + // If this is an expected size change, allow it + if (data->expected_resize) { + break; + } + + // Get the current position of our window + GetWindowRect(hwnd, &size); + x = size.left; + y = size.top; + + // Calculate current size of our window + SDL_GetWindowSize(data->window, &w, &h); + SDL_GetWindowMinimumSize(data->window, &min_w, &min_h); + SDL_GetWindowMaximumSize(data->window, &max_w, &max_h); + + /* Store in min_w and min_h difference between current size and minimal + size so we don't need to call AdjustWindowRectEx twice */ + min_w -= w; + min_h -= h; + if (max_w && max_h) { + max_w -= w; + max_h -= h; + constrain_max_size = TRUE; + } else { + constrain_max_size = FALSE; + } + + if (!(SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS) && !SDL_WINDOW_IS_POPUP(data->window)) { + size.top = 0; + size.left = 0; + size.bottom = h; + size.right = w; + WIN_AdjustWindowRectForHWND(hwnd, &size, 0); + w = size.right - size.left; + h = size.bottom - size.top; +#ifdef HIGHDPI_DEBUG + SDL_Log("WM_GETMINMAXINFO: max window size: %dx%d using dpi: %u", w, h, dpi); +#endif + } + + // Fix our size to the current size + info = (MINMAXINFO *)lParam; + if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_RESIZABLE) { + if (SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS) { + int screenW = GetSystemMetrics(SM_CXSCREEN); + int screenH = GetSystemMetrics(SM_CYSCREEN); + info->ptMaxSize.x = SDL_max(w, screenW); + info->ptMaxSize.y = SDL_max(h, screenH); + info->ptMaxPosition.x = SDL_min(0, ((screenW - w) / 2)); + info->ptMaxPosition.y = SDL_min(0, ((screenH - h) / 2)); + } + info->ptMinTrackSize.x = (LONG)w + min_w; + info->ptMinTrackSize.y = (LONG)h + min_h; + if (constrain_max_size) { + info->ptMaxTrackSize.x = (LONG)w + max_w; + info->ptMaxTrackSize.y = (LONG)h + max_h; + } + } else { + info->ptMaxSize.x = w; + info->ptMaxSize.y = h; + info->ptMaxPosition.x = x; + info->ptMaxPosition.y = y; + info->ptMinTrackSize.x = w; + info->ptMinTrackSize.y = h; + info->ptMaxTrackSize.x = w; + info->ptMaxTrackSize.y = h; + } + } + returnCode = 0; + break; +#endif // WM_GETMINMAXINFO + + case WM_WINDOWPOSCHANGING: + + if (data->expected_resize) { + returnCode = 0; + } + break; + + case WM_WINDOWPOSCHANGED: + { + SDL_Window *win; + const SDL_DisplayID original_displayID = data->last_displayID; + const WINDOWPOS *windowpos = (WINDOWPOS *)lParam; + const bool iconic = IsIconic(hwnd); + const bool zoomed = IsZoomed(hwnd); + RECT rect; + int x, y; + int w, h; + + if (windowpos->flags & SWP_SHOWWINDOW) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_SHOWN, 0, 0); + } + + if (iconic) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); + } else if (zoomed) { + if (data->window->flags & SDL_WINDOW_MINIMIZED) { + // If going from minimized to maximized, send the restored event first. + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + } + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); + data->force_ws_maximizebox = true; + } else if (data->window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED)) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + + /* If resizable was forced on for the maximized window, clear the style flags now, + * but not if the window is fullscreen, as this needs to be preserved in that case. + */ + if (!(data->window->flags & SDL_WINDOW_FULLSCREEN)) { + data->force_ws_maximizebox = false; + WIN_SetWindowResizable(SDL_GetVideoDevice(), data->window, !!(data->window->flags & SDL_WINDOW_RESIZABLE)); + } + } + + if (windowpos->flags & SWP_HIDEWINDOW) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); + } + + // When the window is minimized it's resized to the dock icon size, ignore this + if (iconic) { + break; + } + + if (data->initializing) { + break; + } + + if (!data->disable_move_size_events) { + if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) { + ClientToScreen(hwnd, (LPPOINT) &rect); + ClientToScreen(hwnd, (LPPOINT) &rect + 1); + + x = rect.left; + y = rect.top; + + SDL_GlobalToRelativeForWindow(data->window, x, y, &x, &y); + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MOVED, x, y); + } + + // Moving the window from one display to another can change the size of the window (in the handling of SDL_EVENT_WINDOW_MOVED), so we need to re-query the bounds + if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) { + w = rect.right; + h = rect.bottom; + + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESIZED, w, h); + } + } + + WIN_UpdateClipCursor(data->window); + + // Update the window display position + data->last_displayID = SDL_GetDisplayForWindow(data->window); + + if (data->last_displayID != original_displayID) { + // Display changed, check ICC profile + WIN_UpdateWindowICCProfile(data->window, true); + } + + // Update the position of any child windows + for (win = data->window->first_child; win; win = win->next_sibling) { + // Don't update hidden child popup windows, their relative position doesn't change + if (SDL_WINDOW_IS_POPUP(win) && !(win->flags & SDL_WINDOW_HIDDEN)) { + WIN_SetWindowPositionInternal(win, SWP_NOCOPYBITS | SWP_NOACTIVATE, SDL_WINDOWRECT_CURRENT); + } + } + + // Forces a WM_PAINT event + InvalidateRect(hwnd, NULL, FALSE); + + } break; + + case WM_ENTERSIZEMOVE: + case WM_ENTERMENULOOP: + { + if (g_WindowsMessageHook) { + if (!DispatchModalLoopMessageHook(&hwnd, &msg, &wParam, &lParam)) { + return 0; + } + } + + ++data->in_modal_loop; + if (data->in_modal_loop == 1) { + data->initial_size_rect.left = data->window->x; + data->initial_size_rect.right = data->window->x + data->window->w; + data->initial_size_rect.top = data->window->y; + data->initial_size_rect.bottom = data->window->y + data->window->h; + + SetTimer(hwnd, (UINT_PTR)SDL_IterateMainCallbacks, USER_TIMER_MINIMUM, NULL); + } + } break; + + case WM_TIMER: + { + if (wParam == (UINT_PTR)SDL_IterateMainCallbacks) { + SDL_OnWindowLiveResizeUpdate(data->window); + return 0; + } + } break; + + case WM_EXITSIZEMOVE: + case WM_EXITMENULOOP: + { + --data->in_modal_loop; + if (data->in_modal_loop == 0) { + KillTimer(hwnd, (UINT_PTR)SDL_IterateMainCallbacks); + } + } break; + + case WM_SIZING: + { + WPARAM edge = wParam; + RECT* dragRect = (RECT*)lParam; + RECT clientDragRect = *dragRect; + bool lock_aspect_ratio = (data->window->max_aspect == data->window->min_aspect) ? true : false; + RECT rc; + LONG w, h; + float new_aspect; + + // if aspect ratio constraints are not enabled then skip this message + if (data->window->min_aspect <= 0 && data->window->max_aspect <= 0) { + break; + } + + // unadjust the dragRect from the window rect to the client rect + SetRectEmpty(&rc); + if (!AdjustWindowRectEx(&rc, GetWindowStyle(hwnd), GetMenu(hwnd) != NULL, GetWindowExStyle(hwnd))) { + break; + } + + clientDragRect.left -= rc.left; + clientDragRect.top -= rc.top; + clientDragRect.right -= rc.right; + clientDragRect.bottom -= rc.bottom; + + w = clientDragRect.right - clientDragRect.left; + h = clientDragRect.bottom - clientDragRect.top; + new_aspect = w / (float)h; + + // handle the special case in which the min ar and max ar are the same so the window can size symmetrically + if (lock_aspect_ratio) { + switch (edge) { + case WMSZ_LEFT: + case WMSZ_RIGHT: + h = (int)SDL_roundf(w / data->window->max_aspect); + break; + default: + // resizing via corners or top or bottom + w = (int)SDL_roundf(h * data->window->max_aspect); + break; + } + } else { + switch (edge) { + case WMSZ_LEFT: + case WMSZ_RIGHT: + if (data->window->max_aspect > 0.0f && new_aspect > data->window->max_aspect) { + w = (int)SDL_roundf(h * data->window->max_aspect); + } else if (data->window->min_aspect > 0.0f && new_aspect < data->window->min_aspect) { + w = (int)SDL_roundf(h * data->window->min_aspect); + } + break; + case WMSZ_TOP: + case WMSZ_BOTTOM: + if (data->window->min_aspect > 0.0f && new_aspect < data->window->min_aspect) { + h = (int)SDL_roundf(w / data->window->min_aspect); + } else if (data->window->max_aspect > 0.0f && new_aspect > data->window->max_aspect) { + h = (int)SDL_roundf(w / data->window->max_aspect); + } + break; + + default: + // resizing via corners + if (data->window->max_aspect > 0.0f && new_aspect > data->window->max_aspect) { + w = (int)SDL_roundf(h * data->window->max_aspect); + } else if (data->window->min_aspect > 0.0f && new_aspect < data->window->min_aspect) { + h = (int)SDL_roundf(w / data->window->min_aspect); + } + break; + } + } + + switch (edge) { + case WMSZ_LEFT: + clientDragRect.left = clientDragRect.right - w; + if (lock_aspect_ratio) { + clientDragRect.top = (data->initial_size_rect.bottom + data->initial_size_rect.top - h) / 2; + } + clientDragRect.bottom = h + clientDragRect.top; + break; + case WMSZ_BOTTOMLEFT: + clientDragRect.left = clientDragRect.right - w; + clientDragRect.bottom = h + clientDragRect.top; + break; + case WMSZ_RIGHT: + clientDragRect.right = w + clientDragRect.left; + if (lock_aspect_ratio) { + clientDragRect.top = (data->initial_size_rect.bottom + data->initial_size_rect.top - h) / 2; + } + clientDragRect.bottom = h + clientDragRect.top; + break; + case WMSZ_TOPRIGHT: + clientDragRect.right = w + clientDragRect.left; + clientDragRect.top = clientDragRect.bottom - h; + break; + case WMSZ_TOP: + if (lock_aspect_ratio) { + clientDragRect.left = (data->initial_size_rect.right + data->initial_size_rect.left - w) / 2; + } + clientDragRect.right = w + clientDragRect.left; + clientDragRect.top = clientDragRect.bottom - h; + break; + case WMSZ_TOPLEFT: + clientDragRect.left = clientDragRect.right - w; + clientDragRect.top = clientDragRect.bottom - h; + break; + case WMSZ_BOTTOM: + if (lock_aspect_ratio) { + clientDragRect.left = (data->initial_size_rect.right + data->initial_size_rect.left - w) / 2; + } + clientDragRect.right = w + clientDragRect.left; + clientDragRect.bottom = h + clientDragRect.top; + break; + case WMSZ_BOTTOMRIGHT: + clientDragRect.right = w + clientDragRect.left; + clientDragRect.bottom = h + clientDragRect.top; + break; + } + + // convert the client rect to a window rect + if (!AdjustWindowRectEx(&clientDragRect, GetWindowStyle(hwnd), GetMenu(hwnd) != NULL, GetWindowExStyle(hwnd))) { + break; + } + + *dragRect = clientDragRect; + } + break; + + case WM_SETCURSOR: + { + Uint16 hittest; + + hittest = LOWORD(lParam); + if (hittest == HTCLIENT) { + SetCursor(SDL_cursor); + returnCode = TRUE; + } else if (!g_WindowFrameUsableWhileCursorHidden && !SDL_cursor) { + SetCursor(NULL); + returnCode = TRUE; + } + } break; + + // We were occluded, refresh our display + case WM_PAINT: + { + RECT rect; + if (GetUpdateRect(hwnd, &rect, FALSE)) { + const LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); + + /* Composited windows will continue to receive WM_PAINT messages for update + regions until the window is actually painted through Begin/EndPaint */ + if (style & WS_EX_COMPOSITED) { + PAINTSTRUCT ps; + BeginPaint(hwnd, &ps); + EndPaint(hwnd, &ps); + } + + ValidateRect(hwnd, NULL); + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } + } + returnCode = 0; + break; + + // We'll do our own drawing, prevent flicker + case WM_ERASEBKGND: + if (ShouldClearWindowOnEraseBackground(data)) { + RECT client_rect; + HBRUSH brush; + data->videodata->cleared = true; + GetClientRect(hwnd, &client_rect); + brush = CreateSolidBrush(0); + FillRect(GetDC(hwnd), &client_rect, brush); + DeleteObject(brush); + } + return 1; + + case WM_SYSCOMMAND: + { + if (!g_WindowsEnableMenuMnemonics) { + if ((wParam & 0xFFF0) == SC_KEYMENU) { + return 0; + } + } + +#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER) + // Don't start the screensaver or blank the monitor in fullscreen apps + if ((wParam & 0xFFF0) == SC_SCREENSAVE || + (wParam & 0xFFF0) == SC_MONITORPOWER) { + if (SDL_GetVideoDevice()->suspend_screensaver) { + return 0; + } + } +#endif // System has screensaver support + } break; + + case WM_CLOSE: + { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); + } + returnCode = 0; + break; + + case WM_TOUCH: + if (data->videodata->GetTouchInputInfo && data->videodata->CloseTouchInputHandle) { + UINT i, num_inputs = LOWORD(wParam); + bool isstack; + PTOUCHINPUT inputs = SDL_small_alloc(TOUCHINPUT, num_inputs, &isstack); + if (inputs && data->videodata->GetTouchInputInfo((HTOUCHINPUT)lParam, num_inputs, inputs, sizeof(TOUCHINPUT))) { + RECT rect; + float x, y; + + if (!GetClientRect(hwnd, &rect) || WIN_IsRectEmpty(&rect)) { + if (inputs) { + SDL_small_free(inputs, isstack); + } + break; + } + ClientToScreen(hwnd, (LPPOINT)&rect); + ClientToScreen(hwnd, (LPPOINT)&rect + 1); + rect.top *= 100; + rect.left *= 100; + rect.bottom *= 100; + rect.right *= 100; + + for (i = 0; i < num_inputs; ++i) { + PTOUCHINPUT input = &inputs[i]; + const int w = (rect.right - rect.left); + const int h = (rect.bottom - rect.top); + + const SDL_TouchID touchId = (SDL_TouchID)((uintptr_t)input->hSource); + const SDL_FingerID fingerId = (input->dwID + 1); + + /* TODO: Can we use GetRawInputDeviceInfo and HID info to + determine if this is a direct or indirect touch device? + */ + if (SDL_AddTouch(touchId, SDL_TOUCH_DEVICE_DIRECT, (input->dwFlags & TOUCHEVENTF_PEN) == TOUCHEVENTF_PEN ? "pen" : "touch") < 0) { + continue; + } + + // Get the normalized coordinates for the window + if (w <= 1) { + x = 0.5f; + } else { + x = (float)(input->x - rect.left) / (w - 1); + } + if (h <= 1) { + y = 0.5f; + } else { + y = (float)(input->y - rect.top) / (h - 1); + } + + // FIXME: Should we use the input->dwTime field for the tick source of the timestamp? + if (input->dwFlags & TOUCHEVENTF_DOWN) { + SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, SDL_EVENT_FINGER_DOWN, x, y, 1.0f); + } + if (input->dwFlags & TOUCHEVENTF_MOVE) { + SDL_SendTouchMotion(WIN_GetEventTimestamp(), touchId, fingerId, data->window, x, y, 1.0f); + } + if (input->dwFlags & TOUCHEVENTF_UP) { + SDL_SendTouch(WIN_GetEventTimestamp(), touchId, fingerId, data->window, SDL_EVENT_FINGER_UP, x, y, 1.0f); + } + } + } + SDL_small_free(inputs, isstack); + + data->videodata->CloseTouchInputHandle((HTOUCHINPUT)lParam); + return 0; + } + break; + +#ifdef HAVE_TPCSHRD_H + + case WM_TABLET_QUERYSYSTEMGESTURESTATUS: + /* See https://msdn.microsoft.com/en-us/library/windows/desktop/bb969148(v=vs.85).aspx . + * If we're handling our own touches, we don't want any gestures. + * Not all of these settings are documented. + * The use of the undocumented ones was suggested by https://github.com/bjarkeck/GCGJ/blob/master/Monogame/Windows/WinFormsGameForm.cs . */ + return TABLET_DISABLE_PRESSANDHOLD | TABLET_DISABLE_PENTAPFEEDBACK | TABLET_DISABLE_PENBARRELFEEDBACK | TABLET_DISABLE_TOUCHUIFORCEON | TABLET_DISABLE_TOUCHUIFORCEOFF | TABLET_DISABLE_TOUCHSWITCH | TABLET_DISABLE_FLICKS | TABLET_DISABLE_SMOOTHSCROLLING | TABLET_DISABLE_FLICKFALLBACKKEYS; // disables press and hold (right-click) gesture + // disables UI feedback on pen up (waves) + // disables UI feedback on pen button down (circle) + // disables pen flicks (back, forward, drag down, drag up) + +#endif // HAVE_TPCSHRD_H + + case WM_DROPFILES: + { + UINT i; + HDROP drop = (HDROP)wParam; + UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0); + for (i = 0; i < count; ++i) { + UINT size = DragQueryFile(drop, i, NULL, 0) + 1; + LPTSTR buffer = (LPTSTR)SDL_malloc(sizeof(TCHAR) * size); + if (buffer) { + if (DragQueryFile(drop, i, buffer, size)) { + char *file = WIN_StringToUTF8(buffer); + SDL_SendDropFile(data->window, NULL, file); + SDL_free(file); + } + SDL_free(buffer); + } + } + SDL_SendDropComplete(data->window); + DragFinish(drop); + return 0; + } break; + + case WM_DISPLAYCHANGE: + { + // Reacquire displays if any were added or removed + WIN_RefreshDisplays(SDL_GetVideoDevice()); + } break; + + case WM_NCCALCSIZE: + { + SDL_WindowFlags window_flags = SDL_GetWindowFlags(data->window); + if (wParam == TRUE && (window_flags & SDL_WINDOW_BORDERLESS) && !(window_flags & SDL_WINDOW_FULLSCREEN)) { + // When borderless, need to tell windows that the size of the non-client area is 0 + NCCALCSIZE_PARAMS *params = (NCCALCSIZE_PARAMS *)lParam; + WINDOWPLACEMENT placement; + if (GetWindowPlacement(hwnd, &placement) && placement.showCmd == SW_MAXIMIZE) { + // Maximized borderless windows should use the monitor work area. + HMONITOR hMonitor = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONULL); + if (!hMonitor) { + // The returned monitor can be null when restoring from minimized, so use the last coordinates. + const POINT pt = { data->window->windowed.x, data->window->windowed.y }; + hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); + } + if (hMonitor) { + MONITORINFO info; + SDL_zero(info); + info.cbSize = sizeof(info); + if (GetMonitorInfo(hMonitor, &info)) { + params->rgrc[0] = info.rcWork; + } + } + } else if (!(window_flags & SDL_WINDOW_RESIZABLE) && !data->force_ws_maximizebox) { + int w, h; + if (data->window->last_size_pending) { + w = data->window->pending.w; + h = data->window->pending.h; + } else { + w = data->window->floating.w; + h = data->window->floating.h; + } + params->rgrc[0].right = params->rgrc[0].left + w; + params->rgrc[0].bottom = params->rgrc[0].top + h; + } + return 0; + } + } break; + + case WM_NCHITTEST: + { + SDL_Window *window = data->window; + + if (window->flags & SDL_WINDOW_TOOLTIP) { + return HTTRANSPARENT; + } + + if (window->hit_test) { + POINT winpoint; + winpoint.x = GET_X_LPARAM(lParam); + winpoint.y = GET_Y_LPARAM(lParam); + if (ScreenToClient(hwnd, &winpoint)) { + SDL_Point point; + SDL_HitTestResult rc; + point.x = winpoint.x; + point.y = winpoint.y; + rc = window->hit_test(window, &point, window->hit_test_data); + switch (rc) { +#define POST_HIT_TEST(ret) \ + { \ + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); \ + return ret; \ + } + case SDL_HITTEST_DRAGGABLE: + { + /* If the mouse button state is something other than none or left button down, + * return HTCLIENT, or Windows will eat the button press. + */ + SDL_MouseButtonFlags buttonState = SDL_GetGlobalMouseState(NULL, NULL); + if (buttonState && !(buttonState & SDL_BUTTON_LMASK)) { + // Set focus in case it was lost while previously moving over a draggable area. + SDL_SetMouseFocus(window); + return HTCLIENT; + } + + POST_HIT_TEST(HTCAPTION); + } + case SDL_HITTEST_RESIZE_TOPLEFT: + POST_HIT_TEST(HTTOPLEFT); + case SDL_HITTEST_RESIZE_TOP: + POST_HIT_TEST(HTTOP); + case SDL_HITTEST_RESIZE_TOPRIGHT: + POST_HIT_TEST(HTTOPRIGHT); + case SDL_HITTEST_RESIZE_RIGHT: + POST_HIT_TEST(HTRIGHT); + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: + POST_HIT_TEST(HTBOTTOMRIGHT); + case SDL_HITTEST_RESIZE_BOTTOM: + POST_HIT_TEST(HTBOTTOM); + case SDL_HITTEST_RESIZE_BOTTOMLEFT: + POST_HIT_TEST(HTBOTTOMLEFT); + case SDL_HITTEST_RESIZE_LEFT: + POST_HIT_TEST(HTLEFT); +#undef POST_HIT_TEST + case SDL_HITTEST_NORMAL: + return HTCLIENT; + } + } + // If we didn't return, this will call DefWindowProc below. + } + } break; + + case WM_GETDPISCALEDSIZE: + // Windows 10 Creators Update+ + /* Documented as only being sent to windows that are per-monitor V2 DPI aware. + + Experimentation shows it's only sent during interactive dragging, not in response to + SetWindowPos. */ + if (data->videodata->GetDpiForWindow && data->videodata->AdjustWindowRectExForDpi) { + /* Windows expects applications to scale their window rects linearly + when dragging between monitors with different DPI's. + e.g. a 100x100 window dragged to a 200% scaled monitor + becomes 200x200. + + For SDL, we instead want the client size to scale linearly. + This is not the same as the window rect scaling linearly, + because Windows doesn't scale the non-client area (titlebar etc.) + linearly. So, we need to handle this message to request custom + scaling. */ + + const int nextDPI = (int)wParam; + const int prevDPI = (int)data->videodata->GetDpiForWindow(hwnd); + SIZE *sizeInOut = (SIZE *)lParam; + + int frame_w, frame_h; + int query_client_w_win, query_client_h_win; + +#ifdef HIGHDPI_DEBUG + SDL_Log("WM_GETDPISCALEDSIZE: current DPI: %d potential DPI: %d input size: (%dx%d)", + prevDPI, nextDPI, sizeInOut->cx, sizeInOut->cy); +#endif + + // Subtract the window frame size that would have been used at prevDPI + { + RECT rect = { 0 }; + + if (!(data->window->flags & SDL_WINDOW_BORDERLESS) && !SDL_WINDOW_IS_POPUP(data->window)) { + WIN_AdjustWindowRectForHWND(hwnd, &rect, prevDPI); + } + + frame_w = -rect.left + rect.right; + frame_h = -rect.top + rect.bottom; + + query_client_w_win = sizeInOut->cx - frame_w; + query_client_h_win = sizeInOut->cy - frame_h; + } + + // Add the window frame size that would be used at nextDPI + { + RECT rect = { 0 }; + rect.right = query_client_w_win; + rect.bottom = query_client_h_win; + + if (!(data->window->flags & SDL_WINDOW_BORDERLESS) && !SDL_WINDOW_IS_POPUP(data->window)) { + WIN_AdjustWindowRectForHWND(hwnd, &rect, nextDPI); + } + + // This is supposed to control the suggested rect param of WM_DPICHANGED + sizeInOut->cx = rect.right - rect.left; + sizeInOut->cy = rect.bottom - rect.top; + } + +#ifdef HIGHDPI_DEBUG + SDL_Log("WM_GETDPISCALEDSIZE: output size: (%dx%d)", sizeInOut->cx, sizeInOut->cy); +#endif + return TRUE; + } + break; + + case WM_DPICHANGED: + // Windows 8.1+ + { + const int newDPI = HIWORD(wParam); + RECT *const suggestedRect = (RECT *)lParam; + int w, h; + +#ifdef HIGHDPI_DEBUG + SDL_Log("WM_DPICHANGED: to %d\tsuggested rect: (%d, %d), (%dx%d)", newDPI, + suggestedRect->left, suggestedRect->top, suggestedRect->right - suggestedRect->left, suggestedRect->bottom - suggestedRect->top); +#endif + + if (data->expected_resize) { + /* This DPI change is coming from an explicit SetWindowPos call within SDL. + Assume all call sites are calculating the DPI-aware frame correctly, so + we don't need to do any further adjustment. */ +#ifdef HIGHDPI_DEBUG + SDL_Log("WM_DPICHANGED: Doing nothing, assuming window is already sized correctly"); +#endif + return 0; + } + + // Interactive user-initiated resizing/movement + { + /* Calculate the new frame w/h such that + the client area size is maintained. */ + RECT rect = { 0 }; + rect.right = data->window->w; + rect.bottom = data->window->h; + + if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) { + WIN_AdjustWindowRectForHWND(hwnd, &rect, newDPI); + } + + w = rect.right - rect.left; + h = rect.bottom - rect.top; + } + +#ifdef HIGHDPI_DEBUG + SDL_Log("WM_DPICHANGED: current SDL window size: (%dx%d)\tcalling SetWindowPos: (%d, %d), (%dx%d)", + data->window->w, data->window->h, + suggestedRect->left, suggestedRect->top, w, h); +#endif + + data->expected_resize = true; + SetWindowPos(hwnd, + NULL, + suggestedRect->left, + suggestedRect->top, + w, + h, + SWP_NOZORDER | SWP_NOACTIVATE); + data->expected_resize = false; + return 0; + } + break; + + case WM_SETTINGCHANGE: + if (wParam == 0 && lParam != 0 && SDL_wcscmp((wchar_t *)lParam, L"ImmersiveColorSet") == 0) { + SDL_SetSystemTheme(WIN_GetSystemTheme()); + WIN_UpdateDarkModeForHWND(hwnd); + } + if (wParam == SPI_SETMOUSE || wParam == SPI_SETMOUSESPEED) { + WIN_UpdateMouseSystemScale(); + } + break; + +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + } + + // If there's a window proc, assume it's going to handle messages + if (data->wndproc) { + return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam); + } else if (returnCode >= 0) { + return returnCode; + } else { + return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); + } +} + +int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) +{ + if (g_WindowsEnableMessageLoop) { +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + DWORD timeout, ret; + timeout = timeoutNS < 0 ? INFINITE : (DWORD)SDL_NS_TO_MS(timeoutNS); + ret = MsgWaitForMultipleObjects(0, NULL, FALSE, timeout, QS_ALLINPUT); + if (ret == WAIT_OBJECT_0) { + return 1; + } else { + return 0; + } +#else + // MsgWaitForMultipleObjects is desktop-only. + MSG msg; + BOOL message_result; + UINT_PTR timer_id = 0; + if (timeoutNS > 0) { + timer_id = SetTimer(NULL, 0, (UINT)SDL_NS_TO_MS(timeoutNS), NULL); + message_result = GetMessage(&msg, 0, 0, 0); + KillTimer(NULL, timer_id); + } else if (timeoutNS == 0) { + message_result = PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); + } else { + message_result = GetMessage(&msg, 0, 0, 0); + } + if (message_result) { + if (msg.message == WM_TIMER && !msg.hwnd && msg.wParam == timer_id) { + return 0; + } + if (g_WindowsMessageHook) { + if (!g_WindowsMessageHook(g_WindowsMessageHookData, &msg)) { + return 1; + } + } + // Always translate the message in case it's a non-SDL window (e.g. with Qt integration) + TranslateMessage(&msg); + DispatchMessage(&msg); + return 1; + } else { + return 0; + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + } else { + // Fail the wait so the caller falls back to polling + return -1; + } +} + +void WIN_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + PostMessage(data->hwnd, data->videodata->_SDL_WAKEUP, 0, 0); +} + +void WIN_PumpEvents(SDL_VideoDevice *_this) +{ + MSG msg; +#ifdef _MSC_VER // We explicitly want to use GetTickCount(), not GetTickCount64() +#pragma warning(push) +#pragma warning(disable : 28159) +#endif + DWORD end_ticks = GetTickCount() + 1; +#ifdef _MSC_VER +#pragma warning(pop) +#endif + int new_messages = 0; +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + const bool *keystate; + SDL_Window *focusWindow; +#endif + + if (_this->internal->gameinput_context) { + WIN_UpdateGameInput(_this); + } + + if (g_WindowsEnableMessageLoop) { + SDL_processing_messages = true; + + while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + if (g_WindowsMessageHook) { + if (!g_WindowsMessageHook(g_WindowsMessageHookData, &msg)) { + continue; + } + } + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + // Don't dispatch any mouse motion queued prior to or including the last mouse warp + if (msg.message == WM_MOUSEMOVE && SDL_last_warp_time) { + if (!SDL_TICKS_PASSED(msg.time, (SDL_last_warp_time + 1))) { + continue; + } + + // This mouse message happened after the warp + SDL_last_warp_time = 0; + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + WIN_SetMessageTick(msg.time); + + // Always translate the message in case it's a non-SDL window (e.g. with Qt integration) + TranslateMessage(&msg); + DispatchMessage(&msg); + + // Make sure we don't busy loop here forever if there are lots of events coming in + if (SDL_TICKS_PASSED(msg.time, end_ticks)) { + /* We might get a few new messages generated by the Steam overlay or other application hooks + In this case those messages will be processed before any pending input, so we want to continue after those messages. + (thanks to Peter Deayton for his investigation here) + */ + const int MAX_NEW_MESSAGES = 3; + ++new_messages; + if (new_messages > MAX_NEW_MESSAGES) { + break; + } + } + } + + SDL_processing_messages = false; + } + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + /* Windows loses a shift KEYUP event when you have both pressed at once and let go of one. + You won't get a KEYUP until both are released, and that keyup will only be for the second + key you released. Take heroic measures and check the keystate as of the last handled event, + and if we think a key is pressed when Windows doesn't, unstick it in SDL's state. */ + keystate = SDL_GetKeyboardState(NULL); + if (keystate[SDL_SCANCODE_LSHIFT] && !(GetKeyState(VK_LSHIFT) & 0x8000)) { + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_LSHIFT, false); + } + if (keystate[SDL_SCANCODE_RSHIFT] && !(GetKeyState(VK_RSHIFT) & 0x8000)) { + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_RSHIFT, false); + } + + /* The Windows key state gets lost when using Windows+Space or Windows+G shortcuts and + not grabbing the keyboard. Note: If we *are* grabbing the keyboard, GetKeyState() + will return inaccurate results for VK_LWIN and VK_RWIN but we don't need it anyway. */ + focusWindow = SDL_GetKeyboardFocus(); + if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { + if (keystate[SDL_SCANCODE_LGUI] && !(GetKeyState(VK_LWIN) & 0x8000)) { + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_LGUI, false); + } + if (keystate[SDL_SCANCODE_RGUI] && !(GetKeyState(VK_RWIN) & 0x8000)) { + SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, 0, SDL_SCANCODE_RGUI, false); + } + } + + // Update the clipping rect in case someone else has stolen it + if (_this) { + SDL_Window *window = _this->windows; + while (window) { + SDL_WindowData *data = window->internal; + if (data && data->skip_update_clipcursor) { + data->skip_update_clipcursor = false; + WIN_UpdateClipCursor(window); + } + window = window->next; + } + } + + // Update mouse capture + WIN_UpdateMouseCapture(); + + if (!_this->internal->gameinput_context) { + WIN_CheckKeyboardAndMouseHotplug(_this, false); + } + + WIN_UpdateIMECandidates(_this); + +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#ifdef SDL_PLATFORM_GDK + GDK_DispatchTaskQueue(); +#endif +} + +static int app_registered = 0; +LPTSTR SDL_Appname = NULL; +Uint32 SDL_Appstyle = 0; +HINSTANCE SDL_Instance = NULL; + +static void WIN_CleanRegisterApp(WNDCLASSEX wcex) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (wcex.hIcon) { + DestroyIcon(wcex.hIcon); + } + if (wcex.hIconSm) { + DestroyIcon(wcex.hIconSm); + } +#endif + SDL_free(SDL_Appname); + SDL_Appname = NULL; +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +static BOOL CALLBACK WIN_ResourceNameCallback(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG_PTR lParam) +{ + WNDCLASSEX *wcex = (WNDCLASSEX *)lParam; + + (void)lpType; // We already know that the resource type is RT_GROUP_ICON. + + /* We leave hIconSm as NULL as it will allow Windows to automatically + choose the appropriate small icon size to suit the current DPI. */ + wcex->hIcon = LoadIcon(hModule, lpName); + + // Do not bother enumerating any more. + return FALSE; +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +// Register the class for this application +bool SDL_RegisterApp(const char *name, Uint32 style, void *hInst) +{ + WNDCLASSEX wcex; +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + const char *hint; +#endif + + // Only do this once... + if (app_registered) { + ++app_registered; + return true; + } + SDL_assert(!SDL_Appname); + if (!name) { + name = "SDL_app"; +#if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC) + style = (CS_BYTEALIGNCLIENT | CS_OWNDC); +#endif + } + SDL_Appname = WIN_UTF8ToString(name); + SDL_Appstyle = style; + SDL_Instance = hInst ? (HINSTANCE)hInst : GetModuleHandle(NULL); + + // Register the application class + wcex.cbSize = sizeof(WNDCLASSEX); + wcex.hCursor = NULL; + wcex.hIcon = NULL; + wcex.hIconSm = NULL; + wcex.lpszMenuName = NULL; + wcex.lpszClassName = SDL_Appname; + wcex.style = SDL_Appstyle; + wcex.hbrBackground = NULL; + wcex.lpfnWndProc = WIN_WindowProc; + wcex.hInstance = SDL_Instance; + wcex.cbClsExtra = 0; + wcex.cbWndExtra = 0; + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + hint = SDL_GetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON); + if (hint && *hint) { + wcex.hIcon = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint))); + + hint = SDL_GetHint(SDL_HINT_WINDOWS_INTRESOURCE_ICON_SMALL); + if (hint && *hint) { + wcex.hIconSm = LoadIcon(SDL_Instance, MAKEINTRESOURCE(SDL_atoi(hint))); + } + } else { + // Use the first icon as a default icon, like in the Explorer. + EnumResourceNames(SDL_Instance, RT_GROUP_ICON, WIN_ResourceNameCallback, (LONG_PTR)&wcex); + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + if (!RegisterClassEx(&wcex)) { + WIN_CleanRegisterApp(wcex); + return SDL_SetError("Couldn't register application class"); + } + + app_registered = 1; + return true; +} + +// Unregisters the windowclass registered in SDL_RegisterApp above. +void SDL_UnregisterApp(void) +{ + WNDCLASSEX wcex; + + // SDL_RegisterApp might not have been called before + if (!app_registered) { + return; + } + --app_registered; + if (app_registered == 0) { + // Ensure the icons are initialized. + wcex.hIcon = NULL; + wcex.hIconSm = NULL; + // Check for any registered window classes. +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (GetClassInfoEx(SDL_Instance, SDL_Appname, &wcex)) { + UnregisterClass(SDL_Appname, SDL_Instance); + } +#endif + WIN_CleanRegisterApp(wcex); + } +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.h new file mode 100644 index 0000000..5336013 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsevents.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsevents_h_ +#define SDL_windowsevents_h_ + +extern LPTSTR SDL_Appname; +extern Uint32 SDL_Appstyle; +extern HINSTANCE SDL_Instance; + +extern LRESULT CALLBACK WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam); +extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, + LPARAM lParam); +extern void WIN_PollRawInput(SDL_VideoDevice *_this, Uint64 poll_start); +extern void WIN_CheckKeyboardAndMouseHotplug(SDL_VideoDevice *_this, bool initial_check); +extern void WIN_PumpEvents(SDL_VideoDevice *_this); +extern void WIN_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); +extern int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); + +#endif // SDL_windowsevents_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.c new file mode 100644 index 0000000..f2bbd59 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.c @@ -0,0 +1,132 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsvideo.h" + +bool WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) +{ + SDL_WindowData *data = window->internal; + bool isstack; + size_t size; + LPBITMAPINFO info; + HBITMAP hbm; + int w, h; + + SDL_GetWindowSizeInPixels(window, &w, &h); + + // Free the old framebuffer surface + if (data->mdc) { + DeleteDC(data->mdc); + } + if (data->hbm) { + DeleteObject(data->hbm); + } + + // Find out the format of the screen + size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); + info = (LPBITMAPINFO)SDL_small_alloc(Uint8, size, &isstack); + if (!info) { + return false; + } + + SDL_memset(info, 0, size); + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + + // The second call to GetDIBits() fills in the bitfields + hbm = CreateCompatibleBitmap(data->hdc, 1, 1); + GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS); + GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS); + DeleteObject(hbm); + + *format = SDL_PIXELFORMAT_UNKNOWN; + if (info->bmiHeader.biCompression == BI_BITFIELDS) { + int bpp; + Uint32 *masks; + + bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount; + masks = (Uint32 *)((Uint8 *)info + info->bmiHeader.biSize); + *format = SDL_GetPixelFormatForMasks(bpp, masks[0], masks[1], masks[2], 0); + } + if (*format == SDL_PIXELFORMAT_UNKNOWN) { + // We'll use RGB format for now + *format = SDL_PIXELFORMAT_XRGB8888; + + // Create a new one + SDL_memset(info, 0, size); + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = 32; + info->bmiHeader.biCompression = BI_RGB; + } + + // Fill in the size information + *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); + info->bmiHeader.biWidth = w; + info->bmiHeader.biHeight = -h; // negative for topdown bitmap + info->bmiHeader.biSizeImage = (DWORD)h * (*pitch); + + data->mdc = CreateCompatibleDC(data->hdc); + data->hbm = CreateDIBSection(data->hdc, info, DIB_RGB_COLORS, pixels, NULL, 0); + SDL_small_free(info, isstack); + + if (!data->hbm) { + return WIN_SetError("Unable to create DIB"); + } + SelectObject(data->mdc, data->hbm); + + return true; +} + +bool WIN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) +{ + SDL_WindowData *data = window->internal; + int i; + + for (i = 0; i < numrects; ++i) { + BitBlt(data->hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h, + data->mdc, rects[i].x, rects[i].y, SRCCOPY); + } + return true; +} + +void WIN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + if (!data) { + // The window wasn't fully initialized + return; + } + + if (data->mdc) { + DeleteDC(data->mdc); + data->mdc = NULL; + } + if (data->hbm) { + DeleteObject(data->hbm); + data->hbm = NULL; + } +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.h new file mode 100644 index 0000000..bafcfe9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsframebuffer.h @@ -0,0 +1,25 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +extern bool WIN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); +extern bool WIN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); +extern void WIN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.c new file mode 100644 index 0000000..183733a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.c @@ -0,0 +1,612 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#include "SDL_windowsvideo.h" + +// GameInput currently has a bug with keys stuck on focus change, and crashes on initialization on some systems, so we'll disable it until these issues are fixed. +#undef HAVE_GAMEINPUT_H + +#ifdef HAVE_GAMEINPUT_H + +#include "../../core/windows/SDL_gameinput.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/scancodes_windows.h" + + +#define MAX_GAMEINPUT_BUTTONS 7 // GameInputMouseWheelTiltRight is the highest button + +static const Uint8 GAMEINPUT_button_map[MAX_GAMEINPUT_BUTTONS] = { + SDL_BUTTON_LEFT, + SDL_BUTTON_RIGHT, + SDL_BUTTON_MIDDLE, + SDL_BUTTON_X1, + SDL_BUTTON_X2, + 6, + 7 +}; + +typedef struct GAMEINPUT_Device +{ + IGameInputDevice *pDevice; + const GameInputDeviceInfo *info; + char *name; + Uint32 instance_id; // generated by SDL + bool registered; + bool delete_requested; + IGameInputReading *last_mouse_reading; + IGameInputReading *last_keyboard_reading; +} GAMEINPUT_Device; + +struct WIN_GameInputData +{ + IGameInput *pGameInput; + GameInputCallbackToken gameinput_callback_token; + int num_devices; + GAMEINPUT_Device **devices; + GameInputKind enabled_input; + SDL_Mutex *lock; + uint64_t timestamp_offset; +}; + +static bool GAMEINPUT_InternalAddOrFind(WIN_GameInputData *data, IGameInputDevice *pDevice) +{ + GAMEINPUT_Device **devicelist = NULL; + GAMEINPUT_Device *device = NULL; + const GameInputDeviceInfo *info; + bool result = false; + + info = IGameInputDevice_GetDeviceInfo(pDevice); + + SDL_LockMutex(data->lock); + { + for (int i = 0; i < data->num_devices; ++i) { + device = data->devices[i]; + if (device && device->pDevice == pDevice) { + // we're already added + device->delete_requested = false; + result = true; + goto done; + } + } + + device = (GAMEINPUT_Device *)SDL_calloc(1, sizeof(*device)); + if (!device) { + goto done; + } + + devicelist = (GAMEINPUT_Device **)SDL_realloc(data->devices, (data->num_devices + 1) * sizeof(*devicelist)); + if (!devicelist) { + SDL_free(device); + goto done; + } + + if (info->deviceStrings) { + // In theory we could get the manufacturer and product strings here, but they're NULL for all the devices I've tested + } + + if (info->displayName) { + // This could give us a product string, but it's NULL for all the devices I've tested + } + + IGameInputDevice_AddRef(pDevice); + device->pDevice = pDevice; + device->instance_id = SDL_GetNextObjectID(); + device->info = info; + + data->devices = devicelist; + data->devices[data->num_devices++] = device; + + result = true; + } +done: + SDL_UnlockMutex(data->lock); + + return result; +} + +static bool GAMEINPUT_InternalRemoveByIndex(WIN_GameInputData *data, int idx) +{ + GAMEINPUT_Device **devicelist = NULL; + GAMEINPUT_Device *device; + bool result = false; + + SDL_LockMutex(data->lock); + { + if (idx < 0 || idx >= data->num_devices) { + result = SDL_SetError("GAMEINPUT_InternalRemoveByIndex argument idx %d is out of range", idx); + goto done; + } + + device = data->devices[idx]; + if (device) { + if (device->registered) { + if (device->info->supportedInput & GameInputKindMouse) { + SDL_RemoveMouse(device->instance_id, true); + } + if (device->info->supportedInput & GameInputKindKeyboard) { + SDL_RemoveKeyboard(device->instance_id, true); + } + if (device->last_mouse_reading) { + IGameInputReading_Release(device->last_mouse_reading); + device->last_mouse_reading = NULL; + } + if (device->last_keyboard_reading) { + IGameInputReading_Release(device->last_keyboard_reading); + device->last_keyboard_reading = NULL; + } + } + IGameInputDevice_Release(device->pDevice); + SDL_free(device->name); + SDL_free(device); + } + data->devices[idx] = NULL; + + if (data->num_devices == 1) { + // last element in the list, free the entire list then + SDL_free(data->devices); + data->devices = NULL; + } else { + if (idx != data->num_devices - 1) { + size_t bytes = sizeof(*devicelist) * (data->num_devices - idx - 1); + SDL_memmove(&data->devices[idx], &data->devices[idx + 1], bytes); + } + } + + // decrement the count and return + --data->num_devices; + result = true; + } +done: + SDL_UnlockMutex(data->lock); + + return result; +} + +static void CALLBACK GAMEINPUT_InternalDeviceCallback( + _In_ GameInputCallbackToken callbackToken, + _In_ void* context, + _In_ IGameInputDevice *pDevice, + _In_ uint64_t timestamp, + _In_ GameInputDeviceStatus currentStatus, + _In_ GameInputDeviceStatus previousStatus) +{ + WIN_GameInputData *data = (WIN_GameInputData *)context; + int idx = 0; + GAMEINPUT_Device *device = NULL; + + if (!pDevice) { + // This should never happen, but ignore it if it does + return; + } + + if (currentStatus & GameInputDeviceConnected) { + GAMEINPUT_InternalAddOrFind(data, pDevice); + } else { + for (idx = 0; idx < data->num_devices; ++idx) { + device = data->devices[idx]; + if (device && device->pDevice == pDevice) { + // will be deleted on the next Detect call + device->delete_requested = true; + break; + } + } + } +} + +bool WIN_InitGameInput(SDL_VideoDevice *_this) +{ + WIN_GameInputData *data; + HRESULT hr; + bool result = false; + + if (_this->internal->gameinput_context) { + return true; + } + + data = (WIN_GameInputData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + goto done; + } + _this->internal->gameinput_context = data; + + data->lock = SDL_CreateMutex(); + if (!data->lock) { + goto done; + } + + if (!SDL_InitGameInput(&data->pGameInput)) { + goto done; + } + + hr = IGameInput_RegisterDeviceCallback(data->pGameInput, + NULL, + (GameInputKindMouse | GameInputKindKeyboard), + GameInputDeviceConnected, + GameInputBlockingEnumeration, + data, + GAMEINPUT_InternalDeviceCallback, + &data->gameinput_callback_token); + if (FAILED(hr)) { + SDL_SetError("IGameInput::RegisterDeviceCallback failure with HRESULT of %08X", hr); + goto done; + } + + // Calculate the relative offset between SDL timestamps and GameInput timestamps + Uint64 now = SDL_GetTicksNS(); + uint64_t timestampUS = IGameInput_GetCurrentTimestamp(data->pGameInput); + data->timestamp_offset = (SDL_NS_TO_US(now) - timestampUS); + + result = true; + +done: + if (!result) { + WIN_QuitGameInput(_this); + } + return result; +} + +static void GAMEINPUT_InitialMouseReading(WIN_GameInputData *data, SDL_Window *window, GAMEINPUT_Device *device, IGameInputReading *reading) +{ + GameInputMouseState state; + if (SUCCEEDED(IGameInputReading_GetMouseState(reading, &state))) { + Uint64 timestamp = SDL_US_TO_NS(IGameInputReading_GetTimestamp(reading) + data->timestamp_offset); + SDL_MouseID mouseID = device->instance_id; + + for (int i = 0; i < MAX_GAMEINPUT_BUTTONS; ++i) { + const GameInputMouseButtons mask = (1 << i); + bool down = ((state.buttons & mask) != 0); + SDL_SendMouseButton(timestamp, window, mouseID, GAMEINPUT_button_map[i], down); + } + } +} + +static void GAMEINPUT_HandleMouseDelta(WIN_GameInputData *data, SDL_Window *window, GAMEINPUT_Device *device, IGameInputReading *last_reading, IGameInputReading *reading) +{ + GameInputMouseState last; + GameInputMouseState state; + if (SUCCEEDED(IGameInputReading_GetMouseState(last_reading, &last)) && + SUCCEEDED(IGameInputReading_GetMouseState(reading, &state))) { + Uint64 timestamp = SDL_US_TO_NS(IGameInputReading_GetTimestamp(reading) + data->timestamp_offset); + SDL_MouseID mouseID = device->instance_id; + + GameInputMouseState delta; + delta.buttons = (state.buttons ^ last.buttons); + delta.positionX = (state.positionX - last.positionX); + delta.positionY = (state.positionY - last.positionY); + delta.wheelX = (state.wheelX - last.wheelX); + delta.wheelY = (state.wheelY - last.wheelY); + + if (delta.positionX || delta.positionY) { + SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)delta.positionX, (float)delta.positionY); + } + if (delta.buttons) { + for (int i = 0; i < MAX_GAMEINPUT_BUTTONS; ++i) { + const GameInputMouseButtons mask = (1 << i); + if (delta.buttons & mask) { + bool down = ((state.buttons & mask) != 0); + SDL_SendMouseButton(timestamp, window, mouseID, GAMEINPUT_button_map[i], down); + } + } + } + if (delta.wheelX || delta.wheelY) { + float fAmountX = (float)delta.wheelX / WHEEL_DELTA; + float fAmountY = (float)delta.wheelY / WHEEL_DELTA; + SDL_SendMouseWheel(timestamp, SDL_GetMouseFocus(), device->instance_id, fAmountX, fAmountY, SDL_MOUSEWHEEL_NORMAL); + } + } +} + +static SDL_Scancode GetScancodeFromKeyState(const GameInputKeyState *state) +{ + Uint8 index = (Uint8)(state->scanCode & 0xFF); + if ((state->scanCode & 0xFF00) == 0xE000) { + index |= 0x80; + } + return windows_scancode_table[index]; +} + +static bool KeysHaveScancode(const GameInputKeyState *keys, uint32_t count, SDL_Scancode scancode) +{ + for (uint32_t i = 0; i < count; ++i) { + if (GetScancodeFromKeyState(&keys[i]) == scancode) { + return true; + } + } + return false; +} + +static void GAMEINPUT_InitialKeyboardReading(WIN_GameInputData *data, SDL_Window *window, GAMEINPUT_Device *device, IGameInputReading *reading) +{ + Uint64 timestamp = SDL_US_TO_NS(IGameInputReading_GetTimestamp(reading) + data->timestamp_offset); + SDL_KeyboardID keyboardID = device->instance_id; + + uint32_t max_keys = device->info->keyboardInfo->maxSimultaneousKeys; + GameInputKeyState *keys = SDL_stack_alloc(GameInputKeyState, max_keys); + if (!keys) { + return; + } + + uint32_t num_keys = IGameInputReading_GetKeyState(reading, max_keys, keys); + if (!num_keys) { + // FIXME: We probably need to track key state by keyboardID + SDL_ResetKeyboard(); + return; + } + + // Go through and send key up events for any key that's not held down + int num_scancodes; + const bool *keyboard_state = SDL_GetKeyboardState(&num_scancodes); + for (int i = 0; i < num_scancodes; ++i) { + if (keyboard_state[i] && !KeysHaveScancode(keys, num_keys, (SDL_Scancode)i)) { + SDL_SendKeyboardKey(timestamp, keyboardID, keys[i].scanCode, (SDL_Scancode)i, false); + } + } + + // Go through and send key down events for any key that's held down + for (uint32_t i = 0; i < num_keys; ++i) { + SDL_SendKeyboardKey(timestamp, keyboardID, keys[i].scanCode, GetScancodeFromKeyState(&keys[i]), true); + } +} + +#ifdef DEBUG_KEYS +static void DumpKeys(const char *prefix, GameInputKeyState *keys, uint32_t count) +{ + SDL_Log("%s", prefix); + for (uint32_t i = 0; i < count; ++i) { + char str[5]; + *SDL_UCS4ToUTF8(keys[i].codePoint, str) = '\0'; + SDL_Log(" Key 0x%.2x (%s)", keys[i].scanCode, str); + } +} +#endif // DEBUG_KEYS + +static void GAMEINPUT_HandleKeyboardDelta(WIN_GameInputData *data, SDL_Window *window, GAMEINPUT_Device *device, IGameInputReading *last_reading, IGameInputReading *reading) +{ + Uint64 timestamp = SDL_US_TO_NS(IGameInputReading_GetTimestamp(reading) + data->timestamp_offset); + SDL_KeyboardID keyboardID = device->instance_id; + + uint32_t max_keys = device->info->keyboardInfo->maxSimultaneousKeys; + GameInputKeyState *last = SDL_stack_alloc(GameInputKeyState, max_keys); + GameInputKeyState *keys = SDL_stack_alloc(GameInputKeyState, max_keys); + if (!last || !keys) { + return; + } + + uint32_t index_last = 0; + uint32_t index_keys = 0; + uint32_t num_last = IGameInputReading_GetKeyState(last_reading, max_keys, last); + uint32_t num_keys = IGameInputReading_GetKeyState(reading, max_keys, keys); +#ifdef DEBUG_KEYS + SDL_Log("Timestamp: %llu", timestamp); + DumpKeys("Last keys:", last, num_last); + DumpKeys("New keys:", keys, num_keys); +#endif + while (index_last < num_last || index_keys < num_keys) { + if (index_last < num_last && index_keys < num_keys) { + if (last[index_last].scanCode == keys[index_keys].scanCode) { + // No change + ++index_last; + ++index_keys; + } else { + // This key was released + SDL_SendKeyboardKey(timestamp, keyboardID, last[index_last].scanCode, GetScancodeFromKeyState(&last[index_last]), false); + ++index_last; + } + } else if (index_last < num_last) { + // This key was released + SDL_SendKeyboardKey(timestamp, keyboardID, last[index_last].scanCode, GetScancodeFromKeyState(&last[index_last]), false); + ++index_last; + } else { + // This key was pressed + SDL_SendKeyboardKey(timestamp, keyboardID, keys[index_keys].scanCode, GetScancodeFromKeyState(&keys[index_keys]), true); + ++index_keys; + } + } +} + +void WIN_UpdateGameInput(SDL_VideoDevice *_this) +{ + WIN_GameInputData *data = _this->internal->gameinput_context; + + SDL_LockMutex(data->lock); + { + // Key events and relative mouse motion both go to the window with keyboard focus + SDL_Window *window = SDL_GetKeyboardFocus(); + + for (int i = 0; i < data->num_devices; ++i) { + GAMEINPUT_Device *device = data->devices[i]; + IGameInputReading *reading; + + if (!device->registered) { + if (device->info->supportedInput & GameInputKindMouse) { + SDL_AddMouse(device->instance_id, device->name, true); + } + if (device->info->supportedInput & GameInputKindKeyboard) { + SDL_AddKeyboard(device->instance_id, device->name, true); + } + device->registered = true; + } + + if (device->delete_requested) { + GAMEINPUT_InternalRemoveByIndex(data, i--); + continue; + } + + if (!(device->info->supportedInput & data->enabled_input)) { + continue; + } + + if (!window) { + continue; + } + + if (data->enabled_input & GameInputKindMouse) { + if (device->last_mouse_reading) { + HRESULT hr; + while (SUCCEEDED(hr = IGameInput_GetNextReading(data->pGameInput, device->last_mouse_reading, GameInputKindMouse, device->pDevice, &reading))) { + GAMEINPUT_HandleMouseDelta(data, window, device, device->last_mouse_reading, reading); + IGameInputReading_Release(device->last_mouse_reading); + device->last_mouse_reading = reading; + } + if (hr != GAMEINPUT_E_READING_NOT_FOUND) { + if (SUCCEEDED(IGameInput_GetCurrentReading(data->pGameInput, GameInputKindMouse, device->pDevice, &reading))) { + GAMEINPUT_HandleMouseDelta(data, window, device, device->last_mouse_reading, reading); + IGameInputReading_Release(device->last_mouse_reading); + device->last_mouse_reading = reading; + } + } + } else { + if (SUCCEEDED(IGameInput_GetCurrentReading(data->pGameInput, GameInputKindMouse, device->pDevice, &reading))) { + GAMEINPUT_InitialMouseReading(data, window, device, reading); + device->last_mouse_reading = reading; + } + } + } + + if (data->enabled_input & GameInputKindKeyboard) { + if (window->text_input_active) { + // Reset raw input while text input is active + if (device->last_keyboard_reading) { + IGameInputReading_Release(device->last_keyboard_reading); + device->last_keyboard_reading = NULL; + } + } else { + if (device->last_keyboard_reading) { + HRESULT hr; + while (SUCCEEDED(hr = IGameInput_GetNextReading(data->pGameInput, device->last_keyboard_reading, GameInputKindKeyboard, device->pDevice, &reading))) { + GAMEINPUT_HandleKeyboardDelta(data, window, device, device->last_keyboard_reading, reading); + IGameInputReading_Release(device->last_keyboard_reading); + device->last_keyboard_reading = reading; + } + if (hr != GAMEINPUT_E_READING_NOT_FOUND) { + if (SUCCEEDED(IGameInput_GetCurrentReading(data->pGameInput, GameInputKindKeyboard, device->pDevice, &reading))) { + GAMEINPUT_HandleKeyboardDelta(data, window, device, device->last_keyboard_reading, reading); + IGameInputReading_Release(device->last_keyboard_reading); + device->last_keyboard_reading = reading; + } + } + } else { + if (SUCCEEDED(IGameInput_GetCurrentReading(data->pGameInput, GameInputKindKeyboard, device->pDevice, &reading))) { + GAMEINPUT_InitialKeyboardReading(data, window, device, reading); + device->last_keyboard_reading = reading; + } + } + } + } + } + } + SDL_UnlockMutex(data->lock); +} + +bool WIN_UpdateGameInputEnabled(SDL_VideoDevice *_this) +{ + WIN_GameInputData *data = _this->internal->gameinput_context; + bool raw_mouse_enabled = _this->internal->raw_mouse_enabled; + bool raw_keyboard_enabled = _this->internal->raw_keyboard_enabled; + + SDL_LockMutex(data->lock); + { + data->enabled_input = (raw_mouse_enabled ? GameInputKindMouse : GameInputKindUnknown) | + (raw_keyboard_enabled ? GameInputKindKeyboard : GameInputKindUnknown); + + // Reset input if not enabled + for (int i = 0; i < data->num_devices; ++i) { + GAMEINPUT_Device *device = data->devices[i]; + + if (device->last_mouse_reading && !raw_mouse_enabled) { + IGameInputReading_Release(device->last_mouse_reading); + device->last_mouse_reading = NULL; + } + + if (device->last_keyboard_reading && !raw_keyboard_enabled) { + IGameInputReading_Release(device->last_keyboard_reading); + device->last_keyboard_reading = NULL; + } + } + } + SDL_UnlockMutex(data->lock); + + return true; +} + +void WIN_QuitGameInput(SDL_VideoDevice *_this) +{ + WIN_GameInputData *data = _this->internal->gameinput_context; + + if (!data) { + return; + } + + if (data->pGameInput) { + // free the callback + if (data->gameinput_callback_token != GAMEINPUT_INVALID_CALLBACK_TOKEN_VALUE) { + IGameInput_UnregisterCallback(data->pGameInput, data->gameinput_callback_token, /*timeoutInUs:*/ 10000); + data->gameinput_callback_token = GAMEINPUT_INVALID_CALLBACK_TOKEN_VALUE; + } + + // free the list + while (data->num_devices > 0) { + GAMEINPUT_InternalRemoveByIndex(data, 0); + } + + IGameInput_Release(data->pGameInput); + data->pGameInput = NULL; + } + + if (data->pGameInput) { + SDL_QuitGameInput(); + data->pGameInput = NULL; + } + + if (data->lock) { + SDL_DestroyMutex(data->lock); + data->lock = NULL; + } + + SDL_free(data); + _this->internal->gameinput_context = NULL; +} + +#else // !HAVE_GAMEINPUT_H + +bool WIN_InitGameInput(SDL_VideoDevice* _this) +{ + return SDL_Unsupported(); +} + +bool WIN_UpdateGameInputEnabled(SDL_VideoDevice *_this) +{ + return SDL_Unsupported(); +} + +void WIN_UpdateGameInput(SDL_VideoDevice* _this) +{ + return; +} + +void WIN_QuitGameInput(SDL_VideoDevice* _this) +{ + return; +} + +#endif // HAVE_GAMEINPUT_H diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.h new file mode 100644 index 0000000..561de9c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsgameinput.h @@ -0,0 +1,29 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +typedef struct WIN_GameInputData WIN_GameInputData; + +extern bool WIN_InitGameInput(SDL_VideoDevice *_this); +extern bool WIN_UpdateGameInputEnabled(SDL_VideoDevice *_this); +extern void WIN_UpdateGameInput(SDL_VideoDevice *_this); +extern void WIN_QuitGameInput(SDL_VideoDevice *_this); + diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.c new file mode 100644 index 0000000..75e8ad4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.c @@ -0,0 +1,1145 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsvideo.h" + +#include "../../events/SDL_keyboard_c.h" +#include "../../events/scancodes_windows.h" + +#include +#include + +#ifndef SDL_DISABLE_WINDOWS_IME +#if 0 +#define SDL_DebugIMELog SDL_Log +#else +#define SDL_DebugIMELog(...) +#endif +static bool IME_Init(SDL_VideoData *videodata, SDL_Window *window); +static void IME_Enable(SDL_VideoData *videodata, HWND hwnd); +static void IME_Disable(SDL_VideoData *videodata, HWND hwnd); +static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_Rect *rect, int cursor); +static void IME_ClearComposition(SDL_VideoData *videodata); +static void IME_GetCandidateList(SDL_VideoData *videodata, HWND hwnd); +static void IME_Quit(SDL_VideoData *videodata); +#else +static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_Rect *rect, int cursor); +#endif // !SDL_DISABLE_WINDOWS_IME + +#ifndef MAPVK_VK_TO_VSC +#define MAPVK_VK_TO_VSC 0 +#endif +#ifndef MAPVK_VSC_TO_VK +#define MAPVK_VSC_TO_VK 1 +#endif + +// Alphabetic scancodes for PC keyboards +void WIN_InitKeyboard(SDL_VideoDevice *_this) +{ +#ifndef SDL_DISABLE_WINDOWS_IME + SDL_VideoData *data = _this->internal; + + data->ime_candlistindexbase = 1; + data->ime_composition_length = 32 * sizeof(WCHAR); + data->ime_composition = (WCHAR *)SDL_calloc(data->ime_composition_length, sizeof(WCHAR)); +#endif // !SDL_DISABLE_WINDOWS_IME + + WIN_UpdateKeymap(false); + + SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); + SDL_SetScancodeName(SDL_SCANCODE_LGUI, "Left Windows"); + SDL_SetScancodeName(SDL_SCANCODE_RGUI, "Right Windows"); + + // Are system caps/num/scroll lock active? Set our state to match. + SDL_ToggleModState(SDL_KMOD_CAPS, (GetKeyState(VK_CAPITAL) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_NUM, (GetKeyState(VK_NUMLOCK) & 0x0001) ? true : false); + SDL_ToggleModState(SDL_KMOD_SCROLL, (GetKeyState(VK_SCROLL) & 0x0001) ? true : false); +} + +void WIN_UpdateKeymap(bool send_event) +{ + SDL_Scancode scancode; + SDL_Keymap *keymap; + BYTE keyboardState[256] = { 0 }; + WCHAR buffer[16]; + SDL_Keymod mods[] = { + SDL_KMOD_NONE, + SDL_KMOD_SHIFT, + SDL_KMOD_CAPS, + (SDL_KMOD_SHIFT | SDL_KMOD_CAPS), + SDL_KMOD_MODE, + (SDL_KMOD_MODE | SDL_KMOD_SHIFT), + (SDL_KMOD_MODE | SDL_KMOD_CAPS), + (SDL_KMOD_MODE | SDL_KMOD_SHIFT | SDL_KMOD_CAPS) + }; + + WIN_ResetDeadKeys(); + + keymap = SDL_CreateKeymap(); + + for (int m = 0; m < SDL_arraysize(mods); ++m) { + for (int i = 0; i < SDL_arraysize(windows_scancode_table); i++) { + int vk, sc, result; + Uint32 *ch = 0; + + // Make sure this scancode is a valid character scancode + scancode = windows_scancode_table[i]; + if (scancode == SDL_SCANCODE_UNKNOWN || + scancode == SDL_SCANCODE_DELETE || + (SDL_GetKeymapKeycode(NULL, scancode, SDL_KMOD_NONE) & SDLK_SCANCODE_MASK)) { + + // The Colemak mapping swaps Backspace and CapsLock + if (mods[m] == SDL_KMOD_NONE && + (scancode == SDL_SCANCODE_CAPSLOCK || + scancode == SDL_SCANCODE_BACKSPACE)) { + vk = LOBYTE(MapVirtualKey(i, MAPVK_VSC_TO_VK)); + if (vk == VK_CAPITAL) { + SDL_SetKeymapEntry(keymap, scancode, mods[m], SDLK_CAPSLOCK); + } else if (vk == VK_BACK) { + SDL_SetKeymapEntry(keymap, scancode, mods[m], SDLK_BACKSPACE); + } + } + continue; + } + + // Unpack the single byte index to make the scan code. + sc = MAKEWORD(i & 0x7f, (i & 0x80) ? 0xe0 : 0x00); + vk = LOBYTE(MapVirtualKey(sc, MAPVK_VSC_TO_VK)); + if (!vk) { + continue; + } + + // Update the keyboard state for the modifiers + keyboardState[VK_SHIFT] = (mods[m] & SDL_KMOD_SHIFT) ? 0x80 : 0x00; + keyboardState[VK_CAPITAL] = (mods[m] & SDL_KMOD_CAPS) ? 0x01 : 0x00; + keyboardState[VK_CONTROL] = (mods[m] & SDL_KMOD_MODE) ? 0x80 : 0x00; + keyboardState[VK_MENU] = (mods[m] & SDL_KMOD_MODE) ? 0x80 : 0x00; + + result = ToUnicode(vk, sc, keyboardState, buffer, 16, 0); + buffer[SDL_abs(result)] = 0; + + // Convert UTF-16 to UTF-32 code points + ch = (Uint32 *)SDL_iconv_string("UTF-32LE", "UTF-16LE", (const char *)buffer, (SDL_abs(result) + 1) * sizeof(WCHAR)); + if (ch) { + /* Windows keyboard layouts can emit several UTF-32 code points on a single key press. + * Use since we cannot fit into single SDL_Keycode value in SDL keymap. + * See https://kbdlayout.info/features/ligatures for a list of such keys. */ + SDL_SetKeymapEntry(keymap, scancode, mods[m], ch[1] == 0 ? ch[0] : 0xfffd); + SDL_free(ch); + } else { + // The default keymap doesn't have any SDL_KMOD_MODE entries, so we don't need to override them + if (!(mods[m] & SDL_KMOD_MODE)) { + SDL_SetKeymapEntry(keymap, scancode, mods[m], SDLK_UNKNOWN); + } + } + + if (result < 0) { + WIN_ResetDeadKeys(); + } + } + } + + SDL_SetKeymap(keymap, send_event); +} + +void WIN_QuitKeyboard(SDL_VideoDevice *_this) +{ +#ifndef SDL_DISABLE_WINDOWS_IME + SDL_VideoData *data = _this->internal; + + IME_Quit(data); + + if (data->ime_composition) { + SDL_free(data->ime_composition); + data->ime_composition = NULL; + } +#endif // !SDL_DISABLE_WINDOWS_IME +} + +void WIN_ResetDeadKeys(void) +{ + /* + if a deadkey has been typed, but not the next character (which the deadkey might modify), + this tries to undo the effect pressing the deadkey. + see: http://archives.miloush.net/michkap/archive/2006/09/10/748775.html + */ + BYTE keyboardState[256]; + WCHAR buffer[16]; + int vk, sc, result, i; + + if (!GetKeyboardState(keyboardState)) { + return; + } + + vk = VK_SPACE; + sc = MapVirtualKey(vk, MAPVK_VK_TO_VSC); + if (sc == 0) { + // the keyboard doesn't have this key + return; + } + + for (i = 0; i < 5; i++) { + result = ToUnicode(vk, sc, keyboardState, buffer, 16, 0); + if (result > 0) { + // success + return; + } + } +} + +bool WIN_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + WIN_ResetDeadKeys(); + +#ifndef SDL_DISABLE_WINDOWS_IME + HWND hwnd = window->internal->hwnd; + SDL_VideoData *videodata = _this->internal; + IME_Init(videodata, window); + IME_Enable(videodata, hwnd); + + WIN_UpdateTextInputArea(_this, window); +#endif // !SDL_DISABLE_WINDOWS_IME + + return true; +} + +bool WIN_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + WIN_ResetDeadKeys(); + +#ifndef SDL_DISABLE_WINDOWS_IME + HWND hwnd = window->internal->hwnd; + SDL_VideoData *videodata = _this->internal; + IME_Init(videodata, window); + IME_Disable(videodata, hwnd); +#endif // !SDL_DISABLE_WINDOWS_IME + + return true; +} + +bool WIN_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = _this->internal; + SDL_WindowData *data = window->internal; + + IME_SetTextInputArea(videodata, data->hwnd, &window->text_input_rect, window->text_input_cursor); + return true; +} + +bool WIN_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifndef SDL_DISABLE_WINDOWS_IME + SDL_VideoData *videodata = _this->internal; + + IME_ClearComposition(videodata); +#endif + return true; +} + +#ifdef SDL_DISABLE_WINDOWS_IME + +bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata) +{ + return false; +} + +void WIN_UpdateIMECandidates(SDL_VideoDevice *_this) +{ + return; +} + +#else + +#define LANG_CHT MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL) +#define LANG_CHS MAKELANGID(LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED) + +#define MAKEIMEVERSION(major, minor) ((DWORD)(((BYTE)(major) << 24) | ((BYTE)(minor) << 16))) +#define IMEID_VER(id) ((id)&0xffff0000) +#define IMEID_LANG(id) ((id)&0x0000ffff) + +#define CHT_HKL_DAYI ((HKL)(UINT_PTR)0xE0060404) +#define CHT_HKL_NEW_PHONETIC ((HKL)(UINT_PTR)0xE0080404) +#define CHT_HKL_NEW_CHANG_JIE ((HKL)(UINT_PTR)0xE0090404) +#define CHT_HKL_NEW_QUICK ((HKL)(UINT_PTR)0xE00A0404) +#define CHT_HKL_HK_CANTONESE ((HKL)(UINT_PTR)0xE00B0404) +#define CHT_IMEFILENAME1 "TINTLGNT.IME" +#define CHT_IMEFILENAME2 "CINTLGNT.IME" +#define CHT_IMEFILENAME3 "MSTCIPHA.IME" +#define IMEID_CHT_VER42 (LANG_CHT | MAKEIMEVERSION(4, 2)) +#define IMEID_CHT_VER43 (LANG_CHT | MAKEIMEVERSION(4, 3)) +#define IMEID_CHT_VER44 (LANG_CHT | MAKEIMEVERSION(4, 4)) +#define IMEID_CHT_VER50 (LANG_CHT | MAKEIMEVERSION(5, 0)) +#define IMEID_CHT_VER51 (LANG_CHT | MAKEIMEVERSION(5, 1)) +#define IMEID_CHT_VER52 (LANG_CHT | MAKEIMEVERSION(5, 2)) +#define IMEID_CHT_VER60 (LANG_CHT | MAKEIMEVERSION(6, 0)) +#define IMEID_CHT_VER_VISTA (LANG_CHT | MAKEIMEVERSION(7, 0)) + +#define CHS_HKL ((HKL)(UINT_PTR)0xE00E0804) +#define CHS_IMEFILENAME1 "PINTLGNT.IME" +#define CHS_IMEFILENAME2 "MSSCIPYA.IME" +#define IMEID_CHS_VER41 (LANG_CHS | MAKEIMEVERSION(4, 1)) +#define IMEID_CHS_VER42 (LANG_CHS | MAKEIMEVERSION(4, 2)) +#define IMEID_CHS_VER53 (LANG_CHS | MAKEIMEVERSION(5, 3)) + +#define LANG() LOWORD((videodata->ime_hkl)) +#define PRIMLANG() ((WORD)PRIMARYLANGID(LANG())) +#define SUBLANG() SUBLANGID(LANG()) + +static void IME_UpdateInputLocale(SDL_VideoData *videodata); +static void IME_SetWindow(SDL_VideoData *videodata, SDL_Window *window); +static void IME_SetupAPI(SDL_VideoData *videodata); +static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex); +static void IME_SendEditingEvent(SDL_VideoData *videodata); +static void IME_SendClearComposition(SDL_VideoData *videodata); + +static bool IME_Init(SDL_VideoData *videodata, SDL_Window *window) +{ + HWND hwnd = window->internal->hwnd; + + if (videodata->ime_initialized) { + return true; + } + + const char *hint = SDL_GetHint(SDL_HINT_IME_IMPLEMENTED_UI); + if (hint && SDL_strstr(hint, "composition")) { + videodata->ime_internal_composition = true; + } + if (hint && SDL_strstr(hint, "candidates")) { + videodata->ime_internal_candidates = true; + } + + videodata->ime_hwnd_main = hwnd; + videodata->ime_initialized = true; + videodata->ime_himm32 = SDL_LoadObject("imm32.dll"); + if (!videodata->ime_himm32) { + videodata->ime_available = false; + SDL_ClearError(); + return true; + } + /* *INDENT-OFF* */ // clang-format off + videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC"); + videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC"); + videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC"); + videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC"); + /* *INDENT-ON* */ // clang-format on + + IME_SetWindow(videodata, window); + videodata->ime_himc = ImmGetContext(hwnd); + ImmReleaseContext(hwnd, videodata->ime_himc); + if (!videodata->ime_himc) { + videodata->ime_available = false; + IME_Disable(videodata, hwnd); + return true; + } + videodata->ime_available = true; + IME_UpdateInputLocale(videodata); + IME_SetupAPI(videodata); + IME_UpdateInputLocale(videodata); + IME_Disable(videodata, hwnd); + return true; +} + +static void IME_Enable(SDL_VideoData *videodata, HWND hwnd) +{ + if (!videodata->ime_initialized || !videodata->ime_hwnd_current) { + return; + } + + if (!videodata->ime_available) { + IME_Disable(videodata, hwnd); + return; + } + if (videodata->ime_hwnd_current == videodata->ime_hwnd_main) { + ImmAssociateContext(videodata->ime_hwnd_current, videodata->ime_himc); + } + + videodata->ime_enabled = true; + IME_UpdateInputLocale(videodata); +} + +static void IME_Disable(SDL_VideoData *videodata, HWND hwnd) +{ + if (!videodata->ime_initialized || !videodata->ime_hwnd_current) { + return; + } + + IME_ClearComposition(videodata); + if (videodata->ime_hwnd_current == videodata->ime_hwnd_main) { + ImmAssociateContext(videodata->ime_hwnd_current, (HIMC)0); + } + + videodata->ime_enabled = false; +} + +static void IME_Quit(SDL_VideoData *videodata) +{ + if (!videodata->ime_initialized) { + return; + } + + if (videodata->ime_hwnd_main) { + ImmAssociateContext(videodata->ime_hwnd_main, videodata->ime_himc); + } + + videodata->ime_hwnd_main = 0; + videodata->ime_himc = 0; + if (videodata->ime_himm32) { + SDL_UnloadObject(videodata->ime_himm32); + videodata->ime_himm32 = 0; + } + for (int i = 0; i < videodata->ime_candcount; ++i) { + SDL_free(videodata->ime_candidates[i]); + videodata->ime_candidates[i] = NULL; + } + videodata->ime_initialized = false; +} + +static void IME_GetReadingString(SDL_VideoData *videodata, HWND hwnd) +{ + DWORD id = 0; + HIMC himc = 0; + WCHAR buffer[16]; + WCHAR *s = buffer; + DWORD len = 0; + INT err = 0; + BOOL vertical = FALSE; + UINT maxuilen = 0; + + videodata->ime_readingstring[0] = 0; + + id = IME_GetId(videodata, 0); + if (!id) { + return; + } + + himc = ImmGetContext(hwnd); + if (!himc) { + return; + } + + if (videodata->GetReadingString) { + len = videodata->GetReadingString(himc, 0, 0, &err, &vertical, &maxuilen); + if (len) { + if (len > SDL_arraysize(buffer)) { + len = SDL_arraysize(buffer); + } + + len = videodata->GetReadingString(himc, len, s, &err, &vertical, &maxuilen); + } + SDL_wcslcpy(videodata->ime_readingstring, s, len); + } else { + LPINPUTCONTEXT2 lpimc = videodata->ImmLockIMC(himc); + LPBYTE p = 0; + s = 0; + switch (id) { + case IMEID_CHT_VER42: + case IMEID_CHT_VER43: + case IMEID_CHT_VER44: + p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 24); + if (!p) { + break; + } + + len = *(DWORD *)(p + 7 * 4 + 32 * 4); + s = (WCHAR *)(p + 56); + break; + case IMEID_CHT_VER51: + case IMEID_CHT_VER52: + case IMEID_CHS_VER53: + p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 4); + if (!p) { + break; + } + + p = *(LPBYTE *)(p + 1 * 4 + 5 * 4); + if (!p) { + break; + } + + len = *(DWORD *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4 + 16 * 2); + s = (WCHAR *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4); + break; + case IMEID_CHS_VER41: + { + int offset = (IME_GetId(videodata, 1) >= 0x00000002) ? 8 : 7; + p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + offset * 4); + if (!p) { + break; + } + + len = *(DWORD *)(p + 7 * 4 + 16 * 2 * 4); + s = (WCHAR *)(p + 6 * 4 + 16 * 2 * 1); + } break; + case IMEID_CHS_VER42: + p = *(LPBYTE *)((LPBYTE)videodata->ImmLockIMCC(lpimc->hPrivate) + 1 * 4 + 1 * 4 + 6 * 4); + if (!p) { + break; + } + + len = *(DWORD *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4 + 16 * 2); + s = (WCHAR *)(p + 1 * 4 + (16 * 2 + 2 * 4) + 5 * 4); + break; + } + if (s) { + size_t size = SDL_min((size_t)(len + 1), SDL_arraysize(videodata->ime_readingstring)); + SDL_wcslcpy(videodata->ime_readingstring, s, size); + } + + videodata->ImmUnlockIMCC(lpimc->hPrivate); + videodata->ImmUnlockIMC(himc); + } + ImmReleaseContext(hwnd, himc); + IME_SendEditingEvent(videodata); +} + +static void IME_InputLangChanged(SDL_VideoData *videodata) +{ + UINT lang = PRIMLANG(); + IME_UpdateInputLocale(videodata); + + IME_SetupAPI(videodata); + if (lang != PRIMLANG()) { + IME_ClearComposition(videodata); + } +} + +static DWORD IME_GetId(SDL_VideoData *videodata, UINT uIndex) +{ + static HKL hklprev = 0; + static DWORD dwRet[2] = { 0 }; + DWORD dwVerSize = 0; + DWORD dwVerHandle = 0; + LPVOID lpVerBuffer = 0; + LPVOID lpVerData = 0; + UINT cbVerData = 0; + char szTemp[256]; + HKL hkl = 0; + DWORD dwLang = 0; + SDL_assert(uIndex < sizeof(dwRet) / sizeof(dwRet[0])); + + hkl = videodata->ime_hkl; + if (hklprev == hkl) { + return dwRet[uIndex]; + } + hklprev = hkl; + + SDL_assert(uIndex == 0); + dwLang = ((DWORD_PTR)hkl & 0xffff); + // FIXME: What does this do? + if (videodata->ime_internal_candidates && dwLang == LANG_CHT) { + dwRet[0] = IMEID_CHT_VER_VISTA; + dwRet[1] = 0; + return dwRet[0]; + } + if (hkl != CHT_HKL_NEW_PHONETIC && hkl != CHT_HKL_NEW_CHANG_JIE && hkl != CHT_HKL_NEW_QUICK && hkl != CHT_HKL_HK_CANTONESE && hkl != CHS_HKL) { + dwRet[0] = dwRet[1] = 0; + return dwRet[0]; + } + if (!ImmGetIMEFileNameA(hkl, szTemp, sizeof(szTemp) - 1)) { + dwRet[0] = dwRet[1] = 0; + return dwRet[0]; + } + if (!videodata->GetReadingString) { +#define LCID_INVARIANT MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT) + if (CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME1, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME2, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHT_IMEFILENAME3, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME1, -1) != 2 && CompareStringA(LCID_INVARIANT, NORM_IGNORECASE, szTemp, -1, CHS_IMEFILENAME2, -1) != 2) { + dwRet[0] = dwRet[1] = 0; + return dwRet[0]; + } +#undef LCID_INVARIANT + dwVerSize = GetFileVersionInfoSizeA(szTemp, &dwVerHandle); + if (dwVerSize) { + lpVerBuffer = SDL_malloc(dwVerSize); + if (lpVerBuffer) { + if (GetFileVersionInfoA(szTemp, dwVerHandle, dwVerSize, lpVerBuffer)) { + if (VerQueryValueA(lpVerBuffer, "\\", &lpVerData, &cbVerData)) { +#define pVerFixedInfo ((VS_FIXEDFILEINFO FAR *)lpVerData) + DWORD dwVer = pVerFixedInfo->dwFileVersionMS; + dwVer = (dwVer & 0x00ff0000) << 8 | (dwVer & 0x000000ff) << 16; + if ((videodata->GetReadingString) || + ((dwLang == LANG_CHT) && (dwVer == MAKEIMEVERSION(4, 2) || + dwVer == MAKEIMEVERSION(4, 3) || + dwVer == MAKEIMEVERSION(4, 4) || + dwVer == MAKEIMEVERSION(5, 0) || + dwVer == MAKEIMEVERSION(5, 1) || + dwVer == MAKEIMEVERSION(5, 2) || + dwVer == MAKEIMEVERSION(6, 0))) || + ((dwLang == LANG_CHS) && (dwVer == MAKEIMEVERSION(4, 1) || + dwVer == MAKEIMEVERSION(4, 2) || + dwVer == MAKEIMEVERSION(5, 3)))) { + dwRet[0] = dwVer | dwLang; + dwRet[1] = pVerFixedInfo->dwFileVersionLS; + SDL_free(lpVerBuffer); + return dwRet[0]; + } +#undef pVerFixedInfo + } + } + } + SDL_free(lpVerBuffer); + } + } + dwRet[0] = dwRet[1] = 0; + return dwRet[0]; +} + +static void IME_SetupAPI(SDL_VideoData *videodata) +{ + char ime_file[MAX_PATH + 1]; + SDL_SharedObject *hime = 0; + HKL hkl = 0; + videodata->GetReadingString = NULL; + videodata->ShowReadingWindow = NULL; + + hkl = videodata->ime_hkl; + if (!ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1)) { + return; + } + + hime = SDL_LoadObject(ime_file); + if (!hime) { + return; + } + + /* *INDENT-OFF* */ // clang-format off + videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT)) + SDL_LoadFunction(hime, "GetReadingString"); + videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL)) + SDL_LoadFunction(hime, "ShowReadingWindow"); + /* *INDENT-ON* */ // clang-format on + + if (videodata->ShowReadingWindow) { + HIMC himc = ImmGetContext(videodata->ime_hwnd_current); + if (himc) { + videodata->ShowReadingWindow(himc, FALSE); + ImmReleaseContext(videodata->ime_hwnd_current, himc); + } + } +} + +static void IME_SetWindow(SDL_VideoData *videodata, SDL_Window *window) +{ + HWND hwnd = window->internal->hwnd; + + if (hwnd != videodata->ime_hwnd_current) { + videodata->ime_hwnd_current = hwnd; + SDL_zero(videodata->ime_composition_area); + SDL_zero(videodata->ime_candidate_area); + } + + IME_SetTextInputArea(videodata, hwnd, &window->text_input_rect, window->text_input_cursor); +} + +#endif + +static void IME_SetTextInputArea(SDL_VideoData *videodata, HWND hwnd, const SDL_Rect *rect, int cursor) +{ + HIMC himc; + + himc = ImmGetContext(hwnd); + if (himc) { + COMPOSITIONFORM cof; + CANDIDATEFORM caf; + int font_height = rect->h; + + LOGFONTW font; + if (ImmGetCompositionFontW(himc, &font)) { + font_height = font.lfHeight; + } + + SDL_zero(cof); + cof.dwStyle = CFS_RECT; + cof.ptCurrentPos.x = rect->x + cursor; + cof.ptCurrentPos.y = rect->y + (rect->h - font_height) / 2; + cof.rcArea.left = rect->x; + cof.rcArea.right = (LONG)rect->x + rect->w; + cof.rcArea.top = rect->y; + cof.rcArea.bottom = (LONG)rect->y + rect->h; + if (SDL_memcmp(&cof, &videodata->ime_composition_area, sizeof(cof)) != 0) { + SDL_copyp(&videodata->ime_composition_area, &cof); + ImmSetCompositionWindow(himc, &cof); + } + + SDL_zero(caf); + caf.dwIndex = 0; + caf.dwStyle = CFS_EXCLUDE; + caf.ptCurrentPos.x = rect->x + cursor; + caf.ptCurrentPos.y = rect->y; + caf.rcArea.left = rect->x; + caf.rcArea.right = (LONG)rect->x + rect->w; + caf.rcArea.top = rect->y; + caf.rcArea.bottom = (LONG)rect->y + rect->h; + if (SDL_memcmp(&caf, &videodata->ime_candidate_area, sizeof(caf)) != 0) { + SDL_copyp(&videodata->ime_candidate_area, &caf); + ImmSetCandidateWindow(himc, &caf); + } + + ImmReleaseContext(hwnd, himc); + } +} + +#ifndef SDL_DISABLE_WINDOWS_IME + +static void IME_UpdateInputLocale(SDL_VideoData *videodata) +{ + HKL hklnext = GetKeyboardLayout(0); + + if (hklnext == videodata->ime_hkl) { + return; + } + + videodata->ime_hkl = hklnext; + videodata->ime_horizontal_candidates = (PRIMLANG() == LANG_KOREAN || LANG() == LANG_CHS); + videodata->ime_candlistindexbase = (videodata->ime_hkl == CHT_HKL_DAYI) ? 0 : 1; +} + +static void IME_ClearComposition(SDL_VideoData *videodata) +{ + HIMC himc = 0; + if (!videodata->ime_initialized) { + return; + } + + himc = ImmGetContext(videodata->ime_hwnd_current); + if (!himc) { + return; + } + + ImmNotifyIME(himc, NI_COMPOSITIONSTR, CPS_CANCEL, 0); + ImmSetCompositionString(himc, SCS_SETSTR, TEXT(""), sizeof(TCHAR), TEXT(""), sizeof(TCHAR)); + + ImmNotifyIME(himc, NI_CLOSECANDIDATE, 0, 0); + ImmReleaseContext(videodata->ime_hwnd_current, himc); + IME_SendClearComposition(videodata); +} + +static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD string) +{ + LONG length; + DWORD dwLang = ((DWORD_PTR)videodata->ime_hkl & 0xffff); + + videodata->ime_cursor = LOWORD(ImmGetCompositionStringW(himc, GCS_CURSORPOS, 0, 0)); + videodata->ime_selected_start = 0; + videodata->ime_selected_length = 0; + SDL_DebugIMELog("Cursor = %d", videodata->ime_cursor); + + length = ImmGetCompositionStringW(himc, string, NULL, 0); + if (length > 0 && videodata->ime_composition_length < length) { + if (videodata->ime_composition) { + SDL_free(videodata->ime_composition); + } + + videodata->ime_composition = (WCHAR *)SDL_malloc(length + sizeof(WCHAR)); + videodata->ime_composition_length = length; + } + + length = ImmGetCompositionStringW(himc, string, videodata->ime_composition, videodata->ime_composition_length); + if (length < 0) { + length = 0; + } + length /= sizeof(WCHAR); + + if ((dwLang == LANG_CHT || dwLang == LANG_CHS) && + videodata->ime_cursor > 0 && + videodata->ime_cursor < (int)(videodata->ime_composition_length / sizeof(WCHAR)) && + (videodata->ime_composition[0] == 0x3000 || videodata->ime_composition[0] == 0x0020)) { + // Traditional Chinese IMEs add a placeholder U+3000 + // Simplified Chinese IMEs seem to add a placeholder U+0020 sometimes + for (int i = videodata->ime_cursor + 1; i < length; ++i) { + videodata->ime_composition[i - 1] = videodata->ime_composition[i]; + } + --length; + } + + videodata->ime_composition[length] = 0; + + length = ImmGetCompositionStringW(himc, GCS_COMPATTR, NULL, 0); + if (length > 0) { + Uint8 *attributes = (Uint8 *)SDL_malloc(length); + if (attributes) { + int start = 0; + int end = 0; + + length = ImmGetCompositionString(himc, GCS_COMPATTR, attributes, length); + if (length < 0) { + length = 0; + } + + for (LONG i = 0; i < length; ++i) { + SDL_DebugIMELog("attrib[%d] = %d", i, attributes[i]); + } + + for (start = 0; start < length; ++start) { + if (attributes[start] == ATTR_TARGET_CONVERTED || attributes[start] == ATTR_TARGET_NOTCONVERTED) { + break; + } + } + + for (end = start; end < length; ++end) { + if (attributes[end] != ATTR_TARGET_CONVERTED && attributes[end] != ATTR_TARGET_NOTCONVERTED) { + break; + } + } + + if (end > start) { + videodata->ime_selected_start = start; + videodata->ime_selected_length = end - start; + } + + SDL_free(attributes); + } + } +} + +static void IME_SendInputEvent(SDL_VideoData *videodata) +{ + char *s = 0; + s = WIN_StringToUTF8W(videodata->ime_composition); + SDL_SendKeyboardText(s); + SDL_free(s); + + videodata->ime_composition[0] = 0; + videodata->ime_readingstring[0] = 0; + videodata->ime_cursor = 0; +} + +static void IME_SendEditingEvent(SDL_VideoData *videodata) +{ + char *s = NULL; + WCHAR *buffer = NULL; + size_t size = videodata->ime_composition_length; + if (videodata->ime_readingstring[0]) { + size_t len = SDL_min(SDL_wcslen(videodata->ime_composition), (size_t)videodata->ime_cursor); + + size += sizeof(videodata->ime_readingstring); + buffer = (WCHAR *)SDL_malloc(size + sizeof(WCHAR)); + if (!buffer) { + return; + } + buffer[0] = 0; + + SDL_wcslcpy(buffer, videodata->ime_composition, len + 1); + SDL_wcslcat(buffer, videodata->ime_readingstring, size); + SDL_wcslcat(buffer, &videodata->ime_composition[len], size); + } else { + buffer = (WCHAR *)SDL_malloc(size + sizeof(WCHAR)); + if (!buffer) { + return; + } + buffer[0] = 0; + SDL_wcslcpy(buffer, videodata->ime_composition, size); + } + + s = WIN_StringToUTF8W(buffer); + if (s) { + if (videodata->ime_readingstring[0]) { + SDL_SendEditingText(s, videodata->ime_cursor, (int)SDL_wcslen(videodata->ime_readingstring)); + } else if (videodata->ime_cursor == videodata->ime_selected_start) { + SDL_SendEditingText(s, videodata->ime_selected_start, videodata->ime_selected_length); + } else { + SDL_SendEditingText(s, videodata->ime_cursor, 0); + } + if (*s) { + videodata->ime_needs_clear_composition = true; + } + SDL_free(s); + } + SDL_free(buffer); +} + +static void IME_SendClearComposition(SDL_VideoData *videodata) +{ + if (videodata->ime_needs_clear_composition) { + SDL_SendEditingText("", 0, 0); + videodata->ime_needs_clear_composition = false; + } +} + +static bool IME_OpenCandidateList(SDL_VideoData *videodata) +{ + videodata->ime_candidates_open = true; + videodata->ime_candcount = 0; + return true; +} + +static void IME_AddCandidate(SDL_VideoData *videodata, UINT i, LPCWSTR candidate) +{ + if (videodata->ime_candidates[i]) { + SDL_free(videodata->ime_candidates[i]); + videodata->ime_candidates[i] = NULL; + } + + SDL_COMPILE_TIME_ASSERT(IME_CANDIDATE_INDEXING_REQUIRES, MAX_CANDLIST == 10); + char *candidate_utf8 = WIN_StringToUTF8W(candidate); + SDL_asprintf(&videodata->ime_candidates[i], "%d %s", ((i + videodata->ime_candlistindexbase) % 10), candidate_utf8); + SDL_free(candidate_utf8); + + videodata->ime_candcount = (i + 1); +} + +static void IME_SendCandidateList(SDL_VideoData *videodata) +{ + SDL_SendEditingTextCandidates(videodata->ime_candidates, videodata->ime_candcount, videodata->ime_candsel, videodata->ime_horizontal_candidates); +} + +static void IME_CloseCandidateList(SDL_VideoData *videodata) +{ + videodata->ime_candidates_open = false; + + if (videodata->ime_candcount > 0) { + for (int i = 0; i < videodata->ime_candcount; ++i) { + SDL_free(videodata->ime_candidates[i]); + videodata->ime_candidates[i] = NULL; + } + videodata->ime_candcount = 0; + + SDL_SendEditingTextCandidates(NULL, 0, -1, false); + } +} + +static void IME_GetCandidateList(SDL_VideoData *videodata, HWND hwnd) +{ + HIMC himc; + DWORD size; + LPCANDIDATELIST cand_list; + bool has_candidates = false; + + himc = ImmGetContext(hwnd); + if (himc) { + size = ImmGetCandidateListW(himc, 0, NULL, 0); + if (size != 0) { + cand_list = (LPCANDIDATELIST)SDL_malloc(size); + if (cand_list != NULL) { + size = ImmGetCandidateListW(himc, 0, cand_list, size); + if (size != 0) { + if (IME_OpenCandidateList(videodata)) { + UINT i, j; + UINT page_start = 0; + UINT page_size = 0; + + videodata->ime_candsel = cand_list->dwSelection; + + if (LANG() == LANG_CHS && IME_GetId(videodata, 0)) { + const UINT maxcandchar = 18; + size_t cchars = 0; + + for (i = 0; i < cand_list->dwCount; ++i) { + size_t len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1; + if (len + cchars > maxcandchar) { + if (i > cand_list->dwSelection) { + break; + } + + page_start = i; + cchars = len; + } else { + cchars += len; + } + } + page_size = i - page_start; + } else { + page_size = SDL_min(cand_list->dwPageSize == 0 ? MAX_CANDLIST : cand_list->dwPageSize, MAX_CANDLIST); + page_start = (cand_list->dwSelection / page_size) * page_size; + } + for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < page_size; i++, j++) { + LPCWSTR candidate = (LPCWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i]); + IME_AddCandidate(videodata, j, candidate); + } + + has_candidates = true; + IME_SendCandidateList(videodata); + } + } + SDL_free(cand_list); + } + } + ImmReleaseContext(hwnd, himc); + } + + if (!has_candidates) { + IME_CloseCandidateList(videodata); + } +} + +bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata) +{ + bool trap = false; + HIMC himc = 0; + + if (msg == WM_IME_SETCONTEXT) { + SDL_DebugIMELog("WM_IME_SETCONTEXT"); + + LPARAM element_mask; + if (videodata->ime_internal_composition && videodata->ime_internal_candidates) { + element_mask = 0; + } else { + element_mask = ISC_SHOWUIALL; + if (videodata->ime_internal_composition) { + element_mask &= ~ISC_SHOWUICOMPOSITIONWINDOW; + } + if (videodata->ime_internal_candidates) { + element_mask &= ~ISC_SHOWUIALLCANDIDATEWINDOW; + } + } + *lParam &= element_mask; + + return false; + } + + if (!videodata->ime_initialized || !videodata->ime_available || !videodata->ime_enabled) { + return false; + } + + switch (msg) { + case WM_KEYDOWN: + if (wParam == VK_PROCESSKEY) { + SDL_DebugIMELog("WM_KEYDOWN VK_PROCESSKEY"); + trap = true; + } else { + SDL_DebugIMELog("WM_KEYDOWN normal"); + } + break; + case WM_INPUTLANGCHANGE: + SDL_DebugIMELog("WM_INPUTLANGCHANGE"); + IME_InputLangChanged(videodata); + break; + case WM_IME_STARTCOMPOSITION: + SDL_DebugIMELog("WM_IME_STARTCOMPOSITION"); + if (videodata->ime_internal_composition) { + trap = true; + } + break; + case WM_IME_COMPOSITION: + SDL_DebugIMELog("WM_IME_COMPOSITION %x", lParam); + if (videodata->ime_internal_composition) { + trap = true; + himc = ImmGetContext(hwnd); + if (*lParam & GCS_RESULTSTR) { + SDL_DebugIMELog("GCS_RESULTSTR"); + IME_GetCompositionString(videodata, himc, GCS_RESULTSTR); + IME_SendClearComposition(videodata); + IME_SendInputEvent(videodata); + } + if (*lParam & GCS_COMPSTR) { + SDL_DebugIMELog("GCS_COMPSTR"); + videodata->ime_readingstring[0] = 0; + IME_GetCompositionString(videodata, himc, GCS_COMPSTR); + IME_SendEditingEvent(videodata); + } + ImmReleaseContext(hwnd, himc); + } + break; + case WM_IME_ENDCOMPOSITION: + SDL_DebugIMELog("WM_IME_ENDCOMPOSITION"); + if (videodata->ime_internal_composition) { + trap = true; + videodata->ime_composition[0] = 0; + videodata->ime_readingstring[0] = 0; + videodata->ime_cursor = 0; + videodata->ime_selected_start = 0; + videodata->ime_selected_length = 0; + IME_SendClearComposition(videodata); + } + break; + case WM_IME_NOTIFY: + SDL_DebugIMELog("WM_IME_NOTIFY %x", wParam); + switch (wParam) { + case IMN_SETCOMPOSITIONWINDOW: + SDL_DebugIMELog("IMN_SETCOMPOSITIONWINDOW"); + break; + case IMN_SETCOMPOSITIONFONT: + SDL_DebugIMELog("IMN_SETCOMPOSITIONFONT"); + break; + case IMN_SETCANDIDATEPOS: + SDL_DebugIMELog("IMN_SETCANDIDATEPOS"); + break; + case IMN_SETCONVERSIONMODE: + case IMN_SETOPENSTATUS: + SDL_DebugIMELog("%s", wParam == IMN_SETCONVERSIONMODE ? "IMN_SETCONVERSIONMODE" : "IMN_SETOPENSTATUS"); + IME_UpdateInputLocale(videodata); + break; + case IMN_OPENCANDIDATE: + case IMN_CHANGECANDIDATE: + SDL_DebugIMELog("%s", wParam == IMN_OPENCANDIDATE ? "IMN_OPENCANDIDATE" : "IMN_CHANGECANDIDATE"); + if (videodata->ime_internal_candidates) { + trap = true; + videodata->ime_update_candidates = true; + } + break; + case IMN_CLOSECANDIDATE: + SDL_DebugIMELog("IMN_CLOSECANDIDATE"); + if (videodata->ime_internal_candidates) { + trap = true; + videodata->ime_update_candidates = false; + IME_CloseCandidateList(videodata); + } + break; + case IMN_PRIVATE: + { + DWORD dwId = IME_GetId(videodata, 0); + SDL_DebugIMELog("IMN_PRIVATE %u", dwId); + IME_GetReadingString(videodata, hwnd); + switch (dwId) { + case IMEID_CHT_VER42: + case IMEID_CHT_VER43: + case IMEID_CHT_VER44: + case IMEID_CHS_VER41: + case IMEID_CHS_VER42: + if (*lParam == 1 || *lParam == 2) { + trap = true; + } + + break; + case IMEID_CHT_VER50: + case IMEID_CHT_VER51: + case IMEID_CHT_VER52: + case IMEID_CHT_VER60: + case IMEID_CHS_VER53: + if (*lParam == 16 || *lParam == 17 || *lParam == 26 || *lParam == 27 || *lParam == 28) { + trap = true; + } + break; + } + } break; + default: + trap = true; + break; + } + break; + } + return trap; +} + +void WIN_UpdateIMECandidates(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + + if (videodata->ime_update_candidates) { + IME_GetCandidateList(videodata, videodata->ime_hwnd_current); + videodata->ime_update_candidates = false; + } +} + +#endif // SDL_DISABLE_WINDOWS_IME + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.h new file mode 100644 index 0000000..592da9d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowskeyboard.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowskeyboard_h_ +#define SDL_windowskeyboard_h_ + +extern void WIN_InitKeyboard(SDL_VideoDevice *_this); +extern void WIN_UpdateKeymap(bool send_event); +extern void WIN_QuitKeyboard(SDL_VideoDevice *_this); + +extern void WIN_ResetDeadKeys(void); + +extern bool WIN_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern bool WIN_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_ClearComposition(SDL_VideoDevice *_this, SDL_Window *window); + +extern bool WIN_HandleIMEMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata); +extern void WIN_UpdateIMECandidates(SDL_VideoDevice *_this); + +#endif // SDL_windowskeyboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.c new file mode 100644 index 0000000..c174e3d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.c @@ -0,0 +1,1086 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#ifdef HAVE_LIMITS_H +#include +#endif +#ifndef SIZE_MAX +#define SIZE_MAX ((size_t)-1) +#endif + +#include "../../core/windows/SDL_windows.h" + +#include "SDL_windowsvideo.h" + +#ifndef SS_EDITCONTROL +#define SS_EDITCONTROL 0x2000 +#endif + +#ifndef IDOK +#define IDOK 1 +#endif + +#ifndef IDCANCEL +#define IDCANCEL 2 +#endif + +// Custom dialog return codes +#define IDCLOSED 20 +#define IDINVALPTRINIT 50 +#define IDINVALPTRCOMMAND 51 +#define IDINVALPTRSETFOCUS 52 +#define IDINVALPTRDLGITEM 53 +// First button ID +#define IDBUTTONINDEX0 100 + +#define DLGITEMTYPEBUTTON 0x0080 +#define DLGITEMTYPESTATIC 0x0082 + +/* Windows only sends the lower 16 bits of the control ID when a button + * gets clicked. There are also some predefined and custom IDs that lower + * the available number further. 2^16 - 101 buttons should be enough for + * everyone, no need to make the code more complex. + */ +#define MAX_BUTTONS (0xffff - 100) + +// Display a Windows message box + +typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData); + +enum _TASKDIALOG_FLAGS +{ + TDF_ENABLE_HYPERLINKS = 0x0001, + TDF_USE_HICON_MAIN = 0x0002, + TDF_USE_HICON_FOOTER = 0x0004, + TDF_ALLOW_DIALOG_CANCELLATION = 0x0008, + TDF_USE_COMMAND_LINKS = 0x0010, + TDF_USE_COMMAND_LINKS_NO_ICON = 0x0020, + TDF_EXPAND_FOOTER_AREA = 0x0040, + TDF_EXPANDED_BY_DEFAULT = 0x0080, + TDF_VERIFICATION_FLAG_CHECKED = 0x0100, + TDF_SHOW_PROGRESS_BAR = 0x0200, + TDF_SHOW_MARQUEE_PROGRESS_BAR = 0x0400, + TDF_CALLBACK_TIMER = 0x0800, + TDF_POSITION_RELATIVE_TO_WINDOW = 0x1000, + TDF_RTL_LAYOUT = 0x2000, + TDF_NO_DEFAULT_RADIO_BUTTON = 0x4000, + TDF_CAN_BE_MINIMIZED = 0x8000, + // #if (NTDDI_VERSION >= NTDDI_WIN8) + TDF_NO_SET_FOREGROUND = 0x00010000, // Don't call SetForegroundWindow() when activating the dialog + // #endif // (NTDDI_VERSION >= NTDDI_WIN8) + TDF_SIZE_TO_CONTENT = 0x01000000 // used by ShellMessageBox to emulate MessageBox sizing behavior +}; +typedef int TASKDIALOG_FLAGS; // Note: _TASKDIALOG_FLAGS is an int + +typedef enum _TASKDIALOG_MESSAGES +{ + TDM_NAVIGATE_PAGE = WM_USER + 101, + TDM_CLICK_BUTTON = WM_USER + 102, // wParam = Button ID + TDM_SET_MARQUEE_PROGRESS_BAR = WM_USER + 103, // wParam = 0 (nonMarque) wParam != 0 (Marquee) + TDM_SET_PROGRESS_BAR_STATE = WM_USER + 104, // wParam = new progress state + TDM_SET_PROGRESS_BAR_RANGE = WM_USER + 105, // lParam = MAKELPARAM(nMinRange, nMaxRange) + TDM_SET_PROGRESS_BAR_POS = WM_USER + 106, // wParam = new position + TDM_SET_PROGRESS_BAR_MARQUEE = WM_USER + 107, // wParam = 0 (stop marquee), wParam != 0 (start marquee), lparam = speed (milliseconds between repaints) + TDM_SET_ELEMENT_TEXT = WM_USER + 108, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) + TDM_CLICK_RADIO_BUTTON = WM_USER + 110, // wParam = Radio Button ID + TDM_ENABLE_BUTTON = WM_USER + 111, // lParam = 0 (disable), lParam != 0 (enable), wParam = Button ID + TDM_ENABLE_RADIO_BUTTON = WM_USER + 112, // lParam = 0 (disable), lParam != 0 (enable), wParam = Radio Button ID + TDM_CLICK_VERIFICATION = WM_USER + 113, // wParam = 0 (unchecked), 1 (checked), lParam = 1 (set key focus) + TDM_UPDATE_ELEMENT_TEXT = WM_USER + 114, // wParam = element (TASKDIALOG_ELEMENTS), lParam = new element text (LPCWSTR) + TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE = WM_USER + 115, // wParam = Button ID, lParam = 0 (elevation not required), lParam != 0 (elevation required) + TDM_UPDATE_ICON = WM_USER + 116 // wParam = icon element (TASKDIALOG_ICON_ELEMENTS), lParam = new icon (hIcon if TDF_USE_HICON_* was set, PCWSTR otherwise) +} TASKDIALOG_MESSAGES; + +typedef enum _TASKDIALOG_NOTIFICATIONS +{ + TDN_CREATED = 0, + TDN_NAVIGATED = 1, + TDN_BUTTON_CLICKED = 2, // wParam = Button ID + TDN_HYPERLINK_CLICKED = 3, // lParam = (LPCWSTR)pszHREF + TDN_TIMER = 4, // wParam = Milliseconds since dialog created or timer reset + TDN_DESTROYED = 5, + TDN_RADIO_BUTTON_CLICKED = 6, // wParam = Radio Button ID + TDN_DIALOG_CONSTRUCTED = 7, + TDN_VERIFICATION_CLICKED = 8, // wParam = 1 if checkbox checked, 0 if not, lParam is unused and always 0 + TDN_HELP = 9, + TDN_EXPANDO_BUTTON_CLICKED = 10 // wParam = 0 (dialog is now collapsed), wParam != 0 (dialog is now expanded) +} TASKDIALOG_NOTIFICATIONS; + +typedef enum _TASKDIALOG_ELEMENTS +{ + TDE_CONTENT, + TDE_EXPANDED_INFORMATION, + TDE_FOOTER, + TDE_MAIN_INSTRUCTION +} TASKDIALOG_ELEMENTS; + +typedef enum _TASKDIALOG_ICON_ELEMENTS +{ + TDIE_ICON_MAIN, + TDIE_ICON_FOOTER +} TASKDIALOG_ICON_ELEMENTS; + +#define TD_WARNING_ICON MAKEINTRESOURCEW(-1) +#define TD_ERROR_ICON MAKEINTRESOURCEW(-2) +#define TD_INFORMATION_ICON MAKEINTRESOURCEW(-3) +#define TD_SHIELD_ICON MAKEINTRESOURCEW(-4) + +enum _TASKDIALOG_COMMON_BUTTON_FLAGS +{ + TDCBF_OK_BUTTON = 0x0001, // selected control return value IDOK + TDCBF_YES_BUTTON = 0x0002, // selected control return value IDYES + TDCBF_NO_BUTTON = 0x0004, // selected control return value IDNO + TDCBF_CANCEL_BUTTON = 0x0008, // selected control return value IDCANCEL + TDCBF_RETRY_BUTTON = 0x0010, // selected control return value IDRETRY + TDCBF_CLOSE_BUTTON = 0x0020 // selected control return value IDCLOSE +}; +typedef int TASKDIALOG_COMMON_BUTTON_FLAGS; // Note: _TASKDIALOG_COMMON_BUTTON_FLAGS is an int + +#pragma pack(push, 1) + +typedef struct _TASKDIALOG_BUTTON +{ + int nButtonID; + PCWSTR pszButtonText; +} TASKDIALOG_BUTTON; + +typedef struct _TASKDIALOGCONFIG +{ + UINT cbSize; + HWND hwndParent; // incorrectly named, this is the owner window, not a parent. + HINSTANCE hInstance; // used for MAKEINTRESOURCE() strings + TASKDIALOG_FLAGS dwFlags; // TASKDIALOG_FLAGS (TDF_XXX) flags + TASKDIALOG_COMMON_BUTTON_FLAGS dwCommonButtons; // TASKDIALOG_COMMON_BUTTON (TDCBF_XXX) flags + PCWSTR pszWindowTitle; // string or MAKEINTRESOURCE() + union + { + HICON hMainIcon; + PCWSTR pszMainIcon; + } /*DUMMYUNIONNAME*/; + PCWSTR pszMainInstruction; + PCWSTR pszContent; + UINT cButtons; + const TASKDIALOG_BUTTON *pButtons; + int nDefaultButton; + UINT cRadioButtons; + const TASKDIALOG_BUTTON *pRadioButtons; + int nDefaultRadioButton; + PCWSTR pszVerificationText; + PCWSTR pszExpandedInformation; + PCWSTR pszExpandedControlText; + PCWSTR pszCollapsedControlText; + union + { + HICON hFooterIcon; + PCWSTR pszFooterIcon; + } /*DUMMYUNIONNAME2*/; + PCWSTR pszFooter; + PFTASKDIALOGCALLBACK pfCallback; + LONG_PTR lpCallbackData; + UINT cxWidth; // width of the Task Dialog's client area in DLU's. If 0, Task Dialog will calculate the ideal width. +} TASKDIALOGCONFIG; + +typedef struct +{ + WORD dlgVer; + WORD signature; + DWORD helpID; + DWORD exStyle; + DWORD style; + WORD cDlgItems; + short x; + short y; + short cx; + short cy; +} DLGTEMPLATEEX; + +typedef struct +{ + DWORD helpID; + DWORD exStyle; + DWORD style; + short x; + short y; + short cx; + short cy; + DWORD id; +} DLGITEMTEMPLATEEX; + +#pragma pack(pop) + +typedef struct +{ + DLGTEMPLATEEX *lpDialog; + void *data; + size_t size; + size_t used; + WORD numbuttons; +} WIN_DialogData; + +static bool GetButtonIndex(const SDL_MessageBoxData *messageboxdata, SDL_MessageBoxButtonFlags flags, size_t *i) +{ + for (*i = 0; *i < (size_t)messageboxdata->numbuttons; ++*i) { + if (messageboxdata->buttons[*i].flags & flags) { + return true; + } + } + return false; +} + +static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) +{ + const SDL_MessageBoxData *messageboxdata; + size_t buttonindex; + + switch (iMessage) { + case WM_INITDIALOG: + if (lParam == 0) { + EndDialog(hDlg, IDINVALPTRINIT); + return TRUE; + } + messageboxdata = (const SDL_MessageBoxData *)lParam; + SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); + + if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { + // Focus on the first default return-key button + HWND buttonctl = GetDlgItem(hDlg, (int)(IDBUTTONINDEX0 + buttonindex)); + if (!buttonctl) { + EndDialog(hDlg, IDINVALPTRDLGITEM); + } + PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)buttonctl, TRUE); + } else { + // Give the focus to the dialog window instead + SetFocus(hDlg); + } + return FALSE; + case WM_SETFOCUS: + messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); + if (!messageboxdata) { + EndDialog(hDlg, IDINVALPTRSETFOCUS); + return TRUE; + } + + // Let the default button be focused if there is one. Otherwise, prevent any initial focus. + if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { + return FALSE; + } + return TRUE; + case WM_COMMAND: + messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); + if (!messageboxdata) { + EndDialog(hDlg, IDINVALPTRCOMMAND); + return TRUE; + } + + // Return the ID of the button that was pushed + if (wParam == IDOK) { + if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { + EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex); + } + } else if (wParam == IDCANCEL) { + if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, &buttonindex)) { + EndDialog(hDlg, IDBUTTONINDEX0 + buttonindex); + } else { + // Closing of window was requested by user or system. It would be rude not to comply. + EndDialog(hDlg, IDCLOSED); + } + } else if (wParam >= IDBUTTONINDEX0 && (int)wParam - IDBUTTONINDEX0 < messageboxdata->numbuttons) { + EndDialog(hDlg, wParam); + } + return TRUE; + + default: + break; + } + return FALSE; +} + +static bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) +{ + // Growing memory in 64 KiB steps. + const size_t sizestep = 0x10000; + size_t size = dialog->size; + + if (size == 0) { + // Start with 4 KiB or a multiple of 64 KiB to fit the data. + size = 0x1000; + if (SIZE_MAX - sizestep < space) { + size = space; + } else if (space > size) { + size = (space + sizestep) & ~(sizestep - 1); + } + } else if (SIZE_MAX - dialog->used < space) { + SDL_OutOfMemory(); + return false; + } else if (SIZE_MAX - (dialog->used + space) < sizestep) { + // Close to the maximum. + size = dialog->used + space; + } else if (size < dialog->used + space) { + // Round up to the next 64 KiB block. + size = dialog->used + space; + size += sizestep - size % sizestep; + } + + if (size > dialog->size) { + void *data = SDL_realloc(dialog->data, size); + if (!data) { + return false; + } + dialog->data = data; + dialog->size = size; + dialog->lpDialog = (DLGTEMPLATEEX *)dialog->data; + } + return true; +} + +static bool AlignDialogData(WIN_DialogData *dialog, size_t size) +{ + size_t padding = (dialog->used % size); + + if (!ExpandDialogSpace(dialog, padding)) { + return false; + } + + dialog->used += padding; + + return true; +} + +static bool AddDialogData(WIN_DialogData *dialog, const void *data, size_t size) +{ + if (!ExpandDialogSpace(dialog, size)) { + return false; + } + + SDL_memcpy((Uint8 *)dialog->data + dialog->used, data, size); + dialog->used += size; + + return true; +} + +static bool AddDialogString(WIN_DialogData *dialog, const char *string) +{ + WCHAR *wstring; + WCHAR *p; + size_t count; + bool status; + + if (!string) { + string = ""; + } + + wstring = WIN_UTF8ToStringW(string); + if (!wstring) { + return false; + } + + // Find out how many characters we have, including null terminator + count = 0; + for (p = wstring; *p; ++p) { + ++count; + } + ++count; + + status = AddDialogData(dialog, wstring, count * sizeof(WCHAR)); + SDL_free(wstring); + return status; +} + +static int s_BaseUnitsX; +static int s_BaseUnitsY; +static void Vec2ToDLU(short *x, short *y) +{ + SDL_assert(s_BaseUnitsX != 0); // we init in WIN_ShowMessageBox(), which is the only public function... + + *x = (short)MulDiv(*x, 4, s_BaseUnitsX); + *y = (short)MulDiv(*y, 8, s_BaseUnitsY); +} + +static bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, DWORD exStyle, int x, int y, int w, int h, int id, const char *caption, WORD ordinal) +{ + DLGITEMTEMPLATEEX item; + WORD marker = 0xFFFF; + WORD extraData = 0; + + SDL_zero(item); + item.style = style; + item.exStyle = exStyle; + item.x = (short)x; + item.y = (short)y; + item.cx = (short)w; + item.cy = (short)h; + item.id = id; + + Vec2ToDLU(&item.x, &item.y); + Vec2ToDLU(&item.cx, &item.cy); + + if (!AlignDialogData(dialog, sizeof(DWORD))) { + return false; + } + if (!AddDialogData(dialog, &item, sizeof(item))) { + return false; + } + if (!AddDialogData(dialog, &marker, sizeof(marker))) { + return false; + } + if (!AddDialogData(dialog, &type, sizeof(type))) { + return false; + } + if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption)) { + if (!AddDialogString(dialog, caption)) { + return false; + } + } else { + if (!AddDialogData(dialog, &marker, sizeof(marker))) { + return false; + } + if (!AddDialogData(dialog, &ordinal, sizeof(ordinal))) { + return false; + } + } + if (!AddDialogData(dialog, &extraData, sizeof(extraData))) { + return false; + } + if (type == DLGITEMTYPEBUTTON) { + dialog->numbuttons++; + } + ++dialog->lpDialog->cDlgItems; + + return true; +} + +static bool AddDialogStaticText(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text) +{ + DWORD style = WS_VISIBLE | WS_CHILD | SS_LEFT | SS_NOPREFIX | SS_EDITCONTROL | WS_GROUP; + return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -1, text, 0); +} + +static bool AddDialogStaticIcon(WIN_DialogData *dialog, int x, int y, int w, int h, Uint16 ordinal) +{ + DWORD style = WS_VISIBLE | WS_CHILD | SS_ICON | WS_GROUP; + return AddDialogControl(dialog, DLGITEMTYPESTATIC, style, 0, x, y, w, h, -2, NULL, ordinal); +} + +static bool AddDialogButton(WIN_DialogData *dialog, int x, int y, int w, int h, const char *text, int id, bool isDefault) +{ + DWORD style = WS_VISIBLE | WS_CHILD | WS_TABSTOP; + if (isDefault) { + style |= BS_DEFPUSHBUTTON; + } else { + style |= BS_PUSHBUTTON; + } + // The first button marks the start of the group. + if (dialog->numbuttons == 0) { + style |= WS_GROUP; + } + return AddDialogControl(dialog, DLGITEMTYPEBUTTON, style, 0, x, y, w, h, id, text, 0); +} + +static void FreeDialogData(WIN_DialogData *dialog) +{ + SDL_free(dialog->data); + SDL_free(dialog); +} + +static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) +{ + WIN_DialogData *dialog; + DLGTEMPLATEEX dialogTemplate; + WORD WordToPass; + + SDL_zero(dialogTemplate); + dialogTemplate.dlgVer = 1; + dialogTemplate.signature = 0xffff; + dialogTemplate.style = (WS_CAPTION | DS_CENTER | DS_SHELLFONT); + dialogTemplate.x = 0; + dialogTemplate.y = 0; + dialogTemplate.cx = (short)w; + dialogTemplate.cy = (short)h; + Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy); + + dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog)); + if (!dialog) { + return NULL; + } + + if (!AddDialogData(dialog, &dialogTemplate, sizeof(dialogTemplate))) { + FreeDialogData(dialog); + return NULL; + } + + // No menu + WordToPass = 0; + if (!AddDialogData(dialog, &WordToPass, 2)) { + FreeDialogData(dialog); + return NULL; + } + + // No custom class + if (!AddDialogData(dialog, &WordToPass, 2)) { + FreeDialogData(dialog); + return NULL; + } + + // title + if (!AddDialogString(dialog, caption)) { + FreeDialogData(dialog); + return NULL; + } + + // Font stuff + { + /* + * We want to use the system messagebox font. + */ + BYTE ToPass; + + NONCLIENTMETRICSA NCM; + NCM.cbSize = sizeof(NCM); + SystemParametersInfoA(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0); + + // Font size - convert to logical font size for dialog parameter. + { + HDC ScreenDC = GetDC(NULL); + int LogicalPixelsY = GetDeviceCaps(ScreenDC, LOGPIXELSY); + if (!LogicalPixelsY) { + LogicalPixelsY = 72; // This can happen if the application runs out of GDI handles + } + + WordToPass = (WORD)(-72 * NCM.lfMessageFont.lfHeight / LogicalPixelsY); + ReleaseDC(NULL, ScreenDC); + } + + if (!AddDialogData(dialog, &WordToPass, 2)) { + FreeDialogData(dialog); + return NULL; + } + + // Font weight + WordToPass = (WORD)NCM.lfMessageFont.lfWeight; + if (!AddDialogData(dialog, &WordToPass, 2)) { + FreeDialogData(dialog); + return NULL; + } + + // italic? + ToPass = NCM.lfMessageFont.lfItalic; + if (!AddDialogData(dialog, &ToPass, 1)) { + FreeDialogData(dialog); + return NULL; + } + + // charset? + ToPass = NCM.lfMessageFont.lfCharSet; + if (!AddDialogData(dialog, &ToPass, 1)) { + FreeDialogData(dialog); + return NULL; + } + + // font typeface. + if (!AddDialogString(dialog, NCM.lfMessageFont.lfFaceName)) { + FreeDialogData(dialog); + return NULL; + } + } + + return dialog; +} + +/* Escaping ampersands is necessary to disable mnemonics in dialog controls. + * The caller provides a char** for dst and a size_t* for dstlen where the + * address of the work buffer and its size will be stored. Their values must be + * NULL and 0 on the first call. src is the string to be escaped. On error, the + * function returns NULL and, on success, returns a pointer to the escaped + * sequence as a read-only string that is valid until the next call or until the + * work buffer is freed. Once all strings have been processed, it's the caller's + * responsibility to free the work buffer with SDL_free, even on errors. + */ +static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) +{ + char *newdst; + size_t ampcount = 0; + size_t srclen = 0; + + if (!src) { + return NULL; + } + + while (src[srclen]) { + if (src[srclen] == '&') { + ampcount++; + } + srclen++; + } + srclen++; + + if (ampcount == 0) { + // Nothing to do. + return src; + } + if (SIZE_MAX - srclen < ampcount) { + return NULL; + } + if (!*dst || *dstlen < srclen + ampcount) { + // Allocating extra space in case the next strings are a bit longer. + size_t extraspace = SIZE_MAX - (srclen + ampcount); + if (extraspace > 512) { + extraspace = 512; + } + *dstlen = srclen + ampcount + extraspace; + SDL_free(*dst); + *dst = NULL; + newdst = (char *)SDL_malloc(*dstlen); + if (!newdst) { + return NULL; + } + *dst = newdst; + } else { + newdst = *dst; + } + + // The escape character is the ampersand itself. + while (srclen--) { + if (*src == '&') { + *newdst++ = '&'; + } + *newdst++ = *src++; + } + + return *dst; +} + +static float WIN_GetContentScale(void) +{ + int dpi = 0; + +#if 0 // We don't know what monitor the dialog will be shown on + UINT hdpi_uint, vdpi_uint; + if (GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &hdpi_uint, &vdpi_uint) == S_OK) { + dpi = (int)hdpi_uint; + } +#endif + if (dpi == 0) { + // Window 8.0 and below: same DPI for all monitors + HDC hdc = GetDC(NULL); + if (hdc) { + dpi = GetDeviceCaps(hdc, LOGPIXELSX); + ReleaseDC(NULL, hdc); + } + } + if (dpi == 0) { + // Safe default + dpi = USER_DEFAULT_SCREEN_DPI; + } + return dpi / (float)USER_DEFAULT_SCREEN_DPI; +} + +// This function is called if a Task Dialog is unsupported. +static bool WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + WIN_DialogData *dialog; + int i, x, y; + HFONT DialogFont; + SIZE Size; + RECT TextSize; + wchar_t *wmessage; + TEXTMETRIC TM; + HDC FontDC; + INT_PTR rc; + char *ampescape = NULL; + size_t ampescapesize = 0; + Uint16 defbuttoncount = 0; + Uint16 icon = 0; + bool result; + + HWND ParentWindow = NULL; + + const float scale = WIN_GetContentScale(); + const int ButtonWidth = (int)SDL_roundf(88 * scale); + const int ButtonHeight = (int)SDL_roundf(26 * scale); + const int TextMargin = (int)SDL_roundf(16 * scale); + const int ButtonMargin = (int)SDL_roundf(12 * scale); + const int IconWidth = GetSystemMetrics(SM_CXICON); + const int IconHeight = GetSystemMetrics(SM_CYICON); + const int IconMargin = (int)SDL_roundf(20 * scale); + + if (messageboxdata->numbuttons > MAX_BUTTONS) { + return SDL_SetError("Number of buttons exceeds limit of %d", MAX_BUTTONS); + } + + switch (messageboxdata->flags & (SDL_MESSAGEBOX_ERROR | SDL_MESSAGEBOX_WARNING | SDL_MESSAGEBOX_INFORMATION)) { + case SDL_MESSAGEBOX_ERROR: + icon = (Uint16)(size_t)IDI_ERROR; + break; + case SDL_MESSAGEBOX_WARNING: + icon = (Uint16)(size_t)IDI_WARNING; + break; + case SDL_MESSAGEBOX_INFORMATION: + icon = (Uint16)(size_t)IDI_INFORMATION; + break; + } + + /* Jan 25th, 2013 - dant@fleetsa.com + * + * I've tried to make this more reasonable, but I've run in to a lot + * of nonsense. + * + * The original issue is the code was written in pixels and not + * dialog units (DLUs). All DialogBox functions use DLUs, which + * vary based on the selected font (yay). + * + * According to MSDN, the most reliable way to convert is via + * MapDialogUnits, which requires an HWND, which we don't have + * at time of template creation. + * + * We do however have: + * The system font (DLU width 8 for me) + * The font we select for the dialog (DLU width 6 for me) + * + * Based on experimentation, *neither* of these return the value + * actually used. Stepping in to MapDialogUnits(), the conversion + * is fairly clear, and uses 7 for me. + * + * As a result, some of this is hacky to ensure the sizing is + * somewhat correct. + * + * Honestly, a long term solution is to use CreateWindow, not CreateDialog. + * + * In order to get text dimensions we need to have a DC with the desired font. + * I'm assuming a dialog box in SDL is rare enough we can to the create. + */ + FontDC = CreateCompatibleDC(0); + + { + // Create a duplicate of the font used in system message boxes. + LOGFONT lf; + NONCLIENTMETRICS NCM; + NCM.cbSize = sizeof(NCM); + SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &NCM, 0); + lf = NCM.lfMessageFont; + DialogFont = CreateFontIndirect(&lf); + } + + // Select the font in to our DC + SelectObject(FontDC, DialogFont); + + { + // Get the metrics to try and figure our DLU conversion. + GetTextMetrics(FontDC, &TM); + + /* Calculation from the following documentation: + * https://support.microsoft.com/en-gb/help/125681/how-to-calculate-dialog-base-units-with-non-system-based-font + * This fixes bug 2137, dialog box calculation with a fixed-width system font + */ + { + SIZE extent; + GetTextExtentPoint32A(FontDC, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", 52, &extent); + s_BaseUnitsX = (extent.cx / 26 + 1) / 2; + } + // s_BaseUnitsX = TM.tmAveCharWidth + 1; + s_BaseUnitsY = TM.tmHeight; + } + + /* Measure the *pixel* size of the string. */ + wmessage = WIN_UTF8ToStringW(messageboxdata->message); + SDL_zero(TextSize); + DrawTextW(FontDC, wmessage, -1, &TextSize, DT_CALCRECT | DT_LEFT | DT_NOPREFIX | DT_EDITCONTROL); + + // Add margins and some padding for hangs, etc. + TextSize.left += TextMargin; + TextSize.right += TextMargin + 2; + TextSize.top += TextMargin; + TextSize.bottom += TextMargin + 2; + + // Done with the DC, and the string + DeleteDC(FontDC); + SDL_free(wmessage); + + // Increase the size of the dialog by some border spacing around the text. + Size.cx = TextSize.right - TextSize.left; + Size.cy = TextSize.bottom - TextSize.top; + Size.cx += TextMargin * 2; + Size.cy += TextMargin * 2; + + // Make dialog wider and shift text over for the icon. + if (icon) { + Size.cx += IconMargin + IconWidth; + TextSize.left += IconMargin + IconWidth; + TextSize.right += IconMargin + IconWidth; + } + + // Ensure the size is wide enough for all of the buttons. + if (Size.cx < (LONG)messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin) { + Size.cx = (LONG)messageboxdata->numbuttons * (ButtonWidth + ButtonMargin) + ButtonMargin; + } + + // Reset the height to the icon size if it is actually bigger than the text. + if (icon && Size.cy < (LONG)IconMargin * 2 + IconHeight) { + Size.cy = (LONG)IconMargin * 2 + IconHeight; + } + + // Add vertical space for the buttons and border. + Size.cy += ButtonHeight + TextMargin; + + dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title); + if (!dialog) { + return false; + } + + if (icon && !AddDialogStaticIcon(dialog, IconMargin, IconMargin, IconWidth, IconHeight, icon)) { + FreeDialogData(dialog); + return false; + } + + if (!AddDialogStaticText(dialog, TextSize.left, TextSize.top, TextSize.right - TextSize.left, TextSize.bottom - TextSize.top, messageboxdata->message)) { + FreeDialogData(dialog); + return false; + } + + // Align the buttons to the right/bottom. + x = Size.cx - (ButtonWidth + ButtonMargin) * messageboxdata->numbuttons; + y = Size.cy - ButtonHeight - ButtonMargin; + for (i = 0; i < messageboxdata->numbuttons; i++) { + bool isdefault = false; + const char *buttontext; + const SDL_MessageBoxButtonData *sdlButton; + + /* We always have to create the dialog buttons from left to right + * so that the tab order is correct. Select the info to use + * depending on which order was requested. */ + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT) { + sdlButton = &messageboxdata->buttons[i]; + } else { + sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i]; + } + + if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { + defbuttoncount++; + if (defbuttoncount == 1) { + isdefault = true; + } + } + + buttontext = EscapeAmpersands(&escape, &escapesize, sdlButton->text); + /* Make sure to provide the correct ID to keep buttons indexed in the + * same order as how they are in messageboxdata. */ + if (!buttontext || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) { + FreeDialogData(dialog); + SDL_free(ampescape); + return false; + } + + x += ButtonWidth + ButtonMargin; + } + SDL_free(ampescape); + + /* If we have a parent window, get the Instance and HWND for them + * so that our little dialog gets exclusive focus at all times. */ + if (messageboxdata->window) { + ParentWindow = messageboxdata->window->internal->hwnd; + } + + rc = DialogBoxIndirectParam(NULL, (DLGTEMPLATE *)dialog->lpDialog, ParentWindow, MessageBoxDialogProc, (LPARAM)messageboxdata); + if (rc >= IDBUTTONINDEX0 && rc - IDBUTTONINDEX0 < messageboxdata->numbuttons) { + *buttonID = messageboxdata->buttons[rc - IDBUTTONINDEX0].buttonID; + result = true; + } else if (rc == IDCLOSED) { + // Dialog window closed by user or system. + // This could use a special return code. + result = true; + *buttonID = -1; + } else { + if (rc == 0) { + SDL_SetError("Invalid parent window handle"); + } else if (rc == -1) { + SDL_SetError("The message box encountered an error."); + } else if (rc == IDINVALPTRINIT || rc == IDINVALPTRSETFOCUS || rc == IDINVALPTRCOMMAND) { + SDL_SetError("Invalid message box pointer in dialog procedure"); + } else if (rc == IDINVALPTRDLGITEM) { + SDL_SetError("Couldn't find dialog control of the default enter-key button"); + } else { + SDL_SetError("An unknown error occurred"); + } + result = false; + } + + FreeDialogData(dialog); + return result; +} + +/* TaskDialogIndirect procedure + * This is because SDL targets Windows XP (0x501), so this is not defined in the platform SDK. + */ +/* *INDENT-OFF* */ // clang-format off +typedef HRESULT (FAR WINAPI *TASKDIALOGINDIRECTPROC)(const TASKDIALOGCONFIG *pTaskConfig, int *pnButton, int *pnRadioButton, BOOL *pfVerificationFlagChecked); +/* *INDENT-ON* */ // clang-format on + +bool WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + HWND ParentWindow = NULL; + wchar_t *wmessage; + wchar_t *wtitle; + TASKDIALOGCONFIG TaskConfig; + TASKDIALOG_BUTTON *pButtons; + TASKDIALOG_BUTTON *pButton; + HMODULE hComctl32; + TASKDIALOGINDIRECTPROC pfnTaskDialogIndirect; + HRESULT hr; + char *ampescape = NULL; + size_t ampescapesize = 0; + int nButton; + int nCancelButton; + int i; + bool result = false; + + if (SIZE_MAX / sizeof(TASKDIALOG_BUTTON) < messageboxdata->numbuttons) { + return SDL_OutOfMemory(); + } + + HMODULE hUser32 = GetModuleHandle(TEXT("user32.dll")); + typedef DPI_AWARENESS_CONTEXT (WINAPI * SetThreadDpiAwarenessContext_t)(DPI_AWARENESS_CONTEXT); + SetThreadDpiAwarenessContext_t SetThreadDpiAwarenessContextFunc = (SetThreadDpiAwarenessContext_t)GetProcAddress(hUser32, "SetThreadDpiAwarenessContext"); + DPI_AWARENESS_CONTEXT previous_context = DPI_AWARENESS_CONTEXT_UNAWARE; + if (SetThreadDpiAwarenessContextFunc) { + previous_context = SetThreadDpiAwarenessContextFunc(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2); + } + + // If we cannot load comctl32.dll use the old messagebox! + hComctl32 = LoadLibrary(TEXT("comctl32.dll")); + if (!hComctl32) { + result = WIN_ShowOldMessageBox(messageboxdata, buttonID); + goto done; + } + + /* If TaskDialogIndirect doesn't exist use the old messagebox! + This will fail prior to Windows Vista. + The manifest file in the application may require targeting version 6 of comctl32.dll, even + when we use LoadLibrary here! + If you don't want to bother with manifests, put this #pragma in your app's source code somewhere: + #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") + */ + pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC)GetProcAddress(hComctl32, "TaskDialogIndirect"); + if (!pfnTaskDialogIndirect) { + FreeLibrary(hComctl32); + result = WIN_ShowOldMessageBox(messageboxdata, buttonID); + goto done; + } + + /* If we have a parent window, get the Instance and HWND for them + so that our little dialog gets exclusive focus at all times. */ + if (messageboxdata->window) { + ParentWindow = messageboxdata->window->internal->hwnd; + } + + wmessage = WIN_UTF8ToStringW(messageboxdata->message); + wtitle = WIN_UTF8ToStringW(messageboxdata->title); + + SDL_zero(TaskConfig); + TaskConfig.cbSize = sizeof(TASKDIALOGCONFIG); + TaskConfig.hwndParent = ParentWindow; + TaskConfig.dwFlags = TDF_SIZE_TO_CONTENT; + TaskConfig.pszWindowTitle = wtitle; + if (messageboxdata->flags & SDL_MESSAGEBOX_ERROR) { + TaskConfig.pszMainIcon = TD_ERROR_ICON; + } else if (messageboxdata->flags & SDL_MESSAGEBOX_WARNING) { + TaskConfig.pszMainIcon = TD_WARNING_ICON; + } else if (messageboxdata->flags & SDL_MESSAGEBOX_INFORMATION) { + TaskConfig.pszMainIcon = TD_INFORMATION_ICON; + } else { + TaskConfig.pszMainIcon = NULL; + } + + TaskConfig.pszContent = wmessage; + TaskConfig.cButtons = messageboxdata->numbuttons; + pButtons = (TASKDIALOG_BUTTON *)SDL_malloc(sizeof(TASKDIALOG_BUTTON) * messageboxdata->numbuttons); + TaskConfig.nDefaultButton = 0; + nCancelButton = 0; + for (i = 0; i < messageboxdata->numbuttons; i++) { + const char *buttontext; + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_LEFT_TO_RIGHT) { + pButton = &pButtons[i]; + } else { + pButton = &pButtons[messageboxdata->numbuttons - 1 - i]; + } + if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) { + nCancelButton = messageboxdata->buttons[i].buttonID; + pButton->nButtonID = IDCANCEL; + } else { + pButton->nButtonID = IDBUTTONINDEX0 + i; + } + buttontext = EscapeAmpersands(&escape, &escapesize, messageboxdata->buttons[i].text); + if (!buttontext) { + int j; + FreeLibrary(hComctl32); + SDL_free(ampescape); + SDL_free(wmessage); + SDL_free(wtitle); + for (j = 0; j < i; j++) { + SDL_free((wchar_t *)pButtons[j].pszButtonText); + } + SDL_free(pButtons); + return false; + } + pButton->pszButtonText = WIN_UTF8ToStringW(buttontext); + if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { + TaskConfig.nDefaultButton = pButton->nButtonID; + } + } + TaskConfig.pButtons = pButtons; + + // Show the Task Dialog + hr = pfnTaskDialogIndirect(&TaskConfig, &nButton, NULL, NULL); + + // Free everything + FreeLibrary(hComctl32); + SDL_free(ampescape); + SDL_free(wmessage); + SDL_free(wtitle); + for (i = 0; i < messageboxdata->numbuttons; i++) { + SDL_free((wchar_t *)pButtons[i].pszButtonText); + } + SDL_free(pButtons); + + // Check the Task Dialog was successful and give the result + if (SUCCEEDED(hr)) { + if (nButton == IDCANCEL) { + *buttonID = nCancelButton; + } else if (nButton >= IDBUTTONINDEX0 && nButton < IDBUTTONINDEX0 + messageboxdata->numbuttons) { + *buttonID = messageboxdata->buttons[nButton - IDBUTTONINDEX0].buttonID; + } else { + *buttonID = -1; + } + result = true; + } else { + // We failed showing the Task Dialog, use the old message box! + result = WIN_ShowOldMessageBox(messageboxdata, buttonID); + } + +done: + if (SetThreadDpiAwarenessContextFunc) { + SetThreadDpiAwarenessContextFunc(previous_context); + } + return result; +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.h new file mode 100644 index 0000000..28ed20c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmessagebox.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WINDOWS + +extern bool WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.c new file mode 100644 index 0000000..77ebab2 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.c @@ -0,0 +1,927 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsvideo.h" +#include "../../events/SDL_displayevents_c.h" + +#ifdef HAVE_DXGI1_6_H +#define COBJMACROS +#include +#endif + +// Windows CE compatibility +#ifndef CDS_FULLSCREEN +#define CDS_FULLSCREEN 0 +#endif + +// #define DEBUG_MODES +// #define HIGHDPI_DEBUG_VERBOSE + +static void WIN_UpdateDisplayMode(SDL_VideoDevice *_this, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode) +{ + SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->internal; + HDC hdc; + + data->DeviceMode.dmFields = (DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT | DM_DISPLAYFREQUENCY | DM_DISPLAYFLAGS); + + // NOLINTNEXTLINE(bugprone-assignment-in-if-condition): No simple way to extract the assignment + if (index == ENUM_CURRENT_SETTINGS && (hdc = CreateDC(deviceName, NULL, NULL, NULL)) != NULL) { + char bmi_data[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)]; + LPBITMAPINFO bmi; + HBITMAP hbm; + + SDL_zeroa(bmi_data); + bmi = (LPBITMAPINFO)bmi_data; + bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + + hbm = CreateCompatibleBitmap(hdc, 1, 1); + GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS); + GetDIBits(hdc, hbm, 0, 1, NULL, bmi, DIB_RGB_COLORS); + DeleteObject(hbm); + DeleteDC(hdc); + if (bmi->bmiHeader.biCompression == BI_BITFIELDS) { + switch (*(Uint32 *)bmi->bmiColors) { + case 0x00FF0000: + mode->format = SDL_PIXELFORMAT_XRGB8888; + break; + case 0x000000FF: + mode->format = SDL_PIXELFORMAT_XBGR8888; + break; + case 0xF800: + mode->format = SDL_PIXELFORMAT_RGB565; + break; + case 0x7C00: + mode->format = SDL_PIXELFORMAT_XRGB1555; + break; + } + } else if (bmi->bmiHeader.biCompression == BI_RGB) { + if (bmi->bmiHeader.biBitCount == 24) { + mode->format = SDL_PIXELFORMAT_RGB24; + } else if (bmi->bmiHeader.biBitCount == 8) { + mode->format = SDL_PIXELFORMAT_INDEX8; + } else if (bmi->bmiHeader.biBitCount == 4) { + mode->format = SDL_PIXELFORMAT_INDEX4LSB; + } + } + } else if (mode->format == SDL_PIXELFORMAT_UNKNOWN) { + // FIXME: Can we tell what this will be? + if ((data->DeviceMode.dmFields & DM_BITSPERPEL) == DM_BITSPERPEL) { + switch (data->DeviceMode.dmBitsPerPel) { + case 32: + mode->format = SDL_PIXELFORMAT_XRGB8888; + break; + case 24: + mode->format = SDL_PIXELFORMAT_RGB24; + break; + case 16: + mode->format = SDL_PIXELFORMAT_RGB565; + break; + case 15: + mode->format = SDL_PIXELFORMAT_XRGB1555; + break; + case 8: + mode->format = SDL_PIXELFORMAT_INDEX8; + break; + case 4: + mode->format = SDL_PIXELFORMAT_INDEX4LSB; + break; + } + } + } +} + +static void *WIN_GetDXGIOutput(SDL_VideoDevice *_this, const WCHAR *DeviceName) +{ + void *result = NULL; + +#ifdef HAVE_DXGI_H + const SDL_VideoData *videodata = (const SDL_VideoData *)_this->internal; + int nAdapter, nOutput; + IDXGIAdapter *pDXGIAdapter; + IDXGIOutput *pDXGIOutput; + + if (!videodata->pDXGIFactory) { + return NULL; + } + + nAdapter = 0; + while (!result && SUCCEEDED(IDXGIFactory_EnumAdapters(videodata->pDXGIFactory, nAdapter, &pDXGIAdapter))) { + nOutput = 0; + while (!result && SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) { + DXGI_OUTPUT_DESC outputDesc; + if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) { + if (SDL_wcscmp(outputDesc.DeviceName, DeviceName) == 0) { + result = pDXGIOutput; + } + } + if (pDXGIOutput != result) { + IDXGIOutput_Release(pDXGIOutput); + } + nOutput++; + } + IDXGIAdapter_Release(pDXGIAdapter); + nAdapter++; + } +#endif + return result; +} + +static void WIN_ReleaseDXGIOutput(void *dxgi_output) +{ +#ifdef HAVE_DXGI_H + IDXGIOutput *pDXGIOutput = (IDXGIOutput *)dxgi_output; + + if (pDXGIOutput) { + IDXGIOutput_Release(pDXGIOutput); + } +#endif +} + +static SDL_DisplayOrientation WIN_GetNaturalOrientation(DEVMODE *mode) +{ + int width = mode->dmPelsWidth; + int height = mode->dmPelsHeight; + + // Use unrotated width/height to guess orientation + if (mode->dmDisplayOrientation == DMDO_90 || mode->dmDisplayOrientation == DMDO_270) { + int temp = width; + width = height; + height = temp; + } + + if (width >= height) { + return SDL_ORIENTATION_LANDSCAPE; + } else { + return SDL_ORIENTATION_PORTRAIT; + } +} + +static SDL_DisplayOrientation WIN_GetDisplayOrientation(DEVMODE *mode) +{ + if (WIN_GetNaturalOrientation(mode) == SDL_ORIENTATION_LANDSCAPE) { + switch (mode->dmDisplayOrientation) { + case DMDO_DEFAULT: + return SDL_ORIENTATION_LANDSCAPE; + case DMDO_90: + return SDL_ORIENTATION_PORTRAIT; + case DMDO_180: + return SDL_ORIENTATION_LANDSCAPE_FLIPPED; + case DMDO_270: + return SDL_ORIENTATION_PORTRAIT_FLIPPED; + default: + return SDL_ORIENTATION_UNKNOWN; + } + } else { + switch (mode->dmDisplayOrientation) { + case DMDO_DEFAULT: + return SDL_ORIENTATION_PORTRAIT; + case DMDO_90: + return SDL_ORIENTATION_LANDSCAPE_FLIPPED; + case DMDO_180: + return SDL_ORIENTATION_PORTRAIT_FLIPPED; + case DMDO_270: + return SDL_ORIENTATION_LANDSCAPE; + default: + return SDL_ORIENTATION_UNKNOWN; + } + } +} + +static void WIN_GetRefreshRate(void *dxgi_output, DEVMODE *mode, int *numerator, int *denominator) +{ + // We're not currently using DXGI to query display modes, so fake NTSC timings + switch (mode->dmDisplayFrequency) { + case 119: + case 59: + case 29: + *numerator = (mode->dmDisplayFrequency + 1) * 1000; + *denominator = 1001; + break; + default: + *numerator = mode->dmDisplayFrequency; + *denominator = 1; + break; + } + +#ifdef HAVE_DXGI_H + if (dxgi_output) { + IDXGIOutput *pDXGIOutput = (IDXGIOutput *)dxgi_output; + DXGI_MODE_DESC modeToMatch; + DXGI_MODE_DESC closestMatch; + + SDL_zero(modeToMatch); + modeToMatch.Width = mode->dmPelsWidth; + modeToMatch.Height = mode->dmPelsHeight; + modeToMatch.RefreshRate.Numerator = *numerator; + modeToMatch.RefreshRate.Denominator = *denominator; + modeToMatch.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + + if (SUCCEEDED(IDXGIOutput_FindClosestMatchingMode(pDXGIOutput, &modeToMatch, &closestMatch, NULL))) { + *numerator = closestMatch.RefreshRate.Numerator; + *denominator = closestMatch.RefreshRate.Denominator; + } + } +#endif // HAVE_DXGI_H +} + +static float WIN_GetContentScale(SDL_VideoDevice *_this, HMONITOR hMonitor) +{ + const SDL_VideoData *videodata = (const SDL_VideoData *)_this->internal; + int dpi = 0; + + if (videodata->GetDpiForMonitor) { + UINT hdpi_uint, vdpi_uint; + if (videodata->GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &hdpi_uint, &vdpi_uint) == S_OK) { + dpi = (int)hdpi_uint; + } + } + if (dpi == 0) { + // Window 8.0 and below: same DPI for all monitors + HDC hdc = GetDC(NULL); + if (hdc) { + dpi = GetDeviceCaps(hdc, LOGPIXELSX); + ReleaseDC(NULL, hdc); + } + } + if (dpi == 0) { + // Safe default + dpi = USER_DEFAULT_SCREEN_DPI; + } + return dpi / (float)USER_DEFAULT_SCREEN_DPI; +} + +static bool WIN_GetDisplayMode(SDL_VideoDevice *_this, void *dxgi_output, HMONITOR hMonitor, LPCWSTR deviceName, DWORD index, SDL_DisplayMode *mode, SDL_DisplayOrientation *natural_orientation, SDL_DisplayOrientation *current_orientation) +{ + SDL_DisplayModeData *data; + DEVMODE devmode; + + devmode.dmSize = sizeof(devmode); + devmode.dmDriverExtra = 0; + if (!EnumDisplaySettingsW(deviceName, index, &devmode)) { + return false; + } + + data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); + if (!data) { + return false; + } + + SDL_zerop(mode); + mode->internal = data; + data->DeviceMode = devmode; + + mode->format = SDL_PIXELFORMAT_UNKNOWN; + mode->w = data->DeviceMode.dmPelsWidth; + mode->h = data->DeviceMode.dmPelsHeight; + WIN_GetRefreshRate(dxgi_output, &data->DeviceMode, &mode->refresh_rate_numerator, &mode->refresh_rate_denominator); + + // Fill in the mode information + WIN_UpdateDisplayMode(_this, deviceName, index, mode); + + if (natural_orientation) { + *natural_orientation = WIN_GetNaturalOrientation(&devmode); + } + if (current_orientation) { + *current_orientation = WIN_GetDisplayOrientation(&devmode); + } + + return true; +} + +static char *WIN_GetDisplayNameVista(SDL_VideoData *videodata, const WCHAR *deviceName) +{ + DISPLAYCONFIG_PATH_INFO *paths = NULL; + DISPLAYCONFIG_MODE_INFO *modes = NULL; + char *result = NULL; + UINT32 pathCount = 0; + UINT32 modeCount = 0; + UINT32 i; + LONG rc; + + if (!videodata->GetDisplayConfigBufferSizes || !videodata->QueryDisplayConfig || !videodata->DisplayConfigGetDeviceInfo) { + return NULL; + } + + do { + rc = videodata->GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &pathCount, &modeCount); + if (rc != ERROR_SUCCESS) { + goto WIN_GetDisplayNameVista_failed; + } + + SDL_free(paths); + SDL_free(modes); + + paths = (DISPLAYCONFIG_PATH_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_PATH_INFO) * pathCount); + modes = (DISPLAYCONFIG_MODE_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_MODE_INFO) * modeCount); + if ((!paths) || (!modes)) { + goto WIN_GetDisplayNameVista_failed; + } + + rc = videodata->QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &pathCount, paths, &modeCount, modes, 0); + } while (rc == ERROR_INSUFFICIENT_BUFFER); + + if (rc == ERROR_SUCCESS) { + for (i = 0; i < pathCount; i++) { + DISPLAYCONFIG_SOURCE_DEVICE_NAME sourceName; + DISPLAYCONFIG_TARGET_DEVICE_NAME targetName; + + SDL_zero(sourceName); + sourceName.header.adapterId = paths[i].targetInfo.adapterId; + sourceName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME; + sourceName.header.size = sizeof(sourceName); + sourceName.header.id = paths[i].sourceInfo.id; + rc = videodata->DisplayConfigGetDeviceInfo(&sourceName.header); + if (rc != ERROR_SUCCESS) { + break; + } else if (SDL_wcscmp(deviceName, sourceName.viewGdiDeviceName) != 0) { + continue; + } + + SDL_zero(targetName); + targetName.header.adapterId = paths[i].targetInfo.adapterId; + targetName.header.id = paths[i].targetInfo.id; + targetName.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME; + targetName.header.size = sizeof(targetName); + rc = videodata->DisplayConfigGetDeviceInfo(&targetName.header); + if (rc == ERROR_SUCCESS) { + result = WIN_StringToUTF8W(targetName.monitorFriendlyDeviceName); + /* if we got an empty string, treat it as failure so we'll fallback + to getting the generic name. */ + if (result && (*result == '\0')) { + SDL_free(result); + result = NULL; + } + } + break; + } + } + + SDL_free(paths); + SDL_free(modes); + return result; + +WIN_GetDisplayNameVista_failed: + SDL_free(result); + SDL_free(paths); + SDL_free(modes); + return NULL; +} + +#ifdef HAVE_DXGI1_6_H +static bool WIN_GetMonitorDESC1(HMONITOR hMonitor, DXGI_OUTPUT_DESC1 *desc) +{ + typedef HRESULT (WINAPI * PFN_CREATE_DXGI_FACTORY)(REFIID riid, void **ppFactory); + PFN_CREATE_DXGI_FACTORY CreateDXGIFactoryFunc = NULL; + SDL_SharedObject *hDXGIMod = NULL; + bool found = false; + + hDXGIMod = SDL_LoadObject("dxgi.dll"); + if (hDXGIMod) { + CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(hDXGIMod, "CreateDXGIFactory1"); + } + if (CreateDXGIFactoryFunc) { + static const GUID SDL_IID_IDXGIFactory1 = { 0x770aae78, 0xf26f, 0x4dba, { 0xa8, 0x29, 0x25, 0x3c, 0x83, 0xd1, 0xb3, 0x87 } }; + static const GUID SDL_IID_IDXGIOutput6 = { 0x068346e8, 0xaaec, 0x4b84, { 0xad, 0xd7, 0x13, 0x7f, 0x51, 0x3f, 0x77, 0xa1 } }; + IDXGIFactory1 *dxgiFactory; + + if (SUCCEEDED(CreateDXGIFactoryFunc(&SDL_IID_IDXGIFactory1, (void **)&dxgiFactory))) { + IDXGIAdapter1 *dxgiAdapter; + UINT adapter = 0; + while (!found && SUCCEEDED(IDXGIFactory1_EnumAdapters1(dxgiFactory, adapter, &dxgiAdapter))) { + IDXGIOutput *dxgiOutput; + UINT output = 0; + while (!found && SUCCEEDED(IDXGIAdapter1_EnumOutputs(dxgiAdapter, output, &dxgiOutput))) { + IDXGIOutput6 *dxgiOutput6; + if (SUCCEEDED(IDXGIOutput_QueryInterface(dxgiOutput, &SDL_IID_IDXGIOutput6, (void **)&dxgiOutput6))) { + if (SUCCEEDED(IDXGIOutput6_GetDesc1(dxgiOutput6, desc))) { + if (desc->Monitor == hMonitor) { + found = true; + } + } + IDXGIOutput6_Release(dxgiOutput6); + } + IDXGIOutput_Release(dxgiOutput); + ++output; + } + IDXGIAdapter1_Release(dxgiAdapter); + ++adapter; + } + IDXGIFactory2_Release(dxgiFactory); + } + } + if (hDXGIMod) { + SDL_UnloadObject(hDXGIMod); + } + return found; +} + +static bool WIN_GetMonitorPathInfo(SDL_VideoData *videodata, HMONITOR hMonitor, DISPLAYCONFIG_PATH_INFO *path_info) +{ + LONG result; + MONITORINFOEXW view_info; + UINT32 i; + UINT32 num_path_array_elements = 0; + UINT32 num_mode_info_array_elements = 0; + DISPLAYCONFIG_PATH_INFO *path_infos = NULL, *new_path_infos; + DISPLAYCONFIG_MODE_INFO *mode_infos = NULL, *new_mode_infos; + bool found = false; + + if (!videodata->GetDisplayConfigBufferSizes || !videodata->QueryDisplayConfig || !videodata->DisplayConfigGetDeviceInfo) { + return false; + } + + SDL_zero(view_info); + view_info.cbSize = sizeof(view_info); + if (!GetMonitorInfoW(hMonitor, (MONITORINFO *)&view_info)) { + goto done; + } + + do { + if (videodata->GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &num_path_array_elements, &num_mode_info_array_elements) != ERROR_SUCCESS) { + SDL_free(path_infos); + SDL_free(mode_infos); + return false; + } + + new_path_infos = (DISPLAYCONFIG_PATH_INFO *)SDL_realloc(path_infos, num_path_array_elements * sizeof(*path_infos)); + if (!new_path_infos) { + goto done; + } + path_infos = new_path_infos; + + new_mode_infos = (DISPLAYCONFIG_MODE_INFO *)SDL_realloc(mode_infos, num_mode_info_array_elements * sizeof(*mode_infos)); + if (!new_mode_infos) { + goto done; + } + mode_infos = new_mode_infos; + + result = videodata->QueryDisplayConfig(QDC_ONLY_ACTIVE_PATHS, &num_path_array_elements, path_infos, &num_mode_info_array_elements, mode_infos, NULL); + + } while (result == ERROR_INSUFFICIENT_BUFFER); + + if (result == ERROR_SUCCESS) { + for (i = 0; i < num_path_array_elements; ++i) { + DISPLAYCONFIG_SOURCE_DEVICE_NAME device_name; + + SDL_zero(device_name); + device_name.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME; + device_name.header.size = sizeof(device_name); + device_name.header.adapterId = path_infos[i].sourceInfo.adapterId; + device_name.header.id = path_infos[i].sourceInfo.id; + if (videodata->DisplayConfigGetDeviceInfo(&device_name.header) == ERROR_SUCCESS) { + if (SDL_wcscmp(view_info.szDevice, device_name.viewGdiDeviceName) == 0) { + SDL_copyp(path_info, &path_infos[i]); + found = true; + break; + } + } + } + } + +done: + SDL_free(path_infos); + SDL_free(mode_infos); + + return found; +} + +static float WIN_GetSDRWhitePoint(SDL_VideoDevice *_this, HMONITOR hMonitor) +{ + DISPLAYCONFIG_PATH_INFO path_info; + SDL_VideoData *videodata = _this->internal; + float SDR_white_level = 1.0f; + + if (WIN_GetMonitorPathInfo(videodata, hMonitor, &path_info)) { + /* workarounds for https://github.com/libsdl-org/SDL/issues/11193 */ + struct SDL_DISPLAYCONFIG_SDR_WHITE_LEVEL { + DISPLAYCONFIG_DEVICE_INFO_HEADER header; + ULONG SDRWhiteLevel; + } white_level; + #define DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL 11 + + SDL_zero(white_level); + white_level.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL; + white_level.header.size = sizeof(white_level); + white_level.header.adapterId = path_info.targetInfo.adapterId; + white_level.header.id = path_info.targetInfo.id; + // WIN_GetMonitorPathInfo() succeeded: DisplayConfigGetDeviceInfo is not NULL + if (videodata->DisplayConfigGetDeviceInfo(&white_level.header) == ERROR_SUCCESS && + white_level.SDRWhiteLevel > 0) { + SDR_white_level = (white_level.SDRWhiteLevel / 1000.0f); + } + } + return SDR_white_level; +} + +static void WIN_GetHDRProperties(SDL_VideoDevice *_this, HMONITOR hMonitor, SDL_HDROutputProperties *HDR) +{ + DXGI_OUTPUT_DESC1 desc; + + SDL_zerop(HDR); + + if (WIN_GetMonitorDESC1(hMonitor, &desc)) { + if (desc.ColorSpace == DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020) { + HDR->SDR_white_level = WIN_GetSDRWhitePoint(_this, hMonitor); + HDR->HDR_headroom = (desc.MaxLuminance / 80.0f) / HDR->SDR_white_level; + } + } +} +#endif // HAVE_DXGI1_6_H + +static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONITORINFOEXW *info, int *display_index) +{ + int i, index = *display_index; + SDL_VideoDisplay display; + SDL_DisplayData *displaydata; + void *dxgi_output = NULL; + SDL_DisplayMode mode; + SDL_DisplayOrientation natural_orientation; + SDL_DisplayOrientation current_orientation; + float content_scale = WIN_GetContentScale(_this, hMonitor); + +#ifdef DEBUG_MODES + SDL_Log("Display: %s", WIN_StringToUTF8W(info->szDevice)); +#endif + + dxgi_output = WIN_GetDXGIOutput(_this, info->szDevice); + bool found = WIN_GetDisplayMode(_this, dxgi_output, hMonitor, info->szDevice, ENUM_CURRENT_SETTINGS, &mode, &natural_orientation, ¤t_orientation); + WIN_ReleaseDXGIOutput(dxgi_output); + if (!found) { + return; + } + + // Prevent adding duplicate displays. Do this after we know the display is + // ready to be added to allow any displays that we can't fully query to be + // removed + for (i = 0; i < _this->num_displays; ++i) { + SDL_DisplayData *internal = _this->displays[i]->internal; + if (SDL_wcscmp(internal->DeviceName, info->szDevice) == 0) { + bool moved = (index != i); + bool changed_bounds = false; + + if (internal->state != DisplayRemoved) { + // We've already enumerated this display, don't move it + return; + } + + if (index >= _this->num_displays) { + // This should never happen due to the check above, but just in case... + return; + } + + if (moved) { + SDL_VideoDisplay *tmp; + + tmp = _this->displays[index]; + _this->displays[index] = _this->displays[i]; + _this->displays[i] = tmp; + i = index; + } + + internal->MonitorHandle = hMonitor; + internal->state = DisplayUnchanged; + + if (!_this->setting_display_mode) { + SDL_VideoDisplay *existing_display = _this->displays[i]; + SDL_Rect bounds; + + SDL_ResetFullscreenDisplayModes(existing_display); + SDL_SetDesktopDisplayMode(existing_display, &mode); + if (WIN_GetDisplayBounds(_this, existing_display, &bounds) && + SDL_memcmp(&internal->bounds, &bounds, sizeof(bounds)) != 0) { + changed_bounds = true; + SDL_copyp(&internal->bounds, &bounds); + } + if (moved || changed_bounds) { + SDL_SendDisplayEvent(existing_display, SDL_EVENT_DISPLAY_MOVED, 0, 0); + } + SDL_SendDisplayEvent(existing_display, SDL_EVENT_DISPLAY_ORIENTATION, current_orientation, 0); + SDL_SetDisplayContentScale(existing_display, content_scale); +#ifdef HAVE_DXGI1_6_H + SDL_HDROutputProperties HDR; + WIN_GetHDRProperties(_this, hMonitor, &HDR); + SDL_SetDisplayHDRProperties(existing_display, &HDR); +#endif + } + goto done; + } + } + + displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); + if (!displaydata) { + return; + } + SDL_memcpy(displaydata->DeviceName, info->szDevice, sizeof(displaydata->DeviceName)); + displaydata->MonitorHandle = hMonitor; + displaydata->state = DisplayAdded; + + SDL_zero(display); + display.name = WIN_GetDisplayNameVista(_this->internal, info->szDevice); + if (!display.name) { + DISPLAY_DEVICEW device; + SDL_zero(device); + device.cb = sizeof(device); + if (EnumDisplayDevicesW(info->szDevice, 0, &device, 0)) { + display.name = WIN_StringToUTF8W(device.DeviceString); + } + } + + display.desktop_mode = mode; + display.natural_orientation = natural_orientation; + display.current_orientation = current_orientation; + display.content_scale = content_scale; + display.device = _this; + display.internal = displaydata; + WIN_GetDisplayBounds(_this, &display, &displaydata->bounds); +#ifdef HAVE_DXGI1_6_H + WIN_GetHDRProperties(_this, hMonitor, &display.HDR); +#endif + SDL_AddVideoDisplay(&display, false); + SDL_free(display.name); + +done: + *display_index += 1; +} + +typedef struct _WIN_AddDisplaysData +{ + SDL_VideoDevice *video_device; + int display_index; + bool want_primary; +} WIN_AddDisplaysData; + +static BOOL CALLBACK WIN_AddDisplaysCallback(HMONITOR hMonitor, + HDC hdcMonitor, + LPRECT lprcMonitor, + LPARAM dwData) +{ + WIN_AddDisplaysData *data = (WIN_AddDisplaysData *)dwData; + MONITORINFOEXW info; + + SDL_zero(info); + info.cbSize = sizeof(info); + + if (GetMonitorInfoW(hMonitor, (LPMONITORINFO)&info) != 0) { + const bool is_primary = ((info.dwFlags & MONITORINFOF_PRIMARY) == MONITORINFOF_PRIMARY); + + if (is_primary == data->want_primary) { + WIN_AddDisplay(data->video_device, hMonitor, &info, &data->display_index); + } + } + + // continue enumeration + return TRUE; +} + +static void WIN_AddDisplays(SDL_VideoDevice *_this) +{ + WIN_AddDisplaysData callback_data; + callback_data.video_device = _this; + callback_data.display_index = 0; + + callback_data.want_primary = true; + EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data); + + callback_data.want_primary = false; + EnumDisplayMonitors(NULL, NULL, WIN_AddDisplaysCallback, (LPARAM)&callback_data); +} + +bool WIN_InitModes(SDL_VideoDevice *_this) +{ + WIN_AddDisplays(_this); + + if (_this->num_displays == 0) { + return SDL_SetError("No displays available"); + } + return true; +} + +bool WIN_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + const SDL_DisplayData *data = display->internal; + MONITORINFO minfo; + BOOL rc; + + SDL_zero(minfo); + minfo.cbSize = sizeof(MONITORINFO); + rc = GetMonitorInfo(data->MonitorHandle, &minfo); + + if (!rc) { + return SDL_SetError("Couldn't find monitor data"); + } + + rect->x = minfo.rcMonitor.left; + rect->y = minfo.rcMonitor.top; + rect->w = minfo.rcMonitor.right - minfo.rcMonitor.left; + rect->h = minfo.rcMonitor.bottom - minfo.rcMonitor.top; + + return true; +} + +bool WIN_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect) +{ + const SDL_DisplayData *data = display->internal; + MONITORINFO minfo; + BOOL rc; + + SDL_zero(minfo); + minfo.cbSize = sizeof(MONITORINFO); + rc = GetMonitorInfo(data->MonitorHandle, &minfo); + + if (!rc) { + return SDL_SetError("Couldn't find monitor data"); + } + + rect->x = minfo.rcWork.left; + rect->y = minfo.rcWork.top; + rect->w = minfo.rcWork.right - minfo.rcWork.left; + rect->h = minfo.rcWork.bottom - minfo.rcWork.top; + + return true; +} + +bool WIN_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) +{ + SDL_DisplayData *data = display->internal; + void *dxgi_output; + DWORD i; + SDL_DisplayMode mode; + + dxgi_output = WIN_GetDXGIOutput(_this, data->DeviceName); + + for (i = 0;; ++i) { + if (!WIN_GetDisplayMode(_this, dxgi_output, data->MonitorHandle, data->DeviceName, i, &mode, NULL, NULL)) { + break; + } + if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) { + // We don't support palettized modes now + SDL_free(mode.internal); + continue; + } + if (mode.format != SDL_PIXELFORMAT_UNKNOWN) { + if (!SDL_AddFullscreenDisplayMode(display, &mode)) { + SDL_free(mode.internal); + } + } else { + SDL_free(mode.internal); + } + } + + WIN_ReleaseDXGIOutput(dxgi_output); + + return true; +} + +#ifdef DEBUG_MODES +static void WIN_LogMonitor(SDL_VideoDevice *_this, HMONITOR mon) +{ + const SDL_VideoData *vid_data = (const SDL_VideoData *)_this->internal; + MONITORINFOEX minfo; + UINT xdpi = 0, ydpi = 0; + char *name_utf8; + + if (vid_data->GetDpiForMonitor) { + vid_data->GetDpiForMonitor(mon, MDT_EFFECTIVE_DPI, &xdpi, &ydpi); + } + + SDL_zero(minfo); + minfo.cbSize = sizeof(minfo); + GetMonitorInfo(mon, (LPMONITORINFO)&minfo); + + name_utf8 = WIN_StringToUTF8(minfo.szDevice); + + SDL_Log("WIN_LogMonitor: monitor \"%s\": dpi: %d windows screen coordinates: %d, %d, %dx%d", + name_utf8, + xdpi, + minfo.rcMonitor.left, + minfo.rcMonitor.top, + minfo.rcMonitor.right - minfo.rcMonitor.left, + minfo.rcMonitor.bottom - minfo.rcMonitor.top); + + SDL_free(name_utf8); +} +#endif + +bool WIN_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + SDL_DisplayData *displaydata = display->internal; + SDL_DisplayModeData *data = (SDL_DisplayModeData *)mode->internal; + LONG status; + +#ifdef DEBUG_MODES + SDL_Log("WIN_SetDisplayMode: monitor state before mode change:"); + WIN_LogMonitor(_this, displaydata->MonitorHandle); +#endif + + /* High-DPI notes: + + - ChangeDisplaySettingsEx always takes pixels. + - e.g. if the display is set to 2880x1800 with 200% scaling in Display Settings + - calling ChangeDisplaySettingsEx with a dmPelsWidth/Height other than 2880x1800 will + change the monitor DPI to 96. (100% scaling) + - calling ChangeDisplaySettingsEx with a dmPelsWidth/Height of 2880x1800 (or a NULL DEVMODE*) will + reset the monitor DPI to 192. (200% scaling) + + NOTE: these are temporary changes in DPI, not modifications to the Control Panel setting. */ + if (mode->internal == display->desktop_mode.internal) { +#ifdef DEBUG_MODES + SDL_Log("WIN_SetDisplayMode: resetting to original resolution"); +#endif + status = ChangeDisplaySettingsExW(displaydata->DeviceName, NULL, NULL, CDS_FULLSCREEN, NULL); + } else { +#ifdef DEBUG_MODES + SDL_Log("WIN_SetDisplayMode: changing to %dx%d pixels", data->DeviceMode.dmPelsWidth, data->DeviceMode.dmPelsHeight); +#endif + status = ChangeDisplaySettingsExW(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL); + } + if (status != DISP_CHANGE_SUCCESSFUL) { + const char *reason = "Unknown reason"; + switch (status) { + case DISP_CHANGE_BADFLAGS: + reason = "DISP_CHANGE_BADFLAGS"; + break; + case DISP_CHANGE_BADMODE: + reason = "DISP_CHANGE_BADMODE"; + break; + case DISP_CHANGE_BADPARAM: + reason = "DISP_CHANGE_BADPARAM"; + break; + case DISP_CHANGE_FAILED: + reason = "DISP_CHANGE_FAILED"; + break; + } + return SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason); + } + +#ifdef DEBUG_MODES + SDL_Log("WIN_SetDisplayMode: monitor state after mode change:"); + WIN_LogMonitor(_this, displaydata->MonitorHandle); +#endif + + EnumDisplaySettingsW(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode); + WIN_UpdateDisplayMode(_this, displaydata->DeviceName, ENUM_CURRENT_SETTINGS, mode); + return true; +} + +void WIN_RefreshDisplays(SDL_VideoDevice *_this) +{ + int i; + + // Mark all displays as potentially invalid to detect + // entries that have actually been removed + for (i = 0; i < _this->num_displays; ++i) { + SDL_DisplayData *internal = _this->displays[i]->internal; + internal->state = DisplayRemoved; + } + + // Enumerate displays to add any new ones and mark still + // connected entries as valid + WIN_AddDisplays(_this); + + // Delete any entries still marked as invalid, iterate + // in reverse as each delete takes effect immediately + for (i = _this->num_displays - 1; i >= 0; --i) { + SDL_VideoDisplay *display = _this->displays[i]; + SDL_DisplayData *internal = display->internal; + if (internal->state == DisplayRemoved) { + SDL_DelVideoDisplay(display->id, true); + } + } + + // Send events for any newly added displays + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *display = _this->displays[i]; + SDL_DisplayData *internal = display->internal; + if (internal->state == DisplayAdded) { + SDL_SendDisplayEvent(display, SDL_EVENT_DISPLAY_ADDED, 0, 0); + } + } +} + +void WIN_QuitModes(SDL_VideoDevice *_this) +{ + // All fullscreen windows should have restored modes by now +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.h new file mode 100644 index 0000000..3d294c3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmodes.h @@ -0,0 +1,55 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsmodes_h_ +#define SDL_windowsmodes_h_ + +typedef enum +{ + DisplayUnchanged, + DisplayAdded, + DisplayRemoved, + +} WIN_DisplayState; + +struct SDL_DisplayData +{ + WCHAR DeviceName[32]; + HMONITOR MonitorHandle; + WIN_DisplayState state; + SDL_Rect bounds; +}; + +struct SDL_DisplayModeData +{ + DEVMODE DeviceMode; +}; + +extern bool WIN_InitModes(SDL_VideoDevice *_this); +extern bool WIN_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); +extern bool WIN_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_Rect *rect); +extern bool WIN_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool WIN_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern void WIN_RefreshDisplays(SDL_VideoDevice *_this); +extern void WIN_QuitModes(SDL_VideoDevice *_this); + +#endif // SDL_windowsmodes_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.c new file mode 100644 index 0000000..3d6bcc4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.c @@ -0,0 +1,745 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsvideo.h" +#include "SDL_windowsevents.h" +#include "SDL_windowsrawinput.h" + +#include "../SDL_video_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../joystick/usb_ids.h" +#include "../../core/windows/SDL_windows.h" // for checking windows version + + +typedef struct CachedCursor +{ + float scale; + HCURSOR cursor; + struct CachedCursor *next; +} CachedCursor; + +struct SDL_CursorData +{ + SDL_Surface *surface; + int hot_x; + int hot_y; + CachedCursor *cache; + HCURSOR cursor; +}; + +typedef struct +{ + Uint64 xs[5]; + Uint64 ys[5]; + Sint64 residual[2]; + Uint32 dpiscale; + Uint32 dpidenom; + int last_node; + bool enhanced; + bool dpiaware; +} WIN_MouseData; + +DWORD SDL_last_warp_time = 0; +HCURSOR SDL_cursor = NULL; +static SDL_Cursor *SDL_blank_cursor = NULL; +static WIN_MouseData WIN_system_scale_data; + +static SDL_Cursor *WIN_CreateCursorAndData(HCURSOR hcursor) +{ + if (!hcursor) { + return NULL; + } + + SDL_Cursor *cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); + if (!cursor) { + return NULL; + } + + SDL_CursorData *data = (SDL_CursorData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_free(cursor); + return NULL; + } + + data->cursor = hcursor; + cursor->internal = data; + return cursor; +} + + +static bool IsMonochromeSurface(SDL_Surface *surface) +{ + int x, y; + Uint8 r, g, b, a; + + SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888); + + for (y = 0; y < surface->h; y++) { + for (x = 0; x < surface->w; x++) { + SDL_ReadSurfacePixel(surface, x, y, &r, &g, &b, &a); + + // Black or white pixel. + if (!((r == 0x00 && g == 0x00 && b == 0x00) || (r == 0xff && g == 0xff && b == 0xff))) { + return false; + } + + // Transparent or opaque pixel. + if (!(a == 0x00 || a == 0xff)) { + return false; + } + } + } + + return true; +} + +static HBITMAP CreateColorBitmap(SDL_Surface *surface) +{ + HBITMAP bitmap; + BITMAPINFO bi; + void *pixels; + + SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888); + + SDL_zero(bi); + bi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bi.bmiHeader.biWidth = surface->w; + bi.bmiHeader.biHeight = -surface->h; // Invert height to make the top-down DIB. + bi.bmiHeader.biPlanes = 1; + bi.bmiHeader.biBitCount = 32; + bi.bmiHeader.biCompression = BI_RGB; + + bitmap = CreateDIBSection(NULL, &bi, DIB_RGB_COLORS, &pixels, NULL, 0); + if (!bitmap || !pixels) { + WIN_SetError("CreateDIBSection()"); + if (bitmap) { + DeleteObject(bitmap); + } + return NULL; + } + + SDL_memcpy(pixels, surface->pixels, surface->pitch * surface->h); + + return bitmap; +} + +/* Generate bitmap with a mask and optional monochrome image data. + * + * For info on the expected mask format see: + * https://devblogs.microsoft.com/oldnewthing/20101018-00/?p=12513 + */ +static HBITMAP CreateMaskBitmap(SDL_Surface *surface, bool is_monochrome) +{ + HBITMAP bitmap; + bool isstack; + void *pixels; + int x, y; + Uint8 r, g, b, a; + Uint8 *dst; + const int pitch = ((surface->w + 15) & ~15) / 8; + const int size = pitch * surface->h; + static const unsigned char masks[] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 }; + + SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888); + + pixels = SDL_small_alloc(Uint8, size * (is_monochrome ? 2 : 1), &isstack); + if (!pixels) { + SDL_OutOfMemory(); + return NULL; + } + + dst = (Uint8 *)pixels; + + // Make the mask completely transparent. + SDL_memset(dst, 0xff, size); + if (is_monochrome) { + SDL_memset(dst + size, 0x00, size); + } + + for (y = 0; y < surface->h; y++, dst += pitch) { + for (x = 0; x < surface->w; x++) { + SDL_ReadSurfacePixel(surface, x, y, &r, &g, &b, &a); + + if (a != 0) { + // Reset bit of an opaque pixel. + dst[x >> 3] &= ~masks[x & 7]; + } + + if (is_monochrome && !(r == 0x00 && g == 0x00 && b == 0x00)) { + // Set bit of white or inverted pixel. + dst[size + (x >> 3)] |= masks[x & 7]; + } + } + } + + bitmap = CreateBitmap(surface->w, surface->h * (is_monochrome ? 2 : 1), 1, 1, pixels); + SDL_small_free(pixels, isstack); + if (!bitmap) { + WIN_SetError("CreateBitmap()"); + return NULL; + } + + return bitmap; +} + +static HCURSOR WIN_CreateHCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + HCURSOR hcursor; + ICONINFO ii; + bool is_monochrome = IsMonochromeSurface(surface); + + SDL_zero(ii); + ii.fIcon = FALSE; + ii.xHotspot = (DWORD)hot_x; + ii.yHotspot = (DWORD)hot_y; + ii.hbmMask = CreateMaskBitmap(surface, is_monochrome); + ii.hbmColor = is_monochrome ? NULL : CreateColorBitmap(surface); + + if (!ii.hbmMask || (!is_monochrome && !ii.hbmColor)) { + SDL_SetError("Couldn't create cursor bitmaps"); + if (ii.hbmMask) { + DeleteObject(ii.hbmMask); + } + if (ii.hbmColor) { + DeleteObject(ii.hbmColor); + } + return NULL; + } + + hcursor = CreateIconIndirect(&ii); + if (!hcursor) { + WIN_SetError("CreateIconIndirect()"); + DeleteObject(ii.hbmMask); + if (ii.hbmColor) { + DeleteObject(ii.hbmColor); + } + return NULL; + } + + DeleteObject(ii.hbmMask); + if (ii.hbmColor) { + DeleteObject(ii.hbmColor); + } + + return hcursor; +} + +static SDL_Cursor *WIN_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + if (!SDL_SurfaceHasAlternateImages(surface)) { + HCURSOR hcursor = WIN_CreateHCursor(surface, hot_x, hot_y); + if (!hcursor) { + return NULL; + } + return WIN_CreateCursorAndData(hcursor); + } + + // Dynamically generate cursors at the appropriate DPI + SDL_Cursor *cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + SDL_CursorData *data = (SDL_CursorData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_free(cursor); + return NULL; + } + data->hot_x = hot_x; + data->hot_y = hot_y; + data->surface = surface; + ++surface->refcount; + cursor->internal = data; + } + return cursor; +} + +static SDL_Cursor *WIN_CreateBlankCursor(void) +{ + SDL_Cursor *cursor = NULL; + SDL_Surface *surface = SDL_CreateSurface(32, 32, SDL_PIXELFORMAT_ARGB8888); + if (surface) { + cursor = WIN_CreateCursor(surface, 0, 0); + SDL_DestroySurface(surface); + } + return cursor; +} + +static SDL_Cursor *WIN_CreateSystemCursor(SDL_SystemCursor id) +{ + LPCTSTR name; + + switch (id) { + default: + SDL_assert(!"Unknown system cursor ID"); + return NULL; + case SDL_SYSTEM_CURSOR_DEFAULT: + name = IDC_ARROW; + break; + case SDL_SYSTEM_CURSOR_TEXT: + name = IDC_IBEAM; + break; + case SDL_SYSTEM_CURSOR_WAIT: + name = IDC_WAIT; + break; + case SDL_SYSTEM_CURSOR_CROSSHAIR: + name = IDC_CROSS; + break; + case SDL_SYSTEM_CURSOR_PROGRESS: + name = IDC_APPSTARTING; + break; + case SDL_SYSTEM_CURSOR_NWSE_RESIZE: + name = IDC_SIZENWSE; + break; + case SDL_SYSTEM_CURSOR_NESW_RESIZE: + name = IDC_SIZENESW; + break; + case SDL_SYSTEM_CURSOR_EW_RESIZE: + name = IDC_SIZEWE; + break; + case SDL_SYSTEM_CURSOR_NS_RESIZE: + name = IDC_SIZENS; + break; + case SDL_SYSTEM_CURSOR_MOVE: + name = IDC_SIZEALL; + break; + case SDL_SYSTEM_CURSOR_NOT_ALLOWED: + name = IDC_NO; + break; + case SDL_SYSTEM_CURSOR_POINTER: + name = IDC_HAND; + break; + case SDL_SYSTEM_CURSOR_NW_RESIZE: + name = IDC_SIZENWSE; + break; + case SDL_SYSTEM_CURSOR_N_RESIZE: + name = IDC_SIZENS; + break; + case SDL_SYSTEM_CURSOR_NE_RESIZE: + name = IDC_SIZENESW; + break; + case SDL_SYSTEM_CURSOR_E_RESIZE: + name = IDC_SIZEWE; + break; + case SDL_SYSTEM_CURSOR_SE_RESIZE: + name = IDC_SIZENWSE; + break; + case SDL_SYSTEM_CURSOR_S_RESIZE: + name = IDC_SIZENS; + break; + case SDL_SYSTEM_CURSOR_SW_RESIZE: + name = IDC_SIZENESW; + break; + case SDL_SYSTEM_CURSOR_W_RESIZE: + name = IDC_SIZEWE; + break; + } + return WIN_CreateCursorAndData(LoadCursor(NULL, name)); +} + +static SDL_Cursor *WIN_CreateDefaultCursor(void) +{ + SDL_SystemCursor id = SDL_GetDefaultSystemCursor(); + return WIN_CreateSystemCursor(id); +} + +static void WIN_FreeCursor(SDL_Cursor *cursor) +{ + SDL_CursorData *data = cursor->internal; + + if (data->surface) { + SDL_DestroySurface(data->surface); + } + while (data->cache) { + CachedCursor *entry = data->cache; + data->cache = entry->next; + if (entry->cursor) { + DestroyCursor(entry->cursor); + } + SDL_free(entry); + } + if (data->cursor) { + DestroyCursor(data->cursor); + } + SDL_free(data); + SDL_free(cursor); +} + +static HCURSOR GetCachedCursor(SDL_Cursor *cursor) +{ + SDL_CursorData *data = cursor->internal; + + SDL_Window *focus = SDL_GetMouseFocus(); + if (!focus) { + return NULL; + } + + float scale = SDL_GetDisplayContentScale(SDL_GetDisplayForWindow(focus)); + for (CachedCursor *entry = data->cache; entry; entry = entry->next) { + if (scale == entry->scale) { + return entry->cursor; + } + } + + // Need to create a cursor for this content scale + SDL_Surface *surface = NULL; + HCURSOR hcursor = NULL; + CachedCursor *entry = NULL; + + surface = SDL_GetSurfaceImage(data->surface, scale); + if (!surface) { + goto error; + } + + int hot_x = (int)SDL_round(data->hot_x * scale); + int hot_y = (int)SDL_round(data->hot_y * scale); + hcursor = WIN_CreateHCursor(surface, hot_x, hot_y); + if (!hcursor) { + goto error; + } + + entry = (CachedCursor *)SDL_malloc(sizeof(*entry)); + if (!entry) { + goto error; + } + entry->cursor = hcursor; + entry->scale = scale; + entry->next = data->cache; + data->cache = entry; + + SDL_DestroySurface(surface); + + return hcursor; + +error: + if (surface) { + SDL_DestroySurface(surface); + } + if (hcursor) { + DestroyCursor(hcursor); + } + SDL_free(entry); + return NULL; +} + +static bool WIN_ShowCursor(SDL_Cursor *cursor) +{ + if (!cursor) { + cursor = SDL_blank_cursor; + } + if (cursor) { + if (cursor->internal->surface) { + SDL_cursor = GetCachedCursor(cursor); + } else { + SDL_cursor = cursor->internal->cursor; + } + } else { + SDL_cursor = NULL; + } + if (SDL_GetMouseFocus() != NULL) { + SetCursor(SDL_cursor); + } + return true; +} + +void WIN_SetCursorPos(int x, int y) +{ + // We need to jitter the value because otherwise Windows will occasionally inexplicably ignore the SetCursorPos() or SendInput() + SetCursorPos(x, y); + SetCursorPos(x + 1, y); + SetCursorPos(x, y); + + // Flush any mouse motion prior to or associated with this warp +#ifdef _MSC_VER // We explicitly want to use GetTickCount(), not GetTickCount64() +#pragma warning(push) +#pragma warning(disable : 28159) +#endif + SDL_last_warp_time = GetTickCount(); + if (!SDL_last_warp_time) { + SDL_last_warp_time = 1; + } +#ifdef _MSC_VER +#pragma warning(pop) +#endif +} + +static bool WIN_WarpMouse(SDL_Window *window, float x, float y) +{ + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + POINT pt; + + // Don't warp the mouse while we're doing a modal interaction + if (data->in_title_click || data->focus_click_pending) { + return true; + } + + pt.x = (int)SDL_roundf(x); + pt.y = (int)SDL_roundf(y); + ClientToScreen(hwnd, &pt); + WIN_SetCursorPos(pt.x, pt.y); + + // Send the exact mouse motion associated with this warp + SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, x, y); + return true; +} + +static bool WIN_WarpMouseGlobal(float x, float y) +{ + POINT pt; + + pt.x = (int)SDL_roundf(x); + pt.y = (int)SDL_roundf(y); + SetCursorPos(pt.x, pt.y); + return true; +} + +static bool WIN_SetRelativeMouseMode(bool enabled) +{ + return WIN_SetRawMouseEnabled(SDL_GetVideoDevice(), enabled); +} + +static bool WIN_CaptureMouse(SDL_Window *window) +{ + if (window) { + SDL_WindowData *data = window->internal; + SetCapture(data->hwnd); + } else { + SDL_Window *focus_window = SDL_GetMouseFocus(); + + if (focus_window) { + SDL_WindowData *data = focus_window->internal; + if (!data->mouse_tracked) { + SDL_SetMouseFocus(NULL); + } + } + ReleaseCapture(); + } + + return true; +} + +static SDL_MouseButtonFlags WIN_GetGlobalMouseState(float *x, float *y) +{ + SDL_MouseButtonFlags result = 0; + POINT pt = { 0, 0 }; + bool swapButtons = GetSystemMetrics(SM_SWAPBUTTON) != 0; + + GetCursorPos(&pt); + *x = (float)pt.x; + *y = (float)pt.y; + + result |= GetAsyncKeyState(!swapButtons ? VK_LBUTTON : VK_RBUTTON) & 0x8000 ? SDL_BUTTON_LMASK : 0; + result |= GetAsyncKeyState(!swapButtons ? VK_RBUTTON : VK_LBUTTON) & 0x8000 ? SDL_BUTTON_RMASK : 0; + result |= GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_BUTTON_MMASK : 0; + result |= GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_BUTTON_X1MASK : 0; + result |= GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_BUTTON_X2MASK : 0; + + return result; +} + +static void WIN_ApplySystemScale(void *internal, Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, float *x, float *y) +{ + if (!internal) { + return; + } + WIN_MouseData *data = (WIN_MouseData *)internal; + + SDL_VideoDisplay *display = window ? SDL_GetVideoDisplayForWindow(window) : SDL_GetVideoDisplay(SDL_GetPrimaryDisplay()); + + Sint64 ix = (Sint64)*x * 65536; + Sint64 iy = (Sint64)*y * 65536; + Uint32 dpi = display ? (Uint32)(display->content_scale * USER_DEFAULT_SCREEN_DPI) : USER_DEFAULT_SCREEN_DPI; + + if (!data->enhanced) { // early return if flat scale + dpi = data->dpiscale * (data->dpiaware ? dpi : USER_DEFAULT_SCREEN_DPI); + ix *= dpi; + iy *= dpi; + ix /= USER_DEFAULT_SCREEN_DPI; + iy /= USER_DEFAULT_SCREEN_DPI; + ix /= 32; + iy /= 32; + // data->residual[0] += ix; + // data->residual[1] += iy; + // ix = 65536 * (data->residual[0] / 65536); + // iy = 65536 * (data->residual[1] / 65536); + // data->residual[0] -= ix; + // data->residual[1] -= iy; + *x = (float)ix / 65536.0f; + *y = (float)iy / 65536.0f; + return; + } + + Uint64 *xs = data->xs; + Uint64 *ys = data->ys; + Uint64 absx = SDL_abs(ix); + Uint64 absy = SDL_abs(iy); + Uint64 speed = SDL_min(absx, absy) + (SDL_max(absx, absy) << 1); // super cursed approximation used by Windows + if (speed == 0) { + return; + } + + int i, j, k; + for (i = 1; i < 5; i++) { + j = i; + if (speed < xs[j]) { + break; + } + } + i -= 1; + j -= 1; + k = data->last_node; + data->last_node = j; + + Uint32 denom = data->dpidenom; + Sint64 scale = 0; + Sint64 xdiff = xs[j+1] - xs[j]; + Sint64 ydiff = ys[j+1] - ys[j]; + if (xdiff != 0) { + Sint64 slope = ydiff / xdiff; + Sint64 inter = slope * xs[i] - ys[i]; + scale += slope - inter / speed; + } + + if (j > k) { + denom <<= 1; + xdiff = xs[k+1] - xs[k]; + ydiff = ys[k+1] - ys[k]; + if (xdiff != 0) { + Sint64 slope = ydiff / xdiff; + Sint64 inter = slope * xs[k] - ys[k]; + scale += slope - inter / speed; + } + } + + scale *= dpi; + ix *= scale; + iy *= scale; + ix /= denom; + iy /= denom; + // data->residual[0] += ix; + // data->residual[1] += iy; + // ix = 65536 * (data->residual[0] / 65536); + // iy = 65536 * (data->residual[1] / 65536); + // data->residual[0] -= ix; + // data->residual[1] -= iy; + *x = (float)ix / 65536.0f; + *y = (float)iy / 65536.0f; +} + +void WIN_InitMouse(SDL_VideoDevice *_this) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = WIN_CreateCursor; + mouse->CreateSystemCursor = WIN_CreateSystemCursor; + mouse->ShowCursor = WIN_ShowCursor; + mouse->FreeCursor = WIN_FreeCursor; + mouse->WarpMouse = WIN_WarpMouse; + mouse->WarpMouseGlobal = WIN_WarpMouseGlobal; + mouse->SetRelativeMouseMode = WIN_SetRelativeMouseMode; + mouse->CaptureMouse = WIN_CaptureMouse; + mouse->GetGlobalMouseState = WIN_GetGlobalMouseState; + mouse->ApplySystemScale = WIN_ApplySystemScale; + mouse->system_scale_data = &WIN_system_scale_data; + + SDL_SetDefaultCursor(WIN_CreateDefaultCursor()); + + SDL_blank_cursor = WIN_CreateBlankCursor(); + + WIN_UpdateMouseSystemScale(); +} + +void WIN_QuitMouse(SDL_VideoDevice *_this) +{ + if (SDL_blank_cursor) { + WIN_FreeCursor(SDL_blank_cursor); + SDL_blank_cursor = NULL; + } +} + +static void ReadMouseCurve(int v, Uint64 xs[5], Uint64 ys[5]) +{ + bool win8 = WIN_IsWindows8OrGreater(); + DWORD xbuff[10] = { + 0x00000000, 0, + 0x00006e15, 0, + 0x00014000, 0, + 0x0003dc29, 0, + 0x00280000, 0 + }; + DWORD ybuff[10] = { + 0x00000000, 0, + win8 ? 0x000111fd : 0x00015eb8, 0, + win8 ? 0x00042400 : 0x00054ccd, 0, + win8 ? 0x0012fc00 : 0x00184ccd, 0, + win8 ? 0x01bbc000 : 0x02380000, 0 + }; + DWORD xsize = sizeof(xbuff); + DWORD ysize = sizeof(ybuff); + HKEY open_handle; + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\Mouse", 0, KEY_READ, &open_handle) == ERROR_SUCCESS) { + RegQueryValueExW(open_handle, L"SmoothMouseXCurve", NULL, NULL, (BYTE*)xbuff, &xsize); + RegQueryValueExW(open_handle, L"SmoothMouseYCurve", NULL, NULL, (BYTE*)ybuff, &ysize); + RegCloseKey(open_handle); + } + xs[0] = 0; // first node must always be origin + ys[0] = 0; // first node must always be origin + int i; + for (i = 1; i < 5; i++) { + xs[i] = (7 * (Uint64)xbuff[i*2]); + ys[i] = (v * (Uint64)ybuff[i*2]) << 17; + } +} + +void WIN_UpdateMouseSystemScale(void) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + if (mouse->ApplySystemScale == WIN_ApplySystemScale) { + mouse->system_scale_data = &WIN_system_scale_data; + } + + // always reinitialize to valid defaults, whether fetch was successful or not. + WIN_MouseData *data = &WIN_system_scale_data; + data->residual[0] = 0; + data->residual[1] = 0; + data->dpiscale = 32; + data->dpidenom = (10 * (WIN_IsWindows8OrGreater() ? 120 : 150)) << 16; + data->dpiaware = WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice()); + data->enhanced = false; + + int v = 10; + if (SystemParametersInfo(SPI_GETMOUSESPEED, 0, &v, 0)) { + v = SDL_max(1, SDL_min(v, 20)); + data->dpiscale = SDL_max(SDL_max(v, (v - 2) * 4), (v - 6) * 8); + } + + int params[3]; + if (SystemParametersInfo(SPI_GETMOUSE, 0, ¶ms, 0)) { + data->enhanced = params[2] ? true : false; + if (params[2]) { + ReadMouseCurve(v, data->xs, data->ys); + } + } +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.h new file mode 100644 index 0000000..8fa6d7e --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsmouse.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsmouse_h_ +#define SDL_windowsmouse_h_ + +extern DWORD SDL_last_warp_time; +extern HCURSOR SDL_cursor; + +extern void WIN_InitMouse(SDL_VideoDevice *_this); +extern void WIN_QuitMouse(SDL_VideoDevice *_this); +extern void WIN_SetCursorPos(int x, int y); +extern void WIN_UpdateMouseSystemScale(void); + +#endif // SDL_windowsmouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.c new file mode 100644 index 0000000..c458796 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.c @@ -0,0 +1,906 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_windowsvideo.h" +#include "SDL_windowsopengles.h" + +// WGL implementation of SDL OpenGL support + +#ifdef SDL_VIDEO_OPENGL_WGL +#include + +#define DEFAULT_OPENGL "OPENGL32.DLL" + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#endif + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#endif +#endif + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 +#endif + +#ifndef WGL_EXT_create_context_es_profile +#define WGL_EXT_create_context_es_profile +#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 +#endif + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 +#endif + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 +#endif + +#ifndef WGL_ARB_context_flush_control +#define WGL_ARB_context_flush_control +#define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 +#define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif + +#ifndef WGL_ARB_create_context_no_error +#define WGL_ARB_create_context_no_error +#define WGL_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif + +typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC hDC, + HGLRC + hShareContext, + const int + *attribList); + +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) +#define GetDC(hwnd) (HDC) hwnd +#define ReleaseDC(hwnd, hdc) 1 +#define SwapBuffers _this->gl_data->wglSwapBuffers +#define DescribePixelFormat _this->gl_data->wglDescribePixelFormat +#define ChoosePixelFormat _this->gl_data->wglChoosePixelFormat +#define GetPixelFormat _this->gl_data->wglGetPixelFormat +#define SetPixelFormat _this->gl_data->wglSetPixelFormat +#endif + +bool WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + void *handle; + + if (path == NULL) { + path = SDL_GetHint(SDL_HINT_OPENGL_LIBRARY); + } + if (path == NULL) { + path = DEFAULT_OPENGL; + } + _this->gl_config.dll_handle = SDL_LoadObject(path); + if (!_this->gl_config.dll_handle) { + return false; + } + SDL_strlcpy(_this->gl_config.driver_path, path, + SDL_arraysize(_this->gl_config.driver_path)); + + // Allocate OpenGL memory + _this->gl_data = (struct SDL_GLDriverData *)SDL_calloc(1, sizeof(struct SDL_GLDriverData)); + if (!_this->gl_data) { + return false; + } + + // Load function pointers + handle = _this->gl_config.dll_handle; + /* *INDENT-OFF* */ // clang-format off + _this->gl_data->wglGetProcAddress = (PROC (WINAPI *)(const char *)) + SDL_LoadFunction(handle, "wglGetProcAddress"); + _this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC)) + SDL_LoadFunction(handle, "wglCreateContext"); + _this->gl_data->wglDeleteContext = (BOOL (WINAPI *)(HGLRC)) + SDL_LoadFunction(handle, "wglDeleteContext"); + _this->gl_data->wglMakeCurrent = (BOOL (WINAPI *)(HDC, HGLRC)) + SDL_LoadFunction(handle, "wglMakeCurrent"); + _this->gl_data->wglShareLists = (BOOL (WINAPI *)(HGLRC, HGLRC)) + SDL_LoadFunction(handle, "wglShareLists"); + /* *INDENT-ON* */ // clang-format on + +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + _this->gl_data->wglSwapBuffers = (BOOL(WINAPI *)(HDC)) + SDL_LoadFunction(handle, "wglSwapBuffers"); + _this->gl_data->wglDescribePixelFormat = (int(WINAPI *)(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR)) + SDL_LoadFunction(handle, "wglDescribePixelFormat"); + _this->gl_data->wglChoosePixelFormat = (int(WINAPI *)(HDC, const PIXELFORMATDESCRIPTOR *)) + SDL_LoadFunction(handle, "wglChoosePixelFormat"); + _this->gl_data->wglSetPixelFormat = (BOOL(WINAPI *)(HDC, int, const PIXELFORMATDESCRIPTOR *)) + SDL_LoadFunction(handle, "wglSetPixelFormat"); + _this->gl_data->wglGetPixelFormat = (int(WINAPI *)(HDC hdc)) + SDL_LoadFunction(handle, "wglGetPixelFormat"); +#endif + + if (!_this->gl_data->wglGetProcAddress || + !_this->gl_data->wglCreateContext || + !_this->gl_data->wglDeleteContext || + !_this->gl_data->wglMakeCurrent +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + || !_this->gl_data->wglSwapBuffers || + !_this->gl_data->wglDescribePixelFormat || + !_this->gl_data->wglChoosePixelFormat || + !_this->gl_data->wglGetPixelFormat || + !_this->gl_data->wglSetPixelFormat +#endif + ) { + return SDL_SetError("Could not retrieve OpenGL functions"); + } + + /* XXX Too sleazy? WIN_GL_InitExtensions looks for certain OpenGL + extensions via SDL_GL_DeduceMaxSupportedESProfile. This uses + SDL_GL_ExtensionSupported which in turn calls SDL_GL_GetProcAddress. + However SDL_GL_GetProcAddress will fail if the library is not + loaded; it checks for gl_config.driver_loaded > 0. To avoid this + test failing, increment driver_loaded around the call to + WIN_GLInitExtensions. + + Successful loading of the library is normally indicated by + SDL_GL_LoadLibrary incrementing driver_loaded immediately after + this function returns 0 to it. + + Alternatives to this are: + - moving SDL_GL_DeduceMaxSupportedESProfile to both the WIN and + X11 platforms while adding a function equivalent to + SDL_GL_ExtensionSupported but which directly calls + glGetProcAddress(). Having 3 copies of the + SDL_GL_ExtensionSupported makes this alternative unattractive. + - moving SDL_GL_DeduceMaxSupportedESProfile to a new file shared + by the WIN and X11 platforms while adding a function equivalent + to SDL_GL_ExtensionSupported. This is unattractive due to the + number of project files that will need updating, plus there + will be 2 copies of the SDL_GL_ExtensionSupported code. + - Add a private equivalent of SDL_GL_ExtensionSupported to + SDL_video.c. + - Move the call to WIN_GL_InitExtensions back to WIN_CreateWindow + and add a flag to gl_data to avoid multiple calls to this + expensive function. This is probably the least objectionable + alternative if this increment/decrement trick is unacceptable. + + Note that the driver_loaded > 0 check needs to remain in + SDL_GL_ExtensionSupported and SDL_GL_GetProcAddress as they are + public API functions. + */ + ++_this->gl_config.driver_loaded; + WIN_GL_InitExtensions(_this); + --_this->gl_config.driver_loaded; + + return true; +} + +SDL_FunctionPointer WIN_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + SDL_FunctionPointer func; + + // This is to pick up extensions + func = (SDL_FunctionPointer)_this->gl_data->wglGetProcAddress(proc); + if (!func) { + // This is probably a normal GL function + func = (SDL_FunctionPointer)GetProcAddress((HMODULE)_this->gl_config.dll_handle, proc); + } + return func; +} + +void WIN_GL_UnloadLibrary(SDL_VideoDevice *_this) +{ + SDL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; + + // Free OpenGL memory + SDL_free(_this->gl_data); + _this->gl_data = NULL; +} + +static void WIN_GL_SetupPixelFormat(SDL_VideoDevice *_this, PIXELFORMATDESCRIPTOR *pfd) +{ + SDL_zerop(pfd); + pfd->nSize = sizeof(*pfd); + pfd->nVersion = 1; + pfd->dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL); + if (_this->gl_config.double_buffer) { + pfd->dwFlags |= PFD_DOUBLEBUFFER; + } + if (_this->gl_config.stereo) { + pfd->dwFlags |= PFD_STEREO; + } + pfd->iLayerType = PFD_MAIN_PLANE; + pfd->iPixelType = PFD_TYPE_RGBA; + pfd->cRedBits = (BYTE)_this->gl_config.red_size; + pfd->cGreenBits = (BYTE)_this->gl_config.green_size; + pfd->cBlueBits = (BYTE)_this->gl_config.blue_size; + pfd->cAlphaBits = (BYTE)_this->gl_config.alpha_size; + if (_this->gl_config.buffer_size) { + pfd->cColorBits = (BYTE)(_this->gl_config.buffer_size - _this->gl_config.alpha_size); + } else { + pfd->cColorBits = (pfd->cRedBits + pfd->cGreenBits + pfd->cBlueBits); + } + pfd->cAccumRedBits = (BYTE)_this->gl_config.accum_red_size; + pfd->cAccumGreenBits = (BYTE)_this->gl_config.accum_green_size; + pfd->cAccumBlueBits = (BYTE)_this->gl_config.accum_blue_size; + pfd->cAccumAlphaBits = (BYTE)_this->gl_config.accum_alpha_size; + pfd->cAccumBits = + (pfd->cAccumRedBits + pfd->cAccumGreenBits + pfd->cAccumBlueBits + + pfd->cAccumAlphaBits); + pfd->cDepthBits = (BYTE)_this->gl_config.depth_size; + pfd->cStencilBits = (BYTE)_this->gl_config.stencil_size; +} + +/* Choose the closest pixel format that meets or exceeds the target. + FIXME: Should we weight any particular attribute over any other? +*/ +static bool WIN_GL_ChoosePixelFormat(SDL_VideoDevice *_this, HDC hdc, PIXELFORMATDESCRIPTOR *target) +{ + PIXELFORMATDESCRIPTOR pfd; + int count, index, best = 0; + unsigned int dist, best_dist = ~0U; + + count = DescribePixelFormat(hdc, 1, sizeof(pfd), NULL); + + for (index = 1; index <= count; index++) { + + if (!DescribePixelFormat(hdc, index, sizeof(pfd), &pfd)) { + continue; + } + + if ((pfd.dwFlags & target->dwFlags) != target->dwFlags) { + continue; + } + + if (pfd.iLayerType != target->iLayerType) { + continue; + } + if (pfd.iPixelType != target->iPixelType) { + continue; + } + + dist = 0; + + if (pfd.cColorBits < target->cColorBits) { + continue; + } else { + dist += (pfd.cColorBits - target->cColorBits); + } + if (pfd.cRedBits < target->cRedBits) { + continue; + } else { + dist += (pfd.cRedBits - target->cRedBits); + } + if (pfd.cGreenBits < target->cGreenBits) { + continue; + } else { + dist += (pfd.cGreenBits - target->cGreenBits); + } + if (pfd.cBlueBits < target->cBlueBits) { + continue; + } else { + dist += (pfd.cBlueBits - target->cBlueBits); + } + if (pfd.cAlphaBits < target->cAlphaBits) { + continue; + } else { + dist += (pfd.cAlphaBits - target->cAlphaBits); + } + if (pfd.cAccumBits < target->cAccumBits) { + continue; + } else { + dist += (pfd.cAccumBits - target->cAccumBits); + } + if (pfd.cAccumRedBits < target->cAccumRedBits) { + continue; + } else { + dist += (pfd.cAccumRedBits - target->cAccumRedBits); + } + if (pfd.cAccumGreenBits < target->cAccumGreenBits) { + continue; + } else { + dist += (pfd.cAccumGreenBits - target->cAccumGreenBits); + } + if (pfd.cAccumBlueBits < target->cAccumBlueBits) { + continue; + } else { + dist += (pfd.cAccumBlueBits - target->cAccumBlueBits); + } + if (pfd.cAccumAlphaBits < target->cAccumAlphaBits) { + continue; + } else { + dist += (pfd.cAccumAlphaBits - target->cAccumAlphaBits); + } + if (pfd.cDepthBits < target->cDepthBits) { + continue; + } else { + dist += (pfd.cDepthBits - target->cDepthBits); + } + if (pfd.cStencilBits < target->cStencilBits) { + continue; + } else { + dist += (pfd.cStencilBits - target->cStencilBits); + } + + if (dist < best_dist) { + best = index; + best_dist = dist; + } + } + + return best; +} + +static bool HasExtension(const char *extension, const char *extensions) +{ + const char *start; + const char *where, *terminator; + + // Extension names should not have spaces. + where = SDL_strchr(extension, ' '); + if (where || *extension == '\0') { + return false; + } + + if (!extensions) { + return false; + } + + /* It takes a bit of care to be fool-proof about parsing the + * OpenGL extensions string. Don't be fooled by sub-strings, + * etc. */ + + start = extensions; + + for (;;) { + where = SDL_strstr(start, extension); + if (!where) { + break; + } + + terminator = where + SDL_strlen(extension); + if (where == start || *(where - 1) == ' ') { + if (*terminator == ' ' || *terminator == '\0') { + return true; + } + } + + start = terminator; + } + return false; +} + +void WIN_GL_InitExtensions(SDL_VideoDevice *_this) +{ + /* *INDENT-OFF* */ // clang-format off + const char *(WINAPI * wglGetExtensionsStringARB)(HDC) = 0; + /* *INDENT-ON* */ // clang-format on + const char *extensions; + HWND hwnd; + HDC hdc; + HGLRC hglrc; + PIXELFORMATDESCRIPTOR pfd; + + if (!_this->gl_data) { + return; + } + + hwnd = + CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0, + 10, 10, NULL, NULL, SDL_Instance, NULL); + if (!hwnd) { + return; + } + WIN_PumpEvents(_this); + + hdc = GetDC(hwnd); + + WIN_GL_SetupPixelFormat(_this, &pfd); + + SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); + + hglrc = _this->gl_data->wglCreateContext(hdc); + if (!hglrc) { + return; + } + _this->gl_data->wglMakeCurrent(hdc, hglrc); + + /* *INDENT-OFF* */ // clang-format off + wglGetExtensionsStringARB = (const char *(WINAPI *)(HDC)) + _this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); + /* *INDENT-ON* */ // clang-format on + if (wglGetExtensionsStringARB) { + extensions = wglGetExtensionsStringARB(hdc); + } else { + extensions = NULL; + } + + // Check for WGL_ARB_pixel_format + _this->gl_data->HAS_WGL_ARB_pixel_format = false; + if (HasExtension("WGL_ARB_pixel_format", extensions)) { + /* *INDENT-OFF* */ // clang-format off + _this->gl_data->wglChoosePixelFormatARB = + (BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *)) + WIN_GL_GetProcAddress(_this, "wglChoosePixelFormatARB"); + _this->gl_data->wglGetPixelFormatAttribivARB = + (BOOL (WINAPI *)(HDC, int, int, UINT, const int *, int *)) + WIN_GL_GetProcAddress(_this, "wglGetPixelFormatAttribivARB"); + /* *INDENT-ON* */ // clang-format on + + if ((_this->gl_data->wglChoosePixelFormatARB != NULL) && + (_this->gl_data->wglGetPixelFormatAttribivARB != NULL)) { + _this->gl_data->HAS_WGL_ARB_pixel_format = true; + } + } + + // Check for WGL_EXT_swap_control + _this->gl_data->HAS_WGL_EXT_swap_control_tear = false; + if (HasExtension("WGL_EXT_swap_control", extensions)) { + _this->gl_data->wglSwapIntervalEXT = + (BOOL (WINAPI *)(int)) + WIN_GL_GetProcAddress(_this, "wglSwapIntervalEXT"); + _this->gl_data->wglGetSwapIntervalEXT = + (int (WINAPI *)(void)) + WIN_GL_GetProcAddress(_this, "wglGetSwapIntervalEXT"); + if (HasExtension("WGL_EXT_swap_control_tear", extensions)) { + _this->gl_data->HAS_WGL_EXT_swap_control_tear = true; + } + } else { + _this->gl_data->wglSwapIntervalEXT = NULL; + _this->gl_data->wglGetSwapIntervalEXT = NULL; + } + + // Check for WGL_EXT_create_context_es2_profile + if (HasExtension("WGL_EXT_create_context_es2_profile", extensions)) { + SDL_GL_DeduceMaxSupportedESProfile( + &_this->gl_data->es_profile_max_supported_version.major, + &_this->gl_data->es_profile_max_supported_version.minor); + } + + // Check for WGL_ARB_context_flush_control + if (HasExtension("WGL_ARB_context_flush_control", extensions)) { + _this->gl_data->HAS_WGL_ARB_context_flush_control = true; + } + + // Check for WGL_ARB_create_context_robustness + if (HasExtension("WGL_ARB_create_context_robustness", extensions)) { + _this->gl_data->HAS_WGL_ARB_create_context_robustness = true; + } + + // Check for WGL_ARB_create_context_no_error + if (HasExtension("WGL_ARB_create_context_no_error", extensions)) { + _this->gl_data->HAS_WGL_ARB_create_context_no_error = true; + } + + _this->gl_data->wglMakeCurrent(hdc, NULL); + _this->gl_data->wglDeleteContext(hglrc); + ReleaseDC(hwnd, hdc); + DestroyWindow(hwnd); + WIN_PumpEvents(_this); +} + +static int WIN_GL_ChoosePixelFormatARB(SDL_VideoDevice *_this, int *iAttribs, float *fAttribs) +{ + HWND hwnd; + HDC hdc; + PIXELFORMATDESCRIPTOR pfd; + HGLRC hglrc; + int pixel_format = 0; + unsigned int matching; + + int qAttrib = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB; + int srgb = 0; + + hwnd = + CreateWindow(SDL_Appname, SDL_Appname, (WS_POPUP | WS_DISABLED), 0, 0, + 10, 10, NULL, NULL, SDL_Instance, NULL); + WIN_PumpEvents(_this); + + hdc = GetDC(hwnd); + + WIN_GL_SetupPixelFormat(_this, &pfd); + + SetPixelFormat(hdc, ChoosePixelFormat(hdc, &pfd), &pfd); + + hglrc = _this->gl_data->wglCreateContext(hdc); + if (hglrc) { + _this->gl_data->wglMakeCurrent(hdc, hglrc); + + if (_this->gl_data->HAS_WGL_ARB_pixel_format) { + _this->gl_data->wglChoosePixelFormatARB(hdc, iAttribs, fAttribs, + 1, &pixel_format, + &matching); + + // Check whether we actually got an SRGB capable buffer + _this->gl_data->wglGetPixelFormatAttribivARB(hdc, pixel_format, 0, 1, &qAttrib, &srgb); + _this->gl_config.framebuffer_srgb_capable = srgb; + } + + _this->gl_data->wglMakeCurrent(hdc, NULL); + _this->gl_data->wglDeleteContext(hglrc); + } + ReleaseDC(hwnd, hdc); + DestroyWindow(hwnd); + WIN_PumpEvents(_this); + + return pixel_format; +} + +// actual work of WIN_GL_SetupWindow() happens here. +static bool WIN_GL_SetupWindowInternal(SDL_VideoDevice *_this, SDL_Window *window) +{ + HDC hdc = window->internal->hdc; + PIXELFORMATDESCRIPTOR pfd; + int pixel_format = 0; + int iAttribs[64]; + int *iAttr; + int *iAccelAttr; + float fAttribs[1] = { 0 }; + + WIN_GL_SetupPixelFormat(_this, &pfd); + + // setup WGL_ARB_pixel_format attribs + iAttr = &iAttribs[0]; + + *iAttr++ = WGL_DRAW_TO_WINDOW_ARB; + *iAttr++ = GL_TRUE; + *iAttr++ = WGL_RED_BITS_ARB; + *iAttr++ = _this->gl_config.red_size; + *iAttr++ = WGL_GREEN_BITS_ARB; + *iAttr++ = _this->gl_config.green_size; + *iAttr++ = WGL_BLUE_BITS_ARB; + *iAttr++ = _this->gl_config.blue_size; + + if (_this->gl_config.alpha_size) { + *iAttr++ = WGL_ALPHA_BITS_ARB; + *iAttr++ = _this->gl_config.alpha_size; + } + + *iAttr++ = WGL_DOUBLE_BUFFER_ARB; + *iAttr++ = _this->gl_config.double_buffer; + + *iAttr++ = WGL_DEPTH_BITS_ARB; + *iAttr++ = _this->gl_config.depth_size; + + if (_this->gl_config.stencil_size) { + *iAttr++ = WGL_STENCIL_BITS_ARB; + *iAttr++ = _this->gl_config.stencil_size; + } + + if (_this->gl_config.accum_red_size) { + *iAttr++ = WGL_ACCUM_RED_BITS_ARB; + *iAttr++ = _this->gl_config.accum_red_size; + } + + if (_this->gl_config.accum_green_size) { + *iAttr++ = WGL_ACCUM_GREEN_BITS_ARB; + *iAttr++ = _this->gl_config.accum_green_size; + } + + if (_this->gl_config.accum_blue_size) { + *iAttr++ = WGL_ACCUM_BLUE_BITS_ARB; + *iAttr++ = _this->gl_config.accum_blue_size; + } + + if (_this->gl_config.accum_alpha_size) { + *iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB; + *iAttr++ = _this->gl_config.accum_alpha_size; + } + + if (_this->gl_config.stereo) { + *iAttr++ = WGL_STEREO_ARB; + *iAttr++ = GL_TRUE; + } + + if (_this->gl_config.multisamplebuffers) { + *iAttr++ = WGL_SAMPLE_BUFFERS_ARB; + *iAttr++ = _this->gl_config.multisamplebuffers; + } + + if (_this->gl_config.multisamplesamples) { + *iAttr++ = WGL_SAMPLES_ARB; + *iAttr++ = _this->gl_config.multisamplesamples; + } + + if (_this->gl_config.floatbuffers) { + *iAttr++ = WGL_PIXEL_TYPE_ARB; + *iAttr++ = WGL_TYPE_RGBA_FLOAT_ARB; + } + + if (_this->gl_config.framebuffer_srgb_capable) { + *iAttr++ = WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB; + *iAttr++ = _this->gl_config.framebuffer_srgb_capable; + } + + /* We always choose either FULL or NO accel on Windows, because of flaky + drivers. If the app didn't specify, we use FULL, because that's + probably what they wanted (and if you didn't care and got FULL, that's + a perfectly valid result in any case). */ + *iAttr++ = WGL_ACCELERATION_ARB; + iAccelAttr = iAttr; + if (_this->gl_config.accelerated) { + *iAttr++ = WGL_FULL_ACCELERATION_ARB; + } else { + *iAttr++ = WGL_NO_ACCELERATION_ARB; + } + + *iAttr = 0; + + // Choose and set the closest available pixel format + pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); + + // App said "don't care about accel" and FULL accel failed. Try NO. + if ((!pixel_format) && (_this->gl_config.accelerated < 0)) { + *iAccelAttr = WGL_NO_ACCELERATION_ARB; + pixel_format = WIN_GL_ChoosePixelFormatARB(_this, iAttribs, fAttribs); + *iAccelAttr = WGL_FULL_ACCELERATION_ARB; // if we try again. + } + if (!pixel_format) { + pixel_format = WIN_GL_ChoosePixelFormat(_this, hdc, &pfd); + } + if (!pixel_format) { + return SDL_SetError("No matching GL pixel format available"); + } + if (!SetPixelFormat(hdc, pixel_format, &pfd)) { + return WIN_SetError("SetPixelFormat()"); + } + return true; +} + +bool WIN_GL_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + // The current context is lost in here; save it and reset it. + SDL_Window *current_win = SDL_GL_GetCurrentWindow(); + SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); + const int result = WIN_GL_SetupWindowInternal(_this, window); + WIN_GL_MakeCurrent(_this, current_win, current_ctx); + return result; +} + +bool WIN_GL_UseEGL(SDL_VideoDevice *_this) +{ + SDL_assert(_this->gl_data != NULL); + SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES); + + return SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, false) || _this->gl_config.major_version == 1 || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor); // No WGL extension for OpenGL ES 1.x profiles. +} + +SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + HDC hdc = window->internal->hdc; + HGLRC context, share_context; + + if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES && WIN_GL_UseEGL(_this)) { +#ifdef SDL_VIDEO_OPENGL_EGL + // Switch to EGL based functions + WIN_GL_UnloadLibrary(_this); + _this->GL_LoadLibrary = WIN_GLES_LoadLibrary; + _this->GL_GetProcAddress = WIN_GLES_GetProcAddress; + _this->GL_UnloadLibrary = WIN_GLES_UnloadLibrary; + _this->GL_CreateContext = WIN_GLES_CreateContext; + _this->GL_MakeCurrent = WIN_GLES_MakeCurrent; + _this->GL_SetSwapInterval = WIN_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = WIN_GLES_GetSwapInterval; + _this->GL_SwapWindow = WIN_GLES_SwapWindow; + _this->GL_DestroyContext = WIN_GLES_DestroyContext; + _this->GL_GetEGLSurface = WIN_GLES_GetEGLSurface; + + if (!WIN_GLES_LoadLibrary(_this, NULL)) { + return NULL; + } + + return WIN_GLES_CreateContext(_this, window); +#else + SDL_SetError("SDL not configured with EGL support"); + return NULL; +#endif + } + + if (_this->gl_config.share_with_current_context) { + share_context = (HGLRC)SDL_GL_GetCurrentContext(); + } else { + share_context = 0; + } + + if (_this->gl_config.major_version < 3 && + _this->gl_config.profile_mask == 0 && + _this->gl_config.flags == 0) { + // Create legacy context + context = _this->gl_data->wglCreateContext(hdc); + if (share_context != 0) { + _this->gl_data->wglShareLists(share_context, context); + } + } else { + PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB; + HGLRC temp_context = _this->gl_data->wglCreateContext(hdc); + if (!temp_context) { + SDL_SetError("Could not create GL context"); + return NULL; + } + + // Make the context current + if (!WIN_GL_MakeCurrent(_this, window, (SDL_GLContext)temp_context)) { + WIN_GL_DestroyContext(_this, (SDL_GLContext)temp_context); + return NULL; + } + + wglCreateContextAttribsARB = + (PFNWGLCREATECONTEXTATTRIBSARBPROC)_this->gl_data->wglGetProcAddress("wglCreateContextAttribsARB"); + if (!wglCreateContextAttribsARB) { + SDL_SetError("GL 3.x is not supported"); + context = temp_context; + } else { + int attribs[15]; // max 14 attributes plus terminator + int iattr = 0; + + attribs[iattr++] = WGL_CONTEXT_MAJOR_VERSION_ARB; + attribs[iattr++] = _this->gl_config.major_version; + attribs[iattr++] = WGL_CONTEXT_MINOR_VERSION_ARB; + attribs[iattr++] = _this->gl_config.minor_version; + + // SDL profile bits match WGL profile bits + if (_this->gl_config.profile_mask != 0) { + attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB; + attribs[iattr++] = _this->gl_config.profile_mask; + } + + // SDL flags match WGL flags + if (_this->gl_config.flags != 0) { + attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB; + attribs[iattr++] = _this->gl_config.flags; + } + + // only set if wgl extension is available and not the default setting + if ((_this->gl_data->HAS_WGL_ARB_context_flush_control) && (_this->gl_config.release_behavior == 0)) { + attribs[iattr++] = WGL_CONTEXT_RELEASE_BEHAVIOR_ARB; + attribs[iattr++] = _this->gl_config.release_behavior ? WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB : WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB; + } + + // only set if wgl extension is available and not the default setting + if ((_this->gl_data->HAS_WGL_ARB_create_context_robustness) && (_this->gl_config.reset_notification != 0)) { + attribs[iattr++] = WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB; + attribs[iattr++] = _this->gl_config.reset_notification ? WGL_LOSE_CONTEXT_ON_RESET_ARB : WGL_NO_RESET_NOTIFICATION_ARB; + } + + // only set if wgl extension is available and not the default setting + if ((_this->gl_data->HAS_WGL_ARB_create_context_no_error) && (_this->gl_config.no_error != 0)) { + attribs[iattr++] = WGL_CONTEXT_OPENGL_NO_ERROR_ARB; + attribs[iattr++] = _this->gl_config.no_error; + } + + attribs[iattr++] = 0; + + // Create the GL 3.x context + context = wglCreateContextAttribsARB(hdc, share_context, attribs); + // Delete the GL 2.x context + _this->gl_data->wglDeleteContext(temp_context); + } + } + + if (!context) { + WIN_SetError("Could not create GL context"); + return NULL; + } + + if (!WIN_GL_MakeCurrent(_this, window, (SDL_GLContext)context)) { + WIN_GL_DestroyContext(_this, (SDL_GLContext)context); + return NULL; + } + + return (SDL_GLContext)context; +} + +bool WIN_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + HDC hdc; + + if (!_this->gl_data) { + return SDL_SetError("OpenGL not initialized"); + } + + // sanity check that higher level handled this. + SDL_assert(window || (window == NULL && !context)); + + /* Some Windows drivers freak out if hdc is NULL, even when context is + NULL, against spec. Since hdc is _supposed_ to be ignored if context + is NULL, we either use the current GL window, or do nothing if we + already have no current context. */ + if (!window) { + window = SDL_GL_GetCurrentWindow(); + if (!window) { + SDL_assert(SDL_GL_GetCurrentContext() == NULL); + return true; // already done. + } + } + + hdc = window->internal->hdc; + if (!_this->gl_data->wglMakeCurrent(hdc, (HGLRC)context)) { + return WIN_SetError("wglMakeCurrent()"); + } + return true; +} + +bool WIN_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + if ((interval < 0) && (!_this->gl_data->HAS_WGL_EXT_swap_control_tear)) { + return SDL_SetError("Negative swap interval unsupported in this GL"); + } else if (_this->gl_data->wglSwapIntervalEXT) { + if (!_this->gl_data->wglSwapIntervalEXT(interval)) { + return WIN_SetError("wglSwapIntervalEXT()"); + } + } else { + return SDL_Unsupported(); + } + return true; +} + +bool WIN_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + if (_this->gl_data->wglGetSwapIntervalEXT) { + *interval = _this->gl_data->wglGetSwapIntervalEXT(); + return true; + } else { + return false; + } +} + +bool WIN_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + HDC hdc = window->internal->hdc; + + if (!SwapBuffers(hdc)) { + return WIN_SetError("SwapBuffers()"); + } + return true; +} + +bool WIN_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + if (!_this->gl_data) { + return true; + } + _this->gl_data->wglDeleteContext((HGLRC)context); + return true; +} + +#endif // SDL_VIDEO_OPENGL_WGL + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.h new file mode 100644 index 0000000..23e2f3a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengl.h @@ -0,0 +1,178 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsopengl_h_ +#define SDL_windowsopengl_h_ + +#ifdef SDL_VIDEO_OPENGL_WGL + +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) +typedef struct tagPIXELFORMATDESCRIPTOR +{ + WORD nSize; + WORD nVersion; + DWORD dwFlags; + BYTE iPixelType; + BYTE cColorBits; + BYTE cRedBits; + BYTE cRedShift; + BYTE cGreenBits; + BYTE cGreenShift; + BYTE cBlueBits; + BYTE cBlueShift; + BYTE cAlphaBits; + BYTE cAlphaShift; + BYTE cAccumBits; + BYTE cAccumRedBits; + BYTE cAccumGreenBits; + BYTE cAccumBlueBits; + BYTE cAccumAlphaBits; + BYTE cDepthBits; + BYTE cStencilBits; + BYTE cAuxBuffers; + BYTE iLayerType; + BYTE bReserved; + DWORD dwLayerMask; + DWORD dwVisibleMask; + DWORD dwDamageMask; +} PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR; +#endif + +struct SDL_GLDriverData +{ + bool HAS_WGL_ARB_pixel_format; + bool HAS_WGL_EXT_swap_control_tear; + bool HAS_WGL_ARB_context_flush_control; + bool HAS_WGL_ARB_create_context_robustness; + bool HAS_WGL_ARB_create_context_no_error; + + /* Max version of OpenGL ES context that can be created if the + implementation supports WGL_EXT_create_context_es2_profile. + major = minor = 0 when unsupported. + */ + struct + { + int major; + int minor; + } es_profile_max_supported_version; + + /* *INDENT-OFF* */ // clang-format off + PROC (WINAPI *wglGetProcAddress)(const char *proc); + HGLRC (WINAPI *wglCreateContext)(HDC hdc); + BOOL (WINAPI *wglDeleteContext)(HGLRC hglrc); + BOOL (WINAPI *wglMakeCurrent)(HDC hdc, HGLRC hglrc); + BOOL (WINAPI *wglShareLists)(HGLRC hglrc1, HGLRC hglrc2); + BOOL (WINAPI *wglChoosePixelFormatARB)(HDC hdc, const int *piAttribIList, const FLOAT * pfAttribFList, UINT nMaxFormats, int *piFormats, UINT * nNumFormats); + BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); + BOOL (WINAPI *wglSwapIntervalEXT)(int interval); + int (WINAPI *wglGetSwapIntervalEXT)(void); +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + BOOL (WINAPI *wglSwapBuffers)(HDC hdc); + int (WINAPI *wglDescribePixelFormat)(HDC hdc, + int iPixelFormat, + UINT nBytes, + LPPIXELFORMATDESCRIPTOR ppfd); + int (WINAPI *wglChoosePixelFormat)(HDC hdc, + const PIXELFORMATDESCRIPTOR *ppfd); + BOOL (WINAPI *wglSetPixelFormat)(HDC hdc, + int format, + const PIXELFORMATDESCRIPTOR *ppfd); + int (WINAPI *wglGetPixelFormat)(HDC hdc); +#endif + /* *INDENT-ON* */ // clang-format on +}; + +// OpenGL functions +extern bool WIN_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_FunctionPointer WIN_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern void WIN_GL_UnloadLibrary(SDL_VideoDevice *_this); +extern bool WIN_GL_UseEGL(SDL_VideoDevice *_this); +extern bool WIN_GL_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_GLContext WIN_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, + SDL_GLContext context); +extern bool WIN_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool WIN_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern bool WIN_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern void WIN_GL_InitExtensions(SDL_VideoDevice *_this); + +#ifndef WGL_ARB_pixel_format +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +#endif + +#ifndef WGL_ARB_multisample +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 +#endif + +#endif // SDL_VIDEO_OPENGL_WGL + +#endif // SDL_windowsopengl_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.c new file mode 100644 index 0000000..46f8ea3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.c @@ -0,0 +1,142 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && defined(SDL_VIDEO_OPENGL_EGL) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsvideo.h" +#include "SDL_windowsopengles.h" +#include "SDL_windowsopengl.h" +#include "SDL_windowswindow.h" + +// EGL implementation of SDL OpenGL support + +bool WIN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + + // If the profile requested is not GL ES, switch over to WIN_GL functions + if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES && + !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { +#ifdef SDL_VIDEO_OPENGL_WGL + WIN_GLES_UnloadLibrary(_this); + _this->GL_LoadLibrary = WIN_GL_LoadLibrary; + _this->GL_GetProcAddress = WIN_GL_GetProcAddress; + _this->GL_UnloadLibrary = WIN_GL_UnloadLibrary; + _this->GL_CreateContext = WIN_GL_CreateContext; + _this->GL_MakeCurrent = WIN_GL_MakeCurrent; + _this->GL_SetSwapInterval = WIN_GL_SetSwapInterval; + _this->GL_GetSwapInterval = WIN_GL_GetSwapInterval; + _this->GL_SwapWindow = WIN_GL_SwapWindow; + _this->GL_DestroyContext = WIN_GL_DestroyContext; + _this->GL_GetEGLSurface = NULL; + return WIN_GL_LoadLibrary(_this, path); +#else + return SDL_SetError("SDL not configured with OpenGL/WGL support"); +#endif + } + + if (!_this->egl_data) { + return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform); + } + + return true; +} + +SDL_GLContext WIN_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_GLContext context; + SDL_WindowData *data = window->internal; + +#ifdef SDL_VIDEO_OPENGL_WGL + if (_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES && + !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { + // Switch to WGL based functions + WIN_GLES_UnloadLibrary(_this); + _this->GL_LoadLibrary = WIN_GL_LoadLibrary; + _this->GL_GetProcAddress = WIN_GL_GetProcAddress; + _this->GL_UnloadLibrary = WIN_GL_UnloadLibrary; + _this->GL_CreateContext = WIN_GL_CreateContext; + _this->GL_MakeCurrent = WIN_GL_MakeCurrent; + _this->GL_SetSwapInterval = WIN_GL_SetSwapInterval; + _this->GL_GetSwapInterval = WIN_GL_GetSwapInterval; + _this->GL_SwapWindow = WIN_GL_SwapWindow; + _this->GL_DestroyContext = WIN_GL_DestroyContext; + _this->GL_GetEGLSurface = NULL; + + if (!WIN_GL_LoadLibrary(_this, NULL)) { + return NULL; + } + + return WIN_GL_CreateContext(_this, window); + } +#endif + + context = SDL_EGL_CreateContext(_this, data->egl_surface); + return context; +} + +bool WIN_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + return SDL_EGL_DestroyContext(_this, context); +} + +/* *INDENT-OFF* */ // clang-format off +SDL_EGL_SwapWindow_impl(WIN) +SDL_EGL_MakeCurrent_impl(WIN) +/* *INDENT-ON* */ // clang-format on + +bool WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + // The current context is lost in here; save it and reset it. + SDL_WindowData *windowdata = window->internal; + SDL_Window *current_win = SDL_GL_GetCurrentWindow(); + SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); + + if (!_this->egl_data) { +// !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. +#if 0 // When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. + SDL_assert(!_this->gl_config.driver_loaded); +#endif + if (!SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform)) { + SDL_EGL_UnloadLibrary(_this); + return false; + } + _this->gl_config.driver_loaded = 1; + } + + // Create the GLES window surface + windowdata->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)windowdata->hwnd); + + if (windowdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } + + return WIN_GLES_MakeCurrent(_this, current_win, current_ctx); +} + +EGLSurface WIN_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *windowdata = window->internal; + + return windowdata->egl_surface; +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS && SDL_VIDEO_OPENGL_EGL diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.h new file mode 100644 index 0000000..07cc8d4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsopengles.h @@ -0,0 +1,48 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_winopengles_h_ +#define SDL_winopengles_h_ + +#ifdef SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +// OpenGLES functions +#define WIN_GLES_GetAttribute SDL_EGL_GetAttribute +#define WIN_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define WIN_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define WIN_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define WIN_GLES_SetSwapInterval SDL_EGL_SetSwapInterval + +extern bool WIN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_GLContext WIN_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern bool WIN_GLES_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); +extern bool WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern SDL_EGLSurface WIN_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_VIDEO_OPENGL_EGL + +#endif // SDL_winopengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.c new file mode 100644 index 0000000..fa24991 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.c @@ -0,0 +1,262 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) + +#include "SDL_windowsvideo.h" + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsevents.h" + +#include "../../joystick/usb_ids.h" +#include "../../events/SDL_events_c.h" + +#define ENABLE_RAW_MOUSE_INPUT 0x01 +#define ENABLE_RAW_KEYBOARD_INPUT 0x02 + +typedef struct +{ + bool done; + Uint32 flags; + HANDLE ready_event; + HANDLE done_event; + HANDLE thread; +} RawInputThreadData; + +static RawInputThreadData thread_data = { + false, + 0, + INVALID_HANDLE_VALUE, + INVALID_HANDLE_VALUE, + INVALID_HANDLE_VALUE +}; + +static DWORD WINAPI WIN_RawInputThread(LPVOID param) +{ + SDL_VideoDevice *_this = SDL_GetVideoDevice(); + RawInputThreadData *data = (RawInputThreadData *)param; + RAWINPUTDEVICE devices[2]; + HWND window; + UINT count = 0; + + window = CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); + if (!window) { + return 0; + } + + SDL_zeroa(devices); + + if (data->flags & ENABLE_RAW_MOUSE_INPUT) { + devices[count].usUsagePage = USB_USAGEPAGE_GENERIC_DESKTOP; + devices[count].usUsage = USB_USAGE_GENERIC_MOUSE; + devices[count].dwFlags = 0; + devices[count].hwndTarget = window; + ++count; + } + + if (data->flags & ENABLE_RAW_KEYBOARD_INPUT) { + devices[count].usUsagePage = USB_USAGEPAGE_GENERIC_DESKTOP; + devices[count].usUsage = USB_USAGE_GENERIC_KEYBOARD; + devices[count].dwFlags = 0; + devices[count].hwndTarget = window; + ++count; + } + + if (!RegisterRawInputDevices(devices, count, sizeof(devices[0]))) { + DestroyWindow(window); + return 0; + } + + // Make sure we get events as soon as possible + SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); + + // Tell the parent we're ready to go! + SetEvent(data->ready_event); + + while (!data->done) { + Uint64 idle_begin = SDL_GetTicksNS(); + DWORD result = MsgWaitForMultipleObjects(1, &data->done_event, FALSE, INFINITE, QS_RAWINPUT); + Uint64 idle_end = SDL_GetTicksNS(); + if (result != (WAIT_OBJECT_0 + 1)) { + break; + } + + // Clear the queue status so MsgWaitForMultipleObjects() will wait again + (void)GetQueueStatus(QS_RAWINPUT); + + Uint64 idle_time = idle_end - idle_begin; + Uint64 usb_8khz_interval = SDL_US_TO_NS(125); + Uint64 poll_start = idle_time < usb_8khz_interval ? _this->internal->last_rawinput_poll : idle_end; + + WIN_PollRawInput(_this, poll_start); + } + + devices[0].dwFlags |= RIDEV_REMOVE; + devices[1].dwFlags |= RIDEV_REMOVE; + RegisterRawInputDevices(devices, count, sizeof(devices[0])); + + DestroyWindow(window); + + return 0; +} + +static void CleanupRawInputThreadData(RawInputThreadData *data) +{ + if (data->thread != INVALID_HANDLE_VALUE) { + data->done = true; + SetEvent(data->done_event); + WaitForSingleObject(data->thread, 3000); + CloseHandle(data->thread); + data->thread = INVALID_HANDLE_VALUE; + } + + if (data->ready_event != INVALID_HANDLE_VALUE) { + CloseHandle(data->ready_event); + data->ready_event = INVALID_HANDLE_VALUE; + } + + if (data->done_event != INVALID_HANDLE_VALUE) { + CloseHandle(data->done_event); + data->done_event = INVALID_HANDLE_VALUE; + } +} + +static bool WIN_SetRawInputEnabled(SDL_VideoDevice *_this, Uint32 flags) +{ + bool result = false; + + CleanupRawInputThreadData(&thread_data); + + if (flags) { + HANDLE handles[2]; + + thread_data.flags = flags; + thread_data.ready_event = CreateEvent(NULL, FALSE, FALSE, NULL); + if (thread_data.ready_event == INVALID_HANDLE_VALUE) { + WIN_SetError("CreateEvent"); + goto done; + } + + thread_data.done = false; + thread_data.done_event = CreateEvent(NULL, FALSE, FALSE, NULL); + if (thread_data.done_event == INVALID_HANDLE_VALUE) { + WIN_SetError("CreateEvent"); + goto done; + } + + thread_data.thread = CreateThread(NULL, 0, WIN_RawInputThread, &thread_data, 0, NULL); + if (thread_data.thread == INVALID_HANDLE_VALUE) { + WIN_SetError("CreateThread"); + goto done; + } + + // Wait for the thread to signal ready or exit + handles[0] = thread_data.ready_event; + handles[1] = thread_data.thread; + if (WaitForMultipleObjects(2, handles, FALSE, INFINITE) != WAIT_OBJECT_0) { + SDL_SetError("Couldn't set up raw input handling"); + goto done; + } + result = true; + } else { + result = true; + } + +done: + if (!result) { + CleanupRawInputThreadData(&thread_data); + } + return result; +} + +static bool WIN_UpdateRawInputEnabled(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + Uint32 flags = 0; + if (data->raw_mouse_enabled) { + flags |= ENABLE_RAW_MOUSE_INPUT; + } + if (data->raw_keyboard_enabled) { + flags |= ENABLE_RAW_KEYBOARD_INPUT; + } + if (flags != data->raw_input_enabled) { + if (WIN_SetRawInputEnabled(_this, flags)) { + data->raw_input_enabled = flags; + } else { + return false; + } + } + return true; +} + +bool WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, bool enabled) +{ + SDL_VideoData *data = _this->internal; + data->raw_mouse_enabled = enabled; + if (data->gameinput_context) { + if (!WIN_UpdateGameInputEnabled(_this)) { + data->raw_mouse_enabled = !enabled; + return false; + } + } else { + if (!WIN_UpdateRawInputEnabled(_this)) { + data->raw_mouse_enabled = !enabled; + return false; + } + } + return true; +} + +bool WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, bool enabled) +{ + SDL_VideoData *data = _this->internal; + data->raw_keyboard_enabled = enabled; + if (data->gameinput_context) { + if (!WIN_UpdateGameInputEnabled(_this)) { + data->raw_keyboard_enabled = !enabled; + return false; + } + } else { + if (!WIN_UpdateRawInputEnabled(_this)) { + data->raw_keyboard_enabled = !enabled; + return false; + } + } + return true; +} + +#else + +bool WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, bool enabled) +{ + return SDL_Unsupported(); +} + +bool WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, bool enabled) +{ + return SDL_Unsupported(); +} + +#endif // !SDL_PLATFORM_XBOXONE && !SDL_PLATFORM_XBOXSERIES + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.h new file mode 100644 index 0000000..25ae705 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsrawinput.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsrawinput_h_ +#define SDL_windowsrawinput_h_ + +extern bool WIN_SetRawMouseEnabled(SDL_VideoDevice *_this, bool enabled); +extern bool WIN_SetRawKeyboardEnabled(SDL_VideoDevice *_this, bool enabled); +extern bool WIN_RefreshRawInputEnabled(SDL_VideoDevice *_this); + +#endif // SDL_windowsrawinput_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.c new file mode 100644 index 0000000..db4e4a0 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.c @@ -0,0 +1,125 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#include "SDL_windowsvideo.h" +#include "SDL_windowsshape.h" + + +static void AddRegion(HRGN *mask, int x1, int y1, int x2, int y2) +{ + HRGN region = CreateRectRgn(x1, y1, x2, y2); + if (*mask) { + CombineRgn(*mask, *mask, region, RGN_OR); + DeleteObject(region); + } else { + *mask = region; + } +} + +static HRGN GenerateSpanListRegion(SDL_Surface *shape, int offset_x, int offset_y) +{ + HRGN mask = NULL; + int x, y; + int span_start = -1; + + for (y = 0; y < shape->h; ++y) { + const Uint8 *a = (const Uint8 *)shape->pixels + y * shape->pitch; + for (x = 0; x < shape->w; ++x) { + if (*a == SDL_ALPHA_TRANSPARENT) { + if (span_start != -1) { + AddRegion(&mask, offset_x + span_start, offset_y + y, offset_x + x, offset_y + y + 1); + span_start = -1; + } + } else { + if (span_start == -1) { + span_start = x; + } + } + a += 4; + } + if (span_start != -1) { + // Add the final span + AddRegion(&mask, offset_x + span_start, offset_y + y, offset_x + x, offset_y + y + 1); + span_start = -1; + } + } + return mask; +} + +bool WIN_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape) +{ + SDL_WindowData *data = window->internal; + HRGN mask = NULL; + + // Generate a set of spans for the region + if (shape) { + SDL_Surface *stretched = NULL; + RECT rect; + + if (shape->w != window->w || shape->h != window->h) { + stretched = SDL_CreateSurface(window->w, window->h, SDL_PIXELFORMAT_ARGB32); + if (!stretched) { + return false; + } + if (!SDL_StretchSurface(shape, NULL, stretched, NULL, SDL_SCALEMODE_LINEAR)) { + SDL_DestroySurface(stretched); + return false; + } + shape = stretched; + } + + rect.top = 0; + rect.left = 0; + rect.bottom = 0; + rect.right = 0; + if (!(SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS)) { + WIN_AdjustWindowRectForHWND(data->hwnd, &rect, 0); + } + + mask = GenerateSpanListRegion(shape, -rect.left, -rect.top); + + if (!(SDL_GetWindowFlags(data->window) & SDL_WINDOW_BORDERLESS)) { + // Add the window borders + // top + AddRegion(&mask, 0, 0, -rect.left + shape->w + rect.right + 1, -rect.top + 1); + // left + AddRegion(&mask, 0, -rect.top, -rect.left + 1, -rect.top + shape->h + 1); + // right + AddRegion(&mask, -rect.left + shape->w, -rect.top, -rect.left + shape->w + rect.right + 1, -rect.top + shape->h + 1); + // bottom + AddRegion(&mask, 0, -rect.top + shape->h, -rect.left + shape->w + rect.right + 1, -rect.top + shape->h + rect.bottom + 1); + } + + if (stretched) { + SDL_DestroySurface(stretched); + } + } + if (!SetWindowRgn(data->hwnd, mask, TRUE)) { + DeleteObject(mask); + return WIN_SetError("SetWindowRgn failed"); + } + return true; +} + +#endif // defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.h new file mode 100644 index 0000000..fae61d5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsshape.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsshape_h_ +#define SDL_windowsshape_h_ + +extern bool WIN_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); + +#endif // SDL_windowsshape_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.c new file mode 100644 index 0000000..04415b5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.c @@ -0,0 +1,773 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WINDOWS + +#ifdef SDL_VIDEO_VULKAN +#include "../SDL_vulkan_internal.h" +#endif +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../SDL_hints_c.h" +#include "../../core/windows/SDL_hid.h" + +#include "SDL_windowsvideo.h" +#include "SDL_windowsframebuffer.h" +#include "SDL_windowsmessagebox.h" +#include "SDL_windowsrawinput.h" +#include "SDL_windowsvulkan.h" + +#ifdef SDL_GDK_TEXTINPUT +#include "../gdk/SDL_gdktextinput.h" +#endif + +// #define HIGHDPI_DEBUG + +// Initialization/Query functions +static bool WIN_VideoInit(SDL_VideoDevice *_this); +static void WIN_VideoQuit(SDL_VideoDevice *_this); + +// Hints +bool g_WindowsEnableMessageLoop = true; +bool g_WindowsEnableMenuMnemonics = false; +bool g_WindowFrameUsableWhileCursorHidden = true; + +static void SDLCALL UpdateWindowsRawKeyboard(void *userdata, const char *name, const char *oldValue, const char *newValue) +{ + SDL_VideoDevice *_this = (SDL_VideoDevice *)userdata; + bool enabled = SDL_GetStringBoolean(newValue, false); + WIN_SetRawKeyboardEnabled(_this, enabled); +} + +static void SDLCALL UpdateWindowsEnableMessageLoop(void *userdata, const char *name, const char *oldValue, const char *newValue) +{ + g_WindowsEnableMessageLoop = SDL_GetStringBoolean(newValue, true); +} + +static void SDLCALL UpdateWindowsEnableMenuMnemonics(void *userdata, const char *name, const char *oldValue, const char *newValue) +{ + g_WindowsEnableMenuMnemonics = SDL_GetStringBoolean(newValue, false); +} + +static void SDLCALL UpdateWindowFrameUsableWhileCursorHidden(void *userdata, const char *name, const char *oldValue, const char *newValue) +{ + g_WindowFrameUsableWhileCursorHidden = SDL_GetStringBoolean(newValue, true); +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +static bool WIN_SuspendScreenSaver(SDL_VideoDevice *_this) +{ + DWORD result; + if (_this->suspend_screensaver) { + result = SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED); + } else { + result = SetThreadExecutionState(ES_CONTINUOUS); + } + if (result == 0) { + SDL_SetError("SetThreadExecutionState() failed"); + return false; + } + return true; +} +#endif + +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) +extern void D3D12_XBOX_GetResolution(Uint32 *width, Uint32 *height); +#endif + +// Windows driver bootstrap functions + +static void WIN_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_VideoData *data = device->internal; + + SDL_UnregisterApp(); +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (data->userDLL) { + SDL_UnloadObject(data->userDLL); + } + if (data->shcoreDLL) { + SDL_UnloadObject(data->shcoreDLL); + } +#endif +#ifdef HAVE_DXGI_H + if (data->pDXGIFactory) { + IDXGIFactory_Release(data->pDXGIFactory); + } + if (data->dxgiDLL) { + SDL_UnloadObject(data->dxgiDLL); + } +#endif + if (device->wakeup_lock) { + SDL_DestroyMutex(device->wakeup_lock); + } + SDL_free(device->internal->rawinput); + SDL_free(device->internal); + SDL_free(device); +} + +static SDL_VideoDevice *WIN_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + + SDL_RegisterApp(NULL, 0, NULL); + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device) { + data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + } else { + data = NULL; + } + if (!data) { + SDL_UnregisterApp(); + SDL_free(device); + return NULL; + } + device->internal = data; + device->wakeup_lock = SDL_CreateMutex(); + device->system_theme = WIN_GetSystemTheme(); + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + data->userDLL = SDL_LoadObject("USER32.DLL"); + if (data->userDLL) { + /* *INDENT-OFF* */ // clang-format off + data->CloseTouchInputHandle = (BOOL (WINAPI *)(HTOUCHINPUT))SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle"); + data->GetTouchInputInfo = (BOOL (WINAPI *)(HTOUCHINPUT, UINT, PTOUCHINPUT, int)) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo"); + data->RegisterTouchWindow = (BOOL (WINAPI *)(HWND, ULONG))SDL_LoadFunction(data->userDLL, "RegisterTouchWindow"); + data->SetProcessDPIAware = (BOOL (WINAPI *)(void))SDL_LoadFunction(data->userDLL, "SetProcessDPIAware"); + data->SetProcessDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "SetProcessDpiAwarenessContext"); + data->SetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "SetThreadDpiAwarenessContext"); + data->GetThreadDpiAwarenessContext = (DPI_AWARENESS_CONTEXT (WINAPI *)(void))SDL_LoadFunction(data->userDLL, "GetThreadDpiAwarenessContext"); + data->GetAwarenessFromDpiAwarenessContext = (DPI_AWARENESS (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "GetAwarenessFromDpiAwarenessContext"); + data->EnableNonClientDpiScaling = (BOOL (WINAPI *)(HWND))SDL_LoadFunction(data->userDLL, "EnableNonClientDpiScaling"); + data->AdjustWindowRectExForDpi = (BOOL (WINAPI *)(LPRECT, DWORD, BOOL, DWORD, UINT))SDL_LoadFunction(data->userDLL, "AdjustWindowRectExForDpi"); + data->GetDpiForWindow = (UINT (WINAPI *)(HWND))SDL_LoadFunction(data->userDLL, "GetDpiForWindow"); + data->AreDpiAwarenessContextsEqual = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "AreDpiAwarenessContextsEqual"); + data->IsValidDpiAwarenessContext = (BOOL (WINAPI *)(DPI_AWARENESS_CONTEXT))SDL_LoadFunction(data->userDLL, "IsValidDpiAwarenessContext"); + data->GetDisplayConfigBufferSizes = (LONG (WINAPI *)(UINT32,UINT32*,UINT32* ))SDL_LoadFunction(data->userDLL, "GetDisplayConfigBufferSizes"); + data->QueryDisplayConfig = (LONG (WINAPI *)(UINT32,UINT32*,DISPLAYCONFIG_PATH_INFO*,UINT32*,DISPLAYCONFIG_MODE_INFO*,DISPLAYCONFIG_TOPOLOGY_ID*))SDL_LoadFunction(data->userDLL, "QueryDisplayConfig"); + data->DisplayConfigGetDeviceInfo = (LONG (WINAPI *)(DISPLAYCONFIG_DEVICE_INFO_HEADER*))SDL_LoadFunction(data->userDLL, "DisplayConfigGetDeviceInfo"); + data->GetPointerType = (BOOL (WINAPI *)(UINT32, POINTER_INPUT_TYPE *))SDL_LoadFunction(data->userDLL, "GetPointerType"); + data->GetPointerPenInfo = (BOOL (WINAPI *)(UINT32, POINTER_PEN_INFO *))SDL_LoadFunction(data->userDLL, "GetPointerPenInfo"); + /* *INDENT-ON* */ // clang-format on + } else { + SDL_ClearError(); + } + + data->shcoreDLL = SDL_LoadObject("SHCORE.DLL"); + if (data->shcoreDLL) { + /* *INDENT-OFF* */ // clang-format off + data->GetDpiForMonitor = (HRESULT (WINAPI *)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *))SDL_LoadFunction(data->shcoreDLL, "GetDpiForMonitor"); + data->SetProcessDpiAwareness = (HRESULT (WINAPI *)(PROCESS_DPI_AWARENESS))SDL_LoadFunction(data->shcoreDLL, "SetProcessDpiAwareness"); + /* *INDENT-ON* */ // clang-format on + } else { + SDL_ClearError(); + } +#endif // #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#ifdef HAVE_DXGI_H + data->dxgiDLL = SDL_LoadObject("DXGI.DLL"); + if (data->dxgiDLL) { + /* *INDENT-OFF* */ // clang-format off + typedef HRESULT (WINAPI *CreateDXGI_t)(REFIID riid, void **ppFactory); + /* *INDENT-ON* */ // clang-format on + CreateDXGI_t CreateDXGI; + + CreateDXGI = (CreateDXGI_t)SDL_LoadFunction(data->dxgiDLL, "CreateDXGIFactory"); + if (CreateDXGI) { + GUID dxgiGUID = { 0x7b7166ec, 0x21c7, 0x44ae, { 0xb2, 0x1a, 0xc9, 0xae, 0x32, 0x1a, 0xe3, 0x69 } }; + CreateDXGI(&dxgiGUID, (void **)&data->pDXGIFactory); + } + } +#endif + + // Set the function pointers + device->VideoInit = WIN_VideoInit; + device->VideoQuit = WIN_VideoQuit; +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + device->RefreshDisplays = WIN_RefreshDisplays; + device->GetDisplayBounds = WIN_GetDisplayBounds; + device->GetDisplayUsableBounds = WIN_GetDisplayUsableBounds; + device->GetDisplayModes = WIN_GetDisplayModes; + device->SetDisplayMode = WIN_SetDisplayMode; +#endif + device->PumpEvents = WIN_PumpEvents; + device->WaitEventTimeout = WIN_WaitEventTimeout; +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + device->SendWakeupEvent = WIN_SendWakeupEvent; + device->SuspendScreenSaver = WIN_SuspendScreenSaver; +#endif + + device->CreateSDLWindow = WIN_CreateWindow; + device->SetWindowTitle = WIN_SetWindowTitle; + device->SetWindowIcon = WIN_SetWindowIcon; + device->SetWindowPosition = WIN_SetWindowPosition; + device->SetWindowSize = WIN_SetWindowSize; + device->GetWindowBordersSize = WIN_GetWindowBordersSize; + device->GetWindowSizeInPixels = WIN_GetWindowSizeInPixels; + device->SetWindowOpacity = WIN_SetWindowOpacity; + device->ShowWindow = WIN_ShowWindow; + device->HideWindow = WIN_HideWindow; + device->RaiseWindow = WIN_RaiseWindow; + device->MaximizeWindow = WIN_MaximizeWindow; + device->MinimizeWindow = WIN_MinimizeWindow; + device->RestoreWindow = WIN_RestoreWindow; + device->SetWindowBordered = WIN_SetWindowBordered; + device->SetWindowResizable = WIN_SetWindowResizable; + device->SetWindowAlwaysOnTop = WIN_SetWindowAlwaysOnTop; + device->SetWindowFullscreen = WIN_SetWindowFullscreen; + device->SetWindowParent = WIN_SetWindowParent; + device->SetWindowModal = WIN_SetWindowModal; +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + device->GetWindowICCProfile = WIN_GetWindowICCProfile; + device->SetWindowMouseRect = WIN_SetWindowMouseRect; + device->SetWindowMouseGrab = WIN_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = WIN_SetWindowKeyboardGrab; +#endif + device->DestroyWindow = WIN_DestroyWindow; +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer; + device->OnWindowEnter = WIN_OnWindowEnter; + device->SetWindowHitTest = WIN_SetWindowHitTest; + device->AcceptDragAndDrop = WIN_AcceptDragAndDrop; + device->FlashWindow = WIN_FlashWindow; + device->ShowWindowSystemMenu = WIN_ShowWindowSystemMenu; + device->SetWindowFocusable = WIN_SetWindowFocusable; + device->UpdateWindowShape = WIN_UpdateWindowShape; +#endif + +#ifdef SDL_VIDEO_OPENGL_WGL + device->GL_LoadLibrary = WIN_GL_LoadLibrary; + device->GL_GetProcAddress = WIN_GL_GetProcAddress; + device->GL_UnloadLibrary = WIN_GL_UnloadLibrary; + device->GL_CreateContext = WIN_GL_CreateContext; + device->GL_MakeCurrent = WIN_GL_MakeCurrent; + device->GL_SetSwapInterval = WIN_GL_SetSwapInterval; + device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; + device->GL_SwapWindow = WIN_GL_SwapWindow; + device->GL_DestroyContext = WIN_GL_DestroyContext; + device->GL_GetEGLSurface = NULL; +#endif +#ifdef SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_WGL + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { +#endif + // Use EGL based functions + device->GL_LoadLibrary = WIN_GLES_LoadLibrary; + device->GL_GetProcAddress = WIN_GLES_GetProcAddress; + device->GL_UnloadLibrary = WIN_GLES_UnloadLibrary; + device->GL_CreateContext = WIN_GLES_CreateContext; + device->GL_MakeCurrent = WIN_GLES_MakeCurrent; + device->GL_SetSwapInterval = WIN_GLES_SetSwapInterval; + device->GL_GetSwapInterval = WIN_GLES_GetSwapInterval; + device->GL_SwapWindow = WIN_GLES_SwapWindow; + device->GL_DestroyContext = WIN_GLES_DestroyContext; + device->GL_GetEGLSurface = WIN_GLES_GetEGLSurface; +#ifdef SDL_VIDEO_OPENGL_WGL + } +#endif +#endif +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = WIN_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = WIN_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = WIN_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = WIN_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = WIN_Vulkan_DestroySurface; + device->Vulkan_GetPresentationSupport = WIN_Vulkan_GetPresentationSupport; +#endif + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + device->StartTextInput = WIN_StartTextInput; + device->StopTextInput = WIN_StopTextInput; + device->UpdateTextInputArea = WIN_UpdateTextInputArea; + device->ClearComposition = WIN_ClearComposition; + + device->SetClipboardData = WIN_SetClipboardData; + device->GetClipboardData = WIN_GetClipboardData; + device->HasClipboardData = WIN_HasClipboardData; +#endif + +#ifdef SDL_GDK_TEXTINPUT + GDK_EnsureHints(); + + device->StartTextInput = GDK_StartTextInput; + device->StopTextInput = GDK_StopTextInput; + device->UpdateTextInputArea = GDK_UpdateTextInputArea; + device->ClearComposition = GDK_ClearComposition; + + device->HasScreenKeyboardSupport = GDK_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = GDK_ShowScreenKeyboard; + device->HideScreenKeyboard = GDK_HideScreenKeyboard; + device->IsScreenKeyboardShown = GDK_IsScreenKeyboardShown; +#endif + + device->free = WIN_DeleteDevice; + + device->device_caps = VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT | + VIDEO_DEVICE_CAPS_SENDS_FULLSCREEN_DIMENSIONS; + + return device; +} + +VideoBootStrap WINDOWS_bootstrap = { + "windows", "SDL Windows video driver", WIN_CreateDevice, + #if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + WIN_ShowMessageBox, + #else + NULL, + #endif + false +}; + +static BOOL WIN_DeclareDPIAwareUnaware(SDL_VideoDevice *_this) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + SDL_VideoData *data = _this->internal; + + if (data->SetProcessDpiAwarenessContext) { + return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_UNAWARE); + } else if (data->SetProcessDpiAwareness) { + // Windows 8.1 + return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_DPI_UNAWARE)); + } +#endif + return FALSE; +} + +static BOOL WIN_DeclareDPIAwareSystem(SDL_VideoDevice *_this) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + SDL_VideoData *data = _this->internal; + + if (data->SetProcessDpiAwarenessContext) { + // Windows 10, version 1607 + return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_SYSTEM_AWARE); + } else if (data->SetProcessDpiAwareness) { + // Windows 8.1 + return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)); + } else if (data->SetProcessDPIAware) { + // Windows Vista + return data->SetProcessDPIAware(); + } +#endif + return FALSE; +} + +static BOOL WIN_DeclareDPIAwarePerMonitor(SDL_VideoDevice *_this) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + SDL_VideoData *data = _this->internal; + + if (data->SetProcessDpiAwarenessContext) { + // Windows 10, version 1607 + return data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE); + } else if (data->SetProcessDpiAwareness) { + // Windows 8.1 + return SUCCEEDED(data->SetProcessDpiAwareness(PROCESS_PER_MONITOR_DPI_AWARE)); + } else { + // Older OS: fall back to system DPI aware + return WIN_DeclareDPIAwareSystem(_this); + } +#else + return FALSE; +#endif +} + +static BOOL WIN_DeclareDPIAwarePerMonitorV2(SDL_VideoDevice *_this) +{ +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + return FALSE; +#else + SDL_VideoData *data = _this->internal; + + // Declare DPI aware (may have been done in external code or a manifest, as well) + if (data->SetProcessDpiAwarenessContext) { + // Windows 10, version 1607 + + /* NOTE: SetThreadDpiAwarenessContext doesn't work here with OpenGL - the OpenGL contents + end up still getting OS scaled. (tested on Windows 10 21H1 19043.1348, NVIDIA 496.49) + + NOTE: Enabling DPI awareness through Windows Explorer + (right click .exe -> Properties -> Compatibility -> High DPI Settings -> + check "Override high DPI Scaling behaviour", select Application) gives + a DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE context (at least on Windows 10 21H1), and + setting DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 will fail. + + NOTE: Entering exclusive fullscreen in a DPI_AWARENESS_CONTEXT_UNAWARE process + appears to cause Windows to change the .exe manifest to DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE + on future launches. This means attempting to use DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 + will fail in the future until you manually clear the "Override high DPI Scaling behaviour" + setting in Windows Explorer (tested on Windows 10 21H2). + */ + if (data->SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)) { + return TRUE; + } else { + return WIN_DeclareDPIAwarePerMonitor(_this); + } + } else { + // Older OS: fall back to per-monitor (or system) + return WIN_DeclareDPIAwarePerMonitor(_this); + } +#endif +} + +#ifdef HIGHDPI_DEBUG +static const char *WIN_GetDPIAwareness(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + if (data->GetThreadDpiAwarenessContext && data->AreDpiAwarenessContextsEqual) { + DPI_AWARENESS_CONTEXT context = data->GetThreadDpiAwarenessContext(); + + if (data->AreDpiAwarenessContextsEqual(context, DPI_AWARENESS_CONTEXT_UNAWARE)) { + return "unaware"; + } else if (data->AreDpiAwarenessContextsEqual(context, DPI_AWARENESS_CONTEXT_SYSTEM_AWARE)) { + return "system"; + } else if (data->AreDpiAwarenessContextsEqual(context, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE)) { + return "permonitor"; + } else if (data->AreDpiAwarenessContextsEqual(context, DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2)) { + return "permonitorv2"; + } else if (data->AreDpiAwarenessContextsEqual(context, DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED)) { + return "unaware_gdiscaled"; + } + } + + return ""; +} +#endif + +static void WIN_InitDPIAwareness(SDL_VideoDevice *_this) +{ + const char *hint = SDL_GetHint("SDL_WINDOWS_DPI_AWARENESS"); + + if (!hint || SDL_strcmp(hint, "permonitorv2") == 0) { + WIN_DeclareDPIAwarePerMonitorV2(_this); + } else if (SDL_strcmp(hint, "permonitor") == 0) { + WIN_DeclareDPIAwarePerMonitor(_this); + } else if (SDL_strcmp(hint, "system") == 0) { + WIN_DeclareDPIAwareSystem(_this); + } else if (SDL_strcmp(hint, "unaware") == 0) { + WIN_DeclareDPIAwareUnaware(_this); + } +} + +static bool WIN_VideoInit(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + HRESULT hr; + + hr = WIN_CoInitialize(); + if (SUCCEEDED(hr)) { + data->coinitialized = true; + +#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + hr = OleInitialize(NULL); + if (SUCCEEDED(hr)) { + data->oleinitialized = true; + } else { + SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "OleInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality", (unsigned int)hr); + } +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + } else { + SDL_LogInfo(SDL_LOG_CATEGORY_VIDEO, "CoInitialize() failed: 0x%.8x, using fallback drag-n-drop functionality", (unsigned int)hr); + } + + WIN_InitDPIAwareness(_this); + +#ifdef HIGHDPI_DEBUG + SDL_Log("DPI awareness: %s", WIN_GetDPIAwareness(_this)); +#endif + + if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_GAMEINPUT, true)) { + WIN_InitGameInput(_this); + } + +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + // For Xbox, we just need to create the single display + { + SDL_DisplayMode mode; + + SDL_zero(mode); + D3D12_XBOX_GetResolution(&mode.w, &mode.h); + mode.refresh_rate = 60.0f; + mode.format = SDL_PIXELFORMAT_ARGB8888; + + SDL_AddBasicVideoDisplay(&mode); + } +#else // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (!WIN_InitModes(_this)) { + return false; + } + + WIN_InitKeyboard(_this); + WIN_InitMouse(_this); + WIN_InitDeviceNotification(); + if (!_this->internal->gameinput_context) { + WIN_CheckKeyboardAndMouseHotplug(_this, true); + } +#endif + + SDL_AddHintCallback(SDL_HINT_WINDOWS_RAW_KEYBOARD, UpdateWindowsRawKeyboard, _this); + SDL_AddHintCallback(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, UpdateWindowsEnableMessageLoop, NULL); + SDL_AddHintCallback(SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS, UpdateWindowsEnableMenuMnemonics, NULL); + SDL_AddHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL); + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + data->_SDL_WAKEUP = RegisterWindowMessageA("_SDL_WAKEUP"); +#endif + + return true; +} + +void WIN_VideoQuit(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + SDL_RemoveHintCallback(SDL_HINT_WINDOWS_RAW_KEYBOARD, UpdateWindowsRawKeyboard, _this); + SDL_RemoveHintCallback(SDL_HINT_WINDOWS_ENABLE_MESSAGELOOP, UpdateWindowsEnableMessageLoop, NULL); + SDL_RemoveHintCallback(SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS, UpdateWindowsEnableMenuMnemonics, NULL); + SDL_RemoveHintCallback(SDL_HINT_WINDOW_FRAME_USABLE_WHILE_CURSOR_HIDDEN, UpdateWindowFrameUsableWhileCursorHidden, NULL); + + WIN_SetRawMouseEnabled(_this, false); + WIN_SetRawKeyboardEnabled(_this, false); + WIN_QuitGameInput(_this); + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + WIN_QuitModes(_this); + WIN_QuitDeviceNotification(); + WIN_QuitKeyboard(_this); + WIN_QuitMouse(_this); + + if (data->oleinitialized) { + OleUninitialize(); + data->oleinitialized = false; + } +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + + if (data->coinitialized) { + WIN_CoUninitialize(); + data->coinitialized = false; + } +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#define D3D_DEBUG_INFO +#include + +#ifdef D3D_DEBUG_INFO +#ifndef D3D_SDK_VERSION +#define D3D_SDK_VERSION (32 | 0x80000000) +#endif +#ifndef D3D9b_SDK_VERSION +#define D3D9b_SDK_VERSION (31 | 0x80000000) +#endif +#else // +#ifndef D3D_SDK_VERSION +#define D3D_SDK_VERSION 32 +#endif +#ifndef D3D9b_SDK_VERSION +#define D3D9b_SDK_VERSION 31 +#endif +#endif + +bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface) +{ + *pD3DDLL = SDL_LoadObject("D3D9.DLL"); + if (*pD3DDLL) { + /* *INDENT-OFF* */ // clang-format off + typedef IDirect3D9 *(WINAPI *Direct3DCreate9_t)(UINT SDKVersion); + typedef HRESULT (WINAPI* Direct3DCreate9Ex_t)(UINT SDKVersion, IDirect3D9Ex** ppD3D); + /* *INDENT-ON* */ // clang-format on + Direct3DCreate9_t Direct3DCreate9Func; + + if (SDL_GetHintBoolean(SDL_HINT_WINDOWS_USE_D3D9EX, false)) { + Direct3DCreate9Ex_t Direct3DCreate9ExFunc; + + Direct3DCreate9ExFunc = (Direct3DCreate9Ex_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9Ex"); + if (Direct3DCreate9ExFunc) { + IDirect3D9Ex *pDirect3D9ExInterface; + HRESULT hr = Direct3DCreate9ExFunc(D3D_SDK_VERSION, &pDirect3D9ExInterface); + if (SUCCEEDED(hr)) { + const GUID IDirect3D9_GUID = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } }; + hr = IDirect3D9Ex_QueryInterface(pDirect3D9ExInterface, &IDirect3D9_GUID, (void **)pDirect3D9Interface); + IDirect3D9Ex_Release(pDirect3D9ExInterface); + if (SUCCEEDED(hr)) { + return true; + } + } + } + } + + Direct3DCreate9Func = (Direct3DCreate9_t)SDL_LoadFunction(*pD3DDLL, "Direct3DCreate9"); + if (Direct3DCreate9Func) { + *pDirect3D9Interface = Direct3DCreate9Func(D3D_SDK_VERSION); + if (*pDirect3D9Interface) { + return true; + } + } + + SDL_UnloadObject(*pD3DDLL); + *pD3DDLL = NULL; + } + *pDirect3D9Interface = NULL; + return false; +} + +int SDL_GetDirect3D9AdapterIndex(SDL_DisplayID displayID) +{ + void *pD3DDLL; + IDirect3D9 *pD3D; + if (!D3D_LoadDLL(&pD3DDLL, &pD3D)) { + SDL_SetError("Unable to create Direct3D interface"); + return -1; + } else { + SDL_DisplayData *pData = SDL_GetDisplayDriverData(displayID); + int adapterIndex = D3DADAPTER_DEFAULT; + + if (!pData) { + SDL_SetError("Invalid display index"); + adapterIndex = -1; // make sure we return something invalid + } else { + char *displayName = WIN_StringToUTF8W(pData->DeviceName); + unsigned int count = IDirect3D9_GetAdapterCount(pD3D); + unsigned int i; + for (i = 0; i < count; i++) { + D3DADAPTER_IDENTIFIER9 id; + IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &id); + + if (SDL_strcmp(id.DeviceName, displayName) == 0) { + adapterIndex = i; + break; + } + } + SDL_free(displayName); + } + + // free up the D3D stuff we inited + IDirect3D9_Release(pD3D); + SDL_UnloadObject(pD3DDLL); + + return adapterIndex; + } +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +bool SDL_GetDXGIOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *outputIndex) +{ +#ifndef HAVE_DXGI_H + if (adapterIndex) { + *adapterIndex = -1; + } + if (outputIndex) { + *outputIndex = -1; + } + return SDL_SetError("SDL was compiled without DXGI support due to missing dxgi.h header"); +#else + const SDL_VideoDevice *videodevice = SDL_GetVideoDevice(); + const SDL_VideoData *videodata = videodevice ? videodevice->internal : NULL; + SDL_DisplayData *pData = SDL_GetDisplayDriverData(displayID); + int nAdapter, nOutput; + IDXGIAdapter *pDXGIAdapter; + IDXGIOutput *pDXGIOutput; + + if (!adapterIndex) { + return SDL_InvalidParamError("adapterIndex"); + } + + if (!outputIndex) { + return SDL_InvalidParamError("outputIndex"); + } + + *adapterIndex = -1; + *outputIndex = -1; + + if (!pData) { + return SDL_SetError("Invalid display index"); + } + + if (!videodata || !videodata->pDXGIFactory) { + return SDL_SetError("Unable to create DXGI interface"); + } + + nAdapter = 0; + while (*adapterIndex == -1 && SUCCEEDED(IDXGIFactory_EnumAdapters(videodata->pDXGIFactory, nAdapter, &pDXGIAdapter))) { + nOutput = 0; + while (*adapterIndex == -1 && SUCCEEDED(IDXGIAdapter_EnumOutputs(pDXGIAdapter, nOutput, &pDXGIOutput))) { + DXGI_OUTPUT_DESC outputDesc; + if (SUCCEEDED(IDXGIOutput_GetDesc(pDXGIOutput, &outputDesc))) { + if (SDL_wcscmp(outputDesc.DeviceName, pData->DeviceName) == 0) { + *adapterIndex = nAdapter; + *outputIndex = nOutput; + } + } + IDXGIOutput_Release(pDXGIOutput); + nOutput++; + } + IDXGIAdapter_Release(pDXGIAdapter); + nAdapter++; + } + + if (*adapterIndex == -1) { + return SDL_SetError("Couldn't find matching adapter"); + } + return true; +#endif +} + +SDL_SystemTheme WIN_GetSystemTheme(void) +{ + SDL_SystemTheme theme = SDL_SYSTEM_THEME_LIGHT; + HKEY hKey; + DWORD dwType = REG_DWORD; + DWORD value = ~0U; + DWORD length = sizeof(value); + + // Technically this isn't the system theme, but it's the preference for applications + if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey) == ERROR_SUCCESS) { + if (RegQueryValueExW(hKey, L"AppsUseLightTheme", 0, &dwType, (LPBYTE)&value, &length) == ERROR_SUCCESS) { + if (value == 0) { + theme = SDL_SYSTEM_THEME_DARK; + } + } + RegCloseKey(hKey); + } + return theme; +} + +bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + SDL_VideoData *data = _this->internal; + + if (data->AreDpiAwarenessContextsEqual && data->GetThreadDpiAwarenessContext) { + // Windows 10, version 1607 + return data->AreDpiAwarenessContextsEqual(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2, data->GetThreadDpiAwarenessContext()); + } +#endif + return false; +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.h new file mode 100644 index 0000000..53cfbad --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvideo.h @@ -0,0 +1,507 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowsvideo_h_ +#define SDL_windowsvideo_h_ + +#include "../../core/windows/SDL_windows.h" + +#include "../SDL_sysvideo.h" + +#ifdef HAVE_DXGI_H +#define CINTERFACE +#define COBJMACROS +#include +#endif + +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#include +#else +#include "SDL_msctf.h" +#endif + +#include + +#define MAX_CANDLIST 10 +#define MAX_CANDLENGTH 256 +#define MAX_CANDSIZE (sizeof(WCHAR) * MAX_CANDLIST * MAX_CANDLENGTH) + +#include "SDL_windowsclipboard.h" +#include "SDL_windowsevents.h" +#include "SDL_windowsgameinput.h" +#include "SDL_windowsopengl.h" + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +#include "SDL_windowsshape.h" +#include "SDL_windowskeyboard.h" +#include "SDL_windowsmodes.h" +#include "SDL_windowsmouse.h" +#include "SDL_windowsopengles.h" +#endif + +#include "SDL_windowswindow.h" + +#ifndef USER_DEFAULT_SCREEN_DPI +#define USER_DEFAULT_SCREEN_DPI 96 +#endif + +#if WINVER < 0x0601 +// Touch input definitions +#define TWF_FINETOUCH 1 +#define TWF_WANTPALM 2 + +#define TOUCHEVENTF_MOVE 0x0001 +#define TOUCHEVENTF_DOWN 0x0002 +#define TOUCHEVENTF_UP 0x0004 + +DECLARE_HANDLE(HTOUCHINPUT); + +typedef struct _TOUCHINPUT +{ + LONG x; + LONG y; + HANDLE hSource; + DWORD dwID; + DWORD dwFlags; + DWORD dwMask; + DWORD dwTime; + ULONG_PTR dwExtraInfo; + DWORD cxContact; + DWORD cyContact; +} TOUCHINPUT, *PTOUCHINPUT; + +// More-robust display information in Vista... +// This is a huge amount of data to be stuffing into three API calls. :( +typedef struct DISPLAYCONFIG_PATH_SOURCE_INFO +{ + LUID adapterId; + UINT32 id; + union + { + UINT32 modeInfoIdx; + struct + { + UINT32 cloneGroupId : 16; + UINT32 sourceModeInfoIdx : 16; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + + UINT32 statusFlags; +} DISPLAYCONFIG_PATH_SOURCE_INFO; + +typedef struct DISPLAYCONFIG_RATIONAL +{ + UINT32 Numerator; + UINT32 Denominator; +} DISPLAYCONFIG_RATIONAL; + +typedef struct DISPLAYCONFIG_PATH_TARGET_INFO +{ + LUID adapterId; + UINT32 id; + union + { + UINT32 modeInfoIdx; + struct + { + UINT32 desktopModeInfoIdx : 16; + UINT32 targetModeInfoIdx : 16; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; + UINT32 /*DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY*/ outputTechnology; + UINT32 /*DISPLAYCONFIG_ROTATION*/ rotation; + UINT32 /*DISPLAYCONFIG_SCALING*/ scaling; + DISPLAYCONFIG_RATIONAL refreshRate; + UINT32 /*DISPLAYCONFIG_SCANLINE_ORDERING*/ scanLineOrdering; + BOOL targetAvailable; + UINT32 statusFlags; +} DISPLAYCONFIG_PATH_TARGET_INFO; + +typedef struct DISPLAYCONFIG_PATH_INFO +{ + DISPLAYCONFIG_PATH_SOURCE_INFO sourceInfo; + DISPLAYCONFIG_PATH_TARGET_INFO targetInfo; + UINT32 flags; +} DISPLAYCONFIG_PATH_INFO; + +typedef enum +{ + DISPLAYCONFIG_MODE_INFO_TYPE_SOURCE = 1, + DISPLAYCONFIG_MODE_INFO_TYPE_TARGET = 2, + DISPLAYCONFIG_MODE_INFO_TYPE_DESKTOP_IMAGE = 3, + DISPLAYCONFIG_MODE_INFO_TYPE_FORCE_UINT32 = 0xFFFFFFFF +} DISPLAYCONFIG_MODE_INFO_TYPE; + +typedef struct DISPLAYCONFIG_2DREGION +{ + UINT32 cx; + UINT32 cy; +} DISPLAYCONFIG_2DREGION; + +typedef struct DISPLAYCONFIG_VIDEO_SIGNAL_INFO +{ + UINT64 pixelRate; + DISPLAYCONFIG_RATIONAL hSyncFreq; + DISPLAYCONFIG_RATIONAL vSyncFreq; + DISPLAYCONFIG_2DREGION activeSize; + DISPLAYCONFIG_2DREGION totalSize; + + union + { + struct + { + UINT32 videoStandard : 16; + + // Vertical refresh frequency divider + UINT32 vSyncFreqDivider : 6; + + UINT32 reserved : 10; + } AdditionalSignalInfo; + + UINT32 videoStandard; + } DUMMYUNIONNAME; + + // Scan line ordering (e.g. progressive, interlaced). + UINT32 /*DISPLAYCONFIG_SCANLINE_ORDERING*/ scanLineOrdering; +} DISPLAYCONFIG_VIDEO_SIGNAL_INFO; + +typedef struct DISPLAYCONFIG_SOURCE_MODE +{ + UINT32 width; + UINT32 height; + UINT32 /*DISPLAYCONFIG_PIXELFORMAT*/ pixelFormat; + POINTL position; +} DISPLAYCONFIG_SOURCE_MODE; + +typedef struct DISPLAYCONFIG_TARGET_MODE +{ + DISPLAYCONFIG_VIDEO_SIGNAL_INFO targetVideoSignalInfo; +} DISPLAYCONFIG_TARGET_MODE; + +typedef struct DISPLAYCONFIG_DESKTOP_IMAGE_INFO +{ + POINTL PathSourceSize; + RECTL DesktopImageRegion; + RECTL DesktopImageClip; +} DISPLAYCONFIG_DESKTOP_IMAGE_INFO; + +typedef struct DISPLAYCONFIG_MODE_INFO +{ + DISPLAYCONFIG_MODE_INFO_TYPE infoType; + UINT32 id; + LUID adapterId; + union + { + DISPLAYCONFIG_TARGET_MODE targetMode; + DISPLAYCONFIG_SOURCE_MODE sourceMode; + DISPLAYCONFIG_DESKTOP_IMAGE_INFO desktopImageInfo; + } DUMMYUNIONNAME; +} DISPLAYCONFIG_MODE_INFO; + +typedef enum DISPLAYCONFIG_TOPOLOGY_ID +{ + DISPLAYCONFIG_TOPOLOGY_INTERNAL = 0x00000001, + DISPLAYCONFIG_TOPOLOGY_CLONE = 0x00000002, + DISPLAYCONFIG_TOPOLOGY_EXTEND = 0x00000004, + DISPLAYCONFIG_TOPOLOGY_EXTERNAL = 0x00000008, + DISPLAYCONFIG_TOPOLOGY_FORCE_UINT32 = 0xFFFFFFFF +} DISPLAYCONFIG_TOPOLOGY_ID; + +typedef enum +{ + DISPLAYCONFIG_DEVICE_INFO_GET_SOURCE_NAME = 1, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_NAME = 2, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_PREFERRED_MODE = 3, + DISPLAYCONFIG_DEVICE_INFO_GET_ADAPTER_NAME = 4, + DISPLAYCONFIG_DEVICE_INFO_SET_TARGET_PERSISTENCE = 5, + DISPLAYCONFIG_DEVICE_INFO_GET_TARGET_BASE_TYPE = 6, + DISPLAYCONFIG_DEVICE_INFO_GET_SUPPORT_VIRTUAL_RESOLUTION = 7, + DISPLAYCONFIG_DEVICE_INFO_SET_SUPPORT_VIRTUAL_RESOLUTION = 8, + DISPLAYCONFIG_DEVICE_INFO_GET_ADVANCED_COLOR_INFO = 9, + DISPLAYCONFIG_DEVICE_INFO_SET_ADVANCED_COLOR_STATE = 10, + DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL = 11, + DISPLAYCONFIG_DEVICE_INFO_FORCE_UINT32 = 0xFFFFFFFF +} DISPLAYCONFIG_DEVICE_INFO_TYPE; + +typedef struct DISPLAYCONFIG_DEVICE_INFO_HEADER +{ + DISPLAYCONFIG_DEVICE_INFO_TYPE type; + UINT32 size; + LUID adapterId; + UINT32 id; +} DISPLAYCONFIG_DEVICE_INFO_HEADER; + +typedef struct DISPLAYCONFIG_SOURCE_DEVICE_NAME +{ + DISPLAYCONFIG_DEVICE_INFO_HEADER header; + WCHAR viewGdiDeviceName[CCHDEVICENAME]; +} DISPLAYCONFIG_SOURCE_DEVICE_NAME; + +typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS +{ + union + { + struct + { + UINT32 friendlyNameFromEdid : 1; + UINT32 friendlyNameForced : 1; + UINT32 edidIdsValid : 1; + UINT32 reserved : 29; + } DUMMYSTRUCTNAME; + UINT32 value; + } DUMMYUNIONNAME; +} DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS; + +typedef struct DISPLAYCONFIG_TARGET_DEVICE_NAME +{ + DISPLAYCONFIG_DEVICE_INFO_HEADER header; + DISPLAYCONFIG_TARGET_DEVICE_NAME_FLAGS flags; + UINT32 /*DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY*/ outputTechnology; + UINT16 edidManufactureId; + UINT16 edidProductCodeId; + UINT32 connectorInstance; + WCHAR monitorFriendlyDeviceName[64]; + WCHAR monitorDevicePath[128]; +} DISPLAYCONFIG_TARGET_DEVICE_NAME; + +#define QDC_ONLY_ACTIVE_PATHS 0x00000002 + +#endif // WINVER < 0x0601 + +#ifndef HAVE_SHELLSCALINGAPI_H + +typedef enum MONITOR_DPI_TYPE +{ + MDT_EFFECTIVE_DPI = 0, + MDT_ANGULAR_DPI = 1, + MDT_RAW_DPI = 2, + MDT_DEFAULT = MDT_EFFECTIVE_DPI +} MONITOR_DPI_TYPE; + +typedef enum PROCESS_DPI_AWARENESS +{ + PROCESS_DPI_UNAWARE = 0, + PROCESS_SYSTEM_DPI_AWARE = 1, + PROCESS_PER_MONITOR_DPI_AWARE = 2 +} PROCESS_DPI_AWARENESS; + +#else +#include +#endif + +#ifndef _DPI_AWARENESS_CONTEXTS_ + +typedef enum DPI_AWARENESS +{ + DPI_AWARENESS_INVALID = -1, + DPI_AWARENESS_UNAWARE = 0, + DPI_AWARENESS_SYSTEM_AWARE = 1, + DPI_AWARENESS_PER_MONITOR_AWARE = 2 +} DPI_AWARENESS; + +DECLARE_HANDLE(DPI_AWARENESS_CONTEXT); + +#define DPI_AWARENESS_CONTEXT_UNAWARE ((DPI_AWARENESS_CONTEXT)-1) +#define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE ((DPI_AWARENESS_CONTEXT)-2) +#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ((DPI_AWARENESS_CONTEXT)-3) + +#endif // _DPI_AWARENESS_CONTEXTS_ + +// Windows 10 Creators Update +#if NTDDI_VERSION < 0x0A000003 +#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4) +#endif // NTDDI_VERSION < 0x0A000003 + +// Windows 10 version 1809 +#if NTDDI_VERSION < 0x0A000006 +#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5) +#endif // NTDDI_VERSION < 0x0A000006 + +typedef BOOL (*PFNSHFullScreen)(HWND, DWORD); +typedef void (*PFCoordTransform)(SDL_Window *, POINT *); + +typedef struct +{ + void **lpVtbl; + int refcount; + void *data; +} TSFSink; + +#ifndef SDL_DISABLE_WINDOWS_IME +// Definition from Win98DDK version of IMM.H +typedef struct tagINPUTCONTEXT2 +{ + HWND hWnd; + BOOL fOpen; + POINT ptStatusWndPos; + POINT ptSoftKbdPos; + DWORD fdwConversion; + DWORD fdwSentence; + union + { + LOGFONTA A; + LOGFONTW W; + } lfFont; + COMPOSITIONFORM cfCompForm; + CANDIDATEFORM cfCandForm[4]; + HIMCC hCompStr; + HIMCC hCandInfo; + HIMCC hGuideLine; + HIMCC hPrivate; + DWORD dwNumMsgBuf; + HIMCC hMsgBuf; + DWORD fdwInit; + DWORD dwReserve[3]; +} INPUTCONTEXT2, *PINPUTCONTEXT2, NEAR *NPINPUTCONTEXT2, FAR *LPINPUTCONTEXT2; +#endif + +// Private display data + +struct SDL_VideoData +{ + int render; + + bool coinitialized; +#if !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + bool oleinitialized; +#endif // !(defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES)) + + DWORD clipboard_count; + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) // Xbox doesn't support user32/shcore + // Touch input functions + SDL_SharedObject *userDLL; + /* *INDENT-OFF* */ // clang-format off + BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); + BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); + BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); + BOOL (WINAPI *SetProcessDPIAware)( void ); + BOOL (WINAPI *SetProcessDpiAwarenessContext)( DPI_AWARENESS_CONTEXT ); + DPI_AWARENESS_CONTEXT (WINAPI *SetThreadDpiAwarenessContext)( DPI_AWARENESS_CONTEXT ); + DPI_AWARENESS_CONTEXT (WINAPI *GetThreadDpiAwarenessContext)( void ); + DPI_AWARENESS (WINAPI *GetAwarenessFromDpiAwarenessContext)( DPI_AWARENESS_CONTEXT ); + BOOL (WINAPI *EnableNonClientDpiScaling)( HWND ); + BOOL (WINAPI *AdjustWindowRectExForDpi)( LPRECT, DWORD, BOOL, DWORD, UINT ); + UINT (WINAPI *GetDpiForWindow)( HWND ); + BOOL (WINAPI *AreDpiAwarenessContextsEqual)(DPI_AWARENESS_CONTEXT, DPI_AWARENESS_CONTEXT); + BOOL (WINAPI *IsValidDpiAwarenessContext)(DPI_AWARENESS_CONTEXT); + // DisplayConfig functions + LONG (WINAPI *GetDisplayConfigBufferSizes)( UINT32, UINT32*, UINT32* ); + LONG (WINAPI *QueryDisplayConfig)( UINT32, UINT32*, DISPLAYCONFIG_PATH_INFO*, UINT32*, DISPLAYCONFIG_MODE_INFO*, DISPLAYCONFIG_TOPOLOGY_ID*); + LONG (WINAPI *DisplayConfigGetDeviceInfo)( DISPLAYCONFIG_DEVICE_INFO_HEADER*); + /* *INDENT-ON* */ // clang-format on + + SDL_SharedObject *shcoreDLL; + /* *INDENT-OFF* */ // clang-format off + HRESULT (WINAPI *GetDpiForMonitor)( HMONITOR hmonitor, + MONITOR_DPI_TYPE dpiType, + UINT *dpiX, + UINT *dpiY ); + HRESULT (WINAPI *SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS dpiAwareness); + BOOL (WINAPI *GetPointerType)(UINT32 pointerId, POINTER_INPUT_TYPE *pointerType); + BOOL (WINAPI *GetPointerPenInfo)(UINT32 pointerId, POINTER_PEN_INFO *penInfo); + + /* *INDENT-ON* */ // clang-format on +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#ifdef HAVE_DXGI_H + SDL_SharedObject *dxgiDLL; + IDXGIFactory *pDXGIFactory; +#endif + + bool cleared; + + BYTE *rawinput; + UINT rawinput_offset; + UINT rawinput_size; + UINT rawinput_count; + Uint64 last_rawinput_poll; + SDL_Point last_raw_mouse_position; + bool raw_mouse_enabled; + bool raw_keyboard_enabled; + bool pending_E1_key_sequence; + Uint32 raw_input_enabled; + + WIN_GameInputData *gameinput_context; + +#ifndef SDL_DISABLE_WINDOWS_IME + bool ime_initialized; + bool ime_enabled; + bool ime_available; + bool ime_internal_composition; + bool ime_internal_candidates; + HWND ime_hwnd_main; + HWND ime_hwnd_current; + bool ime_needs_clear_composition; + HIMC ime_himc; + + WCHAR *ime_composition; + int ime_composition_length; + WCHAR ime_readingstring[16]; + int ime_cursor; + int ime_selected_start; + int ime_selected_length; + + bool ime_candidates_open; + bool ime_update_candidates; + char *ime_candidates[MAX_CANDLIST]; + int ime_candcount; + DWORD ime_candref; + DWORD ime_candsel; + int ime_candlistindexbase; + bool ime_horizontal_candidates; +#endif + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + COMPOSITIONFORM ime_composition_area; + CANDIDATEFORM ime_candidate_area; +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +#ifndef SDL_DISABLE_WINDOWS_IME + HKL ime_hkl; + SDL_SharedObject *ime_himm32; + /* *INDENT-OFF* */ // clang-format off + UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen); + BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow); + LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc); + BOOL (WINAPI *ImmUnlockIMC)(HIMC himc); + LPVOID (WINAPI *ImmLockIMCC)(HIMCC himcc); + BOOL (WINAPI *ImmUnlockIMCC)(HIMCC himcc); + /* *INDENT-ON* */ // clang-format on + +#endif // !SDL_DISABLE_WINDOWS_IME + + BYTE pre_hook_key_state[256]; + UINT _SDL_WAKEUP; +}; + +extern bool g_WindowsEnableMessageLoop; +extern bool g_WindowsEnableMenuMnemonics; +extern bool g_WindowFrameUsableWhileCursorHidden; + +typedef struct IDirect3D9 IDirect3D9; +extern bool D3D_LoadDLL(void **pD3DDLL, IDirect3D9 **pDirect3D9Interface); + +extern SDL_SystemTheme WIN_GetSystemTheme(void); +extern bool WIN_IsPerMonitorV2DPIAware(SDL_VideoDevice *_this); + +#endif // SDL_windowsvideo_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.c new file mode 100644 index 0000000..0b16d55 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.c @@ -0,0 +1,195 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.c. + */ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WINDOWS) + +#include "../SDL_vulkan_internal.h" + +#include "SDL_windowsvideo.h" +#include "SDL_windowswindow.h" + +#include "SDL_windowsvulkan.h" + +bool WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + VkExtensionProperties *extensions = NULL; + Uint32 extensionCount = 0; + Uint32 i; + bool hasSurfaceExtension = false; + bool hasWin32SurfaceExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan already loaded"); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + if (!path) { + path = "vulkan-1.dll"; + } + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + if (!_this->vulkan_config.loader_handle) { + return false; + } + SDL_strlcpy(_this->vulkan_config.loader_path, path, + SDL_arraysize(_this->vulkan_config.loader_path)); + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + if (!vkGetInstanceProcAddr) { + goto fail; + } + _this->vulkan_config.vkGetInstanceProcAddr = (SDL_FunctionPointer)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (SDL_FunctionPointer)vkGetInstanceProcAddr( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + if (!extensions) { + goto fail; + } + for (i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_KHR_WIN32_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasWin32SurfaceExtension = true; + } + } + SDL_free(extensions); + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else if (!hasWin32SurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_WIN32_SURFACE_EXTENSION_NAME "extension"); + goto fail; + } + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void WIN_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + if (_this->vulkan_config.loader_handle) { + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + } +} + +char const* const* WIN_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ + static const char *const extensionsForWin32[] = { + VK_KHR_SURFACE_EXTENSION_NAME, VK_KHR_WIN32_SURFACE_EXTENSION_NAME + }; + if (count) { + *count = SDL_arraysize(extensionsForWin32); + } + return extensionsForWin32; +} + +bool WIN_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + SDL_WindowData *windowData = window->internal; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = + (PFN_vkCreateWin32SurfaceKHR)vkGetInstanceProcAddr( + instance, + "vkCreateWin32SurfaceKHR"); + VkWin32SurfaceCreateInfoKHR createInfo; + VkResult result; + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + if (!vkCreateWin32SurfaceKHR) { + return SDL_SetError(VK_KHR_WIN32_SURFACE_EXTENSION_NAME + " extension is not enabled in the Vulkan instance."); + } + createInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; + createInfo.pNext = NULL; + createInfo.flags = 0; + createInfo.hinstance = windowData->hinstance; + createInfo.hwnd = windowData->hwnd; + result = vkCreateWin32SurfaceKHR(instance, &createInfo, allocator, surface); + if (result != VK_SUCCESS) { + return SDL_SetError("vkCreateWin32SurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); + } + return true; +} + +void WIN_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + } +} + +bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, + VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex) +{ + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = + (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR vkGetPhysicalDeviceWin32PresentationSupportKHR = + (PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)vkGetInstanceProcAddr( + instance, + "vkGetPhysicalDeviceWin32PresentationSupportKHR"); + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + + if (!vkGetPhysicalDeviceWin32PresentationSupportKHR) { + return SDL_SetError(VK_KHR_WIN32_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); + } + + return vkGetPhysicalDeviceWin32PresentationSupportKHR(physicalDevice, + queueFamilyIndex); +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.h new file mode 100644 index 0000000..34f3a66 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowsvulkan.h @@ -0,0 +1,55 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* + * @author Mark Callow, www.edgewise-consulting.com. Based on Jacob Lifshay's + * SDL_x11vulkan.h. + */ + +#include "SDL_internal.h" + +#ifndef SDL_windowsvulkan_h_ +#define SDL_windowsvulkan_h_ + +#include + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_WINDOWS) + +extern bool WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void WIN_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* WIN_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool WIN_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void WIN_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); +bool WIN_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, + VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex); + +#endif + +#endif // SDL_windowsvulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.c b/contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.c new file mode 100644 index 0000000..36c8de7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.c @@ -0,0 +1,2435 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_WINDOWS + +#include "../../core/windows/SDL_windows.h" + +#include "../../SDL_hints_c.h" +#include "../../events/SDL_dropevents_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_windowevents_c.h" +#include "../SDL_pixels_c.h" +#include "../SDL_sysvideo.h" + +#include "SDL_windowsvideo.h" +#include "SDL_windowswindow.h" + +// Dropfile support +#include + +// DWM setting support +typedef HRESULT (WINAPI *DwmSetWindowAttribute_t)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute); +typedef HRESULT (WINAPI *DwmGetWindowAttribute_t)(HWND hwnd, DWORD dwAttribute, PVOID pvAttribute, DWORD cbAttribute); + +// Dark mode support +typedef enum { + UXTHEME_APPMODE_DEFAULT, + UXTHEME_APPMODE_ALLOW_DARK, + UXTHEME_APPMODE_FORCE_DARK, + UXTHEME_APPMODE_FORCE_LIGHT, + UXTHEME_APPMODE_MAX +} UxthemePreferredAppMode; + +typedef enum { + WCA_UNDEFINED = 0, + WCA_USEDARKMODECOLORS = 26, + WCA_LAST = 27 +} WINDOWCOMPOSITIONATTRIB; + +typedef struct { + WINDOWCOMPOSITIONATTRIB Attrib; + PVOID pvData; + SIZE_T cbData; +} WINDOWCOMPOSITIONATTRIBDATA; + +typedef struct { + ULONG dwOSVersionInfoSize; + ULONG dwMajorVersion; + ULONG dwMinorVersion; + ULONG dwBuildNumber; + ULONG dwPlatformId; + WCHAR szCSDVersion[128]; +} NT_OSVERSIONINFOW; + +typedef bool (WINAPI *ShouldAppsUseDarkMode_t)(void); +typedef void (WINAPI *AllowDarkModeForWindow_t)(HWND, bool); +typedef void (WINAPI *AllowDarkModeForApp_t)(bool); +typedef void (WINAPI *RefreshImmersiveColorPolicyState_t)(void); +typedef UxthemePreferredAppMode (WINAPI *SetPreferredAppMode_t)(UxthemePreferredAppMode); +typedef BOOL (WINAPI *SetWindowCompositionAttribute_t)(HWND, const WINDOWCOMPOSITIONATTRIBDATA *); +typedef void (NTAPI *RtlGetVersion_t)(NT_OSVERSIONINFOW *); + +// Corner rounding support (Win 11+) +#ifndef DWMWA_WINDOW_CORNER_PREFERENCE +#define DWMWA_WINDOW_CORNER_PREFERENCE 33 +#endif +typedef enum { + DWMWCP_DEFAULT = 0, + DWMWCP_DONOTROUND = 1, + DWMWCP_ROUND = 2, + DWMWCP_ROUNDSMALL = 3 +} DWM_WINDOW_CORNER_PREFERENCE; + +// Border Color support (Win 11+) +#ifndef DWMWA_BORDER_COLOR +#define DWMWA_BORDER_COLOR 34 +#endif + +#ifndef DWMWA_COLOR_DEFAULT +#define DWMWA_COLOR_DEFAULT 0xFFFFFFFF +#endif + +#ifndef DWMWA_COLOR_NONE +#define DWMWA_COLOR_NONE 0xFFFFFFFE +#endif + +// Transparent window support +#ifndef DWM_BB_ENABLE +#define DWM_BB_ENABLE 0x00000001 +#endif +#ifndef DWM_BB_BLURREGION +#define DWM_BB_BLURREGION 0x00000002 +#endif +typedef struct +{ + DWORD flags; + BOOL enable; + HRGN blur_region; + BOOL transition_on_maxed; +} DWM_BLURBEHIND; +typedef HRESULT(WINAPI *DwmEnableBlurBehindWindow_t)(HWND hwnd, const DWM_BLURBEHIND *pBlurBehind); + +// Windows CE compatibility +#ifndef SWP_NOCOPYBITS +#define SWP_NOCOPYBITS 0 +#endif + +/* An undocumented message to create a popup system menu + * - wParam is always 0 + * - lParam = MAKELONG(x, y) where x and y are the screen coordinates where the menu should be displayed + */ +#ifndef WM_POPUPSYSTEMMENU +#define WM_POPUPSYSTEMMENU 0x313 +#endif + +// #define HIGHDPI_DEBUG + +// Fake window to help with DirectInput events. +HWND SDL_HelperWindow = NULL; +static const TCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher"); +static const TCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow"); +static ATOM SDL_HelperWindowClass = 0; + +/* For borderless Windows, still want the following flag: + - WS_MINIMIZEBOX: window will respond to Windows minimize commands sent to all windows, such as windows key + m, shaking title bar, etc. + Additionally, non-fullscreen windows can add: + - WS_CAPTION: this seems to enable the Windows minimize animation + - WS_SYSMENU: enables system context menu on task bar + This will also cause the task bar to overlap the window and other windowed behaviors, so only use this for windows that shouldn't appear to be fullscreen + - WS_THICKFRAME: allows hit-testing to resize window (doesn't actually add a frame to a borderless window). + - WS_MAXIMIZEBOX: window will respond to Windows maximize commands sent to all windows, and the window will fill the usable desktop area rather than the whole screen + */ + +#define STYLE_BASIC (WS_CLIPSIBLINGS | WS_CLIPCHILDREN) +#define STYLE_FULLSCREEN (WS_POPUP | WS_MINIMIZEBOX) +#define STYLE_BORDERLESS (WS_POPUP | WS_MINIMIZEBOX) +#define STYLE_BORDERLESS_WINDOWED (WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX) +#define STYLE_NORMAL (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX) +#define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX) +#define STYLE_MASK (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE) + +static DWORD GetWindowStyle(SDL_Window *window) +{ + DWORD style = 0; + + if (SDL_WINDOW_IS_POPUP(window)) { + style |= WS_POPUP; + } else if (window->flags & SDL_WINDOW_FULLSCREEN) { + style |= STYLE_FULLSCREEN; + } else { + if (window->flags & SDL_WINDOW_BORDERLESS) { + /* This behavior more closely matches other platform where the window is borderless + but still interacts with the window manager (e.g. task bar shows above it, it can + be resized to fit within usable desktop area, etc.) + */ + if (SDL_GetHintBoolean("SDL_BORDERLESS_WINDOWED_STYLE", true)) { + style |= STYLE_BORDERLESS_WINDOWED; + } else { + style |= STYLE_BORDERLESS; + } + } else { + style |= STYLE_NORMAL; + } + + /* The WS_MAXIMIZEBOX style flag needs to be retained for as long as the window is maximized, + * or restoration from minimized can fail, and leaving maximized can result in an odd size. + */ + if (window->flags & SDL_WINDOW_RESIZABLE) { + /* You can have a borderless resizable window, but Windows doesn't always draw it correctly, + see https://bugzilla.libsdl.org/show_bug.cgi?id=4466 + */ + if (!(window->flags & SDL_WINDOW_BORDERLESS) || + SDL_GetHintBoolean("SDL_BORDERLESS_RESIZABLE_STYLE", true)) { + style |= STYLE_RESIZABLE; + } + } + + if (window->internal && window->internal->force_ws_maximizebox) { + /* Even if the resizable flag is cleared, WS_MAXIMIZEBOX is still needed as long + * as the window is maximized, or de-maximizing or minimizing and restoring the + * maximized window can result in the window disappearing or being the wrong size. + */ + style |= WS_MAXIMIZEBOX; + } + + // Need to set initialize minimize style, or when we call ShowWindow with WS_MINIMIZE it will activate a random window + if (window->flags & SDL_WINDOW_MINIMIZED) { + style |= WS_MINIMIZE; + } + } + return style; +} + +static DWORD GetWindowStyleEx(SDL_Window *window) +{ + DWORD style = 0; + + if (SDL_WINDOW_IS_POPUP(window) || (window->flags & SDL_WINDOW_UTILITY)) { + style |= WS_EX_TOOLWINDOW; + } + if (SDL_WINDOW_IS_POPUP(window) || (window->flags & SDL_WINDOW_NOT_FOCUSABLE)) { + style |= WS_EX_NOACTIVATE; + } + return style; +} + +/** + * Returns arguments to pass to SetWindowPos - the window rect, including frame, in Windows coordinates. + * Can be called before we have a HWND. + */ +static bool WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, DWORD styleEx, BOOL menu, int *x, int *y, int *width, int *height, SDL_WindowRect rect_type) +{ + SDL_VideoData *videodata = SDL_GetVideoDevice() ? SDL_GetVideoDevice()->internal : NULL; + RECT rect; + + // Client rect, in points + switch (rect_type) { + case SDL_WINDOWRECT_CURRENT: + SDL_RelativeToGlobalForWindow(window, window->x, window->y, x, y); + *width = window->w; + *height = window->h; + break; + case SDL_WINDOWRECT_WINDOWED: + SDL_RelativeToGlobalForWindow(window, window->windowed.x, window->windowed.y, x, y); + *width = window->windowed.w; + *height = window->windowed.h; + break; + case SDL_WINDOWRECT_FLOATING: + SDL_RelativeToGlobalForWindow(window, window->floating.x, window->floating.y, x, y); + *width = window->floating.w; + *height = window->floating.h; + break; + case SDL_WINDOWRECT_PENDING: + SDL_RelativeToGlobalForWindow(window, window->pending.x, window->pending.y, x, y); + *width = window->pending.w; + *height = window->pending.h; + break; + default: + // Should never be here + SDL_assert_release(false); + *width = 0; + *height = 0; + break; + } + + /* Copy the client size in pixels into this rect structure, + which we'll then adjust with AdjustWindowRectEx */ + rect.left = 0; + rect.top = 0; + rect.right = *width; + rect.bottom = *height; + + /* borderless windows will have WM_NCCALCSIZE return 0 for the non-client area. When this happens, it looks like windows will send a resize message + expanding the window client area to the previous window + chrome size, so shouldn't need to adjust the window size for the set styles. + */ + if (!(window->flags & SDL_WINDOW_BORDERLESS) && !SDL_WINDOW_IS_POPUP(window)) { +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + AdjustWindowRectEx(&rect, style, menu, 0); +#else + if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) { + /* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of + AdjustWindowRectEx. */ + if (videodata) { + UINT frame_dpi; + SDL_WindowData *data = window->internal; + frame_dpi = (data && videodata->GetDpiForWindow) ? videodata->GetDpiForWindow(data->hwnd) : USER_DEFAULT_SCREEN_DPI; + if (videodata->AdjustWindowRectExForDpi(&rect, style, menu, styleEx, frame_dpi) == 0) { + return WIN_SetError("AdjustWindowRectExForDpi()"); + } + } + } else { + if (AdjustWindowRectEx(&rect, style, menu, styleEx) == 0) { + return WIN_SetError("AdjustWindowRectEx()"); + } + } +#endif + } + + // Final rect in Windows screen space, including the frame + *x += rect.left; + *y += rect.top; + *width = (rect.right - rect.left); + *height = (rect.bottom - rect.top); + +#ifdef HIGHDPI_DEBUG + SDL_Log("WIN_AdjustWindowRectWithStyle: in: %d, %d, %dx%d, returning: %d, %d, %dx%d, used dpi %d for frame calculation", + (rect_type == SDL_WINDOWRECT_FLOATING ? window->floating.x : rect_type == SDL_WINDOWRECT_WINDOWED ? window->windowed.x : window->x), + (rect_type == SDL_WINDOWRECT_FLOATING ? window->floating.y : rect_type == SDL_WINDOWRECT_WINDOWED ? window->windowed.y : window->y), + (rect_type == SDL_WINDOWRECT_FLOATING ? window->floating.w : rect_type == SDL_WINDOWRECT_WINDOWED ? window->windowed.w : window->w), + (rect_type == SDL_WINDOWRECT_FLOATING ? window->floating.h : rect_type == SDL_WINDOWRECT_WINDOWED ? window->windowed.h : window->h), + *x, *y, *width, *height, frame_dpi); +#endif + return true; +} + +bool WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height, SDL_WindowRect rect_type) +{ + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + DWORD style, styleEx; + BOOL menu; + + style = GetWindowLong(hwnd, GWL_STYLE); + styleEx = GetWindowLong(hwnd, GWL_EXSTYLE); +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + menu = FALSE; +#else + menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); +#endif + return WIN_AdjustWindowRectWithStyle(window, style, styleEx, menu, x, y, width, height, rect_type); +} + +bool WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi) +{ + SDL_VideoDevice *videodevice = SDL_GetVideoDevice(); + SDL_VideoData *videodata = videodevice ? videodevice->internal : NULL; + DWORD style, styleEx; + BOOL menu; + + style = GetWindowLong(hwnd, GWL_STYLE); + styleEx = GetWindowLong(hwnd, GWL_EXSTYLE); +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + menu = FALSE; +#else + menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); +#endif + +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + AdjustWindowRectEx(lpRect, style, menu, styleEx); +#else + if (WIN_IsPerMonitorV2DPIAware(videodevice)) { + // With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. + if (!frame_dpi) { + frame_dpi = videodata->GetDpiForWindow ? videodata->GetDpiForWindow(hwnd) : USER_DEFAULT_SCREEN_DPI; + } + if (!videodata->AdjustWindowRectExForDpi(lpRect, style, menu, styleEx, frame_dpi)) { + return WIN_SetError("AdjustWindowRectExForDpi()"); + } + } else { + if (!AdjustWindowRectEx(lpRect, style, menu, styleEx)) { + return WIN_SetError("AdjustWindowRectEx()"); + } + } +#endif + return true; +} + +bool WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_WindowRect rect_type) +{ + SDL_Window *child_window; + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + HWND top; + int x, y; + int w, h; + bool result = true; + + // Figure out what the window area will be + if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_ALWAYS_ON_TOP)) { + top = HWND_TOPMOST; + } else { + top = HWND_NOTOPMOST; + } + + WIN_AdjustWindowRect(window, &x, &y, &w, &h, rect_type); + + data->expected_resize = true; + if (SetWindowPos(hwnd, top, x, y, w, h, flags) == 0) { + result = WIN_SetError("SetWindowPos()"); + } + data->expected_resize = false; + + // Update any child windows + for (child_window = window->first_child; child_window; child_window = child_window->next_sibling) { + if (!WIN_SetWindowPositionInternal(child_window, flags, SDL_WINDOWRECT_CURRENT)) { + result = false; + } + } + return result; +} + +static SDL_WindowEraseBackgroundMode GetEraseBackgroundModeHint(void) +{ + const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_ERASE_BACKGROUND_MODE); + if (!hint) + return SDL_ERASEBACKGROUNDMODE_INITIAL; + + if (SDL_strstr(hint, "never")) + return SDL_ERASEBACKGROUNDMODE_NEVER; + + if (SDL_strstr(hint, "initial")) + return SDL_ERASEBACKGROUNDMODE_INITIAL; + + if (SDL_strstr(hint, "always")) + return SDL_ERASEBACKGROUNDMODE_ALWAYS; + + int mode = SDL_GetStringInteger(hint, 1); + if (mode < 0 || mode > 2) { + SDL_Log("GetEraseBackgroundModeHint: invalid value for SDL_HINT_WINDOWS_ERASE_BACKGROUND_MODE. Fallback to default"); + return SDL_ERASEBACKGROUNDMODE_INITIAL; + } + + return (SDL_WindowEraseBackgroundMode)mode; +} + +static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd, HWND parent) +{ + SDL_VideoData *videodata = _this->internal; + SDL_WindowData *data; + + // Allocate the window data + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + return false; + } + data->window = window; + data->hwnd = hwnd; + data->parent = parent; +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + data->hdc = (HDC)data->hwnd; +#else + data->hdc = GetDC(hwnd); +#endif + data->hinstance = (HINSTANCE)GetWindowLongPtr(hwnd, GWLP_HINSTANCE); + data->mouse_button_flags = (WPARAM)-1; + data->last_pointer_update = (LPARAM)-1; + data->videodata = videodata; + data->initializing = true; + data->last_displayID = window->last_displayID; + data->dwma_border_color = DWMWA_COLOR_DEFAULT; + data->hint_erase_background_mode = GetEraseBackgroundModeHint(); + + + // WIN_WarpCursor() jitters by +1, and remote desktop warp wobble is +/- 1 +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + LONG remote_desktop_adjustment = GetSystemMetrics(SM_REMOTESESSION) ? 2 : 0; + data->cursor_ctrlock_rect.left = 0 - remote_desktop_adjustment; + data->cursor_ctrlock_rect.top = 0; + data->cursor_ctrlock_rect.right = 1 + remote_desktop_adjustment; + data->cursor_ctrlock_rect.bottom = 1; +#endif + + if (SDL_GetHintBoolean("SDL_WINDOW_RETAIN_CONTENT", false)) { + data->copybits_flag = 0; + } else { + data->copybits_flag = SWP_NOCOPYBITS; + } + +#ifdef HIGHDPI_DEBUG + SDL_Log("SetupWindowData: initialized data->scaling_dpi to %d", data->scaling_dpi); +#endif + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + // Associate the data with the window + if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { + ReleaseDC(hwnd, data->hdc); + SDL_free(data); + return WIN_SetError("SetProp() failed"); + } +#endif + + window->internal = data; + + // Set up the window proc function +#ifdef GWLP_WNDPROC + data->wndproc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_WNDPROC); + if (data->wndproc == WIN_WindowProc) { + data->wndproc = NULL; + } else { + SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)WIN_WindowProc); + } +#else + data->wndproc = (WNDPROC)GetWindowLong(hwnd, GWL_WNDPROC); + if (data->wndproc == WIN_WindowProc) { + data->wndproc = NULL; + } else { + SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR)WIN_WindowProc); + } +#endif + + // Fill in the SDL window with the window state + { + DWORD style = GetWindowLong(hwnd, GWL_STYLE); + if (style & WS_VISIBLE) { + window->flags &= ~SDL_WINDOW_HIDDEN; + } else { + window->flags |= SDL_WINDOW_HIDDEN; + } + if (style & WS_POPUP) { + window->flags |= SDL_WINDOW_BORDERLESS; + } else { + window->flags &= ~SDL_WINDOW_BORDERLESS; + } + if (style & WS_THICKFRAME) { + window->flags |= SDL_WINDOW_RESIZABLE; + } else if (!(style & WS_POPUP)) { + window->flags &= ~SDL_WINDOW_RESIZABLE; + } +#ifdef WS_MAXIMIZE + if (style & WS_MAXIMIZE) { + window->flags |= SDL_WINDOW_MAXIMIZED; + } else +#endif + { + window->flags &= ~SDL_WINDOW_MAXIMIZED; + } +#ifdef WS_MINIMIZE + if (style & WS_MINIMIZE) { + window->flags |= SDL_WINDOW_MINIMIZED; + } else +#endif + { + window->flags &= ~SDL_WINDOW_MINIMIZED; + } + } + if (!(window->flags & SDL_WINDOW_MINIMIZED)) { + RECT rect; + if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) { + int w = rect.right; + int h = rect.bottom; + + if (window->flags & SDL_WINDOW_EXTERNAL) { + window->floating.w = window->windowed.w = window->w = w; + window->floating.h = window->windowed.h = window->h = h; + } else if ((window->windowed.w && window->windowed.w != w) || (window->windowed.h && window->windowed.h != h)) { + // We tried to create a window larger than the desktop and Windows didn't allow it. Override! + int x, y; + // Figure out what the window area will be + WIN_AdjustWindowRect(window, &x, &y, &w, &h, SDL_WINDOWRECT_FLOATING); + data->expected_resize = true; + SetWindowPos(hwnd, NULL, x, y, w, h, data->copybits_flag | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); + data->expected_resize = false; + } else { + window->w = w; + window->h = h; + } + } + } +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (!(window->flags & SDL_WINDOW_MINIMIZED)) { + POINT point; + point.x = 0; + point.y = 0; + if (ClientToScreen(hwnd, &point)) { + if (window->flags & SDL_WINDOW_EXTERNAL) { + window->floating.x = window->windowed.x = point.x; + window->floating.y = window->windowed.y = point.y; + } + window->x = point.x; + window->y = point.y; + } + } + + WIN_UpdateWindowICCProfile(window, false); +#endif + +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + window->flags |= SDL_WINDOW_INPUT_FOCUS; + SDL_SetKeyboardFocus(window); +#else + if (GetFocus() == hwnd) { + window->flags |= SDL_WINDOW_INPUT_FOCUS; + SDL_SetKeyboardFocus(window); + WIN_UpdateClipCursor(window); + } +#endif + + if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + WIN_SetWindowAlwaysOnTop(_this, window, true); + } else { + WIN_SetWindowAlwaysOnTop(_this, window, false); + } + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + // Enable multi-touch + if (videodata->RegisterTouchWindow) { + videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH | TWF_WANTPALM)); + } +#endif + + if (data->parent && !window->parent) { + data->destroy_parent_with_window = true; + } + + data->initializing = false; + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (window->flags & SDL_WINDOW_EXTERNAL) { + // Query the title from the existing window + LPTSTR title; + int titleLen; + bool isstack; + + titleLen = GetWindowTextLength(hwnd); + title = SDL_small_alloc(TCHAR, titleLen + 1, &isstack); + if (title) { + titleLen = GetWindowText(hwnd, title, titleLen + 1); + } else { + titleLen = 0; + } + if (titleLen > 0) { + window->title = WIN_StringToUTF8(title); + } + if (title) { + SDL_small_free(title, isstack); + } + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HWND_POINTER, data->hwnd); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WIN32_HDC_POINTER, data->hdc); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_WIN32_INSTANCE_POINTER, data->hinstance); + + // All done! + return true; +} + +static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + if (data) { + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (data->drop_target) { + WIN_AcceptDragAndDrop(window, false); + } + if (data->ICMFileName) { + SDL_free(data->ICMFileName); + } + if (data->keyboard_hook) { + UnhookWindowsHookEx(data->keyboard_hook); + } + ReleaseDC(data->hwnd, data->hdc); + RemoveProp(data->hwnd, TEXT("SDL_WindowData")); +#endif + if (!(window->flags & SDL_WINDOW_EXTERNAL)) { + DestroyWindow(data->hwnd); + if (data->destroy_parent_with_window && data->parent) { + DestroyWindow(data->parent); + } + } else { + // Restore any original event handler... + if (data->wndproc) { +#ifdef GWLP_WNDPROC + SetWindowLongPtr(data->hwnd, GWLP_WNDPROC, + (LONG_PTR)data->wndproc); +#else + SetWindowLong(data->hwnd, GWL_WNDPROC, + (LONG_PTR)data->wndproc); +#endif + } + } + SDL_free(data); + } + window->internal = NULL; +} + +static void WIN_ConstrainPopup(SDL_Window *window, bool output_to_pending) +{ + // Clamp popup windows to the output borders + if (SDL_WINDOW_IS_POPUP(window)) { + SDL_Window *w; + SDL_DisplayID displayID; + SDL_Rect rect; + int abs_x = window->last_position_pending ? window->pending.x : window->floating.x; + int abs_y = window->last_position_pending ? window->pending.y : window->floating.y; + const int width = window->last_size_pending ? window->pending.w : window->floating.w; + const int height = window->last_size_pending ? window->pending.h : window->floating.h; + int offset_x = 0, offset_y = 0; + + // Calculate the total offset from the parents + for (w = window->parent; SDL_WINDOW_IS_POPUP(w); w = w->parent) { + offset_x += w->x; + offset_y += w->y; + } + + offset_x += w->x; + offset_y += w->y; + abs_x += offset_x; + abs_y += offset_y; + + // Constrain the popup window to the display of the toplevel parent + displayID = SDL_GetDisplayForWindow(w); + SDL_GetDisplayBounds(displayID, &rect); + if (abs_x + width > rect.x + rect.w) { + abs_x -= (abs_x + width) - (rect.x + rect.w); + } + if (abs_y + height > rect.y + rect.h) { + abs_y -= (abs_y + height) - (rect.y + rect.h); + } + abs_x = SDL_max(abs_x, rect.x); + abs_y = SDL_max(abs_y, rect.y); + + if (output_to_pending) { + window->pending.x = abs_x - offset_x; + window->pending.y = abs_y - offset_y; + window->pending.w = width; + window->pending.h = height; + } else { + window->floating.x = abs_x - offset_x; + window->floating.y = abs_y - offset_y; + window->floating.w = width; + window->floating.h = height; + } + } +} + +static void WIN_SetKeyboardFocus(SDL_Window *window, bool set_active_focus) +{ + SDL_Window *toplevel = window; + + // Find the topmost parent + while (SDL_WINDOW_IS_POPUP(toplevel)) { + toplevel = toplevel->parent; + } + + toplevel->internal->keyboard_focus = window; + + if (set_active_focus && !window->is_hiding && !window->is_destroying) { + SDL_SetKeyboardFocus(window); + } +} + +bool WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + HWND hwnd = (HWND)SDL_GetPointerProperty(create_props, SDL_PROP_WINDOW_CREATE_WIN32_HWND_POINTER, SDL_GetPointerProperty(create_props, "sdl2-compat.external_window", NULL)); + HWND parent = NULL; + if (hwnd) { + window->flags |= SDL_WINDOW_EXTERNAL; + + if (!SetupWindowData(_this, window, hwnd, parent)) { + return false; + } + } else { + DWORD style = STYLE_BASIC; + DWORD styleEx = 0; + int x, y; + int w, h; + + if (window->flags & SDL_WINDOW_UTILITY) { + parent = CreateWindow(SDL_Appname, TEXT(""), STYLE_BASIC, 0, 0, 32, 32, NULL, NULL, SDL_Instance, NULL); + } else if (window->parent) { + parent = window->parent->internal->hwnd; + } + + style |= GetWindowStyle(window); + styleEx |= GetWindowStyleEx(window); + + // Figure out what the window area will be + WIN_ConstrainPopup(window, false); + WIN_AdjustWindowRectWithStyle(window, style, styleEx, FALSE, &x, &y, &w, &h, SDL_WINDOWRECT_FLOATING); + + hwnd = CreateWindowEx(styleEx, SDL_Appname, TEXT(""), style, + x, y, w, h, parent, NULL, SDL_Instance, NULL); + if (!hwnd) { + return WIN_SetError("Couldn't create window"); + } + + WIN_UpdateDarkModeForHWND(hwnd); + + WIN_PumpEvents(_this); + + if (!SetupWindowData(_this, window, hwnd, parent)) { + DestroyWindow(hwnd); + if (parent) { + DestroyWindow(parent); + } + return false; + } + + // Inform Windows of the frame change so we can respond to WM_NCCALCSIZE + SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE); + + if (window->flags & SDL_WINDOW_MINIMIZED) { + /* TODO: We have to clear SDL_WINDOW_HIDDEN here to ensure the window flags match the window state. The + window is already shown after this and windows with WS_MINIMIZE do not generate a WM_SHOWWINDOW. This + means you can't currently create a window that is initially hidden and is minimized when shown. + */ + window->flags &= ~SDL_WINDOW_HIDDEN; + ShowWindow(hwnd, SW_SHOWMINNOACTIVE); + } + } + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + // FIXME: does not work on all hardware configurations with different renders (i.e. hybrid GPUs) + if (window->flags & SDL_WINDOW_TRANSPARENT) { + SDL_SharedObject *handle = SDL_LoadObject("dwmapi.dll"); + if (handle) { + DwmEnableBlurBehindWindow_t DwmEnableBlurBehindWindowFunc = (DwmEnableBlurBehindWindow_t)SDL_LoadFunction(handle, "DwmEnableBlurBehindWindow"); + if (DwmEnableBlurBehindWindowFunc) { + /* The region indicates which part of the window will be blurred and rest will be transparent. This + is because the alpha value of the window will be used for non-blurred areas + We can use (-1, -1, 0, 0) boundary to make sure no pixels are being blurred + */ + HRGN rgn = CreateRectRgn(-1, -1, 0, 0); + DWM_BLURBEHIND bb; + bb.flags = (DWM_BB_ENABLE | DWM_BB_BLURREGION); + bb.enable = TRUE; + bb.blur_region = rgn; + bb.transition_on_maxed = FALSE; + DwmEnableBlurBehindWindowFunc(hwnd, &bb); + DeleteObject(rgn); + } + SDL_UnloadObject(handle); + } + } + + HWND share_hwnd = (HWND)SDL_GetPointerProperty(create_props, SDL_PROP_WINDOW_CREATE_WIN32_PIXEL_FORMAT_HWND_POINTER, NULL); + if (share_hwnd) { + HDC hdc = GetDC(share_hwnd); + int pixel_format = GetPixelFormat(hdc); + PIXELFORMATDESCRIPTOR pfd; + + SDL_zero(pfd); + DescribePixelFormat(hdc, pixel_format, sizeof(pfd), &pfd); + ReleaseDC(share_hwnd, hdc); + + if (!SetPixelFormat(window->internal->hdc, pixel_format, &pfd)) { + WIN_DestroyWindow(_this, window); + return WIN_SetError("SetPixelFormat()"); + } + } else { +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + if (!(window->flags & SDL_WINDOW_OPENGL)) { + return true; + } + + // The rest of this macro mess is for OpenGL or OpenGL ES windows +#ifdef SDL_VIDEO_OPENGL_ES2 + if ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES || + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) +#ifdef SDL_VIDEO_OPENGL_WGL + && (!_this->gl_data || WIN_GL_UseEGL(_this)) +#endif // SDL_VIDEO_OPENGL_WGL + ) { +#ifdef SDL_VIDEO_OPENGL_EGL + if (!WIN_GLES_SetupWindow(_this, window)) { + WIN_DestroyWindow(_this, window); + return false; + } + return true; +#else + return SDL_SetError("Could not create GLES window surface (EGL support not configured)"); +#endif // SDL_VIDEO_OPENGL_EGL + } +#endif // SDL_VIDEO_OPENGL_ES2 + +#ifdef SDL_VIDEO_OPENGL_WGL + if (!WIN_GL_SetupWindow(_this, window)) { + WIN_DestroyWindow(_this, window); + return false; + } +#else + return SDL_SetError("Could not create GL window (WGL support not configured)"); +#endif +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + return true; +} + +void WIN_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + HWND hwnd = window->internal->hwnd; + LPTSTR title = WIN_UTF8ToString(window->title); + SetWindowText(hwnd, title); + SDL_free(title); +#endif +} + +bool WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + HWND hwnd = window->internal->hwnd; + HICON hicon = NULL; + BYTE *icon_bmp; + int icon_len, mask_len, row_len, y; + BITMAPINFOHEADER *bmi; + Uint8 *dst; + bool isstack; + bool result = true; + + // Create temporary buffer for ICONIMAGE structure + SDL_COMPILE_TIME_ASSERT(WIN_SetWindowIcon_uses_BITMAPINFOHEADER_to_prepare_an_ICONIMAGE, sizeof(BITMAPINFOHEADER) == 40); + mask_len = (icon->h * (icon->w + 7) / 8); + icon_len = sizeof(BITMAPINFOHEADER) + icon->h * icon->w * sizeof(Uint32) + mask_len; + icon_bmp = SDL_small_alloc(BYTE, icon_len, &isstack); + if (!icon_bmp) { + return false; + } + + // Write the BITMAPINFO header + bmi = (BITMAPINFOHEADER *)icon_bmp; + bmi->biSize = SDL_Swap32LE(sizeof(BITMAPINFOHEADER)); + bmi->biWidth = SDL_Swap32LE(icon->w); + bmi->biHeight = SDL_Swap32LE(icon->h * 2); + bmi->biPlanes = SDL_Swap16LE(1); + bmi->biBitCount = SDL_Swap16LE(32); + bmi->biCompression = SDL_Swap32LE(BI_RGB); + bmi->biSizeImage = SDL_Swap32LE(icon->h * icon->w * sizeof(Uint32)); + bmi->biXPelsPerMeter = SDL_Swap32LE(0); + bmi->biYPelsPerMeter = SDL_Swap32LE(0); + bmi->biClrUsed = SDL_Swap32LE(0); + bmi->biClrImportant = SDL_Swap32LE(0); + + // Write the pixels upside down into the bitmap buffer + SDL_assert(icon->format == SDL_PIXELFORMAT_ARGB8888); + dst = &icon_bmp[sizeof(BITMAPINFOHEADER)]; + row_len = icon->w * sizeof(Uint32); + y = icon->h; + while (y--) { + Uint8 *src = (Uint8 *)icon->pixels + y * icon->pitch; + SDL_memcpy(dst, src, row_len); + dst += row_len; + } + + // Write the mask + SDL_memset(icon_bmp + icon_len - mask_len, 0xFF, mask_len); + + hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000); + + SDL_small_free(icon_bmp, isstack); + + if (!hicon) { + result = SDL_SetError("SetWindowIcon() failed, error %08X", (unsigned int)GetLastError()); + } + + // Set the icon for the window + SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hicon); + + // Set the icon in the task manager (should we do this?) + SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hicon); + return result; +#else + return SDL_Unsupported(); +#endif +} + +bool WIN_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + /* HighDPI support: removed SWP_NOSIZE. If the move results in a DPI change, we need to allow + * the window to resize (e.g. AdjustWindowRectExForDpi frame sizes are different). + */ + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + if (!(window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { + WIN_ConstrainPopup(window, true); + return WIN_SetWindowPositionInternal(window, + window->internal->copybits_flag | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOSIZE | + SWP_NOACTIVATE, SDL_WINDOWRECT_PENDING); + } + } else { + return SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_ENTER, true); + } + + return true; +} + +void WIN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (!(window->flags & (SDL_WINDOW_FULLSCREEN | SDL_WINDOW_MAXIMIZED))) { + WIN_SetWindowPositionInternal(window, window->internal->copybits_flag | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE, SDL_WINDOWRECT_PENDING); + } else { + // Can't resize the window + window->last_size_pending = false; + } +} + +bool WIN_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *top, int *left, int *bottom, int *right) +{ +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + HWND hwnd = window->internal->hwnd; + RECT rcClient; + + /* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left + * screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */ + GetClientRect(hwnd, &rcClient); + + *top = rcClient.top; + *left = rcClient.left; + *bottom = rcClient.bottom; + *right = rcClient.right; + + return true; +#else // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + HWND hwnd = window->internal->hwnd; + RECT rcClient, rcWindow; + POINT ptDiff; + + /* rcClient stores the size of the inner window, while rcWindow stores the outer size relative to the top-left + * screen position; so the top/left values of rcClient are always {0,0} and bottom/right are {height,width} */ + if (!GetClientRect(hwnd, &rcClient)) { + return SDL_SetError("GetClientRect() failed, error %08X", (unsigned int)GetLastError()); + } + + if (!GetWindowRect(hwnd, &rcWindow)) { + return SDL_SetError("GetWindowRect() failed, error %08X", (unsigned int)GetLastError()); + } + + /* convert the top/left values to make them relative to + * the window; they will end up being slightly negative */ + ptDiff.y = rcWindow.top; + ptDiff.x = rcWindow.left; + + if (!ScreenToClient(hwnd, &ptDiff)) { + return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError()); + } + + rcWindow.top = ptDiff.y; + rcWindow.left = ptDiff.x; + + /* convert the bottom/right values to make them relative to the window, + * these will be slightly bigger than the inner width/height */ + ptDiff.y = rcWindow.bottom; + ptDiff.x = rcWindow.right; + + if (!ScreenToClient(hwnd, &ptDiff)) { + return SDL_SetError("ScreenToClient() failed, error %08X", (unsigned int)GetLastError()); + } + + rcWindow.bottom = ptDiff.y; + rcWindow.right = ptDiff.x; + + /* Now that both the inner and outer rects use the same coordinate system we can subtract them to get the border size. + * Keep in mind that the top/left coordinates of rcWindow are negative because the border lies slightly before {0,0}, + * so switch them around because SDL3 wants them in positive. */ + *top = rcClient.top - rcWindow.top; + *left = rcClient.left - rcWindow.left; + *bottom = rcWindow.bottom - rcClient.bottom; + *right = rcWindow.right - rcClient.right; + + return true; +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +} + +void WIN_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *w, int *h) +{ + const SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + RECT rect; + + if (GetClientRect(hwnd, &rect) && !WIN_IsRectEmpty(&rect)) { + *w = rect.right; + *h = rect.bottom; + } else if (window->last_pixel_w && window->last_pixel_h) { + *w = window->last_pixel_w; + *h = window->last_pixel_h; + } else { + // Probably created minimized, use the restored size + *w = window->floating.w; + *h = window->floating.h; + } +} + +void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + DWORD style; + HWND hwnd; + + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, true); + + if (SDL_WINDOW_IS_POPUP(window)) { + // Update our position in case our parent moved while we were hidden + WIN_SetWindowPosition(_this, window); + } + + hwnd = window->internal->hwnd; + style = GetWindowLong(hwnd, GWL_EXSTYLE); + if (style & WS_EX_NOACTIVATE) { + bActivate = false; + } + if (bActivate) { + ShowWindow(hwnd, SW_SHOW); + } else { + // Use SetWindowPos instead of ShowWindow to avoid activating the parent window if this is a child window + SetWindowPos(hwnd, NULL, 0, 0, 0, 0, window->internal->copybits_flag | SWP_SHOWWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER); + } + + if (window->flags & SDL_WINDOW_POPUP_MENU && bActivate) { + WIN_SetKeyboardFocus(window, window->parent == SDL_GetKeyboardFocus()); + } + if (window->flags & SDL_WINDOW_MODAL) { + WIN_SetWindowModal(_this, window, true); + } +} + +void WIN_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + HWND hwnd = window->internal->hwnd; + + if (window->flags & SDL_WINDOW_MODAL) { + WIN_SetWindowModal(_this, window, false); + } + + ShowWindow(hwnd, SW_HIDE); + + // Transfer keyboard focus back to the parent + if (window->flags & SDL_WINDOW_POPUP_MENU) { + SDL_Window *new_focus = window->parent; + bool set_focus = window == SDL_GetKeyboardFocus(); + + // Find the highest level window, up to the toplevel parent, that isn't being hidden or destroyed. + while (SDL_WINDOW_IS_POPUP(new_focus) && (new_focus->is_hiding || new_focus->is_destroying)) { + new_focus = new_focus->parent; + + // If some window in the chain currently had keyboard focus, set it to the new lowest-level window. + if (!set_focus) { + set_focus = new_focus == SDL_GetKeyboardFocus(); + } + } + + WIN_SetKeyboardFocus(new_focus, set_focus); + } +} + +void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + /* If desired, raise the window more forcefully. + * Technique taken from http://stackoverflow.com/questions/916259/ . + * Specifically, http://stackoverflow.com/a/34414846 . + * + * The issue is that Microsoft has gone through a lot of trouble to make it + * nearly impossible to programmatically move a window to the foreground, + * for "security" reasons. Apparently, the following song-and-dance gets + * around their objections. */ + bool bForce = SDL_GetHintBoolean(SDL_HINT_FORCE_RAISEWINDOW, false); + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, true); + + HWND hCurWnd = NULL; + DWORD dwMyID = 0u; + DWORD dwCurID = 0u; + + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + if (bForce) { + hCurWnd = GetForegroundWindow(); + dwMyID = GetCurrentThreadId(); + dwCurID = GetWindowThreadProcessId(hCurWnd, NULL); + ShowWindow(hwnd, SW_RESTORE); + AttachThreadInput(dwCurID, dwMyID, TRUE); + SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + if (!SDL_ShouldAllowTopmost() || !(window->flags & SDL_WINDOW_ALWAYS_ON_TOP)) { + SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); + } + } + if (bActivate) { + SetForegroundWindow(hwnd); + if (window->flags & SDL_WINDOW_POPUP_MENU) { + WIN_SetKeyboardFocus(window, window->parent == SDL_GetKeyboardFocus()); + } + } else { + SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, data->copybits_flag | SWP_NOMOVE | SWP_NOSIZE | SWP_NOOWNERZORDER | SWP_NOACTIVATE); + } + if (bForce) { + AttachThreadInput(dwCurID, dwMyID, FALSE); + SetFocus(hwnd); + SetActiveWindow(hwnd); + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +} + +void WIN_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + HWND hwnd = data->hwnd; + data->expected_resize = true; + ShowWindow(hwnd, SW_MAXIMIZE); + data->expected_resize = false; + + /* Clamp the maximized window size to the max window size. + * This is automatic if maximizing from the window controls. + */ + if (window->max_w || window->max_h) { + int fx, fy, fw, fh; + + window->windowed.w = window->max_w ? SDL_min(window->w, window->max_w) : window->windowed.w; + window->windowed.h = window->max_h ? SDL_min(window->h, window->max_h) : window->windowed.h; + WIN_AdjustWindowRect(window, &fx, &fy, &fw, &fh, SDL_WINDOWRECT_WINDOWED); + + data->expected_resize = true; + SetWindowPos(hwnd, HWND_TOP, fx, fy, fw, fh, data->copybits_flag | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOACTIVATE); + data->expected_resize = false; + } + } else { + data->windowed_mode_was_maximized = true; + } +} + +void WIN_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + HWND hwnd = window->internal->hwnd; + ShowWindow(hwnd, SW_MINIMIZE); +} + +void WIN_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) +{ + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + DWORD style; + + style = GetWindowLong(hwnd, GWL_STYLE); + style &= ~STYLE_MASK; + style |= GetWindowStyle(window); + + data->in_border_change = true; + SetWindowLong(hwnd, GWL_STYLE, style); + WIN_SetWindowPositionInternal(window, data->copybits_flag | SWP_FRAMECHANGED | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOACTIVATE, SDL_WINDOWRECT_CURRENT); + data->in_border_change = false; +} + +void WIN_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) +{ + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + DWORD style; + + style = GetWindowLong(hwnd, GWL_STYLE); + style &= ~STYLE_MASK; + style |= GetWindowStyle(window); + + SetWindowLong(hwnd, GWL_STYLE, style); +} + +void WIN_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top) +{ + WIN_SetWindowPositionInternal(window, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE, SDL_WINDOWRECT_CURRENT); +} + +void WIN_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + HWND hwnd = data->hwnd; + data->expected_resize = true; + ShowWindow(hwnd, SW_RESTORE); + data->expected_resize = false; + } else { + data->windowed_mode_was_maximized = false; + } +} + +static DWM_WINDOW_CORNER_PREFERENCE WIN_UpdateCornerRoundingForHWND(HWND hwnd, DWM_WINDOW_CORNER_PREFERENCE cornerPref) +{ + DWM_WINDOW_CORNER_PREFERENCE oldPref = DWMWCP_DEFAULT; + + SDL_SharedObject *handle = SDL_LoadObject("dwmapi.dll"); + if (handle) { + DwmGetWindowAttribute_t DwmGetWindowAttributeFunc = (DwmGetWindowAttribute_t)SDL_LoadFunction(handle, "DwmGetWindowAttribute"); + DwmSetWindowAttribute_t DwmSetWindowAttributeFunc = (DwmSetWindowAttribute_t)SDL_LoadFunction(handle, "DwmSetWindowAttribute"); + if (DwmGetWindowAttributeFunc && DwmSetWindowAttributeFunc) { + DwmGetWindowAttributeFunc(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &oldPref, sizeof(oldPref)); + DwmSetWindowAttributeFunc(hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, &cornerPref, sizeof(cornerPref)); + } + + SDL_UnloadObject(handle); + } + + return oldPref; +} + +static COLORREF WIN_UpdateBorderColorForHWND(HWND hwnd, COLORREF colorRef) +{ + COLORREF oldPref = DWMWA_COLOR_DEFAULT; + + SDL_SharedObject *handle = SDL_LoadObject("dwmapi.dll"); + if (handle) { + DwmGetWindowAttribute_t DwmGetWindowAttributeFunc = (DwmGetWindowAttribute_t)SDL_LoadFunction(handle, "DwmGetWindowAttribute"); + DwmSetWindowAttribute_t DwmSetWindowAttributeFunc = (DwmSetWindowAttribute_t)SDL_LoadFunction(handle, "DwmSetWindowAttribute"); + if (DwmGetWindowAttributeFunc && DwmSetWindowAttributeFunc) { + DwmGetWindowAttributeFunc(hwnd, DWMWA_BORDER_COLOR, &oldPref, sizeof(oldPref)); + DwmSetWindowAttributeFunc(hwnd, DWMWA_BORDER_COLOR, &colorRef, sizeof(colorRef)); + } + + SDL_UnloadObject(handle); + } + + return oldPref; +} + +/** + * Reconfigures the window to fill the given display, if fullscreen is true, otherwise restores the window. + */ +SDL_FullscreenResult WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + SDL_DisplayData *displaydata = display->internal; + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + MONITORINFO minfo; + DWORD style, styleEx; + HWND top; + int x, y; + int w, h; + bool enterMaximized = false; + +#ifdef HIGHDPI_DEBUG + SDL_Log("WIN_SetWindowFullscreen: %d", (int)fullscreen); +#endif + + /* Early out if already not in fullscreen, or the styling on + * external windows may end up being overridden. + */ + if (!(window->flags & SDL_WINDOW_FULLSCREEN) && !fullscreen) { + return SDL_FULLSCREEN_SUCCEEDED; + } + + if (SDL_ShouldAllowTopmost() && (window->flags & SDL_WINDOW_ALWAYS_ON_TOP)) { + top = HWND_TOPMOST; + } else { + top = HWND_NOTOPMOST; + } + + /* Use GetMonitorInfo instead of WIN_GetDisplayBounds because we want the + monitor bounds in Windows coordinates (pixels) rather than SDL coordinates (points). */ + SDL_zero(minfo); + minfo.cbSize = sizeof(MONITORINFO); + if (!GetMonitorInfo(displaydata->MonitorHandle, &minfo)) { + SDL_SetError("GetMonitorInfo failed"); + return SDL_FULLSCREEN_FAILED; + } + + SDL_SendWindowEvent(window, fullscreen ? SDL_EVENT_WINDOW_ENTER_FULLSCREEN : SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + style = GetWindowLong(hwnd, GWL_STYLE); + style &= ~STYLE_MASK; + style |= GetWindowStyle(window); + styleEx = GetWindowLong(hwnd, GWL_EXSTYLE); + + if (fullscreen) { + x = minfo.rcMonitor.left; + y = minfo.rcMonitor.top; + w = minfo.rcMonitor.right - minfo.rcMonitor.left; + h = minfo.rcMonitor.bottom - minfo.rcMonitor.top; + + /* Unset the maximized flag. This fixes + https://bugzilla.libsdl.org/show_bug.cgi?id=3215 + */ + if (style & WS_MAXIMIZE) { + data->windowed_mode_was_maximized = true; + style &= ~WS_MAXIMIZE; + } + + // Disable corner rounding & border color (Windows 11+) so the window fills the full screen + data->windowed_mode_corner_rounding = WIN_UpdateCornerRoundingForHWND(hwnd, DWMWCP_DONOTROUND); + data->dwma_border_color = WIN_UpdateBorderColorForHWND(hwnd, DWMWA_COLOR_NONE); + } else { + BOOL menu; + + WIN_UpdateCornerRoundingForHWND(hwnd, (DWM_WINDOW_CORNER_PREFERENCE)data->windowed_mode_corner_rounding); + WIN_UpdateBorderColorForHWND(hwnd, data->dwma_border_color); + + /* Restore window-maximization state, as applicable. + Special care is taken to *not* do this if and when we're + alt-tab'ing away (to some other window; as indicated by + in_window_deactivation), otherwise + https://bugzilla.libsdl.org/show_bug.cgi?id=3215 can reproduce! + */ + if (data->windowed_mode_was_maximized && !data->in_window_deactivation) { + enterMaximized = true; + data->disable_move_size_events = true; + } + + menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); + WIN_AdjustWindowRectWithStyle(window, style, styleEx, menu, + &x, &y, + &w, &h, + SDL_WINDOWRECT_FLOATING); + data->windowed_mode_was_maximized = false; + + /* A window may have been maximized by dragging it to the top of another display, in which case the floating + * position may be out-of-date. If the window is being restored to maximized, and the maximized and floating + * position are on different displays, try to center the window on the maximized display for restoration, which + * mimics native Windows behavior. + */ + if (enterMaximized) { + const SDL_Point windowed_point = { window->windowed.x, window->windowed.y }; + const SDL_Point floating_point = { window->floating.x, window->floating.y }; + const SDL_DisplayID floating_display = SDL_GetDisplayForPoint(&floating_point); + const SDL_DisplayID windowed_display = SDL_GetDisplayForPoint(&windowed_point); + + if (floating_display != windowed_display) { + SDL_Rect bounds; + + SDL_zero(bounds); + SDL_GetDisplayUsableBounds(windowed_display, &bounds); + if (w < bounds.w) { + x = bounds.x + (bounds.w - w) / 2; + } else { + x = bounds.x; + } + if (h < bounds.h) { + y = bounds.y + (bounds.h - h) / 2; + } else { + y = bounds.y; + } + } + } + } + + /* Always reset the window to the base floating size before possibly re-applying the maximized state, + * otherwise, the base floating size can seemingly be lost in some cases. + */ + SetWindowLong(hwnd, GWL_STYLE, style); + data->expected_resize = true; + SetWindowPos(hwnd, top, x, y, w, h, data->copybits_flag | SWP_NOACTIVATE); + data->expected_resize = false; + data->disable_move_size_events = false; + + if (enterMaximized) { + WIN_MaximizeWindow(_this, window); + } + +#ifdef HIGHDPI_DEBUG + SDL_Log("WIN_SetWindowFullscreen: %d finished. Set window to %d,%d, %dx%d", (int)fullscreen, x, y, w, h); +#endif + +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + return SDL_FULLSCREEN_SUCCEEDED; +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +void WIN_UpdateWindowICCProfile(SDL_Window *window, bool send_event) +{ + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + + if (displaydata) { + HDC hdc = CreateDCW(displaydata->DeviceName, NULL, NULL, NULL); + if (hdc) { + WCHAR fileName[MAX_PATH]; + DWORD fileNameSize = SDL_arraysize(fileName); + if (GetICMProfileW(hdc, &fileNameSize, fileName)) { + // fileNameSize includes '\0' on return + if (!data->ICMFileName || + SDL_wcscmp(data->ICMFileName, fileName) != 0) { + if (data->ICMFileName) { + SDL_free(data->ICMFileName); + } + data->ICMFileName = SDL_wcsdup(fileName); + if (send_event) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_ICCPROF_CHANGED, 0, 0); + } + } + } + DeleteDC(hdc); + } + } +} + +void *WIN_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size) +{ + SDL_WindowData *data = window->internal; + char *filename_utf8; + void *iccProfileData = NULL; + + filename_utf8 = WIN_StringToUTF8(data->ICMFileName); + if (filename_utf8) { + iccProfileData = SDL_LoadFile(filename_utf8, size); + if (!iccProfileData) { + SDL_SetError("Could not open ICC profile"); + } + SDL_free(filename_utf8); + } + return iccProfileData; +} + +static void WIN_GrabKeyboard(SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + HMODULE module; + + if (data->keyboard_hook) { + return; + } + + /* SetWindowsHookEx() needs to know which module contains the hook we + want to install. This is complicated by the fact that SDL can be + linked statically or dynamically. Fortunately XP and later provide + this nice API that will go through the loaded modules and find the + one containing our code. + */ + if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, + (LPTSTR)WIN_KeyboardHookProc, + &module)) { + return; + } + + // Capture a snapshot of the current keyboard state before the hook + if (!GetKeyboardState(data->videodata->pre_hook_key_state)) { + return; + } + + /* To grab the keyboard, we have to install a low-level keyboard hook to + intercept keys that would normally be captured by the OS. Intercepting + all key events on the system is rather invasive, but it's what Microsoft + actually documents that you do to capture these. + */ + data->keyboard_hook = SetWindowsHookEx(WH_KEYBOARD_LL, WIN_KeyboardHookProc, module, 0); +} + +void WIN_UngrabKeyboard(SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + if (data->keyboard_hook) { + UnhookWindowsHookEx(data->keyboard_hook); + data->keyboard_hook = NULL; + } +} + +bool WIN_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) +{ + WIN_UpdateClipCursor(window); + return true; +} + +bool WIN_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + WIN_UpdateClipCursor(window); + return true; +} + +bool WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + if (grabbed) { + WIN_GrabKeyboard(window); + } else { + WIN_UngrabKeyboard(window); + } + + return true; +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + CleanupWindowData(_this, window); +} + +/* + * Creates a HelperWindow used for DirectInput. + */ +bool SDL_HelperWindowCreate(void) +{ + HINSTANCE hInstance = GetModuleHandle(NULL); + WNDCLASS wce; + + // Make sure window isn't created twice. + if (SDL_HelperWindow != NULL) { + return true; + } + + // Create the class. + SDL_zero(wce); + wce.lpfnWndProc = DefWindowProc; + wce.lpszClassName = SDL_HelperWindowClassName; + wce.hInstance = hInstance; + + // Register the class. + SDL_HelperWindowClass = RegisterClass(&wce); + if (SDL_HelperWindowClass == 0 && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) { + return WIN_SetError("Unable to create Helper Window Class"); + } + + // Create the window. + SDL_HelperWindow = CreateWindowEx(0, SDL_HelperWindowClassName, + SDL_HelperWindowName, + WS_OVERLAPPED, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, HWND_MESSAGE, NULL, + hInstance, NULL); + if (!SDL_HelperWindow) { + UnregisterClass(SDL_HelperWindowClassName, hInstance); + return WIN_SetError("Unable to create Helper Window"); + } + + return true; +} + +/* + * Destroys the HelperWindow previously created with SDL_HelperWindowCreate. + */ +void SDL_HelperWindowDestroy(void) +{ + HINSTANCE hInstance = GetModuleHandle(NULL); + + // Destroy the window. + if (SDL_HelperWindow != NULL) { + if (DestroyWindow(SDL_HelperWindow) == 0) { + WIN_SetError("Unable to destroy Helper Window"); + return; + } + SDL_HelperWindow = NULL; + } + + // Unregister the class. + if (SDL_HelperWindowClass != 0) { + if ((UnregisterClass(SDL_HelperWindowClassName, hInstance)) == 0) { + WIN_SetError("Unable to destroy Helper Window Class"); + return; + } + SDL_HelperWindowClass = 0; + } +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + if (!data || !data->hwnd) { + // The window wasn't fully initialized + return; + } + + if (window->flags & SDL_WINDOW_ALWAYS_ON_TOP) { + WIN_SetWindowPositionInternal(window, data->copybits_flag | SWP_NOSIZE | SWP_NOACTIVATE, SDL_WINDOWRECT_CURRENT); + } +} + +static BOOL GetClientScreenRect(HWND hwnd, RECT *rect) +{ + return GetClientRect(hwnd, rect) && // RECT( left , top , right , bottom ) + ClientToScreen(hwnd, (LPPOINT)rect) && // POINT( left , top ) + ClientToScreen(hwnd, (LPPOINT)rect + 1); // POINT( right , bottom ) +} + +void WIN_UnclipCursorForWindow(SDL_Window *window) { + SDL_WindowData *data = window->internal; + RECT rect; + if (GetClipCursor(&rect) && SDL_memcmp(&rect, &data->cursor_clipped_rect, sizeof(rect)) == 0) { + ClipCursor(NULL); + SDL_zero(data->cursor_clipped_rect); + } +} + +void WIN_UpdateClipCursor(SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + if (data->in_title_click || data->focus_click_pending || data->skip_update_clipcursor) { + return; + } + + SDL_Rect mouse_rect = window->mouse_rect; + bool win_mouse_rect = (mouse_rect.w > 0 && mouse_rect.h > 0); + bool win_have_focus = (window->flags & SDL_WINDOW_INPUT_FOCUS); + bool win_is_grabbed = (window->flags & SDL_WINDOW_MOUSE_GRABBED); + bool win_in_relmode = (window->flags & SDL_WINDOW_MOUSE_RELATIVE_MODE); + bool cursor_confine = win_in_relmode || win_is_grabbed || win_mouse_rect; + + // This is verbatim translation of the old logic, + // but I don't quite get what it's trying to do. + // A clean-room implementation according to MSDN + // documentation of GetClipCursor is provided in + // a commented-out block below. + if (!win_have_focus || !cursor_confine) { + SDL_VideoDevice *videodevice = SDL_GetVideoDevice(); + RECT current; + if (!GetClipCursor(¤t)) { + return; + } + if (videodevice && ( + current.left != videodevice->desktop_bounds.x || + current.top != videodevice->desktop_bounds.y + )) { + POINT first, second; + first.x = current.left; + first.y = current.top; + second.x = current.right - 1; + second.y = current.bottom - 1; + if (!PtInRect(&data->cursor_clipped_rect, first) || + !PtInRect(&data->cursor_clipped_rect, second)) { + return; + } + } + ClipCursor(NULL); + SDL_zero(data->cursor_clipped_rect); + return; + } + + // if (!win_have_focus || !cursor_confine) { + // RECT current; + // SDL_VideoDevice *videodevice = SDL_GetVideoDevice(); + // if (GetClipCursor(¤t) && (!videodevice || + // current.left != videodevice->desktop_bounds.x || + // current.top != videodevice->desktop_bounds.y || + // current.right != videodevice->desktop_bounds.x + videodevice->desktop_bounds.w || + // current.bottom != videodevice->desktop_bounds.y + videodevice->desktop_bounds.h )) { + // ClipCursor(NULL); + // SDL_zero(data->cursor_clipped_rect); + // } + // return; + // } + + SDL_Mouse *mouse = SDL_GetMouse(); + bool lock_to_ctr = (mouse->relative_mode && mouse->relative_mode_center); + + RECT client; + if (!GetClientScreenRect(data->hwnd, &client)) { + return; + } + + RECT target = client; + if (lock_to_ctr) { + LONG cx = (client.left + client.right ) / 2; + LONG cy = (client.top + client.bottom) / 2; + target = data->cursor_ctrlock_rect; + target.left += cx; + target.right += cx; + target.top += cy; + target.bottom += cy; + } else if (win_mouse_rect) { + RECT custom, overlap; + custom.left = client.left + mouse_rect.x; + custom.top = client.top + mouse_rect.y; + custom.right = client.left + mouse_rect.x + mouse_rect.w; + custom.bottom = client.top + mouse_rect.y + mouse_rect.h; + if (IntersectRect(&overlap, &client, &custom)) { + target = overlap; + } else if (!win_is_grabbed) { + WIN_UnclipCursorForWindow(window); + return; + } + } + + if (GetClipCursor(&client) && + 0 != SDL_memcmp(&target, &client, sizeof(client)) && + ClipCursor(&target)) { + data->cursor_clipped_rect = target; // ClipCursor may fail if rect beyond screen + } +} + +bool WIN_SetWindowHitTest(SDL_Window *window, bool enabled) +{ + return true; // just succeed, the real work is done elsewhere. +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +bool WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity) +{ +#if defined(SDL_PLATFORM_XBOXONE) || defined(SDL_PLATFORM_XBOXSERIES) + return false; +#else + const SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + const LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); + + SDL_assert(style != 0); + + if (opacity == 1.0f) { + // want it fully opaque, just mark it unlayered if necessary. + if (style & WS_EX_LAYERED) { + if (SetWindowLong(hwnd, GWL_EXSTYLE, style & ~WS_EX_LAYERED) == 0) { + return WIN_SetError("SetWindowLong()"); + } + } + } else { + const BYTE alpha = (BYTE)((int)(opacity * 255.0f)); + // want it transparent, mark it layered if necessary. + if (!(style & WS_EX_LAYERED)) { + if (SetWindowLong(hwnd, GWL_EXSTYLE, style | WS_EX_LAYERED) == 0) { + return WIN_SetError("SetWindowLong()"); + } + } + + if (SetLayeredWindowAttributes(hwnd, 0, alpha, LWA_ALPHA) == 0) { + return WIN_SetError("SetLayeredWindowAttributes()"); + } + } + + return true; +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) +} + +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +static const char *SDLGetClipboardFormatName(UINT cf, char *text, int len) +{ + switch (cf) { + case CF_TEXT: + return "CF_TEXT"; + case CF_BITMAP: + return "CF_BITMAP"; + case CF_METAFILEPICT: + return "CF_METAFILEPICT"; + case CF_SYLK: + return "CF_SYLK"; + case CF_DIF: + return "CF_DIF"; + case CF_TIFF: + return "CF_TIFF"; + case CF_OEMTEXT: + return "CF_OEMTEXT"; + case CF_DIB: + return "CF_DIB"; + case CF_PALETTE: + return "CF_PALETTE"; + case CF_PENDATA: + return "CF_PENDATA"; + case CF_RIFF: + return "CF_RIFF"; + case CF_WAVE: + return "CF_WAVE"; + case CF_UNICODETEXT: + return "CF_UNICODETEXT"; + case CF_ENHMETAFILE: + return "CF_ENHMETAFILE"; + case CF_HDROP: + return "CF_HDROP"; + case CF_LOCALE: + return "CF_LOCALE"; + case CF_DIBV5: + return "CF_DIBV5"; + case CF_OWNERDISPLAY: + return "CF_OWNERDISPLAY"; + case CF_DSPTEXT: + return "CF_DSPTEXT"; + case CF_DSPBITMAP: + return "CF_DSPBITMAP"; + case CF_DSPMETAFILEPICT: + return "CF_DSPMETAFILEPICT"; + case CF_DSPENHMETAFILE: + return "CF_DSPENHMETAFILE"; + default: + if (GetClipboardFormatNameA(cf, text, len)) { + return text; + } else { + return NULL; + } + } +} + +static STDMETHODIMP_(ULONG) SDLDropTarget_AddRef(SDLDropTarget *target) +{ + return ++target->refcount; +} + +static STDMETHODIMP_(ULONG) SDLDropTarget_Release(SDLDropTarget *target) +{ + --target->refcount; + if (target->refcount == 0) { + SDL_free(target); + return 0; + } + return target->refcount; +} + +static STDMETHODIMP SDLDropTarget_QueryInterface(SDLDropTarget *target, REFIID riid, PVOID *ppv) +{ + if (ppv == NULL) { + return E_INVALIDARG; + } + + *ppv = NULL; + if (WIN_IsEqualIID(riid, &IID_IUnknown) || + WIN_IsEqualIID(riid, &IID_IDropTarget)) { + *ppv = (void *)target; + } + if (*ppv) { + SDLDropTarget_AddRef(target); + return S_OK; + } + return E_NOINTERFACE; +} + +static STDMETHODIMP SDLDropTarget_DragEnter(SDLDropTarget *target, + IDataObject *pDataObject, DWORD grfKeyState, + POINTL pt, DWORD *pdwEffect) +{ + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In DragEnter at %ld, %ld", pt.x, pt.y); + *pdwEffect = DROPEFFECT_COPY; + POINT pnt = { pt.x, pt.y }; + if (ScreenToClient(target->hwnd, &pnt)) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In DragEnter at %ld, %ld => window %u at %ld, %ld", pt.x, pt.y, target->window->id, pnt.x, pnt.y); + SDL_SendDropPosition(target->window, pnt.x, pnt.y); + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In DragEnter at %ld, %ld => nil, nil", pt.x, pt.y); + } + return S_OK; +} + +static STDMETHODIMP SDLDropTarget_DragOver(SDLDropTarget *target, + DWORD grfKeyState, + POINTL pt, DWORD *pdwEffect) +{ + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In DragOver at %ld, %ld", pt.x, pt.y); + *pdwEffect = DROPEFFECT_COPY; + POINT pnt = { pt.x, pt.y }; + if (ScreenToClient(target->hwnd, &pnt)) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In DragOver at %ld, %ld => window %u at %ld, %ld", pt.x, pt.y, target->window->id, pnt.x, pnt.y); + SDL_SendDropPosition(target->window, pnt.x, pnt.y); + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In DragOver at %ld, %ld => nil, nil", pt.x, pt.y); + } + return S_OK; +} + +static STDMETHODIMP SDLDropTarget_DragLeave(SDLDropTarget *target) +{ + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In DragLeave"); + SDL_SendDropComplete(target->window); + return S_OK; +} + +static STDMETHODIMP SDLDropTarget_Drop(SDLDropTarget *target, + IDataObject *pDataObject, DWORD grfKeyState, + POINTL pt, DWORD *pdwEffect) +{ + *pdwEffect = DROPEFFECT_COPY; + POINT pnt = { pt.x, pt.y }; + if (ScreenToClient(target->hwnd, &pnt)) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop at %ld, %ld => window %u at %ld, %ld", pt.x, pt.y, target->window->id, pnt.x, pnt.y); + SDL_SendDropPosition(target->window, pnt.x, pnt.y); + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop at %ld, %ld => nil, nil", pt.x, pt.y); + } + + { + IEnumFORMATETC *pEnumFormatEtc; + HRESULT hres; + hres = pDataObject->lpVtbl->EnumFormatEtc(pDataObject, DATADIR_GET, &pEnumFormatEtc); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop for EnumFormatEtc, HRESULT is %08lx", hres); + if (hres == S_OK) { + FORMATETC fetc; + while (pEnumFormatEtc->lpVtbl->Next(pEnumFormatEtc, 1, &fetc, NULL) == S_OK) { + char name[257] = { 0 }; + const char *cfnm = SDLGetClipboardFormatName(fetc.cfFormat, name, 256); + if (cfnm) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop, Supported format is %08x, '%s'", fetc.cfFormat, cfnm); + } else { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop, Supported format is %08x, Predefined", fetc.cfFormat); + } + } + } + } + + { + FORMATETC fetc; + fetc.cfFormat = target->format_file; + fetc.ptd = NULL; + fetc.dwAspect = DVASPECT_CONTENT; + fetc.lindex = -1; + fetc.tymed = TYMED_HGLOBAL; + const char *format_mime = "text/uri-list"; + if (SUCCEEDED(pDataObject->lpVtbl->QueryGetData(pDataObject, &fetc))) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File for QueryGetData, format %08x '%s', success", + fetc.cfFormat, format_mime); + STGMEDIUM med; + HRESULT hres = pDataObject->lpVtbl->GetData(pDataObject, &fetc, &med); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File for GetData, format %08x '%s', HRESULT is %08lx", + fetc.cfFormat, format_mime, hres); + if (SUCCEEDED(hres)) { + const size_t bsize = GlobalSize(med.hGlobal); + const void *buffer = (void *)GlobalLock(med.hGlobal); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File for GlobalLock, format %08x '%s', memory (%lu) %p", + fetc.cfFormat, format_mime, (unsigned long)bsize, buffer); + if (buffer) { + char *text = (char *)SDL_malloc(bsize + sizeof(Uint32)); + SDL_memcpy((Uint8 *)text, buffer, bsize); + SDL_memset((Uint8 *)text + bsize, 0, sizeof(Uint32)); + char *saveptr = NULL; + char *token = SDL_strtok_r(text, "\r\n", &saveptr); + while (token != NULL) { + if (SDL_URIToLocal(token, token) >= 0) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File, file (%lu of %lu) '%s'", + (unsigned long)SDL_strlen(token), (unsigned long)bsize, token); + SDL_SendDropFile(target->window, NULL, token); + } + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + SDL_free(text); + } + GlobalUnlock(med.hGlobal); + ReleaseStgMedium(&med); + SDL_SendDropComplete(target->window); + return S_OK; + } + } + } + + { + FORMATETC fetc; + fetc.cfFormat = target->format_text; + fetc.ptd = NULL; + fetc.dwAspect = DVASPECT_CONTENT; + fetc.lindex = -1; + fetc.tymed = TYMED_HGLOBAL; + const char *format_mime = "text/plain;charset=utf-8"; + if (SUCCEEDED(pDataObject->lpVtbl->QueryGetData(pDataObject, &fetc))) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for QueryGetData, format %08x '%s', success", + fetc.cfFormat, format_mime); + STGMEDIUM med; + HRESULT hres = pDataObject->lpVtbl->GetData(pDataObject, &fetc, &med); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for GetData, format %08x '%s', HRESULT is %08lx", + fetc.cfFormat, format_mime, hres); + if (SUCCEEDED(hres)) { + const size_t bsize = GlobalSize(med.hGlobal); + const void *buffer = (void *)GlobalLock(med.hGlobal); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for GlobalLock, format %08x '%s', memory (%lu) %p", + fetc.cfFormat, format_mime, (unsigned long)bsize, buffer); + if (buffer) { + char *text = (char *)SDL_malloc(bsize + sizeof(Uint32)); + SDL_memcpy((Uint8 *)text, buffer, bsize); + SDL_memset((Uint8 *)text + bsize, 0, sizeof(Uint32)); + char *saveptr = NULL; + char *token = SDL_strtok_r(text, "\r\n", &saveptr); + while (token != NULL) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text, text (%lu of %lu) '%s'", + (unsigned long)SDL_strlen(token), (unsigned long)bsize, token); + SDL_SendDropText(target->window, (char *)token); + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + SDL_free(text); + } + GlobalUnlock(med.hGlobal); + ReleaseStgMedium(&med); + SDL_SendDropComplete(target->window); + return S_OK; + } + } + } + + { + FORMATETC fetc; + fetc.cfFormat = CF_UNICODETEXT; + fetc.ptd = NULL; + fetc.dwAspect = DVASPECT_CONTENT; + fetc.lindex = -1; + fetc.tymed = TYMED_HGLOBAL; + const char *format_mime = "CF_UNICODETEXT"; + if (SUCCEEDED(pDataObject->lpVtbl->QueryGetData(pDataObject, &fetc))) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for QueryGetData, format %08x '%s', success", + fetc.cfFormat, format_mime); + STGMEDIUM med; + HRESULT hres = pDataObject->lpVtbl->GetData(pDataObject, &fetc, &med); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for GetData, format %08x '%s', HRESULT is %08lx", + fetc.cfFormat, format_mime, hres); + if (SUCCEEDED(hres)) { + const size_t bsize = GlobalSize(med.hGlobal); + const void *buffer = (void *)GlobalLock(med.hGlobal); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for GlobalLock, format %08x '%s', memory (%lu) %p", + fetc.cfFormat, format_mime, (unsigned long)bsize, buffer); + if (buffer) { + buffer = WIN_StringToUTF8((const wchar_t *)buffer); + if (buffer) { + const size_t lbuffer = SDL_strlen((const char *)buffer); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for StringToUTF8, format %08x '%s', memory (%lu) %p", + fetc.cfFormat, format_mime, (unsigned long)lbuffer, buffer); + char *text = (char *)SDL_malloc(lbuffer + sizeof(Uint32)); + SDL_memcpy((Uint8 *)text, buffer, lbuffer); + SDL_memset((Uint8 *)text + lbuffer, 0, sizeof(Uint32)); + char *saveptr = NULL; + char *token = SDL_strtok_r(text, "\r\n", &saveptr); + while (token != NULL) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text, text (%lu of %lu) '%s'", + (unsigned long)SDL_strlen(token), (unsigned long)lbuffer, token); + SDL_SendDropText(target->window, (char *)token); + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + SDL_free(text); + SDL_free((void *)buffer); + } + } + GlobalUnlock(med.hGlobal); + ReleaseStgMedium(&med); + SDL_SendDropComplete(target->window); + return S_OK; + } + } + } + + { + FORMATETC fetc; + fetc.cfFormat = CF_TEXT; + fetc.ptd = NULL; + fetc.dwAspect = DVASPECT_CONTENT; + fetc.lindex = -1; + fetc.tymed = TYMED_HGLOBAL; + const char *format_mime = "CF_TEXT"; + if (SUCCEEDED(pDataObject->lpVtbl->QueryGetData(pDataObject, &fetc))) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for QueryGetData, format %08x '%s', success", + fetc.cfFormat, format_mime); + STGMEDIUM med; + HRESULT hres = pDataObject->lpVtbl->GetData(pDataObject, &fetc, &med); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for GetData, format %08x '%s', HRESULT is %08lx", + fetc.cfFormat, format_mime, hres); + if (SUCCEEDED(hres)) { + const size_t bsize = GlobalSize(med.hGlobal); + const void *buffer = (void *)GlobalLock(med.hGlobal); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text for GlobalLock, format %08x '%s', memory (%lu) %p", + fetc.cfFormat, format_mime, (unsigned long)bsize, buffer); + if (buffer) { + char *text = (char *)SDL_malloc(bsize + sizeof(Uint32)); + SDL_memcpy((Uint8 *)text, buffer, bsize); + SDL_memset((Uint8 *)text + bsize, 0, sizeof(Uint32)); + char *saveptr = NULL; + char *token = SDL_strtok_r(text, "\r\n", &saveptr); + while (token != NULL) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop Text, text (%lu of %lu) '%s'", + (unsigned long)SDL_strlen(token), (unsigned long)bsize, token); + SDL_SendDropText(target->window, (char *)token); + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + SDL_free(text); + } + GlobalUnlock(med.hGlobal); + ReleaseStgMedium(&med); + SDL_SendDropComplete(target->window); + return S_OK; + } + } + } + + { + FORMATETC fetc; + fetc.cfFormat = CF_HDROP; + fetc.ptd = NULL; + fetc.dwAspect = DVASPECT_CONTENT; + fetc.lindex = -1; + fetc.tymed = TYMED_HGLOBAL; + const char *format_mime = "CF_HDROP"; + if (SUCCEEDED(pDataObject->lpVtbl->QueryGetData(pDataObject, &fetc))) { + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File for QueryGetData, format %08x '%s', success", + fetc.cfFormat, format_mime); + STGMEDIUM med; + HRESULT hres = pDataObject->lpVtbl->GetData(pDataObject, &fetc, &med); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File for GetData, format %08x '%s', HRESULT is %08lx", + fetc.cfFormat, format_mime, hres); + if (SUCCEEDED(hres)) { + const size_t bsize = GlobalSize(med.hGlobal); + HDROP drop = (HDROP)GlobalLock(med.hGlobal); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File for GlobalLock, format %08x '%s', memory (%lu) %p", + fetc.cfFormat, format_mime, (unsigned long)bsize, drop); + UINT count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0); + for (UINT i = 0; i < count; ++i) { + UINT size = DragQueryFile(drop, i, NULL, 0) + 1; + LPTSTR buffer = (LPTSTR)SDL_malloc(size * sizeof(TCHAR)); + if (buffer) { + if (DragQueryFile(drop, i, buffer, size)) { + char *file = WIN_StringToUTF8(buffer); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Drop File, file (%lu of %lu) '%s'", + (unsigned long)SDL_strlen(file), (unsigned long)bsize, file); + SDL_SendDropFile(target->window, NULL, file); + SDL_free(file); + } + SDL_free(buffer); + } + } + GlobalUnlock(med.hGlobal); + ReleaseStgMedium(&med); + SDL_SendDropComplete(target->window); + return S_OK; + } + } + } + + SDL_SendDropComplete(target->window); + return S_OK; +} + +static void *vtDropTarget[] = { + (void *)(SDLDropTarget_QueryInterface), + (void *)(SDLDropTarget_AddRef), + (void *)(SDLDropTarget_Release), + (void *)(SDLDropTarget_DragEnter), + (void *)(SDLDropTarget_DragOver), + (void *)(SDLDropTarget_DragLeave), + (void *)(SDLDropTarget_Drop) +}; + +void WIN_AcceptDragAndDrop(SDL_Window *window, bool accept) +{ + SDL_WindowData *data = window->internal; + if (data->videodata->oleinitialized) { + if (accept && !data->drop_target) { + SDLDropTarget *drop_target = (SDLDropTarget *)SDL_calloc(1, sizeof(SDLDropTarget)); + if (drop_target != NULL) { + drop_target->lpVtbl = vtDropTarget; + drop_target->window = window; + drop_target->hwnd = data->hwnd; + drop_target->format_file = RegisterClipboardFormat(L"text/uri-list"); + drop_target->format_text = RegisterClipboardFormat(L"text/plain;charset=utf-8"); + data->drop_target = drop_target; + SDLDropTarget_AddRef(drop_target); + RegisterDragDrop(data->hwnd, (LPDROPTARGET)drop_target); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Accept Drag and Drop, window %u, enabled Full OLE IDropTarget", + window->id); + } + } else if (!accept && data->drop_target) { + RevokeDragDrop(data->hwnd); + SDLDropTarget_Release(data->drop_target); + data->drop_target = NULL; + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Accept Drag and Drop, window %u, disabled Full OLE IDropTarget", + window->id); + } + } else { + DragAcceptFiles(data->hwnd, accept ? TRUE : FALSE); + SDL_LogTrace(SDL_LOG_CATEGORY_INPUT, + ". In Accept Drag and Drop, window %u, %s Fallback WM_DROPFILES", + window->id, (accept ? "enabled" : "disabled")); + } +} + +bool WIN_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation) +{ + FLASHWINFO desc; + + SDL_zero(desc); + desc.cbSize = sizeof(desc); + desc.hwnd = window->internal->hwnd; + switch (operation) { + case SDL_FLASH_CANCEL: + desc.dwFlags = FLASHW_STOP; + break; + case SDL_FLASH_BRIEFLY: + desc.dwFlags = FLASHW_TRAY; + desc.uCount = 1; + break; + case SDL_FLASH_UNTIL_FOCUSED: + desc.dwFlags = (FLASHW_TRAY | FLASHW_TIMERNOFG); + break; + default: + return SDL_Unsupported(); + } + + FlashWindowEx(&desc); + + return true; +} + +void WIN_ShowWindowSystemMenu(SDL_Window *window, int x, int y) +{ + const SDL_WindowData *data = window->internal; + POINT pt; + + pt.x = x; + pt.y = y; + ClientToScreen(data->hwnd, &pt); + SendMessage(data->hwnd, WM_POPUPSYSTEMMENU, 0, MAKELPARAM(pt.x, pt.y)); +} + +bool WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable) +{ + SDL_WindowData *data = window->internal; + HWND hwnd = data->hwnd; + const LONG style = GetWindowLong(hwnd, GWL_EXSTYLE); + + SDL_assert(style != 0); + + if (focusable) { + if (style & WS_EX_NOACTIVATE) { + if (SetWindowLong(hwnd, GWL_EXSTYLE, style & ~WS_EX_NOACTIVATE) == 0) { + return WIN_SetError("SetWindowLong()"); + } + } + } else { + if (!(style & WS_EX_NOACTIVATE)) { + if (SetWindowLong(hwnd, GWL_EXSTYLE, style | WS_EX_NOACTIVATE) == 0) { + return WIN_SetError("SetWindowLong()"); + } + } + } + + return true; +} +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + +void WIN_UpdateDarkModeForHWND(HWND hwnd) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + SDL_SharedObject *ntdll = SDL_LoadObject("ntdll.dll"); + if (!ntdll) { + return; + } + // There is no function to get Windows build number, so let's get it here via RtlGetVersion + RtlGetVersion_t RtlGetVersionFunc = (RtlGetVersion_t)SDL_LoadFunction(ntdll, "RtlGetVersion"); + NT_OSVERSIONINFOW os_info; + os_info.dwOSVersionInfoSize = sizeof(NT_OSVERSIONINFOW); + os_info.dwBuildNumber = 0; + if (RtlGetVersionFunc) { + RtlGetVersionFunc(&os_info); + } + SDL_UnloadObject(ntdll); + os_info.dwBuildNumber &= ~0xF0000000; + if (os_info.dwBuildNumber < 17763) { + // Too old to support dark mode + return; + } + SDL_SharedObject *uxtheme = SDL_LoadObject("uxtheme.dll"); + if (!uxtheme) { + return; + } + RefreshImmersiveColorPolicyState_t RefreshImmersiveColorPolicyStateFunc = (RefreshImmersiveColorPolicyState_t)SDL_LoadFunction(uxtheme, MAKEINTRESOURCEA(104)); + ShouldAppsUseDarkMode_t ShouldAppsUseDarkModeFunc = (ShouldAppsUseDarkMode_t)SDL_LoadFunction(uxtheme, MAKEINTRESOURCEA(132)); + AllowDarkModeForWindow_t AllowDarkModeForWindowFunc = (AllowDarkModeForWindow_t)SDL_LoadFunction(uxtheme, MAKEINTRESOURCEA(133)); + if (os_info.dwBuildNumber < 18362) { + AllowDarkModeForApp_t AllowDarkModeForAppFunc = (AllowDarkModeForApp_t)SDL_LoadFunction(uxtheme, MAKEINTRESOURCEA(135)); + if (AllowDarkModeForAppFunc) { + AllowDarkModeForAppFunc(true); + } + } else { + SetPreferredAppMode_t SetPreferredAppModeFunc = (SetPreferredAppMode_t)SDL_LoadFunction(uxtheme, MAKEINTRESOURCEA(135)); + if (SetPreferredAppModeFunc) { + SetPreferredAppModeFunc(UXTHEME_APPMODE_ALLOW_DARK); + } + } + if (RefreshImmersiveColorPolicyStateFunc) { + RefreshImmersiveColorPolicyStateFunc(); + } + if (AllowDarkModeForWindowFunc) { + AllowDarkModeForWindowFunc(hwnd, true); + } + BOOL value; + // Check dark mode using ShouldAppsUseDarkMode, but use SDL_GetSystemTheme as a fallback + if (ShouldAppsUseDarkModeFunc) { + value = ShouldAppsUseDarkModeFunc() ? TRUE : FALSE; + } else { + value = (SDL_GetSystemTheme() == SDL_SYSTEM_THEME_DARK) ? TRUE : FALSE; + } + SDL_UnloadObject(uxtheme); + if (os_info.dwBuildNumber < 18362) { + SetProp(hwnd, TEXT("UseImmersiveDarkModeColors"), SDL_reinterpret_cast(HANDLE, SDL_static_cast(INT_PTR, value))); + } else { + HMODULE user32 = GetModuleHandle(TEXT("user32.dll")); + if (user32) { + SetWindowCompositionAttribute_t SetWindowCompositionAttributeFunc = (SetWindowCompositionAttribute_t)GetProcAddress(user32, "SetWindowCompositionAttribute"); + if (SetWindowCompositionAttributeFunc) { + WINDOWCOMPOSITIONATTRIBDATA data = { WCA_USEDARKMODECOLORS, &value, sizeof(value) }; + SetWindowCompositionAttributeFunc(hwnd, &data); + } + } + } +#endif +} + +bool WIN_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + SDL_WindowData *child_data = window->internal; + const LONG_PTR parent_hwnd = (LONG_PTR)(parent ? parent->internal->hwnd : NULL); + const DWORD style = GetWindowLong(child_data->hwnd, GWL_STYLE); + + if (!(style & WS_CHILD)) { + /* Despite the name, this changes the *owner* of a toplevel window, not + * the parent of a child window. + * + * https://devblogs.microsoft.com/oldnewthing/20100315-00/?p=14613 + */ + SetWindowLongPtr(child_data->hwnd, GWLP_HWNDPARENT, parent_hwnd); + } else { + SetParent(child_data->hwnd, (HWND)parent_hwnd); + } +#endif /*!defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES)*/ + + return true; +} + +bool WIN_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal) +{ +#if !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + const HWND parent_hwnd = window->parent->internal->hwnd; + + if (modal) { + // Disable the parent window. + EnableWindow(parent_hwnd, FALSE); + } else if (!(window->flags & SDL_WINDOW_HIDDEN)) { + // Re-enable the parent window + EnableWindow(parent_hwnd, TRUE); + } +#endif // !defined(SDL_PLATFORM_XBOXONE) && !defined(SDL_PLATFORM_XBOXSERIES) + + return true; +} + +#endif // SDL_VIDEO_DRIVER_WINDOWS diff --git a/contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.h b/contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.h new file mode 100644 index 0000000..a2c9a21 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/SDL_windowswindow.h @@ -0,0 +1,152 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_windowswindow_h_ +#define SDL_windowswindow_h_ + +#ifdef SDL_VIDEO_OPENGL_EGL +#include "../SDL_egl_c.h" +#else +#include "../SDL_sysvideo.h" +#endif + +// Set up for C function definitions, even when using C++ +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum SDL_WindowRect +{ + SDL_WINDOWRECT_CURRENT, + SDL_WINDOWRECT_WINDOWED, + SDL_WINDOWRECT_FLOATING, + SDL_WINDOWRECT_PENDING +} SDL_WindowRect; + +typedef enum SDL_WindowEraseBackgroundMode +{ + SDL_ERASEBACKGROUNDMODE_NEVER, + SDL_ERASEBACKGROUNDMODE_INITIAL, + SDL_ERASEBACKGROUNDMODE_ALWAYS, +} SDL_WindowEraseBackgroundMode; + +typedef struct +{ + void **lpVtbl; + int refcount; + SDL_Window *window; + HWND hwnd; + UINT format_text; + UINT format_file; +} SDLDropTarget; + +struct SDL_WindowData +{ + SDL_Window *window; + HWND hwnd; + HWND parent; + HDC hdc; + HDC mdc; + HINSTANCE hinstance; + HBITMAP hbm; + WNDPROC wndproc; + HHOOK keyboard_hook; + WPARAM mouse_button_flags; + LPARAM last_pointer_update; + WCHAR high_surrogate; + bool initializing; + bool expected_resize; + bool in_border_change; + bool in_title_click; + Uint8 focus_click_pending; + bool skip_update_clipcursor; + bool windowed_mode_was_maximized; + bool in_window_deactivation; + bool force_ws_maximizebox; + bool disable_move_size_events; + int in_modal_loop; + RECT initial_size_rect; + RECT cursor_clipped_rect; // last successfully committed clipping rect for this window + RECT cursor_ctrlock_rect; // this is Windows-specific, but probably does not need to be per-window + UINT windowed_mode_corner_rounding; + COLORREF dwma_border_color; + bool mouse_tracked; + bool destroy_parent_with_window; + SDL_DisplayID last_displayID; + WCHAR *ICMFileName; + SDL_Window *keyboard_focus; + SDL_WindowEraseBackgroundMode hint_erase_background_mode; + struct SDL_VideoData *videodata; +#ifdef SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif + + // Whether we retain the content of the window when changing state + UINT copybits_flag; + SDLDropTarget *drop_target; +}; + +extern bool WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern void WIN_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); +extern bool WIN_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *top, int *left, int *bottom, int *right); +extern void WIN_GetWindowSizeInPixels(SDL_VideoDevice *_this, SDL_Window *window, int *width, int *height); +extern bool WIN_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity); +extern void WIN_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void WIN_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern void WIN_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); +extern SDL_FullscreenResult WIN_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); +extern void WIN_UpdateWindowICCProfile(SDL_Window *window, bool send_event); +extern void *WIN_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); +extern bool WIN_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); +extern bool WIN_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern bool WIN_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern void WIN_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window); +extern void WIN_UpdateClipCursor(SDL_Window *window); +extern void WIN_UnclipCursorForWindow(SDL_Window *window); +extern bool WIN_SetWindowHitTest(SDL_Window *window, bool enabled); +extern void WIN_AcceptDragAndDrop(SDL_Window *window, bool accept); +extern bool WIN_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); +extern void WIN_UpdateDarkModeForHWND(HWND hwnd); +extern bool WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags, SDL_WindowRect rect_type); +extern void WIN_ShowWindowSystemMenu(SDL_Window *window, int x, int y); +extern bool WIN_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); +extern bool WIN_AdjustWindowRect(SDL_Window *window, int *x, int *y, int *width, int *height, SDL_WindowRect rect_type); +extern bool WIN_AdjustWindowRectForHWND(HWND hwnd, LPRECT lpRect, UINT frame_dpi); +extern bool WIN_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); +extern bool WIN_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); + +// Ends C function definitions when using C++ +#ifdef __cplusplus +} +#endif + +#endif // SDL_windowswindow_h_ diff --git a/contrib/SDL-3.2.8/src/video/windows/wmmsg.h b/contrib/SDL-3.2.8/src/video/windows/wmmsg.h new file mode 100644 index 0000000..2f18aaa --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/windows/wmmsg.h @@ -0,0 +1,1050 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#define MAX_WMMSG (sizeof(wmtab) / sizeof(wmtab[0])) + +const char *wmtab[] = { + "WM_NULL", + "WM_CREATE", + "WM_DESTROY", + "WM_MOVE", + "UNKNOWN (4)", + "WM_SIZE", + "WM_ACTIVATE", + "WM_SETFOCUS", + "WM_KILLFOCUS", + "UNKNOWN (9)", + "WM_ENABLE", + "WM_SETREDRAW", + "WM_SETTEXT", + "WM_GETTEXT", + "WM_GETTEXTLENGTH", + "WM_PAINT", + "WM_CLOSE", + "WM_QUERYENDSESSION", + "WM_QUIT", + "WM_QUERYOPEN", + "WM_ERASEBKGND", + "WM_SYSCOLORCHANGE", + "WM_ENDSESSION", + "UNKNOWN (23)", + "WM_SHOWWINDOW", + "UNKNOWN (25)", + "WM_SETTINGCHANGE", + "WM_DEVMODECHANGE", + "WM_ACTIVATEAPP", + "WM_FONTCHANGE", + "WM_TIMECHANGE", + "WM_CANCELMODE", + "WM_SETCURSOR", + "WM_MOUSEACTIVATE", + "WM_CHILDACTIVATE", + "WM_QUEUESYNC", + "WM_GETMINMAXINFO", + "UNKNOWN (37)", + "WM_PAINTICON", + "WM_ICONERASEBKGND", + "WM_NEXTDLGCTL", + "UNKNOWN (41)", + "WM_SPOOLERSTATUS", + "WM_DRAWITEM", + "WM_MEASUREITEM", + "WM_DELETEITEM", + "WM_VKEYTOITEM", + "WM_CHARTOITEM", + "WM_SETFONT", + "WM_GETFONT", + "WM_SETHOTKEY", + "WM_GETHOTKEY", + "UNKNOWN (52)", + "UNKNOWN (53)", + "UNKNOWN (54)", + "WM_QUERYDRAGICON", + "UNKNOWN (56)", + "WM_COMPAREITEM", + "UNKNOWN (58)", + "UNKNOWN (59)", + "UNKNOWN (60)", + "WM_GETOBJECT", + "UNKNOWN (62)", + "UNKNOWN (63)", + "UNKNOWN (64)", + "WM_COMPACTING", + "UNKNOWN (66)", + "UNKNOWN (67)", + "WM_COMMNOTIFY", + "UNKNOWN (69)", + "WM_WINDOWPOSCHANGING", + "WM_WINDOWPOSCHANGED", + "WM_POWER", + "UNKNOWN (73)", + "WM_COPYDATA", + "WM_CANCELJOURNAL", + "UNKNOWN (76)", + "UNKNOWN (77)", + "WM_NOTIFY", + "UNKNOWN (79)", + "WM_INPUTLANGCHANGEREQUEST", + "WM_INPUTLANGCHANGE", + "WM_TCARD", + "WM_HELP", + "WM_USERCHANGED", + "WM_NOTIFYFORMAT", + "UNKNOWN (86)", + "UNKNOWN (87)", + "UNKNOWN (88)", + "UNKNOWN (89)", + "UNKNOWN (90)", + "UNKNOWN (91)", + "UNKNOWN (92)", + "UNKNOWN (93)", + "UNKNOWN (94)", + "UNKNOWN (95)", + "UNKNOWN (96)", + "UNKNOWN (97)", + "UNKNOWN (98)", + "UNKNOWN (99)", + "UNKNOWN (100)", + "UNKNOWN (101)", + "UNKNOWN (102)", + "UNKNOWN (103)", + "UNKNOWN (104)", + "UNKNOWN (105)", + "UNKNOWN (106)", + "UNKNOWN (107)", + "UNKNOWN (108)", + "UNKNOWN (109)", + "UNKNOWN (110)", + "UNKNOWN (111)", + "UNKNOWN (112)", + "UNKNOWN (113)", + "UNKNOWN (114)", + "UNKNOWN (115)", + "UNKNOWN (116)", + "UNKNOWN (117)", + "UNKNOWN (118)", + "UNKNOWN (119)", + "UNKNOWN (120)", + "UNKNOWN (121)", + "UNKNOWN (122)", + "WM_CONTEXTMENU", + "WM_STYLECHANGING", + "WM_STYLECHANGED", + "WM_DISPLAYCHANGE", + "WM_GETICON", + "WM_SETICON", + "WM_NCCREATE", + "WM_NCDESTROY", + "WM_NCCALCSIZE", + "WM_NCHITTEST", + "WM_NCPAINT", + "WM_NCACTIVATE", + "WM_GETDLGCODE", + "WM_SYNCPAINT", + "UNKNOWN (137)", + "UNKNOWN (138)", + "UNKNOWN (139)", + "UNKNOWN (140)", + "UNKNOWN (141)", + "UNKNOWN (142)", + "UNKNOWN (143)", + "UNKNOWN (144)", + "UNKNOWN (145)", + "UNKNOWN (146)", + "UNKNOWN (147)", + "UNKNOWN (148)", + "UNKNOWN (149)", + "UNKNOWN (150)", + "UNKNOWN (151)", + "UNKNOWN (152)", + "UNKNOWN (153)", + "UNKNOWN (154)", + "UNKNOWN (155)", + "UNKNOWN (156)", + "UNKNOWN (157)", + "UNKNOWN (158)", + "UNKNOWN (159)", + "WM_NCMOUSEMOVE", + "WM_NCLBUTTONDOWN", + "WM_NCLBUTTONUP", + "WM_NCLBUTTONDBLCLK", + "WM_NCRBUTTONDOWN", + "WM_NCRBUTTONUP", + "WM_NCRBUTTONDBLCLK", + "WM_NCMBUTTONDOWN", + "WM_NCMBUTTONUP", + "WM_NCMBUTTONDBLCLK", + "UNKNOWN (170)", + "WM_NCXBUTTONDOWN", + "WM_NCXBUTTONUP", + "WM_NCXBUTTONDBLCLK", + "WM_NCUAHDRAWCAPTION", + "WM_NCUAHDRAWFRAME", + "UNKNOWN (176)", + "UNKNOWN (177)", + "UNKNOWN (178)", + "UNKNOWN (179)", + "UNKNOWN (180)", + "UNKNOWN (181)", + "UNKNOWN (182)", + "UNKNOWN (183)", + "UNKNOWN (184)", + "UNKNOWN (185)", + "UNKNOWN (186)", + "UNKNOWN (187)", + "UNKNOWN (188)", + "UNKNOWN (189)", + "UNKNOWN (190)", + "UNKNOWN (191)", + "UNKNOWN (192)", + "UNKNOWN (193)", + "UNKNOWN (194)", + "UNKNOWN (195)", + "UNKNOWN (196)", + "UNKNOWN (197)", + "UNKNOWN (198)", + "UNKNOWN (199)", + "UNKNOWN (200)", + "UNKNOWN (201)", + "UNKNOWN (202)", + "UNKNOWN (203)", + "UNKNOWN (204)", + "UNKNOWN (205)", + "UNKNOWN (206)", + "UNKNOWN (207)", + "UNKNOWN (208)", + "UNKNOWN (209)", + "UNKNOWN (210)", + "UNKNOWN (211)", + "UNKNOWN (212)", + "UNKNOWN (213)", + "UNKNOWN (214)", + "UNKNOWN (215)", + "UNKNOWN (216)", + "UNKNOWN (217)", + "UNKNOWN (218)", + "UNKNOWN (219)", + "UNKNOWN (220)", + "UNKNOWN (221)", + "UNKNOWN (222)", + "UNKNOWN (223)", + "UNKNOWN (224)", + "UNKNOWN (225)", + "UNKNOWN (226)", + "UNKNOWN (227)", + "UNKNOWN (228)", + "UNKNOWN (229)", + "UNKNOWN (230)", + "UNKNOWN (231)", + "UNKNOWN (232)", + "UNKNOWN (233)", + "UNKNOWN (234)", + "UNKNOWN (235)", + "UNKNOWN (236)", + "UNKNOWN (237)", + "UNKNOWN (238)", + "UNKNOWN (239)", + "UNKNOWN (240)", + "UNKNOWN (241)", + "UNKNOWN (242)", + "UNKNOWN (243)", + "UNKNOWN (244)", + "UNKNOWN (245)", + "UNKNOWN (246)", + "UNKNOWN (247)", + "UNKNOWN (248)", + "UNKNOWN (249)", + "UNKNOWN (250)", + "UNKNOWN (251)", + "UNKNOWN (252)", + "UNKNOWN (253)", + "UNKNOWN (254)", + "WM_INPUT", + "WM_KEYDOWN", + "WM_KEYUP", + "WM_CHAR", + "WM_DEADCHAR", + "WM_SYSKEYDOWN", + "WM_SYSKEYUP", + "WM_SYSCHAR", + "WM_SYSDEADCHAR", + "WM_KEYLAST", + "UNKNOWN (265)", + "UNKNOWN (266)", + "UNKNOWN (267)", + "UNKNOWN (268)", + "UNKNOWN (269)", + "UNKNOWN (270)", + "UNKNOWN (271)", + "WM_INITDIALOG", + "WM_COMMAND", + "WM_SYSCOMMAND", + "WM_TIMER", + "WM_HSCROLL", + "WM_VSCROLL", + "WM_INITMENU", + "WM_INITMENUPOPUP", + "UNKNOWN (280)", + "WM_GESTURE", + "UNKNOWN (282)", + "UNKNOWN (283)", + "UNKNOWN (284)", + "UNKNOWN (285)", + "UNKNOWN (286)", + "WM_MENUSELECT", + "WM_MENUCHAR", + "WM_ENTERIDLE", + "WM_MENURBUTTONUP", + "WM_MENUDRAG", + "WM_MENUGETOBJECT", + "WM_UNINITMENUPOPUP", + "WM_MENUCOMMAND", + "UNKNOWN (295)", + "UNKNOWN (296)", + "UNKNOWN (297)", + "UNKNOWN (298)", + "UNKNOWN (299)", + "UNKNOWN (300)", + "UNKNOWN (301)", + "UNKNOWN (302)", + "UNKNOWN (303)", + "UNKNOWN (304)", + "UNKNOWN (305)", + "WM_CTLCOLORMSGBOX", + "WM_CTLCOLOREDIT", + "WM_CTLCOLORLISTBOX", + "WM_CTLCOLORBTN", + "WM_CTLCOLORDLG", + "WM_CTLCOLORSCROLLBAR", + "WM_CTLCOLORSTATIC", + "UNKNOWN (313)", + "UNKNOWN (314)", + "UNKNOWN (315)", + "UNKNOWN (316)", + "UNKNOWN (317)", + "UNKNOWN (318)", + "UNKNOWN (319)", + "UNKNOWN (320)", + "UNKNOWN (321)", + "UNKNOWN (322)", + "UNKNOWN (323)", + "UNKNOWN (324)", + "UNKNOWN (325)", + "UNKNOWN (326)", + "UNKNOWN (327)", + "UNKNOWN (328)", + "UNKNOWN (329)", + "UNKNOWN (330)", + "UNKNOWN (331)", + "UNKNOWN (332)", + "UNKNOWN (333)", + "UNKNOWN (334)", + "UNKNOWN (335)", + "UNKNOWN (336)", + "UNKNOWN (337)", + "UNKNOWN (338)", + "UNKNOWN (339)", + "UNKNOWN (340)", + "UNKNOWN (341)", + "UNKNOWN (342)", + "UNKNOWN (343)", + "UNKNOWN (344)", + "UNKNOWN (345)", + "UNKNOWN (346)", + "UNKNOWN (347)", + "UNKNOWN (348)", + "UNKNOWN (349)", + "UNKNOWN (350)", + "UNKNOWN (351)", + "UNKNOWN (352)", + "UNKNOWN (353)", + "UNKNOWN (354)", + "UNKNOWN (355)", + "UNKNOWN (356)", + "UNKNOWN (357)", + "UNKNOWN (358)", + "UNKNOWN (359)", + "UNKNOWN (360)", + "UNKNOWN (361)", + "UNKNOWN (362)", + "UNKNOWN (363)", + "UNKNOWN (364)", + "UNKNOWN (365)", + "UNKNOWN (366)", + "UNKNOWN (367)", + "UNKNOWN (368)", + "UNKNOWN (369)", + "UNKNOWN (370)", + "UNKNOWN (371)", + "UNKNOWN (372)", + "UNKNOWN (373)", + "UNKNOWN (374)", + "UNKNOWN (375)", + "UNKNOWN (376)", + "UNKNOWN (377)", + "UNKNOWN (378)", + "UNKNOWN (379)", + "UNKNOWN (380)", + "UNKNOWN (381)", + "UNKNOWN (382)", + "UNKNOWN (383)", + "UNKNOWN (384)", + "UNKNOWN (385)", + "UNKNOWN (386)", + "UNKNOWN (387)", + "UNKNOWN (388)", + "UNKNOWN (389)", + "UNKNOWN (390)", + "UNKNOWN (391)", + "UNKNOWN (392)", + "UNKNOWN (393)", + "UNKNOWN (394)", + "UNKNOWN (395)", + "UNKNOWN (396)", + "UNKNOWN (397)", + "UNKNOWN (398)", + "UNKNOWN (399)", + "UNKNOWN (400)", + "UNKNOWN (401)", + "UNKNOWN (402)", + "UNKNOWN (403)", + "UNKNOWN (404)", + "UNKNOWN (405)", + "UNKNOWN (406)", + "UNKNOWN (407)", + "UNKNOWN (408)", + "UNKNOWN (409)", + "UNKNOWN (410)", + "UNKNOWN (411)", + "UNKNOWN (412)", + "UNKNOWN (413)", + "UNKNOWN (414)", + "UNKNOWN (415)", + "UNKNOWN (416)", + "UNKNOWN (417)", + "UNKNOWN (418)", + "UNKNOWN (419)", + "UNKNOWN (420)", + "UNKNOWN (421)", + "UNKNOWN (422)", + "UNKNOWN (423)", + "UNKNOWN (424)", + "UNKNOWN (425)", + "UNKNOWN (426)", + "UNKNOWN (427)", + "UNKNOWN (428)", + "UNKNOWN (429)", + "UNKNOWN (430)", + "UNKNOWN (431)", + "UNKNOWN (432)", + "UNKNOWN (433)", + "UNKNOWN (434)", + "UNKNOWN (435)", + "UNKNOWN (436)", + "UNKNOWN (437)", + "UNKNOWN (438)", + "UNKNOWN (439)", + "UNKNOWN (440)", + "UNKNOWN (441)", + "UNKNOWN (442)", + "UNKNOWN (443)", + "UNKNOWN (444)", + "UNKNOWN (445)", + "UNKNOWN (446)", + "UNKNOWN (447)", + "UNKNOWN (448)", + "UNKNOWN (449)", + "UNKNOWN (450)", + "UNKNOWN (451)", + "UNKNOWN (452)", + "UNKNOWN (453)", + "UNKNOWN (454)", + "UNKNOWN (455)", + "UNKNOWN (456)", + "UNKNOWN (457)", + "UNKNOWN (458)", + "UNKNOWN (459)", + "UNKNOWN (460)", + "UNKNOWN (461)", + "UNKNOWN (462)", + "UNKNOWN (463)", + "UNKNOWN (464)", + "UNKNOWN (465)", + "UNKNOWN (466)", + "UNKNOWN (467)", + "UNKNOWN (468)", + "UNKNOWN (469)", + "UNKNOWN (470)", + "UNKNOWN (471)", + "UNKNOWN (472)", + "UNKNOWN (473)", + "UNKNOWN (474)", + "UNKNOWN (475)", + "UNKNOWN (476)", + "UNKNOWN (477)", + "UNKNOWN (478)", + "UNKNOWN (479)", + "UNKNOWN (480)", + "UNKNOWN (481)", + "UNKNOWN (482)", + "UNKNOWN (483)", + "UNKNOWN (484)", + "UNKNOWN (485)", + "UNKNOWN (486)", + "UNKNOWN (487)", + "UNKNOWN (488)", + "UNKNOWN (489)", + "UNKNOWN (490)", + "UNKNOWN (491)", + "UNKNOWN (492)", + "UNKNOWN (493)", + "UNKNOWN (494)", + "UNKNOWN (495)", + "UNKNOWN (496)", + "UNKNOWN (497)", + "UNKNOWN (498)", + "UNKNOWN (499)", + "UNKNOWN (500)", + "UNKNOWN (501)", + "UNKNOWN (502)", + "UNKNOWN (503)", + "UNKNOWN (504)", + "UNKNOWN (505)", + "UNKNOWN (506)", + "UNKNOWN (507)", + "UNKNOWN (508)", + "UNKNOWN (509)", + "UNKNOWN (510)", + "UNKNOWN (511)", + "WM_MOUSEMOVE", + "WM_LBUTTONDOWN", + "WM_LBUTTONUP", + "WM_LBUTTONDBLCLK", + "WM_RBUTTONDOWN", + "WM_RBUTTONUP", + "WM_RBUTTONDBLCLK", + "WM_MBUTTONDOWN", + "WM_MBUTTONUP", + "WM_MOUSELAST", + "WM_MOUSEWHEEL", + "WM_XBUTTONDOWN", + "WM_XBUTTONUP", + "UNKNOWN (525)", + "UNKNOWN (526)", + "UNKNOWN (527)", + "WM_PARENTNOTIFY", + "WM_ENTERMENULOOP", + "WM_EXITMENULOOP", + "WM_NEXTMENU", + "WM_SIZING", + "WM_CAPTURECHANGED", + "WM_MOVING", + "UNKNOWN (535)", + "WM_POWERBROADCAST", + "WM_DEVICECHANGE", + "UNKNOWN (538)", + "UNKNOWN (539)", + "UNKNOWN (540)", + "UNKNOWN (541)", + "UNKNOWN (542)", + "UNKNOWN (543)", + "WM_MDICREATE", + "WM_MDIDESTROY", + "WM_MDIACTIVATE", + "WM_MDIRESTORE", + "WM_MDINEXT", + "WM_MDIMAXIMIZE", + "WM_MDITILE", + "WM_MDICASCADE", + "WM_MDIICONARRANGE", + "WM_MDIGETACTIVE", + "UNKNOWN (554)", + "UNKNOWN (555)", + "UNKNOWN (556)", + "UNKNOWN (557)", + "UNKNOWN (558)", + "UNKNOWN (559)", + "WM_MDISETMENU", + "WM_ENTERSIZEMOVE", + "WM_EXITSIZEMOVE", + "WM_DROPFILES", + "WM_MDIREFRESHMENU", + "UNKNOWN (565)", + "UNKNOWN (566)", + "UNKNOWN (567)", + "WM_POINTERDEVICECHANGE", + "WM_POINTERDEVICEINRANGE", + "WM_POINTERDEVICEOUTOFRANGE", + "UNKNOWN (571)", + "UNKNOWN (572)", + "UNKNOWN (573)", + "UNKNOWN (574)", + "UNKNOWN (575)", + "WM_TOUCH", + "WM_NCPOINTERUPDATE", + "WM_NCPOINTERDOWN", + "WM_NCPOINTERUP", + "UNKNOWN (580)", + "WM_POINTERUPDATE", + "WM_POINTERDOWN", + "WM_POINTERUP", + "WM_POINTERENTER", + "WM_POINTERLEAVE", + "WM_POINTERACTIVATE", + "WM_POINTERCAPTURECHANGED", + "WM_TOUCHHITTESTING", + "WM_POINTERWHEEL", + "WM_POINTERHWHEEL", + "DM_POINTERHITTEST", + "UNKNOWN (592)", + "UNKNOWN (593)", + "UNKNOWN (594)", + "UNKNOWN (595)", + "UNKNOWN (596)", + "UNKNOWN (597)", + "UNKNOWN (598)", + "UNKNOWN (599)", + "UNKNOWN (600)", + "UNKNOWN (601)", + "UNKNOWN (602)", + "UNKNOWN (603)", + "UNKNOWN (604)", + "UNKNOWN (605)", + "UNKNOWN (606)", + "UNKNOWN (607)", + "UNKNOWN (608)", + "UNKNOWN (609)", + "UNKNOWN (610)", + "UNKNOWN (611)", + "UNKNOWN (612)", + "UNKNOWN (613)", + "UNKNOWN (614)", + "UNKNOWN (615)", + "UNKNOWN (616)", + "UNKNOWN (617)", + "UNKNOWN (618)", + "UNKNOWN (619)", + "UNKNOWN (620)", + "UNKNOWN (621)", + "UNKNOWN (622)", + "UNKNOWN (623)", + "UNKNOWN (624)", + "UNKNOWN (625)", + "UNKNOWN (626)", + "UNKNOWN (627)", + "UNKNOWN (628)", + "UNKNOWN (629)", + "UNKNOWN (630)", + "UNKNOWN (631)", + "UNKNOWN (632)", + "UNKNOWN (633)", + "UNKNOWN (634)", + "UNKNOWN (635)", + "UNKNOWN (636)", + "UNKNOWN (637)", + "UNKNOWN (638)", + "UNKNOWN (639)", + "UNKNOWN (640)", + "WM_IME_SETCONTEXT", + "WM_IME_NOTIFY", + "WM_IME_CONTROL", + "WM_IME_COMPOSITIONFULL", + "WM_IME_SELECT", + "WM_IME_CHAR", + "UNKNOWN (647)", + "WM_IME_REQUEST", + "UNKNOWN (649)", + "UNKNOWN (650)", + "UNKNOWN (651)", + "UNKNOWN (652)", + "UNKNOWN (653)", + "UNKNOWN (654)", + "UNKNOWN (655)", + "WM_IME_KEYDOWN", + "WM_IME_KEYUP", + "UNKNOWN (658)", + "UNKNOWN (659)", + "UNKNOWN (660)", + "UNKNOWN (661)", + "UNKNOWN (662)", + "UNKNOWN (663)", + "UNKNOWN (664)", + "UNKNOWN (665)", + "UNKNOWN (666)", + "UNKNOWN (667)", + "UNKNOWN (668)", + "UNKNOWN (669)", + "UNKNOWN (670)", + "UNKNOWN (671)", + "WM_NCMOUSEHOVER", + "WM_MOUSEHOVER", + "WM_NCMOUSELEAVE", + "WM_MOUSELEAVE", + "UNKNOWN (676)", + "UNKNOWN (677)", + "UNKNOWN (678)", + "UNKNOWN (679)", + "UNKNOWN (680)", + "UNKNOWN (681)", + "UNKNOWN (682)", + "UNKNOWN (683)", + "UNKNOWN (684)", + "UNKNOWN (685)", + "UNKNOWN (686)", + "UNKNOWN (687)", + "UNKNOWN (688)", + "WM_WTSSESSION_CHANGE", + "UNKNOWN (690)", + "UNKNOWN (691)", + "UNKNOWN (692)", + "UNKNOWN (693)", + "UNKNOWN (694)", + "UNKNOWN (695)", + "UNKNOWN (696)", + "UNKNOWN (697)", + "UNKNOWN (698)", + "UNKNOWN (699)", + "UNKNOWN (700)", + "UNKNOWN (701)", + "UNKNOWN (702)", + "UNKNOWN (703)", + "UNKNOWN (704)", + "UNKNOWN (705)", + "UNKNOWN (706)", + "UNKNOWN (707)", + "UNKNOWN (708)", + "UNKNOWN (709)", + "UNKNOWN (710)", + "UNKNOWN (711)", + "UNKNOWN (712)", + "UNKNOWN (713)", + "UNKNOWN (714)", + "UNKNOWN (715)", + "UNKNOWN (716)", + "UNKNOWN (717)", + "UNKNOWN (718)", + "UNKNOWN (719)", + "UNKNOWN (720)", + "UNKNOWN (721)", + "UNKNOWN (722)", + "UNKNOWN (723)", + "UNKNOWN (724)", + "UNKNOWN (725)", + "UNKNOWN (726)", + "UNKNOWN (727)", + "UNKNOWN (728)", + "UNKNOWN (729)", + "UNKNOWN (730)", + "UNKNOWN (731)", + "UNKNOWN (732)", + "UNKNOWN (733)", + "UNKNOWN (734)", + "UNKNOWN (735)", + "WM_DPICHANGED", + "UNKNOWN (737)", + "UNKNOWN (738)", + "UNKNOWN (739)", + "WM_GETDPISCALEDSIZE", + "UNKNOWN (741)", + "UNKNOWN (742)", + "UNKNOWN (743)", + "UNKNOWN (744)", + "UNKNOWN (745)", + "UNKNOWN (746)", + "UNKNOWN (747)", + "UNKNOWN (748)", + "UNKNOWN (749)", + "UNKNOWN (750)", + "UNKNOWN (751)", + "UNKNOWN (752)", + "UNKNOWN (753)", + "UNKNOWN (754)", + "UNKNOWN (755)", + "UNKNOWN (756)", + "UNKNOWN (757)", + "UNKNOWN (758)", + "UNKNOWN (759)", + "UNKNOWN (760)", + "UNKNOWN (761)", + "UNKNOWN (762)", + "UNKNOWN (763)", + "UNKNOWN (764)", + "UNKNOWN (765)", + "UNKNOWN (766)", + "UNKNOWN (767)", + "WM_CUT", + "WM_COPY", + "WM_PASTE", + "WM_CLEAR", + "WM_UNDO", + "WM_RENDERFORMAT", + "WM_RENDERALLFORMATS", + "WM_DESTROYCLIPBOARD", + "WM_DRAWCLIPBOARD", + "WM_PAINTCLIPBOARD", + "WM_VSCROLLCLIPBOARD", + "WM_SIZECLIPBOARD", + "WM_ASKCBFORMATNAME", + "WM_CHANGECBCHAIN", + "WM_HSCROLLCLIPBOARD", + "WM_QUERYNEWPALETTE", + "WM_PALETTEISCHANGING", + "WM_PALETTECHANGED", + "WM_HOTKEY", + "UNKNOWN (787)", + "UNKNOWN (788)", + "UNKNOWN (789)", + "UNKNOWN (790)", + "WM_PRINT", + "WM_PRINTCLIENT", + "WM_APPCOMMAND", + "WM_THEMECHANGED", + "UNKNOWN (795)", + "UNKNOWN (796)", + "WM_CLIPBOARDUPDATE", + "WM_DWMCOMPOSITIONCHANGED", + "WM_DWMNCRENDERINGCHANGED", + "WM_DWMCOLORIZATIONCOLORCHANGED", + "WM_DWMWINDOWMAXIMIZEDCHANGE", + "UNKNOWN (802)", + "WM_DWMSENDICONICTHUMBNAIL", + "UNKNOWN (804)", + "UNKNOWN (805)", + "WM_DWMSENDICONICLIVEPREVIEWBITMAP", + "UNKNOWN (807)", + "UNKNOWN (808)", + "UNKNOWN (809)", + "UNKNOWN (810)", + "UNKNOWN (811)", + "UNKNOWN (812)", + "UNKNOWN (813)", + "UNKNOWN (814)", + "UNKNOWN (815)", + "UNKNOWN (816)", + "UNKNOWN (817)", + "UNKNOWN (818)", + "UNKNOWN (819)", + "UNKNOWN (820)", + "UNKNOWN (821)", + "UNKNOWN (822)", + "UNKNOWN (823)", + "UNKNOWN (824)", + "UNKNOWN (825)", + "UNKNOWN (826)", + "UNKNOWN (827)", + "UNKNOWN (828)", + "UNKNOWN (829)", + "UNKNOWN (830)", + "WM_GETTITLEBARINFOEX", + "UNKNOWN (832)", + "UNKNOWN (833)", + "UNKNOWN (834)", + "UNKNOWN (835)", + "UNKNOWN (836)", + "UNKNOWN (837)", + "UNKNOWN (838)", + "UNKNOWN (839)", + "UNKNOWN (840)", + "UNKNOWN (841)", + "UNKNOWN (842)", + "UNKNOWN (843)", + "UNKNOWN (844)", + "UNKNOWN (845)", + "UNKNOWN (846)", + "UNKNOWN (847)", + "UNKNOWN (848)", + "UNKNOWN (849)", + "UNKNOWN (850)", + "UNKNOWN (851)", + "UNKNOWN (852)", + "UNKNOWN (853)", + "UNKNOWN (854)", + "UNKNOWN (855)", + "WM_HANDHELDFIRST", + "UNKNOWN (857)", + "UNKNOWN (858)", + "UNKNOWN (859)", + "UNKNOWN (860)", + "UNKNOWN (861)", + "UNKNOWN (862)", + "WM_HANDHELDLAST", + "WM_AFXFIRST", + "UNKNOWN (865)", + "UNKNOWN (866)", + "UNKNOWN (867)", + "UNKNOWN (868)", + "UNKNOWN (869)", + "UNKNOWN (870)", + "UNKNOWN (871)", + "UNKNOWN (872)", + "UNKNOWN (873)", + "UNKNOWN (874)", + "UNKNOWN (875)", + "UNKNOWN (876)", + "UNKNOWN (877)", + "UNKNOWN (878)", + "UNKNOWN (879)", + "UNKNOWN (880)", + "UNKNOWN (881)", + "UNKNOWN (882)", + "UNKNOWN (883)", + "UNKNOWN (884)", + "UNKNOWN (885)", + "UNKNOWN (886)", + "UNKNOWN (887)", + "UNKNOWN (888)", + "UNKNOWN (889)", + "UNKNOWN (890)", + "UNKNOWN (891)", + "UNKNOWN (892)", + "UNKNOWN (893)", + "UNKNOWN (894)", + "WM_AFXLAST", + "WM_PENWINFIRST", + "UNKNOWN (897)", + "UNKNOWN (898)", + "UNKNOWN (899)", + "UNKNOWN (900)", + "UNKNOWN (901)", + "UNKNOWN (902)", + "UNKNOWN (903)", + "UNKNOWN (904)", + "UNKNOWN (905)", + "UNKNOWN (906)", + "UNKNOWN (907)", + "UNKNOWN (908)", + "UNKNOWN (909)", + "UNKNOWN (910)", + "WM_PENWINLAST", + "UNKNOWN (912)", + "UNKNOWN (913)", + "UNKNOWN (914)", + "UNKNOWN (915)", + "UNKNOWN (916)", + "UNKNOWN (917)", + "UNKNOWN (918)", + "UNKNOWN (919)", + "UNKNOWN (920)", + "UNKNOWN (921)", + "UNKNOWN (922)", + "UNKNOWN (923)", + "UNKNOWN (924)", + "UNKNOWN (925)", + "UNKNOWN (926)", + "UNKNOWN (927)", + "UNKNOWN (928)", + "UNKNOWN (929)", + "UNKNOWN (930)", + "UNKNOWN (931)", + "UNKNOWN (932)", + "UNKNOWN (933)", + "UNKNOWN (934)", + "UNKNOWN (935)", + "UNKNOWN (936)", + "UNKNOWN (937)", + "UNKNOWN (938)", + "UNKNOWN (939)", + "UNKNOWN (940)", + "UNKNOWN (941)", + "UNKNOWN (942)", + "UNKNOWN (943)", + "UNKNOWN (944)", + "UNKNOWN (945)", + "UNKNOWN (946)", + "UNKNOWN (947)", + "UNKNOWN (948)", + "UNKNOWN (949)", + "UNKNOWN (950)", + "UNKNOWN (951)", + "UNKNOWN (952)", + "UNKNOWN (953)", + "UNKNOWN (954)", + "UNKNOWN (955)", + "UNKNOWN (956)", + "UNKNOWN (957)", + "UNKNOWN (958)", + "UNKNOWN (959)", + "UNKNOWN (960)", + "UNKNOWN (961)", + "UNKNOWN (962)", + "UNKNOWN (963)", + "UNKNOWN (964)", + "UNKNOWN (965)", + "UNKNOWN (966)", + "UNKNOWN (967)", + "UNKNOWN (968)", + "UNKNOWN (969)", + "UNKNOWN (970)", + "UNKNOWN (971)", + "UNKNOWN (972)", + "UNKNOWN (973)", + "UNKNOWN (974)", + "UNKNOWN (975)", + "UNKNOWN (976)", + "UNKNOWN (977)", + "UNKNOWN (978)", + "UNKNOWN (979)", + "UNKNOWN (980)", + "UNKNOWN (981)", + "UNKNOWN (982)", + "UNKNOWN (983)", + "UNKNOWN (984)", + "UNKNOWN (985)", + "UNKNOWN (986)", + "UNKNOWN (987)", + "UNKNOWN (988)", + "UNKNOWN (989)", + "UNKNOWN (990)", + "UNKNOWN (991)", + "UNKNOWN (992)", + "UNKNOWN (993)", + "UNKNOWN (994)", + "UNKNOWN (995)", + "UNKNOWN (996)", + "UNKNOWN (997)", + "UNKNOWN (998)", + "UNKNOWN (999)", + "UNKNOWN (1000)", + "UNKNOWN (1001)", + "UNKNOWN (1002)", + "UNKNOWN (1003)", + "UNKNOWN (1004)", + "UNKNOWN (1005)", + "UNKNOWN (1006)", + "UNKNOWN (1007)", + "UNKNOWN (1008)", + "UNKNOWN (1009)", + "UNKNOWN (1010)", + "UNKNOWN (1011)", + "UNKNOWN (1012)", + "UNKNOWN (1013)", + "UNKNOWN (1014)", + "UNKNOWN (1015)", + "UNKNOWN (1016)", + "UNKNOWN (1017)", + "UNKNOWN (1018)", + "UNKNOWN (1019)", + "UNKNOWN (1020)", + "UNKNOWN (1021)", + "UNKNOWN (1022)", + "UNKNOWN (1023)", + "WM_USER" +}; diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.c new file mode 100644 index 0000000..5e33555 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.c @@ -0,0 +1,329 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include // For INT_MAX + +#include "SDL_x11video.h" +#include "SDL_x11clipboard.h" +#include "../SDL_clipboard_c.h" +#include "../../events/SDL_events_c.h" + +static const char *text_mime_types[] = { + "UTF8_STRING", + "text/plain;charset=utf-8", + "text/plain", + "TEXT", + "STRING" +}; + +// Get any application owned window handle for clipboard association +Window GetWindow(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + /* We create an unmapped window that exists just to manage the clipboard, + since X11 selection data is tied to a specific window and dies with it. + We create the window on demand, so apps that don't use the clipboard + don't have to keep an unnecessary resource around. */ + if (data->clipboard_window == None) { + Display *dpy = data->display; + Window parent = RootWindow(dpy, DefaultScreen(dpy)); + XSetWindowAttributes xattr; + data->clipboard_window = X11_XCreateWindow(dpy, parent, -10, -10, 1, 1, 0, + CopyFromParent, InputOnly, + CopyFromParent, 0, &xattr); + + X11_XSelectInput(dpy, data->clipboard_window, PropertyChangeMask); + X11_XFlush(data->display); + } + + return data->clipboard_window; +} + +static bool SetSelectionData(SDL_VideoDevice *_this, Atom selection, SDL_ClipboardDataCallback callback, + void *userdata, const char **mime_types, size_t mime_count, Uint32 sequence) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + Window window; + SDLX11_ClipboardData *clipboard; + bool clipboard_owner = false; + + window = GetWindow(_this); + if (window == None) { + return SDL_SetError("Couldn't find a window to own the selection"); + } + + if (selection == XA_PRIMARY) { + clipboard = &videodata->primary_selection; + } else { + clipboard = &videodata->clipboard; + } + + clipboard_owner = X11_XGetSelectionOwner(display, selection) == window; + + // If we are canceling our own data we need to clean it up + if (clipboard_owner && clipboard->sequence == 0) { + SDL_free(clipboard->userdata); + } + + clipboard->callback = callback; + clipboard->userdata = userdata; + clipboard->mime_types = mime_types; + clipboard->mime_count = mime_count; + clipboard->sequence = sequence; + + X11_XSetSelectionOwner(display, selection, window, CurrentTime); + return true; +} + +static void *CloneDataBuffer(const void *buffer, const size_t len) +{ + void *clone = NULL; + if (len > 0 && buffer) { + clone = SDL_malloc(len + sizeof(Uint32)); + if (clone) { + SDL_memcpy(clone, buffer, len); + SDL_memset((Uint8 *)clone + len, 0, sizeof(Uint32)); + } + } + return clone; +} + +/* + * original_buffer is considered unusable after the function is called. + */ +static void *AppendDataBuffer(void *original_buffer, const size_t old_len, const void *buffer, const size_t buffer_len) +{ + void *resized_buffer; + + if (buffer_len > 0 && buffer) { + resized_buffer = SDL_realloc(original_buffer, old_len + buffer_len + sizeof(Uint32)); + if (resized_buffer) { + SDL_memcpy((Uint8 *)resized_buffer + old_len, buffer, buffer_len); + SDL_memset((Uint8 *)resized_buffer + old_len + buffer_len, 0, sizeof(Uint32)); + } + + return resized_buffer; + } else { + return original_buffer; + } +} + +static bool WaitForSelection(SDL_VideoDevice *_this, Atom selection_type, bool *flag) +{ + Uint64 waitStart; + Uint64 waitElapsed; + + waitStart = SDL_GetTicks(); + *flag = true; + while (*flag) { + SDL_PumpEvents(); + waitElapsed = SDL_GetTicks() - waitStart; + // Wait one second for a selection response. + if (waitElapsed > 1000) { + *flag = false; + SDL_SetError("Selection timeout"); + /* We need to set the selection text so that next time we won't + timeout, otherwise we will hang on every call to this function. */ + SetSelectionData(_this, selection_type, SDL_ClipboardTextCallback, NULL, + text_mime_types, SDL_arraysize(text_mime_types), 0); + return false; + } + } + + return true; +} + +static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type, + const char *mime_type, size_t *length) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + Window window; + Window owner; + Atom selection; + Atom seln_type; + int seln_format; + unsigned long count; + unsigned long overflow; + + SDLX11_ClipboardData *clipboard; + void *data = NULL; + unsigned char *src = NULL; + bool incr_success = false; + Atom XA_MIME = X11_XInternAtom(display, mime_type, False); + + *length = 0; + + // Get the window that holds the selection + window = GetWindow(_this); + owner = X11_XGetSelectionOwner(display, selection_type); + if (owner == None) { + // This requires a fallback to ancient X10 cut-buffers. We will just skip those for now + data = NULL; + } else if (owner == window) { + owner = DefaultRootWindow(display); + if (selection_type == XA_PRIMARY) { + clipboard = &videodata->primary_selection; + } else { + clipboard = &videodata->clipboard; + } + + if (clipboard->callback) { + const void *clipboard_data = clipboard->callback(clipboard->userdata, mime_type, length); + data = CloneDataBuffer(clipboard_data, *length); + } + } else { + // Request that the selection owner copy the data to our window + owner = window; + selection = videodata->atoms.SDL_SELECTION; + X11_XConvertSelection(display, selection_type, XA_MIME, selection, owner, + CurrentTime); + + if (WaitForSelection(_this, selection_type, &videodata->selection_waiting) == false) { + data = NULL; + *length = 0; + } + + if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX / 4, False, + XA_MIME, &seln_type, &seln_format, &count, &overflow, &src) == Success) { + if (seln_type == XA_MIME) { + *length = (size_t)count; + data = CloneDataBuffer(src, count); + } else if (seln_type == videodata->atoms.INCR) { + while (1) { + // Only delete the property after being done with the previous "chunk". + X11_XDeleteProperty(display, owner, selection); + X11_XFlush(display); + + if (WaitForSelection(_this, selection_type, &videodata->selection_incr_waiting) == false) { + break; + } + + X11_XFree(src); + if (X11_XGetWindowProperty(display, owner, selection, 0, INT_MAX / 4, False, + XA_MIME, &seln_type, &seln_format, &count, &overflow, &src) != Success) { + break; + } + + if (count == 0) { + incr_success = true; + break; + } + + if (*length == 0) { + *length = (size_t)count; + data = CloneDataBuffer(src, count); + } else { + data = AppendDataBuffer(data, *length, src, count); + *length += (size_t)count; + } + + if (data == NULL) { + break; + } + } + + if (incr_success == false) { + SDL_free(data); + data = 0; + *length = 0; + } + } + X11_XFree(src); + } + } + return data; +} + +const char **X11_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types) +{ + *num_mime_types = SDL_arraysize(text_mime_types); + return text_mime_types; +} + +bool X11_SetClipboardData(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + return SetSelectionData(_this, videodata->atoms.CLIPBOARD, _this->clipboard_callback, _this->clipboard_userdata, (const char **)_this->clipboard_mime_types, _this->num_clipboard_mime_types, _this->clipboard_sequence); +} + +void *X11_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length) +{ + SDL_VideoData *videodata = _this->internal; + return GetSelectionData(_this, videodata->atoms.CLIPBOARD, mime_type, length); +} + +bool X11_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) +{ + size_t length; + void *data; + data = X11_GetClipboardData(_this, mime_type, &length); + if (data) { + SDL_free(data); + } + return length > 0; +} + +bool X11_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *text) +{ + return SetSelectionData(_this, XA_PRIMARY, SDL_ClipboardTextCallback, SDL_strdup(text), text_mime_types, SDL_arraysize(text_mime_types), 0); +} + +char *X11_GetPrimarySelectionText(SDL_VideoDevice *_this) +{ + size_t length; + char *text = GetSelectionData(_this, XA_PRIMARY, text_mime_types[0], &length); + if (!text) { + text = SDL_strdup(""); + } + return text; +} + +bool X11_HasPrimarySelectionText(SDL_VideoDevice *_this) +{ + bool result = false; + char *text = X11_GetPrimarySelectionText(_this); + if (text) { + if (text[0] != '\0') { + result = true; + } + SDL_free(text); + } + return result; +} + +void X11_QuitClipboard(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + if (data->primary_selection.sequence == 0) { + SDL_free(data->primary_selection.userdata); + } + if (data->clipboard.sequence == 0) { + SDL_free(data->clipboard.userdata); + } +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.h new file mode 100644 index 0000000..da5990a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11clipboard.h @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11clipboard_h_ +#define SDL_x11clipboard_h_ + +#include + +typedef struct X11_ClipboardData { + SDL_ClipboardDataCallback callback; + void *userdata; + const char **mime_types; + size_t mime_count; + Uint32 sequence; +} SDLX11_ClipboardData; + +extern const char **X11_GetTextMimeTypes(SDL_VideoDevice *_this, size_t *num_mime_types); +extern bool X11_SetClipboardData(SDL_VideoDevice *_this); +extern void *X11_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length); +extern bool X11_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type); +extern bool X11_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *text); +extern char *X11_GetPrimarySelectionText(SDL_VideoDevice *_this); +extern bool X11_HasPrimarySelectionText(SDL_VideoDevice *_this); +extern void X11_QuitClipboard(SDL_VideoDevice *_this); +Window GetWindow(SDL_VideoDevice *_this); + +#endif // SDL_x11clipboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.c new file mode 100644 index 0000000..7c48ed5 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.c @@ -0,0 +1,211 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#define DEBUG_DYNAMIC_X11 0 + +#include "SDL_x11dyn.h" + +#if DEBUG_DYNAMIC_X11 +#include +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC + +typedef struct +{ + SDL_SharedObject *lib; + const char *libname; +} x11dynlib; + +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT NULL +#endif +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR NULL +#endif +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 NULL +#endif +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES NULL +#endif +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR NULL +#endif +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS NULL +#endif + +static x11dynlib x11libs[] = { + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT2 }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR }, + { NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS } +}; + +static void *X11_GetSym(const char *fnname, int *pHasModule) +{ + int i; + void *fn = NULL; + for (i = 0; i < SDL_arraysize(x11libs); i++) { + if (x11libs[i].lib) { + fn = SDL_LoadFunction(x11libs[i].lib, fnname); + if (fn) { + break; + } + } + } + +#if DEBUG_DYNAMIC_X11 + if (fn) + printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, fn); + else + printf("X11: Symbol '%s' NOT FOUND!\n", fnname); +#endif + + if (!fn) { + *pHasModule = 0; // kill this module. + } + + return fn; +} + +#endif // SDL_VIDEO_DRIVER_X11_DYNAMIC + +// Define all the function pointers and wrappers... +#define SDL_X11_SYM(rc, fn, params, args, ret) SDL_DYNX11FN_##fn X11_##fn = NULL; +#include "SDL_x11sym.h" + +// Annoying varargs entry point... +#ifdef X_HAVE_UTF8_STRING +SDL_DYNX11FN_XCreateIC X11_XCreateIC = NULL; +SDL_DYNX11FN_XGetICValues X11_XGetICValues = NULL; +SDL_DYNX11FN_XSetICValues X11_XSetICValues = NULL; +SDL_DYNX11FN_XVaCreateNestedList X11_XVaCreateNestedList = NULL; +#endif + +/* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ +#define SDL_X11_MODULE(modname) int SDL_X11_HAVE_##modname = 0; +#include "SDL_x11sym.h" + +static int x11_load_refcount = 0; + +void SDL_X11_UnloadSymbols(void) +{ + // Don't actually unload if more than one module is using the libs... + if (x11_load_refcount > 0) { + if (--x11_load_refcount == 0) { +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC + int i; +#endif + + // set all the function pointers to NULL. +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0; +#define SDL_X11_SYM(rc, fn, params, args, ret) X11_##fn = NULL; +#include "SDL_x11sym.h" + +#ifdef X_HAVE_UTF8_STRING + X11_XCreateIC = NULL; + X11_XGetICValues = NULL; + X11_XSetICValues = NULL; + X11_XVaCreateNestedList = NULL; +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC + for (i = 0; i < SDL_arraysize(x11libs); i++) { + if (x11libs[i].lib) { + SDL_UnloadObject(x11libs[i].lib); + x11libs[i].lib = NULL; + } + } +#endif + } + } +} + +// returns non-zero if all needed symbols were loaded. +bool SDL_X11_LoadSymbols(void) +{ + bool result = true; // always succeed if not using Dynamic X11 stuff. + + // deal with multiple modules (dga, x11, etc) needing these symbols... + if (x11_load_refcount++ == 0) { +#ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC + int i; + int *thismod = NULL; + for (i = 0; i < SDL_arraysize(x11libs); i++) { + if (x11libs[i].libname) { + x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); + } + } + +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; // default yes +#include "SDL_x11sym.h" + +#define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; +#define SDL_X11_SYM(a, fn, x, y, z) X11_##fn = (SDL_DYNX11FN_##fn)X11_GetSym(#fn, thismod); +#include "SDL_x11sym.h" + +#ifdef X_HAVE_UTF8_STRING + X11_XCreateIC = (SDL_DYNX11FN_XCreateIC) + X11_GetSym("XCreateIC", &SDL_X11_HAVE_UTF8); + X11_XGetICValues = (SDL_DYNX11FN_XGetICValues) + X11_GetSym("XGetICValues", &SDL_X11_HAVE_UTF8); + X11_XSetICValues = (SDL_DYNX11FN_XSetICValues) + X11_GetSym("XSetICValues", &SDL_X11_HAVE_UTF8); + X11_XVaCreateNestedList = (SDL_DYNX11FN_XVaCreateNestedList) + X11_GetSym("XVaCreateNestedList", &SDL_X11_HAVE_UTF8); +#endif + + if (SDL_X11_HAVE_BASEXLIB) { + // all required symbols loaded. + SDL_ClearError(); + } else { + // in case something got loaded... + SDL_X11_UnloadSymbols(); + result = false; + } + +#else // no dynamic X11 + +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; // default yes +#define SDL_X11_SYM(a, fn, x, y, z) X11_##fn = (SDL_DYNX11FN_##fn)fn; +#include "SDL_x11sym.h" + +#ifdef X_HAVE_UTF8_STRING + X11_XCreateIC = XCreateIC; + X11_XGetICValues = XGetICValues; + X11_XSetICValues = XSetICValues; + X11_XVaCreateNestedList = XVaCreateNestedList; +#endif +#endif + } + + return result; +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.h new file mode 100644 index 0000000..e9831fc --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11dyn.h @@ -0,0 +1,113 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11dyn_h_ +#define SDL_x11dyn_h_ + +#include +#include +#include +#include + +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM +#include +#endif + +// Apparently some X11 systems can't include this multiple times... +#ifndef SDL_INCLUDED_XLIBINT_H +#define SDL_INCLUDED_XLIBINT_H 1 +#include +#endif + +#include +#include + +#ifndef NO_SHARED_MEMORY +#include +#include +#include +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR +#include +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XDBE +#include +#endif +#if defined(SDL_VIDEO_DRIVER_X11_XINPUT2) || defined(SDL_VIDEO_DRIVER_X11_XFIXES) +#include +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES +#include +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC +#include +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR +#include +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#include +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +// evil function signatures... +typedef Bool (*SDL_X11_XESetWireToEventRetType)(Display *, XEvent *, xEvent *); +typedef int (*SDL_X11_XSynchronizeRetType)(Display *); +typedef Status (*SDL_X11_XESetEventToWireRetType)(Display *, XEvent *, xEvent *); + +extern bool SDL_X11_LoadSymbols(void); +extern void SDL_X11_UnloadSymbols(void); + +// Declare all the function pointers and wrappers... +#define SDL_X11_SYM(rc, fn, params, args, ret) \ + typedef rc(*SDL_DYNX11FN_##fn) params; \ + extern SDL_DYNX11FN_##fn X11_##fn; +#include "SDL_x11sym.h" + +// Annoying varargs entry point... +#ifdef X_HAVE_UTF8_STRING +typedef XIC (*SDL_DYNX11FN_XCreateIC)(XIM, ...); +typedef char *(*SDL_DYNX11FN_XGetICValues)(XIC, ...); +typedef char *(*SDL_DYNX11FN_XSetICValues)(XIC, ...); +typedef XVaNestedList (*SDL_DYNX11FN_XVaCreateNestedList)(int, ...); +extern SDL_DYNX11FN_XCreateIC X11_XCreateIC; +extern SDL_DYNX11FN_XGetICValues X11_XGetICValues; +extern SDL_DYNX11FN_XSetICValues X11_XSetICValues; +extern SDL_DYNX11FN_XVaCreateNestedList X11_XVaCreateNestedList; +#endif + +/* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ +#define SDL_X11_MODULE(modname) extern int SDL_X11_HAVE_##modname; +#include "SDL_x11sym.h" + +#ifdef __cplusplus +} +#endif + +#endif // !defined SDL_x11dyn_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11events.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11events.c new file mode 100644 index 0000000..02c2d90 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11events.c @@ -0,0 +1,2205 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include +#include +#include +#include +#include // For INT_MAX + +#include "SDL_x11video.h" +#include "SDL_x11pen.h" +#include "SDL_x11touch.h" +#include "SDL_x11xinput2.h" +#include "SDL_x11xfixes.h" +#include "SDL_x11settings.h" +#include "../SDL_clipboard_c.h" +#include "SDL_x11xsync.h" +#include "../../core/unix/SDL_poll.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" +#include "../../core/linux/SDL_system_theme.h" +#include "../SDL_sysvideo.h" + +#include + +#if 0 +#define DEBUG_XEVENTS +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_TOPLEFT +#define _NET_WM_MOVERESIZE_SIZE_TOPLEFT 0 +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_TOP +#define _NET_WM_MOVERESIZE_SIZE_TOP 1 +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_TOPRIGHT +#define _NET_WM_MOVERESIZE_SIZE_TOPRIGHT 2 +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_RIGHT +#define _NET_WM_MOVERESIZE_SIZE_RIGHT 3 +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT +#define _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT 4 +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOM +#define _NET_WM_MOVERESIZE_SIZE_BOTTOM 5 +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT +#define _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT 6 +#endif + +#ifndef _NET_WM_MOVERESIZE_SIZE_LEFT +#define _NET_WM_MOVERESIZE_SIZE_LEFT 7 +#endif + +#ifndef _NET_WM_MOVERESIZE_MOVE +#define _NET_WM_MOVERESIZE_MOVE 8 +#endif + +typedef struct +{ + unsigned char *data; + int format, count; + Atom type; +} SDL_x11Prop; + +/* Reads property + Must call X11_XFree on results + */ +static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) +{ + unsigned char *ret = NULL; + Atom type; + int fmt; + unsigned long count; + unsigned long bytes_left; + int bytes_fetch = 0; + + do { + if (ret) { + X11_XFree(ret); + } + X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); + bytes_fetch += bytes_left; + } while (bytes_left != 0); + + p->data = ret; + p->format = fmt; + p->count = count; + p->type = type; +} + +/* Find text-uri-list in a list of targets and return it's atom + if available, else return None */ +static Atom X11_PickTarget(Display *disp, Atom list[], int list_count) +{ + Atom request = None; + char *name; + int i; + for (i = 0; i < list_count && request == None; i++) { + name = X11_XGetAtomName(disp, list[i]); + // Preferred MIME targets + if ((SDL_strcmp("text/uri-list", name) == 0) || + (SDL_strcmp("text/plain;charset=utf-8", name) == 0) || + (SDL_strcmp("UTF8_STRING", name) == 0)) { + request = list[i]; + } + // Fallback MIME targets + if ((SDL_strcmp("text/plain", name) == 0) || + (SDL_strcmp("TEXT", name) == 0)) { + if (request == None) { + request = list[i]; + } + } + X11_XFree(name); + } + return request; +} + +/* Wrapper for X11_PickTarget for a maximum of three targets, a special + case in the Xdnd protocol */ +static Atom X11_PickTargetFromAtoms(Display *disp, Atom a0, Atom a1, Atom a2) +{ + int count = 0; + Atom atom[3]; + if (a0 != None) { + atom[count++] = a0; + } + if (a1 != None) { + atom[count++] = a1; + } + if (a2 != None) { + atom[count++] = a2; + } + return X11_PickTarget(disp, atom, count); +} + +struct KeyRepeatCheckData +{ + XEvent *event; + bool found; +}; + +static Bool X11_KeyRepeatCheckIfEvent(Display *display, XEvent *chkev, + XPointer arg) +{ + struct KeyRepeatCheckData *d = (struct KeyRepeatCheckData *)arg; + if (chkev->type == KeyPress && chkev->xkey.keycode == d->event->xkey.keycode && chkev->xkey.time - d->event->xkey.time < 2) { + d->found = true; + } + return False; +} + +/* Check to see if this is a repeated key. + (idea shamelessly lifted from GII -- thanks guys! :) + */ +static bool X11_KeyRepeat(Display *display, XEvent *event) +{ + XEvent dummyev; + struct KeyRepeatCheckData d; + d.event = event; + d.found = false; + if (X11_XPending(display)) { + X11_XCheckIfEvent(display, &dummyev, X11_KeyRepeatCheckIfEvent, (XPointer)&d); + } + return d.found; +} + +static bool X11_IsWheelEvent(Display *display, int button, int *xticks, int *yticks) +{ + /* according to the xlib docs, no specific mouse wheel events exist. + However, the defacto standard is that the vertical wheel is X buttons + 4 (up) and 5 (down) and a horizontal wheel is 6 (left) and 7 (right). */ + + // Xlib defines "Button1" through 5, so we just use literals here. + switch (button) { + case 4: + *yticks = 1; + return true; + case 5: + *yticks = -1; + return true; + case 6: + *xticks = 1; + return true; + case 7: + *xticks = -1; + return true; + default: + break; + } + return false; +} + +// An X11 event hook +static SDL_X11EventHook g_X11EventHook = NULL; +static void *g_X11EventHookData = NULL; + +void SDL_SetX11EventHook(SDL_X11EventHook callback, void *userdata) +{ + g_X11EventHook = callback; + g_X11EventHookData = userdata; +} + +#ifdef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +static void X11_HandleGenericEvent(SDL_VideoDevice *_this, XEvent *xev) +{ + SDL_VideoData *videodata = _this->internal; + + // event is a union, so cookie == &event, but this is type safe. + XGenericEventCookie *cookie = &xev->xcookie; + if (X11_XGetEventData(videodata->display, cookie)) { + if (!g_X11EventHook || g_X11EventHook(g_X11EventHookData, xev)) { + X11_HandleXinput2Event(_this, cookie); + } + X11_XFreeEventData(videodata->display, cookie); + } +} +#endif // SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS + +static void X11_UpdateSystemKeyModifiers(SDL_VideoData *viddata) +{ + Window junk_window; + int x, y; + + X11_XQueryPointer(viddata->display, DefaultRootWindow(viddata->display), &junk_window, &junk_window, &x, &y, &x, &y, &viddata->xkb.xkb_modifiers); +} + +static void X11_ReconcileModifiers(SDL_VideoData *viddata) +{ + const Uint32 xk_modifiers = viddata->xkb.xkb_modifiers; + + /* If a modifier was activated by a keypress, it will be tied to the + * specific left/right key that initiated it. Otherwise, the ambiguous + * left/right combo is used. + */ + if (xk_modifiers & ShiftMask) { + if (!(viddata->xkb.sdl_modifiers & SDL_KMOD_SHIFT)) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_SHIFT; + } + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_SHIFT; + } + + if (xk_modifiers & ControlMask) { + if (!(viddata->xkb.sdl_modifiers & SDL_KMOD_CTRL)) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_CTRL; + } + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_CTRL; + } + + // Mod1 is used for the Alt keys + if (xk_modifiers & Mod1Mask) { + if (!(viddata->xkb.sdl_modifiers & SDL_KMOD_ALT)) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_ALT; + } + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_ALT; + } + + // Mod4 is used for the Super (aka GUI/Logo) keys. + if (xk_modifiers & Mod4Mask) { + if (!(viddata->xkb.sdl_modifiers & SDL_KMOD_GUI)) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_GUI; + } + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_GUI; + } + + // Mod3 is typically Level 5 shift. + if (xk_modifiers & Mod3Mask) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_LEVEL5; + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_LEVEL5; + } + + // Mod5 is typically Level 3 shift (aka AltGr). + if (xk_modifiers & Mod5Mask) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_MODE; + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_MODE; + } + + if (xk_modifiers & LockMask) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_CAPS; + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_CAPS; + } + + if (xk_modifiers & viddata->xkb.numlock_mask) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_NUM; + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_NUM; + } + + if (xk_modifiers & viddata->xkb.scrolllock_mask) { + viddata->xkb.sdl_modifiers |= SDL_KMOD_SCROLL; + } else { + viddata->xkb.sdl_modifiers &= ~SDL_KMOD_SCROLL; + } + + SDL_SetModState(viddata->xkb.sdl_modifiers); +} + +static void X11_HandleModifierKeys(SDL_VideoData *viddata, SDL_Scancode scancode, bool pressed, bool allow_reconciliation) +{ + const SDL_Keycode keycode = SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false); + SDL_Keymod mod = SDL_KMOD_NONE; + bool reconcile = false; + + /* SDL clients expect modifier state to be activated at the same time as the + * source keypress, so we set pressed modifier state with the usual modifier + * keys here, as the explicit modifier event won't arrive until after the + * keypress event. If this is wrong, it will be corrected when the explicit + * modifier state is checked. + */ + switch (keycode) { + case SDLK_LSHIFT: + mod = SDL_KMOD_LSHIFT; + break; + case SDLK_RSHIFT: + mod = SDL_KMOD_RSHIFT; + break; + case SDLK_LCTRL: + mod = SDL_KMOD_LCTRL; + break; + case SDLK_RCTRL: + mod = SDL_KMOD_RCTRL; + break; + case SDLK_LALT: + mod = SDL_KMOD_LALT; + break; + case SDLK_RALT: + mod = SDL_KMOD_RALT; + break; + case SDLK_LGUI: + mod = SDL_KMOD_LGUI; + break; + case SDLK_RGUI: + mod = SDL_KMOD_RGUI; + break; + case SDLK_MODE: + mod = SDL_KMOD_MODE; + break; + case SDLK_LEVEL5_SHIFT: + mod = SDL_KMOD_LEVEL5; + break; + case SDLK_CAPSLOCK: + case SDLK_NUMLOCKCLEAR: + case SDLK_SCROLLLOCK: + { + /* For locking modifier keys, query the lock state directly, or we may have to wait until the next + * key press event to know if a lock was actually activated from the key event. + */ + unsigned int cur_mask = viddata->xkb.xkb_modifiers; + X11_UpdateSystemKeyModifiers(viddata); + + if (viddata->xkb.xkb_modifiers & LockMask) { + cur_mask |= LockMask; + } else { + cur_mask &= ~LockMask; + } + if (viddata->xkb.xkb_modifiers & viddata->xkb.numlock_mask) { + cur_mask |= viddata->xkb.numlock_mask; + } else { + cur_mask &= ~viddata->xkb.numlock_mask; + } + if (viddata->xkb.xkb_modifiers & viddata->xkb.scrolllock_mask) { + cur_mask |= viddata->xkb.scrolllock_mask; + } else { + cur_mask &= ~viddata->xkb.scrolllock_mask; + } + + viddata->xkb.xkb_modifiers = cur_mask; + } SDL_FALLTHROUGH; + default: + reconcile = true; + break; + } + + if (pressed) { + viddata->xkb.sdl_modifiers |= mod; + } else { + viddata->xkb.sdl_modifiers &= ~mod; + } + + if (allow_reconciliation) { + if (reconcile) { + X11_ReconcileModifiers(viddata); + } else { + SDL_SetModState(viddata->xkb.sdl_modifiers); + } + } +} + +void X11_ReconcileKeyboardState(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + char keys[32]; + int keycode; + const bool *keyboardState; + + X11_XQueryKeymap(display, keys); + + keyboardState = SDL_GetKeyboardState(0); + for (keycode = 0; keycode < SDL_arraysize(videodata->key_layout); ++keycode) { + SDL_Scancode scancode = videodata->key_layout[keycode]; + bool x11KeyPressed = (keys[keycode / 8] & (1 << (keycode % 8))) != 0; + bool sdlKeyPressed = keyboardState[scancode]; + + if (x11KeyPressed && !sdlKeyPressed) { + // Only update modifier state for keys that are pressed in another application + switch (SDL_GetKeyFromScancode(scancode, SDL_KMOD_NONE, false)) { + case SDLK_LCTRL: + case SDLK_RCTRL: + case SDLK_LSHIFT: + case SDLK_RSHIFT: + case SDLK_LALT: + case SDLK_RALT: + case SDLK_LGUI: + case SDLK_RGUI: + case SDLK_MODE: + case SDLK_LEVEL5_SHIFT: + X11_HandleModifierKeys(videodata, scancode, true, false); + SDL_SendKeyboardKeyIgnoreModifiers(0, SDL_GLOBAL_KEYBOARD_ID, keycode, scancode, true); + break; + default: + break; + } + } else if (!x11KeyPressed && sdlKeyPressed) { + X11_HandleModifierKeys(videodata, scancode, false, false); + SDL_SendKeyboardKeyIgnoreModifiers(0, SDL_GLOBAL_KEYBOARD_ID, keycode, scancode, false); + } + } + + X11_UpdateSystemKeyModifiers(videodata); + X11_ReconcileModifiers(videodata); +} + +static void X11_DispatchFocusIn(SDL_VideoDevice *_this, SDL_WindowData *data) +{ +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: Dispatching FocusIn", data->xwindow); +#endif + SDL_SetKeyboardFocus(data->window); + X11_ReconcileKeyboardState(_this); +#ifdef X_HAVE_UTF8_STRING + if (data->ic) { + X11_XSetICFocus(data->ic); + } +#endif + if (data->flashing_window) { + X11_FlashWindow(_this, data->window, SDL_FLASH_CANCEL); + } +} + +static void X11_DispatchFocusOut(SDL_VideoDevice *_this, SDL_WindowData *data) +{ +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: Dispatching FocusOut", data->xwindow); +#endif + /* If another window has already processed a focus in, then don't try to + * remove focus here. Doing so will incorrectly remove focus from that + * window, and the focus lost event for this window will have already + * been dispatched anyway. */ + if (data->window == SDL_GetKeyboardFocus()) { + SDL_SetKeyboardFocus(NULL); + } +#ifdef X_HAVE_UTF8_STRING + if (data->ic) { + X11_XUnsetICFocus(data->ic); + } +#endif +} + +static void X11_DispatchMapNotify(SDL_WindowData *data) +{ + SDL_Window *window = data->window; + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_SHOWN, 0, 0); + if (!(window->flags & SDL_WINDOW_HIDDEN) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { + SDL_UpdateWindowGrab(window); + } +} + +static void X11_DispatchUnmapNotify(SDL_WindowData *data) +{ + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_HIDDEN, 0, 0); + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); +} + +static void DispatchWindowMove(SDL_VideoDevice *_this, const SDL_WindowData *data, const SDL_Point *point) +{ + SDL_VideoData *videodata = _this->internal; + SDL_Window *window = data->window; + Display *display = videodata->display; + XEvent evt; + + // !!! FIXME: we need to regrab this if necessary when the drag is done. + X11_XUngrabPointer(display, 0L); + X11_XFlush(display); + + evt.xclient.type = ClientMessage; + evt.xclient.window = data->xwindow; + evt.xclient.message_type = videodata->atoms._NET_WM_MOVERESIZE; + evt.xclient.format = 32; + evt.xclient.data.l[0] = (size_t)window->x + point->x; + evt.xclient.data.l[1] = (size_t)window->y + point->y; + evt.xclient.data.l[2] = _NET_WM_MOVERESIZE_MOVE; + evt.xclient.data.l[3] = Button1; + evt.xclient.data.l[4] = 0; + X11_XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &evt); + + X11_XSync(display, 0); +} + +static void ScheduleWindowMove(SDL_VideoDevice *_this, SDL_WindowData *data, const SDL_Point *point) +{ + data->pending_move = true; + data->pending_move_point = *point; +} + +static void InitiateWindowResize(SDL_VideoDevice *_this, const SDL_WindowData *data, const SDL_Point *point, int direction) +{ + SDL_VideoData *videodata = _this->internal; + SDL_Window *window = data->window; + Display *display = videodata->display; + XEvent evt; + + if (direction < _NET_WM_MOVERESIZE_SIZE_TOPLEFT || direction > _NET_WM_MOVERESIZE_SIZE_LEFT) { + return; + } + + // !!! FIXME: we need to regrab this if necessary when the drag is done. + X11_XUngrabPointer(display, 0L); + X11_XFlush(display); + + evt.xclient.type = ClientMessage; + evt.xclient.window = data->xwindow; + evt.xclient.message_type = videodata->atoms._NET_WM_MOVERESIZE; + evt.xclient.format = 32; + evt.xclient.data.l[0] = (size_t)window->x + point->x; + evt.xclient.data.l[1] = (size_t)window->y + point->y; + evt.xclient.data.l[2] = direction; + evt.xclient.data.l[3] = Button1; + evt.xclient.data.l[4] = 0; + X11_XSendEvent(display, DefaultRootWindow(display), False, SubstructureRedirectMask | SubstructureNotifyMask, &evt); + + X11_XSync(display, 0); +} + +bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y, bool force_new_result) +{ + SDL_Window *window = data->window; + if (!window->hit_test) return false; + const SDL_Point point = { (int)x, (int)y }; + SDL_HitTestResult rc = window->hit_test(window, &point, window->hit_test_data); + if (!force_new_result && rc == data->hit_test_result) { + return true; + } + X11_SetHitTestCursor(rc); + data->hit_test_result = rc; + return true; +} + +bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y) +{ + SDL_Window *window = data->window; + + if (window->hit_test) { + const SDL_Point point = { (int)x, (int)y }; + static const int directions[] = { + _NET_WM_MOVERESIZE_SIZE_TOPLEFT, _NET_WM_MOVERESIZE_SIZE_TOP, + _NET_WM_MOVERESIZE_SIZE_TOPRIGHT, _NET_WM_MOVERESIZE_SIZE_RIGHT, + _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT, _NET_WM_MOVERESIZE_SIZE_BOTTOM, + _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT, _NET_WM_MOVERESIZE_SIZE_LEFT + }; + + switch (data->hit_test_result) { + case SDL_HITTEST_DRAGGABLE: + /* Some window managers get in a bad state when a move event starts while input is transitioning + to the SDL window. This can happen when clicking on a drag region of an unfocused window + where the same mouse down event will trigger a drag event and a window activate. */ + if (data->window->flags & SDL_WINDOW_INPUT_FOCUS) { + DispatchWindowMove(_this, data, &point); + } else { + ScheduleWindowMove(_this, data, &point); + } + return true; + + case SDL_HITTEST_RESIZE_TOPLEFT: + case SDL_HITTEST_RESIZE_TOP: + case SDL_HITTEST_RESIZE_TOPRIGHT: + case SDL_HITTEST_RESIZE_RIGHT: + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: + case SDL_HITTEST_RESIZE_BOTTOM: + case SDL_HITTEST_RESIZE_BOTTOMLEFT: + case SDL_HITTEST_RESIZE_LEFT: + InitiateWindowResize(_this, data, &point, directions[data->hit_test_result - SDL_HITTEST_RESIZE_TOPLEFT]); + return true; + + default: + return false; + } + } + + return false; +} + +static void X11_UpdateUserTime(SDL_WindowData *data, const unsigned long latest) +{ + if (latest && (latest != data->user_time)) { + SDL_VideoData *videodata = data->videodata; + Display *display = videodata->display; + X11_XChangeProperty(display, data->xwindow, videodata->atoms._NET_WM_USER_TIME, + XA_CARDINAL, 32, PropModeReplace, + (const unsigned char *)&latest, 1); +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: updating _NET_WM_USER_TIME to %lu", data->xwindow, latest); +#endif + data->user_time = latest; + } +} + +static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xevent) +{ + int i; + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + + SDL_assert(videodata->clipboard_window != None); + SDL_assert(xevent->xany.window == videodata->clipboard_window); + + switch (xevent->type) { + // Copy the selection from our own CUTBUFFER to the requested property + case SelectionRequest: + { + const XSelectionRequestEvent *req = &xevent->xselectionrequest; + XEvent sevent; + int mime_formats; + unsigned char *seln_data; + size_t seln_length = 0; + Atom XA_TARGETS = videodata->atoms.TARGETS; + SDLX11_ClipboardData *clipboard; + +#ifdef DEBUG_XEVENTS + char *atom_name; + atom_name = X11_XGetAtomName(display, req->target); + SDL_Log("window CLIPBOARD: SelectionRequest (requestor = 0x%lx, target = 0x%lx, mime_type = %s)", + req->requestor, req->target, atom_name); + if (atom_name) { + X11_XFree(atom_name); + } +#endif + + if (req->selection == XA_PRIMARY) { + clipboard = &videodata->primary_selection; + } else { + clipboard = &videodata->clipboard; + } + + SDL_zero(sevent); + sevent.xany.type = SelectionNotify; + sevent.xselection.selection = req->selection; + sevent.xselection.target = None; + sevent.xselection.property = None; // tell them no by default + sevent.xselection.requestor = req->requestor; + sevent.xselection.time = req->time; + + /* !!! FIXME: We were probably storing this on the root window + because an SDL window might go away...? but we don't have to do + this now (or ever, really). */ + + if (req->target == XA_TARGETS) { + Atom *supportedFormats; + supportedFormats = SDL_malloc((clipboard->mime_count + 1) * sizeof(Atom)); + supportedFormats[0] = XA_TARGETS; + mime_formats = 1; + for (i = 0; i < clipboard->mime_count; ++i) { + supportedFormats[mime_formats++] = X11_XInternAtom(display, clipboard->mime_types[i], False); + } + X11_XChangeProperty(display, req->requestor, req->property, + XA_ATOM, 32, PropModeReplace, + (unsigned char *)supportedFormats, + mime_formats); + sevent.xselection.property = req->property; + sevent.xselection.target = XA_TARGETS; + SDL_free(supportedFormats); + } else { + if (clipboard->callback) { + for (i = 0; i < clipboard->mime_count; ++i) { + const char *mime_type = clipboard->mime_types[i]; + if (X11_XInternAtom(display, mime_type, False) != req->target) { + continue; + } + + // FIXME: We don't support the X11 INCR protocol for large clipboards. Do we want that? - Yes, yes we do. + // This is a safe cast, XChangeProperty() doesn't take a const value, but it doesn't modify the data + seln_data = (unsigned char *)clipboard->callback(clipboard->userdata, mime_type, &seln_length); + if (seln_data) { + X11_XChangeProperty(display, req->requestor, req->property, + req->target, 8, PropModeReplace, + seln_data, seln_length); + sevent.xselection.property = req->property; + sevent.xselection.target = req->target; + } + break; + } + } + } + X11_XSendEvent(display, req->requestor, False, 0, &sevent); + X11_XSync(display, False); + } break; + + case SelectionNotify: + { + const XSelectionEvent *xsel = &xevent->xselection; +#ifdef DEBUG_XEVENTS + const char *propName = xsel->property ? X11_XGetAtomName(display, xsel->property) : "None"; + const char *targetName = xsel->target ? X11_XGetAtomName(display, xsel->target) : "None"; + + SDL_Log("window CLIPBOARD: SelectionNotify (requestor = 0x%lx, target = %s, property = %s)", + xsel->requestor, targetName, propName); +#endif + if (xsel->target == videodata->atoms.TARGETS && xsel->property == videodata->atoms.SDL_FORMATS) { + /* the new mime formats are the SDL_FORMATS property as an array of Atoms */ + Atom atom = None; + Atom *patom; + unsigned char* data = NULL; + int format_property = 0; + unsigned long length = 0; + unsigned long bytes_left = 0; + int j; + + X11_XGetWindowProperty(display, GetWindow(_this), videodata->atoms.SDL_FORMATS, 0, 200, + 0, XA_ATOM, &atom, &format_property, &length, &bytes_left, &data); + + int allocationsize = (length + 1) * sizeof(char*); + for (j = 0, patom = (Atom*)data; j < length; j++, patom++) { + char *atomStr = X11_XGetAtomName(display, *patom); + allocationsize += SDL_strlen(atomStr) + 1; + X11_XFree(atomStr); + } + + char **new_mime_types = SDL_AllocateTemporaryMemory(allocationsize); + if (new_mime_types) { + char *strPtr = (char *)(new_mime_types + length + 1); + + for (j = 0, patom = (Atom*)data; j < length; j++, patom++) { + char *atomStr = X11_XGetAtomName(display, *patom); + new_mime_types[j] = strPtr; + strPtr = stpcpy(strPtr, atomStr) + 1; + X11_XFree(atomStr); + } + new_mime_types[length] = NULL; + + SDL_SendClipboardUpdate(false, new_mime_types, length); + } + + if (data) { + X11_XFree(data); + } + } + + videodata->selection_waiting = false; + } break; + + case SelectionClear: + { + Atom XA_CLIPBOARD = videodata->atoms.CLIPBOARD; + SDLX11_ClipboardData *clipboard = NULL; + +#ifdef DEBUG_XEVENTS + SDL_Log("window CLIPBOARD: SelectionClear (requestor = 0x%lx, target = 0x%lx)", + xevent->xselection.requestor, xevent->xselection.target); +#endif + + if (xevent->xselectionclear.selection == XA_PRIMARY) { + clipboard = &videodata->primary_selection; + } else if (XA_CLIPBOARD != None && xevent->xselectionclear.selection == XA_CLIPBOARD) { + clipboard = &videodata->clipboard; + } + if (clipboard && clipboard->callback) { + if (clipboard->sequence) { + SDL_CancelClipboardData(clipboard->sequence); + } else { + SDL_free(clipboard->userdata); + } + SDL_zerop(clipboard); + } + } break; + + case PropertyNotify: + { + char *name_of_atom = X11_XGetAtomName(display, xevent->xproperty.atom); + + if (SDL_strncmp(name_of_atom, "SDL_SELECTION", sizeof("SDL_SELECTION") - 1) == 0 && xevent->xproperty.state == PropertyNewValue) { + videodata->selection_incr_waiting = false; + } + + if (name_of_atom) { + X11_XFree(name_of_atom); + } + } break; + } +} + +static void X11_HandleSettingsEvent(SDL_VideoDevice *_this, const XEvent *xevent) +{ + SDL_VideoData *videodata = _this->internal; + + SDL_assert(videodata->xsettings_window != None); + SDL_assert(xevent->xany.window == videodata->xsettings_window); + + X11_HandleXsettings(_this, xevent); +} + +static Bool isMapNotify(Display *display, XEvent *ev, XPointer arg) +{ + XUnmapEvent *unmap; + + unmap = (XUnmapEvent *)arg; + + return ev->type == MapNotify && + ev->xmap.window == unmap->window && + ev->xmap.serial == unmap->serial; +} + +static Bool isReparentNotify(Display *display, XEvent *ev, XPointer arg) +{ + XUnmapEvent *unmap; + + unmap = (XUnmapEvent *)arg; + + return ev->type == ReparentNotify && + ev->xreparent.window == unmap->window && + ev->xreparent.serial == unmap->serial; +} + +static bool IsHighLatin1(const char *string, int length) +{ + while (length-- > 0) { + Uint8 ch = (Uint8)*string; + if (ch >= 0x80) { + return true; + } + ++string; + } + return false; +} + +static int XLookupStringAsUTF8(XKeyEvent *event_struct, char *buffer_return, int bytes_buffer, KeySym *keysym_return, XComposeStatus *status_in_out) +{ + int result = X11_XLookupString(event_struct, buffer_return, bytes_buffer, keysym_return, status_in_out); + if (IsHighLatin1(buffer_return, result)) { + char *utf8_text = SDL_iconv_string("UTF-8", "ISO-8859-1", buffer_return, result + 1); + if (utf8_text) { + SDL_strlcpy(buffer_return, utf8_text, bytes_buffer); + SDL_free(utf8_text); + return SDL_strlen(buffer_return); + } else { + return 0; + } + } + return result; +} + +SDL_WindowData *X11_FindWindow(SDL_VideoDevice *_this, Window window) +{ + const SDL_VideoData *videodata = _this->internal; + int i; + + if (videodata && videodata->windowlist) { + for (i = 0; i < videodata->numwindows; ++i) { + if ((videodata->windowlist[i] != NULL) && + (videodata->windowlist[i]->xwindow == window)) { + return videodata->windowlist[i]; + } + } + } + return NULL; +} + +Uint64 X11_GetEventTimestamp(unsigned long time) +{ + // FIXME: Get the event time in the SDL tick time base + return SDL_GetTicksNS(); +} + +void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_KeyboardID keyboardID, XEvent *xevent) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + KeyCode keycode = xevent->xkey.keycode; + KeySym keysym = NoSymbol; + int text_length = 0; + char text[64]; + Status status = 0; + bool handled_by_ime = false; + bool pressed = (xevent->type == KeyPress); + SDL_Scancode scancode = videodata->key_layout[keycode]; + Uint64 timestamp = X11_GetEventTimestamp(xevent->xkey.time); + +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx %s (X11 keycode = 0x%X)", xevent->xany.window, (xevent->type == KeyPress ? "KeyPress" : "KeyRelease"), xevent->xkey.keycode); +#endif +#ifdef DEBUG_SCANCODES + if (scancode == SDL_SCANCODE_UNKNOWN && keycode) { + int min_keycode, max_keycode; + X11_XDisplayKeycodes(display, &min_keycode, &max_keycode); + keysym = X11_KeyCodeToSym(_this, keycode, xevent->xkey.state >> 13); + SDL_Log("The key you just pressed is not recognized by SDL. To help get this fixed, please report this to the SDL forums/mailing list X11 KeyCode %d (%d), X11 KeySym 0x%lX (%s).", + keycode, keycode - min_keycode, keysym, + X11_XKeysymToString(keysym)); + } +#endif // DEBUG SCANCODES + + text[0] = '\0'; + videodata->xkb.xkb_modifiers = xevent->xkey.state; + + if (SDL_TextInputActive(windowdata->window)) { + // filter events catches XIM events and sends them to the correct handler + if (X11_XFilterEvent(xevent, None)) { +#ifdef DEBUG_XEVENTS + SDL_Log("Filtered event type = %d display = %p window = 0x%lx", + xevent->type, xevent->xany.display, xevent->xany.window); +#endif + handled_by_ime = true; + } + + if (!handled_by_ime) { +#ifdef X_HAVE_UTF8_STRING + if (windowdata->ic && xevent->type == KeyPress) { + text_length = X11_Xutf8LookupString(windowdata->ic, &xevent->xkey, text, sizeof(text) - 1, + &keysym, &status); + } else { + text_length = XLookupStringAsUTF8(&xevent->xkey, text, sizeof(text) - 1, &keysym, NULL); + } +#else + text_length = XLookupStringAsUTF8(&xevent->xkey, text, sizeof(text) - 1, &keysym, NULL); +#endif + } + } + + if (!handled_by_ime) { + if (pressed) { + X11_HandleModifierKeys(videodata, scancode, true, true); + SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, true); + + if (*text) { + text[text_length] = '\0'; + X11_ClearComposition(windowdata); + SDL_SendKeyboardText(text); + } + } else { + if (X11_KeyRepeat(display, xevent)) { + // We're about to get a repeated key down, ignore the key up + return; + } + + X11_HandleModifierKeys(videodata, scancode, false, true); + SDL_SendKeyboardKeyIgnoreModifiers(timestamp, keyboardID, keycode, scancode, false); + } + } + + if (pressed) { + X11_UpdateUserTime(windowdata, xevent->xkey.time); + } +} + +void X11_HandleButtonPress(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_MouseID mouseID, int button, float x, float y, unsigned long time) +{ + SDL_Window *window = windowdata->window; + const SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + int xticks = 0, yticks = 0; + Uint64 timestamp = X11_GetEventTimestamp(time); + +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: ButtonPress (X11 button = %d)", windowdata->xwindow, button); +#endif + + SDL_Mouse *mouse = SDL_GetMouse(); + if (!mouse->relative_mode && (x != mouse->x || y != mouse->y)) { + X11_ProcessHitTest(_this, windowdata, x, y, false); + SDL_SendMouseMotion(timestamp, window, mouseID, false, x, y); + } + + if (X11_IsWheelEvent(display, button, &xticks, &yticks)) { + SDL_SendMouseWheel(timestamp, window, mouseID, (float)-xticks, (float)yticks, SDL_MOUSEWHEEL_NORMAL); + } else { + bool ignore_click = false; + if (button > 7) { + /* X button values 4-7 are used for scrolling, so X1 is 8, X2 is 9, ... + => subtract (8-SDL_BUTTON_X1) to get value SDL expects */ + button -= (8 - SDL_BUTTON_X1); + } + if (button == Button1) { + if (X11_TriggerHitTestAction(_this, windowdata, x, y)) { + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_HIT_TEST, 0, 0); + return; // don't pass this event on to app. + } + } + if (windowdata->last_focus_event_time) { + const int X11_FOCUS_CLICK_TIMEOUT = 10; + if (SDL_GetTicks() < (windowdata->last_focus_event_time + X11_FOCUS_CLICK_TIMEOUT)) { + ignore_click = !SDL_GetHintBoolean(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, false); + } + windowdata->last_focus_event_time = 0; + } + if (!ignore_click) { + SDL_SendMouseButton(timestamp, window, mouseID, button, true); + } + } + X11_UpdateUserTime(windowdata, time); +} + +void X11_HandleButtonRelease(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_MouseID mouseID, int button, unsigned long time) +{ + SDL_Window *window = windowdata->window; + const SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + // The X server sends a Release event for each Press for wheels. Ignore them. + int xticks = 0, yticks = 0; + Uint64 timestamp = X11_GetEventTimestamp(time); + +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: ButtonRelease (X11 button = %d)", windowdata->xwindow, button); +#endif + if (!X11_IsWheelEvent(display, button, &xticks, &yticks)) { + if (button > 7) { + // see explanation at case ButtonPress + button -= (8 - SDL_BUTTON_X1); + } + SDL_SendMouseButton(timestamp, window, mouseID, button, false); + } +} + +void X11_GetBorderValues(SDL_WindowData *data) +{ + SDL_VideoData *videodata = data->videodata; + Display *display = videodata->display; + + Atom type; + int format; + unsigned long nitems, bytes_after; + unsigned char *property; + + // Some compositors will send extents even when the border hint is turned off. Ignore them in this case. + if (!(data->window->flags & SDL_WINDOW_BORDERLESS)) { + if (X11_XGetWindowProperty(display, data->xwindow, videodata->atoms._NET_FRAME_EXTENTS, 0, 16, 0, XA_CARDINAL, &type, &format, &nitems, &bytes_after, &property) == Success) { + if (type != None && nitems == 4) { + data->border_left = (int)((long *)property)[0]; + data->border_right = (int)((long *)property)[1]; + data->border_top = (int)((long *)property)[2]; + data->border_bottom = (int)((long *)property)[3]; + } + X11_XFree(property); + +#ifdef DEBUG_XEVENTS + SDL_Log("New _NET_FRAME_EXTENTS: left=%d right=%d, top=%d, bottom=%d", data->border_left, data->border_right, data->border_top, data->border_bottom); +#endif + } + } else { + data->border_left = data->border_top = data->border_right = data->border_bottom = 0; + } +} + +static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) +{ + SDL_VideoData *videodata = _this->internal; + Display *display; + SDL_WindowData *data; + XClientMessageEvent m; + int i; + + SDL_assert(videodata != NULL); + display = videodata->display; + + // filter events catches XIM events and sends them to the correct handler + // Key press/release events are filtered in X11_HandleKeyEvent() + if (xevent->type != KeyPress && xevent->type != KeyRelease) { + if (X11_XFilterEvent(xevent, None)) { +#ifdef DEBUG_XEVENTS + SDL_Log("Filtered event type = %d display = %p window = 0x%lx", + xevent->type, xevent->xany.display, xevent->xany.window); +#endif + return; + } + } + +#ifdef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS + if (xevent->type == GenericEvent) { + X11_HandleGenericEvent(_this, xevent); + return; + } +#endif + + // Calling the event hook for generic events happens in X11_HandleGenericEvent(), where the event data is available + if (g_X11EventHook) { + if (!g_X11EventHook(g_X11EventHookData, xevent)) { + return; + } + } + +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR + if (videodata->xrandr_event_base && (xevent->type == (videodata->xrandr_event_base + RRNotify))) { + X11_HandleXRandREvent(_this, xevent); + } +#endif + +#ifdef DEBUG_XEVENTS + SDL_Log("X11 event type = %d display = %p window = 0x%lx", + xevent->type, xevent->xany.display, xevent->xany.window); +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + if (SDL_X11_HAVE_XFIXES && + xevent->type == X11_GetXFixesSelectionNotifyEvent()) { + XFixesSelectionNotifyEvent *ev = (XFixesSelectionNotifyEvent *)xevent; + +#ifdef DEBUG_XEVENTS + SDL_Log("window CLIPBOARD: XFixesSelectionNotify (selection = %s)", + X11_XGetAtomName(display, ev->selection)); +#endif + + if (ev->subtype == XFixesSetSelectionOwnerNotify) + { + if (ev->selection != videodata->atoms.CLIPBOARD) + return; + + if (X11_XGetSelectionOwner(display, ev->selection) == videodata->clipboard_window) + return; + + /* when here we're notified that the clipboard had an external change, we request the + * available mime types by asking for a conversion to the TARGETS format. We should get a + * SelectionNotify event later, and when treating these results, we will push a ClipboardUpdated + * event + */ + + X11_XConvertSelection(display, videodata->atoms.CLIPBOARD, videodata->atoms.TARGETS, + videodata->atoms.SDL_FORMATS, GetWindow(_this), CurrentTime); + } + + return; + } +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + + if ((videodata->clipboard_window != None) && + (videodata->clipboard_window == xevent->xany.window)) { + X11_HandleClipboardEvent(_this, xevent); + return; + } + + if ((videodata->xsettings_window != None) && + (videodata->xsettings_window == xevent->xany.window)) { + X11_HandleSettingsEvent(_this, xevent); + return; + } + + data = X11_FindWindow(_this, xevent->xany.window); + + if (!data) { + // The window for KeymapNotify, etc events is 0 + if (xevent->type == KeymapNotify) { +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: KeymapNotify!", xevent->xany.window); +#endif + if (SDL_GetKeyboardFocus() != NULL) { +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM + if (videodata->xkb.desc_ptr) { + XkbStateRec state; + if (X11_XkbGetState(videodata->display, XkbUseCoreKbd, &state) == Success) { + if (state.group != videodata->xkb.current_group) { + // Only rebuild the keymap if the layout has changed. + videodata->xkb.current_group = state.group; + X11_UpdateKeymap(_this, true); + } + } + } +#endif + X11_ReconcileKeyboardState(_this); + } + } else if (xevent->type == MappingNotify) { + // Has the keyboard layout changed? + const int request = xevent->xmapping.request; + +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: MappingNotify!", xevent->xany.window); +#endif + if ((request == MappingKeyboard) || (request == MappingModifier)) { + X11_XRefreshKeyboardMapping(&xevent->xmapping); + } + + X11_UpdateKeymap(_this, true); + } else if (xevent->type == PropertyNotify && videodata && videodata->windowlist) { + char *name_of_atom = X11_XGetAtomName(display, xevent->xproperty.atom); + + if (SDL_strncmp(name_of_atom, "_ICC_PROFILE", sizeof("_ICC_PROFILE") - 1) == 0) { + XWindowAttributes attrib; + int screennum; + for (i = 0; i < videodata->numwindows; ++i) { + if (videodata->windowlist[i] != NULL) { + data = videodata->windowlist[i]; + X11_XGetWindowAttributes(display, data->xwindow, &attrib); + screennum = X11_XScreenNumberOfScreen(attrib.screen); + if (screennum == 0 && SDL_strcmp(name_of_atom, "_ICC_PROFILE") == 0) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_ICCPROF_CHANGED, 0, 0); + } else if (SDL_strncmp(name_of_atom, "_ICC_PROFILE_", sizeof("_ICC_PROFILE_") - 1) == 0 && SDL_strlen(name_of_atom) > sizeof("_ICC_PROFILE_") - 1) { + int iccscreennum = SDL_atoi(&name_of_atom[sizeof("_ICC_PROFILE_") - 1]); + + if (screennum == iccscreennum) { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_ICCPROF_CHANGED, 0, 0); + } + } + } + } + } + + if (name_of_atom) { + X11_XFree(name_of_atom); + } + } + return; + } + + switch (xevent->type) { + + // Gaining mouse coverage? + case EnterNotify: + { + SDL_Mouse *mouse = SDL_GetMouse(); +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: EnterNotify! (%d,%d,%d)", xevent->xany.window, + xevent->xcrossing.x, + xevent->xcrossing.y, + xevent->xcrossing.mode); + if (xevent->xcrossing.mode == NotifyGrab) { + SDL_Log("Mode: NotifyGrab"); + } + if (xevent->xcrossing.mode == NotifyUngrab) { + SDL_Log("Mode: NotifyUngrab"); + } +#endif + SDL_SetMouseFocus(data->window); + + mouse->last_x = xevent->xcrossing.x; + mouse->last_y = xevent->xcrossing.y; + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + { + // Only create the barriers if we have input focus + SDL_WindowData *windowdata = data->window->internal; + if ((data->pointer_barrier_active == true) && windowdata->window->flags & SDL_WINDOW_INPUT_FOCUS) { + X11_ConfineCursorWithFlags(_this, windowdata->window, &windowdata->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); + } + } +#endif + + if (!mouse->relative_mode) { + SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, false, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y); + } + + // We ungrab in LeaveNotify, so we may need to grab again here + SDL_UpdateWindowGrab(data->window); + + X11_ProcessHitTest(_this, data, mouse->last_x, mouse->last_y, true); + } break; + // Losing mouse coverage? + case LeaveNotify: + { +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: LeaveNotify! (%d,%d,%d)", xevent->xany.window, + xevent->xcrossing.x, + xevent->xcrossing.y, + xevent->xcrossing.mode); + if (xevent->xcrossing.mode == NotifyGrab) { + SDL_Log("Mode: NotifyGrab"); + } + if (xevent->xcrossing.mode == NotifyUngrab) { + SDL_Log("Mode: NotifyUngrab"); + } +#endif + if (!SDL_GetMouse()->relative_mode) { + SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, false, (float)xevent->xcrossing.x, (float)xevent->xcrossing.y); + } + + if (xevent->xcrossing.mode != NotifyGrab && + xevent->xcrossing.mode != NotifyUngrab && + xevent->xcrossing.detail != NotifyInferior) { + + /* In order for interaction with the window decorations and menu to work properly + on Mutter, we need to ungrab the keyboard when the the mouse leaves. */ + if (!(data->window->flags & SDL_WINDOW_FULLSCREEN)) { + X11_SetWindowKeyboardGrab(_this, data->window, false); + } + + SDL_SetMouseFocus(NULL); + } + } break; + + // Gaining input focus? + case FocusIn: + { + if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { + // Someone is handling a global hotkey, ignore it +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: FocusIn (NotifyGrab/NotifyUngrab, ignoring)", xevent->xany.window); +#endif + break; + } + + if (xevent->xfocus.detail == NotifyInferior || xevent->xfocus.detail == NotifyPointer) { +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: FocusIn (NotifyInferior/NotifyPointer, ignoring)", xevent->xany.window); +#endif + break; + } +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: FocusIn!", xevent->xany.window); +#endif + if (!videodata->last_mode_change_deadline) /* no recent mode changes */ { + data->pending_focus = PENDING_FOCUS_NONE; + data->pending_focus_time = 0; + X11_DispatchFocusIn(_this, data); + } else { + data->pending_focus = PENDING_FOCUS_IN; + data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_TIME; + } + data->last_focus_event_time = SDL_GetTicks(); + } break; + + // Losing input focus? + case FocusOut: + { + if (xevent->xfocus.mode == NotifyGrab || xevent->xfocus.mode == NotifyUngrab) { + // Someone is handling a global hotkey, ignore it +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: FocusOut (NotifyGrab/NotifyUngrab, ignoring)", xevent->xany.window); +#endif + break; + } + if (xevent->xfocus.detail == NotifyInferior || xevent->xfocus.detail == NotifyPointer) { + /* We still have focus if a child gets focus. We also don't + care about the position of the pointer when the keyboard + focus changed. */ +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: FocusOut (NotifyInferior/NotifyPointer, ignoring)", xevent->xany.window); +#endif + break; + } +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: FocusOut!", xevent->xany.window); +#endif + if (!videodata->last_mode_change_deadline) /* no recent mode changes */ { + data->pending_focus = PENDING_FOCUS_NONE; + data->pending_focus_time = 0; + X11_DispatchFocusOut(_this, data); + } else { + data->pending_focus = PENDING_FOCUS_OUT; + data->pending_focus_time = SDL_GetTicks() + PENDING_FOCUS_TIME; + } + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + // Disable confinement if it is activated. + if (data->pointer_barrier_active == true) { + X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); + } +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + } break; + + + // Have we been iconified? + case UnmapNotify: + { + XEvent ev; + +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: UnmapNotify!", xevent->xany.window); +#endif + + if (X11_XCheckIfEvent(display, &ev, &isReparentNotify, (XPointer)&xevent->xunmap)) { + X11_XCheckIfEvent(display, &ev, &isMapNotify, (XPointer)&xevent->xunmap); + } else { + X11_DispatchUnmapNotify(data); + } + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + // Disable confinement if the window gets hidden. + if (data->pointer_barrier_active == true) { + X11_ConfineCursorWithFlags(_this, data->window, NULL, X11_BARRIER_HANDLED_BY_EVENT); + } +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + } break; + + // Have we been restored? + case MapNotify: + { +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: MapNotify!", xevent->xany.window); +#endif + X11_DispatchMapNotify(data); + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + // Enable confinement if it was activated. + if (data->pointer_barrier_active == true) { + X11_ConfineCursorWithFlags(_this, data->window, &data->barrier_rect, X11_BARRIER_HANDLED_BY_EVENT); + } +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + } break; + + // Have we been resized or moved? + case ConfigureNotify: + { +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: ConfigureNotify! (position: %d,%d, size: %dx%d)", xevent->xany.window, + xevent->xconfigure.x, xevent->xconfigure.y, + xevent->xconfigure.width, xevent->xconfigure.height); +#endif + // Real configure notify events are relative to the parent, synthetic events are absolute. + if (!xevent->xconfigure.send_event) + { + unsigned int NumChildren; + Window ChildReturn, Root, Parent; + Window *Children; + // Translate these coordinates back to relative to root + X11_XQueryTree(data->videodata->display, xevent->xconfigure.window, &Root, &Parent, &Children, &NumChildren); + X11_XTranslateCoordinates(xevent->xconfigure.display, + Parent, DefaultRootWindow(xevent->xconfigure.display), + xevent->xconfigure.x, xevent->xconfigure.y, + &xevent->xconfigure.x, &xevent->xconfigure.y, + &ChildReturn); + } + + if (xevent->xconfigure.x != data->last_xconfigure.x || + xevent->xconfigure.y != data->last_xconfigure.y) { + if (!data->size_move_event_flags) { + SDL_Window *w; + int x = xevent->xconfigure.x; + int y = xevent->xconfigure.y; + + data->pending_operation &= ~X11_PENDING_OP_MOVE; + SDL_GlobalToRelativeForWindow(data->window, x, y, &x, &y); + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MOVED, x, y); + + for (w = data->window->first_child; w; w = w->next_sibling) { + // Don't update hidden child popup windows, their relative position doesn't change + if (SDL_WINDOW_IS_POPUP(w) && !(w->flags & SDL_WINDOW_HIDDEN)) { + X11_UpdateWindowPosition(w, true); + } + } + } + } + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + X11_HandleConfigure(data->window, &xevent->xconfigure); +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + + if (xevent->xconfigure.width != data->last_xconfigure.width || + xevent->xconfigure.height != data->last_xconfigure.height) { + if (!data->size_move_event_flags) { + data->pending_operation &= ~X11_PENDING_OP_RESIZE; + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESIZED, + xevent->xconfigure.width, + xevent->xconfigure.height); + } + } + + data->last_xconfigure = xevent->xconfigure; + } break; + + // Have we been requested to quit (or another client message?) + case ClientMessage: + { + static int xdnd_version = 0; + + if (xevent->xclient.message_type == videodata->atoms.XdndEnter) { + + bool use_list = xevent->xclient.data.l[1] & 1; + data->xdnd_source = xevent->xclient.data.l[0]; + xdnd_version = (xevent->xclient.data.l[1] >> 24); +#ifdef DEBUG_XEVENTS + SDL_Log("XID of source window : 0x%lx", data->xdnd_source); + SDL_Log("Protocol version to use : %d", xdnd_version); + SDL_Log("More then 3 data types : %d", (int)use_list); +#endif + + if (use_list) { + // fetch conversion targets + SDL_x11Prop p; + X11_ReadProperty(&p, display, data->xdnd_source, videodata->atoms.XdndTypeList); + // pick one + data->xdnd_req = X11_PickTarget(display, (Atom *)p.data, p.count); + X11_XFree(p.data); + } else { + // pick from list of three + data->xdnd_req = X11_PickTargetFromAtoms(display, xevent->xclient.data.l[2], xevent->xclient.data.l[3], xevent->xclient.data.l[4]); + } + } else if (xevent->xclient.message_type == videodata->atoms.XdndLeave) { +#ifdef DEBUG_XEVENTS + SDL_Log("XID of source window : 0x%lx", xevent->xclient.data.l[0]); +#endif + SDL_SendDropComplete(data->window); + } else if (xevent->xclient.message_type == videodata->atoms.XdndPosition) { + +#ifdef DEBUG_XEVENTS + Atom act = videodata->atoms.XdndActionCopy; + if (xdnd_version >= 2) { + act = xevent->xclient.data.l[4]; + } + SDL_Log("Action requested by user is : %s", X11_XGetAtomName(display, act)); +#endif + { + // Drag and Drop position + int root_x, root_y, window_x, window_y; + Window ChildReturn; + root_x = xevent->xclient.data.l[2] >> 16; + root_y = xevent->xclient.data.l[2] & 0xffff; + // Translate from root to current window position + X11_XTranslateCoordinates(display, DefaultRootWindow(display), data->xwindow, + root_x, root_y, &window_x, &window_y, &ChildReturn); + + SDL_SendDropPosition(data->window, (float)window_x, (float)window_y); + } + + // reply with status + SDL_memset(&m, 0, sizeof(XClientMessageEvent)); + m.type = ClientMessage; + m.display = xevent->xclient.display; + m.window = xevent->xclient.data.l[0]; + m.message_type = videodata->atoms.XdndStatus; + m.format = 32; + m.data.l[0] = data->xwindow; + m.data.l[1] = (data->xdnd_req != None); + m.data.l[2] = 0; // specify an empty rectangle + m.data.l[3] = 0; + m.data.l[4] = videodata->atoms.XdndActionCopy; // we only accept copying anyway + + X11_XSendEvent(display, xevent->xclient.data.l[0], False, NoEventMask, (XEvent *)&m); + X11_XFlush(display); + } else if (xevent->xclient.message_type == videodata->atoms.XdndDrop) { + if (data->xdnd_req == None) { + // say again - not interested! + SDL_memset(&m, 0, sizeof(XClientMessageEvent)); + m.type = ClientMessage; + m.display = xevent->xclient.display; + m.window = xevent->xclient.data.l[0]; + m.message_type = videodata->atoms.XdndFinished; + m.format = 32; + m.data.l[0] = data->xwindow; + m.data.l[1] = 0; + m.data.l[2] = None; // fail! + X11_XSendEvent(display, xevent->xclient.data.l[0], False, NoEventMask, (XEvent *)&m); + } else { + // convert + if (xdnd_version >= 1) { + X11_XConvertSelection(display, videodata->atoms.XdndSelection, data->xdnd_req, videodata->atoms.PRIMARY, data->xwindow, xevent->xclient.data.l[2]); + } else { + X11_XConvertSelection(display, videodata->atoms.XdndSelection, data->xdnd_req, videodata->atoms.PRIMARY, data->xwindow, CurrentTime); + } + } + } else if ((xevent->xclient.message_type == videodata->atoms.WM_PROTOCOLS) && + (xevent->xclient.format == 32) && + (xevent->xclient.data.l[0] == videodata->atoms._NET_WM_PING)) { + Window root = DefaultRootWindow(display); + +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: _NET_WM_PING", xevent->xany.window); +#endif + xevent->xclient.window = root; + X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, xevent); + break; + } + + else if ((xevent->xclient.message_type == videodata->atoms.WM_PROTOCOLS) && + (xevent->xclient.format == 32) && + (xevent->xclient.data.l[0] == videodata->atoms.WM_DELETE_WINDOW)) { + +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: WM_DELETE_WINDOW", xevent->xany.window); +#endif + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_CLOSE_REQUESTED, 0, 0); + break; + } else if ((xevent->xclient.message_type == videodata->atoms.WM_PROTOCOLS) && + (xevent->xclient.format == 32) && + (xevent->xclient.data.l[0] == videodata->atoms._NET_WM_SYNC_REQUEST)) { + +#ifdef DEBUG_XEVENTS + printf("window %p: _NET_WM_SYNC_REQUEST\n", data); +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + X11_HandleSyncRequest(data->window, &xevent->xclient); +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + break; + } + } break; + + // Do we need to refresh ourselves? + case Expose: + { +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: Expose (count = %d)", xevent->xany.window, xevent->xexpose.count); +#endif + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } break; + + /* Use XInput2 instead of the xevents API if possible, for: + - KeyPress + - KeyRelease + - MotionNotify + - ButtonPress + - ButtonRelease + XInput2 has more precise information, e.g., to distinguish different input devices. */ + case KeyPress: + case KeyRelease: + { + if (data->xinput2_keyboard_enabled) { + // This input is being handled by XInput2 + break; + } + + X11_HandleKeyEvent(_this, data, SDL_GLOBAL_KEYBOARD_ID, xevent); + } break; + + case MotionNotify: + { + if (data->xinput2_mouse_enabled && !data->mouse_grabbed) { + // This input is being handled by XInput2 + break; + } + + SDL_Mouse *mouse = SDL_GetMouse(); + if (!mouse->relative_mode) { +#ifdef DEBUG_MOTION + SDL_Log("window 0x%lx: X11 motion: %d,%d", xevent->xany.window, xevent->xmotion.x, xevent->xmotion.y); +#endif + + X11_ProcessHitTest(_this, data, (float)xevent->xmotion.x, (float)xevent->xmotion.y, false); + SDL_SendMouseMotion(0, data->window, SDL_GLOBAL_MOUSE_ID, false, (float)xevent->xmotion.x, (float)xevent->xmotion.y); + } + } break; + + case ButtonPress: + { + if (data->xinput2_mouse_enabled) { + // This input is being handled by XInput2 + break; + } + + X11_HandleButtonPress(_this, data, SDL_GLOBAL_MOUSE_ID, xevent->xbutton.button, + xevent->xbutton.x, xevent->xbutton.y, xevent->xbutton.time); + } break; + + case ButtonRelease: + { + if (data->xinput2_mouse_enabled) { + // This input is being handled by XInput2 + break; + } + + X11_HandleButtonRelease(_this, data, SDL_GLOBAL_MOUSE_ID, xevent->xbutton.button, xevent->xbutton.time); + } break; + + case PropertyNotify: + { +#ifdef DEBUG_XEVENTS + unsigned char *propdata; + int status, real_format; + Atom real_type; + unsigned long items_read, items_left; + + char *name = X11_XGetAtomName(display, xevent->xproperty.atom); + if (name) { + SDL_Log("window 0x%lx: PropertyNotify: %s %s time=%lu", xevent->xany.window, name, (xevent->xproperty.state == PropertyDelete) ? "deleted" : "changed", xevent->xproperty.time); + X11_XFree(name); + } + + status = X11_XGetWindowProperty(display, data->xwindow, xevent->xproperty.atom, 0L, 8192L, False, AnyPropertyType, &real_type, &real_format, &items_read, &items_left, &propdata); + if (status == Success && items_read > 0) { + if (real_type == XA_INTEGER) { + int *values = (int *)propdata; + + SDL_Log("{"); + for (i = 0; i < items_read; i++) { + SDL_Log(" %d", values[i]); + } + SDL_Log(" }"); + } else if (real_type == XA_CARDINAL) { + if (real_format == 32) { + Uint32 *values = (Uint32 *)propdata; + + SDL_Log("{"); + for (i = 0; i < items_read; i++) { + SDL_Log(" %d", values[i]); + } + SDL_Log(" }"); + } else if (real_format == 16) { + Uint16 *values = (Uint16 *)propdata; + + SDL_Log("{"); + for (i = 0; i < items_read; i++) { + SDL_Log(" %d", values[i]); + } + SDL_Log(" }"); + } else if (real_format == 8) { + Uint8 *values = (Uint8 *)propdata; + + SDL_Log("{"); + for (i = 0; i < items_read; i++) { + SDL_Log(" %d", values[i]); + } + SDL_Log(" }"); + } + } else if (real_type == XA_STRING || + real_type == videodata->atoms.UTF8_STRING) { + SDL_Log("{ \"%s\" }", propdata); + } else if (real_type == XA_ATOM) { + Atom *atoms = (Atom *)propdata; + + SDL_Log("{"); + for (i = 0; i < items_read; i++) { + char *atomname = X11_XGetAtomName(display, atoms[i]); + if (atomname) { + SDL_Log(" %s", atomname); + X11_XFree(atomname); + } + } + SDL_Log(" }"); + } else { + char *atomname = X11_XGetAtomName(display, real_type); + SDL_Log("Unknown type: 0x%lx (%s)", real_type, atomname ? atomname : "UNKNOWN"); + if (atomname) { + X11_XFree(atomname); + } + } + } + if (status == Success) { + X11_XFree(propdata); + } +#endif // DEBUG_XEVENTS + + /* Take advantage of this moment to make sure user_time has a + valid timestamp from the X server, so if we later try to + raise/restore this window, _NET_ACTIVE_WINDOW can have a + non-zero timestamp, even if there's never been a mouse or + key press to this window so far. Note that we don't try to + set _NET_WM_USER_TIME here, though. That's only for legit + user interaction with the window. */ + if (!data->user_time) { + data->user_time = xevent->xproperty.time; + } + + if (xevent->xproperty.atom == data->videodata->atoms._NET_WM_STATE) { + /* Get the new state from the window manager. + Compositing window managers can alter visibility of windows + without ever mapping / unmapping them, so we handle that here, + because they use the NETWM protocol to notify us of changes. + */ + const SDL_WindowFlags flags = X11_GetNetWMState(_this, data->window, xevent->xproperty.window); + const SDL_WindowFlags changed = flags ^ data->window->flags; + + if ((changed & (SDL_WINDOW_HIDDEN | SDL_WINDOW_FULLSCREEN)) != 0) { + if (flags & SDL_WINDOW_HIDDEN) { + X11_DispatchUnmapNotify(data); + } else { + X11_DispatchMapNotify(data); + } + } + + if (!SDL_WINDOW_IS_POPUP(data->window)) { + if (changed & SDL_WINDOW_FULLSCREEN) { + data->pending_operation &= ~X11_PENDING_OP_FULLSCREEN; + + if (flags & SDL_WINDOW_FULLSCREEN) { + if (!(flags & SDL_WINDOW_MINIMIZED)) { + const bool commit = SDL_memcmp(&data->window->current_fullscreen_mode, &data->requested_fullscreen_mode, sizeof(SDL_DisplayMode)) != 0; + + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_ENTER_FULLSCREEN, 0, 0); + if (commit) { + /* This was initiated by the compositor, or the mode was changed between the request and the window + * becoming fullscreen. Switch to the application requested mode if necessary. + */ + SDL_copyp(&data->window->current_fullscreen_mode, &data->window->requested_fullscreen_mode); + SDL_UpdateFullscreenMode(data->window, SDL_FULLSCREEN_OP_UPDATE, true); + } else { + SDL_UpdateFullscreenMode(data->window, SDL_FULLSCREEN_OP_ENTER, false); + } + } + } else { + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_LEAVE_FULLSCREEN, 0, 0); + SDL_UpdateFullscreenMode(data->window, false, false); + + SDL_zero(data->requested_fullscreen_mode); + + // Need to restore or update any limits changed while the window was fullscreen. + X11_SetWindowMinMax(data->window, !!(flags & SDL_WINDOW_MAXIMIZED)); + + // Toggle the borders if they were forced on while creating a borderless fullscreen window. + if (data->fullscreen_borders_forced_on) { + data->toggle_borders = true; + data->fullscreen_borders_forced_on = false; + } + } + + if ((flags & SDL_WINDOW_FULLSCREEN) && + (data->border_top || data->border_left || data->border_bottom || data->border_right)) { + /* If the window is entering fullscreen and the borders are + * non-zero sized, turn off size events until the borders are + * shut off to avoid bogus window sizes and positions, and + * note that the old borders were non-zero for restoration. + */ + data->size_move_event_flags |= X11_SIZE_MOVE_EVENTS_WAIT_FOR_BORDERS; + data->previous_borders_nonzero = true; + } else if (!(flags & SDL_WINDOW_FULLSCREEN) && + data->previous_borders_nonzero && + (!data->border_top && !data->border_left && !data->border_bottom && !data->border_right)) { + /* If the window is leaving fullscreen and the current borders + * are zero sized, but weren't when entering fullscreen, turn + * off size events until the borders come back to avoid bogus + * window sizes and positions. + */ + data->size_move_event_flags |= X11_SIZE_MOVE_EVENTS_WAIT_FOR_BORDERS; + data->previous_borders_nonzero = false; + } else { + data->size_move_event_flags = 0; + data->previous_borders_nonzero = false; + + if (!(data->window->flags & SDL_WINDOW_FULLSCREEN) && data->toggle_borders) { + data->toggle_borders = false; + X11_SetWindowBordered(_this, data->window, !(data->window->flags & SDL_WINDOW_BORDERLESS)); + } + } + } + if ((changed & SDL_WINDOW_MAXIMIZED) && ((flags & SDL_WINDOW_MAXIMIZED) && !(flags & SDL_WINDOW_MINIMIZED))) { + data->pending_operation &= ~X11_PENDING_OP_MAXIMIZE; + if ((changed & SDL_WINDOW_MINIMIZED)) { + data->pending_operation &= ~X11_PENDING_OP_RESTORE; + // If coming out of minimized, send a restore event before sending maximized. + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + } + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MAXIMIZED, 0, 0); + } + if ((changed & SDL_WINDOW_MINIMIZED) && (flags & SDL_WINDOW_MINIMIZED)) { + data->pending_operation &= ~X11_PENDING_OP_MINIMIZE; + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); + } + if (!(flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED))) { + data->pending_operation &= ~X11_PENDING_OP_RESTORE; + SDL_SendWindowEvent(data->window, SDL_EVENT_WINDOW_RESTORED, 0, 0); + + // Apply any pending state if restored. + if (!(flags & SDL_WINDOW_FULLSCREEN)) { + if (data->pending_position) { + data->pending_position = false; + data->pending_operation |= X11_PENDING_OP_MOVE; + data->expected.x = data->window->pending.x - data->border_left; + data->expected.y = data->window->pending.y - data->border_top; + X11_XMoveWindow(display, data->xwindow, data->expected.x, data->expected.y); + } + if (data->pending_size) { + data->pending_size = false; + data->pending_operation |= X11_PENDING_OP_RESIZE; + data->expected.w = data->window->pending.w; + data->expected.h = data->window->pending.h; + X11_XResizeWindow(display, data->xwindow, data->window->pending.w, data->window->pending.h); + } + } + } + if ((flags & SDL_WINDOW_INPUT_FOCUS)) { + if (data->pending_move) { + DispatchWindowMove(_this, data, &data->pending_move_point); + data->pending_move = false; + } + } + } + if (changed & SDL_WINDOW_OCCLUDED) { + SDL_SendWindowEvent(data->window, (flags & SDL_WINDOW_OCCLUDED) ? SDL_EVENT_WINDOW_OCCLUDED : SDL_EVENT_WINDOW_EXPOSED, 0, 0); + } + } else if (xevent->xproperty.atom == videodata->atoms.XKLAVIER_STATE) { + /* Hack for Ubuntu 12.04 (etc) that doesn't send MappingNotify + events when the keyboard layout changes (for example, + changing from English to French on the menubar's keyboard + icon). Since it changes the XKLAVIER_STATE property, we + notice and reinit our keymap here. This might not be the + right approach, but it seems to work. */ + X11_UpdateKeymap(_this, true); + } else if (xevent->xproperty.atom == videodata->atoms._NET_FRAME_EXTENTS) { + /* Events are disabled when leaving fullscreen until the borders appear to avoid + * incorrect size/position events. + */ + if (data->size_move_event_flags) { + data->size_move_event_flags &= ~X11_SIZE_MOVE_EVENTS_WAIT_FOR_BORDERS; + X11_GetBorderValues(data); + + } + if (!(data->window->flags & SDL_WINDOW_FULLSCREEN) && data->toggle_borders) { + data->toggle_borders = false; + X11_SetWindowBordered(_this, data->window, !(data->window->flags & SDL_WINDOW_BORDERLESS)); + } + } + } break; + + case SelectionNotify: + { + Atom target = xevent->xselection.target; +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: SelectionNotify (requestor = 0x%lx, target = 0x%lx)", xevent->xany.window, + xevent->xselection.requestor, xevent->xselection.target); +#endif + if (target == data->xdnd_req) { + // read data + SDL_x11Prop p; + X11_ReadProperty(&p, display, data->xwindow, videodata->atoms.PRIMARY); + + if (p.format == 8) { + char *saveptr = NULL; + char *name = X11_XGetAtomName(display, target); + if (name) { + char *token = SDL_strtok_r((char *)p.data, "\r\n", &saveptr); + while (token) { + if ((SDL_strcmp("text/plain;charset=utf-8", name) == 0) || + (SDL_strcmp("UTF8_STRING", name) == 0) || + (SDL_strcmp("text/plain", name) == 0) || + (SDL_strcmp("TEXT", name) == 0)) { + SDL_SendDropText(data->window, token); + } else if (SDL_strcmp("text/uri-list", name) == 0) { + if (SDL_URIToLocal(token, token) >= 0) { + SDL_SendDropFile(data->window, NULL, token); + } + } + token = SDL_strtok_r(NULL, "\r\n", &saveptr); + } + X11_XFree(name); + } + SDL_SendDropComplete(data->window); + } + X11_XFree(p.data); + + // send reply + SDL_memset(&m, 0, sizeof(XClientMessageEvent)); + m.type = ClientMessage; + m.display = display; + m.window = data->xdnd_source; + m.message_type = videodata->atoms.XdndFinished; + m.format = 32; + m.data.l[0] = data->xwindow; + m.data.l[1] = 1; + m.data.l[2] = videodata->atoms.XdndActionCopy; + X11_XSendEvent(display, data->xdnd_source, False, NoEventMask, (XEvent *)&m); + + X11_XSync(display, False); + } + } break; + + default: + { +#ifdef DEBUG_XEVENTS + SDL_Log("window 0x%lx: Unhandled event %d", xevent->xany.window, xevent->type); +#endif + } break; + } +} + +static void X11_HandleFocusChanges(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + int i; + + if (videodata && videodata->windowlist) { + for (i = 0; i < videodata->numwindows; ++i) { + SDL_WindowData *data = videodata->windowlist[i]; + if (data && data->pending_focus != PENDING_FOCUS_NONE) { + Uint64 now = SDL_GetTicks(); + if (now >= data->pending_focus_time) { + if (data->pending_focus == PENDING_FOCUS_IN) { + X11_DispatchFocusIn(_this, data); + } else { + X11_DispatchFocusOut(_this, data); + } + data->pending_focus = PENDING_FOCUS_NONE; + } + } + } + } +} + +static Bool isAnyEvent(Display *display, XEvent *ev, XPointer arg) +{ + return True; +} + +static bool X11_PollEvent(Display *display, XEvent *event) +{ + if (!X11_XCheckIfEvent(display, event, isAnyEvent, NULL)) { + return false; + } + + return true; +} + +void X11_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *data = _this->internal; + Display *req_display = data->request_display; + Window xwindow = window->internal->xwindow; + XClientMessageEvent event; + + SDL_memset(&event, 0, sizeof(XClientMessageEvent)); + event.type = ClientMessage; + event.display = req_display; + event.send_event = True; + event.message_type = data->atoms._SDL_WAKEUP; + event.format = 8; + + X11_XSendEvent(req_display, xwindow, False, NoEventMask, (XEvent *)&event); + /* XSendEvent returns a status and it could be BadValue or BadWindow. If an + error happens it is an SDL's internal error and there is nothing we can do here. */ + X11_XFlush(req_display); +} + +int X11_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) +{ + SDL_VideoData *videodata = _this->internal; + Display *display; + XEvent xevent; + display = videodata->display; + + SDL_zero(xevent); + + // Flush and poll to grab any events already read and queued + X11_XFlush(display); + if (X11_PollEvent(display, &xevent)) { + // Fall through + } else if (timeoutNS == 0) { + return 0; + } else { + // Use SDL_IOR_NO_RETRY to ensure SIGINT will break us out of our wait + int err = SDL_IOReady(ConnectionNumber(display), SDL_IOR_READ | SDL_IOR_NO_RETRY, timeoutNS); + if (err > 0) { + if (!X11_PollEvent(display, &xevent)) { + /* Someone may have beat us to reading the fd. Return 1 here to + * trigger the normal spurious wakeup logic in the event core. */ + return 1; + } + } else if (err == 0) { + // Timeout + return 0; + } else { + // Error returned from poll()/select() + + if (errno == EINTR) { + /* If the wait was interrupted by a signal, we may have generated a + * SDL_EVENT_QUIT event. Let the caller know to call SDL_PumpEvents(). */ + return 1; + } else { + return err; + } + } + } + + X11_DispatchEvent(_this, &xevent); + +#ifdef SDL_USE_LIBDBUS + SDL_DBus_PumpEvents(); +#endif + return 1; +} + +void X11_PumpEvents(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + XEvent xevent; + int i; + + /* Check if a display had the mode changed and is waiting for a window to asynchronously become + * fullscreen. If there is no fullscreen window past the elapsed timeout, revert the mode switch. + */ + for (i = 0; i < _this->num_displays; ++i) { + if (_this->displays[i]->internal->mode_switch_deadline_ns) { + if (_this->displays[i]->fullscreen_window) { + _this->displays[i]->internal->mode_switch_deadline_ns = 0; + } else if (SDL_GetTicksNS() >= _this->displays[i]->internal->mode_switch_deadline_ns) { + SDL_LogError(SDL_LOG_CATEGORY_VIDEO, + "Time out elapsed after mode switch on display %" SDL_PRIu32 " with no window becoming fullscreen; reverting", _this->displays[i]->id); + SDL_SetDisplayModeForDisplay(_this->displays[i], NULL); + } + } + } + + if (data->last_mode_change_deadline) { + if (SDL_GetTicks() >= data->last_mode_change_deadline) { + data->last_mode_change_deadline = 0; // assume we're done. + } + } + + // Update activity every 30 seconds to prevent screensaver + if (_this->suspend_screensaver) { + Uint64 now = SDL_GetTicks(); + if (!data->screensaver_activity || now >= (data->screensaver_activity + 30000)) { + X11_XResetScreenSaver(data->display); + +#ifdef SDL_USE_LIBDBUS + SDL_DBus_ScreensaverTickle(); +#endif + + data->screensaver_activity = now; + } + } + + SDL_zero(xevent); + + // Keep processing pending events + while (X11_PollEvent(data->display, &xevent)) { + X11_DispatchEvent(_this, &xevent); + } + +#ifdef SDL_USE_LIBDBUS + SDL_DBus_PumpEvents(); +#endif + + // FIXME: Only need to do this when there are pending focus changes + X11_HandleFocusChanges(_this); + + // FIXME: Only need to do this when there are flashing windows + for (i = 0; i < data->numwindows; ++i) { + if (data->windowlist[i] != NULL && + data->windowlist[i]->flash_cancel_time && + SDL_GetTicks() >= data->windowlist[i]->flash_cancel_time) { + X11_FlashWindow(_this, data->windowlist[i]->window, SDL_FLASH_CANCEL); + } + } + + if (data->xinput_hierarchy_changed) { + X11_Xinput2UpdateDevices(_this, false); + data->xinput_hierarchy_changed = false; + } +} + +bool X11_SuspendScreenSaver(SDL_VideoDevice *_this) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER + SDL_VideoData *data = _this->internal; + int dummy; + int major_version, minor_version; +#endif // SDL_VIDEO_DRIVER_X11_XSCRNSAVER + +#ifdef SDL_USE_LIBDBUS + if (SDL_DBus_ScreensaverInhibit(_this->suspend_screensaver)) { + return true; + } + + if (_this->suspend_screensaver) { + SDL_DBus_ScreensaverTickle(); + } +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER + if (SDL_X11_HAVE_XSS) { + // X11_XScreenSaverSuspend was introduced in MIT-SCREEN-SAVER 1.1 + if (!X11_XScreenSaverQueryExtension(data->display, &dummy, &dummy) || + !X11_XScreenSaverQueryVersion(data->display, + &major_version, &minor_version) || + major_version < 1 || (major_version == 1 && minor_version < 1)) { + return SDL_Unsupported(); + } + + X11_XScreenSaverSuspend(data->display, _this->suspend_screensaver); + X11_XResetScreenSaver(data->display); + return true; + } +#endif + return SDL_Unsupported(); +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11events.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11events.h new file mode 100644 index 0000000..bb76f83 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11events.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11events_h_ +#define SDL_x11events_h_ + +extern void X11_PumpEvents(SDL_VideoDevice *_this); +extern int X11_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS); +extern void X11_SendWakeupEvent(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_SuspendScreenSaver(SDL_VideoDevice *_this); +extern void X11_ReconcileKeyboardState(SDL_VideoDevice *_this); +extern void X11_GetBorderValues(SDL_WindowData *data); +extern Uint64 X11_GetEventTimestamp(unsigned long time); +extern void X11_HandleKeyEvent(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_KeyboardID keyboardID, XEvent *xevent); +extern void X11_HandleButtonPress(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_MouseID mouseID, int button, float x, float y, unsigned long time); +extern void X11_HandleButtonRelease(SDL_VideoDevice *_this, SDL_WindowData *windowdata, SDL_MouseID mouseID, int button, unsigned long time); +extern SDL_WindowData *X11_FindWindow(SDL_VideoDevice *_this, Window window); +extern bool X11_ProcessHitTest(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y, bool force_new_result); +extern bool X11_TriggerHitTestAction(SDL_VideoDevice *_this, SDL_WindowData *data, const float x, const float y); + +#endif // SDL_x11events_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.c new file mode 100644 index 0000000..12642cc --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.c @@ -0,0 +1,261 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" +#include "SDL_x11framebuffer.h" +#include "SDL_x11xsync.h" + +#ifndef NO_SHARED_MEMORY + +// Shared memory error handler routine +static int shm_error; +static int (*X_handler)(Display *, XErrorEvent *) = NULL; +static int shm_errhandler(Display *d, XErrorEvent *e) +{ + if (e->error_code == BadAccess) { + shm_error = True; + return 0; + } + return X_handler(d, e); +} + +static bool have_mitshm(Display *dpy) +{ + // Only use shared memory on local X servers + return X11_XShmQueryExtension(dpy) ? SDL_X11_HAVE_SHM : false; +} + +#endif // !NO_SHARED_MEMORY + +bool X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, + void **pixels, int *pitch) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + XGCValues gcv; + XVisualInfo vinfo; + int w, h; + + SDL_GetWindowSizeInPixels(window, &w, &h); + + // Free the old framebuffer surface + X11_DestroyWindowFramebuffer(_this, window); + + // Create the graphics context for drawing + gcv.graphics_exposures = False; + data->gc = X11_XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); + if (!data->gc) { + return SDL_SetError("Couldn't create graphics context"); + } + + // Find out the pixel format and depth + if (!X11_GetVisualInfoFromVisual(display, data->visual, &vinfo)) { + return SDL_SetError("Couldn't get window visual information"); + } + + *format = X11_GetPixelFormatFromVisualInfo(display, &vinfo); + if (*format == SDL_PIXELFORMAT_UNKNOWN) { + return SDL_SetError("Unknown window pixel format"); + } + + // Calculate pitch + *pitch = (((w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); + + // Create the actual image +#ifndef NO_SHARED_MEMORY + if (have_mitshm(display)) { + XShmSegmentInfo *shminfo = &data->shminfo; + + shminfo->shmid = shmget(IPC_PRIVATE, (size_t)h * (*pitch), IPC_CREAT | 0777); + if (shminfo->shmid >= 0) { + shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0); + shminfo->readOnly = False; + if (shminfo->shmaddr != (char *)-1) { + shm_error = False; + X_handler = X11_XSetErrorHandler(shm_errhandler); + X11_XShmAttach(display, shminfo); + X11_XSync(display, False); + X11_XSetErrorHandler(X_handler); + if (shm_error) { + shmdt(shminfo->shmaddr); + } + } else { + shm_error = True; + } + shmctl(shminfo->shmid, IPC_RMID, NULL); + } else { + shm_error = True; + } + if (!shm_error) { + data->ximage = X11_XShmCreateImage(display, data->visual, + vinfo.depth, ZPixmap, + shminfo->shmaddr, shminfo, + w, h); + if (!data->ximage) { + X11_XShmDetach(display, shminfo); + X11_XSync(display, False); + shmdt(shminfo->shmaddr); + } else { + // Done! + data->ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) ? MSBFirst : LSBFirst; + data->use_mitshm = true; + *pixels = shminfo->shmaddr; + return true; + } + } + } +#endif // not NO_SHARED_MEMORY + + *pixels = SDL_malloc((size_t)h * (*pitch)); + if (!*pixels) { + return false; + } + + data->ximage = X11_XCreateImage(display, data->visual, + vinfo.depth, ZPixmap, 0, (char *)(*pixels), + w, h, 32, 0); + if (!data->ximage) { + SDL_free(*pixels); + return SDL_SetError("Couldn't create XImage"); + } + data->ximage->byte_order = (SDL_BYTEORDER == SDL_BIG_ENDIAN) ? MSBFirst : LSBFirst; + return true; +} + +bool X11_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, + int numrects) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + int i; + int x, y, w, h; + int window_w, window_h; + + SDL_GetWindowSizeInPixels(window, &window_w, &window_h); + +#ifndef NO_SHARED_MEMORY + if (data->use_mitshm) { + for (i = 0; i < numrects; ++i) { + x = rects[i].x; + y = rects[i].y; + w = rects[i].w; + h = rects[i].h; + + if (w <= 0 || h <= 0 || (x + w) <= 0 || (y + h) <= 0) { + // Clipped? + continue; + } + if (x < 0) { + x += w; + w += rects[i].x; + } + if (y < 0) { + y += h; + h += rects[i].y; + } + if (x + w > window_w) { + w = window_w - x; + } + if (y + h > window_h) { + h = window_h - y; + } + + X11_XShmPutImage(display, data->xwindow, data->gc, data->ximage, + x, y, x, y, w, h, False); + } + } else +#endif // !NO_SHARED_MEMORY + { + for (i = 0; i < numrects; ++i) { + x = rects[i].x; + y = rects[i].y; + w = rects[i].w; + h = rects[i].h; + + if (w <= 0 || h <= 0 || (x + w) <= 0 || (y + h) <= 0) { + // Clipped? + continue; + } + if (x < 0) { + x += w; + w += rects[i].x; + } + if (y < 0) { + y += h; + h += rects[i].y; + } + if (x + w > window_w) { + w = window_w - x; + } + if (y + h > window_h) { + h = window_h - y; + } + + X11_XPutImage(display, data->xwindow, data->gc, data->ximage, + x, y, x, y, w, h); + } + } + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + X11_HandlePresent(data->window); +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + + X11_XSync(display, False); + + return true; +} + +void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display; + + if (!data) { + // The window wasn't fully initialized + return; + } + + display = data->videodata->display; + + if (data->ximage) { + XDestroyImage(data->ximage); + +#ifndef NO_SHARED_MEMORY + if (data->use_mitshm) { + X11_XShmDetach(display, &data->shminfo); + X11_XSync(display, False); + shmdt(data->shminfo.shmaddr); + data->use_mitshm = false; + } +#endif // !NO_SHARED_MEMORY + + data->ximage = NULL; + } + if (data->gc) { + X11_XFreeGC(display, data->gc); + data->gc = NULL; + } +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.h new file mode 100644 index 0000000..08feda4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11framebuffer.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_x11framebuffer_h_ +#define SDL_x11framebuffer_h_ + +#include "SDL_internal.h" + +extern bool X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, + SDL_PixelFormat *format, + void **pixels, int *pitch); +extern bool X11_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, + const SDL_Rect *rects, int numrects); +extern void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_x11framebuffer_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.c new file mode 100644 index 0000000..c48e829 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.c @@ -0,0 +1,789 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" + +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_scancode_tables_c.h" + +#include +#include + +#include "../../events/imKStoUCS.h" +#include "../../events/SDL_keysym_to_scancode_c.h" +#include "../../events/SDL_keysym_to_keycode_c.h" + +#ifdef X_HAVE_UTF8_STRING +#include +#endif + +static SDL_ScancodeTable scancode_set[] = { + SDL_SCANCODE_TABLE_DARWIN, + SDL_SCANCODE_TABLE_XFREE86_1, + SDL_SCANCODE_TABLE_XFREE86_2, + SDL_SCANCODE_TABLE_XVNC, +}; + +static bool X11_ScancodeIsRemappable(SDL_Scancode scancode) +{ + /* + * XKB remappings can assign different keysyms for these scancodes, but + * as these keys are in fixed positions, the scancodes themselves shouldn't + * be switched. Mark them as not being remappable. + */ + switch (scancode) { + case SDL_SCANCODE_ESCAPE: + case SDL_SCANCODE_CAPSLOCK: + case SDL_SCANCODE_NUMLOCKCLEAR: + case SDL_SCANCODE_LSHIFT: + case SDL_SCANCODE_RSHIFT: + case SDL_SCANCODE_LCTRL: + case SDL_SCANCODE_RCTRL: + case SDL_SCANCODE_LALT: + case SDL_SCANCODE_RALT: + case SDL_SCANCODE_LGUI: + case SDL_SCANCODE_RGUI: + return false; + default: + return true; + } +} + +// This function only correctly maps letters and numbers for keyboards in US QWERTY layout +static SDL_Scancode X11_KeyCodeToSDLScancode(SDL_VideoDevice *_this, KeyCode keycode) +{ + const KeySym keysym = X11_KeyCodeToSym(_this, keycode, 0, 0); + + if (keysym == NoSymbol) { + return SDL_SCANCODE_UNKNOWN; + } + + return SDL_GetScancodeFromKeySym(keysym, keycode); +} + +KeySym X11_KeyCodeToSym(SDL_VideoDevice *_this, KeyCode keycode, unsigned char group, unsigned int mod_mask) +{ + SDL_VideoData *data = _this->internal; + KeySym keysym; + unsigned int mods_ret[16]; + + SDL_zero(mods_ret); + +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM + if (data->xkb.desc_ptr) { + int num_groups = XkbKeyNumGroups(data->xkb.desc_ptr, keycode); + unsigned char info = XkbKeyGroupInfo(data->xkb.desc_ptr, keycode); + + if (num_groups && group >= num_groups) { + + int action = XkbOutOfRangeGroupAction(info); + + if (action == XkbRedirectIntoRange) { + group = XkbOutOfRangeGroupNumber(info); + if (group >= num_groups) { + group = 0; + } + } else if (action == XkbClampIntoRange) { + group = num_groups - 1; + } else { + group %= num_groups; + } + } + + if (X11_XkbLookupKeySym(data->display, keycode, XkbBuildCoreState(mod_mask, group), mods_ret, &keysym) == NoSymbol) { + keysym = NoSymbol; + } + } else +#endif + { + // TODO: Handle groups and modifiers on the legacy path. + keysym = X11_XKeycodeToKeysym(data->display, keycode, 0); + } + + return keysym; +} + +bool X11_InitKeyboard(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + int i = 0; + int j = 0; + int min_keycode, max_keycode; + struct + { + SDL_Scancode scancode; + KeySym keysym; + int value; + } fingerprint[] = { + { SDL_SCANCODE_HOME, XK_Home, 0 }, + { SDL_SCANCODE_PAGEUP, XK_Prior, 0 }, + { SDL_SCANCODE_UP, XK_Up, 0 }, + { SDL_SCANCODE_LEFT, XK_Left, 0 }, + { SDL_SCANCODE_DELETE, XK_Delete, 0 }, + { SDL_SCANCODE_KP_ENTER, XK_KP_Enter, 0 }, + }; + int best_distance; + int best_index; + int distance; + Bool xkb_repeat = 0; + +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM + { + int xkb_major = XkbMajorVersion; + int xkb_minor = XkbMinorVersion; + + if (X11_XkbQueryExtension(data->display, NULL, &data->xkb.event, NULL, &xkb_major, &xkb_minor)) { + data->xkb.desc_ptr = X11_XkbGetMap(data->display, XkbAllClientInfoMask, XkbUseCoreKbd); + } + + // This will remove KeyRelease events for held keys + X11_XkbSetDetectableAutoRepeat(data->display, True, &xkb_repeat); + } +#endif + + // Open a connection to the X input manager +#ifdef X_HAVE_UTF8_STRING + if (SDL_X11_HAVE_UTF8) { + /* Set the locale, and call XSetLocaleModifiers before XOpenIM so that + Compose keys will work correctly. */ + char *prev_locale = setlocale(LC_ALL, NULL); + char *prev_xmods = X11_XSetLocaleModifiers(NULL); + + if (prev_locale) { + prev_locale = SDL_strdup(prev_locale); + } + + if (prev_xmods) { + prev_xmods = SDL_strdup(prev_xmods); + } + + (void)setlocale(LC_ALL, ""); + X11_XSetLocaleModifiers(""); + + data->im = X11_XOpenIM(data->display, NULL, NULL, NULL); + + /* Reset the locale + X locale modifiers back to how they were, + locale first because the X locale modifiers depend on it. */ + (void)setlocale(LC_ALL, prev_locale); + X11_XSetLocaleModifiers(prev_xmods); + + if (prev_locale) { + SDL_free(prev_locale); + } + + if (prev_xmods) { + SDL_free(prev_xmods); + } + } +#endif + // Try to determine which scancodes are being used based on fingerprint + best_distance = SDL_arraysize(fingerprint) + 1; + best_index = -1; + X11_XDisplayKeycodes(data->display, &min_keycode, &max_keycode); + for (i = 0; i < SDL_arraysize(fingerprint); ++i) { + fingerprint[i].value = X11_XKeysymToKeycode(data->display, fingerprint[i].keysym) - min_keycode; + } + for (i = 0; i < SDL_arraysize(scancode_set); ++i) { + int table_size; + const SDL_Scancode *table = SDL_GetScancodeTable(scancode_set[i], &table_size); + + distance = 0; + for (j = 0; j < SDL_arraysize(fingerprint); ++j) { + if (fingerprint[j].value < 0 || fingerprint[j].value >= table_size) { + distance += 1; + } else if (table[fingerprint[j].value] != fingerprint[j].scancode) { + distance += 1; + } + } + if (distance < best_distance) { + best_distance = distance; + best_index = i; + } + } + if (best_index < 0 || best_distance > 2) { + // This is likely to be SDL_SCANCODE_TABLE_XFREE86_2 with remapped keys, double check a rarely remapped value + int fingerprint_value = X11_XKeysymToKeycode(data->display, 0x1008FF5B /* XF86Documents */) - min_keycode; + if (fingerprint_value == 235) { + for (i = 0; i < SDL_arraysize(scancode_set); ++i) { + if (scancode_set[i] == SDL_SCANCODE_TABLE_XFREE86_2) { + best_index = i; + best_distance = 0; + break; + } + } + } + } + if (best_index >= 0 && best_distance <= 2) { + int table_size; + const SDL_Scancode *table = SDL_GetScancodeTable(scancode_set[best_index], &table_size); + +#ifdef DEBUG_KEYBOARD + SDL_Log("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d", best_index, min_keycode, max_keycode, table_size); +#endif + // This should never happen, but just in case... + if (table_size > (SDL_arraysize(data->key_layout) - min_keycode)) { + table_size = (SDL_arraysize(data->key_layout) - min_keycode); + } + SDL_memcpy(&data->key_layout[min_keycode], table, sizeof(SDL_Scancode) * table_size); + + /* Scancodes represent physical locations on the keyboard, unaffected by keyboard mapping. + However, there are a number of extended scancodes that have no standard location, so use + the X11 mapping for all non-character keys. + */ + for (i = min_keycode; i <= max_keycode; ++i) { + SDL_Scancode scancode = X11_KeyCodeToSDLScancode(_this, i); +#ifdef DEBUG_KEYBOARD + { + KeySym sym; + sym = X11_KeyCodeToSym(_this, (KeyCode)i, 0); + SDL_Log("code = %d, sym = 0x%X (%s) ", i - min_keycode, + (unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym)); + } +#endif + if (scancode == data->key_layout[i]) { + continue; + } + if ((SDL_GetKeymapKeycode(NULL, scancode, SDL_KMOD_NONE) & (SDLK_SCANCODE_MASK | SDLK_EXTENDED_MASK)) && X11_ScancodeIsRemappable(scancode)) { + // Not a character key and the scancode is safe to remap +#ifdef DEBUG_KEYBOARD + SDL_Log("Changing scancode, was %d (%s), now %d (%s)", data->key_layout[i], SDL_GetScancodeName(data->key_layout[i]), scancode, SDL_GetScancodeName(scancode)); +#endif + data->key_layout[i] = scancode; + } + } + } else { +#ifdef DEBUG_SCANCODES + SDL_Log("Keyboard layout unknown, please report the following to the SDL forums/mailing list (https://discourse.libsdl.org/):"); +#endif + + // Determine key_layout - only works on US QWERTY layout + for (i = min_keycode; i <= max_keycode; ++i) { + SDL_Scancode scancode = X11_KeyCodeToSDLScancode(_this, i); +#ifdef DEBUG_SCANCODES + { + KeySym sym; + sym = X11_KeyCodeToSym(_this, (KeyCode)i, 0); + SDL_Log("code = %d, sym = 0x%X (%s) ", i - min_keycode, + (unsigned int)sym, sym == NoSymbol ? "NoSymbol" : X11_XKeysymToString(sym)); + } + if (scancode == SDL_SCANCODE_UNKNOWN) { + SDL_Log("scancode not found"); + } else { + SDL_Log("scancode = %d (%s)", scancode, SDL_GetScancodeName(scancode)); + } +#endif + data->key_layout[i] = scancode; + } + } + + X11_UpdateKeymap(_this, false); + + SDL_SetScancodeName(SDL_SCANCODE_APPLICATION, "Menu"); + + X11_ReconcileKeyboardState(_this); + + return true; +} + +static unsigned X11_GetNumLockModifierMask(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + unsigned num_mask = 0; + int i, j; + XModifierKeymap *xmods; + unsigned n; + + xmods = X11_XGetModifierMapping(display); + n = xmods->max_keypermod; + for (i = 3; i < 8; i++) { + for (j = 0; j < n; j++) { + KeyCode kc = xmods->modifiermap[i * n + j]; + if (videodata->key_layout[kc] == SDL_SCANCODE_NUMLOCKCLEAR) { + num_mask = 1 << i; + break; + } + } + } + X11_XFreeModifiermap(xmods); + + return num_mask; +} + +static unsigned X11_GetScrollLockModifierMask(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + unsigned num_mask = 0; + int i, j; + XModifierKeymap *xmods; + unsigned n; + + xmods = X11_XGetModifierMapping(display); + n = xmods->max_keypermod; + for (i = 3; i < 8; i++) { + for (j = 0; j < n; j++) { + KeyCode kc = xmods->modifiermap[i * n + j]; + if (videodata->key_layout[kc] == SDL_SCANCODE_SCROLLLOCK) { + num_mask = 1 << i; + break; + } + } + } + X11_XFreeModifiermap(xmods); + + return num_mask; +} + +void X11_UpdateKeymap(SDL_VideoDevice *_this, bool send_event) +{ + struct Keymod_masks + { + SDL_Keymod sdl_mask; + unsigned int xkb_mask; + } const keymod_masks[] = { + { SDL_KMOD_NONE, 0 }, + { SDL_KMOD_SHIFT, ShiftMask }, + { SDL_KMOD_CAPS, LockMask }, + { SDL_KMOD_SHIFT | SDL_KMOD_CAPS, ShiftMask | LockMask }, + { SDL_KMOD_MODE, Mod5Mask }, + { SDL_KMOD_MODE | SDL_KMOD_SHIFT, Mod5Mask | ShiftMask }, + { SDL_KMOD_MODE | SDL_KMOD_CAPS, Mod5Mask | LockMask }, + { SDL_KMOD_MODE | SDL_KMOD_SHIFT | SDL_KMOD_CAPS, Mod5Mask | ShiftMask | LockMask }, + { SDL_KMOD_LEVEL5, Mod3Mask }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_SHIFT, Mod3Mask | ShiftMask }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_CAPS, Mod3Mask | LockMask }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_SHIFT | SDL_KMOD_CAPS, Mod3Mask | ShiftMask | LockMask }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE, Mod5Mask | Mod3Mask }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE | SDL_KMOD_SHIFT, Mod3Mask | Mod5Mask | ShiftMask }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE | SDL_KMOD_CAPS, Mod3Mask | Mod5Mask | LockMask }, + { SDL_KMOD_LEVEL5 | SDL_KMOD_MODE | SDL_KMOD_SHIFT | SDL_KMOD_CAPS, Mod3Mask | Mod5Mask | ShiftMask | LockMask } + }; + + SDL_VideoData *data = _this->internal; + SDL_Scancode scancode; + SDL_Keymap *keymap = SDL_CreateKeymap(); + +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM + if (data->xkb.desc_ptr) { + XkbStateRec state; + X11_XkbGetUpdatedMap(data->display, XkbAllClientInfoMask, data->xkb.desc_ptr); + + if (X11_XkbGetState(data->display, XkbUseCoreKbd, &state) == Success) { + data->xkb.current_group = state.group; + } + } +#endif + + for (int m = 0; m < SDL_arraysize(keymod_masks); ++m) { + for (int i = 0; i < SDL_arraysize(data->key_layout); ++i) { + // Make sure this is a valid scancode + scancode = data->key_layout[i]; + if (scancode == SDL_SCANCODE_UNKNOWN) { + continue; + } + + const KeySym keysym = X11_KeyCodeToSym(_this, i, data->xkb.current_group, keymod_masks[m].xkb_mask); + + if (keysym != NoSymbol) { + SDL_Keycode keycode = SDL_GetKeyCodeFromKeySym(keysym, i, keymod_masks[m].sdl_mask); + + if (!keycode) { + switch (scancode) { + case SDL_SCANCODE_RETURN: + keycode = SDLK_RETURN; + break; + case SDL_SCANCODE_ESCAPE: + keycode = SDLK_ESCAPE; + break; + case SDL_SCANCODE_BACKSPACE: + keycode = SDLK_BACKSPACE; + break; + case SDL_SCANCODE_DELETE: + keycode = SDLK_DELETE; + break; + default: + keycode = SDL_SCANCODE_TO_KEYCODE(scancode); + break; + } + } + + SDL_SetKeymapEntry(keymap, scancode, keymod_masks[m].sdl_mask, keycode); + } + } + } + + data->xkb.numlock_mask = X11_GetNumLockModifierMask(_this); + data->xkb.scrolllock_mask = X11_GetScrollLockModifierMask(_this); + SDL_SetKeymap(keymap, send_event); +} + +void X11_QuitKeyboard(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM + if (data->xkb.desc_ptr) { + X11_XkbFreeKeyboard(data->xkb.desc_ptr, 0, True); + data->xkb.desc_ptr = NULL; + } +#endif +} + +void X11_ClearComposition(SDL_WindowData *data) +{ + if (data->preedit_length > 0) { + data->preedit_text[0] = '\0'; + data->preedit_length = 0; + } + + if (data->ime_needs_clear_composition) { + SDL_SendEditingText("", 0, 0); + data->ime_needs_clear_composition = false; + } +} + +static void X11_SendEditingEvent(SDL_WindowData *data) +{ + if (data->preedit_length == 0) { + X11_ClearComposition(data); + return; + } + + bool in_highlight = false; + int start = -1, length = 0, i; + for (i = 0; i < data->preedit_length; ++i) { + if (data->preedit_feedback[i] & (XIMReverse | XIMHighlight)) { + if (start < 0) { + start = i; + in_highlight = true; + } + } else if (in_highlight) { + // Found the end of the highlight + break; + } + } + if (in_highlight) { + length = (i - start); + } else { + start = SDL_clamp(data->preedit_cursor, 0, data->preedit_length); + } + SDL_SendEditingText(data->preedit_text, start, length); + + data->ime_needs_clear_composition = true; +} + +static int preedit_start_callback(XIC xic, XPointer client_data, XPointer call_data) +{ + // No limit on preedit text length + return -1; +} + +static void preedit_done_callback(XIC xic, XPointer client_data, XPointer call_data) +{ +} + +static void preedit_draw_callback(XIC xic, XPointer client_data, XIMPreeditDrawCallbackStruct *call_data) +{ + SDL_WindowData *data = (SDL_WindowData *)client_data; + int chg_first = SDL_clamp(call_data->chg_first, 0, data->preedit_length); + int chg_length = SDL_clamp(call_data->chg_length, 0, data->preedit_length - chg_first); + + const char *start = data->preedit_text; + if (chg_length > 0) { + // Delete text in range + for (int i = 0; start && *start && i < chg_first; ++i) { + SDL_StepUTF8(&start, NULL); + } + + const char *end = start; + for (int i = 0; end && *end && i < chg_length; ++i) { + SDL_StepUTF8(&end, NULL); + } + + if (end > start) { + SDL_memmove((char *)start, end, SDL_strlen(end) + 1); + if ((chg_first + chg_length) > data->preedit_length) { + SDL_memmove(&data->preedit_feedback[chg_first], &data->preedit_feedback[chg_first + chg_length], (data->preedit_length - chg_first - chg_length) * sizeof(*data->preedit_feedback)); + } + } + data->preedit_length -= chg_length; + } + + XIMText *text = call_data->text; + if (text) { + // Insert text in range + SDL_assert(!text->encoding_is_wchar); + + // The text length isn't calculated as directed by the spec, recalculate it now + if (text->string.multi_byte) { + text->length = SDL_utf8strlen(text->string.multi_byte); + } + + size_t string_size = SDL_strlen(text->string.multi_byte); + size_t size = string_size + 1; + if (data->preedit_text) { + size += SDL_strlen(data->preedit_text); + } + char *preedit_text = (char *)SDL_malloc(size * sizeof(*preedit_text)); + if (preedit_text) { + size_t pre_size = (start - data->preedit_text); + size_t post_size = start ? SDL_strlen(start) : 0; + if (pre_size > 0) { + SDL_memcpy(&preedit_text[0], data->preedit_text, pre_size); + } + SDL_memcpy(&preedit_text[pre_size], text->string.multi_byte, string_size); + if (post_size > 0) { + SDL_memcpy(&preedit_text[pre_size + string_size], start, post_size); + } + preedit_text[size - 1] = '\0'; + } + + size_t feedback_size = data->preedit_length + text->length; + XIMFeedback *feedback = (XIMFeedback *)SDL_malloc(feedback_size * sizeof(*feedback)); + if (feedback) { + size_t pre_size = (size_t)chg_first; + size_t post_size = (size_t)data->preedit_length - pre_size; + if (pre_size > 0) { + SDL_memcpy(&feedback[0], data->preedit_feedback, pre_size * sizeof(*feedback)); + } + SDL_memcpy(&feedback[pre_size], text->feedback, text->length * sizeof(*feedback)); + if (post_size > 0) { + SDL_memcpy(&feedback[pre_size + text->length], &data->preedit_feedback[pre_size], post_size * sizeof(*feedback)); + } + } + + if (preedit_text && feedback) { + SDL_free(data->preedit_text); + data->preedit_text = preedit_text; + + SDL_free(data->preedit_feedback); + data->preedit_feedback = feedback; + + data->preedit_length += text->length; + } else { + SDL_free(preedit_text); + SDL_free(feedback); + } + } + + data->preedit_cursor = call_data->caret; + +#ifdef DEBUG_XIM + if (call_data->chg_length > 0) { + SDL_Log("Draw callback deleted %d characters at %d", call_data->chg_length, call_data->chg_first); + } + if (text) { + SDL_Log("Draw callback inserted %s at %d, caret: %d", text->string.multi_byte, call_data->chg_first, call_data->caret); + } + SDL_Log("Pre-edit text: %s", data->preedit_text); +#endif + + X11_SendEditingEvent(data); +} + +static void preedit_caret_callback(XIC xic, XPointer client_data, XIMPreeditCaretCallbackStruct *call_data) +{ + SDL_WindowData *data = (SDL_WindowData *)client_data; + + switch (call_data->direction) { + case XIMAbsolutePosition: + if (call_data->position != data->preedit_cursor) { + data->preedit_cursor = call_data->position; + X11_SendEditingEvent(data); + } + break; + case XIMDontChange: + break; + default: + // Not currently supported + break; + } +} + +void X11_CreateInputContext(SDL_WindowData *data) +{ +#ifdef X_HAVE_UTF8_STRING + SDL_VideoData *videodata = data->videodata; + + if (SDL_X11_HAVE_UTF8 && videodata->im) { + const char *hint = SDL_GetHint(SDL_HINT_IME_IMPLEMENTED_UI); + if (hint && SDL_strstr(hint, "composition")) { + XIMCallback draw_callback; + draw_callback.client_data = (XPointer)data; + draw_callback.callback = (XIMProc)preedit_draw_callback; + + XIMCallback start_callback; + start_callback.client_data = (XPointer)data; + start_callback.callback = (XIMProc)preedit_start_callback; + + XIMCallback done_callback; + done_callback.client_data = (XPointer)data; + done_callback.callback = (XIMProc)preedit_done_callback; + + XIMCallback caret_callback; + caret_callback.client_data = (XPointer)data; + caret_callback.callback = (XIMProc)preedit_caret_callback; + + XVaNestedList attr = X11_XVaCreateNestedList(0, + XNPreeditStartCallback, &start_callback, + XNPreeditDoneCallback, &done_callback, + XNPreeditDrawCallback, &draw_callback, + XNPreeditCaretCallback, &caret_callback, + NULL); + if (attr) { + data->ic = X11_XCreateIC(videodata->im, + XNInputStyle, XIMPreeditCallbacks | XIMStatusCallbacks, + XNPreeditAttributes, attr, + XNClientWindow, data->xwindow, + NULL); + X11_XFree(attr); + } + } + if (!data->ic) { + data->ic = X11_XCreateIC(videodata->im, + XNInputStyle, XIMPreeditNothing | XIMStatusNothing, + XNClientWindow, data->xwindow, + NULL); + } + data->xim_spot.x = -1; + data->xim_spot.y = -1; + } +#endif // X_HAVE_UTF8_STRING +} + +static void X11_ResetXIM(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef X_HAVE_UTF8_STRING + SDL_WindowData *data = window->internal; + + if (data && data->ic) { + // Clear any partially entered dead keys + char *contents = X11_Xutf8ResetIC(data->ic); + if (contents) { + X11_XFree(contents); + } + } +#endif // X_HAVE_UTF8_STRING +} + +bool X11_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + X11_ResetXIM(_this, window); + + return X11_UpdateTextInputArea(_this, window); +} + +bool X11_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + X11_ResetXIM(_this, window); + return true; +} + +bool X11_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef X_HAVE_UTF8_STRING + SDL_WindowData *data = window->internal; + + if (data && data->ic) { + XPoint spot; + spot.x = window->text_input_rect.x + window->text_input_cursor; + spot.y = window->text_input_rect.y + window->text_input_rect.h; + if (spot.x != data->xim_spot.x || spot.y != data->xim_spot.y) { + XVaNestedList attr = X11_XVaCreateNestedList(0, XNSpotLocation, &spot, NULL); + if (attr) { + X11_XSetICValues(data->ic, XNPreeditAttributes, attr, NULL); + X11_XFree(attr); + } + SDL_copyp(&data->xim_spot, &spot); + } + } +#endif + return true; +} + +bool X11_HasScreenKeyboardSupport(SDL_VideoDevice *_this) +{ + SDL_VideoData *videodata = _this->internal; + return videodata->is_steam_deck; +} + +void X11_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props) +{ + SDL_VideoData *videodata = _this->internal; + + if (videodata->is_steam_deck) { + /* For more documentation of the URL parameters, see: + * https://partner.steamgames.com/doc/api/ISteamUtils#ShowFloatingGamepadTextInput + */ + const int k_EFloatingGamepadTextInputModeModeSingleLine = 0; // Enter dismisses the keyboard + const int k_EFloatingGamepadTextInputModeModeMultipleLines = 1; // User needs to explicitly dismiss the keyboard + const int k_EFloatingGamepadTextInputModeModeEmail = 2; // Keyboard is displayed in a special mode that makes it easier to enter emails + const int k_EFloatingGamepadTextInputModeModeNumeric = 3; // Numeric keypad is shown + char deeplink[128]; + int mode; + + switch (SDL_GetTextInputType(props)) { + case SDL_TEXTINPUT_TYPE_TEXT_EMAIL: + mode = k_EFloatingGamepadTextInputModeModeEmail; + break; + case SDL_TEXTINPUT_TYPE_NUMBER: + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_HIDDEN: + case SDL_TEXTINPUT_TYPE_NUMBER_PASSWORD_VISIBLE: + mode = k_EFloatingGamepadTextInputModeModeNumeric; + break; + default: + if (SDL_GetTextInputMultiline(props)) { + mode = k_EFloatingGamepadTextInputModeModeMultipleLines; + } else { + mode = k_EFloatingGamepadTextInputModeModeSingleLine; + } + break; + } + (void)SDL_snprintf(deeplink, sizeof(deeplink), + "steam://open/keyboard?XPosition=0&YPosition=0&Width=0&Height=0&Mode=%d", + mode); + SDL_OpenURL(deeplink); + videodata->steam_keyboard_open = true; + } +} + +void X11_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = _this->internal; + + if (videodata->is_steam_deck) { + SDL_OpenURL("steam://close/keyboard"); + videodata->steam_keyboard_open = false; + } +} + +bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_VideoData *videodata = _this->internal; + + return videodata->steam_keyboard_open; +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.h new file mode 100644 index 0000000..a6cd2f7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11keyboard.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11keyboard_h_ +#define SDL_x11keyboard_h_ + +extern bool X11_InitKeyboard(SDL_VideoDevice *_this); +extern void X11_UpdateKeymap(SDL_VideoDevice *_this, bool send_event); +extern void X11_QuitKeyboard(SDL_VideoDevice *_this); +extern void X11_CreateInputContext(SDL_WindowData *data); +extern void X11_ClearComposition(SDL_WindowData *data); +extern bool X11_StartTextInput(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern bool X11_StopTextInput(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_UpdateTextInputArea(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_HasScreenKeyboardSupport(SDL_VideoDevice *_this); +extern void X11_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID props); +extern void X11_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_IsScreenKeyboardShown(SDL_VideoDevice *_this, SDL_Window *window); +extern KeySym X11_KeyCodeToSym(SDL_VideoDevice *_this, KeyCode, unsigned char group, unsigned int mod_mask); + +#endif // SDL_x11keyboard_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.c new file mode 100644 index 0000000..8aa1c6a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.c @@ -0,0 +1,887 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" +#include "SDL_x11dyn.h" +#include "SDL_x11messagebox.h" + +#include +#include + +#define SDL_FORK_MESSAGEBOX 1 +#define SDL_SET_LOCALE 1 + +#if SDL_FORK_MESSAGEBOX +#include +#include +#include +#include +#endif + +#define MAX_BUTTONS 8 // Maximum number of buttons supported +#define MIN_BUTTON_WIDTH 64 // Minimum button width +#define MIN_DIALOG_WIDTH 200 // Minimum dialog width +#define MIN_DIALOG_HEIGHT 100 // Minimum dialog height + +static const char g_MessageBoxFontLatin1[] = + "-*-*-medium-r-normal--0-120-*-*-p-0-iso8859-1"; + +static const char* g_MessageBoxFont[] = { + "-*-*-medium-r-normal--*-120-*-*-*-*-iso10646-1", // explicitly unicode (iso10646-1) + "-*-*-medium-r-*--*-120-*-*-*-*-iso10646-1", // explicitly unicode (iso10646-1) + "-misc-*-*-*-*--*-*-*-*-*-*-iso10646-1", // misc unicode (fix for some systems) + "-*-*-*-*-*--*-*-*-*-*-*-iso10646-1", // just give me anything Unicode. + "-*-*-medium-r-normal--*-120-*-*-*-*-iso8859-1", // explicitly latin1, in case low-ASCII works out. + "-*-*-medium-r-*--*-120-*-*-*-*-iso8859-1", // explicitly latin1, in case low-ASCII works out. + "-misc-*-*-*-*--*-*-*-*-*-*-iso8859-1", // misc latin1 (fix for some systems) + "-*-*-*-*-*--*-*-*-*-*-*-iso8859-1", // just give me anything latin1. + NULL +}; + +static const SDL_MessageBoxColor g_default_colors[SDL_MESSAGEBOX_COLOR_COUNT] = { + { 56, 54, 53 }, // SDL_MESSAGEBOX_COLOR_BACKGROUND, + { 209, 207, 205 }, // SDL_MESSAGEBOX_COLOR_TEXT, + { 140, 135, 129 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, + { 105, 102, 99 }, // SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, + { 205, 202, 53 }, // SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, +}; + +#define SDL_MAKE_RGB(_r, _g, _b) (((Uint32)(_r) << 16) | \ + ((Uint32)(_g) << 8) | \ + ((Uint32)(_b))) + +typedef struct SDL_MessageBoxButtonDataX11 +{ + int x, y; // Text position + int length; // Text length + int text_width; // Text width + + SDL_Rect rect; // Rectangle for entire button + + const SDL_MessageBoxButtonData *buttondata; // Button data from caller +} SDL_MessageBoxButtonDataX11; + +typedef struct TextLineData +{ + int width; // Width of this text line + int length; // String length of this text line + const char *text; // Text for this line +} TextLineData; + +typedef struct SDL_MessageBoxDataX11 +{ + Display *display; + int screen; + Window window; +#ifdef SDL_VIDEO_DRIVER_X11_XDBE + XdbeBackBuffer buf; + bool xdbe; // Whether Xdbe is present or not +#endif + long event_mask; + Atom wm_protocols; + Atom wm_delete_message; + + int dialog_width; // Dialog box width. + int dialog_height; // Dialog box height. + + XFontSet font_set; // for UTF-8 systems + XFontStruct *font_struct; // Latin1 (ASCII) fallback. + int xtext, ytext; // Text position to start drawing at. + int numlines; // Count of Text lines. + int text_height; // Height for text lines. + TextLineData *linedata; + + int *pbuttonid; // Pointer to user return buttonID value. + + int button_press_index; // Index into buttondata/buttonpos for button which is pressed (or -1). + int mouse_over_index; // Index into buttondata/buttonpos for button mouse is over (or -1). + + int numbuttons; // Count of buttons. + const SDL_MessageBoxButtonData *buttondata; + SDL_MessageBoxButtonDataX11 buttonpos[MAX_BUTTONS]; + + Uint32 color[SDL_MESSAGEBOX_COLOR_COUNT]; + + const SDL_MessageBoxData *messageboxdata; +} SDL_MessageBoxDataX11; + +// Maximum helper for ints. +static SDL_INLINE int IntMax(int a, int b) +{ + return (a > b) ? a : b; +} + +// Return width and height for a string. +static void GetTextWidthHeight(SDL_MessageBoxDataX11 *data, const char *str, int nbytes, int *pwidth, int *pheight) +{ +#ifdef X_HAVE_UTF8_STRING + if (SDL_X11_HAVE_UTF8) { + XRectangle overall_ink, overall_logical; + X11_Xutf8TextExtents(data->font_set, str, nbytes, &overall_ink, &overall_logical); + *pwidth = overall_logical.width; + *pheight = overall_logical.height; + } else +#endif + { + XCharStruct text_structure; + int font_direction, font_ascent, font_descent; + X11_XTextExtents(data->font_struct, str, nbytes, + &font_direction, &font_ascent, &font_descent, + &text_structure); + *pwidth = text_structure.width; + *pheight = text_structure.ascent + text_structure.descent; + } +} + +// Return index of button if position x,y is contained therein. +static int GetHitButtonIndex(SDL_MessageBoxDataX11 *data, int x, int y) +{ + int i; + int numbuttons = data->numbuttons; + SDL_MessageBoxButtonDataX11 *buttonpos = data->buttonpos; + + for (i = 0; i < numbuttons; i++) { + SDL_Rect *rect = &buttonpos[i].rect; + + if ((x >= rect->x) && + (x <= (rect->x + rect->w)) && + (y >= rect->y) && + (y <= (rect->y + rect->h))) { + return i; + } + } + + return -1; +} + +// Initialize SDL_MessageBoxData structure and Display, etc. +static bool X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBoxData *messageboxdata, int *pbuttonid) +{ + int i; + int numbuttons = messageboxdata->numbuttons; + const SDL_MessageBoxButtonData *buttondata = messageboxdata->buttons; + const SDL_MessageBoxColor *colorhints; + + if (numbuttons > MAX_BUTTONS) { + return SDL_SetError("Too many buttons (%d max allowed)", MAX_BUTTONS); + } + + data->dialog_width = MIN_DIALOG_WIDTH; + data->dialog_height = MIN_DIALOG_HEIGHT; + data->messageboxdata = messageboxdata; + data->buttondata = buttondata; + data->numbuttons = numbuttons; + data->pbuttonid = pbuttonid; + + data->display = X11_XOpenDisplay(NULL); + if (!data->display) { + return SDL_SetError("Couldn't open X11 display"); + } + +#ifdef X_HAVE_UTF8_STRING + if (SDL_X11_HAVE_UTF8) { + char **missing = NULL; + int num_missing = 0; + int i_font; + for (i_font = 0; g_MessageBoxFont[i_font]; ++i_font) { + data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont[i_font], + &missing, &num_missing, NULL); + if (missing) { + X11_XFreeStringList(missing); + } + if (data->font_set) { + break; + } + } + if (!data->font_set) { + return SDL_SetError("Couldn't load x11 message box font"); + } + } else +#endif + { + data->font_struct = X11_XLoadQueryFont(data->display, g_MessageBoxFontLatin1); + if (!data->font_struct) { + return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); + } + } + + if (messageboxdata->colorScheme) { + colorhints = messageboxdata->colorScheme->colors; + } else { + colorhints = g_default_colors; + } + + // Convert our SDL_MessageBoxColor r,g,b values to packed RGB format. + for (i = 0; i < SDL_MESSAGEBOX_COLOR_COUNT; i++) { + data->color[i] = SDL_MAKE_RGB(colorhints[i].r, colorhints[i].g, colorhints[i].b); + } + + return true; +} + +static int CountLinesOfText(const char *text) +{ + int result = 0; + while (text && *text) { + const char *lf = SDL_strchr(text, '\n'); + result++; // even without an endline, this counts as a line. + text = lf ? lf + 1 : NULL; + } + return result; +} + +// Calculate and initialize text and button locations. +static bool X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) +{ + int i; + int ybuttons; + int text_width_max = 0; + int button_text_height = 0; + int button_width = MIN_BUTTON_WIDTH; + const SDL_MessageBoxData *messageboxdata = data->messageboxdata; + + // Go over text and break linefeeds into separate lines. + if (messageboxdata && messageboxdata->message[0]) { + const char *text = messageboxdata->message; + const int linecount = CountLinesOfText(text); + TextLineData *plinedata = (TextLineData *)SDL_malloc(sizeof(TextLineData) * linecount); + + if (!plinedata) { + return false; + } + + data->linedata = plinedata; + data->numlines = linecount; + + for (i = 0; i < linecount; i++, plinedata++) { + const char *lf = SDL_strchr(text, '\n'); + const int length = lf ? (lf - text) : SDL_strlen(text); + int height; + + plinedata->text = text; + + GetTextWidthHeight(data, text, length, &plinedata->width, &height); + + // Text and widths are the largest we've ever seen. + data->text_height = IntMax(data->text_height, height); + text_width_max = IntMax(text_width_max, plinedata->width); + + plinedata->length = length; + if (lf && (lf > text) && (lf[-1] == '\r')) { + plinedata->length--; + } + + text += length + 1; + + // Break if there are no more linefeeds. + if (!lf) { + break; + } + } + + // Bump up the text height slightly. + data->text_height += 2; + } + + // Loop through all buttons and calculate the button widths and height. + for (i = 0; i < data->numbuttons; i++) { + int height; + + data->buttonpos[i].buttondata = &data->buttondata[i]; + data->buttonpos[i].length = SDL_strlen(data->buttondata[i].text); + + GetTextWidthHeight(data, data->buttondata[i].text, SDL_strlen(data->buttondata[i].text), + &data->buttonpos[i].text_width, &height); + + button_width = IntMax(button_width, data->buttonpos[i].text_width); + button_text_height = IntMax(button_text_height, height); + } + + if (data->numlines) { + // x,y for this line of text. + data->xtext = data->text_height; + data->ytext = data->text_height + data->text_height; + + // Bump button y down to bottom of text. + ybuttons = 3 * data->ytext / 2 + (data->numlines - 1) * data->text_height; + + // Bump the dialog box width and height up if needed. + data->dialog_width = IntMax(data->dialog_width, 2 * data->xtext + text_width_max); + data->dialog_height = IntMax(data->dialog_height, ybuttons); + } else { + // Button y starts at height of button text. + ybuttons = button_text_height; + } + + if (data->numbuttons) { + int x, y; + int width_of_buttons; + int button_spacing = button_text_height; + int button_height = 2 * button_text_height; + + // Bump button width up a bit. + button_width += button_text_height; + + // Get width of all buttons lined up. + width_of_buttons = data->numbuttons * button_width + (data->numbuttons - 1) * button_spacing; + + // Bump up dialog width and height if buttons are wider than text. + data->dialog_width = IntMax(data->dialog_width, width_of_buttons + 2 * button_spacing); + data->dialog_height = IntMax(data->dialog_height, ybuttons + 2 * button_height); + + // Location for first button. + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { + x = data->dialog_width - (data->dialog_width - width_of_buttons) / 2 - (button_width + button_spacing); + } else { + x = (data->dialog_width - width_of_buttons) / 2; + } + y = ybuttons + (data->dialog_height - ybuttons - button_height) / 2; + + for (i = 0; i < data->numbuttons; i++) { + // Button coordinates. + data->buttonpos[i].rect.x = x; + data->buttonpos[i].rect.y = y; + data->buttonpos[i].rect.w = button_width; + data->buttonpos[i].rect.h = button_height; + + // Button text coordinates. + data->buttonpos[i].x = x + (button_width - data->buttonpos[i].text_width) / 2; + data->buttonpos[i].y = y + (button_height - button_text_height - 1) / 2 + button_text_height; + + // Scoot over for next button. + if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) { + x -= button_width + button_spacing; + } else { + x += button_width + button_spacing; + } + } + } + + return true; +} + +// Free SDL_MessageBoxData data. +static void X11_MessageBoxShutdown(SDL_MessageBoxDataX11 *data) +{ + if (data->font_set) { + X11_XFreeFontSet(data->display, data->font_set); + data->font_set = NULL; + } + + if (data->font_struct) { + X11_XFreeFont(data->display, data->font_struct); + data->font_struct = NULL; + } + +#ifdef SDL_VIDEO_DRIVER_X11_XDBE + if (SDL_X11_HAVE_XDBE && data->xdbe) { + X11_XdbeDeallocateBackBufferName(data->display, data->buf); + } +#endif + + if (data->display) { + if (data->window != None) { + X11_XWithdrawWindow(data->display, data->window, data->screen); + X11_XDestroyWindow(data->display, data->window); + data->window = None; + } + + X11_XCloseDisplay(data->display); + data->display = NULL; + } + + SDL_free(data->linedata); +} + +// Create and set up our X11 dialog box indow. +static bool X11_MessageBoxCreateWindow(SDL_MessageBoxDataX11 *data) +{ + int x, y; + XSizeHints *sizehints; + XSetWindowAttributes wnd_attr; + Atom _NET_WM_WINDOW_TYPE, _NET_WM_WINDOW_TYPE_DIALOG; + Display *display = data->display; + SDL_WindowData *windowdata = NULL; + const SDL_MessageBoxData *messageboxdata = data->messageboxdata; + + if (messageboxdata->window) { + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(messageboxdata->window); + windowdata = messageboxdata->window->internal; + data->screen = displaydata->screen; + } else { + data->screen = DefaultScreen(display); + } + + data->event_mask = ExposureMask | + ButtonPressMask | ButtonReleaseMask | KeyPressMask | KeyReleaseMask | + StructureNotifyMask | FocusChangeMask | PointerMotionMask; + wnd_attr.event_mask = data->event_mask; + + data->window = X11_XCreateWindow( + display, RootWindow(display, data->screen), + 0, 0, + data->dialog_width, data->dialog_height, + 0, CopyFromParent, InputOutput, CopyFromParent, + CWEventMask, &wnd_attr); + if (data->window == None) { + return SDL_SetError("Couldn't create X window"); + } + + if (windowdata) { + Atom _NET_WM_STATE = X11_XInternAtom(display, "_NET_WM_STATE", False); + Atom stateatoms[16]; + size_t statecount = 0; + // Set some message-boxy window states when attached to a parent window... + // we skip the taskbar since this will pop to the front when the parent window is clicked in the taskbar, etc + stateatoms[statecount++] = X11_XInternAtom(display, "_NET_WM_STATE_SKIP_TASKBAR", False); + stateatoms[statecount++] = X11_XInternAtom(display, "_NET_WM_STATE_SKIP_PAGER", False); + stateatoms[statecount++] = X11_XInternAtom(display, "_NET_WM_STATE_FOCUSED", False); + stateatoms[statecount++] = X11_XInternAtom(display, "_NET_WM_STATE_MODAL", False); + SDL_assert(statecount <= SDL_arraysize(stateatoms)); + X11_XChangeProperty(display, data->window, _NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, (unsigned char *)stateatoms, statecount); + + // http://tronche.com/gui/x/icccm/sec-4.html#WM_TRANSIENT_FOR + X11_XSetTransientForHint(display, data->window, windowdata->xwindow); + } + + SDL_X11_SetWindowTitle(display, data->window, (char *)messageboxdata->title); + + // Let the window manager know this is a dialog box + _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); + _NET_WM_WINDOW_TYPE_DIALOG = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE_DIALOG", False); + X11_XChangeProperty(display, data->window, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, + PropModeReplace, + (unsigned char *)&_NET_WM_WINDOW_TYPE_DIALOG, 1); + + // Allow the window to be deleted by the window manager + data->wm_delete_message = X11_XInternAtom(display, "WM_DELETE_WINDOW", False); + X11_XSetWMProtocols(display, data->window, &data->wm_delete_message, 1); + + data->wm_protocols = X11_XInternAtom(display, "WM_PROTOCOLS", False); + + if (windowdata) { + XWindowAttributes attrib; + Window dummy; + + X11_XGetWindowAttributes(display, windowdata->xwindow, &attrib); + x = attrib.x + (attrib.width - data->dialog_width) / 2; + y = attrib.y + (attrib.height - data->dialog_height) / 3; + X11_XTranslateCoordinates(display, windowdata->xwindow, RootWindow(display, data->screen), x, y, &x, &y, &dummy); + } else { + const SDL_VideoDevice *dev = SDL_GetVideoDevice(); + if (dev && dev->displays && dev->num_displays > 0) { + const SDL_VideoDisplay *dpy = dev->displays[0]; + const SDL_DisplayData *dpydata = dpy->internal; + x = dpydata->x + ((dpy->current_mode->w - data->dialog_width) / 2); + y = dpydata->y + ((dpy->current_mode->h - data->dialog_height) / 3); + } else { // oh well. This will misposition on a multi-head setup. Init first next time. + x = (DisplayWidth(display, data->screen) - data->dialog_width) / 2; + y = (DisplayHeight(display, data->screen) - data->dialog_height) / 3; + } + } + X11_XMoveWindow(display, data->window, x, y); + + sizehints = X11_XAllocSizeHints(); + if (sizehints) { + sizehints->flags = USPosition | USSize | PMaxSize | PMinSize; + sizehints->x = x; + sizehints->y = y; + sizehints->width = data->dialog_width; + sizehints->height = data->dialog_height; + + sizehints->min_width = sizehints->max_width = data->dialog_width; + sizehints->min_height = sizehints->max_height = data->dialog_height; + + X11_XSetWMNormalHints(display, data->window, sizehints); + + X11_XFree(sizehints); + } + + X11_XMapRaised(display, data->window); + +#ifdef SDL_VIDEO_DRIVER_X11_XDBE + // Initialise a back buffer for double buffering + if (SDL_X11_HAVE_XDBE) { + int xdbe_major, xdbe_minor; + if (X11_XdbeQueryExtension(display, &xdbe_major, &xdbe_minor) != 0) { + data->xdbe = true; + data->buf = X11_XdbeAllocateBackBufferName(display, data->window, XdbeUndefined); + } else { + data->xdbe = false; + } + } +#endif + + return true; +} + +// Draw our message box. +static void X11_MessageBoxDraw(SDL_MessageBoxDataX11 *data, GC ctx) +{ + int i; + Drawable window = data->window; + Display *display = data->display; + +#ifdef SDL_VIDEO_DRIVER_X11_XDBE + if (SDL_X11_HAVE_XDBE && data->xdbe) { + window = data->buf; + X11_XdbeBeginIdiom(data->display); + } +#endif + + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_BACKGROUND]); + X11_XFillRectangle(display, window, ctx, 0, 0, data->dialog_width, data->dialog_height); + + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_TEXT]); + for (i = 0; i < data->numlines; i++) { + TextLineData *plinedata = &data->linedata[i]; + +#ifdef X_HAVE_UTF8_STRING + if (SDL_X11_HAVE_UTF8) { + X11_Xutf8DrawString(display, window, data->font_set, ctx, + data->xtext, data->ytext + i * data->text_height, + plinedata->text, plinedata->length); + } else +#endif + { + X11_XDrawString(display, window, ctx, + data->xtext, data->ytext + i * data->text_height, + plinedata->text, plinedata->length); + } + } + + for (i = 0; i < data->numbuttons; i++) { + SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[i]; + const SDL_MessageBoxButtonData *buttondata = buttondatax11->buttondata; + int border = (buttondata->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) ? 2 : 0; + int offset = ((data->mouse_over_index == i) && (data->button_press_index == data->mouse_over_index)) ? 1 : 0; + + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND]); + X11_XFillRectangle(display, window, ctx, + buttondatax11->rect.x - border, buttondatax11->rect.y - border, + buttondatax11->rect.w + 2 * border, buttondatax11->rect.h + 2 * border); + + X11_XSetForeground(display, ctx, data->color[SDL_MESSAGEBOX_COLOR_BUTTON_BORDER]); + X11_XDrawRectangle(display, window, ctx, + buttondatax11->rect.x, buttondatax11->rect.y, + buttondatax11->rect.w, buttondatax11->rect.h); + + X11_XSetForeground(display, ctx, (data->mouse_over_index == i) ? data->color[SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED] : data->color[SDL_MESSAGEBOX_COLOR_TEXT]); + +#ifdef X_HAVE_UTF8_STRING + if (SDL_X11_HAVE_UTF8) { + X11_Xutf8DrawString(display, window, data->font_set, ctx, + buttondatax11->x + offset, + buttondatax11->y + offset, + buttondata->text, buttondatax11->length); + } else +#endif + { + X11_XDrawString(display, window, ctx, + buttondatax11->x + offset, buttondatax11->y + offset, + buttondata->text, buttondatax11->length); + } + } + +#ifdef SDL_VIDEO_DRIVER_X11_XDBE + if (SDL_X11_HAVE_XDBE && data->xdbe) { + XdbeSwapInfo swap_info; + swap_info.swap_window = data->window; + swap_info.swap_action = XdbeUndefined; + X11_XdbeSwapBuffers(data->display, &swap_info, 1); + X11_XdbeEndIdiom(data->display); + } +#endif +} + +// NOLINTNEXTLINE(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef +static Bool X11_MessageBoxEventTest(Display *display, XEvent *event, XPointer arg) +{ + const SDL_MessageBoxDataX11 *data = (const SDL_MessageBoxDataX11 *)arg; + return ((event->xany.display == data->display) && (event->xany.window == data->window)) ? True : False; +} + +// Loop and handle message box event messages until something kills it. +static bool X11_MessageBoxLoop(SDL_MessageBoxDataX11 *data) +{ + GC ctx; + XGCValues ctx_vals; + bool close_dialog = false; + bool has_focus = true; + KeySym last_key_pressed = XK_VoidSymbol; + unsigned long gcflags = GCForeground | GCBackground; +#ifdef X_HAVE_UTF8_STRING + const int have_utf8 = SDL_X11_HAVE_UTF8; +#else + const int have_utf8 = 0; +#endif + + SDL_zero(ctx_vals); + ctx_vals.foreground = data->color[SDL_MESSAGEBOX_COLOR_BACKGROUND]; + ctx_vals.background = data->color[SDL_MESSAGEBOX_COLOR_BACKGROUND]; + + if (!have_utf8) { + gcflags |= GCFont; + ctx_vals.font = data->font_struct->fid; + } + + ctx = X11_XCreateGC(data->display, data->window, gcflags, &ctx_vals); + if (ctx == None) { + return SDL_SetError("Couldn't create graphics context"); + } + + data->button_press_index = -1; // Reset what button is currently depressed. + data->mouse_over_index = -1; // Reset what button the mouse is over. + + while (!close_dialog) { + XEvent e; + bool draw = true; + + // can't use XWindowEvent() because it can't handle ClientMessage events. + // can't use XNextEvent() because we only want events for this window. + X11_XIfEvent(data->display, &e, X11_MessageBoxEventTest, (XPointer)data); + + /* If X11_XFilterEvent returns True, then some input method has filtered the + event, and the client should discard the event. */ + if ((e.type != Expose) && X11_XFilterEvent(&e, None)) { + continue; + } + + switch (e.type) { + case Expose: + if (e.xexpose.count > 0) { + draw = false; + } + break; + + case FocusIn: + // Got focus. + has_focus = true; + break; + + case FocusOut: + // lost focus. Reset button and mouse info. + has_focus = false; + data->button_press_index = -1; + data->mouse_over_index = -1; + break; + + case MotionNotify: + if (has_focus) { + // Mouse moved... + const int previndex = data->mouse_over_index; + data->mouse_over_index = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); + if (data->mouse_over_index == previndex) { + draw = false; + } + } + break; + + case ClientMessage: + if (e.xclient.message_type == data->wm_protocols && + e.xclient.format == 32 && + e.xclient.data.l[0] == data->wm_delete_message) { + close_dialog = true; + } + break; + + case KeyPress: + // Store key press - we make sure in key release that we got both. + last_key_pressed = X11_XLookupKeysym(&e.xkey, 0); + break; + + case KeyRelease: + { + Uint32 mask = 0; + KeySym key = X11_XLookupKeysym(&e.xkey, 0); + + // If this is a key release for something we didn't get the key down for, then bail. + if (key != last_key_pressed) { + break; + } + + if (key == XK_Escape) { + mask = SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT; + } else if ((key == XK_Return) || (key == XK_KP_Enter)) { + mask = SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT; + } + + if (mask) { + int i; + + // Look for first button with this mask set, and return it if found. + for (i = 0; i < data->numbuttons; i++) { + SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[i]; + + if (buttondatax11->buttondata->flags & mask) { + *data->pbuttonid = buttondatax11->buttondata->buttonID; + close_dialog = true; + break; + } + } + } + break; + } + + case ButtonPress: + data->button_press_index = -1; + if (e.xbutton.button == Button1) { + // Find index of button they clicked on. + data->button_press_index = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); + } + break; + + case ButtonRelease: + // If button is released over the same button that was clicked down on, then return it. + if ((e.xbutton.button == Button1) && (data->button_press_index >= 0)) { + int button = GetHitButtonIndex(data, e.xbutton.x, e.xbutton.y); + + if (data->button_press_index == button) { + SDL_MessageBoxButtonDataX11 *buttondatax11 = &data->buttonpos[button]; + + *data->pbuttonid = buttondatax11->buttondata->buttonID; + close_dialog = true; + } + } + data->button_press_index = -1; + break; + } + + if (draw) { + // Draw our dialog box. + X11_MessageBoxDraw(data, ctx); + } + } + + X11_XFreeGC(data->display, ctx); + return true; +} + +static bool X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ + bool result = false; + SDL_MessageBoxDataX11 data; +#if SDL_SET_LOCALE + char *origlocale; +#endif + + SDL_zero(data); + + if (!SDL_X11_LoadSymbols()) { + return false; + } + +#if SDL_SET_LOCALE + origlocale = setlocale(LC_ALL, NULL); + if (origlocale) { + origlocale = SDL_strdup(origlocale); + if (!origlocale) { + return false; + } + (void)setlocale(LC_ALL, ""); + } +#endif + + // This code could get called from multiple threads maybe? + X11_XInitThreads(); + + // Initialize the return buttonID value to -1 (for error or dialogbox closed). + *buttonID = -1; + + // Init and display the message box. + if (X11_MessageBoxInit(&data, messageboxdata, buttonID) && + X11_MessageBoxInitPositions(&data) && + X11_MessageBoxCreateWindow(&data)) { + result = X11_MessageBoxLoop(&data); + } + + X11_MessageBoxShutdown(&data); + +#if SDL_SET_LOCALE + if (origlocale) { + (void)setlocale(LC_ALL, origlocale); + SDL_free(origlocale); + } +#endif + + return result; +} + +// Display an x11 message box. +bool X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID) +{ +#if SDL_FORK_MESSAGEBOX + // Use a child process to protect against setlocale(). Annoying. + pid_t pid; + int fds[2]; + int status = 0; + bool result = true; + + if (pipe(fds) == -1) { + return X11_ShowMessageBoxImpl(messageboxdata, buttonID); // oh well. + } + + pid = fork(); + if (pid == -1) { // failed + close(fds[0]); + close(fds[1]); + return X11_ShowMessageBoxImpl(messageboxdata, buttonID); // oh well. + } else if (pid == 0) { // we're the child + int exitcode = 0; + close(fds[0]); + result = X11_ShowMessageBoxImpl(messageboxdata, buttonID); + if (write(fds[1], &result, sizeof(result)) != sizeof(result)) { + exitcode = 1; + } else if (write(fds[1], buttonID, sizeof(*buttonID)) != sizeof(*buttonID)) { + exitcode = 1; + } + close(fds[1]); + _exit(exitcode); // don't run atexit() stuff, static destructors, etc. + } else { // we're the parent + pid_t rc; + close(fds[1]); + do { + rc = waitpid(pid, &status, 0); + } while ((rc == -1) && (errno == EINTR)); + + SDL_assert(rc == pid); // not sure what to do if this fails. + + if ((rc == -1) || (!WIFEXITED(status)) || (WEXITSTATUS(status) != 0)) { + result = SDL_SetError("msgbox child process failed"); + } else if ((read(fds[0], &result, sizeof(result)) != sizeof(result)) || + (read(fds[0], buttonID, sizeof(*buttonID)) != sizeof(*buttonID))) { + result = SDL_SetError("read from msgbox child process failed"); + *buttonID = 0; + } + close(fds[0]); + + return result; + } +#else + return X11_ShowMessageBoxImpl(messageboxdata, buttonID); +#endif +} +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.h new file mode 100644 index 0000000..9baa875 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11messagebox.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_x11messagebox_h_ +#define SDL_x11messagebox_h_ + +#ifdef SDL_VIDEO_DRIVER_X11 + +extern bool X11_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonID); + +#endif // SDL_VIDEO_DRIVER_X11 + +#endif // SDL_x11messagebox_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.c new file mode 100644 index 0000000..e17a2d1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.c @@ -0,0 +1,1051 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" +#include "SDL_x11settings.h" +#include "edid.h" +#include "../../events/SDL_displayevents_c.h" + +// #define X11MODES_DEBUG + +/* Timeout and revert mode switches if the timespan has elapsed without the window becoming fullscreen. + * 5 seconds seems good from testing. + */ +#define MODE_SWITCH_TIMEOUT_NS SDL_NS_PER_SECOND * 5 + +/* I'm becoming more and more convinced that the application should never + * use XRandR, and it's the window manager's responsibility to track and + * manage display modes for fullscreen windows. Right now XRandR is completely + * broken with respect to window manager behavior on every window manager that + * I can find. For example, on Unity 3D if you show a fullscreen window while + * the resolution is changing (within ~250 ms) your window will retain the + * fullscreen state hint but be decorated and windowed. + * + * However, many people swear by it, so let them swear at it. :) + */ +// #define XRANDR_DISABLED_BY_DEFAULT + +static float GetGlobalContentScale(SDL_VideoDevice *_this) +{ + static double scale_factor = 0.0; + + if (scale_factor <= 0.0) { + + // First use the forced scaling factor specified by the app/user + const char *hint = SDL_GetHint(SDL_HINT_VIDEO_X11_SCALING_FACTOR); + if (hint && *hint) { + double value = SDL_atof(hint); + if (value >= 1.0f && value <= 10.0f) { + scale_factor = value; + } + } + + // If that failed, try "Xft.dpi" from the XResourcesDatabase... + if (scale_factor <= 0.0) + { + SDL_VideoData *data = _this->internal; + Display *display = data->display; + char *resource_manager; + XrmDatabase db; + XrmValue value; + char *type; + + X11_XrmInitialize(); + + resource_manager = X11_XResourceManagerString(display); + if (resource_manager) { + db = X11_XrmGetStringDatabase(resource_manager); + + // Get the value of Xft.dpi from the Database + if (X11_XrmGetResource(db, "Xft.dpi", "String", &type, &value)) { + if (value.addr && type && SDL_strcmp(type, "String") == 0) { + int dpi = SDL_atoi(value.addr); + scale_factor = dpi / 96.0; + } + } + X11_XrmDestroyDatabase(db); + } + } + + // If that failed, try the XSETTINGS keys... + if (scale_factor <= 0.0) { + scale_factor = X11_GetXsettingsIntKey(_this, "Gdk/WindowScalingFactor", -1); + + // The Xft/DPI key is stored in increments of 1024th + if (scale_factor <= 0.0) { + int dpi = X11_GetXsettingsIntKey(_this, "Xft/DPI", -1); + if (dpi > 0) { + scale_factor = (double) dpi / 1024.0; + scale_factor /= 96.0; + } + } + } + + // If that failed, try the GDK_SCALE envvar... + if (scale_factor <= 0.0) { + const char *scale_str = SDL_getenv("GDK_SCALE"); + if (scale_str) { + scale_factor = SDL_atoi(scale_str); + } + } + + // Nothing or a bad value, just fall back to 1.0 + if (scale_factor <= 0.0) { + scale_factor = 1.0; + } + } + + return (float)scale_factor; +} + +static bool get_visualinfo(Display *display, int screen, XVisualInfo *vinfo) +{ + const char *visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_VISUALID); + int depth; + + // Look for an exact visual, if requested + if (visual_id && *visual_id) { + XVisualInfo *vi, template; + int nvis; + + SDL_zero(template); + template.visualid = SDL_strtol(visual_id, NULL, 0); + vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis); + if (vi) { + *vinfo = *vi; + X11_XFree(vi); + return true; + } + } + + depth = DefaultDepth(display, screen); + if ((X11_UseDirectColorVisuals() && + X11_XMatchVisualInfo(display, screen, depth, DirectColor, vinfo)) || + X11_XMatchVisualInfo(display, screen, depth, TrueColor, vinfo) || + X11_XMatchVisualInfo(display, screen, depth, PseudoColor, vinfo) || + X11_XMatchVisualInfo(display, screen, depth, StaticColor, vinfo)) { + return true; + } + return false; +} + +bool X11_GetVisualInfoFromVisual(Display *display, Visual *visual, XVisualInfo *vinfo) +{ + XVisualInfo *vi; + int nvis; + + vinfo->visualid = X11_XVisualIDFromVisual(visual); + vi = X11_XGetVisualInfo(display, VisualIDMask, vinfo, &nvis); + if (vi) { + *vinfo = *vi; + X11_XFree(vi); + return true; + } + return false; +} + +SDL_PixelFormat X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo) +{ + if (vinfo->class == DirectColor || vinfo->class == TrueColor) { + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + + Rmask = vinfo->visual->red_mask; + Gmask = vinfo->visual->green_mask; + Bmask = vinfo->visual->blue_mask; + if (vinfo->depth == 32) { + Amask = (0xFFFFFFFF & ~(Rmask | Gmask | Bmask)); + } else { + Amask = 0; + } + + bpp = vinfo->depth; + if (bpp == 24) { + int i, n; + XPixmapFormatValues *p = X11_XListPixmapFormats(display, &n); + if (p) { + for (i = 0; i < n; ++i) { + if (p[i].depth == 24) { + bpp = p[i].bits_per_pixel; + break; + } + } + X11_XFree(p); + } + } + + return SDL_GetPixelFormatForMasks(bpp, Rmask, Gmask, Bmask, Amask); + } + + if (vinfo->class == PseudoColor || vinfo->class == StaticColor) { + switch (vinfo->depth) { + case 8: + return SDL_PIXELFORMAT_INDEX8; + case 4: + if (BitmapBitOrder(display) == LSBFirst) { + return SDL_PIXELFORMAT_INDEX4LSB; + } else { + return SDL_PIXELFORMAT_INDEX4MSB; + } + // break; -Wunreachable-code-break + case 1: + if (BitmapBitOrder(display) == LSBFirst) { + return SDL_PIXELFORMAT_INDEX1LSB; + } else { + return SDL_PIXELFORMAT_INDEX1MSB; + } + // break; -Wunreachable-code-break + } + } + + return SDL_PIXELFORMAT_UNKNOWN; +} + +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR +static bool CheckXRandR(Display *display, int *major, int *minor) +{ + // Default the extension not available + *major = *minor = 0; + + // Allow environment override +#ifdef XRANDR_DISABLED_BY_DEFAULT + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, false)) { +#ifdef X11MODES_DEBUG + printf("XRandR disabled by default due to window manager issues\n"); +#endif + return false; + } +#else + if (!SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_XRANDR, true)) { +#ifdef X11MODES_DEBUG + printf("XRandR disabled due to hint\n"); +#endif + return false; + } +#endif // XRANDR_DISABLED_BY_DEFAULT + + if (!SDL_X11_HAVE_XRANDR) { +#ifdef X11MODES_DEBUG + printf("XRandR support not available\n"); +#endif + return false; + } + + // Query the extension version + *major = 1; + *minor = 3; // we want 1.3 + if (!X11_XRRQueryVersion(display, major, minor)) { +#ifdef X11MODES_DEBUG + printf("XRandR not active on the display\n"); +#endif + *major = *minor = 0; + return false; + } +#ifdef X11MODES_DEBUG + printf("XRandR available at version %d.%d!\n", *major, *minor); +#endif + return true; +} + +#define XRANDR_ROTATION_LEFT (1 << 1) +#define XRANDR_ROTATION_RIGHT (1 << 3) + +static void CalculateXRandRRefreshRate(const XRRModeInfo *info, int *numerator, int *denominator) +{ + unsigned int vTotal = info->vTotal; + + if (info->modeFlags & RR_DoubleScan) { + // doublescan doubles the number of lines + vTotal *= 2; + } + + if (info->modeFlags & RR_Interlace) { + // interlace splits the frame into two fields + // the field rate is what is typically reported by monitors + vTotal /= 2; + } + + if (info->hTotal && vTotal) { + *numerator = info->dotClock; + *denominator = (info->hTotal * vTotal); + } else { + *numerator = 0; + *denominator = 0; + } +} + +static bool SetXRandRModeInfo(Display *display, XRRScreenResources *res, RRCrtc crtc, + RRMode modeID, SDL_DisplayMode *mode) +{ + int i; + for (i = 0; i < res->nmode; ++i) { + const XRRModeInfo *info = &res->modes[i]; + if (info->id == modeID) { + XRRCrtcInfo *crtcinfo; + Rotation rotation = 0; + XFixed scale_w = 0x10000, scale_h = 0x10000; + XRRCrtcTransformAttributes *attr; + + crtcinfo = X11_XRRGetCrtcInfo(display, res, crtc); + if (crtcinfo) { + rotation = crtcinfo->rotation; + X11_XRRFreeCrtcInfo(crtcinfo); + } + if (X11_XRRGetCrtcTransform(display, crtc, &attr) && attr) { + scale_w = attr->currentTransform.matrix[0][0]; + scale_h = attr->currentTransform.matrix[1][1]; + X11_XFree(attr); + } + + if (rotation & (XRANDR_ROTATION_LEFT | XRANDR_ROTATION_RIGHT)) { + mode->w = (info->height * scale_w + 0xffff) >> 16; + mode->h = (info->width * scale_h + 0xffff) >> 16; + } else { + mode->w = (info->width * scale_w + 0xffff) >> 16; + mode->h = (info->height * scale_h + 0xffff) >> 16; + } + CalculateXRandRRefreshRate(info, &mode->refresh_rate_numerator, &mode->refresh_rate_denominator); + mode->internal->xrandr_mode = modeID; +#ifdef X11MODES_DEBUG + printf("XRandR mode %d: %dx%d@%d/%dHz\n", (int)modeID, + mode->screen_w, mode->screen_h, mode->refresh_rate_numerator, mode->refresh_rate_denominator); +#endif + return true; + } + } + return false; +} + +static void SetXRandRDisplayName(Display *dpy, Atom EDID, char *name, const size_t namelen, RROutput output, const unsigned long widthmm, const unsigned long heightmm) +{ + // See if we can get the EDID data for the real monitor name + int inches; + int nprop; + Atom *props = X11_XRRListOutputProperties(dpy, output, &nprop); + int i; + + for (i = 0; i < nprop; ++i) { + unsigned char *prop; + int actual_format; + unsigned long nitems, bytes_after; + Atom actual_type; + + if (props[i] == EDID) { + if (X11_XRRGetOutputProperty(dpy, output, props[i], 0, 100, False, + False, AnyPropertyType, &actual_type, + &actual_format, &nitems, &bytes_after, + &prop) == Success) { + MonitorInfo *info = decode_edid(prop); + if (info) { +#ifdef X11MODES_DEBUG + printf("Found EDID data for %s\n", name); + dump_monitor_info(info); +#endif + SDL_strlcpy(name, info->dsc_product_name, namelen); + SDL_free(info); + } + X11_XFree(prop); + } + break; + } + } + + if (props) { + X11_XFree(props); + } + + inches = (int)((SDL_sqrtf(widthmm * widthmm + heightmm * heightmm) / 25.4f) + 0.5f); + if (*name && inches) { + const size_t len = SDL_strlen(name); + (void)SDL_snprintf(&name[len], namelen - len, " %d\"", inches); + } + +#ifdef X11MODES_DEBUG + printf("Display name: %s\n", name); +#endif +} + +static bool X11_FillXRandRDisplayInfo(SDL_VideoDevice *_this, Display *dpy, int screen, RROutput outputid, XRRScreenResources *res, SDL_VideoDisplay *display, char *display_name, size_t display_name_size) +{ + Atom EDID = X11_XInternAtom(dpy, "EDID", False); + XRROutputInfo *output_info; + int display_x, display_y; + unsigned long display_mm_width, display_mm_height; + SDL_DisplayData *displaydata; + SDL_DisplayMode mode; + SDL_DisplayModeData *modedata; + RRMode modeID; + RRCrtc output_crtc; + XRRCrtcInfo *crtc; + XVisualInfo vinfo; + Uint32 pixelformat; + XPixmapFormatValues *pixmapformats; + int scanline_pad; + int i, n; + + if (!display || !display_name) { + return false; // invalid parameters + } + + if (!get_visualinfo(dpy, screen, &vinfo)) { + return false; // uh, skip this screen? + } + + pixelformat = X11_GetPixelFormatFromVisualInfo(dpy, &vinfo); + if (SDL_ISPIXELFORMAT_INDEXED(pixelformat)) { + return false; // Palettized video modes are no longer supported, ignore this one. + } + + scanline_pad = SDL_BYTESPERPIXEL(pixelformat) * 8; + pixmapformats = X11_XListPixmapFormats(dpy, &n); + if (pixmapformats) { + for (i = 0; i < n; i++) { + if (pixmapformats[i].depth == vinfo.depth) { + scanline_pad = pixmapformats[i].scanline_pad; + break; + } + } + X11_XFree(pixmapformats); + } + + output_info = X11_XRRGetOutputInfo(dpy, res, outputid); + if (!output_info || !output_info->crtc || output_info->connection == RR_Disconnected) { + X11_XRRFreeOutputInfo(output_info); + return false; // ignore this one. + } + + SDL_strlcpy(display_name, output_info->name, display_name_size); + display_mm_width = output_info->mm_width; + display_mm_height = output_info->mm_height; + output_crtc = output_info->crtc; + X11_XRRFreeOutputInfo(output_info); + + crtc = X11_XRRGetCrtcInfo(dpy, res, output_crtc); + if (!crtc) { + return false; // oh well, ignore it. + } + + SDL_zero(mode); + modeID = crtc->mode; + mode.w = crtc->width; + mode.h = crtc->height; + mode.format = pixelformat; + + display_x = crtc->x; + display_y = crtc->y; + + X11_XRRFreeCrtcInfo(crtc); + + displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); + if (!displaydata) { + return false; + } + + modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); + if (!modedata) { + SDL_free(displaydata); + return false; + } + + modedata->xrandr_mode = modeID; + mode.internal = modedata; + + displaydata->screen = screen; + displaydata->visual = vinfo.visual; + displaydata->depth = vinfo.depth; + displaydata->scanline_pad = scanline_pad; + displaydata->x = display_x; + displaydata->y = display_y; + displaydata->use_xrandr = true; + displaydata->xrandr_output = outputid; + SDL_strlcpy(displaydata->connector_name, display_name, sizeof(displaydata->connector_name)); + + SetXRandRModeInfo(dpy, res, output_crtc, modeID, &mode); + SetXRandRDisplayName(dpy, EDID, display_name, display_name_size, outputid, display_mm_width, display_mm_height); + + SDL_zero(*display); + if (*display_name) { + display->name = display_name; + } + display->desktop_mode = mode; + display->content_scale = GetGlobalContentScale(_this); + display->internal = displaydata; + + return true; +} + +static bool X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen, RROutput outputid, XRRScreenResources *res, bool send_event) +{ + SDL_VideoDisplay display; + char display_name[128]; + + if (!X11_FillXRandRDisplayInfo(_this, dpy, screen, outputid, res, &display, display_name, sizeof(display_name))) { + return true; // failed to query data, skip this display + } + + if (SDL_AddVideoDisplay(&display, send_event) == 0) { + return false; + } + + return true; +} + + +static bool X11_UpdateXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen, RROutput outputid, XRRScreenResources *res, SDL_VideoDisplay *existing_display) +{ + SDL_VideoDisplay display; + char display_name[128]; + + if (!X11_FillXRandRDisplayInfo(_this, dpy, screen, outputid, res, &display, display_name, sizeof(display_name))) { + return false; // failed to query current display state + } + + // update mode - this call takes ownership of display.desktop_mode.internal + SDL_SetDesktopDisplayMode(existing_display, &display.desktop_mode); + + // update bounds + if (existing_display->internal->x != display.internal->x || + existing_display->internal->y != display.internal->y) { + existing_display->internal->x = display.internal->x; + existing_display->internal->y = display.internal->y; + SDL_SendDisplayEvent(existing_display, SDL_EVENT_DISPLAY_MOVED, 0, 0); + } + + // update scale + SDL_SetDisplayContentScale(existing_display, display.content_scale); + + // SDL_DisplayData is updated piece-meal above, free our local copy of this data + SDL_free( display.internal ); + + return true; +} + +static XRRScreenResources *X11_GetScreenResources(Display *dpy, int screen) +{ + XRRScreenResources *res = X11_XRRGetScreenResourcesCurrent(dpy, RootWindow(dpy, screen)); + if (!res || res->noutput == 0) { + if (res) { + X11_XRRFreeScreenResources(res); + } + res = X11_XRRGetScreenResources(dpy, RootWindow(dpy, screen)); + } + return res; +} + +static void X11_CheckDisplaysMoved(SDL_VideoDevice *_this, Display *dpy) +{ + const int screen = DefaultScreen(dpy); + XRRScreenResources *res = X11_GetScreenResources(dpy, screen); + if (!res) { + return; + } + + SDL_DisplayID *displays = SDL_GetDisplays(NULL); + if (displays) { + for (int i = 0; displays[i]; ++i) { + SDL_VideoDisplay *display = SDL_GetVideoDisplay(displays[i]); + const SDL_DisplayData *displaydata = display->internal; + X11_UpdateXRandRDisplay(_this, dpy, screen, displaydata->xrandr_output, res, display); + } + SDL_free(displays); + } + X11_XRRFreeScreenResources(res); +} + +static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutputChangeNotifyEvent *ev) +{ + SDL_DisplayID *displays; + SDL_VideoDisplay *display = NULL; + int i; + +#if 0 + printf("XRROutputChangeNotifyEvent! [output=%u, crtc=%u, mode=%u, rotation=%u, connection=%u]", (unsigned int) ev->output, (unsigned int) ev->crtc, (unsigned int) ev->mode, (unsigned int) ev->rotation, (unsigned int) ev->connection); +#endif + + displays = SDL_GetDisplays(NULL); + if (displays) { + for (i = 0; displays[i]; ++i) { + SDL_VideoDisplay *thisdisplay = SDL_GetVideoDisplay(displays[i]); + const SDL_DisplayData *displaydata = thisdisplay->internal; + if (displaydata->xrandr_output == ev->output) { + display = thisdisplay; + break; + } + } + SDL_free(displays); + } + + if (ev->connection == RR_Disconnected) { // output is going away + if (display) { + SDL_DelVideoDisplay(display->id, true); + } + X11_CheckDisplaysMoved(_this, ev->display); + + } else if (ev->connection == RR_Connected) { // output is coming online + if (!display) { + Display *dpy = ev->display; + const int screen = DefaultScreen(dpy); + XRRScreenResources *res = X11_GetScreenResources(dpy, screen); + if (res) { + X11_AddXRandRDisplay(_this, dpy, screen, ev->output, res, true); + X11_XRRFreeScreenResources(res); + } + } + X11_CheckDisplaysMoved(_this, ev->display); + } +} + +void X11_HandleXRandREvent(SDL_VideoDevice *_this, const XEvent *xevent) +{ + SDL_VideoData *videodata = _this->internal; + SDL_assert(xevent->type == (videodata->xrandr_event_base + RRNotify)); + + switch (((const XRRNotifyEvent *)xevent)->subtype) { + case RRNotify_OutputChange: + X11_HandleXRandROutputChange(_this, (const XRROutputChangeNotifyEvent *)xevent); + break; + default: + break; + } +} + +static void X11_SortOutputsByPriorityHint(SDL_VideoDevice *_this) +{ + const char *name_hint = SDL_GetHint(SDL_HINT_VIDEO_DISPLAY_PRIORITY); + + if (name_hint) { + char *saveptr; + char *str = SDL_strdup(name_hint); + SDL_VideoDisplay **sorted_list = SDL_malloc(sizeof(SDL_VideoDisplay *) * _this->num_displays); + + if (str && sorted_list) { + int sorted_index = 0; + + // Sort the requested displays to the front of the list. + const char *token = SDL_strtok_r(str, ",", &saveptr); + while (token) { + for (int i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *d = _this->displays[i]; + if (d) { + SDL_DisplayData *data = d->internal; + if (SDL_strcmp(token, data->connector_name) == 0) { + sorted_list[sorted_index++] = d; + _this->displays[i] = NULL; + break; + } + } + } + + token = SDL_strtok_r(NULL, ",", &saveptr); + } + + // Append the remaining displays to the end of the list. + for (int i = 0; i < _this->num_displays; ++i) { + if (_this->displays[i]) { + sorted_list[sorted_index++] = _this->displays[i]; + } + } + + // Copy the sorted list back to the display list. + SDL_memcpy(_this->displays, sorted_list, sizeof(SDL_VideoDisplay *) * _this->num_displays); + } + + SDL_free(str); + SDL_free(sorted_list); + } +} + +static bool X11_InitModes_XRandR(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + Display *dpy = data->display; + const int screencount = ScreenCount(dpy); + const int default_screen = DefaultScreen(dpy); + RROutput primary = X11_XRRGetOutputPrimary(dpy, RootWindow(dpy, default_screen)); + int xrandr_error_base = 0; + int looking_for_primary; + int output; + int screen; + + if (!X11_XRRQueryExtension(dpy, &data->xrandr_event_base, &xrandr_error_base)) { + return SDL_SetError("XRRQueryExtension failed"); + } + + for (looking_for_primary = 1; looking_for_primary >= 0; looking_for_primary--) { + for (screen = 0; screen < screencount; screen++) { + + // we want the primary output first, and then skipped later. + if (looking_for_primary && (screen != default_screen)) { + continue; + } + + XRRScreenResources *res = X11_GetScreenResources(dpy, screen); + if (!res) { + continue; + } + + for (output = 0; output < res->noutput; output++) { + // The primary output _should_ always be sorted first, but just in case... + if ((looking_for_primary && (res->outputs[output] != primary)) || + (!looking_for_primary && (screen == default_screen) && (res->outputs[output] == primary))) { + continue; + } + if (!X11_AddXRandRDisplay(_this, dpy, screen, res->outputs[output], res, false)) { + break; + } + } + + X11_XRRFreeScreenResources(res); + + // This will generate events for displays that come and go at runtime. + X11_XRRSelectInput(dpy, RootWindow(dpy, screen), RROutputChangeNotifyMask); + } + } + + if (_this->num_displays == 0) { + return SDL_SetError("No available displays"); + } + + X11_SortOutputsByPriorityHint(_this); + + return true; +} +#endif // SDL_VIDEO_DRIVER_X11_XRANDR + +/* This is used if there's no better functionality--like XRandR--to use. + It won't attempt to supply different display modes at all, but it can + enumerate the current displays and their current sizes. */ +static bool X11_InitModes_StdXlib(SDL_VideoDevice *_this) +{ + // !!! FIXME: a lot of copy/paste from X11_InitModes_XRandR in this function. + SDL_VideoData *data = _this->internal; + Display *dpy = data->display; + const int default_screen = DefaultScreen(dpy); + Screen *screen = ScreenOfDisplay(dpy, default_screen); + int scanline_pad, n, i; + SDL_DisplayModeData *modedata; + SDL_DisplayData *displaydata; + SDL_DisplayMode mode; + XPixmapFormatValues *pixmapformats; + Uint32 pixelformat; + XVisualInfo vinfo; + SDL_VideoDisplay display; + + // note that generally even if you have a multiple physical monitors, ScreenCount(dpy) still only reports ONE screen. + + if (!get_visualinfo(dpy, default_screen, &vinfo)) { + return SDL_SetError("Failed to find an X11 visual for the primary display"); + } + + pixelformat = X11_GetPixelFormatFromVisualInfo(dpy, &vinfo); + if (SDL_ISPIXELFORMAT_INDEXED(pixelformat)) { + return SDL_SetError("Palettized video modes are no longer supported"); + } + + SDL_zero(mode); + mode.w = WidthOfScreen(screen); + mode.h = HeightOfScreen(screen); + mode.format = pixelformat; + + displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); + if (!displaydata) { + return false; + } + + modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); + if (!modedata) { + SDL_free(displaydata); + return false; + } + mode.internal = modedata; + + displaydata->screen = default_screen; + displaydata->visual = vinfo.visual; + displaydata->depth = vinfo.depth; + + scanline_pad = SDL_BYTESPERPIXEL(pixelformat) * 8; + pixmapformats = X11_XListPixmapFormats(dpy, &n); + if (pixmapformats) { + for (i = 0; i < n; ++i) { + if (pixmapformats[i].depth == vinfo.depth) { + scanline_pad = pixmapformats[i].scanline_pad; + break; + } + } + X11_XFree(pixmapformats); + } + + displaydata->scanline_pad = scanline_pad; + displaydata->x = 0; + displaydata->y = 0; + displaydata->use_xrandr = false; + + SDL_zero(display); + display.name = (char *)"Generic X11 Display"; /* this is just copied and thrown away, it's safe to cast to char* here. */ + display.desktop_mode = mode; + display.internal = displaydata; + display.content_scale = GetGlobalContentScale(_this); + if (SDL_AddVideoDisplay(&display, true) == 0) { + return false; + } + return true; +} + +bool X11_InitModes(SDL_VideoDevice *_this) +{ + /* XRandR is the One True Modern Way to do this on X11. If this + fails, we just won't report any display modes except the current + desktop size. */ +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR + { + SDL_VideoData *data = _this->internal; + int xrandr_major, xrandr_minor; + // require at least XRandR v1.3 + if (CheckXRandR(data->display, &xrandr_major, &xrandr_minor) && + (xrandr_major >= 2 || (xrandr_major == 1 && xrandr_minor >= 3)) && + X11_InitModes_XRandR(_this)) { + return true; + } + } +#endif // SDL_VIDEO_DRIVER_X11_XRANDR + + // still here? Just set up an extremely basic display. + return X11_InitModes_StdXlib(_this); +} + +bool X11_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR + SDL_DisplayData *data = sdl_display->internal; + SDL_DisplayMode mode; + + /* Unfortunately X11 requires the window to be created with the correct + * visual and depth ahead of time, but the SDL API allows you to create + * a window before setting the fullscreen display mode. This means that + * we have to use the same format for all windows and all display modes. + * (or support recreating the window with a new visual behind the scenes) + */ + SDL_zero(mode); + mode.format = sdl_display->desktop_mode.format; + + if (data->use_xrandr) { + Display *display = _this->internal->display; + XRRScreenResources *res; + + res = X11_XRRGetScreenResources(display, RootWindow(display, data->screen)); + if (res) { + SDL_DisplayModeData *modedata; + XRROutputInfo *output_info; + int i; + + output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); + if (output_info && output_info->connection != RR_Disconnected) { + for (i = 0; i < output_info->nmode; ++i) { + modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); + if (!modedata) { + continue; + } + mode.internal = modedata; + + if (!SetXRandRModeInfo(display, res, output_info->crtc, output_info->modes[i], &mode) || + !SDL_AddFullscreenDisplayMode(sdl_display, &mode)) { + SDL_free(modedata); + } + } + } + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); + } + } +#endif // SDL_VIDEO_DRIVER_X11_XRANDR + return true; +} + +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR +// This catches an error from XRRSetScreenSize, as a workaround for now. +// !!! FIXME: remove this later when we have a better solution. +static int (*PreXRRSetScreenSizeErrorHandler)(Display *, XErrorEvent *) = NULL; +static int SDL_XRRSetScreenSizeErrHandler(Display *d, XErrorEvent *e) +{ + // BadMatch: https://github.com/libsdl-org/SDL/issues/4561 + // BadValue: https://github.com/libsdl-org/SDL/issues/4840 + if ((e->error_code == BadMatch) || (e->error_code == BadValue)) { + return 0; + } + + return PreXRRSetScreenSizeErrorHandler(d, e); +} +#endif + +bool X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_DisplayMode *mode) +{ + SDL_VideoData *viddata = _this->internal; + SDL_DisplayData *data = sdl_display->internal; + + viddata->last_mode_change_deadline = SDL_GetTicks() + (PENDING_FOCUS_TIME * 2); + + // XWayland mode switches are emulated with viewports and thus instantaneous. + if (!viddata->is_xwayland) { + if (sdl_display->current_mode != mode) { + data->mode_switch_deadline_ns = SDL_GetTicksNS() + MODE_SWITCH_TIMEOUT_NS; + } else { + data->mode_switch_deadline_ns = 0; + } + } + +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR + if (data->use_xrandr) { + Display *display = viddata->display; + SDL_DisplayModeData *modedata = mode->internal; + int mm_width, mm_height; + XRRScreenResources *res; + XRROutputInfo *output_info; + XRRCrtcInfo *crtc; + Status status; + + res = X11_XRRGetScreenResources(display, RootWindow(display, data->screen)); + if (!res) { + return SDL_SetError("Couldn't get XRandR screen resources"); + } + + output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); + if (!output_info || output_info->connection == RR_Disconnected) { + X11_XRRFreeScreenResources(res); + return SDL_SetError("Couldn't get XRandR output info"); + } + + crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); + if (!crtc) { + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); + return SDL_SetError("Couldn't get XRandR crtc info"); + } + + if (crtc->mode == modedata->xrandr_mode) { +#ifdef X11MODES_DEBUG + printf("already in desired mode 0x%lx (%ux%u), nothing to do\n", + crtc->mode, crtc->width, crtc->height); +#endif + status = Success; + goto freeInfo; + } + + X11_XGrabServer(display); + status = X11_XRRSetCrtcConfig(display, res, output_info->crtc, CurrentTime, + 0, 0, None, crtc->rotation, NULL, 0); + if (status != Success) { + goto ungrabServer; + } + + mm_width = mode->w * DisplayWidthMM(display, data->screen) / DisplayWidth(display, data->screen); + mm_height = mode->h * DisplayHeightMM(display, data->screen) / DisplayHeight(display, data->screen); + + /* !!! FIXME: this can get into a problem scenario when a window is + bigger than a physical monitor in a configuration where one screen + spans multiple physical monitors. A detailed reproduction case is + discussed at https://github.com/libsdl-org/SDL/issues/4561 ... + for now we cheat and just catch the X11 error and carry on, which + is likely to cause subtle issues but is better than outright + crashing */ + X11_XSync(display, False); + PreXRRSetScreenSizeErrorHandler = X11_XSetErrorHandler(SDL_XRRSetScreenSizeErrHandler); + X11_XRRSetScreenSize(display, RootWindow(display, data->screen), + mode->w, mode->h, mm_width, mm_height); + X11_XSync(display, False); + X11_XSetErrorHandler(PreXRRSetScreenSizeErrorHandler); + + status = X11_XRRSetCrtcConfig(display, res, output_info->crtc, CurrentTime, + crtc->x, crtc->y, modedata->xrandr_mode, crtc->rotation, + &data->xrandr_output, 1); + + ungrabServer: + X11_XUngrabServer(display); + freeInfo: + X11_XRRFreeCrtcInfo(crtc); + X11_XRRFreeOutputInfo(output_info); + X11_XRRFreeScreenResources(res); + + if (status != Success) { + return SDL_SetError("X11_XRRSetCrtcConfig failed"); + } + } +#else + (void)data; +#endif // SDL_VIDEO_DRIVER_X11_XRANDR + + return true; +} + +void X11_QuitModes(SDL_VideoDevice *_this) +{ +} + +bool X11_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_Rect *rect) +{ + SDL_DisplayData *data = sdl_display->internal; + + rect->x = data->x; + rect->y = data->y; + rect->w = sdl_display->current_mode->w; + rect->h = sdl_display->current_mode->h; + return true; +} + +bool X11_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_Rect *rect) +{ + SDL_VideoData *data = _this->internal; + Display *display = data->display; + Atom _NET_WORKAREA; + int real_format; + Atom real_type; + unsigned long items_read = 0, items_left = 0; + unsigned char *propdata = NULL; + bool result = false; + + if (!X11_GetDisplayBounds(_this, sdl_display, rect)) { + return false; + } + + _NET_WORKAREA = X11_XInternAtom(display, "_NET_WORKAREA", False); + int status = X11_XGetWindowProperty(display, DefaultRootWindow(display), + _NET_WORKAREA, 0L, 4L, False, XA_CARDINAL, + &real_type, &real_format, &items_read, + &items_left, &propdata); + if ((status == Success) && (items_read >= 4)) { + const long *p = (long *)propdata; + const SDL_Rect usable = { (int)p[0], (int)p[1], (int)p[2], (int)p[3] }; + result = true; + if (!SDL_GetRectIntersection(rect, &usable, rect)) { + SDL_zerop(rect); + } + } + + if (propdata) { + X11_XFree(propdata); + } + + return result; +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.h new file mode 100644 index 0000000..35fd866 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11modes.h @@ -0,0 +1,69 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11modes_h_ +#define SDL_x11modes_h_ + +struct SDL_DisplayData +{ + int screen; + Visual *visual; + int depth; + int scanline_pad; + int x; + int y; + + Uint64 mode_switch_deadline_ns; + + bool use_xrandr; + +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR + RROutput xrandr_output; + char connector_name[16]; +#endif +}; + +struct SDL_DisplayModeData +{ +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR + RRMode xrandr_mode; +#else + int unused; // just so struct isn't empty. +#endif +}; + +extern bool X11_InitModes(SDL_VideoDevice *_this); +extern bool X11_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display); +extern bool X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL_DisplayMode *mode); +extern void X11_QuitModes(SDL_VideoDevice *_this); + +// Some utility functions for working with visuals +extern bool X11_GetVisualInfoFromVisual(Display *display, Visual *visual, XVisualInfo *vinfo); +extern SDL_PixelFormat X11_GetPixelFormatFromVisualInfo(Display *display, XVisualInfo *vinfo); +extern bool X11_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_Rect *rect); +extern bool X11_GetDisplayUsableBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SDL_Rect *rect); + +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR +extern void X11_HandleXRandREvent(SDL_VideoDevice *_this, const XEvent *xevent); +#endif + +#endif // SDL_x11modes_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.c new file mode 100644 index 0000000..5c72dbf --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.c @@ -0,0 +1,552 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include +#include "SDL_x11video.h" +#include "SDL_x11mouse.h" +#include "SDL_x11xinput2.h" +#include "../SDL_video_c.h" +#include "../../events/SDL_mouse_c.h" + +struct SDL_CursorData +{ + Cursor cursor; +}; + +// FIXME: Find a better place to put this... +static Cursor x11_empty_cursor = None; +static bool x11_cursor_visible = true; + +static SDL_Cursor *sys_cursors[SDL_HITTEST_RESIZE_LEFT + 1]; + +static Display *GetDisplay(void) +{ + return SDL_GetVideoDevice()->internal->display; +} + +static Cursor X11_CreateEmptyCursor(void) +{ + if (x11_empty_cursor == None) { + Display *display = GetDisplay(); + char data[1]; + XColor color; + Pixmap pixmap; + + SDL_zeroa(data); + color.red = color.green = color.blue = 0; + pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), + data, 1, 1); + if (pixmap) { + x11_empty_cursor = X11_XCreatePixmapCursor(display, pixmap, pixmap, + &color, &color, 0, 0); + X11_XFreePixmap(display, pixmap); + } + } + return x11_empty_cursor; +} + +static void X11_DestroyEmptyCursor(void) +{ + if (x11_empty_cursor != None) { + X11_XFreeCursor(GetDisplay(), x11_empty_cursor); + x11_empty_cursor = None; + } +} + +static SDL_Cursor *X11_CreateCursorAndData(Cursor x11_cursor) +{ + SDL_Cursor *cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + SDL_CursorData *data = (SDL_CursorData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_free(cursor); + return NULL; + } + data->cursor = x11_cursor; + cursor->internal = data; + } + return cursor; +} + +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR +static Cursor X11_CreateXCursorCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + Display *display = GetDisplay(); + Cursor cursor = None; + XcursorImage *image; + + image = X11_XcursorImageCreate(surface->w, surface->h); + if (!image) { + SDL_OutOfMemory(); + return None; + } + image->xhot = hot_x; + image->yhot = hot_y; + image->delay = 0; + + SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + SDL_memcpy(image->pixels, surface->pixels, (size_t)surface->h * surface->pitch); + + cursor = X11_XcursorImageLoadCursor(display, image); + + X11_XcursorImageDestroy(image); + + return cursor; +} +#endif // SDL_VIDEO_DRIVER_X11_XCURSOR + +static Cursor X11_CreatePixmapCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + Display *display = GetDisplay(); + XColor fg, bg; + Cursor cursor = None; + Uint32 *ptr; + Uint8 *data_bits, *mask_bits; + Pixmap data_pixmap, mask_pixmap; + int x, y; + unsigned int rfg, gfg, bfg, rbg, gbg, bbg, fgBits, bgBits; + size_t width_bytes = ((surface->w + 7) & ~((size_t)7)) / 8; + + data_bits = SDL_calloc(1, surface->h * width_bytes); + if (!data_bits) { + return None; + } + + mask_bits = SDL_calloc(1, surface->h * width_bytes); + if (!mask_bits) { + SDL_free(data_bits); + return None; + } + + // Code below assumes ARGB pixel format + SDL_assert(surface->format == SDL_PIXELFORMAT_ARGB8888); + + rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0; + for (y = 0; y < surface->h; ++y) { + ptr = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch); + for (x = 0; x < surface->w; ++x) { + int alpha = (*ptr >> 24) & 0xff; + int red = (*ptr >> 16) & 0xff; + int green = (*ptr >> 8) & 0xff; + int blue = (*ptr >> 0) & 0xff; + if (alpha > 25) { + mask_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8)); + + if ((red + green + blue) > 0x40) { + fgBits++; + rfg += red; + gfg += green; + bfg += blue; + data_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8)); + } else { + bgBits++; + rbg += red; + gbg += green; + bbg += blue; + } + } + ++ptr; + } + } + + if (fgBits) { + fg.red = rfg * 257 / fgBits; + fg.green = gfg * 257 / fgBits; + fg.blue = bfg * 257 / fgBits; + } else { + fg.red = fg.green = fg.blue = 0; + } + + if (bgBits) { + bg.red = rbg * 257 / bgBits; + bg.green = gbg * 257 / bgBits; + bg.blue = bbg * 257 / bgBits; + } else { + bg.red = bg.green = bg.blue = 0; + } + + data_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), + (char *)data_bits, + surface->w, surface->h); + mask_pixmap = X11_XCreateBitmapFromData(display, DefaultRootWindow(display), + (char *)mask_bits, + surface->w, surface->h); + cursor = X11_XCreatePixmapCursor(display, data_pixmap, mask_pixmap, + &fg, &bg, hot_x, hot_y); + X11_XFreePixmap(display, data_pixmap); + X11_XFreePixmap(display, mask_pixmap); + SDL_free(data_bits); + SDL_free(mask_bits); + + return cursor; +} + +static SDL_Cursor *X11_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + Cursor x11_cursor = None; + +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR + if (SDL_X11_HAVE_XCURSOR) { + x11_cursor = X11_CreateXCursorCursor(surface, hot_x, hot_y); + } +#endif + if (x11_cursor == None) { + x11_cursor = X11_CreatePixmapCursor(surface, hot_x, hot_y); + } + return X11_CreateCursorAndData(x11_cursor); +} + +static unsigned int GetLegacySystemCursorShape(SDL_SystemCursor id) +{ + switch (id) { + // X Font Cursors reference: + // http://tronche.com/gui/x/xlib/appendix/b/ + case SDL_SYSTEM_CURSOR_DEFAULT: return XC_left_ptr; + case SDL_SYSTEM_CURSOR_TEXT: return XC_xterm; + case SDL_SYSTEM_CURSOR_WAIT: return XC_watch; + case SDL_SYSTEM_CURSOR_CROSSHAIR: return XC_tcross; + case SDL_SYSTEM_CURSOR_PROGRESS: return XC_watch; + case SDL_SYSTEM_CURSOR_NWSE_RESIZE: return XC_top_left_corner; + case SDL_SYSTEM_CURSOR_NESW_RESIZE: return XC_top_right_corner; + case SDL_SYSTEM_CURSOR_EW_RESIZE: return XC_sb_h_double_arrow; + case SDL_SYSTEM_CURSOR_NS_RESIZE: return XC_sb_v_double_arrow; + case SDL_SYSTEM_CURSOR_MOVE: return XC_fleur; + case SDL_SYSTEM_CURSOR_NOT_ALLOWED: return XC_pirate; + case SDL_SYSTEM_CURSOR_POINTER: return XC_hand2; + case SDL_SYSTEM_CURSOR_NW_RESIZE: return XC_top_left_corner; + case SDL_SYSTEM_CURSOR_N_RESIZE: return XC_top_side; + case SDL_SYSTEM_CURSOR_NE_RESIZE: return XC_top_right_corner; + case SDL_SYSTEM_CURSOR_E_RESIZE: return XC_right_side; + case SDL_SYSTEM_CURSOR_SE_RESIZE: return XC_bottom_right_corner; + case SDL_SYSTEM_CURSOR_S_RESIZE: return XC_bottom_side; + case SDL_SYSTEM_CURSOR_SW_RESIZE: return XC_bottom_left_corner; + case SDL_SYSTEM_CURSOR_W_RESIZE: return XC_left_side; + case SDL_SYSTEM_CURSOR_COUNT: break; // so the compiler might notice if an enum value is missing here. + } + + SDL_assert(0); + return 0; +} + +static SDL_Cursor *X11_CreateSystemCursor(SDL_SystemCursor id) +{ + SDL_Cursor *cursor = NULL; + Display *dpy = GetDisplay(); + Cursor x11_cursor = None; + +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR + if (SDL_X11_HAVE_XCURSOR) { + x11_cursor = X11_XcursorLibraryLoadCursor(dpy, SDL_GetCSSCursorName(id, NULL)); + } +#endif + + if (x11_cursor == None) { + x11_cursor = X11_XCreateFontCursor(dpy, GetLegacySystemCursorShape(id)); + } + + if (x11_cursor != None) { + cursor = X11_CreateCursorAndData(x11_cursor); + } + + return cursor; +} + +static SDL_Cursor *X11_CreateDefaultCursor(void) +{ + SDL_SystemCursor id = SDL_GetDefaultSystemCursor(); + return X11_CreateSystemCursor(id); +} + +static void X11_FreeCursor(SDL_Cursor *cursor) +{ + Cursor x11_cursor = cursor->internal->cursor; + + if (x11_cursor != None) { + X11_XFreeCursor(GetDisplay(), x11_cursor); + } + SDL_free(cursor->internal); + SDL_free(cursor); +} + +static bool X11_ShowCursor(SDL_Cursor *cursor) +{ + Cursor x11_cursor = 0; + + if (cursor) { + x11_cursor = cursor->internal->cursor; + } else { + x11_cursor = X11_CreateEmptyCursor(); + } + + // FIXME: Is there a better way than this? + { + SDL_VideoDevice *video = SDL_GetVideoDevice(); + Display *display = GetDisplay(); + SDL_Window *window; + + x11_cursor_visible = !!cursor; + + for (window = video->windows; window; window = window->next) { + SDL_WindowData *data = window->internal; + if (data) { + if (x11_cursor != None) { + X11_XDefineCursor(display, data->xwindow, x11_cursor); + } else { + X11_XUndefineCursor(display, data->xwindow); + } + } + } + X11_XFlush(display); + } + return true; +} + +static void X11_WarpMouseInternal(Window xwindow, float x, float y) +{ + SDL_VideoData *videodata = SDL_GetVideoDevice()->internal; + Display *display = videodata->display; + bool warp_hack = false; + + // XWayland will only warp the cursor if it is hidden, so this workaround is required. + if (videodata->is_xwayland && x11_cursor_visible) { + warp_hack = true; + } + + if (warp_hack) { + X11_ShowCursor(NULL); + } +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + int deviceid = 0; + if (X11_Xinput2IsInitialized()) { + /* It seems XIWarpPointer() doesn't work correctly on multi-head setups: + * https://developer.blender.org/rB165caafb99c6846e53d11c4e966990aaffc06cea + */ + if (ScreenCount(display) == 1) { + X11_XIGetClientPointer(display, None, &deviceid); + } + } + if (deviceid != 0) { + SDL_assert(SDL_X11_HAVE_XINPUT2); + X11_XIWarpPointer(display, deviceid, None, xwindow, 0.0, 0.0, 0, 0, x, y); + } else +#endif + { + X11_XWarpPointer(display, None, xwindow, 0, 0, 0, 0, (int)x, (int)y); + } + + if (warp_hack) { + X11_ShowCursor(SDL_GetCursor()); + } + X11_XSync(display, False); + videodata->global_mouse_changed = true; +} + +static bool X11_WarpMouse(SDL_Window *window, float x, float y) +{ + SDL_WindowData *data = window->internal; + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + // If we have no barrier, we need to warp + if (data->pointer_barrier_active == false) { + X11_WarpMouseInternal(data->xwindow, x, y); + } +#else + X11_WarpMouseInternal(data->xwindow, x, y); +#endif + return true; +} + +static bool X11_WarpMouseGlobal(float x, float y) +{ + X11_WarpMouseInternal(DefaultRootWindow(GetDisplay()), x, y); + return true; +} + +static bool X11_SetRelativeMouseMode(bool enabled) +{ + if (!X11_Xinput2IsInitialized()) { + return SDL_Unsupported(); + } + return true; +} + +static bool X11_CaptureMouse(SDL_Window *window) +{ + Display *display = GetDisplay(); + SDL_Window *mouse_focus = SDL_GetMouseFocus(); + + if (window) { + SDL_WindowData *data = window->internal; + + /* If XInput2 is handling the pointer input, non-confinement grabs will always fail with 'AlreadyGrabbed', + * since the pointer is being grabbed by XInput2. + */ + if (!data->xinput2_mouse_enabled || data->mouse_grabbed) { + const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask; + Window confined = (data->mouse_grabbed ? data->xwindow : None); + const int rc = X11_XGrabPointer(display, data->xwindow, False, + mask, GrabModeAsync, GrabModeAsync, + confined, None, CurrentTime); + if (rc != GrabSuccess) { + return SDL_SetError("X server refused mouse capture"); + } + + if (data->mouse_grabbed) { + // XGrabPointer can warp the cursor when confining, so update the coordinates. + data->videodata->global_mouse_changed = true; + } + } + } else if (mouse_focus) { + SDL_UpdateWindowGrab(mouse_focus); + } else { + X11_XUngrabPointer(display, CurrentTime); + } + + X11_XSync(display, False); + + return true; +} + +static SDL_MouseButtonFlags X11_GetGlobalMouseState(float *x, float *y) +{ + SDL_VideoData *videodata = SDL_GetVideoDevice()->internal; + SDL_DisplayID *displays; + Display *display = GetDisplay(); + int i; + + // !!! FIXME: should we XSync() here first? + + if (!X11_Xinput2IsInitialized()) { + videodata->global_mouse_changed = true; + } + + // check if we have this cached since XInput last saw the mouse move. + // !!! FIXME: can we just calculate this from XInput's events? + if (videodata->global_mouse_changed) { + displays = SDL_GetDisplays(NULL); + if (displays) { + for (i = 0; displays[i]; ++i) { + SDL_DisplayData *data = SDL_GetDisplayDriverData(displays[i]); + if (data) { + Window root, child; + int rootx, rooty, winx, winy; + unsigned int mask; + if (X11_XQueryPointer(display, RootWindow(display, data->screen), &root, &child, &rootx, &rooty, &winx, &winy, &mask)) { + XWindowAttributes root_attrs; + SDL_MouseButtonFlags buttons = 0; + buttons |= (mask & Button1Mask) ? SDL_BUTTON_LMASK : 0; + buttons |= (mask & Button2Mask) ? SDL_BUTTON_MMASK : 0; + buttons |= (mask & Button3Mask) ? SDL_BUTTON_RMASK : 0; + // Use the SDL state for the extended buttons - it's better than nothing + buttons |= (SDL_GetMouseState(NULL, NULL) & (SDL_BUTTON_X1MASK | SDL_BUTTON_X2MASK)); + /* SDL_DisplayData->x,y point to screen origin, and adding them to mouse coordinates relative to root window doesn't do the right thing + * (observed on dual monitor setup with primary display being the rightmost one - mouse was offset to the right). + * + * Adding root position to root-relative coordinates seems to be a better way to get absolute position. */ + X11_XGetWindowAttributes(display, root, &root_attrs); + videodata->global_mouse_position.x = root_attrs.x + rootx; + videodata->global_mouse_position.y = root_attrs.y + rooty; + videodata->global_mouse_buttons = buttons; + videodata->global_mouse_changed = false; + break; + } + } + } + SDL_free(displays); + } + } + + SDL_assert(!videodata->global_mouse_changed); // The pointer wasn't on any X11 screen?! + + *x = (float)videodata->global_mouse_position.x; + *y = (float)videodata->global_mouse_position.y; + return videodata->global_mouse_buttons; +} + +void X11_InitMouse(SDL_VideoDevice *_this) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = X11_CreateCursor; + mouse->CreateSystemCursor = X11_CreateSystemCursor; + mouse->ShowCursor = X11_ShowCursor; + mouse->FreeCursor = X11_FreeCursor; + mouse->WarpMouse = X11_WarpMouse; + mouse->WarpMouseGlobal = X11_WarpMouseGlobal; + mouse->SetRelativeMouseMode = X11_SetRelativeMouseMode; + mouse->CaptureMouse = X11_CaptureMouse; + mouse->GetGlobalMouseState = X11_GetGlobalMouseState; + + SDL_HitTestResult r = SDL_HITTEST_NORMAL; + while (r <= SDL_HITTEST_RESIZE_LEFT) { + switch (r) { + case SDL_HITTEST_NORMAL: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); break; + case SDL_HITTEST_DRAGGABLE: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_DEFAULT); break; + case SDL_HITTEST_RESIZE_TOPLEFT: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_NW_RESIZE); break; + case SDL_HITTEST_RESIZE_TOP: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_N_RESIZE); break; + case SDL_HITTEST_RESIZE_TOPRIGHT: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_NE_RESIZE); break; + case SDL_HITTEST_RESIZE_RIGHT: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_E_RESIZE); break; + case SDL_HITTEST_RESIZE_BOTTOMRIGHT: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_SE_RESIZE); break; + case SDL_HITTEST_RESIZE_BOTTOM: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_S_RESIZE); break; + case SDL_HITTEST_RESIZE_BOTTOMLEFT: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_SW_RESIZE); break; + case SDL_HITTEST_RESIZE_LEFT: sys_cursors[r] = X11_CreateSystemCursor(SDL_SYSTEM_CURSOR_W_RESIZE); break; + } + r++; + } + + SDL_SetDefaultCursor(X11_CreateDefaultCursor()); +} + +void X11_QuitMouse(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + SDL_XInput2DeviceInfo *i; + SDL_XInput2DeviceInfo *next; + int j; + + for (j = 0; j < SDL_arraysize(sys_cursors); j++) { + X11_FreeCursor(sys_cursors[j]); + sys_cursors[j] = NULL; + } + + for (i = data->mouse_device_info; i; i = next) { + next = i->next; + SDL_free(i); + } + data->mouse_device_info = NULL; + + X11_DestroyEmptyCursor(); +} + +void X11_SetHitTestCursor(SDL_HitTestResult rc) +{ + if (rc == SDL_HITTEST_NORMAL || rc == SDL_HITTEST_DRAGGABLE) { + SDL_SetCursor(NULL); + } else { + X11_ShowCursor(sys_cursors[rc]); + } +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.h new file mode 100644 index 0000000..2a2973c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11mouse.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11mouse_h_ +#define SDL_x11mouse_h_ + +typedef struct SDL_XInput2DeviceInfo +{ + int device_id; + bool relative[2]; + double minval[2]; + double maxval[2]; + double prev_coords[2]; + struct SDL_XInput2DeviceInfo *next; +} SDL_XInput2DeviceInfo; + +extern void X11_InitMouse(SDL_VideoDevice *_this); +extern void X11_QuitMouse(SDL_VideoDevice *_this); +extern void X11_SetHitTestCursor(SDL_HitTestResult rc); + +#endif // SDL_x11mouse_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.c new file mode 100644 index 0000000..d46409f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.c @@ -0,0 +1,1116 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + Copyright (C) 2021 NVIDIA Corporation + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" +#include "SDL_x11xsync.h" + +// GLX implementation of SDL OpenGL support + +#ifdef SDL_VIDEO_OPENGL_GLX +#include "SDL_x11opengles.h" + +#if defined(SDL_PLATFORM_IRIX) || defined(SDL_PLATFORM_NETBSD) || defined(SDL_PLATFORM_OPENBSD) +/* + * IRIX doesn't have a GL library versioning system. + * NetBSD and OpenBSD have different GL library versions depending on how + * the library was installed. + */ +#define DEFAULT_OPENGL "libGL.so" +#elif defined(SDL_PLATFORM_MACOS) +#define DEFAULT_OPENGL "/opt/X11/lib/libGL.1.dylib" +#else +#define DEFAULT_OPENGL "libGL.so.1" +#endif + +#ifndef GLX_NONE_EXT +#define GLX_NONE_EXT 0x8000 +#endif + +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 +#endif + +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_NONE_EXT 0x8000 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D +#endif + +#ifndef GLX_EXT_visual_info +#define GLX_EXT_visual_info +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#endif + +#ifndef GLX_ARB_create_context +#define GLX_ARB_create_context +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +// Typedef for the GL 3.0 context creation function +typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display *dpy, + GLXFBConfig config, + GLXContext + share_context, + Bool direct, + const int + *attrib_list); +#endif + +#ifndef GLX_ARB_create_context_profile +#define GLX_ARB_create_context_profile +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#endif + +#ifndef GLX_ARB_create_context_robustness +#define GLX_ARB_create_context_robustness +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#endif + +#ifndef GLX_EXT_create_context_es2_profile +#define GLX_EXT_create_context_es2_profile +#ifndef GLX_CONTEXT_ES2_PROFILE_BIT_EXT +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000002 +#endif +#endif + +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB +#ifndef GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 +#endif +#endif + +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float +#ifndef GLX_RGBA_FLOAT_TYPE_ARB +#define GLX_RGBA_FLOAT_TYPE_ARB 0x20B9 +#endif +#ifndef GLX_RGBA_FLOAT_BIT_ARB +#define GLX_RGBA_FLOAT_BIT_ARB 0x00000004 +#endif +#endif + +#ifndef GLX_ARB_create_context_no_error +#define GLX_ARB_create_context_no_error +#ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB +#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 +#endif +#endif + +#ifndef GLX_EXT_swap_control +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 +#endif + +#ifndef GLX_EXT_swap_control_tear +#define GLX_LATE_SWAPS_TEAR_EXT 0x20F3 +#endif + +#ifndef GLX_ARB_context_flush_control +#define GLX_ARB_context_flush_control +#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0x0000 +#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 +#endif + +#define OPENGL_REQUIRES_DLOPEN +#if defined(OPENGL_REQUIRES_DLOPEN) && defined(HAVE_DLOPEN) +#include +#define GL_LoadObject(X) dlopen(X, (RTLD_NOW | RTLD_GLOBAL)) +#define GL_LoadFunction dlsym +#define GL_UnloadObject dlclose +#else +#define GL_LoadObject SDL_LoadObject +#define GL_LoadFunction SDL_LoadFunction +#define GL_UnloadObject SDL_UnloadObject +#endif + +static void X11_GL_InitExtensions(SDL_VideoDevice *_this); + +bool X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + Display *display; + SDL_SharedObject *handle; + + if (_this->gl_data) { + return SDL_SetError("OpenGL context already created"); + } + + // Load the OpenGL library + if (path == NULL) { + path = SDL_GetHint(SDL_HINT_OPENGL_LIBRARY); + } + if (path == NULL) { + path = DEFAULT_OPENGL; + } + _this->gl_config.dll_handle = GL_LoadObject(path); + if (!_this->gl_config.dll_handle) { +#if defined(OPENGL_REQUIRES_DLOPEN) && defined(HAVE_DLOPEN) + SDL_SetError("Failed loading %s: %s", path, dlerror()); +#endif + return false; + } + SDL_strlcpy(_this->gl_config.driver_path, path, + SDL_arraysize(_this->gl_config.driver_path)); + + // Allocate OpenGL memory + _this->gl_data = + (struct SDL_GLDriverData *)SDL_calloc(1, + sizeof(struct + SDL_GLDriverData)); + if (!_this->gl_data) { + return false; + } + + // Load function pointers + handle = _this->gl_config.dll_handle; + _this->gl_data->glXQueryExtension = + (Bool(*)(Display *, int *, int *)) + GL_LoadFunction(handle, "glXQueryExtension"); + _this->gl_data->glXGetProcAddress = + (__GLXextFuncPtr (*)(const GLubyte *)) + GL_LoadFunction(handle, "glXGetProcAddressARB"); + _this->gl_data->glXChooseVisual = + (XVisualInfo * (*)(Display *, int, int *)) + X11_GL_GetProcAddress(_this, "glXChooseVisual"); + _this->gl_data->glXCreateContext = + (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int)) + X11_GL_GetProcAddress(_this, "glXCreateContext"); + _this->gl_data->glXDestroyContext = + (void (*)(Display *, GLXContext)) + X11_GL_GetProcAddress(_this, "glXDestroyContext"); + _this->gl_data->glXMakeCurrent = + (int (*)(Display *, GLXDrawable, GLXContext)) + X11_GL_GetProcAddress(_this, "glXMakeCurrent"); + _this->gl_data->glXSwapBuffers = + (void (*)(Display *, GLXDrawable)) + X11_GL_GetProcAddress(_this, "glXSwapBuffers"); + _this->gl_data->glXQueryDrawable = + (void (*)(Display *, GLXDrawable, int, unsigned int *)) + X11_GL_GetProcAddress(_this, "glXQueryDrawable"); + + if (!_this->gl_data->glXQueryExtension || + !_this->gl_data->glXChooseVisual || + !_this->gl_data->glXCreateContext || + !_this->gl_data->glXDestroyContext || + !_this->gl_data->glXMakeCurrent || + !_this->gl_data->glXSwapBuffers) { + return SDL_SetError("Could not retrieve OpenGL functions"); + } + + display = _this->internal->display; + if (!_this->gl_data->glXQueryExtension(display, &_this->gl_data->errorBase, &_this->gl_data->eventBase)) { + return SDL_SetError("GLX is not supported"); + } + + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNTESTED; + + // Initialize extensions + /* See lengthy comment about the inc/dec in + ../windows/SDL_windowsopengl.c. */ + ++_this->gl_config.driver_loaded; + X11_GL_InitExtensions(_this); + --_this->gl_config.driver_loaded; + + /* If we need a GL ES context and there's no + * GLX_EXT_create_context_es2_profile extension, switch over to X11_GLES functions + */ + if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) && + X11_GL_UseEGL(_this)) { +#ifdef SDL_VIDEO_OPENGL_EGL + X11_GL_UnloadLibrary(_this); + _this->GL_LoadLibrary = X11_GLES_LoadLibrary; + _this->GL_GetProcAddress = X11_GLES_GetProcAddress; + _this->GL_UnloadLibrary = X11_GLES_UnloadLibrary; + _this->GL_CreateContext = X11_GLES_CreateContext; + _this->GL_MakeCurrent = X11_GLES_MakeCurrent; + _this->GL_SetSwapInterval = X11_GLES_SetSwapInterval; + _this->GL_GetSwapInterval = X11_GLES_GetSwapInterval; + _this->GL_SwapWindow = X11_GLES_SwapWindow; + _this->GL_DestroyContext = X11_GLES_DestroyContext; + return X11_GLES_LoadLibrary(_this, NULL); +#else + return SDL_SetError("SDL not configured with EGL support"); +#endif + } + + return true; +} + +SDL_FunctionPointer X11_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) +{ + if (_this->gl_data->glXGetProcAddress) { + return _this->gl_data->glXGetProcAddress((const GLubyte *)proc); + } + return GL_LoadFunction(_this->gl_config.dll_handle, proc); +} + +void X11_GL_UnloadLibrary(SDL_VideoDevice *_this) +{ + /* Don't actually unload the library, since it may have registered + * X11 shutdown hooks, per the notes at: + * http://dri.sourceforge.net/doc/DRIuserguide.html + */ +#if 0 + GL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; +#endif + + // Free OpenGL memory + SDL_free(_this->gl_data); + _this->gl_data = NULL; +} + +static bool HasExtension(const char *extension, const char *extensions) +{ + const char *start; + const char *where, *terminator; + + if (!extensions) { + return false; + } + + // Extension names should not have spaces. + where = SDL_strchr(extension, ' '); + if (where || *extension == '\0') { + return false; + } + + /* It takes a bit of care to be fool-proof about parsing the + * OpenGL extensions string. Don't be fooled by sub-strings, + * etc. */ + + start = extensions; + + for (;;) { + where = SDL_strstr(start, extension); + if (!where) { + break; + } + + terminator = where + SDL_strlen(extension); + if (where == start || *(where - 1) == ' ') { + if (*terminator == ' ' || *terminator == '\0') { + return true; + } + } + + start = terminator; + } + return false; +} + +static void X11_GL_InitExtensions(SDL_VideoDevice *_this) +{ + Display *display = _this->internal->display; + const int screen = DefaultScreen(display); + XVisualInfo *vinfo = NULL; + Window w = 0; + GLXContext prev_ctx = 0; + GLXDrawable prev_drawable = 0; + GLXContext context = 0; + const char *(*glXQueryExtensionsStringFunc)(Display *, int); + const char *extensions; + + vinfo = X11_GL_GetVisual(_this, display, screen, false); + if (vinfo) { + GLXContext (*glXGetCurrentContextFunc)(void) = + (GLXContext(*)(void)) + X11_GL_GetProcAddress(_this, "glXGetCurrentContext"); + + GLXDrawable (*glXGetCurrentDrawableFunc)(void) = + (GLXDrawable(*)(void)) + X11_GL_GetProcAddress(_this, "glXGetCurrentDrawable"); + + if (glXGetCurrentContextFunc && glXGetCurrentDrawableFunc) { + XSetWindowAttributes xattr; + prev_ctx = glXGetCurrentContextFunc(); + prev_drawable = glXGetCurrentDrawableFunc(); + + xattr.background_pixel = 0; + xattr.border_pixel = 0; + xattr.colormap = + X11_XCreateColormap(display, RootWindow(display, screen), + vinfo->visual, AllocNone); + w = X11_XCreateWindow(display, RootWindow(display, screen), 0, 0, + 32, 32, 0, vinfo->depth, InputOutput, vinfo->visual, + (CWBackPixel | CWBorderPixel | CWColormap), &xattr); + + context = _this->gl_data->glXCreateContext(display, vinfo, + NULL, True); + if (context) { + _this->gl_data->glXMakeCurrent(display, w, context); + } + } + + X11_XFree(vinfo); + } + + glXQueryExtensionsStringFunc = + (const char *(*)(Display *, int))X11_GL_GetProcAddress(_this, + "glXQueryExtensionsString"); + if (glXQueryExtensionsStringFunc) { + extensions = glXQueryExtensionsStringFunc(display, screen); + } else { + extensions = NULL; + } + + // Check for GLX_EXT_swap_control(_tear) + _this->gl_data->HAS_GLX_EXT_swap_control_tear = false; + if (HasExtension("GLX_EXT_swap_control", extensions)) { + _this->gl_data->glXSwapIntervalEXT = + (void (*)(Display *, GLXDrawable, int)) + X11_GL_GetProcAddress(_this, "glXSwapIntervalEXT"); + if (HasExtension("GLX_EXT_swap_control_tear", extensions)) { + _this->gl_data->HAS_GLX_EXT_swap_control_tear = true; + } + } + + // Check for GLX_MESA_swap_control + if (HasExtension("GLX_MESA_swap_control", extensions)) { + _this->gl_data->glXSwapIntervalMESA = + (int (*)(int))X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); + _this->gl_data->glXGetSwapIntervalMESA = + (int (*)(void))X11_GL_GetProcAddress(_this, + "glXGetSwapIntervalMESA"); + } + + // Check for GLX_SGI_swap_control + if (HasExtension("GLX_SGI_swap_control", extensions)) { + _this->gl_data->glXSwapIntervalSGI = + (int (*)(int))X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); + } + + // Check for GLX_ARB_create_context + if (HasExtension("GLX_ARB_create_context", extensions)) { + _this->gl_data->glXCreateContextAttribsARB = + (GLXContext(*)(Display *, GLXFBConfig, GLXContext, Bool, const int *)) + X11_GL_GetProcAddress(_this, "glXCreateContextAttribsARB"); + _this->gl_data->glXChooseFBConfig = + (GLXFBConfig * (*)(Display *, int, const int *, int *)) + X11_GL_GetProcAddress(_this, "glXChooseFBConfig"); + _this->gl_data->glXGetVisualFromFBConfig = + (XVisualInfo * (*)(Display *, GLXFBConfig)) + X11_GL_GetProcAddress(_this, "glXGetVisualFromFBConfig"); + } + + // Check for GLX_EXT_visual_rating + if (HasExtension("GLX_EXT_visual_rating", extensions)) { + _this->gl_data->HAS_GLX_EXT_visual_rating = true; + } + + // Check for GLX_EXT_visual_info + if (HasExtension("GLX_EXT_visual_info", extensions)) { + _this->gl_data->HAS_GLX_EXT_visual_info = true; + } + + // Check for GLX_EXT_create_context_es2_profile + if (HasExtension("GLX_EXT_create_context_es2_profile", extensions)) { + // this wants to call glGetString(), so it needs a context. + // !!! FIXME: it would be nice not to make a context here though! + if (context) { + SDL_GL_DeduceMaxSupportedESProfile( + &_this->gl_data->es_profile_max_supported_version.major, + &_this->gl_data->es_profile_max_supported_version.minor); + } + } + + // Check for GLX_ARB_context_flush_control + if (HasExtension("GLX_ARB_context_flush_control", extensions)) { + _this->gl_data->HAS_GLX_ARB_context_flush_control = true; + } + + // Check for GLX_ARB_create_context_robustness + if (HasExtension("GLX_ARB_create_context_robustness", extensions)) { + _this->gl_data->HAS_GLX_ARB_create_context_robustness = true; + } + + // Check for GLX_ARB_create_context_no_error + if (HasExtension("GLX_ARB_create_context_no_error", extensions)) { + _this->gl_data->HAS_GLX_ARB_create_context_no_error = true; + } + + if (context) { + _this->gl_data->glXMakeCurrent(display, None, NULL); + _this->gl_data->glXDestroyContext(display, context); + if (prev_ctx && prev_drawable) { + _this->gl_data->glXMakeCurrent(display, prev_drawable, prev_ctx); + } + } + + if (w) { + X11_XDestroyWindow(display, w); + } + X11_PumpEvents(_this); +} + +/* glXChooseVisual and glXChooseFBConfig have some small differences in + * the attribute encoding, it can be chosen with the for_FBConfig parameter. + * Some targets fail if you use GLX_X_VISUAL_TYPE_EXT/GLX_DIRECT_COLOR_EXT, + * so it gets specified last if used and is pointed to by *_pvistypeattr. + * In case of failure, if that pointer is not NULL, set that pointer to None + * and try again. + */ +static int X11_GL_GetAttributes(SDL_VideoDevice *_this, Display *display, int screen, int *attribs, int size, Bool for_FBConfig, int **_pvistypeattr, bool transparent) +{ + int i = 0; + const int MAX_ATTRIBUTES = 64; + int *pvistypeattr = NULL; + + // assert buffer is large enough to hold all SDL attributes. + SDL_assert(size >= MAX_ATTRIBUTES); + + // Setup our GLX attributes according to the gl_config. + if (for_FBConfig) { + attribs[i++] = GLX_RENDER_TYPE; + if (_this->gl_config.floatbuffers) { + attribs[i++] = GLX_RGBA_FLOAT_BIT_ARB; + } else { + attribs[i++] = GLX_RGBA_BIT; + } + } else { + attribs[i++] = GLX_RGBA; + } + attribs[i++] = GLX_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = GLX_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = GLX_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + + if (_this->gl_config.alpha_size) { + attribs[i++] = GLX_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + + if (_this->gl_config.double_buffer) { + attribs[i++] = GLX_DOUBLEBUFFER; + if (for_FBConfig) { + attribs[i++] = True; + } + } + + attribs[i++] = GLX_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + + if (_this->gl_config.stencil_size) { + attribs[i++] = GLX_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } + + if (_this->gl_config.accum_red_size) { + attribs[i++] = GLX_ACCUM_RED_SIZE; + attribs[i++] = _this->gl_config.accum_red_size; + } + + if (_this->gl_config.accum_green_size) { + attribs[i++] = GLX_ACCUM_GREEN_SIZE; + attribs[i++] = _this->gl_config.accum_green_size; + } + + if (_this->gl_config.accum_blue_size) { + attribs[i++] = GLX_ACCUM_BLUE_SIZE; + attribs[i++] = _this->gl_config.accum_blue_size; + } + + if (_this->gl_config.accum_alpha_size) { + attribs[i++] = GLX_ACCUM_ALPHA_SIZE; + attribs[i++] = _this->gl_config.accum_alpha_size; + } + + if (_this->gl_config.stereo) { + attribs[i++] = GLX_STEREO; + if (for_FBConfig) { + attribs[i++] = True; + } + } + + if (_this->gl_config.multisamplebuffers) { + attribs[i++] = GLX_SAMPLE_BUFFERS_ARB; + attribs[i++] = _this->gl_config.multisamplebuffers; + } + + if (_this->gl_config.multisamplesamples) { + attribs[i++] = GLX_SAMPLES_ARB; + attribs[i++] = _this->gl_config.multisamplesamples; + } + + if (_this->gl_config.floatbuffers) { + attribs[i++] = GLX_RENDER_TYPE; + attribs[i++] = GLX_RGBA_FLOAT_TYPE_ARB; + } + + if (_this->gl_config.framebuffer_srgb_capable) { + attribs[i++] = GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB; + attribs[i++] = True; // always needed, for_FBConfig or not! + } + + if (_this->gl_config.accelerated >= 0 && + _this->gl_data->HAS_GLX_EXT_visual_rating) { + attribs[i++] = GLX_VISUAL_CAVEAT_EXT; + attribs[i++] = _this->gl_config.accelerated ? GLX_NONE_EXT : GLX_SLOW_VISUAL_EXT; + } + + // Un-wanted when we request a transparent buffer + if (!transparent) { + /* If we're supposed to use DirectColor visuals, and we've got the + EXT_visual_info extension, then add GLX_X_VISUAL_TYPE_EXT. */ + if (X11_UseDirectColorVisuals() && _this->gl_data->HAS_GLX_EXT_visual_info) { + pvistypeattr = &attribs[i]; + attribs[i++] = GLX_X_VISUAL_TYPE_EXT; + attribs[i++] = GLX_DIRECT_COLOR_EXT; + } + } + + attribs[i++] = None; + + SDL_assert(i <= MAX_ATTRIBUTES); + + if (_pvistypeattr) { + *_pvistypeattr = pvistypeattr; + } + + return i; +} + +//get the first transparent Visual +static XVisualInfo* X11_GL_GetTransparentVisualInfo(Display *display, int screen) +{ + XVisualInfo* visualinfo = NULL; + XVisualInfo vi_in; + int out_count = 0; + + vi_in.screen = screen; + visualinfo = X11_XGetVisualInfo(display, VisualScreenMask, &vi_in, &out_count); + if (visualinfo != NULL) { + int i = 0; + for (i = 0; i < out_count; i++) { + XVisualInfo* v = &visualinfo[i]; + Uint32 format = X11_GetPixelFormatFromVisualInfo(display, v); + if (SDL_ISPIXELFORMAT_ALPHA(format)) { + vi_in.screen = screen; + vi_in.visualid = v->visualid; + X11_XFree(visualinfo); + visualinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count); + break; + } + } + } + return visualinfo; +} + +XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent) +{ + // 64 seems nice. + int attribs[64]; + XVisualInfo *vinfo = NULL; + int *pvistypeattr = NULL; + + if (!_this->gl_data) { + // The OpenGL library wasn't loaded, SDL_GetError() should have info + return NULL; + } + + if (_this->gl_data->glXChooseFBConfig && + _this->gl_data->glXGetVisualFromFBConfig) { + GLXFBConfig *framebuffer_config = NULL; + int fbcount = 0; + + X11_GL_GetAttributes(_this, display, screen, attribs, 64, true, &pvistypeattr, transparent); + framebuffer_config = _this->gl_data->glXChooseFBConfig(display, screen, attribs, &fbcount); + if (!framebuffer_config && (pvistypeattr != NULL)) { + *pvistypeattr = None; + framebuffer_config = _this->gl_data->glXChooseFBConfig(display, screen, attribs, &fbcount); + } + + if (transparent) { + // Return the first transparent Visual + int i; + for (i = 0; i < fbcount; i++) { + Uint32 format; + vinfo = _this->gl_data->glXGetVisualFromFBConfig(display, framebuffer_config[i]); + format = X11_GetPixelFormatFromVisualInfo(display, vinfo); + if (SDL_ISPIXELFORMAT_ALPHA(format)) { // found! + X11_XFree(framebuffer_config); + framebuffer_config = NULL; + break; + } + X11_XFree(vinfo); + vinfo = NULL; + } + } + + if (framebuffer_config) { + vinfo = _this->gl_data->glXGetVisualFromFBConfig(display, framebuffer_config[0]); + } + + X11_XFree(framebuffer_config); + } + + if (!vinfo) { + X11_GL_GetAttributes(_this, display, screen, attribs, 64, false, &pvistypeattr, transparent); + vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); + + if (!vinfo && (pvistypeattr != NULL)) { + *pvistypeattr = None; + vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); + } + } + + if (transparent && vinfo) { + Uint32 format = X11_GetPixelFormatFromVisualInfo(display, vinfo); + if (!SDL_ISPIXELFORMAT_ALPHA(format)) { + // not transparent! + XVisualInfo* visualinfo = X11_GL_GetTransparentVisualInfo(display, screen); + if (visualinfo != NULL) { + X11_XFree(vinfo); + vinfo = visualinfo; + } + } + } + + if (!vinfo) { + SDL_SetError("Couldn't find matching GLX visual"); + } + return vinfo; +} + +static int (*handler)(Display *, XErrorEvent *) = NULL; +static const char *errorHandlerOperation = NULL; +static int errorBase = 0; +static int errorCode = 0; +static int X11_GL_ErrorHandler(Display *d, XErrorEvent *e) +{ + char *x11_error = NULL; + char x11_error_locale[256]; + + errorCode = e->error_code; + if (X11_XGetErrorText(d, errorCode, x11_error_locale, sizeof(x11_error_locale)) == Success) { + x11_error = SDL_iconv_string("UTF-8", "", x11_error_locale, SDL_strlen(x11_error_locale) + 1); + } + + if (x11_error) { + SDL_SetError("Could not %s: %s", errorHandlerOperation, x11_error); + SDL_free(x11_error); + } else { + SDL_SetError("Could not %s: %i (Base %i)", errorHandlerOperation, errorCode, errorBase); + } + + return 0; +} + +bool X11_GL_UseEGL(SDL_VideoDevice *_this) +{ + SDL_assert(_this->gl_data != NULL); + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { + // use of EGL has been requested, even for desktop GL + return true; + } + + SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES); + return (SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, false) || _this->gl_config.major_version == 1 // No GLX extension for OpenGL ES 1.x profiles. + || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor)); +} + +SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + int screen = SDL_GetDisplayDriverDataForWindow(window)->screen; + XWindowAttributes xattr; + XVisualInfo v, *vinfo; + int n; + SDL_GLContext context = NULL; + GLXContext share_context; + const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? true : false; + + if (_this->gl_config.share_with_current_context) { + share_context = (GLXContext)SDL_GL_GetCurrentContext(); + } else { + share_context = NULL; + } + + // We do this to create a clean separation between X and GLX errors. + X11_XSync(display, False); + errorHandlerOperation = "create GL context"; + errorBase = _this->gl_data->errorBase; + errorCode = Success; + handler = X11_XSetErrorHandler(X11_GL_ErrorHandler); + X11_XGetWindowAttributes(display, data->xwindow, &xattr); + v.screen = screen; + v.visualid = X11_XVisualIDFromVisual(xattr.visual); + vinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); + if (vinfo) { + if (_this->gl_config.major_version < 3 && + _this->gl_config.profile_mask == 0 && + _this->gl_config.flags == 0 && !transparent) { + // Create legacy context + context = + (SDL_GLContext)_this->gl_data->glXCreateContext(display, vinfo, share_context, True); + } else { + // max 14 attributes plus terminator + int attribs[15] = { + GLX_CONTEXT_MAJOR_VERSION_ARB, + _this->gl_config.major_version, + GLX_CONTEXT_MINOR_VERSION_ARB, + _this->gl_config.minor_version, + 0 + }; + int iattr = 4; + + // SDL profile bits match GLX profile bits + if (_this->gl_config.profile_mask != 0) { + attribs[iattr++] = GLX_CONTEXT_PROFILE_MASK_ARB; + attribs[iattr++] = _this->gl_config.profile_mask; + } + + // SDL flags match GLX flags + if (_this->gl_config.flags != 0) { + attribs[iattr++] = GLX_CONTEXT_FLAGS_ARB; + attribs[iattr++] = _this->gl_config.flags; + } + + // only set if glx extension is available and not the default setting + if ((_this->gl_data->HAS_GLX_ARB_context_flush_control) && (_this->gl_config.release_behavior == 0)) { + attribs[iattr++] = GLX_CONTEXT_RELEASE_BEHAVIOR_ARB; + attribs[iattr++] = + _this->gl_config.release_behavior ? GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB : GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB; + } + + // only set if glx extension is available and not the default setting + if ((_this->gl_data->HAS_GLX_ARB_create_context_robustness) && (_this->gl_config.reset_notification != 0)) { + attribs[iattr++] = GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB; + attribs[iattr++] = + _this->gl_config.reset_notification ? GLX_LOSE_CONTEXT_ON_RESET_ARB : GLX_NO_RESET_NOTIFICATION_ARB; + } + + // only set if glx extension is available and not the default setting + if ((_this->gl_data->HAS_GLX_ARB_create_context_no_error) && (_this->gl_config.no_error != 0)) { + attribs[iattr++] = GLX_CONTEXT_OPENGL_NO_ERROR_ARB; + attribs[iattr++] = _this->gl_config.no_error; + } + + attribs[iattr++] = 0; + + // Get a pointer to the context creation function for GL 3.0 + if (!_this->gl_data->glXCreateContextAttribsARB) { + SDL_SetError("OpenGL 3.0 and later are not supported by this system"); + } else { + int glxAttribs[64]; + + // Create a GL 3.x context + GLXFBConfig *framebuffer_config = NULL; + int fbcount = 0; + int *pvistypeattr = NULL; + + X11_GL_GetAttributes(_this, display, screen, glxAttribs, 64, true, &pvistypeattr, transparent); + + if (_this->gl_data->glXChooseFBConfig) { + framebuffer_config = _this->gl_data->glXChooseFBConfig(display, + DefaultScreen(display), glxAttribs, + &fbcount); + + if (!framebuffer_config && (pvistypeattr != NULL)) { + *pvistypeattr = None; + framebuffer_config = _this->gl_data->glXChooseFBConfig(display, + DefaultScreen(display), glxAttribs, + &fbcount); + } + + if (transparent && (framebuffer_config != NULL)) { + int i; + for (i = 0; i < fbcount; i++) { + XVisualInfo* vinfo_temp = _this->gl_data->glXGetVisualFromFBConfig(display, framebuffer_config[i]); + if ( vinfo_temp != NULL) { + Uint32 format = X11_GetPixelFormatFromVisualInfo(display, vinfo_temp); + if (SDL_ISPIXELFORMAT_ALPHA(format)) { + // found! + context = (SDL_GLContext)_this->gl_data->glXCreateContextAttribsARB(display, + framebuffer_config[i], + share_context, True, attribs); + X11_XFree(framebuffer_config); + framebuffer_config = NULL; + X11_XFree(vinfo_temp); + break; + } + X11_XFree(vinfo_temp); + } + } + } + if (framebuffer_config) { + context = (SDL_GLContext)_this->gl_data->glXCreateContextAttribsARB(display, + framebuffer_config[0], + share_context, True, attribs); + X11_XFree(framebuffer_config); + } + } + } + } + X11_XFree(vinfo); + } + X11_XSync(display, False); + X11_XSetErrorHandler(handler); + + if (!context) { + if (errorCode == Success) { + SDL_SetError("Could not create GL context"); + } + return NULL; + } + + if (!X11_GL_MakeCurrent(_this, window, context)) { + X11_GL_DestroyContext(_this, context); + return NULL; + } + + return context; +} + +bool X11_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context) +{ + Display *display = _this->internal->display; + Window drawable = + (context ? window->internal->xwindow : None); + GLXContext glx_context = (GLXContext)context; + int rc; + + if (!_this->gl_data) { + return SDL_SetError("OpenGL not initialized"); + } + + // We do this to create a clean separation between X and GLX errors. + X11_XSync(display, False); + errorHandlerOperation = "make GL context current"; + errorBase = _this->gl_data->errorBase; + errorCode = Success; + handler = X11_XSetErrorHandler(X11_GL_ErrorHandler); + rc = _this->gl_data->glXMakeCurrent(display, drawable, glx_context); + X11_XSetErrorHandler(handler); + + if (errorCode != Success) { // uhoh, an X error was thrown! + return false; // the error handler called SDL_SetError() already. + } else if (!rc) { // glXMakeCurrent() failed without throwing an X error + return SDL_SetError("Unable to make GL context current"); + } + + return true; +} + +/* + 0 is a valid argument to glXSwapInterval(MESA|EXT) and setting it to 0 + will undo the effect of a previous call with a value that is greater + than zero (or at least that is what the docs say). OTOH, 0 is an invalid + argument to glXSwapIntervalSGI and it returns an error if you call it + with 0 as an argument. +*/ + +static int swapinterval = 0; +bool X11_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval) +{ + bool result = false; + + if ((interval < 0) && (!_this->gl_data->HAS_GLX_EXT_swap_control_tear)) { + return SDL_SetError("Negative swap interval unsupported in this GL"); + } else if (_this->gl_data->glXSwapIntervalEXT) { + Display *display = _this->internal->display; + const SDL_WindowData *windowdata = SDL_GL_GetCurrentWindow()->internal; + + Window drawable = windowdata->xwindow; + + /* + * This is a workaround for a bug in NVIDIA drivers. Bug has been reported + * and will be fixed in a future release (probably 319.xx). + * + * There's a bug where glXSetSwapIntervalEXT ignores updates because + * it has the wrong value cached. To work around it, we just run a no-op + * update to the current value. + */ + int currentInterval = 0; + X11_GL_GetSwapInterval(_this, ¤tInterval); + _this->gl_data->glXSwapIntervalEXT(display, drawable, currentInterval); + _this->gl_data->glXSwapIntervalEXT(display, drawable, interval); + result = true; + swapinterval = interval; + } else if (_this->gl_data->glXSwapIntervalMESA) { + const int rc = _this->gl_data->glXSwapIntervalMESA(interval); + if (rc == 0) { + swapinterval = interval; + result = true; + } else { + result = SDL_SetError("glXSwapIntervalMESA failed"); + } + } else if (_this->gl_data->glXSwapIntervalSGI) { + const int rc = _this->gl_data->glXSwapIntervalSGI(interval); + if (rc == 0) { + swapinterval = interval; + result = true; + } else { + result = SDL_SetError("glXSwapIntervalSGI failed"); + } + } else { + return SDL_Unsupported(); + } + return result; +} + +static SDL_GLSwapIntervalTearBehavior CheckSwapIntervalTearBehavior(SDL_VideoDevice *_this, Window drawable, unsigned int current_val, unsigned int current_allow_late) +{ + /* Mesa and Nvidia interpret GLX_EXT_swap_control_tear differently, as of this writing, so + figure out which behavior we have. + Technical details: https://github.com/libsdl-org/SDL/issues/8004#issuecomment-1819603282 */ + if (_this->gl_data->swap_interval_tear_behavior == SDL_SWAPINTERVALTEAR_UNTESTED) { + if (!_this->gl_data->HAS_GLX_EXT_swap_control_tear) { + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNKNOWN; + } else { + Display *display = _this->internal->display; + unsigned int allow_late_swap_tearing = 22; + int original_val = (int) current_val; + + /* + * This is a workaround for a bug in NVIDIA drivers. Bug has been reported + * and will be fixed in a future release (probably 319.xx). + * + * There's a bug where glXSetSwapIntervalEXT ignores updates because + * it has the wrong value cached. To work around it, we just run a no-op + * update to the current value. + */ + _this->gl_data->glXSwapIntervalEXT(display, drawable, current_val); + + // set it to no swap interval and see how it affects GLX_LATE_SWAPS_TEAR_EXT... + _this->gl_data->glXSwapIntervalEXT(display, drawable, 0); + _this->gl_data->glXQueryDrawable(display, drawable, GLX_LATE_SWAPS_TEAR_EXT, &allow_late_swap_tearing); + + if (allow_late_swap_tearing == 0) { // GLX_LATE_SWAPS_TEAR_EXT says whether late swapping is currently in use + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_NVIDIA; + if (current_allow_late) { + original_val = -original_val; + } + } else if (allow_late_swap_tearing == 1) { // GLX_LATE_SWAPS_TEAR_EXT says whether the Drawable can use late swapping at all + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_MESA; + } else { // unexpected outcome! + _this->gl_data->swap_interval_tear_behavior = SDL_SWAPINTERVALTEAR_UNKNOWN; + } + + // set us back to what it was originally... + _this->gl_data->glXSwapIntervalEXT(display, drawable, original_val); + } + } + + return _this->gl_data->swap_interval_tear_behavior; +} + + +bool X11_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval) +{ + if (_this->gl_data->glXSwapIntervalEXT) { + Display *display = _this->internal->display; + const SDL_WindowData *windowdata = SDL_GL_GetCurrentWindow()->internal; + Window drawable = windowdata->xwindow; + unsigned int allow_late_swap_tearing = 0; + unsigned int val = 0; + + if (_this->gl_data->HAS_GLX_EXT_swap_control_tear) { + allow_late_swap_tearing = 22; // set this to nonsense. + _this->gl_data->glXQueryDrawable(display, drawable, + GLX_LATE_SWAPS_TEAR_EXT, + &allow_late_swap_tearing); + } + + _this->gl_data->glXQueryDrawable(display, drawable, + GLX_SWAP_INTERVAL_EXT, &val); + + *interval = (int)val; + + switch (CheckSwapIntervalTearBehavior(_this, drawable, val, allow_late_swap_tearing)) { + case SDL_SWAPINTERVALTEAR_MESA: + *interval = (int)val; // unsigned int cast to signed that generates negative value if necessary. + break; + + case SDL_SWAPINTERVALTEAR_NVIDIA: + default: + if ((allow_late_swap_tearing) && (val > 0)) { + *interval = -((int)val); + } + break; + } + + return true; + } else if (_this->gl_data->glXGetSwapIntervalMESA) { + int val = _this->gl_data->glXGetSwapIntervalMESA(); + if (val == GLX_BAD_CONTEXT) { + return SDL_SetError("GLX_BAD_CONTEXT"); + } + *interval = val; + return true; + } else { + *interval = swapinterval; + return true; + } +} + +bool X11_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + + _this->gl_data->glXSwapBuffers(display, data->xwindow); + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + X11_HandlePresent(data->window); +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + + return true; +} + +bool X11_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context) +{ + Display *display = _this->internal->display; + GLXContext glx_context = (GLXContext)context; + + if (!_this->gl_data) { + return true; + } + _this->gl_data->glXDestroyContext(display, glx_context); + X11_XSync(display, False); + return true; +} + +#endif // SDL_VIDEO_OPENGL_GLX + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.h new file mode 100644 index 0000000..24db485 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengl.h @@ -0,0 +1,96 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11opengl_h_ +#define SDL_x11opengl_h_ + +#ifdef SDL_VIDEO_OPENGL_GLX +#include +#include + +typedef void (*__GLXextFuncPtr)(void); + +typedef enum SDL_GLSwapIntervalTearBehavior +{ + SDL_SWAPINTERVALTEAR_UNTESTED, + SDL_SWAPINTERVALTEAR_UNKNOWN, + SDL_SWAPINTERVALTEAR_MESA, + SDL_SWAPINTERVALTEAR_NVIDIA +} SDL_GLSwapIntervalTearBehavior; + +struct SDL_GLDriverData +{ + int errorBase, eventBase; + + bool HAS_GLX_EXT_visual_rating; + bool HAS_GLX_EXT_visual_info; + bool HAS_GLX_EXT_swap_control_tear; + bool HAS_GLX_ARB_context_flush_control; + bool HAS_GLX_ARB_create_context_robustness; + bool HAS_GLX_ARB_create_context_no_error; + + /* Max version of OpenGL ES context that can be created if the + implementation supports GLX_EXT_create_context_es2_profile. + major = minor = 0 when unsupported. + */ + struct + { + int major; + int minor; + } es_profile_max_supported_version; + + SDL_GLSwapIntervalTearBehavior swap_interval_tear_behavior; + + Bool (*glXQueryExtension)(Display *, int *, int *); + __GLXextFuncPtr (*glXGetProcAddress)(const GLubyte *); + XVisualInfo *(*glXChooseVisual)(Display *, int, int *); + GLXContext (*glXCreateContext)(Display *, XVisualInfo *, GLXContext, Bool); + GLXContext (*glXCreateContextAttribsARB)(Display *, GLXFBConfig, GLXContext, Bool, const int *); + GLXFBConfig *(*glXChooseFBConfig)(Display *, int, const int *, int *); + XVisualInfo *(*glXGetVisualFromFBConfig)(Display *, GLXFBConfig); + void (*glXDestroyContext)(Display *, GLXContext); + Bool (*glXMakeCurrent)(Display *, GLXDrawable, GLXContext); + void (*glXSwapBuffers)(Display *, GLXDrawable); + void (*glXQueryDrawable)(Display *, GLXDrawable, int, unsigned int *); + void (*glXSwapIntervalEXT)(Display *, GLXDrawable, int); + int (*glXSwapIntervalSGI)(int); + int (*glXSwapIntervalMESA)(int); + int (*glXGetSwapIntervalMESA)(void); +}; + +// OpenGL functions +extern bool X11_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern SDL_FunctionPointer X11_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc); +extern void X11_GL_UnloadLibrary(SDL_VideoDevice *_this); +extern bool X11_GL_UseEGL(SDL_VideoDevice *_this); +extern XVisualInfo *X11_GL_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent); +extern SDL_GLContext X11_GL_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, + SDL_GLContext context); +extern bool X11_GL_SetSwapInterval(SDL_VideoDevice *_this, int interval); +extern bool X11_GL_GetSwapInterval(SDL_VideoDevice *_this, int *interval); +extern bool X11_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_GL_DestroyContext(SDL_VideoDevice *_this, SDL_GLContext context); + +#endif // SDL_VIDEO_OPENGL_GLX + +#endif // SDL_x11opengl_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.c new file mode 100644 index 0000000..9c1910f --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.c @@ -0,0 +1,152 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_X11) && defined(SDL_VIDEO_OPENGL_EGL) + +#include "SDL_x11video.h" +#include "SDL_x11opengles.h" +#include "SDL_x11opengl.h" +#include "SDL_x11xsync.h" + +// EGL implementation of SDL OpenGL support + +bool X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + SDL_VideoData *data = _this->internal; + + // If the profile requested is not GL ES, switch over to X11_GL functions + if ((_this->gl_config.profile_mask != SDL_GL_CONTEXT_PROFILE_ES) && + !SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { +#ifdef SDL_VIDEO_OPENGL_GLX + X11_GLES_UnloadLibrary(_this); + _this->GL_LoadLibrary = X11_GL_LoadLibrary; + _this->GL_GetProcAddress = X11_GL_GetProcAddress; + _this->GL_UnloadLibrary = X11_GL_UnloadLibrary; + _this->GL_CreateContext = X11_GL_CreateContext; + _this->GL_MakeCurrent = X11_GL_MakeCurrent; + _this->GL_SetSwapInterval = X11_GL_SetSwapInterval; + _this->GL_GetSwapInterval = X11_GL_GetSwapInterval; + _this->GL_SwapWindow = X11_GL_SwapWindow; + _this->GL_DestroyContext = X11_GL_DestroyContext; + return X11_GL_LoadLibrary(_this, path); +#else + return SDL_SetError("SDL not configured with OpenGL/GLX support"); +#endif + } + + return SDL_EGL_LoadLibrary(_this, path, (NativeDisplayType)data->display, _this->gl_config.egl_platform); +} + +XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent) +{ + + XVisualInfo *egl_visualinfo = NULL; + EGLint visual_id = 0; + XVisualInfo vi_in; + int out_count = 0; + + if (!_this->egl_data) { + // The EGL library wasn't loaded, SDL_GetError() should have info + return NULL; + } + + if (_this->egl_data->eglGetConfigAttrib(_this->egl_data->egl_display, + _this->egl_data->egl_config, + EGL_NATIVE_VISUAL_ID, + &visual_id) == EGL_FALSE) { + visual_id = 0; + } + if (visual_id != 0) { + vi_in.screen = screen; + vi_in.visualid = visual_id; + egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count); + if (transparent && egl_visualinfo) { + Uint32 format = X11_GetPixelFormatFromVisualInfo(display, egl_visualinfo); + if (!SDL_ISPIXELFORMAT_ALPHA(format)) { + // not transparent! + X11_XFree(egl_visualinfo); + egl_visualinfo = NULL; + } + } + } + + if(!egl_visualinfo) { + // Use the default visual when all else fails + vi_in.screen = screen; + egl_visualinfo = X11_XGetVisualInfo(display, + VisualScreenMask, + &vi_in, &out_count); + + // Return the first transparent Visual + if (transparent) { + int i; + for (i = 0; i < out_count; i++) { + XVisualInfo *v = &egl_visualinfo[i]; + Uint32 format = X11_GetPixelFormatFromVisualInfo(display, v); + if (SDL_ISPIXELFORMAT_ALPHA(format)) { // found! + // re-request it to have a copy that can be X11_XFree'ed later + vi_in.screen = screen; + vi_in.visualid = v->visualid; + X11_XFree(egl_visualinfo); + egl_visualinfo = X11_XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &vi_in, &out_count); + return egl_visualinfo; + } + } + } + } + return egl_visualinfo; +} + +SDL_GLContext X11_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_GLContext context; + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + + X11_XSync(display, False); + context = SDL_EGL_CreateContext(_this, data->egl_surface); + X11_XSync(display, False); + + return context; +} + +SDL_EGLSurface X11_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + return data->egl_surface; +} + +bool X11_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + const bool ret = SDL_EGL_SwapBuffers(_this, window->internal->egl_surface); \ + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + X11_HandlePresent(window); +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + + return ret; +} + +SDL_EGL_MakeCurrent_impl(X11) + +#endif // SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_EGL + diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.h new file mode 100644 index 0000000..f8e8d3b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11opengles.h @@ -0,0 +1,55 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11opengles_h_ +#define SDL_x11opengles_h_ + +#ifdef SDL_VIDEO_OPENGL_EGL + +#include "../SDL_sysvideo.h" +#include "../SDL_egl_c.h" + +typedef struct SDL_PrivateGLESData +{ + // 1401 If the struct-declaration-list contains no named members, the behavior is undefined. + // warning: empty struct has size 0 in C, size 1 in C++ [-Wc++-compat] + int dummy; +} SDL_PrivateGLESData; + +// OpenGLES functions +#define X11_GLES_GetAttribute SDL_EGL_GetAttribute +#define X11_GLES_GetProcAddress SDL_EGL_GetProcAddressInternal +#define X11_GLES_UnloadLibrary SDL_EGL_UnloadLibrary +#define X11_GLES_SetSwapInterval SDL_EGL_SetSwapInterval +#define X11_GLES_GetSwapInterval SDL_EGL_GetSwapInterval +#define X11_GLES_DestroyContext SDL_EGL_DestroyContext + +extern bool X11_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern XVisualInfo *X11_GLES_GetVisual(SDL_VideoDevice *_this, Display *display, int screen, bool transparent); +extern SDL_GLContext X11_GLES_CreateContext(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_GLES_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext context); +extern SDL_EGLSurface X11_GLES_GetEGLSurface(SDL_VideoDevice *_this, SDL_Window *window); + +#endif // SDL_VIDEO_OPENGL_EGL + +#endif // SDL_x11opengles_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.c new file mode 100644 index 0000000..f16da51 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.c @@ -0,0 +1,437 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#include "../../events/SDL_pen_c.h" +#include "../SDL_sysvideo.h" +#include "SDL_x11pen.h" +#include "SDL_x11video.h" +#include "SDL_x11xinput2.h" + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + +// Does this device have a valuator for pressure sensitivity? +static bool X11_XInput2DeviceIsPen(SDL_VideoDevice *_this, const XIDeviceInfo *dev) +{ + const SDL_VideoData *data = _this->internal; + for (int i = 0; i < dev->num_classes; i++) { + const XIAnyClassInfo *classinfo = dev->classes[i]; + if (classinfo->type == XIValuatorClass) { + const XIValuatorClassInfo *val_classinfo = (const XIValuatorClassInfo *)classinfo; + if (val_classinfo->label == data->atoms.pen_atom_abs_pressure) { + return true; + } + } + } + + return false; +} + +// Heuristically determines if device is an eraser +static bool X11_XInput2PenIsEraser(SDL_VideoDevice *_this, int deviceid, char *devicename) +{ + #define PEN_ERASER_NAME_TAG "eraser" // String constant to identify erasers + SDL_VideoData *data = _this->internal; + + if (data->atoms.pen_atom_wacom_tool_type != None) { + Atom type_return; + int format_return; + unsigned long num_items_return; + unsigned long bytes_after_return; + unsigned char *tooltype_name_info = NULL; + + // Try Wacom-specific method + if (Success == X11_XIGetProperty(data->display, deviceid, + data->atoms.pen_atom_wacom_tool_type, + 0, 32, False, + AnyPropertyType, &type_return, &format_return, + &num_items_return, &bytes_after_return, + &tooltype_name_info) && + tooltype_name_info != NULL && num_items_return > 0) { + + bool result = false; + char *tooltype_name = NULL; + + if (type_return == XA_ATOM) { + // Atom instead of string? Un-intern + Atom atom = *((Atom *)tooltype_name_info); + if (atom != None) { + tooltype_name = X11_XGetAtomName(data->display, atom); + } + } else if (type_return == XA_STRING && format_return == 8) { + tooltype_name = (char *)tooltype_name_info; + } + + if (tooltype_name) { + if (SDL_strcasecmp(tooltype_name, PEN_ERASER_NAME_TAG) == 0) { + result = true; + } + if (tooltype_name != (char *)tooltype_name_info) { + X11_XFree(tooltype_name_info); + } + X11_XFree(tooltype_name); + + return result; + } + } + } + + // Non-Wacom device? + + /* We assume that a device is an eraser if its name contains the string "eraser". + * Unfortunately there doesn't seem to be a clean way to distinguish these cases (as of 2022-03). */ + return (SDL_strcasestr(devicename, PEN_ERASER_NAME_TAG)) ? true : false; +} + +// Read out an integer property and store into a preallocated Sint32 array, extending 8 and 16 bit values suitably. +// Returns number of Sint32s written (<= max_words), or 0 on error. +static size_t X11_XInput2PenGetIntProperty(SDL_VideoDevice *_this, int deviceid, Atom property, Sint32 *dest, size_t max_words) +{ + const SDL_VideoData *data = _this->internal; + Atom type_return; + int format_return; + unsigned long num_items_return; + unsigned long bytes_after_return; + unsigned char *output; + + if (property == None) { + return 0; + } + + if (Success != X11_XIGetProperty(data->display, deviceid, + property, + 0, max_words, False, + XA_INTEGER, &type_return, &format_return, + &num_items_return, &bytes_after_return, + &output) || + num_items_return == 0 || output == NULL) { + return 0; + } + + if (type_return == XA_INTEGER) { + int k; + const int to_copy = SDL_min(max_words, num_items_return); + + if (format_return == 8) { + Sint8 *numdata = (Sint8 *)output; + for (k = 0; k < to_copy; ++k) { + dest[k] = numdata[k]; + } + } else if (format_return == 16) { + Sint16 *numdata = (Sint16 *)output; + for (k = 0; k < to_copy; ++k) { + dest[k] = numdata[k]; + } + } else { + SDL_memcpy(dest, output, sizeof(Sint32) * to_copy); + } + X11_XFree(output); + return to_copy; + } + + return 0; // type mismatch +} + +// Identify Wacom devices (if true is returned) and extract their device type and serial IDs +static bool X11_XInput2PenWacomDeviceID(SDL_VideoDevice *_this, int deviceid, Uint32 *wacom_devicetype_id, Uint32 *wacom_serial) +{ + SDL_VideoData *data = _this->internal; + Sint32 serial_id_buf[3]; + int result; + + if ((result = X11_XInput2PenGetIntProperty(_this, deviceid, data->atoms.pen_atom_wacom_serial_ids, serial_id_buf, 3)) == 3) { + *wacom_devicetype_id = serial_id_buf[2]; + *wacom_serial = serial_id_buf[1]; + return true; + } + + *wacom_devicetype_id = *wacom_serial = 0; + return false; +} + + +typedef struct FindPenByDeviceIDData +{ + int x11_deviceid; + void *handle; +} FindPenByDeviceIDData; + +static bool FindPenByDeviceID(void *handle, void *userdata) +{ + const X11_PenHandle *x11_handle = (const X11_PenHandle *) handle; + FindPenByDeviceIDData *data = (FindPenByDeviceIDData *) userdata; + if (x11_handle->x11_deviceid != data->x11_deviceid) { + return false; + } + data->handle = handle; + return true; +} + +X11_PenHandle *X11_FindPenByDeviceID(int deviceid) +{ + FindPenByDeviceIDData data; + data.x11_deviceid = deviceid; + data.handle = NULL; + SDL_FindPenByCallback(FindPenByDeviceID, &data); + return (X11_PenHandle *) data.handle; +} + +static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo *dev) +{ + SDL_VideoData *data = _this->internal; + SDL_PenCapabilityFlags capabilities = 0; + X11_PenHandle *handle = NULL; + + if ((dev->use != XISlavePointer && (dev->use != XIFloatingSlave)) || dev->enabled == 0 || !X11_XInput2DeviceIsPen(_this, dev)) { + return NULL; // Only track physical devices that are enabled and look like pens + } else if ((handle = X11_FindPenByDeviceID(dev->deviceid)) != 0) { + return handle; // already have this pen, skip it. + } else if ((handle = SDL_calloc(1, sizeof (*handle))) == NULL) { + return NULL; // oh well. + } + + for (int i = 0; i < SDL_arraysize(handle->valuator_for_axis); i++) { + handle->valuator_for_axis[i] = SDL_X11_PEN_AXIS_VALUATOR_MISSING; // until proven otherwise + } + + int total_buttons = 0; + for (int i = 0; i < dev->num_classes; i++) { + const XIAnyClassInfo *classinfo = dev->classes[i]; + if (classinfo->type == XIButtonClass) { + const XIButtonClassInfo *button_classinfo = (const XIButtonClassInfo *)classinfo; + total_buttons += button_classinfo->num_buttons; + } else if (classinfo->type == XIValuatorClass) { + const XIValuatorClassInfo *val_classinfo = (const XIValuatorClassInfo *)classinfo; + const Sint8 valuator_nr = val_classinfo->number; + const Atom vname = val_classinfo->label; + const float min = (float)val_classinfo->min; + const float max = (float)val_classinfo->max; + bool use_this_axis = true; + SDL_PenAxis axis = SDL_PEN_AXIS_COUNT; + + // afaict, SDL_PEN_AXIS_DISTANCE is never reported by XInput2 (Wayland can offer it, though) + if (vname == data->atoms.pen_atom_abs_pressure) { + axis = SDL_PEN_AXIS_PRESSURE; + } else if (vname == data->atoms.pen_atom_abs_tilt_x) { + axis = SDL_PEN_AXIS_XTILT; + } else if (vname == data->atoms.pen_atom_abs_tilt_y) { + axis = SDL_PEN_AXIS_YTILT; + } else { + use_this_axis = false; + } + + // !!! FIXME: there are wacom-specific hacks for getting SDL_PEN_AXIS_(ROTATION|SLIDER) on some devices, but for simplicity, we're skipping all that for now. + + if (use_this_axis) { + capabilities |= SDL_GetPenCapabilityFromAxis(axis); + handle->valuator_for_axis[axis] = valuator_nr; + handle->axis_min[axis] = min; + handle->axis_max[axis] = max; + } + } + } + + // We have a pen if and only if the device measures pressure. + // We checked this in X11_XInput2DeviceIsPen, so just assert it here. + SDL_assert(capabilities & SDL_PEN_CAPABILITY_PRESSURE); + + const bool is_eraser = X11_XInput2PenIsEraser(_this, dev->deviceid, dev->name); + Uint32 wacom_devicetype_id = 0; + Uint32 wacom_serial = 0; + X11_XInput2PenWacomDeviceID(_this, dev->deviceid, &wacom_devicetype_id, &wacom_serial); + + SDL_PenInfo peninfo; + SDL_zero(peninfo); + peninfo.capabilities = capabilities; + peninfo.max_tilt = -1; + peninfo.wacom_id = wacom_devicetype_id; + peninfo.num_buttons = total_buttons; + peninfo.subtype = is_eraser ? SDL_PEN_TYPE_ERASER : SDL_PEN_TYPE_PEN; + if (is_eraser) { + peninfo.capabilities |= SDL_PEN_CAPABILITY_ERASER; + } + + handle->is_eraser = is_eraser; + handle->x11_deviceid = dev->deviceid; + + handle->pen = SDL_AddPenDevice(0, dev->name, &peninfo, handle); + if (!handle->pen) { + SDL_free(handle); + return NULL; + } + + return handle; +} + +X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid) +{ + SDL_VideoData *data = _this->internal; + int num_device_info = 0; + XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, deviceid, &num_device_info); + if (device_info) { + SDL_assert(num_device_info == 1); + X11_PenHandle *handle = X11_MaybeAddPen(_this, device_info); + X11_XIFreeDeviceInfo(device_info); + return handle; + } + return NULL; +} + +void X11_RemovePenByDeviceID(int deviceid) +{ + X11_PenHandle *handle = X11_FindPenByDeviceID(deviceid); + if (handle) { + SDL_RemovePenDevice(0, handle->pen); + SDL_free(handle); + } +} + +void X11_InitPen(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + #define LOOKUP_PEN_ATOM(X) X11_XInternAtom(data->display, X, False) + data->atoms.pen_atom_device_product_id = LOOKUP_PEN_ATOM("Device Product ID"); + data->atoms.pen_atom_wacom_serial_ids = LOOKUP_PEN_ATOM("Wacom Serial IDs"); + data->atoms.pen_atom_wacom_tool_type = LOOKUP_PEN_ATOM("Wacom Tool Type"); + data->atoms.pen_atom_abs_pressure = LOOKUP_PEN_ATOM("Abs Pressure"); + data->atoms.pen_atom_abs_tilt_x = LOOKUP_PEN_ATOM("Abs Tilt X"); + data->atoms.pen_atom_abs_tilt_y = LOOKUP_PEN_ATOM("Abs Tilt Y"); + #undef LOOKUP_PEN_ATOM + + // Do an initial check on devices. After this, we'll add/remove individual pens when XI_HierarchyChanged events alert us. + int num_device_info = 0; + XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, XIAllDevices, &num_device_info); + if (device_info) { + for (int i = 0; i < num_device_info; i++) { + X11_MaybeAddPen(_this, &device_info[i]); + } + X11_XIFreeDeviceInfo(device_info); + } +} + +static void X11_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdata) +{ + SDL_free(handle); +} + +void X11_QuitPen(SDL_VideoDevice *_this) +{ + SDL_RemoveAllPenDevices(X11_FreePenHandle, NULL); +} + +static void X11_XInput2NormalizePenAxes(const X11_PenHandle *pen, float *coords) +{ + // Normalise axes + for (int axis = 0; axis < SDL_PEN_AXIS_COUNT; ++axis) { + const int valuator = pen->valuator_for_axis[axis]; + if (valuator == SDL_X11_PEN_AXIS_VALUATOR_MISSING) { + continue; + } + + float value = coords[axis]; + const float min = pen->axis_min[axis]; + const float max = pen->axis_max[axis]; + + if (axis == SDL_PEN_AXIS_SLIDER) { + value += pen->slider_bias; + } + + // min ... 0 ... max + if (min < 0.0) { + // Normalise so that 0 remains 0.0 + if (value < 0) { + value = value / (-min); + } else { + if (max == 0.0f) { + value = 0.0f; + } else { + value = value / max; + } + } + } else { + // 0 ... min ... max + // including 0.0 = min + if (max == 0.0f) { + value = 0.0f; + } else { + value = (value - min) / max; + } + } + + switch (axis) { + case SDL_PEN_AXIS_XTILT: + case SDL_PEN_AXIS_YTILT: + //if (peninfo->info.max_tilt > 0.0f) { + // value *= peninfo->info.max_tilt; // normalize to physical max + //} + break; + + case SDL_PEN_AXIS_ROTATION: + // normalised to -1..1, so let's convert to degrees + value *= 180.0f; + value += pen->rotation_bias; + + // handle simple over/underflow + if (value >= 180.0f) { + value -= 360.0f; + } else if (value < -180.0f) { + value += 360.0f; + } + break; + + default: + break; + } + + coords[axis] = value; + } +} + +void X11_PenAxesFromValuators(const X11_PenHandle *pen, + const double *input_values, const unsigned char *mask, int mask_len, + float axis_values[SDL_PEN_AXIS_COUNT]) +{ + for (int i = 0; i < SDL_PEN_AXIS_COUNT; i++) { + const int valuator = pen->valuator_for_axis[i]; + if ((valuator == SDL_X11_PEN_AXIS_VALUATOR_MISSING) || (valuator >= mask_len * 8) || !(XIMaskIsSet(mask, valuator))) { + axis_values[i] = 0.0f; + } else { + axis_values[i] = (float)input_values[valuator]; + } + } + X11_XInput2NormalizePenAxes(pen, axis_values); +} + +#else + +void X11_InitPen(SDL_VideoDevice *_this) +{ + (void) _this; +} + +void X11_QuitPen(SDL_VideoDevice *_this) +{ + (void) _this; +} + +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 + diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.h new file mode 100644 index 0000000..de75181 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11pen.h @@ -0,0 +1,72 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "../../SDL_internal.h" + +#ifndef SDL_x11pen_h_ +#define SDL_x11pen_h_ + +// Pressure-sensitive pen support for X11. + +#include "SDL_x11video.h" +#include "../../events/SDL_pen_c.h" + +// Prep pen support (never fails; pens simply won't be added if there's a problem). +extern void X11_InitPen(SDL_VideoDevice *_this); + +// Clean up pen support. +extern void X11_QuitPen(SDL_VideoDevice *_this); + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + +// Forward definition for SDL_x11video.h +struct SDL_VideoData; + +#define SDL_X11_PEN_AXIS_VALUATOR_MISSING -1 + +typedef struct X11_PenHandle +{ + SDL_PenID pen; + bool is_eraser; + int x11_deviceid; + int valuator_for_axis[SDL_PEN_AXIS_COUNT]; + float slider_bias; // shift value to add to PEN_AXIS_SLIDER (before normalisation) + float rotation_bias; // rotation to add to PEN_AXIS_ROTATION (after normalisation) + float axis_min[SDL_PEN_AXIS_COUNT]; + float axis_max[SDL_PEN_AXIS_COUNT]; +} X11_PenHandle; + +// Converts XINPUT2 valuators into pen axis information, including normalisation. +extern void X11_PenAxesFromValuators(const X11_PenHandle *pen, + const double *input_values, const unsigned char *mask, int mask_len, + float axis_values[SDL_PEN_AXIS_COUNT]); + +// Add a pen (if this function's further checks validate it). +extern X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid); + +// Remove a pen. It's okay if deviceid is bogus or not a pen, we'll check it. +extern void X11_RemovePenByDeviceID(int deviceid); + +// Map X11 device ID to pen ID. +extern X11_PenHandle *X11_FindPenByDeviceID(int deviceid); + +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 + +#endif // SDL_x11pen_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.c new file mode 100644 index 0000000..7a7ae01 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.c @@ -0,0 +1,129 @@ +/* + Simple DirectMedia Layer + Copyright 2024 Igalia S.L. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_X11) + +#include "SDL_x11video.h" +#include "SDL_x11settings.h" + +#define SDL_XSETTINGS_GDK_WINDOW_SCALING_FACTOR "Gdk/WindowScalingFactor" +#define SDL_XSETTINGS_XFT_DPI "Xft/DPI" + +static void X11_XsettingsNotify(const char *name, XSettingsAction action, XSettingsSetting *setting, void *data) +{ + SDL_VideoDevice *_this = data; + float scale_factor = 1.0; + int i; + + if (SDL_strcmp(name, SDL_XSETTINGS_GDK_WINDOW_SCALING_FACTOR) != 0 || + SDL_strcmp(name, SDL_XSETTINGS_XFT_DPI) != 0) { + return; + } + + if (setting->type != XSETTINGS_TYPE_INT) { + return; + } + + switch (action) { + case XSETTINGS_ACTION_NEW: + SDL_FALLTHROUGH; + case XSETTINGS_ACTION_CHANGED: + scale_factor = setting->data.v_int; + if (SDL_strcmp(name, SDL_XSETTINGS_XFT_DPI) == 0) { + scale_factor = scale_factor / 1024.0f / 96.0f; + } + break; + case XSETTINGS_ACTION_DELETED: + scale_factor = 1.0; + break; + } + + if (_this) { + for (i = 0; i < _this->num_displays; ++i) { + SDL_SetDisplayContentScale(_this->displays[i], scale_factor); + } + } +} + +void X11_InitXsettings(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + SDLX11_SettingsData *xsettings_data = &data->xsettings_data; + + xsettings_data->xsettings = xsettings_client_new(data->display, + DefaultScreen(data->display), X11_XsettingsNotify, NULL, _this); + +} + +void X11_QuitXsettings(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + SDLX11_SettingsData *xsettings_data = &data->xsettings_data; + + if (xsettings_data->xsettings) { + xsettings_client_destroy(xsettings_data->xsettings); + xsettings_data->xsettings = NULL; + } +} + +void X11_HandleXsettings(SDL_VideoDevice *_this, const XEvent *xevent) +{ + SDL_VideoData *data = _this->internal; + SDLX11_SettingsData *xsettings_data = &data->xsettings_data; + + if (xsettings_data->xsettings) { + if (!xsettings_client_process_event(xsettings_data->xsettings, xevent)) { + xsettings_client_destroy(xsettings_data->xsettings); + xsettings_data->xsettings = NULL; + } + } +} + +int X11_GetXsettingsIntKey(SDL_VideoDevice *_this, const char *key, int fallback_value) { + SDL_VideoData *data = _this->internal; + SDLX11_SettingsData *xsettings_data = &data->xsettings_data; + XSettingsSetting *setting = NULL; + int res = fallback_value; + + + if (xsettings_data->xsettings) { + if (xsettings_client_get_setting(xsettings_data->xsettings, key, &setting) != XSETTINGS_SUCCESS) { + goto no_key; + } + + if (setting->type != XSETTINGS_TYPE_INT) { + goto no_key; + } + + res = setting->data.v_int; + } + +no_key: + if (setting) { + xsettings_setting_free(setting); + } + + return res; +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.h new file mode 100644 index 0000000..5b36884 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11settings.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright 2024 Igalia S.L. + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_x11settings_h_ +#define SDL_x11settings_h_ + +#include +#include "xsettings-client.h" + +typedef struct X11_SettingsData { + XSettingsClient *xsettings; +} SDLX11_SettingsData; + +extern void X11_InitXsettings(SDL_VideoDevice *_this); +extern void X11_QuitXsettings(SDL_VideoDevice *_this); +extern void X11_HandleXsettings(SDL_VideoDevice *_this, const XEvent *xevent); +extern int X11_GetXsettingsIntKey(SDL_VideoDevice *_this, const char *key, int fallback_value); + +#endif // SDL_x11settings_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.c new file mode 100644 index 0000000..e433598 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.c @@ -0,0 +1,111 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" +#include "SDL_x11shape.h" + + +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE +static Uint8 *GenerateShapeMask(SDL_Surface *shape) +{ + int x, y; + const size_t ppb = 8; + const size_t bytes_per_scanline = (shape->w + (ppb - 1)) / ppb; + const Uint8 *a; + Uint8 *mask; + Uint8 *mask_scanline; + Uint8 mask_value; + + mask = (Uint8 *)SDL_calloc(1, shape->h * bytes_per_scanline); + if (mask) { + for (y = 0; y < shape->h; y++) { + a = (const Uint8 *)shape->pixels + y * shape->pitch; + mask_scanline = mask + y * bytes_per_scanline; + for (x = 0; x < shape->w; x++) { + mask_value = (*a == SDL_ALPHA_TRANSPARENT) ? 0 : 1; + mask_scanline[x / ppb] |= mask_value << (x % ppb); + a += 4; + } + } + } + return mask; +} +#endif // SDL_VIDEO_DRIVER_X11_XSHAPE + +bool X11_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape) +{ + bool result = false; + +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE + SDL_WindowData *windowdata = window->internal; + + // Generate a set of spans for the region + if (shape) { + SDL_Surface *stretched = NULL; + Uint8 *mask; + Pixmap pixmap; + + if (shape->w != window->w || shape->h != window->h) { + stretched = SDL_CreateSurface(window->w, window->h, SDL_PIXELFORMAT_ARGB32); + if (!stretched) { + return false; + } + if (!SDL_StretchSurface(shape, NULL, stretched, NULL, SDL_SCALEMODE_LINEAR)) { + SDL_DestroySurface(stretched); + return false; + } + shape = stretched; + } + + mask = GenerateShapeMask(shape); + if (mask) { + pixmap = X11_XCreateBitmapFromData(windowdata->videodata->display, windowdata->xwindow, (const char *)mask, shape->w, shape->h); + X11_XShapeCombineMask(windowdata->videodata->display, windowdata->xwindow, ShapeInput, 0, 0, pixmap, ShapeSet); + SDL_free(mask); + + result = true; + } + + if (stretched) { + SDL_DestroySurface(stretched); + } + } else { + Region region = X11_XCreateRegion(); + XRectangle rect; + + rect.x = 0; + rect.y = 0; + rect.width = window->w; + rect.height = window->h; + X11_XUnionRectWithRegion(&rect, region, region); + X11_XShapeCombineRegion(windowdata->videodata->display, windowdata->xwindow, ShapeInput, 0, 0, region, ShapeSet); + X11_XDestroyRegion(region); + result = true; + } +#endif // SDL_VIDEO_DRIVER_X11_XSHAPE + + return result; +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.h new file mode 100644 index 0000000..d47d103 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11shape.h @@ -0,0 +1,28 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11shape_h_ +#define SDL_x11shape_h_ + +extern bool X11_UpdateWindowShape(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *shape); + +#endif // SDL_x11shape_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11sym.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11sym.h new file mode 100644 index 0000000..68d70cd --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11sym.h @@ -0,0 +1,354 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* *INDENT-OFF* */ // clang-format off + +#ifndef SDL_X11_MODULE +#define SDL_X11_MODULE(modname) +#endif + +#ifndef SDL_X11_SYM +#define SDL_X11_SYM(rc,fn,params,args,ret) +#endif + +SDL_X11_MODULE(BASEXLIB) +SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return) +SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return) +SDL_X11_SYM(XClassHint*,XAllocClassHint,(void),(),return) +SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return) +SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return) +SDL_X11_SYM(Bool,XCheckIfEvent,(Display* a,XEvent *b,Bool (*c)(Display*,XEvent*,XPointer),XPointer d),(a,b,c,d),return) +SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return) +SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return) +SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return) +SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return) +SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(Cursor,XCreateFontCursor,(Display* a,unsigned int b),(a,b),return) +SDL_X11_SYM(XFontSet,XCreateFontSet,(Display* a, _Xconst char* b, char*** c, int* d, char** e),(a,b,c,d,e),return) +SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return) +SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return) +SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return) +SDL_X11_SYM(int,XDefineCursor,(Display* a,Window b,Cursor c),(a,b,c),return) +SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return) +SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return) +SDL_X11_SYM(int,XDrawRectangle,(Display* a,Drawable b,GC c,int d,int e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return) +SDL_X11_SYM(int,XDrawString,(Display* a,Drawable b,GC c,int d,int e,_Xconst char* f,int g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return) +SDL_X11_SYM(int,XFillRectangle,(Display* a,Drawable b,GC c,int d,int e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return) +SDL_X11_SYM(int,XFlush,(Display* a),(a),return) +SDL_X11_SYM(int,XFree,(void*a),(a),return) +SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return) +SDL_X11_SYM(void,XFreeFontSet,(Display* a, XFontSet b),(a,b),) +SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return) +SDL_X11_SYM(int,XFreeFont,(Display* a, XFontStruct* b),(a,b),return) +SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return) +SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return) +SDL_X11_SYM(void,XFreeStringList,(char** a),(a),) +SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return) +SDL_X11_SYM(int,XGetInputFocus,(Display *a,Window *b,int *c),(a,b,c),return) +SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return) +SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return) +SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return) +SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return) +SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return) +SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return) +SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return) +SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(Status,XGetWMNormalHints,(Display *a,Window b, XSizeHints *c, long *d),(a,b,c,d),return) +SDL_X11_SYM(int,XIfEvent,(Display* a,XEvent *b,Bool (*c)(Display*,XEvent*,XPointer),XPointer d),(a,b,c,d),return) +SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return) +SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return) +SDL_X11_SYM(Status,XIconifyWindow,(Display* a,Window b,int c),(a,b,c),return) +SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display* a,KeySym b),(a,b),return) +SDL_X11_SYM(char*,XKeysymToString,(KeySym a),(a),return) +SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return) +SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return) +SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return) +SDL_X11_SYM(XFontStruct*,XLoadQueryFont,(Display* a,_Xconst char* b),(a,b),return) +SDL_X11_SYM(KeySym,XLookupKeysym,(XKeyEvent* a,int b),(a,b),return) +SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(Status,XMatchVisualInfo,(Display* a,int b,int c,int d,XVisualInfo* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XMissingExtension,(Display* a,_Xconst char* b),(a,b),return) +SDL_X11_SYM(int,XMoveWindow,(Display* a,Window b,int c,int d),(a,b,c,d),return) +SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char* a),(a),return) +SDL_X11_SYM(Status,XInitThreads,(void),(),return) +SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return) +SDL_X11_SYM(int,XPending,(Display* a),(a),return) +SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return) +SDL_X11_SYM(int,XQueryKeymap,(Display* a,char b[32]),(a,b),return) +SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return) +SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return) +SDL_X11_SYM(int,XScreenNumberOfScreen,(Screen* a),(a),return) +SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return) +SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return) +SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return) +SDL_X11_SYM(int,XSetForeground,(Display* a,GC b,unsigned long c),(a,b,c),return) +SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return) +SDL_X11_SYM(int,XSetInputFocus,(Display *a,Window b,int c,Time d),(a,b,c,d),return) +SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return) +SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return) +SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),) +SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return) +SDL_X11_SYM(void,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),) +SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),) +SDL_X11_SYM(void,XSetWMProperties,(Display* a,Window b,XTextProperty* c,XTextProperty* d,char** e,int f,XSizeHints* g,XWMHints* h,XClassHint* i),(a,b,c,d,e,f,g,h,i),) +SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return) +SDL_X11_SYM(int,XStoreColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return) +SDL_X11_SYM(int,XStoreName,(Display* a,Window b,_Xconst char* c),(a,b,c),return) +SDL_X11_SYM(Status,XStringListToTextProperty,(char** a,int b,XTextProperty* c),(a,b,c),return) +SDL_X11_SYM(int,XSync,(Display* a,Bool b),(a,b),return) +SDL_X11_SYM(int,XTextExtents,(XFontStruct* a,_Xconst char* b,int c,int* d,int* e,int* f,XCharStruct* g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(Bool,XTranslateCoordinates,(Display *a,Window b,Window c,int d,int e,int* f,int* g,Window* h),(a,b,c,d,e,f,g,h),return) +SDL_X11_SYM(int,XUndefineCursor,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XUngrabKeyboard,(Display* a,Time b),(a,b),return) +SDL_X11_SYM(int,XUngrabPointer,(Display* a,Time b),(a,b),return) +SDL_X11_SYM(int,XUngrabServer,(Display* a),(a),return) +SDL_X11_SYM(int,XUninstallColormap,(Display* a,Colormap b),(a,b),return) +SDL_X11_SYM(int,XUnloadFont,(Display* a,Font b),(a,b),return) +SDL_X11_SYM(int,XWarpPointer,(Display* a,Window b,Window c,int d,int e,unsigned int f,unsigned int g,int h,int i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(int,XWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return) +SDL_X11_SYM(Status,XWithdrawWindow,(Display* a,Window b,int c),(a,b,c),return) +SDL_X11_SYM(VisualID,XVisualIDFromVisual,(Visual* a),(a),return) +SDL_X11_SYM(char*,XGetDefault,(Display* a,_Xconst char* b, _Xconst char* c),(a,b,c),return) +SDL_X11_SYM(Bool,XQueryExtension,(Display* a,_Xconst char* b,int* c,int* d,int* e),(a,b,c,d,e),return) +SDL_X11_SYM(char *,XDisplayString,(Display* a),(a),return) +SDL_X11_SYM(int,XGetErrorText,(Display* a,int b,char* c,int d),(a,b,c,d),return) +SDL_X11_SYM(void,_XEatData,(Display* a,unsigned long b),(a,b),) +SDL_X11_SYM(void,_XFlush,(Display* a),(a),) +SDL_X11_SYM(void,_XFlushGCCache,(Display* a,GC b),(a,b),) +SDL_X11_SYM(int,_XRead,(Display* a,char* b,long c),(a,b,c),return) +SDL_X11_SYM(void,_XReadPad,(Display* a,char* b,long c),(a,b,c),) +SDL_X11_SYM(void,_XSend,(Display* a,_Xconst char* b,long c),(a,b,c),) +SDL_X11_SYM(Status,_XReply,(Display* a,xReply* b,int c,Bool d),(a,b,c,d),return) +SDL_X11_SYM(unsigned long,_XSetLastRequestRead,(Display* a,xGenericReply* b),(a,b),return) +SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),return) +SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return) +SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return) +SDL_X11_SYM(void,XRefreshKeyboardMapping,(XMappingEvent *a),(a),) +SDL_X11_SYM(int,XQueryTree,(Display* a,Window b,Window* c,Window* d,Window** e,unsigned int* f),(a,b,c,d,e,f),return) +SDL_X11_SYM(Bool,XSupportsLocale,(void),(),return) +SDL_X11_SYM(Status,XmbTextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return) +SDL_X11_SYM(Region,XCreateRegion,(void),(),return) +SDL_X11_SYM(int,XUnionRectWithRegion,(XRectangle *a, Region b, Region c),(a,b,c), return) +SDL_X11_SYM(void,XDestroyRegion,(Region),(a),) +SDL_X11_SYM(void,XrmInitialize,(void),(),) +SDL_X11_SYM(char*,XResourceManagerString,(Display *display),(display),) +SDL_X11_SYM(XrmDatabase,XrmGetStringDatabase,(char *data),(data),) +SDL_X11_SYM(void,XrmDestroyDatabase,(XrmDatabase db),(db),) +SDL_X11_SYM(Bool,XrmGetResource,(XrmDatabase db, char* str_name, char* str_class, char **str_type_return, XrmValue *),(db, str_name, str_class,str_type_return,value_return),) + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES +SDL_X11_MODULE(XFIXES) +SDL_X11_SYM(PointerBarrier, XFixesCreatePointerBarrier, (Display* a, Window b, int c, int d, int e, int f, int g, int h, int *i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(void, XFixesDestroyPointerBarrier, (Display* a, PointerBarrier b), (a,b),) +SDL_X11_SYM(int, XIBarrierReleasePointer,(Display* a, int b, PointerBarrier c, BarrierEventID d), (a,b,c,d), return) // this is actually Xinput2 +SDL_X11_SYM(Status, XFixesQueryVersion,(Display* a, int* b, int* c), (a,b,c), return) +SDL_X11_SYM(Status, XFixesSelectSelectionInput, (Display* a, Window b, Atom c, unsigned long d), (a,b,c,d), return) +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC +SDL_X11_MODULE(XSYNC) +SDL_X11_SYM(Status, XSyncQueryExtension, (Display* a, int* b, int* c), (a, b, c), return) +SDL_X11_SYM(Status, XSyncInitialize, (Display* a, int* b, int* c), (a, b, c), return) +SDL_X11_SYM(XSyncCounter, XSyncCreateCounter, (Display* a, XSyncValue b), (a, b), return) +SDL_X11_SYM(Status, XSyncDestroyCounter, (Display* a, XSyncCounter b), (a, b), return) +SDL_X11_SYM(Status, XSyncSetCounter, (Display* a, XSyncCounter b, XSyncValue c), (a, b, c), return) +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +SDL_X11_SYM(Bool,XGetEventData,(Display* a,XGenericEventCookie* b),(a,b),return) +SDL_X11_SYM(void,XFreeEventData,(Display* a,XGenericEventCookie* b),(a,b),) +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM +SDL_X11_SYM(Bool,XkbQueryExtension,(Display* a,int * b,int * c,int * d,int * e, int *f),(a,b,c,d,e,f),return) +#if NeedWidePrototypes +SDL_X11_SYM(Bool,XkbLookupKeySym,(Display* a, unsigned int b, unsigned int c, unsigned int* d, KeySym* e),(a,b,c,d,e),return) +#else +SDL_X11_SYM(Bool,XkbLookupKeySym,(Display* a, KeyCode b, unsigned int c, unsigned int* d, KeySym* e),(a,b,c,d,e),return) +#endif +SDL_X11_SYM(Status,XkbGetState,(Display* a,unsigned int b,XkbStatePtr c),(a,b,c),return) +SDL_X11_SYM(Status,XkbGetUpdatedMap,(Display* a,unsigned int b,XkbDescPtr c),(a,b,c),return) +SDL_X11_SYM(XkbDescPtr,XkbGetMap,(Display* a,unsigned int b,unsigned int c),(a,b,c),return) +SDL_X11_SYM(void,XkbFreeClientMap,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),) +SDL_X11_SYM(void,XkbFreeKeyboard,(XkbDescPtr a,unsigned int b, Bool c),(a,b,c),) +SDL_X11_SYM(Bool,XkbSetDetectableAutoRepeat,(Display* a, Bool b, Bool* c),(a,b,c),return) +#endif + +// XKeycodeToKeysym is a deprecated function +#ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif +#if NeedWidePrototypes +SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return) +#else +SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,KeyCode b,int c),(a,b,c),return) +#endif +#ifdef HAVE_GCC_DIAGNOSTIC_PRAGMA +#pragma GCC diagnostic pop +#endif + +#ifdef X_HAVE_UTF8_STRING +SDL_X11_MODULE(UTF8) +SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,Xutf8LookupString,(XIC a,XKeyPressedEvent* b,char* c,int d,KeySym* e,Status* f),(a,b,c,d,e,f),return) +// SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! +SDL_X11_SYM(void,XDestroyIC,(XIC a),(a),) +/* SDL_X11_SYM(char*,XGetICValues,(XIC, ...),return) !!! ARGH! */ +/* SDL_X11_SYM(char*,XSetICValues,(XIC, ...),return) !!! ARGH! */ +/* SDL_X11_SYM(XVaNestedList,XVaCreateNestedList,(int, ...),return) !!! ARGH! */ +SDL_X11_SYM(void,XSetICFocus,(XIC a),(a),) +SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),) +SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return) +SDL_X11_SYM(Status,XCloseIM,(XIM a),(a),return) +SDL_X11_SYM(void,Xutf8DrawString,(Display *a, Drawable b, XFontSet c, GC d, int e, int f, _Xconst char *g, int h),(a,b,c,d,e,f,g,h),) +SDL_X11_SYM(int,Xutf8TextExtents,(XFontSet a, _Xconst char* b, int c, XRectangle* d, XRectangle* e),(a,b,c,d,e),return) +SDL_X11_SYM(char*,XSetLocaleModifiers,(const char *a),(a),return) +SDL_X11_SYM(char*,Xutf8ResetIC,(XIC a),(a),return) +#endif + +#ifndef NO_SHARED_MEMORY +SDL_X11_MODULE(SHM) +SDL_X11_SYM(Status,XShmAttach,(Display* a,XShmSegmentInfo* b),(a,b),return) +SDL_X11_SYM(Status,XShmDetach,(Display* a,XShmSegmentInfo* b),(a,b),return) +SDL_X11_SYM(Status,XShmPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j,Bool k),(a,b,c,d,e,f,g,h,i,j,k),return) +SDL_X11_SYM(XImage*,XShmCreateImage,(Display* a,Visual* b,unsigned int c,int d,char* e,XShmSegmentInfo* f,unsigned int g,unsigned int h),(a,b,c,d,e,f,g,h),return) +SDL_X11_SYM(Pixmap,XShmCreatePixmap,(Display *a,Drawable b,char* c,XShmSegmentInfo* d, unsigned int e, unsigned int f, unsigned int g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(Bool,XShmQueryExtension,(Display* a),(a),return) +#endif + +/* + * Not required...these only exist in code in headers on some 64-bit platforms, + * and are removed via macros elsewhere, so it's safe for them to be missing. + */ +#ifdef LONG64 +SDL_X11_MODULE(IO_32BIT) +SDL_X11_SYM(int,_XData32,(Display *dpy,register _Xconst long *data,unsigned len),(dpy,data,len),return) +SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),) +#endif + +/* + * These only show up on some variants of Unix. + */ +#ifdef SDL_PLATFORM_OSF +SDL_X11_MODULE(OSF_ENTRY_POINTS) +SDL_X11_SYM(void,_SmtBufferOverflow,(Display *dpy,register smtDisplayPtr p),(dpy,p),) +SDL_X11_SYM(void,_SmtIpError,(Display *dpy,register smtDisplayPtr p,int i),(dpy,p,i),) +SDL_X11_SYM(int,ipAllocateData,(ChannelPtr a,IPCard b,IPDataPtr * c),(a,b,c),return) +SDL_X11_SYM(int,ipUnallocateAndSendData,(ChannelPtr a,IPCard b),(a,b),return) +#endif + +// XCursor support +#ifdef SDL_VIDEO_DRIVER_X11_XCURSOR +SDL_X11_MODULE(XCURSOR) +SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),return) +SDL_X11_SYM(void,XcursorImageDestroy,(XcursorImage *a),(a),) +SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),return) +SDL_X11_SYM(Cursor,XcursorLibraryLoadCursor,(Display *a, const char *b),(a,b),return) +#endif + +// Xdbe support +#ifdef SDL_VIDEO_DRIVER_X11_XDBE +SDL_X11_MODULE(XDBE) +SDL_X11_SYM(Status,XdbeQueryExtension,(Display *dpy,int *major_version_return,int *minor_version_return),(dpy,major_version_return,minor_version_return),return) +SDL_X11_SYM(XdbeBackBuffer,XdbeAllocateBackBufferName,(Display *dpy,Window window,XdbeSwapAction swap_action),(dpy,window,swap_action),return) +SDL_X11_SYM(Status,XdbeDeallocateBackBufferName,(Display *dpy,XdbeBackBuffer buffer),(dpy,buffer),return) +SDL_X11_SYM(Status,XdbeSwapBuffers,(Display *dpy,XdbeSwapInfo *swap_info,int num_windows),(dpy,swap_info,num_windows),return) +SDL_X11_SYM(Status,XdbeBeginIdiom,(Display *dpy),(dpy),return) +SDL_X11_SYM(Status,XdbeEndIdiom,(Display *dpy),(dpy),return) +SDL_X11_SYM(XdbeScreenVisualInfo*,XdbeGetVisualInfo,(Display *dpy,Drawable *screen_specifiers,int *num_screens),(dpy,screen_specifiers,num_screens),return) +SDL_X11_SYM(void,XdbeFreeVisualInfo,(XdbeScreenVisualInfo *visual_info),(visual_info),) +SDL_X11_SYM(XdbeBackBufferAttributes*,XdbeGetBackBufferAttributes,(Display *dpy,XdbeBackBuffer buffer),(dpy,buffer),return) +#endif + +// XInput2 support for multiple mice, tablets, etc. +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 +SDL_X11_MODULE(XINPUT2) +SDL_X11_SYM(XIDeviceInfo*,XIQueryDevice,(Display *a,int b,int *c),(a,b,c),return) +SDL_X11_SYM(void,XIFreeDeviceInfo,(XIDeviceInfo *a),(a),) +SDL_X11_SYM(int,XISelectEvents,(Display *a,Window b,XIEventMask *c,int d),(a,b,c,d),return) +SDL_X11_SYM(int,XIGrabTouchBegin,(Display *a,int b,Window c,int d,XIEventMask *e,int f,XIGrabModifiers *g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(int,XIUngrabTouchBegin, (Display *a,int b,Window c, int d,XIGrabModifiers *e),(a, b, c, d, e),return) +SDL_X11_SYM(Status,XIQueryVersion,(Display *a,int *b,int *c),(a,b,c),return) +SDL_X11_SYM(XIEventMask*,XIGetSelectedEvents,(Display *a,Window b,int *c),(a,b,c),return) +SDL_X11_SYM(Bool,XIGetClientPointer,(Display *a,Window b,int *c),(a,b,c),return) +SDL_X11_SYM(Bool,XIWarpPointer,(Display *a,int b,Window c,Window d,double e,double f,int g,int h,double i,double j),(a,b,c,d,e,f,g,h,i,j),return) +SDL_X11_SYM(Status,XIGetProperty,(Display *a,int b,Atom c,long d,long e,Bool f, Atom g, Atom *h, int *i, unsigned long *j, unsigned long *k, unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return) +#endif + +// XRandR support +#ifdef SDL_VIDEO_DRIVER_X11_XRANDR +SDL_X11_MODULE(XRANDR) +SDL_X11_SYM(Status,XRRQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) +SDL_X11_SYM(Bool,XRRQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return) +SDL_X11_SYM(XRRScreenConfiguration *,XRRGetScreenInfo,(Display *dpy,Drawable draw),(dpy,draw),return) +SDL_X11_SYM(SizeID,XRRConfigCurrentConfiguration,(XRRScreenConfiguration *config,Rotation *rotation),(config,rotation),return) +SDL_X11_SYM(short,XRRConfigCurrentRate,(XRRScreenConfiguration *config),(config),return) +SDL_X11_SYM(short *,XRRConfigRates,(XRRScreenConfiguration *config,int sizeID,int *nrates),(config,sizeID,nrates),return) +SDL_X11_SYM(XRRScreenSize *,XRRConfigSizes,(XRRScreenConfiguration *config,int *nsizes),(config,nsizes),return) +SDL_X11_SYM(Status,XRRSetScreenConfigAndRate,(Display *dpy,XRRScreenConfiguration *config,Drawable draw,int size_index,Rotation rotation,short rate,Time timestamp),(dpy,config,draw,size_index,rotation,rate,timestamp),return) +SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),) +SDL_X11_SYM(void,XRRSetScreenSize,(Display *dpy, Window window,int width, int height,int mmWidth, int mmHeight),(dpy,window,width,height,mmWidth,mmHeight),) +SDL_X11_SYM(Status,XRRGetScreenSizeRange,(Display *dpy, Window window,int *minWidth, int *minHeight, int *maxWidth, int *maxHeight),(dpy,window,minWidth,minHeight,maxWidth,maxHeight),return) +SDL_X11_SYM(XRRScreenResources *,XRRGetScreenResources,(Display *dpy, Window window),(dpy, window),return) +SDL_X11_SYM(XRRScreenResources *,XRRGetScreenResourcesCurrent,(Display *dpy, Window window),(dpy, window),return) +SDL_X11_SYM(void,XRRFreeScreenResources,(XRRScreenResources *resources),(resources),) +SDL_X11_SYM(XRROutputInfo *,XRRGetOutputInfo,(Display *dpy, XRRScreenResources *resources, RROutput output),(dpy,resources,output),return) +SDL_X11_SYM(void,XRRFreeOutputInfo,(XRROutputInfo *outputInfo),(outputInfo),) +SDL_X11_SYM(XRRCrtcInfo *,XRRGetCrtcInfo,(Display *dpy, XRRScreenResources *resources, RRCrtc crtc),(dpy,resources,crtc),return) +SDL_X11_SYM(void,XRRFreeCrtcInfo,(XRRCrtcInfo *crtcInfo),(crtcInfo),) +SDL_X11_SYM(Status,XRRSetCrtcConfig,(Display *dpy, XRRScreenResources *resources, RRCrtc crtc, Time timestamp, int x, int y, RRMode mode, Rotation rotation, RROutput *outputs, int noutputs),(dpy,resources,crtc,timestamp,x,y,mode,rotation,outputs,noutputs),return) +SDL_X11_SYM(Atom*,XRRListOutputProperties,(Display *dpy, RROutput output, int *nprop),(dpy,output,nprop),return) +SDL_X11_SYM(XRRPropertyInfo*,XRRQueryOutputProperty,(Display *dpy,RROutput output, Atom property),(dpy,output,property),return) +SDL_X11_SYM(int,XRRGetOutputProperty,(Display *dpy,RROutput output, Atom property, long offset, long length, Bool _delete, Bool pending, Atom req_type, Atom *actual_type, int *actual_format, unsigned long *nitems, unsigned long *bytes_after, unsigned char **prop),(dpy,output,property,offset,length, _delete, pending, req_type, actual_type, actual_format, nitems, bytes_after, prop),return) +SDL_X11_SYM(RROutput,XRRGetOutputPrimary,(Display *dpy,Window window),(dpy,window),return) +SDL_X11_SYM(void,XRRSelectInput,(Display *dpy, Window window, int mask),(dpy,window,mask),) +SDL_X11_SYM(Status,XRRGetCrtcTransform,(Display *dpy,RRCrtc crtc,XRRCrtcTransformAttributes **attributes),(dpy,crtc,attributes),return) +#endif + +// MIT-SCREEN-SAVER support +#ifdef SDL_VIDEO_DRIVER_X11_XSCRNSAVER +SDL_X11_MODULE(XSS) +SDL_X11_SYM(Bool,XScreenSaverQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return) +SDL_X11_SYM(Status,XScreenSaverQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) +SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),return) +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE +SDL_X11_MODULE(XSHAPE) +SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x_off,int y_off,Pixmap src,int op),(dpy,dest,dest_kind,x_off,y_off,src,op),) +SDL_X11_SYM(void,XShapeCombineRegion,(Display *a,Window b,int c,int d,int e,Region f,int g),(a,b,c,d,e,f,g),) +#endif + +#undef SDL_X11_MODULE +#undef SDL_X11_SYM + +/* *INDENT-ON* */ // clang-format on diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.c new file mode 100644 index 0000000..5b42c97 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.c @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" +#include "SDL_x11touch.h" +#include "SDL_x11xinput2.h" +#include "../../events/SDL_touch_c.h" + +void X11_InitTouch(SDL_VideoDevice *_this) +{ + X11_InitXinput2Multitouch(_this); +} + +void X11_QuitTouch(SDL_VideoDevice *_this) +{ + SDL_QuitTouch(); +} + +void X11_ResetTouch(SDL_VideoDevice *_this) +{ + X11_QuitTouch(_this); + X11_InitTouch(_this); +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.h new file mode 100644 index 0000000..548bf07 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11touch.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11touch_h_ +#define SDL_x11touch_h_ + +extern void X11_InitTouch(SDL_VideoDevice *_this); +extern void X11_QuitTouch(SDL_VideoDevice *_this); +extern void X11_ResetTouch(SDL_VideoDevice *_this); + +#endif // SDL_x11touch_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11video.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11video.c new file mode 100644 index 0000000..75862db --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11video.c @@ -0,0 +1,505 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include // For getpid() and readlink() + +#include "../../core/linux/SDL_system_theme.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../SDL_pixels_c.h" +#include "../SDL_sysvideo.h" + +#include "SDL_x11framebuffer.h" +#include "SDL_x11pen.h" +#include "SDL_x11touch.h" +#include "SDL_x11video.h" +#include "SDL_x11xfixes.h" +#include "SDL_x11xinput2.h" +#include "SDL_x11messagebox.h" +#include "SDL_x11shape.h" +#include "SDL_x11xsync.h" + +#ifdef SDL_VIDEO_OPENGL_EGL +#include "SDL_x11opengles.h" +#endif + +// Initialization/Query functions +static bool X11_VideoInit(SDL_VideoDevice *_this); +static void X11_VideoQuit(SDL_VideoDevice *_this); + +// X11 driver bootstrap functions + +static void X11_DeleteDevice(SDL_VideoDevice *device) +{ + SDL_VideoData *data = device->internal; + if (device->vulkan_config.loader_handle) { + device->Vulkan_UnloadLibrary(device); + } + if (data->display) { + X11_XCloseDisplay(data->display); + } + if (data->request_display) { + X11_XCloseDisplay(data->request_display); + } + SDL_free(data->windowlist); + if (device->wakeup_lock) { + SDL_DestroyMutex(device->wakeup_lock); + } + SDL_free(device->internal); + SDL_free(device); + + SDL_X11_UnloadSymbols(); +} + +static bool X11_IsXWayland(Display *d) +{ + int opcode, event, error; + return X11_XQueryExtension(d, "XWAYLAND", &opcode, &event, &error) == True; +} + +static bool X11_CheckCurrentDesktop(const char *name) +{ + SDL_Environment *env = SDL_GetEnvironment(); + + const char *desktopVar = SDL_GetEnvironmentVariable(env, "DESKTOP_SESSION"); + if (desktopVar && SDL_strcasecmp(desktopVar, name) == 0) { + return true; + } + + desktopVar = SDL_GetEnvironmentVariable(env, "XDG_CURRENT_DESKTOP"); + if (desktopVar && SDL_strcasestr(desktopVar, name)) { + return true; + } + + return false; +} + +static SDL_VideoDevice *X11_CreateDevice(void) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + const char *display = NULL; // Use the DISPLAY environment variable + Display *x11_display = NULL; + + if (!SDL_X11_LoadSymbols()) { + return NULL; + } + + /* Need for threading gl calls. This is also required for the proprietary + nVidia driver to be threaded. */ + X11_XInitThreads(); + + // Open the display first to be sure that X11 is available + x11_display = X11_XOpenDisplay(display); + + if (!x11_display) { + SDL_X11_UnloadSymbols(); + return NULL; + } + + // Initialize all variables that we clean on shutdown + device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + return NULL; + } + data = (struct SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); + if (!data) { + SDL_free(device); + return NULL; + } + device->internal = data; + + data->global_mouse_changed = true; + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + data->active_cursor_confined_window = NULL; +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + + data->display = x11_display; + data->request_display = X11_XOpenDisplay(display); + if (!data->request_display) { + X11_XCloseDisplay(data->display); + SDL_free(device->internal); + SDL_free(device); + SDL_X11_UnloadSymbols(); + return NULL; + } + + device->wakeup_lock = SDL_CreateMutex(); + +#ifdef X11_DEBUG + X11_XSynchronize(data->display, True); +#endif + + /* Steam Deck will have an on-screen keyboard, so check their environment + * variable so we can make use of SDL_StartTextInput. + */ + data->is_steam_deck = SDL_GetHintBoolean("SteamDeck", false); + + // Set the function pointers + device->VideoInit = X11_VideoInit; + device->VideoQuit = X11_VideoQuit; + device->ResetTouch = X11_ResetTouch; + device->GetDisplayModes = X11_GetDisplayModes; + device->GetDisplayBounds = X11_GetDisplayBounds; + device->GetDisplayUsableBounds = X11_GetDisplayUsableBounds; + device->GetWindowICCProfile = X11_GetWindowICCProfile; + device->SetDisplayMode = X11_SetDisplayMode; + device->SuspendScreenSaver = X11_SuspendScreenSaver; + device->PumpEvents = X11_PumpEvents; + device->WaitEventTimeout = X11_WaitEventTimeout; + device->SendWakeupEvent = X11_SendWakeupEvent; + + device->CreateSDLWindow = X11_CreateWindow; + device->SetWindowTitle = X11_SetWindowTitle; + device->SetWindowIcon = X11_SetWindowIcon; + device->SetWindowPosition = X11_SetWindowPosition; + device->SetWindowSize = X11_SetWindowSize; + device->SetWindowMinimumSize = X11_SetWindowMinimumSize; + device->SetWindowMaximumSize = X11_SetWindowMaximumSize; + device->SetWindowAspectRatio = X11_SetWindowAspectRatio; + device->GetWindowBordersSize = X11_GetWindowBordersSize; + device->SetWindowOpacity = X11_SetWindowOpacity; + device->SetWindowParent = X11_SetWindowParent; + device->SetWindowModal = X11_SetWindowModal; + device->ShowWindow = X11_ShowWindow; + device->HideWindow = X11_HideWindow; + device->RaiseWindow = X11_RaiseWindow; + device->MaximizeWindow = X11_MaximizeWindow; + device->MinimizeWindow = X11_MinimizeWindow; + device->RestoreWindow = X11_RestoreWindow; + device->SetWindowBordered = X11_SetWindowBordered; + device->SetWindowResizable = X11_SetWindowResizable; + device->SetWindowAlwaysOnTop = X11_SetWindowAlwaysOnTop; + device->SetWindowFullscreen = X11_SetWindowFullscreen; + device->SetWindowMouseGrab = X11_SetWindowMouseGrab; + device->SetWindowKeyboardGrab = X11_SetWindowKeyboardGrab; + device->DestroyWindow = X11_DestroyWindow; + device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer; + device->SetWindowHitTest = X11_SetWindowHitTest; + device->AcceptDragAndDrop = X11_AcceptDragAndDrop; + device->UpdateWindowShape = X11_UpdateWindowShape; + device->FlashWindow = X11_FlashWindow; + device->ShowWindowSystemMenu = X11_ShowWindowSystemMenu; + device->SetWindowFocusable = X11_SetWindowFocusable; + device->SyncWindow = X11_SyncWindow; + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + device->SetWindowMouseRect = X11_SetWindowMouseRect; +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + +#ifdef SDL_VIDEO_OPENGL_GLX + device->GL_LoadLibrary = X11_GL_LoadLibrary; + device->GL_GetProcAddress = X11_GL_GetProcAddress; + device->GL_UnloadLibrary = X11_GL_UnloadLibrary; + device->GL_CreateContext = X11_GL_CreateContext; + device->GL_MakeCurrent = X11_GL_MakeCurrent; + device->GL_SetSwapInterval = X11_GL_SetSwapInterval; + device->GL_GetSwapInterval = X11_GL_GetSwapInterval; + device->GL_SwapWindow = X11_GL_SwapWindow; + device->GL_DestroyContext = X11_GL_DestroyContext; + device->GL_GetEGLSurface = NULL; +#endif +#ifdef SDL_VIDEO_OPENGL_EGL +#ifdef SDL_VIDEO_OPENGL_GLX + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) { +#endif + device->GL_LoadLibrary = X11_GLES_LoadLibrary; + device->GL_GetProcAddress = X11_GLES_GetProcAddress; + device->GL_UnloadLibrary = X11_GLES_UnloadLibrary; + device->GL_CreateContext = X11_GLES_CreateContext; + device->GL_MakeCurrent = X11_GLES_MakeCurrent; + device->GL_SetSwapInterval = X11_GLES_SetSwapInterval; + device->GL_GetSwapInterval = X11_GLES_GetSwapInterval; + device->GL_SwapWindow = X11_GLES_SwapWindow; + device->GL_DestroyContext = X11_GLES_DestroyContext; + device->GL_GetEGLSurface = X11_GLES_GetEGLSurface; +#ifdef SDL_VIDEO_OPENGL_GLX + } +#endif +#endif + + device->GetTextMimeTypes = X11_GetTextMimeTypes; + device->SetClipboardData = X11_SetClipboardData; + device->GetClipboardData = X11_GetClipboardData; + device->HasClipboardData = X11_HasClipboardData; + device->SetPrimarySelectionText = X11_SetPrimarySelectionText; + device->GetPrimarySelectionText = X11_GetPrimarySelectionText; + device->HasPrimarySelectionText = X11_HasPrimarySelectionText; + device->StartTextInput = X11_StartTextInput; + device->StopTextInput = X11_StopTextInput; + device->UpdateTextInputArea = X11_UpdateTextInputArea; + device->HasScreenKeyboardSupport = X11_HasScreenKeyboardSupport; + device->ShowScreenKeyboard = X11_ShowScreenKeyboard; + device->HideScreenKeyboard = X11_HideScreenKeyboard; + device->IsScreenKeyboardShown = X11_IsScreenKeyboardShown; + + device->free = X11_DeleteDevice; + +#ifdef SDL_VIDEO_VULKAN + device->Vulkan_LoadLibrary = X11_Vulkan_LoadLibrary; + device->Vulkan_UnloadLibrary = X11_Vulkan_UnloadLibrary; + device->Vulkan_GetInstanceExtensions = X11_Vulkan_GetInstanceExtensions; + device->Vulkan_CreateSurface = X11_Vulkan_CreateSurface; + device->Vulkan_DestroySurface = X11_Vulkan_DestroySurface; + device->Vulkan_GetPresentationSupport = X11_Vulkan_GetPresentationSupport; +#endif + +#ifdef SDL_USE_LIBDBUS + if (SDL_SystemTheme_Init()) + device->system_theme = SDL_SystemTheme_Get(); +#endif + + device->device_caps = VIDEO_DEVICE_CAPS_HAS_POPUP_WINDOW_SUPPORT; + + /* Openbox doesn't send the new window dimensions when entering fullscreen, so the events must be synthesized. + * This is otherwise not wanted, as it can break fullscreen window positioning on multi-monitor configurations. + */ + if (!X11_CheckCurrentDesktop("openbox")) { + device->device_caps |= VIDEO_DEVICE_CAPS_SENDS_DISPLAY_CHANGES; + } + + data->is_xwayland = X11_IsXWayland(x11_display); + if (data->is_xwayland) { + device->device_caps |= VIDEO_DEVICE_CAPS_MODE_SWITCHING_EMULATED | + VIDEO_DEVICE_CAPS_DISABLE_MOUSE_WARP_ON_FULLSCREEN_TRANSITIONS; + } + + return device; +} + +VideoBootStrap X11_bootstrap = { + "x11", "SDL X11 video driver", + X11_CreateDevice, + X11_ShowMessageBox, + false +}; + +static int (*handler)(Display *, XErrorEvent *) = NULL; +static int X11_CheckWindowManagerErrorHandler(Display *d, XErrorEvent *e) +{ + if (e->error_code == BadWindow) { + return 0; + } else { + return handler(d, e); + } +} + +static void X11_CheckWindowManager(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + Display *display = data->display; + Atom _NET_SUPPORTING_WM_CHECK; + int status, real_format; + Atom real_type; + unsigned long items_read = 0, items_left = 0; + unsigned char *propdata = NULL; + Window wm_window = 0; +#ifdef DEBUG_WINDOW_MANAGER + char *wm_name; +#endif + + // Set up a handler to gracefully catch errors + X11_XSync(display, False); + handler = X11_XSetErrorHandler(X11_CheckWindowManagerErrorHandler); + + _NET_SUPPORTING_WM_CHECK = X11_XInternAtom(display, "_NET_SUPPORTING_WM_CHECK", False); + status = X11_XGetWindowProperty(display, DefaultRootWindow(display), _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); + if (status == Success) { + if (items_read) { + wm_window = ((Window *)propdata)[0]; + } + if (propdata) { + X11_XFree(propdata); + propdata = NULL; + } + } + + if (wm_window) { + status = X11_XGetWindowProperty(display, wm_window, _NET_SUPPORTING_WM_CHECK, 0L, 1L, False, XA_WINDOW, &real_type, &real_format, &items_read, &items_left, &propdata); + if (status != Success || !items_read || wm_window != ((Window *)propdata)[0]) { + wm_window = None; + } + if (status == Success && propdata) { + X11_XFree(propdata); + propdata = NULL; + } + } + + // Reset the error handler, we're done checking + X11_XSync(display, False); + X11_XSetErrorHandler(handler); + + if (!wm_window) { +#ifdef DEBUG_WINDOW_MANAGER + printf("Couldn't get _NET_SUPPORTING_WM_CHECK property\n"); +#endif + return; + } + data->net_wm = true; + +#ifdef DEBUG_WINDOW_MANAGER + wm_name = X11_GetWindowTitle(_this, wm_window); + printf("Window manager: %s\n", wm_name); + SDL_free(wm_name); +#endif +} + +static bool X11_VideoInit(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + // Get the process PID to be associated to the window + data->pid = getpid(); + + // I have no idea how random this actually is, or has to be. + data->window_group = (XID)(((size_t)data->pid) ^ ((size_t)_this)); + + // Look up some useful Atoms +#define GET_ATOM(X) data->atoms.X = X11_XInternAtom(data->display, #X, False) + GET_ATOM(WM_PROTOCOLS); + GET_ATOM(WM_DELETE_WINDOW); + GET_ATOM(WM_TAKE_FOCUS); + GET_ATOM(WM_NAME); + GET_ATOM(WM_TRANSIENT_FOR); + GET_ATOM(_NET_WM_STATE); + GET_ATOM(_NET_WM_STATE_HIDDEN); + GET_ATOM(_NET_WM_STATE_FOCUSED); + GET_ATOM(_NET_WM_STATE_MAXIMIZED_VERT); + GET_ATOM(_NET_WM_STATE_MAXIMIZED_HORZ); + GET_ATOM(_NET_WM_STATE_FULLSCREEN); + GET_ATOM(_NET_WM_STATE_ABOVE); + GET_ATOM(_NET_WM_STATE_SKIP_TASKBAR); + GET_ATOM(_NET_WM_STATE_SKIP_PAGER); + GET_ATOM(_NET_WM_MOVERESIZE); + GET_ATOM(_NET_WM_STATE_MODAL); + GET_ATOM(_NET_WM_ALLOWED_ACTIONS); + GET_ATOM(_NET_WM_ACTION_FULLSCREEN); + GET_ATOM(_NET_WM_NAME); + GET_ATOM(_NET_WM_ICON_NAME); + GET_ATOM(_NET_WM_ICON); + GET_ATOM(_NET_WM_PING); + GET_ATOM(_NET_WM_SYNC_REQUEST); + GET_ATOM(_NET_WM_SYNC_REQUEST_COUNTER); + GET_ATOM(_NET_WM_WINDOW_OPACITY); + GET_ATOM(_NET_WM_USER_TIME); + GET_ATOM(_NET_ACTIVE_WINDOW); + GET_ATOM(_NET_FRAME_EXTENTS); + GET_ATOM(_SDL_WAKEUP); + GET_ATOM(UTF8_STRING); + GET_ATOM(PRIMARY); + GET_ATOM(CLIPBOARD); + GET_ATOM(INCR); + GET_ATOM(SDL_SELECTION); + GET_ATOM(TARGETS); + GET_ATOM(SDL_FORMATS); + GET_ATOM(XdndAware); + GET_ATOM(XdndEnter); + GET_ATOM(XdndLeave); + GET_ATOM(XdndPosition); + GET_ATOM(XdndStatus); + GET_ATOM(XdndTypeList); + GET_ATOM(XdndActionCopy); + GET_ATOM(XdndDrop); + GET_ATOM(XdndFinished); + GET_ATOM(XdndSelection); + GET_ATOM(XKLAVIER_STATE); + + // Detect the window manager + X11_CheckWindowManager(_this); + + if (!X11_InitModes(_this)) { + return false; + } + + if (!X11_InitXinput2(_this)) { + // Assume a mouse and keyboard are attached + SDL_AddKeyboard(SDL_DEFAULT_KEYBOARD_ID, NULL, false); + SDL_AddMouse(SDL_DEFAULT_MOUSE_ID, NULL, false); + } + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + X11_InitXfixes(_this); +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + + X11_InitXsettings(_this); + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + X11_InitXsync(_this); +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + +#ifndef X_HAVE_UTF8_STRING +#warning X server does not support UTF8_STRING, a feature introduced in 2000! This is likely to become a hard error in a future libSDL3. +#endif + + if (!X11_InitKeyboard(_this)) { + return false; + } + X11_InitMouse(_this); + + X11_InitTouch(_this); + + X11_InitPen(_this); + + return true; +} + +void X11_VideoQuit(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + if (data->clipboard_window) { + X11_XDestroyWindow(data->display, data->clipboard_window); + } + + if (data->xsettings_window) { + X11_XDestroyWindow(data->display, data->xsettings_window); + } + +#ifdef X_HAVE_UTF8_STRING + if (data->im) { + X11_XCloseIM(data->im); + } +#endif + + X11_QuitModes(_this); + X11_QuitKeyboard(_this); + X11_QuitMouse(_this); + X11_QuitTouch(_this); + X11_QuitPen(_this); + X11_QuitClipboard(_this); + X11_QuitXsettings(_this); +} + +bool X11_UseDirectColorVisuals(void) +{ + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NODIRECTCOLOR, false)) { + return false; + } + return true; +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11video.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11video.h new file mode 100644 index 0000000..a336a80 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11video.h @@ -0,0 +1,177 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11video_h_ +#define SDL_x11video_h_ + +#include "../SDL_sysvideo.h" + +#include "../../core/linux/SDL_dbus.h" +#include "../../core/linux/SDL_ime.h" + +#include "SDL_x11dyn.h" + +#include "SDL_x11clipboard.h" +#include "SDL_x11events.h" +#include "SDL_x11keyboard.h" +#include "SDL_x11modes.h" +#include "SDL_x11mouse.h" +#include "SDL_x11opengl.h" +#include "SDL_x11settings.h" +#include "SDL_x11window.h" +#include "SDL_x11vulkan.h" + +// Private display data + +struct SDL_VideoData +{ + Display *display; + Display *request_display; + pid_t pid; + XIM im; + Uint64 screensaver_activity; + int numwindows; + SDL_WindowData **windowlist; + int windowlistlength; + XID window_group; + Window clipboard_window; + SDLX11_ClipboardData clipboard; + SDLX11_ClipboardData primary_selection; +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + SDL_Window *active_cursor_confined_window; +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + Window xsettings_window; + SDLX11_SettingsData xsettings_data; + + // This is true for ICCCM2.0-compliant window managers + bool net_wm; + + // Useful atoms + struct { + Atom WM_PROTOCOLS; + Atom WM_DELETE_WINDOW; + Atom WM_TAKE_FOCUS; + Atom WM_NAME; + Atom WM_TRANSIENT_FOR; + Atom _NET_WM_STATE; + Atom _NET_WM_STATE_HIDDEN; + Atom _NET_WM_STATE_FOCUSED; + Atom _NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_FULLSCREEN; + Atom _NET_WM_STATE_ABOVE; + Atom _NET_WM_STATE_SKIP_TASKBAR; + Atom _NET_WM_STATE_SKIP_PAGER; + Atom _NET_WM_STATE_MODAL; + Atom _NET_WM_MOVERESIZE; + Atom _NET_WM_ALLOWED_ACTIONS; + Atom _NET_WM_ACTION_FULLSCREEN; + Atom _NET_WM_NAME; + Atom _NET_WM_ICON_NAME; + Atom _NET_WM_ICON; + Atom _NET_WM_PING; + Atom _NET_WM_SYNC_REQUEST; + Atom _NET_WM_SYNC_REQUEST_COUNTER; + Atom _NET_WM_WINDOW_OPACITY; + Atom _NET_WM_USER_TIME; + Atom _NET_ACTIVE_WINDOW; + Atom _NET_FRAME_EXTENTS; + Atom _SDL_WAKEUP; + Atom UTF8_STRING; + Atom PRIMARY; + Atom CLIPBOARD; + Atom INCR; + Atom SDL_SELECTION; + Atom TARGETS; + Atom SDL_FORMATS; + Atom XdndAware; + Atom XdndEnter; + Atom XdndLeave; + Atom XdndPosition; + Atom XdndStatus; + Atom XdndTypeList; + Atom XdndActionCopy; + Atom XdndDrop; + Atom XdndFinished; + Atom XdndSelection; + Atom XKLAVIER_STATE; + + // Pen atoms (these have names that don't map well to C symbols) + Atom pen_atom_device_product_id; + Atom pen_atom_abs_pressure; + Atom pen_atom_abs_tilt_x; + Atom pen_atom_abs_tilt_y; + Atom pen_atom_wacom_serial_ids; + Atom pen_atom_wacom_tool_type; + } atoms; + + SDL_Scancode key_layout[256]; + bool selection_waiting; + bool selection_incr_waiting; + + bool broken_pointer_grab; // true if XGrabPointer seems unreliable. + + Uint64 last_mode_change_deadline; + + bool global_mouse_changed; + SDL_Point global_mouse_position; + Uint32 global_mouse_buttons; + + SDL_XInput2DeviceInfo *mouse_device_info; + int xinput_master_pointer_device; + bool xinput_hierarchy_changed; + + int xrandr_event_base; + struct + { +#ifdef SDL_VIDEO_DRIVER_X11_HAS_XKBLOOKUPKEYSYM + XkbDescPtr desc_ptr; +#endif + int event; + unsigned int current_group; + unsigned int xkb_modifiers; + + SDL_Keymod sdl_modifiers; + + Uint32 numlock_mask; + Uint32 scrolllock_mask; + } xkb; + + KeyCode filter_code; + Time filter_time; + +#ifdef SDL_VIDEO_VULKAN + // Vulkan variables only valid if _this->vulkan_config.loader_handle is not NULL + SDL_SharedObject *vulkan_xlib_xcb_library; + PFN_XGetXCBConnection vulkan_XGetXCBConnection; +#endif + + // Used to interact with the on-screen keyboard + bool is_steam_deck; + bool steam_keyboard_open; + + bool is_xwayland; +}; + +extern bool X11_UseDirectColorVisuals(void); + +#endif // SDL_x11video_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.c new file mode 100644 index 0000000..065549b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.c @@ -0,0 +1,290 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_X11) + +#include "../SDL_vulkan_internal.h" + +#include "SDL_x11video.h" + +#include "SDL_x11vulkan.h" + +#include +// #include + +#ifdef SDL_PLATFORM_OPENBSD +#define DEFAULT_VULKAN "libvulkan.so" +#define DEFAULT_X11_XCB "libX11-xcb.so" +#else +#define DEFAULT_VULKAN "libvulkan.so.1" +#define DEFAULT_X11_XCB "libX11-xcb.so.1" +#endif + +/* +typedef uint32_t xcb_window_t; +typedef uint32_t xcb_visualid_t; +*/ + +bool X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) +{ + SDL_VideoData *videoData = _this->internal; + VkExtensionProperties *extensions = NULL; + Uint32 extensionCount = 0; + bool hasSurfaceExtension = false; + bool hasXlibSurfaceExtension = false; + bool hasXCBSurfaceExtension = false; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr = NULL; + Uint32 i; + if (_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan already loaded"); + } + + // Load the Vulkan loader library + if (!path) { + path = SDL_GetHint(SDL_HINT_VULKAN_LIBRARY); + } + if (!path) { + path = DEFAULT_VULKAN; + } + _this->vulkan_config.loader_handle = SDL_LoadObject(path); + if (!_this->vulkan_config.loader_handle) { + return false; + } + SDL_strlcpy(_this->vulkan_config.loader_path, path, SDL_arraysize(_this->vulkan_config.loader_path)); + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)SDL_LoadFunction( + _this->vulkan_config.loader_handle, "vkGetInstanceProcAddr"); + if (!vkGetInstanceProcAddr) { + goto fail; + } + _this->vulkan_config.vkGetInstanceProcAddr = (void *)vkGetInstanceProcAddr; + _this->vulkan_config.vkEnumerateInstanceExtensionProperties = + (void *)((PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr)( + VK_NULL_HANDLE, "vkEnumerateInstanceExtensionProperties"); + if (!_this->vulkan_config.vkEnumerateInstanceExtensionProperties) { + goto fail; + } + extensions = SDL_Vulkan_CreateInstanceExtensionsList( + (PFN_vkEnumerateInstanceExtensionProperties) + _this->vulkan_config.vkEnumerateInstanceExtensionProperties, + &extensionCount); + if (!extensions) { + goto fail; + } + for (i = 0; i < extensionCount; i++) { + if (SDL_strcmp(VK_KHR_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasSurfaceExtension = true; + } else if (SDL_strcmp(VK_KHR_XCB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasXCBSurfaceExtension = true; + } else if (SDL_strcmp(VK_KHR_XLIB_SURFACE_EXTENSION_NAME, extensions[i].extensionName) == 0) { + hasXlibSurfaceExtension = true; + } + } + SDL_free(extensions); + if (!hasSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement the " VK_KHR_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } + if (hasXlibSurfaceExtension) { + videoData->vulkan_xlib_xcb_library = NULL; + } else if (!hasXCBSurfaceExtension) { + SDL_SetError("Installed Vulkan doesn't implement either the " VK_KHR_XCB_SURFACE_EXTENSION_NAME "extension or the " VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension"); + goto fail; + } else { + const char *libX11XCBLibraryName = SDL_GetHint(SDL_HINT_X11_XCB_LIBRARY); + if (!libX11XCBLibraryName || !*libX11XCBLibraryName) { + libX11XCBLibraryName = DEFAULT_X11_XCB; + } + videoData->vulkan_xlib_xcb_library = SDL_LoadObject(libX11XCBLibraryName); + if (!videoData->vulkan_xlib_xcb_library) { + goto fail; + } + videoData->vulkan_XGetXCBConnection = + (PFN_XGetXCBConnection)SDL_LoadFunction(videoData->vulkan_xlib_xcb_library, "XGetXCBConnection"); + if (!videoData->vulkan_XGetXCBConnection) { + SDL_UnloadObject(videoData->vulkan_xlib_xcb_library); + goto fail; + } + } + return true; + +fail: + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + return false; +} + +void X11_Vulkan_UnloadLibrary(SDL_VideoDevice *_this) +{ + SDL_VideoData *videoData = _this->internal; + if (_this->vulkan_config.loader_handle) { + if (videoData->vulkan_xlib_xcb_library) { + SDL_UnloadObject(videoData->vulkan_xlib_xcb_library); + } + SDL_UnloadObject(_this->vulkan_config.loader_handle); + _this->vulkan_config.loader_handle = NULL; + } +} + +char const* const* X11_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, + Uint32 *count) +{ + SDL_VideoData *videoData = _this->internal; + if (videoData->vulkan_xlib_xcb_library) { + static const char *const extensionsForXCB[] = { + VK_KHR_SURFACE_EXTENSION_NAME, + VK_KHR_XCB_SURFACE_EXTENSION_NAME, + }; + if(count) { + *count = SDL_arraysize(extensionsForXCB); + } + return extensionsForXCB; + } else { + static const char *const extensionsForXlib[] = { + VK_KHR_SURFACE_EXTENSION_NAME, + VK_KHR_XLIB_SURFACE_EXTENSION_NAME, + }; + if(count) { + *count = SDL_arraysize(extensionsForXlib); + } + return extensionsForXlib; + } +} + +bool X11_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface) +{ + SDL_VideoData *videoData = _this->internal; + SDL_WindowData *windowData = window->internal; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + if (videoData->vulkan_xlib_xcb_library) { + PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR = + (PFN_vkCreateXcbSurfaceKHR)vkGetInstanceProcAddr(instance, + "vkCreateXcbSurfaceKHR"); + VkXcbSurfaceCreateInfoKHR createInfo; + VkResult result; + if (!vkCreateXcbSurfaceKHR) { + return SDL_SetError(VK_KHR_XCB_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); + } + SDL_zero(createInfo); + createInfo.sType = VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR; + createInfo.connection = videoData->vulkan_XGetXCBConnection(videoData->display); + if (!createInfo.connection) { + return SDL_SetError("XGetXCBConnection failed"); + } + createInfo.window = (xcb_window_t)windowData->xwindow; + result = vkCreateXcbSurfaceKHR(instance, &createInfo, allocator, surface); + if (result != VK_SUCCESS) { + return SDL_SetError("vkCreateXcbSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); + } + } else { + PFN_vkCreateXlibSurfaceKHR vkCreateXlibSurfaceKHR = + (PFN_vkCreateXlibSurfaceKHR)vkGetInstanceProcAddr(instance, + "vkCreateXlibSurfaceKHR"); + VkXlibSurfaceCreateInfoKHR createInfo; + VkResult result; + if (!vkCreateXlibSurfaceKHR) { + return SDL_SetError(VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); + } + SDL_zero(createInfo); + createInfo.sType = VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR; + createInfo.dpy = videoData->display; + createInfo.window = (xcb_window_t)windowData->xwindow; + result = vkCreateXlibSurfaceKHR(instance, &createInfo, allocator, surface); + if (result != VK_SUCCESS) { + return SDL_SetError("vkCreateXlibSurfaceKHR failed: %s", SDL_Vulkan_GetResultString(result)); + } + } + + return true; // success! +} + +void X11_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator) +{ + if (_this->vulkan_config.loader_handle) { + SDL_Vulkan_DestroySurface_Internal(_this->vulkan_config.vkGetInstanceProcAddr, instance, surface, allocator); + } +} + +bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, + VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex) +{ + SDL_VideoData *videoData = _this->internal; + PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr; + const char *forced_visual_id; + VisualID visualid; + + if (!_this->vulkan_config.loader_handle) { + return SDL_SetError("Vulkan is not loaded"); + } + vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)_this->vulkan_config.vkGetInstanceProcAddr; + + forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID); + if (forced_visual_id) { + visualid = SDL_strtol(forced_visual_id, NULL, 0); + } else { + visualid = X11_XVisualIDFromVisual(DefaultVisual(videoData->display, DefaultScreen(videoData->display))); + } + + if (videoData->vulkan_xlib_xcb_library) { + PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR vkGetPhysicalDeviceXcbPresentationSupportKHR = + (PFN_vkGetPhysicalDeviceXcbPresentationSupportKHR)vkGetInstanceProcAddr( + instance, + "vkGetPhysicalDeviceXcbPresentationSupportKHR"); + + if (!vkGetPhysicalDeviceXcbPresentationSupportKHR) { + return SDL_SetError(VK_KHR_XCB_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); + } + + return vkGetPhysicalDeviceXcbPresentationSupportKHR(physicalDevice, + queueFamilyIndex, + videoData->vulkan_XGetXCBConnection(videoData->display), + visualid); + } else { + PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR vkGetPhysicalDeviceXlibPresentationSupportKHR = + (PFN_vkGetPhysicalDeviceXlibPresentationSupportKHR)vkGetInstanceProcAddr( + instance, + "vkGetPhysicalDeviceXlibPresentationSupportKHR"); + + if (!vkGetPhysicalDeviceXlibPresentationSupportKHR) { + return SDL_SetError(VK_KHR_XLIB_SURFACE_EXTENSION_NAME " extension is not enabled in the Vulkan instance."); + } + + return vkGetPhysicalDeviceXlibPresentationSupportKHR(physicalDevice, + queueFamilyIndex, + videoData->display, + visualid); + } +} + +#endif diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.h new file mode 100644 index 0000000..2a62596 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11vulkan.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11vulkan_h_ +#define SDL_x11vulkan_h_ + +#include + +#if defined(SDL_VIDEO_VULKAN) && defined(SDL_VIDEO_DRIVER_X11) + +typedef struct xcb_connection_t xcb_connection_t; +typedef xcb_connection_t *(*PFN_XGetXCBConnection)(Display *dpy); + +extern bool X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path); +extern void X11_Vulkan_UnloadLibrary(SDL_VideoDevice *_this); +extern char const* const* X11_Vulkan_GetInstanceExtensions(SDL_VideoDevice *_this, Uint32 *count); +extern bool X11_Vulkan_CreateSurface(SDL_VideoDevice *_this, + SDL_Window *window, + VkInstance instance, + const struct VkAllocationCallbacks *allocator, + VkSurfaceKHR *surface); +extern void X11_Vulkan_DestroySurface(SDL_VideoDevice *_this, + VkInstance instance, + VkSurfaceKHR surface, + const struct VkAllocationCallbacks *allocator); +extern bool X11_Vulkan_GetPresentationSupport(SDL_VideoDevice *_this, + VkInstance instance, + VkPhysicalDevice physicalDevice, + Uint32 queueFamilyIndex); + +#endif + +#endif // SDL_x11vulkan_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11window.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11window.c new file mode 100644 index 0000000..5562053 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11window.c @@ -0,0 +1,2243 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_events_c.h" +#include "../../core/unix/SDL_appid.h" + +#include "SDL_x11video.h" +#include "SDL_x11mouse.h" +#include "SDL_x11xinput2.h" +#include "SDL_x11xfixes.h" + +#ifdef SDL_VIDEO_OPENGL_EGL +#include "SDL_x11opengles.h" +#endif + +#include "SDL_x11xsync.h" + +#define _NET_WM_STATE_REMOVE 0l +#define _NET_WM_STATE_ADD 1l + +#define CHECK_WINDOW_DATA(window) \ + if (!window) { \ + return SDL_SetError("Invalid window"); \ + } \ + if (!window->internal) { \ + return SDL_SetError("Invalid window driver data"); \ + } + +#define CHECK_DISPLAY_DATA(display) \ + if (!_display) { \ + return SDL_SetError("Invalid display"); \ + } \ + if (!_display->internal) { \ + return SDL_SetError("Invalid display driver data"); \ + } + +static Bool isMapNotify(Display *dpy, XEvent *ev, XPointer win) // NOLINT(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef +{ + return ev->type == MapNotify && ev->xmap.window == *((Window *)win); +} +static Bool isUnmapNotify(Display *dpy, XEvent *ev, XPointer win) // NOLINT(readability-non-const-parameter): cannot make XPointer a const pointer due to typedef +{ + return ev->type == UnmapNotify && ev->xunmap.window == *((Window *)win); +} + +/* +static Bool isConfigureNotify(Display *dpy, XEvent *ev, XPointer win) +{ + return ev->type == ConfigureNotify && ev->xconfigure.window == *((Window*)win); +} +static Bool X11_XIfEventTimeout(Display *display, XEvent *event_return, Bool (*predicate)(), XPointer arg, int timeoutMS) +{ + Uint64 start = SDL_GetTicks(); + + while (!X11_XCheckIfEvent(display, event_return, predicate, arg)) { + if (SDL_GetTicks() >= (start + timeoutMS)) { + return False; + } + } + return True; +} +*/ + +static bool X11_IsWindowMapped(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + SDL_VideoData *videodata = _this->internal; + XWindowAttributes attr; + + X11_XGetWindowAttributes(videodata->display, data->xwindow, &attr); + if (attr.map_state != IsUnmapped) { + return true; + } else { + return false; + } +} + +static bool X11_IsDisplayOk(Display *display) +{ + if (display->flags & XlibDisplayIOError) { + return false; + } + return true; +} + +#if 0 +static bool X11_IsActionAllowed(SDL_Window *window, Atom action) +{ + SDL_WindowData *data = window->internal; + Atom _NET_WM_ALLOWED_ACTIONS = data->videodata->_NET_WM_ALLOWED_ACTIONS; + Atom type; + Display *display = data->videodata->display; + int form; + unsigned long remain; + unsigned long len, i; + Atom *list; + bool ret = false; + + if (X11_XGetWindowProperty(display, data->xwindow, _NET_WM_ALLOWED_ACTIONS, 0, 1024, False, XA_ATOM, &type, &form, &len, &remain, (unsigned char **)&list) == Success) { + for (i=0; ilast_position_pending; + const bool last_size_pending = window->last_size_pending; + + X11_SyncWindow(_this, window); + + window->last_position_pending = last_position_pending; + window->last_size_pending = last_size_pending; +} + +void X11_SetNetWMState(SDL_VideoDevice *_this, Window xwindow, SDL_WindowFlags flags) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + // !!! FIXME: just dereference videodata below instead of copying to locals. + Atom _NET_WM_STATE = videodata->atoms._NET_WM_STATE; + // Atom _NET_WM_STATE_HIDDEN = videodata->atoms._NET_WM_STATE_HIDDEN; + Atom _NET_WM_STATE_FOCUSED = videodata->atoms._NET_WM_STATE_FOCUSED; + Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->atoms._NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->atoms._NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_FULLSCREEN = videodata->atoms._NET_WM_STATE_FULLSCREEN; + Atom _NET_WM_STATE_ABOVE = videodata->atoms._NET_WM_STATE_ABOVE; + Atom _NET_WM_STATE_SKIP_TASKBAR = videodata->atoms._NET_WM_STATE_SKIP_TASKBAR; + Atom _NET_WM_STATE_SKIP_PAGER = videodata->atoms._NET_WM_STATE_SKIP_PAGER; + Atom _NET_WM_STATE_MODAL = videodata->atoms._NET_WM_STATE_MODAL; + Atom atoms[16]; + int count = 0; + + /* The window manager sets this property, we shouldn't set it. + If we did, this would indicate to the window manager that we don't + actually want to be mapped during X11_XMapRaised(), which would be bad. + * + if ((flags & SDL_WINDOW_HIDDEN) != 0) { + atoms[count++] = _NET_WM_STATE_HIDDEN; + } + */ + + if (flags & SDL_WINDOW_ALWAYS_ON_TOP) { + atoms[count++] = _NET_WM_STATE_ABOVE; + } + if (flags & SDL_WINDOW_UTILITY) { + atoms[count++] = _NET_WM_STATE_SKIP_TASKBAR; + atoms[count++] = _NET_WM_STATE_SKIP_PAGER; + } + if (flags & SDL_WINDOW_INPUT_FOCUS) { + atoms[count++] = _NET_WM_STATE_FOCUSED; + } + if (flags & SDL_WINDOW_MAXIMIZED) { + atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT; + atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ; + } + if (flags & SDL_WINDOW_FULLSCREEN) { + atoms[count++] = _NET_WM_STATE_FULLSCREEN; + } + if (flags & SDL_WINDOW_MODAL) { + atoms[count++] = _NET_WM_STATE_MODAL; + } + + SDL_assert(count <= SDL_arraysize(atoms)); + + if (count > 0) { + X11_XChangeProperty(display, xwindow, _NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, (unsigned char *)atoms, count); + } else { + X11_XDeleteProperty(display, xwindow, _NET_WM_STATE); + } +} + +static void X11_ConstrainPopup(SDL_Window *window, bool output_to_pending) +{ + // Clamp popup windows to the output borders + if (SDL_WINDOW_IS_POPUP(window)) { + SDL_Window *w; + SDL_DisplayID displayID; + SDL_Rect rect; + int abs_x = window->last_position_pending ? window->pending.x : window->floating.x; + int abs_y = window->last_position_pending ? window->pending.y : window->floating.y; + int offset_x = 0, offset_y = 0; + + // Calculate the total offset from the parents + for (w = window->parent; SDL_WINDOW_IS_POPUP(w); w = w->parent) { + offset_x += w->x; + offset_y += w->y; + } + + offset_x += w->x; + offset_y += w->y; + abs_x += offset_x; + abs_y += offset_y; + + displayID = SDL_GetDisplayForWindow(w); + + SDL_GetDisplayBounds(displayID, &rect); + if (abs_x + window->w > rect.x + rect.w) { + abs_x -= (abs_x + window->w) - (rect.x + rect.w); + } + if (abs_y + window->h > rect.y + rect.h) { + abs_y -= (abs_y + window->h) - (rect.y + rect.h); + } + abs_x = SDL_max(abs_x, rect.x); + abs_y = SDL_max(abs_y, rect.y); + + if (output_to_pending) { + window->pending.x = abs_x - offset_x; + window->pending.y = abs_y - offset_y; + } else { + window->floating.x = window->windowed.x = abs_x - offset_x; + window->floating.y = window->windowed.y = abs_y - offset_y; + } + } +} + +static void X11_SetKeyboardFocus(SDL_Window *window, bool set_active_focus) +{ + SDL_Window *toplevel = window; + + // Find the toplevel parent + while (SDL_WINDOW_IS_POPUP(toplevel)) { + toplevel = toplevel->parent; + } + + toplevel->internal->keyboard_focus = window; + + if (set_active_focus && !window->is_hiding && !window->is_destroying) { + SDL_SetKeyboardFocus(window); + } +} + +Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwindow) +{ + SDL_VideoData *videodata = _this->internal; + Display *display = videodata->display; + Atom _NET_WM_STATE = videodata->atoms._NET_WM_STATE; + Atom _NET_WM_STATE_HIDDEN = videodata->atoms._NET_WM_STATE_HIDDEN; + Atom _NET_WM_STATE_FOCUSED = videodata->atoms._NET_WM_STATE_FOCUSED; + Atom _NET_WM_STATE_MAXIMIZED_VERT = videodata->atoms._NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ = videodata->atoms._NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_FULLSCREEN = videodata->atoms._NET_WM_STATE_FULLSCREEN; + Atom actualType; + int actualFormat; + unsigned long i, numItems, bytesAfter; + unsigned char *propertyValue = NULL; + long maxLength = 1024; + SDL_WindowFlags flags = 0; + + if (X11_XGetWindowProperty(display, xwindow, _NET_WM_STATE, + 0l, maxLength, False, XA_ATOM, &actualType, + &actualFormat, &numItems, &bytesAfter, + &propertyValue) == Success) { + Atom *atoms = (Atom *)propertyValue; + int maximized = 0; + int fullscreen = 0; + + for (i = 0; i < numItems; ++i) { + if (atoms[i] == _NET_WM_STATE_HIDDEN) { + flags |= SDL_WINDOW_MINIMIZED | SDL_WINDOW_OCCLUDED; + } else if (atoms[i] == _NET_WM_STATE_FOCUSED) { + flags |= SDL_WINDOW_INPUT_FOCUS; + } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_VERT) { + maximized |= 1; + } else if (atoms[i] == _NET_WM_STATE_MAXIMIZED_HORZ) { + maximized |= 2; + } else if (atoms[i] == _NET_WM_STATE_FULLSCREEN) { + fullscreen = 1; + } + } + + if (fullscreen == 1) { + if (window->flags & SDL_WINDOW_FULLSCREEN) { + // Pick whatever state the window expects + flags |= (window->flags & SDL_WINDOW_FULLSCREEN); + } else { + // Assume we're fullscreen desktop + flags |= SDL_WINDOW_FULLSCREEN; + } + } + + if (maximized == 3) { + /* Fullscreen windows are maximized on some window managers, + and this is functional behavior - if maximized is removed, + the windows remain floating centered and not covering the + rest of the desktop. So we just won't change the maximize + state for fullscreen windows here, otherwise SDL would think + we're always maximized when fullscreen and not restore the + correct state when leaving fullscreen. + */ + if (fullscreen) { + flags |= (window->flags & SDL_WINDOW_MAXIMIZED); + } else { + flags |= SDL_WINDOW_MAXIMIZED; + } + } + + /* If the window is unmapped, numItems will be zero and _NET_WM_STATE_HIDDEN + * will not be set. Do an additional check to see if the window is unmapped + * and mark it as SDL_WINDOW_HIDDEN if it is. + */ + { + XWindowAttributes attr; + SDL_memset(&attr, 0, sizeof(attr)); + X11_XGetWindowAttributes(videodata->display, xwindow, &attr); + if (attr.map_state == IsUnmapped) { + flags |= SDL_WINDOW_HIDDEN; + } + } + X11_XFree(propertyValue); + } + + // FIXME, check the size hints for resizable + // flags |= SDL_WINDOW_RESIZABLE; + + return flags; +} + +static bool SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w) +{ + SDL_VideoData *videodata = _this->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + SDL_WindowData *data; + int numwindows = videodata->numwindows; + int windowlistlength = videodata->windowlistlength; + SDL_WindowData **windowlist = videodata->windowlist; + + // Allocate the window data + data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + return false; + } + data->videodata = videodata; + data->window = window; + data->xwindow = w; + data->hit_test_result = SDL_HITTEST_NORMAL; + + X11_CreateInputContext(data); + + // Associate the data with the window + + if (numwindows < windowlistlength) { + windowlist[numwindows] = data; + videodata->numwindows++; + } else { + SDL_WindowData ** new_windowlist = (SDL_WindowData **)SDL_realloc(windowlist, (numwindows + 1) * sizeof(*windowlist)); + if (!new_windowlist) { + SDL_free(data); + return false; + } + windowlist = new_windowlist; + windowlist[numwindows] = data; + videodata->numwindows++; + videodata->windowlistlength++; + videodata->windowlist = windowlist; + } + + // Fill in the SDL window with the window data + { + XWindowAttributes attrib; + + X11_XGetWindowAttributes(data->videodata->display, w, &attrib); + if (!SDL_WINDOW_IS_POPUP(window)) { + window->x = window->windowed.x = window->floating.x = attrib.x; + window->y = window->windowed.y = window->floating.y = attrib.y - data->border_top; + } + window->w = window->windowed.w = window->floating.w = attrib.width; + window->h = window->windowed.h = window->floating.h = attrib.height; + if (attrib.map_state != IsUnmapped) { + window->flags &= ~SDL_WINDOW_HIDDEN; + } else { + window->flags |= SDL_WINDOW_HIDDEN; + } + data->visual = attrib.visual; + data->colormap = attrib.colormap; + } + + window->flags |= X11_GetNetWMState(_this, window, w); + + { + Window FocalWindow; + int RevertTo = 0; + X11_XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); + if (FocalWindow == w) { + window->flags |= SDL_WINDOW_INPUT_FOCUS; + } + + if (window->flags & SDL_WINDOW_INPUT_FOCUS) { + SDL_SetKeyboardFocus(data->window); + } + + if (window->flags & SDL_WINDOW_MOUSE_GRABBED) { + // Tell x11 to clip mouse + } + } + + if (window->flags & SDL_WINDOW_EXTERNAL) { + // Query the title from the existing window + window->title = X11_GetWindowTitle(_this, w); + } + + SDL_PropertiesID props = SDL_GetWindowProperties(window); + int screen = (displaydata ? displaydata->screen : 0); + SDL_SetPointerProperty(props, SDL_PROP_WINDOW_X11_DISPLAY_POINTER, data->videodata->display); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_SCREEN_NUMBER, screen); + SDL_SetNumberProperty(props, SDL_PROP_WINDOW_X11_WINDOW_NUMBER, data->xwindow); + + // All done! + window->internal = data; + return true; +} + +static void SetupWindowInput(SDL_VideoDevice *_this, SDL_Window *window) +{ + long fevent = 0; + SDL_WindowData *data = window->internal; + Window xwindow = data->xwindow; + +#ifdef X_HAVE_UTF8_STRING + if (SDL_X11_HAVE_UTF8 && data->ic) { + X11_XGetICValues(data->ic, XNFilterEvents, &fevent, NULL); + } +#endif + + X11_Xinput2SelectTouch(_this, window); + + { + unsigned int x11_keyboard_events = KeyPressMask | KeyReleaseMask; + unsigned int x11_pointer_events = ButtonPressMask | ButtonReleaseMask | PointerMotionMask; + + X11_Xinput2SelectMouseAndKeyboard(_this, window); + + // If XInput2 can handle pointer and keyboard events, we don't track them here + if (data->xinput2_keyboard_enabled) { + x11_keyboard_events = 0; + } + if (data->xinput2_mouse_enabled) { + x11_pointer_events = 0; + } + + X11_XSelectInput(data->videodata->display, xwindow, + (FocusChangeMask | EnterWindowMask | LeaveWindowMask | ExposureMask | + x11_keyboard_events | x11_pointer_events | + PropertyChangeMask | StructureNotifyMask | + KeymapStateMask | fevent)); + } +} + +static void SetWindowBordered(Display *display, int screen, Window window, bool border) +{ + /* + * this code used to check for KWM_WIN_DECORATION, but KDE hasn't + * supported it for years and years. It now respects _MOTIF_WM_HINTS. + * Gnome is similar: just use the Motif atom. + */ + + Atom WM_HINTS = X11_XInternAtom(display, "_MOTIF_WM_HINTS", True); + if (WM_HINTS != None) { + // Hints used by Motif compliant window managers + struct + { + unsigned long flags; + unsigned long functions; + unsigned long decorations; + long input_mode; + unsigned long status; + } MWMHints = { + (1L << 1), 0, border ? 1 : 0, 0, 0 + }; + + X11_XChangeProperty(display, window, WM_HINTS, WM_HINTS, 32, + PropModeReplace, (unsigned char *)&MWMHints, + sizeof(MWMHints) / sizeof(long)); + } else { // set the transient hints instead, if necessary + X11_XSetTransientForHint(display, window, RootWindow(display, screen)); + } +} + +bool X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) +{ + Window w = (Window)SDL_GetNumberProperty(create_props, SDL_PROP_WINDOW_CREATE_X11_WINDOW_NUMBER, + (Window)SDL_GetPointerProperty(create_props, "sdl2-compat.external_window", NULL)); + if (w) { + window->flags |= SDL_WINDOW_EXTERNAL; + + if (!SetupWindowData(_this, window, w)) { + return false; + } + + SetupWindowInput(_this, window); + return true; + } + + SDL_VideoData *data = _this->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + if (!displaydata) { + return SDL_SetError("Could not find display info"); + } + + const bool force_override_redirect = SDL_GetHintBoolean(SDL_HINT_X11_FORCE_OVERRIDE_REDIRECT, false); + const bool use_resize_sync = (window->flags & SDL_WINDOW_VULKAN); /* doesn't work well with Vulkan */ + SDL_WindowData *windowdata; + Display *display = data->display; + int screen = displaydata->screen; + Visual *visual; + int depth; + XSetWindowAttributes xattr; + XSizeHints *sizehints; + XWMHints *wmhints; + XClassHint *classhints; + Atom _NET_WM_BYPASS_COMPOSITOR; + Atom _NET_WM_WINDOW_TYPE; + Atom wintype; + const char *wintype_name = NULL; + long compositor = 1; + Atom _NET_WM_PID; + const char *hint = NULL; + int win_x, win_y; + bool undefined_position = false; + +#if defined(SDL_VIDEO_OPENGL_GLX) || defined(SDL_VIDEO_OPENGL_EGL) + const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? true : false; + const char *forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID); + const char *display_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_VISUALID); + + if (forced_visual_id && *forced_visual_id) { + XVisualInfo *vi, template; + int nvis; + + SDL_zero(template); + template.visualid = SDL_strtol(forced_visual_id, NULL, 0); + vi = X11_XGetVisualInfo(display, VisualIDMask, &template, &nvis); + if (vi) { + visual = vi->visual; + depth = vi->depth; + X11_XFree(vi); + } else { + return false; + } + } else if ((window->flags & SDL_WINDOW_OPENGL) && + (!display_visual_id || !*display_visual_id)) { + XVisualInfo *vinfo = NULL; + +#ifdef SDL_VIDEO_OPENGL_EGL + if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) +#ifdef SDL_VIDEO_OPENGL_GLX + && (!_this->gl_data || X11_GL_UseEGL(_this)) +#endif + ) { + vinfo = X11_GLES_GetVisual(_this, display, screen, transparent); + } else +#endif + { +#ifdef SDL_VIDEO_OPENGL_GLX + vinfo = X11_GL_GetVisual(_this, display, screen, transparent); +#endif + } + + if (!vinfo) { + return false; + } + visual = vinfo->visual; + depth = vinfo->depth; + X11_XFree(vinfo); + } else +#endif + { + visual = displaydata->visual; + depth = displaydata->depth; + } + + xattr.override_redirect = ((window->flags & SDL_WINDOW_TOOLTIP) || (window->flags & SDL_WINDOW_POPUP_MENU) || force_override_redirect) ? True : False; + xattr.backing_store = NotUseful; + xattr.background_pixmap = None; + xattr.border_pixel = 0; + + if (visual->class == DirectColor) { + XColor *colorcells; + int i; + int ncolors; + int rmax, gmax, bmax; + int rmask, gmask, bmask; + int rshift, gshift, bshift; + + xattr.colormap = + X11_XCreateColormap(display, RootWindow(display, screen), + visual, AllocAll); + + // If we can't create a colormap, then we must die + if (!xattr.colormap) { + return SDL_SetError("Could not create writable colormap"); + } + + // OK, we got a colormap, now fill it in as best as we can + colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); + if (!colorcells) { + return false; + } + ncolors = visual->map_entries; + rmax = 0xffff; + gmax = 0xffff; + bmax = 0xffff; + + rshift = 0; + rmask = visual->red_mask; + while (0 == (rmask & 1)) { + rshift++; + rmask >>= 1; + } + + gshift = 0; + gmask = visual->green_mask; + while (0 == (gmask & 1)) { + gshift++; + gmask >>= 1; + } + + bshift = 0; + bmask = visual->blue_mask; + while (0 == (bmask & 1)) { + bshift++; + bmask >>= 1; + } + + // build the color table pixel values + for (i = 0; i < ncolors; i++) { + Uint32 red = (rmax * i) / (ncolors - 1); + Uint32 green = (gmax * i) / (ncolors - 1); + Uint32 blue = (bmax * i) / (ncolors - 1); + + Uint32 rbits = (rmask * i) / (ncolors - 1); + Uint32 gbits = (gmask * i) / (ncolors - 1); + Uint32 bbits = (bmask * i) / (ncolors - 1); + + Uint32 pix = + (rbits << rshift) | (gbits << gshift) | (bbits << bshift); + + colorcells[i].pixel = pix; + + colorcells[i].red = red; + colorcells[i].green = green; + colorcells[i].blue = blue; + + colorcells[i].flags = DoRed | DoGreen | DoBlue; + } + + X11_XStoreColors(display, xattr.colormap, colorcells, ncolors); + + SDL_free(colorcells); + } else { + xattr.colormap = + X11_XCreateColormap(display, RootWindow(display, screen), + visual, AllocNone); + } + + if (window->undefined_x && window->undefined_y && + window->last_displayID == SDL_GetPrimaryDisplay()) { + undefined_position = true; + } + + if (SDL_WINDOW_IS_POPUP(window)) { + X11_ConstrainPopup(window, false); + } + SDL_RelativeToGlobalForWindow(window, + window->floating.x, window->floating.y, + &win_x, &win_y); + + /* Always create this with the window->floating.* fields; if we're creating a windowed mode window, + * that's fine. If we're creating a maximized or fullscreen window, the window manager will want to + * know these values so it can use them if we go _back_ to the base floating windowed mode. SDL manages + * migration to fullscreen after CreateSDLWindow returns, which will put all the SDL_Window fields and + * system state as expected. + */ + w = X11_XCreateWindow(display, RootWindow(display, screen), + win_x, win_y, window->floating.w, window->floating.h, + 0, depth, InputOutput, visual, + (CWOverrideRedirect | CWBackPixmap | CWBorderPixel | + CWBackingStore | CWColormap), + &xattr); + if (!w) { + return SDL_SetError("Couldn't create window"); + } + + /* Don't set the borderless flag if we're about to go fullscreen. + * This prevents the window manager from moving a full-screen borderless + * window to a different display before we actually go fullscreen. + */ + if (!(window->pending_flags & SDL_WINDOW_FULLSCREEN)) { + SetWindowBordered(display, screen, w, !(window->flags & SDL_WINDOW_BORDERLESS)); + } + + sizehints = X11_XAllocSizeHints(); + // Setup the normal size hints + sizehints->flags = 0; + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + sizehints->min_width = sizehints->max_width = window->floating.w; + sizehints->min_height = sizehints->max_height = window->floating.h; + sizehints->flags |= (PMaxSize | PMinSize); + } + if (!undefined_position) { + sizehints->x = win_x; + sizehints->y = win_y; + sizehints->flags |= USPosition; + } + + // Setup the input hints so we get keyboard input + wmhints = X11_XAllocWMHints(); + wmhints->input = !(window->flags & SDL_WINDOW_NOT_FOCUSABLE) ? True : False; + wmhints->window_group = data->window_group; + wmhints->flags = InputHint | WindowGroupHint; + + // Setup the class hints so we can get an icon (AfterStep) + classhints = X11_XAllocClassHint(); + classhints->res_name = (char *)SDL_GetExeName(); + classhints->res_class = (char *)SDL_GetAppID(); + + // Set the size, input and class hints, and define WM_CLIENT_MACHINE and WM_LOCALE_NAME + X11_XSetWMProperties(display, w, NULL, NULL, NULL, 0, sizehints, wmhints, classhints); + + X11_XFree(sizehints); + X11_XFree(wmhints); + X11_XFree(classhints); + // Set the PID related to the window for the given hostname, if possible + if (data->pid > 0) { + long pid = (long)data->pid; + _NET_WM_PID = X11_XInternAtom(display, "_NET_WM_PID", False); + X11_XChangeProperty(display, w, _NET_WM_PID, XA_CARDINAL, 32, PropModeReplace, + (unsigned char *)&pid, 1); + } + + // Set the window manager state + X11_SetNetWMState(_this, w, window->flags); + + compositor = 2; // don't disable compositing except for "normal" windows + hint = SDL_GetHint(SDL_HINT_X11_WINDOW_TYPE); + if (window->flags & SDL_WINDOW_UTILITY) { + wintype_name = "_NET_WM_WINDOW_TYPE_UTILITY"; + } else if (window->flags & SDL_WINDOW_TOOLTIP) { + wintype_name = "_NET_WM_WINDOW_TYPE_TOOLTIP"; + } else if (window->flags & SDL_WINDOW_POPUP_MENU) { + wintype_name = "_NET_WM_WINDOW_TYPE_POPUP_MENU"; + } else if (hint && *hint) { + wintype_name = hint; + } else { + wintype_name = "_NET_WM_WINDOW_TYPE_NORMAL"; + compositor = 1; // disable compositing for "normal" windows + } + + // Let the window manager know what type of window we are. + _NET_WM_WINDOW_TYPE = X11_XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); + wintype = X11_XInternAtom(display, wintype_name, False); + X11_XChangeProperty(display, w, _NET_WM_WINDOW_TYPE, XA_ATOM, 32, + PropModeReplace, (unsigned char *)&wintype, 1); + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_BYPASS_COMPOSITOR, true)) { + _NET_WM_BYPASS_COMPOSITOR = X11_XInternAtom(display, "_NET_WM_BYPASS_COMPOSITOR", False); + X11_XChangeProperty(display, w, _NET_WM_BYPASS_COMPOSITOR, XA_CARDINAL, 32, + PropModeReplace, + (unsigned char *)&compositor, 1); + } + + { + Atom protocols[4]; + int proto_count = 0; + + protocols[proto_count++] = data->atoms.WM_DELETE_WINDOW; // Allow window to be deleted by the WM + protocols[proto_count++] = data->atoms.WM_TAKE_FOCUS; // Since we will want to set input focus explicitly + + // Default to using ping if there is no hint + if (SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_NET_WM_PING, true)) { + protocols[proto_count++] = data->atoms._NET_WM_PING; // Respond so WM knows we're alive + } + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + if (use_resize_sync) { + protocols[proto_count++] = data->atoms._NET_WM_SYNC_REQUEST; /* Respond after completing resize */ + } +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + + SDL_assert(proto_count <= sizeof(protocols) / sizeof(protocols[0])); + + X11_XSetWMProtocols(display, w, protocols, proto_count); + } + + if (!SetupWindowData(_this, window, w)) { + X11_XDestroyWindow(display, w); + return false; + } + windowdata = window->internal; + + // Set the parent if this is a non-popup window. + if (!SDL_WINDOW_IS_POPUP(window) && window->parent) { + X11_XSetTransientForHint(display, w, window->parent->internal->xwindow); + } + + // Set the flag if the borders were forced on when creating a fullscreen window for later removal. + windowdata->fullscreen_borders_forced_on = !!(window->pending_flags & SDL_WINDOW_FULLSCREEN) && + !!(window->flags & SDL_WINDOW_BORDERLESS); + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + if (use_resize_sync) { + X11_InitResizeSync(window); + } +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + +#if defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) || defined(SDL_VIDEO_OPENGL_EGL) + if ((window->flags & SDL_WINDOW_OPENGL) && + ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || + SDL_GetHintBoolean(SDL_HINT_VIDEO_FORCE_EGL, false)) +#ifdef SDL_VIDEO_OPENGL_GLX + && (!_this->gl_data || X11_GL_UseEGL(_this)) +#endif + ) { +#ifdef SDL_VIDEO_OPENGL_EGL + if (!_this->egl_data) { + return false; + } + + // Create the GLES window surface + windowdata->egl_surface = SDL_EGL_CreateSurface(_this, window, (NativeWindowType)w); + + if (windowdata->egl_surface == EGL_NO_SURFACE) { + return SDL_SetError("Could not create GLES window surface"); + } +#else + return SDL_SetError("Could not create GLES window surface (EGL support not configured)"); +#endif // SDL_VIDEO_OPENGL_EGL + } +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_XSHAPE + // Tooltips do not receive input + if (window->flags & SDL_WINDOW_TOOLTIP) { + Region region = X11_XCreateRegion(); + X11_XShapeCombineRegion(display, w, ShapeInput, 0, 0, region, ShapeSet); + X11_XDestroyRegion(region); + } +#endif + + SetupWindowInput(_this, window); + + // For _ICC_PROFILE. + X11_XSelectInput(display, RootWindow(display, screen), PropertyChangeMask); + + X11_XFlush(display); + + return true; +} + +char *X11_GetWindowTitle(SDL_VideoDevice *_this, Window xwindow) +{ + SDL_VideoData *data = _this->internal; + Display *display = data->display; + int status, real_format; + Atom real_type; + unsigned long items_read, items_left; + unsigned char *propdata; + char *title = NULL; + + status = X11_XGetWindowProperty(display, xwindow, data->atoms._NET_WM_NAME, + 0L, 8192L, False, data->atoms.UTF8_STRING, &real_type, &real_format, + &items_read, &items_left, &propdata); + if (status == Success && propdata) { + title = SDL_strdup(SDL_static_cast(char *, propdata)); + X11_XFree(propdata); + } else { + status = X11_XGetWindowProperty(display, xwindow, XA_WM_NAME, + 0L, 8192L, False, XA_STRING, &real_type, &real_format, + &items_read, &items_left, &propdata); + if (status == Success && propdata) { + title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char *, propdata), items_read + 1); + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Failed to convert WM_NAME title expecting UTF8! Title: %s", title); + X11_XFree(propdata); + } else { + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "Could not get any window title response from Xorg, returning empty string!"); + title = SDL_strdup(""); + } + } + return title; +} + +void X11_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Window xwindow = data->xwindow; + Display *display = data->videodata->display; + char *title = window->title ? window->title : ""; + + SDL_X11_SetWindowTitle(display, xwindow, title); +} + +static bool caught_x11_error = false; +static int X11_CatchAnyError(Display *d, XErrorEvent *e) +{ + /* this may happen during tumultuous times when we are polling anyhow, + so just note we had an error and return control. */ + caught_x11_error = true; + return 0; +} + +/* Wait a brief time, or not, to see if the window manager decided to move/resize the window. + * Send MOVED and RESIZED window events */ +static bool X11_SyncWindowTimeout(SDL_VideoDevice *_this, SDL_Window *window, Uint64 param_timeout) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + int (*prev_handler)(Display *, XErrorEvent *); + Uint64 timeout = 0; + bool force_exit = false; + bool result = true; + + X11_XSync(display, False); + prev_handler = X11_XSetErrorHandler(X11_CatchAnyError); + + if (param_timeout) { + timeout = SDL_GetTicksNS() + param_timeout; + } + + while (true) { + X11_XSync(display, False); + X11_PumpEvents(_this); + + if ((data->pending_operation & X11_PENDING_OP_MOVE) && (window->x == data->expected.x + data->border_left && window->y == data->expected.y + data->border_top)) { + data->pending_operation &= ~X11_PENDING_OP_MOVE; + } + if ((data->pending_operation & X11_PENDING_OP_RESIZE) && (window->w == data->expected.w && window->h == data->expected.h)) { + data->pending_operation &= ~X11_PENDING_OP_RESIZE; + } + + if (data->pending_operation == X11_PENDING_OP_NONE) { + if (force_exit || + (window->x == data->expected.x + data->border_left && window->y == data->expected.y + data->border_top && + window->w == data->expected.w && window->h == data->expected.h)) { + // The window is in the expected state and nothing is pending. Done. + break; + } + + /* No operations are pending, but the window still isn't in the expected state. + * Try one more time before exiting. + */ + force_exit = true; + } + + if (SDL_GetTicksNS() >= timeout) { + // Timed out without the expected values. Update the requested data so future sync calls won't block. + data->expected.x = window->x; + data->expected.y = window->y; + data->expected.w = window->w; + data->expected.h = window->h; + + result = false; + break; + } + + SDL_Delay(10); + } + + data->pending_operation = X11_PENDING_OP_NONE; + + if (!caught_x11_error) { + X11_PumpEvents(_this); + } else { + result = false; + } + + X11_XSetErrorHandler(prev_handler); + caught_x11_error = false; + + return result; +} + +bool X11_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + Atom _NET_WM_ICON = data->videodata->atoms._NET_WM_ICON; + int (*prevHandler)(Display *, XErrorEvent *) = NULL; + bool result = true; + + if (icon) { + int x, y; + int propsize; + long *propdata; + Uint32 *src; + long *dst; + + // Set the _NET_WM_ICON property + SDL_assert(icon->format == SDL_PIXELFORMAT_ARGB8888); + propsize = 2 + (icon->w * icon->h); + propdata = SDL_malloc(propsize * sizeof(long)); + + if (!propdata) { + return false; + } + + X11_XSync(display, False); + prevHandler = X11_XSetErrorHandler(X11_CatchAnyError); + + propdata[0] = icon->w; + propdata[1] = icon->h; + dst = &propdata[2]; + + for (y = 0; y < icon->h; ++y) { + src = (Uint32 *)((Uint8 *)icon->pixels + y * icon->pitch); + for (x = 0; x < icon->w; ++x) { + *dst++ = *src++; + } + } + + X11_XChangeProperty(display, data->xwindow, _NET_WM_ICON, XA_CARDINAL, + 32, PropModeReplace, (unsigned char *)propdata, + propsize); + SDL_free(propdata); + + if (caught_x11_error) { + result = SDL_SetError("An error occurred while trying to set the window's icon"); + } + } + + X11_XFlush(display); + + if (prevHandler) { + X11_XSetErrorHandler(prevHandler); + caught_x11_error = false; + } + + return result; +} + +void X11_UpdateWindowPosition(SDL_Window *window, bool use_current_position) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + const int rel_x = use_current_position ? window->x : window->pending.x; + const int rel_y = use_current_position ? window->y : window->pending.y; + + SDL_RelativeToGlobalForWindow(window, + rel_x - data->border_left, rel_y - data->border_top, + &data->expected.x, &data->expected.y); + + // Attempt to move the window + if (window->flags & SDL_WINDOW_HIDDEN) { + window->internal->pending_position = true; + } else { + data->pending_operation |= X11_PENDING_OP_MOVE; + X11_XMoveWindow(display, data->xwindow, data->expected.x, data->expected.y); + } +} + +bool X11_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window) +{ + // Sync any pending fullscreen or maximize events. + if (window->internal->pending_operation & (X11_PENDING_OP_FULLSCREEN | X11_PENDING_OP_MAXIMIZE)) { + X11_FlushPendingEvents(_this, window); + } + + // Set the position as pending if the window is maximized with a restore pending. + if (window->flags & SDL_WINDOW_MAXIMIZED) { + if (window->internal->pending_operation & X11_PENDING_OP_RESTORE) { + window->internal->pending_position = true; + } + return true; + } + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + if (SDL_WINDOW_IS_POPUP(window)) { + X11_ConstrainPopup(window, true); + } + X11_UpdateWindowPosition(window, false); + } else { + SDL_UpdateFullscreenMode(window, SDL_FULLSCREEN_OP_UPDATE, true); + } + return true; +} + +void X11_SetWindowMinMax(SDL_Window *window, bool use_current) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + XSizeHints *sizehints = X11_XAllocSizeHints(); + long hint_flags = 0; + + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &hint_flags); + sizehints->flags &= ~(PMinSize | PMaxSize | PAspect); + + if (data->window->flags & SDL_WINDOW_RESIZABLE) { + if (data->window->min_w || data->window->min_h) { + sizehints->flags |= PMinSize; + sizehints->min_width = data->window->min_w; + sizehints->min_height = data->window->min_h; + } + if (data->window->max_w || data->window->max_h) { + sizehints->flags |= PMaxSize; + sizehints->max_width = data->window->max_w; + sizehints->max_height = data->window->max_h; + } + if (data->window->min_aspect > 0.0f || data->window->max_aspect > 0.0f) { + sizehints->flags |= PAspect; + SDL_CalculateFraction(data->window->min_aspect, &sizehints->min_aspect.x, &sizehints->min_aspect.y); + SDL_CalculateFraction(data->window->max_aspect, &sizehints->max_aspect.x, &sizehints->max_aspect.y); + } + } else { + // Set the min/max to the same values to make the window non-resizable + sizehints->flags |= PMinSize | PMaxSize; + sizehints->min_width = sizehints->max_width = use_current ? data->window->floating.w : window->windowed.w; + sizehints->min_height = sizehints->max_height = use_current ? data->window->floating.h : window->windowed.h; + } + + X11_XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XFree(sizehints); +} + +void X11_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (window->internal->pending_operation & X11_PENDING_OP_FULLSCREEN) { + X11_SyncWindow(_this, window); + } + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + X11_SetWindowMinMax(window, true); + } +} + +void X11_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (window->internal->pending_operation & X11_PENDING_OP_FULLSCREEN) { + X11_SyncWindow(_this, window); + } + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + X11_SetWindowMinMax(window, true); + } +} + +void X11_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (window->internal->pending_operation & X11_PENDING_OP_FULLSCREEN) { + X11_SyncWindow(_this, window); + } + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + X11_SetWindowMinMax(window, true); + } +} + +void X11_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + + /* Wait for pending maximize and fullscreen operations to complete, as these windows + * don't get size changes. + */ + if (data->pending_operation & (X11_PENDING_OP_MAXIMIZE | X11_PENDING_OP_FULLSCREEN)) { + X11_FlushPendingEvents(_this, window); + } + + // Set the size as pending if the window is being restored. + if (window->flags & (SDL_WINDOW_MAXIMIZED | SDL_WINDOW_FULLSCREEN)) { + // New size will be set when the window is restored. + if (data->pending_operation & X11_PENDING_OP_RESTORE) { + data->pending_size = true; + } else { + // Can't resize the window. + window->last_size_pending = false; + } + return; + } + + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the X11_XResizeWindow, thus + * we must set the size hints to adjust the window size. + */ + XSizeHints *sizehints = X11_XAllocSizeHints(); + long userhints; + int dest_x, dest_y; + + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + + sizehints->min_width = sizehints->max_width = window->pending.w; + sizehints->min_height = sizehints->max_height = window->pending.h; + sizehints->flags |= PMinSize | PMaxSize; + + X11_XSetWMNormalHints(display, data->xwindow, sizehints); + + /* From Pierre-Loup: + WMs each have their little quirks with that. When you change the + size hints, they get a ConfigureNotify event with the + WM_NORMAL_SIZE_HINTS Atom. They all save the hints then, but they + don't all resize the window right away to enforce the new hints. + + Some of them resize only after: + - A user-initiated move or resize + - A code-initiated move or resize + - Hiding & showing window (Unmap & map) + + The following move & resize seems to help a lot of WMs that didn't + properly update after the hints were changed. We don't do a + hide/show, because there are supposedly subtle problems with doing so + and transitioning from windowed to fullscreen in Unity. + */ + X11_XResizeWindow(display, data->xwindow, window->pending.w, window->pending.h); + const int x = window->last_position_pending ? window->pending.x : window->x; + const int y = window->last_position_pending ? window->pending.y : window->y; + SDL_RelativeToGlobalForWindow(window, + x - data->border_left, + y - data->border_top, + &dest_x, &dest_y); + X11_XMoveWindow(display, data->xwindow, dest_x, dest_y); + X11_XRaiseWindow(display, data->xwindow); + + X11_XFree(sizehints); + } + } else { + data->expected.w = window->pending.w; + data->expected.h = window->pending.h; + data->pending_operation |= X11_PENDING_OP_RESIZE; + X11_XResizeWindow(display, data->xwindow, data->expected.w, data->expected.h); + } +} + +bool X11_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *top, int *left, int *bottom, int *right) +{ + SDL_WindowData *data = window->internal; + + *left = data->border_left; + *right = data->border_right; + *top = data->border_top; + *bottom = data->border_bottom; + + return true; +} + +bool X11_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + Atom _NET_WM_WINDOW_OPACITY = data->videodata->atoms._NET_WM_WINDOW_OPACITY; + + if (opacity == 1.0f) { + X11_XDeleteProperty(display, data->xwindow, _NET_WM_WINDOW_OPACITY); + } else { + const Uint32 FullyOpaque = 0xFFFFFFFF; + const long alpha = (long)((double)opacity * (double)FullyOpaque); + X11_XChangeProperty(display, data->xwindow, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)&alpha, 1); + } + + return true; +} + +bool X11_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent) +{ + SDL_WindowData *data = window->internal; + SDL_WindowData *parent_data = parent ? parent->internal : NULL; + SDL_VideoData *video_data = _this->internal; + Display *display = video_data->display; + + if (parent_data) { + X11_XSetTransientForHint(display, data->xwindow, parent_data->xwindow); + } else { + X11_XDeleteProperty(display, data->xwindow, video_data->atoms.WM_TRANSIENT_FOR); + } + + return true; +} + +bool X11_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal) +{ + SDL_WindowData *data = window->internal; + SDL_VideoData *video_data = _this->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + Display *display = video_data->display; + Uint32 flags = window->flags; + Atom _NET_WM_STATE = data->videodata->atoms._NET_WM_STATE; + Atom _NET_WM_STATE_MODAL = data->videodata->atoms._NET_WM_STATE_MODAL; + + if (modal) { + flags |= SDL_WINDOW_MODAL; + } else { + flags &= ~SDL_WINDOW_MODAL; + X11_XDeleteProperty(display, data->xwindow, video_data->atoms.WM_TRANSIENT_FOR); + } + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = modal ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + e.xclient.data.l[1] = _NET_WM_STATE_MODAL; + e.xclient.data.l[3] = 0l; + + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + X11_SetNetWMState(_this, data->xwindow, flags); + } + + X11_XFlush(display); + + return true; +} + +void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered) +{ + const bool focused = (window->flags & SDL_WINDOW_INPUT_FOCUS) ? true : false; + const bool visible = (!(window->flags & SDL_WINDOW_HIDDEN)) ? true : false; + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + Display *display = data->videodata->display; + XEvent event; + + if (data->pending_operation & X11_PENDING_OP_FULLSCREEN) { + X11_SyncWindow(_this, window); + } + + // If the window is fullscreen, the resize capability will be set/cleared when it is returned to windowed mode. + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + SetWindowBordered(display, displaydata->screen, data->xwindow, bordered); + X11_XFlush(display); + + if (visible) { + XWindowAttributes attr; + do { + X11_XSync(display, False); + X11_XGetWindowAttributes(display, data->xwindow, &attr); + } while (attr.map_state != IsViewable); + + if (focused) { + X11_XSetInputFocus(display, data->xwindow, RevertToParent, CurrentTime); + } + } + + // make sure these don't make it to the real event queue if they fired here. + X11_XSync(display, False); + X11_XCheckIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); + X11_XCheckIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); + + // Turning the borders off doesn't send an extent event, so they must be cleared here. + X11_GetBorderValues(data); + + // Make sure the window manager didn't resize our window for the difference. + X11_XResizeWindow(display, data->xwindow, window->floating.w, window->floating.h); + X11_XSync(display, False); + } else { + // If fullscreen, set a flag to toggle the borders when returning to windowed mode. + data->toggle_borders = true; + data->fullscreen_borders_forced_on = false; + } +} + +void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable) +{ + SDL_WindowData *data = window->internal; + + if (data->pending_operation & X11_PENDING_OP_FULLSCREEN) { + X11_SyncWindow(_this, window); + } + + // If the window is fullscreen, the resize capability will be set/cleared when it is returned to windowed mode. + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + X11_SetWindowMinMax(window, true); + } +} + +void X11_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top) +{ + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + Display *display = data->videodata->display; + Atom _NET_WM_STATE = data->videodata->atoms._NET_WM_STATE; + Atom _NET_WM_STATE_ABOVE = data->videodata->atoms._NET_WM_STATE_ABOVE; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = + on_top ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + e.xclient.data.l[1] = _NET_WM_STATE_ABOVE; + e.xclient.data.l[3] = 0l; + + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + X11_SetNetWMState(_this, data->xwindow, window->flags); + } + X11_XFlush(display); +} + +void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_SHOWN, true); + bool position_is_absolute = false; + bool set_position = false; + XEvent event; + + if (SDL_WINDOW_IS_POPUP(window)) { + // Update the position in case the parent moved while we were hidden + X11_ConstrainPopup(window, true); + data->pending_position = true; + + // Coordinates after X11_ConstrainPopup() are already in the global space. + position_is_absolute = true; + set_position = true; + } + + /* Whether XMapRaised focuses the window is based on the window type and it is + * wm specific. There isn't much we can do here */ + (void)bActivate; + + if (!X11_IsWindowMapped(_this, window)) { + X11_XMapRaised(display, data->xwindow); + /* Blocking wait for "MapNotify" event. + * We use X11_XIfEvent because pXWindowEvent takes a mask rather than a type, + * and XCheckTypedWindowEvent doesn't block */ + if (!(window->flags & SDL_WINDOW_EXTERNAL) && X11_IsDisplayOk(display)) { + X11_XIfEvent(display, &event, &isMapNotify, (XPointer)&data->xwindow); + } + X11_XFlush(display); + set_position = data->pending_position || + (!(window->flags & SDL_WINDOW_BORDERLESS) && !window->undefined_x && !window->undefined_y); + } + + if (!data->videodata->net_wm) { + // no WM means no FocusIn event, which confuses us. Force it. + X11_XSync(display, False); + X11_XSetInputFocus(display, data->xwindow, RevertToNone, CurrentTime); + X11_XFlush(display); + } + + // Popup menus grab the keyboard + if (window->flags & SDL_WINDOW_POPUP_MENU) { + X11_SetKeyboardFocus(window, window->parent == SDL_GetKeyboardFocus()); + } + + // Get some valid border values, if we haven't received them yet + if (data->border_left == 0 && data->border_right == 0 && data->border_top == 0 && data->border_bottom == 0) { + X11_GetBorderValues(data); + } + + if (set_position) { + // Apply the window position, accounting for offsets due to the borders appearing. + const int tx = data->pending_position ? window->pending.x : window->x; + const int ty = data->pending_position ? window->pending.y : window->y; + int x, y; + if (position_is_absolute) { + x = tx; + y = ty; + } else { + SDL_RelativeToGlobalForWindow(window, + tx - data->border_left, ty - data->border_top, + &x, &y); + } + data->pending_position = false; + X11_XMoveWindow(display, data->xwindow, x, y); + } + + /* Some window managers can send garbage coordinates while mapping the window, so don't emit size and position + * events during the initial configure events. + */ + data->size_move_event_flags = X11_SIZE_MOVE_EVENTS_DISABLE; + X11_XSync(display, False); + X11_PumpEvents(_this); + data->size_move_event_flags = 0; + + // If a configure event was received (type is non-zero), send the final window size and coordinates. + if (data->last_xconfigure.type) { + int x, y; + SDL_GlobalToRelativeForWindow(data->window, data->last_xconfigure.x, data->last_xconfigure.y, &x, &y); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESIZED, data->last_xconfigure.width, data->last_xconfigure.height); + SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, x, y); + } +} + +void X11_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + int screen = (displaydata ? displaydata->screen : 0); + Display *display = data->videodata->display; + XEvent event; + + if (X11_IsWindowMapped(_this, window)) { + X11_XWithdrawWindow(display, data->xwindow, screen); + // Blocking wait for "UnmapNotify" event + if (!(window->flags & SDL_WINDOW_EXTERNAL) && X11_IsDisplayOk(display)) { + X11_XIfEvent(display, &event, &isUnmapNotify, (XPointer)&data->xwindow); + } + X11_XFlush(display); + } + + // Transfer keyboard focus back to the parent + if (window->flags & SDL_WINDOW_POPUP_MENU) { + SDL_Window *new_focus = window->parent; + bool set_focus = window == SDL_GetKeyboardFocus(); + + // Find the highest level window, up to the toplevel parent, that isn't being hidden or destroyed. + while (SDL_WINDOW_IS_POPUP(new_focus) && (new_focus->is_hiding || new_focus->is_destroying)) { + new_focus = new_focus->parent; + + // If some window in the chain currently had focus, set it to the new lowest-level window. + if (!set_focus) { + set_focus = new_focus == SDL_GetKeyboardFocus(); + } + } + + X11_SetKeyboardFocus(new_focus, set_focus); + } + + X11_XSync(display, False); + X11_PumpEvents(_this); +} + +static bool X11_SetWindowActive(SDL_VideoDevice *_this, SDL_Window *window) +{ + CHECK_WINDOW_DATA(window); + + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + Display *display = data->videodata->display; + Atom _NET_ACTIVE_WINDOW = data->videodata->atoms._NET_ACTIVE_WINDOW; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + // printf("SDL Window %p: sending _NET_ACTIVE_WINDOW with timestamp %lu\n", window, data->user_time); + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_ACTIVE_WINDOW; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = 1; // source indication. 1 = application + e.xclient.data.l[1] = data->user_time; + e.xclient.data.l[2] = 0; + + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + + X11_XFlush(display); + } + return true; +} + +void X11_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + bool bActivate = SDL_GetHintBoolean(SDL_HINT_WINDOW_ACTIVATE_WHEN_RAISED, true); + + X11_XRaiseWindow(display, data->xwindow); + if (bActivate) { + X11_SetWindowActive(_this, window); + } + X11_XFlush(display); +} + +static bool X11_SetWindowMaximized(SDL_VideoDevice *_this, SDL_Window *window, bool maximized) +{ + CHECK_WINDOW_DATA(window); + + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + Display *display = data->videodata->display; + Atom _NET_WM_STATE = data->videodata->atoms._NET_WM_STATE; + Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->atoms._NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->atoms._NET_WM_STATE_MAXIMIZED_HORZ; + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + /* Fullscreen windows are maximized on some window managers, + and this is functional behavior, so don't remove that state + now, we'll take care of it when we leave fullscreen mode. + */ + return true; + } + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = + maximized ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + e.xclient.data.l[1] = _NET_WM_STATE_MAXIMIZED_VERT; + e.xclient.data.l[2] = _NET_WM_STATE_MAXIMIZED_HORZ; + e.xclient.data.l[3] = 0l; + + if (maximized) { + SDL_DisplayID displayID = SDL_GetDisplayForWindow(window); + SDL_Rect bounds; + + SDL_zero(bounds); + SDL_GetDisplayUsableBounds(displayID, &bounds); + + data->expected.x = bounds.x + data->border_left; + data->expected.y = bounds.y + data->border_top; + data->expected.w = bounds.w - (data->border_left + data->border_right); + data->expected.h = bounds.h - (data->border_top + data->border_bottom); + } else { + data->expected.x = window->floating.x; + data->expected.y = window->floating.y; + data->expected.w = window->floating.w; + data->expected.h = window->floating.h; + } + + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + X11_SetNetWMState(_this, data->xwindow, window->flags); + } + X11_XFlush(display); + + return true; +} + +void X11_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (window->internal->pending_operation & (X11_PENDING_OP_FULLSCREEN | X11_PENDING_OP_MINIMIZE)) { + SDL_SyncWindow(window); + } + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + // If fullscreen, just toggle the restored state. + window->internal->window_was_maximized = true; + return; + } + + if (!(window->flags & SDL_WINDOW_MINIMIZED)) { + window->internal->pending_operation |= X11_PENDING_OP_MAXIMIZE; + X11_SetWindowMaximized(_this, window, true); + } +} + +void X11_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + Display *display = data->videodata->display; + + if (data->pending_operation & SDL_WINDOW_FULLSCREEN) { + SDL_SyncWindow(window); + } + + data->pending_operation |= X11_PENDING_OP_MINIMIZE; + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + data->window_was_maximized = !!(window->flags & SDL_WINDOW_MAXIMIZED); + } + X11_XIconifyWindow(display, data->xwindow, displaydata->screen); + X11_XFlush(display); +} + +void X11_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (window->internal->pending_operation & (X11_PENDING_OP_FULLSCREEN | X11_PENDING_OP_MAXIMIZE | X11_PENDING_OP_MINIMIZE)) { + SDL_SyncWindow(window); + } + + if ((window->flags & SDL_WINDOW_FULLSCREEN) && !(window->flags & SDL_WINDOW_MINIMIZED)) { + // If fullscreen and not minimized, just toggle the restored state. + window->internal->window_was_maximized = false; + return; + } + + if (window->flags & (SDL_WINDOW_MINIMIZED | SDL_WINDOW_MAXIMIZED) || + (window->internal->pending_operation & X11_PENDING_OP_MINIMIZE)) { + window->internal->pending_operation |= X11_PENDING_OP_RESTORE; + } + + // If the window was minimized while maximized, restore as maximized. + const bool maximize = !!(window->flags & SDL_WINDOW_MINIMIZED) && window->internal->window_was_maximized; + X11_SetWindowMaximized(_this, window, maximize); + X11_ShowWindow(_this, window); + X11_SetWindowActive(_this, window); +} + +// This asks the Window Manager to handle fullscreen for us. This is the modern way. +static SDL_FullscreenResult X11_SetWindowFullscreenViaWM(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *_display, SDL_FullscreenOp fullscreen) +{ + CHECK_WINDOW_DATA(window); + CHECK_DISPLAY_DATA(_display); + + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = _display->internal; + Display *display = data->videodata->display; + Atom _NET_WM_STATE = data->videodata->atoms._NET_WM_STATE; + Atom _NET_WM_STATE_FULLSCREEN = data->videodata->atoms._NET_WM_STATE_FULLSCREEN; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + // Flush any pending fullscreen events. + if (data->pending_operation & (X11_PENDING_OP_FULLSCREEN | X11_PENDING_OP_MAXIMIZE | X11_PENDING_OP_MOVE)) { + X11_SyncWindow(_this, window); + } + + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + if (fullscreen == SDL_FULLSCREEN_OP_UPDATE) { + // Request was out of date; set -1 to signal the video core to undo a mode switch. + return SDL_FULLSCREEN_FAILED; + } else if (fullscreen == SDL_FULLSCREEN_OP_LEAVE) { + // Nothing to do. + return SDL_FULLSCREEN_SUCCEEDED; + } + } + + if (fullscreen && !(window->flags & SDL_WINDOW_RESIZABLE)) { + /* Compiz refuses fullscreen toggle if we're not resizable, so update the hints so we + can be resized to the fullscreen resolution (or reset so we're not resizable again) */ + XSizeHints *sizehints = X11_XAllocSizeHints(); + long flags = 0; + X11_XGetWMNormalHints(display, data->xwindow, sizehints, &flags); + // we are going fullscreen so turn the flags off + sizehints->flags &= ~(PMinSize | PMaxSize | PAspect); + X11_XSetWMNormalHints(display, data->xwindow, sizehints); + X11_XFree(sizehints); + } + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = + fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; + e.xclient.data.l[3] = 0l; + + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + + if (!!(window->flags & SDL_WINDOW_FULLSCREEN) != fullscreen) { + data->pending_operation |= X11_PENDING_OP_FULLSCREEN; + } + + // Set the position so the window will be on the target display + if (fullscreen) { + SDL_DisplayID current = SDL_GetDisplayForWindowPosition(window); + SDL_copyp(&data->requested_fullscreen_mode, &window->current_fullscreen_mode); + if (fullscreen != !!(window->flags & SDL_WINDOW_FULLSCREEN)) { + data->window_was_maximized = !!(window->flags & SDL_WINDOW_MAXIMIZED); + } + data->expected.x = displaydata->x; + data->expected.y = displaydata->y; + data->expected.w = _display->current_mode->w; + data->expected.h = _display->current_mode->h; + + // Only move the window if it isn't fullscreen or already on the target display. + if (!(window->flags & SDL_WINDOW_FULLSCREEN) || (!current || current != _display->id)) { + X11_XMoveWindow(display, data->xwindow, displaydata->x, displaydata->y); + data->pending_operation |= X11_PENDING_OP_MOVE; + } + } else { + SDL_zero(data->requested_fullscreen_mode); + + /* Fullscreen windows sometimes end up being marked maximized by + * window managers. Force it back to how we expect it to be. + */ + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + if (data->window_was_maximized) { + e.xclient.data.l[0] = _NET_WM_STATE_ADD; + } else { + e.xclient.data.l[0] = _NET_WM_STATE_REMOVE; + } + e.xclient.data.l[1] = data->videodata->atoms._NET_WM_STATE_MAXIMIZED_VERT; + e.xclient.data.l[2] = data->videodata->atoms._NET_WM_STATE_MAXIMIZED_HORZ; + e.xclient.data.l[3] = 0l; + X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } + } else { + SDL_WindowFlags flags; + + flags = window->flags; + if (fullscreen) { + flags |= SDL_WINDOW_FULLSCREEN; + } else { + flags &= ~SDL_WINDOW_FULLSCREEN; + } + X11_SetNetWMState(_this, data->xwindow, flags); + } + + if (data->visual->class == DirectColor) { + if (fullscreen) { + X11_XInstallColormap(display, data->colormap); + } else { + X11_XUninstallColormap(display, data->colormap); + } + } + + return SDL_FULLSCREEN_PENDING; +} + +SDL_FullscreenResult X11_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *_display, SDL_FullscreenOp fullscreen) +{ + return X11_SetWindowFullscreenViaWM(_this, window, _display, fullscreen); +} + +typedef struct +{ + unsigned char *data; + int format, count; + Atom type; +} SDL_x11Prop; + +/* Reads property + Must call X11_XFree on results + */ +static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) +{ + unsigned char *ret = NULL; + Atom type; + int fmt; + unsigned long count; + unsigned long bytes_left; + int bytes_fetch = 0; + + do { + if (ret) { + X11_XFree(ret); + } + X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); + bytes_fetch += bytes_left; + } while (bytes_left != 0); + + p->data = ret; + p->format = fmt; + p->count = count; + p->type = type; +} + +void *X11_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + XWindowAttributes attributes; + Atom icc_profile_atom; + char icc_atom_string[sizeof("_ICC_PROFILE_") + 12]; + void *ret_icc_profile_data = NULL; + CARD8 *icc_profile_data; + int real_format; + unsigned long real_nitems; + SDL_x11Prop atomProp; + + X11_XGetWindowAttributes(display, data->xwindow, &attributes); + if (X11_XScreenNumberOfScreen(attributes.screen) > 0) { + (void)SDL_snprintf(icc_atom_string, sizeof("_ICC_PROFILE_") + 12, "%s%d", "_ICC_PROFILE_", X11_XScreenNumberOfScreen(attributes.screen)); + } else { + SDL_strlcpy(icc_atom_string, "_ICC_PROFILE", sizeof("_ICC_PROFILE")); + } + X11_XGetWindowAttributes(display, RootWindowOfScreen(attributes.screen), &attributes); + + icc_profile_atom = X11_XInternAtom(display, icc_atom_string, True); + if (icc_profile_atom == None) { + SDL_SetError("Screen is not calibrated."); + return NULL; + } + + X11_ReadProperty(&atomProp, display, RootWindowOfScreen(attributes.screen), icc_profile_atom); + real_format = atomProp.format; + real_nitems = atomProp.count; + icc_profile_data = atomProp.data; + if (real_format == None) { + SDL_SetError("Screen is not calibrated."); + return NULL; + } + + ret_icc_profile_data = SDL_malloc(real_nitems); + if (!ret_icc_profile_data) { + return NULL; + } + + SDL_memcpy(ret_icc_profile_data, icc_profile_data, real_nitems); + *size = real_nitems; + X11_XFree(icc_profile_data); + + return ret_icc_profile_data; +} + +bool X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + SDL_WindowData *data = window->internal; + Display *display; + + if (!data) { + return SDL_SetError("Invalid window data"); + } + data->mouse_grabbed = false; + + display = data->videodata->display; + + if (grabbed) { + /* If the window is unmapped, XGrab calls return GrabNotViewable, + so when we get a MapNotify later, we'll try to update the grab as + appropriate. */ + if (window->flags & SDL_WINDOW_HIDDEN) { + return true; + } + + /* If XInput2 is enabled, it will grab the pointer on button presses, + * which results in XGrabPointer returning AlreadyGrabbed. If buttons + * are currently pressed, clear any existing grabs before attempting + * the confinement grab. + */ + if (data->xinput2_mouse_enabled && SDL_GetMouseState(NULL, NULL)) { + X11_XUngrabPointer(display, CurrentTime); + } + + // Try to grab the mouse + if (!data->videodata->broken_pointer_grab) { + const unsigned int mask = ButtonPressMask | ButtonReleaseMask | PointerMotionMask | FocusChangeMask; + int attempts; + int result = 0; + + // Try for up to 5000ms (5s) to grab. If it still fails, stop trying. + for (attempts = 0; attempts < 100; attempts++) { + result = X11_XGrabPointer(display, data->xwindow, False, mask, GrabModeAsync, + GrabModeAsync, data->xwindow, None, CurrentTime); + if (result == GrabSuccess) { + data->mouse_grabbed = true; + break; + } + SDL_Delay(50); + } + + if (result != GrabSuccess) { + data->videodata->broken_pointer_grab = true; // don't try again. + } + } + + X11_Xinput2GrabTouch(_this, window); + + // Raise the window if we grab the mouse + X11_XRaiseWindow(display, data->xwindow); + } else { + X11_XUngrabPointer(display, CurrentTime); + + X11_Xinput2UngrabTouch(_this, window); + } + X11_XSync(display, False); + + if (!data->videodata->broken_pointer_grab) { + return true; + } else { + return SDL_SetError("The X server refused to let us grab the mouse. You might experience input bugs."); + } +} + +bool X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed) +{ + SDL_WindowData *data = window->internal; + Display *display; + + if (!data) { + return SDL_SetError("Invalid window data"); + } + + display = data->videodata->display; + + if (grabbed) { + /* If the window is unmapped, XGrab calls return GrabNotViewable, + so when we get a MapNotify later, we'll try to update the grab as + appropriate. */ + if (window->flags & SDL_WINDOW_HIDDEN) { + return true; + } + + X11_XGrabKeyboard(display, data->xwindow, True, GrabModeAsync, + GrabModeAsync, CurrentTime); + } else { + X11_XUngrabKeyboard(display, CurrentTime); + } + X11_XSync(display, False); + + return true; +} + +void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + + if (data) { + SDL_VideoData *videodata = data->videodata; + Display *display = videodata->display; + int numwindows = videodata->numwindows; + SDL_WindowData **windowlist = videodata->windowlist; + int i; + + if (windowlist) { + for (i = 0; i < numwindows; ++i) { + if (windowlist[i] && (windowlist[i]->window == window)) { + windowlist[i] = windowlist[numwindows - 1]; + windowlist[numwindows - 1] = NULL; + videodata->numwindows--; + break; + } + } + } +#ifdef X_HAVE_UTF8_STRING + if (data->ic) { + X11_XDestroyIC(data->ic); + SDL_free(data->preedit_text); + SDL_free(data->preedit_feedback); + } +#endif + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + X11_TermResizeSync(window); +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + + if (!(window->flags & SDL_WINDOW_EXTERNAL)) { + X11_XDestroyWindow(display, data->xwindow); + X11_XFlush(display); + } + SDL_free(data); + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + // If the pointer barriers are active for this, deactivate it. + if (videodata->active_cursor_confined_window == window) { + X11_DestroyPointerBarrier(_this, window); + } +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + } + window->internal = NULL; +} + +bool X11_SetWindowHitTest(SDL_Window *window, bool enabled) +{ + return true; // just succeed, the real work is done elsewhere. +} + +void X11_AcceptDragAndDrop(SDL_Window *window, bool accept) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + Atom XdndAware = data->videodata->atoms.XdndAware; + + if (accept) { + Atom xdnd_version = 5; + X11_XChangeProperty(display, data->xwindow, XdndAware, XA_ATOM, 32, + PropModeReplace, (unsigned char *)&xdnd_version, 1); + } else { + X11_XDeleteProperty(display, data->xwindow, XdndAware); + } +} + +bool X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + XWMHints *wmhints; + + wmhints = X11_XGetWMHints(display, data->xwindow); + if (!wmhints) { + return SDL_SetError("Couldn't get WM hints"); + } + + wmhints->flags &= ~XUrgencyHint; + data->flashing_window = false; + data->flash_cancel_time = 0; + + switch (operation) { + case SDL_FLASH_CANCEL: + // Taken care of above + break; + case SDL_FLASH_BRIEFLY: + if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { + wmhints->flags |= XUrgencyHint; + data->flashing_window = true; + // On Ubuntu 21.04 this causes a dialog to pop up, so leave it up for a full second so users can see it + data->flash_cancel_time = SDL_GetTicks() + 1000; + } + break; + case SDL_FLASH_UNTIL_FOCUSED: + if (!(window->flags & SDL_WINDOW_INPUT_FOCUS)) { + wmhints->flags |= XUrgencyHint; + data->flashing_window = true; + } + break; + default: + break; + } + + X11_XSetWMHints(display, data->xwindow, wmhints); + X11_XFree(wmhints); + return true; +} + +bool SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title) +{ + Atom _NET_WM_NAME = X11_XInternAtom(display, "_NET_WM_NAME", False); + XTextProperty titleprop; + int conv = X11_XmbTextListToTextProperty(display, &title, 1, XTextStyle, &titleprop); + Status status; + + if (X11_XSupportsLocale() != True) { + return SDL_SetError("Current locale not supported by X server, cannot continue."); + } + + if (conv == 0) { + X11_XSetTextProperty(display, xwindow, &titleprop, XA_WM_NAME); + X11_XFree(titleprop.value); + // we know this can't be a locale error as we checked X locale validity + } else if (conv < 0) { + return SDL_OutOfMemory(); + } else { // conv > 0 + SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "%d characters were not convertible to the current locale!", conv); + return true; + } + +#ifdef X_HAVE_UTF8_STRING + status = X11_Xutf8TextListToTextProperty(display, &title, 1, XUTF8StringStyle, &titleprop); + if (status == Success) { + X11_XSetTextProperty(display, xwindow, &titleprop, _NET_WM_NAME); + X11_XFree(titleprop.value); + } else { + return SDL_SetError("Failed to convert title to UTF8! Bad encoding, or bad Xorg encoding? Window title: «%s»", title); + } +#endif + + X11_XFlush(display); + return true; +} + +void X11_ShowWindowSystemMenu(SDL_Window *window, int x, int y) +{ + SDL_WindowData *data = window->internal; + SDL_DisplayData *displaydata = SDL_GetDisplayDriverDataForWindow(window); + Display *display = data->videodata->display; + Window root = RootWindow(display, displaydata->screen); + XClientMessageEvent e; + Window childReturn; + int wx, wy; + + SDL_zero(e); + X11_XTranslateCoordinates(display, data->xwindow, root, x, y, &wx, &wy, &childReturn); + + e.type = ClientMessage; + e.window = data->xwindow; + e.message_type = X11_XInternAtom(display, "_GTK_SHOW_WINDOW_MENU", 0); + e.data.l[0] = 0; // GTK device ID (unused) + e.data.l[1] = wx; // X coordinate relative to root + e.data.l[2] = wy; // Y coordinate relative to root + e.format = 32; + + X11_XSendEvent(display, root, False, SubstructureRedirectMask | SubstructureNotifyMask, (XEvent *)&e); + X11_XFlush(display); +} + +bool X11_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window) +{ + const Uint64 current_time = SDL_GetTicksNS(); + Uint64 timeout = 0; + + // Allow time for any pending mode switches to complete. + for (int i = 0; i < _this->num_displays; ++i) { + if (_this->displays[i]->internal->mode_switch_deadline_ns && + current_time < _this->displays[i]->internal->mode_switch_deadline_ns) { + timeout = SDL_max(_this->displays[i]->internal->mode_switch_deadline_ns - current_time, timeout); + } + } + + /* 100ms is fine for most cases, but, for some reason, maximizing + * a window can take a very long time. + */ + timeout += window->internal->pending_operation & X11_PENDING_OP_MAXIMIZE ? SDL_MS_TO_NS(1000) : SDL_MS_TO_NS(100); + + return X11_SyncWindowTimeout(_this, window, timeout); +} + +bool X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + XWMHints *wmhints; + + wmhints = X11_XGetWMHints(display, data->xwindow); + if (!wmhints) { + return SDL_SetError("Couldn't get WM hints"); + } + + wmhints->input = focusable ? True : False; + wmhints->flags |= InputHint; + + X11_XSetWMHints(display, data->xwindow, wmhints); + X11_XFree(wmhints); + + return true; +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11window.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11window.h new file mode 100644 index 0000000..f1a73ab --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11window.h @@ -0,0 +1,169 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11window_h_ +#define SDL_x11window_h_ + +/* We need to queue the focus in/out changes because they may occur during + video mode changes and we can respond to them by triggering more mode + changes. +*/ +#define PENDING_FOCUS_TIME 200 + +#ifdef SDL_VIDEO_OPENGL_EGL +#include +#endif + +typedef enum +{ + PENDING_FOCUS_NONE, + PENDING_FOCUS_IN, + PENDING_FOCUS_OUT +} PendingFocusEnum; + +struct SDL_WindowData +{ + SDL_Window *window; + Window xwindow; + Visual *visual; + Colormap colormap; +#ifndef NO_SHARED_MEMORY + // MIT shared memory extension information + bool use_mitshm; + XShmSegmentInfo shminfo; +#endif + XImage *ximage; + GC gc; + XIC ic; + bool created; + int border_left; + int border_right; + int border_top; + int border_bottom; + bool xinput2_mouse_enabled; + bool xinput2_keyboard_enabled; + bool mouse_grabbed; + Uint64 last_focus_event_time; + PendingFocusEnum pending_focus; + Uint64 pending_focus_time; + bool pending_move; + SDL_Point pending_move_point; + XConfigureEvent last_xconfigure; + struct SDL_VideoData *videodata; + unsigned long user_time; + Atom xdnd_req; + Window xdnd_source; + bool flashing_window; + Uint64 flash_cancel_time; + SDL_Window *keyboard_focus; +#ifdef SDL_VIDEO_OPENGL_EGL + EGLSurface egl_surface; +#endif +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + bool pointer_barrier_active; + PointerBarrier barrier[4]; + SDL_Rect barrier_rect; +#endif // SDL_VIDEO_DRIVER_X11_XFIXES +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + XSyncCounter resize_counter; + XSyncValue resize_id; + bool resize_in_progress; +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + + SDL_Rect expected; + SDL_DisplayMode requested_fullscreen_mode; + + enum + { + X11_PENDING_OP_NONE = 0x00, + X11_PENDING_OP_RESTORE = 0x01, + X11_PENDING_OP_MINIMIZE = 0x02, + X11_PENDING_OP_MAXIMIZE = 0x04, + X11_PENDING_OP_FULLSCREEN = 0x08, + X11_PENDING_OP_MOVE = 0x10, + X11_PENDING_OP_RESIZE = 0x20 + } pending_operation; + + enum + { + X11_SIZE_MOVE_EVENTS_DISABLE = 0x01, // Events are completely disabled. + X11_SIZE_MOVE_EVENTS_WAIT_FOR_BORDERS = 0x02, // Events are disabled until a _NET_FRAME_EXTENTS event arrives. + } size_move_event_flags; + + bool pending_size; + bool pending_position; + bool window_was_maximized; + bool previous_borders_nonzero; + bool toggle_borders; + bool fullscreen_borders_forced_on; + SDL_HitTestResult hit_test_result; + + XPoint xim_spot; + char *preedit_text; + XIMFeedback *preedit_feedback; + int preedit_length; + int preedit_cursor; + bool ime_needs_clear_composition; +}; + +extern void X11_SetNetWMState(SDL_VideoDevice *_this, Window xwindow, SDL_WindowFlags flags); +extern Uint32 X11_GetNetWMState(SDL_VideoDevice *_this, SDL_Window *window, Window xwindow); + +extern bool X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); +extern char *X11_GetWindowTitle(SDL_VideoDevice *_this, Window xwindow); +extern void X11_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *icon); +extern bool X11_SetWindowPosition(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_SetWindowMinimumSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_SetWindowMaximumSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_SetWindowAspectRatio(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_GetWindowBordersSize(SDL_VideoDevice *_this, SDL_Window *window, int *top, int *left, int *bottom, int *right); +extern bool X11_SetWindowOpacity(SDL_VideoDevice *_this, SDL_Window *window, float opacity); +extern bool X11_SetWindowParent(SDL_VideoDevice *_this, SDL_Window *window, SDL_Window *parent); +extern bool X11_SetWindowModal(SDL_VideoDevice *_this, SDL_Window *window, bool modal); +extern void X11_SetWindowSize(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_HideWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_RaiseWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_SetWindowBordered(SDL_VideoDevice *_this, SDL_Window *window, bool bordered); +extern void X11_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, bool resizable); +extern void X11_SetWindowAlwaysOnTop(SDL_VideoDevice *_this, SDL_Window *window, bool on_top); +extern SDL_FullscreenResult X11_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL_VideoDisplay *display, SDL_FullscreenOp fullscreen); +extern void *X11_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t *size); +extern bool X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern bool X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, bool grabbed); +extern void X11_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_SetWindowHitTest(SDL_Window *window, bool enabled); +extern void X11_AcceptDragAndDrop(SDL_Window *window, bool accept); +extern bool X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperation operation); +extern void X11_ShowWindowSystemMenu(SDL_Window *window, int x, int y); +extern bool X11_SyncWindow(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, bool focusable); + +extern bool SDL_X11_SetWindowTitle(Display *display, Window xwindow, char *title); +extern void X11_UpdateWindowPosition(SDL_Window *window, bool use_current_position); +extern void X11_SetWindowMinMax(SDL_Window *window, bool use_current); + +#endif // SDL_x11window_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.c new file mode 100644 index 0000000..517ebc8 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.c @@ -0,0 +1,214 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_X11) && defined(SDL_VIDEO_DRIVER_X11_XFIXES) + +#include "SDL_x11video.h" +#include "SDL_x11xfixes.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_touch_c.h" + +static bool xfixes_initialized = true; +static int xfixes_selection_notify_event = 0; + +static int query_xfixes_version(Display *display, int major, int minor) +{ + // We don't care if this fails, so long as it sets major/minor on it's way out the door. + X11_XFixesQueryVersion(display, &major, &minor); + return (major * 1000) + minor; +} + +static bool xfixes_version_atleast(const int version, const int wantmajor, const int wantminor) +{ + return version >= ((wantmajor * 1000) + wantminor); +} + +void X11_InitXfixes(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + int version = 0; + int event, error; + int fixes_opcode; + + Atom XA_CLIPBOARD = data->atoms.CLIPBOARD; + + if (!SDL_X11_HAVE_XFIXES || + !X11_XQueryExtension(data->display, "XFIXES", &fixes_opcode, &event, &error)) { + return; + } + + // Selection tracking is available in all versions of XFixes + xfixes_selection_notify_event = event + XFixesSelectionNotify; + X11_XFixesSelectSelectionInput(data->display, DefaultRootWindow(data->display), + XA_CLIPBOARD, XFixesSetSelectionOwnerNotifyMask); + X11_XFixesSelectSelectionInput(data->display, DefaultRootWindow(data->display), + XA_PRIMARY, XFixesSetSelectionOwnerNotifyMask); + + // We need at least 5.0 for barriers. + version = query_xfixes_version(data->display, 5, 0); + if (!xfixes_version_atleast(version, 5, 0)) { + return; // X server does not support the version we want at all. + } + + xfixes_initialized = 1; +} + +bool X11_XfixesIsInitialized(void) +{ + return xfixes_initialized; +} + +int X11_GetXFixesSelectionNotifyEvent(void) +{ + return xfixes_selection_notify_event; +} + +bool X11_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window) +{ + if (SDL_RectEmpty(&window->mouse_rect)) { + X11_ConfineCursorWithFlags(_this, window, NULL, 0); + } else { + if (window->flags & SDL_WINDOW_INPUT_FOCUS) { + X11_ConfineCursorWithFlags(_this, window, &window->mouse_rect, 0); + } else { + // Save the state for when we get focus again + SDL_WindowData *wdata = window->internal; + + SDL_memcpy(&wdata->barrier_rect, &window->mouse_rect, sizeof(wdata->barrier_rect)); + + wdata->pointer_barrier_active = true; + } + } + + return true; +} + +bool X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rect, int flags) +{ + /* Yaakuro: For some reason Xfixes when confining inside a rect where the + * edges exactly match, a rectangle the cursor 'slips' out of the barrier. + * To prevent that the lines for the barriers will span the whole screen. + */ + SDL_VideoData *data = _this->internal; + SDL_WindowData *wdata; + + if (!X11_XfixesIsInitialized()) { + return SDL_Unsupported(); + } + + // If there is already a set of barriers active, disable them. + if (data->active_cursor_confined_window) { + X11_DestroyPointerBarrier(_this, data->active_cursor_confined_window); + } + + SDL_assert(window != NULL); + wdata = window->internal; + + /* If user did not specify an area to confine, destroy the barrier that was/is assigned to + * this window it was assigned */ + if (rect) { + int x1, y1, x2, y2; + SDL_Rect bounds; + SDL_GetWindowPosition(window, &bounds.x, &bounds.y); + SDL_GetWindowSize(window, &bounds.w, &bounds.h); + + /** Negative values are not allowed. Clip values relative to the specified window. */ + x1 = bounds.x + SDL_max(rect->x, 0); + y1 = bounds.y + SDL_max(rect->y, 0); + x2 = SDL_min(bounds.x + rect->x + rect->w, bounds.x + bounds.w); + y2 = SDL_min(bounds.y + rect->y + rect->h, bounds.y + bounds.h); + + if ((wdata->barrier_rect.x != rect->x) || + (wdata->barrier_rect.y != rect->y) || + (wdata->barrier_rect.w != rect->w) || + (wdata->barrier_rect.h != rect->h)) { + wdata->barrier_rect = *rect; + } + + // Use the display bounds to ensure the barriers don't have corner gaps + SDL_GetDisplayBounds(SDL_GetDisplayForWindow(window), &bounds); + + /** Create the left barrier */ + wdata->barrier[0] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, + x1, bounds.y, + x1, bounds.y + bounds.h, + BarrierPositiveX, + 0, NULL); + /** Create the right barrier */ + wdata->barrier[1] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, + x2, bounds.y, + x2, bounds.y + bounds.h, + BarrierNegativeX, + 0, NULL); + /** Create the top barrier */ + wdata->barrier[2] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, + bounds.x, y1, + bounds.x + bounds.w, y1, + BarrierPositiveY, + 0, NULL); + /** Create the bottom barrier */ + wdata->barrier[3] = X11_XFixesCreatePointerBarrier(data->display, wdata->xwindow, + bounds.x, y2, + bounds.x + bounds.w, y2, + BarrierNegativeY, + 0, NULL); + + X11_XFlush(data->display); + + // Lets remember current active confined window. + data->active_cursor_confined_window = window; + + /* User activated the confinement for this window. We use this later to reactivate + * the confinement if it got deactivated by FocusOut or UnmapNotify */ + wdata->pointer_barrier_active = true; + } else { + X11_DestroyPointerBarrier(_this, window); + + // Only set barrier inactive when user specified NULL and not handled by focus out. + if (flags != X11_BARRIER_HANDLED_BY_EVENT) { + wdata->pointer_barrier_active = false; + } + } + return true; +} + +void X11_DestroyPointerBarrier(SDL_VideoDevice *_this, SDL_Window *window) +{ + int i; + SDL_VideoData *data = _this->internal; + if (window) { + SDL_WindowData *wdata = window->internal; + + for (i = 0; i < 4; i++) { + if (wdata->barrier[i] > 0) { + X11_XFixesDestroyPointerBarrier(data->display, wdata->barrier[i]); + wdata->barrier[i] = 0; + } + } + X11_XFlush(data->display); + } + data->active_cursor_confined_window = NULL; +} + +#endif // SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_DRIVER_X11_XFIXES diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.h new file mode 100644 index 0000000..bd8e437 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xfixes.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_x11xfixes_h_ +#define SDL_x11xfixes_h_ + +#ifdef SDL_VIDEO_DRIVER_X11_XFIXES + +#define X11_BARRIER_HANDLED_BY_EVENT 1 + +extern void X11_InitXfixes(SDL_VideoDevice *_this); +extern bool X11_XfixesIsInitialized(void); +extern bool X11_SetWindowMouseRect(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rect, int flags); +extern void X11_DestroyPointerBarrier(SDL_VideoDevice *_this, SDL_Window *window); +extern int X11_GetXFixesSelectionNotifyEvent(void); +#endif // SDL_VIDEO_DRIVER_X11_XFIXES + +#endif // SDL_x11xfixes_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.c new file mode 100644 index 0000000..afe4a7c --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.c @@ -0,0 +1,829 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11pen.h" +#include "SDL_x11video.h" +#include "SDL_x11xinput2.h" +#include "../../events/SDL_events_c.h" +#include "../../events/SDL_mouse_c.h" +#include "../../events/SDL_pen_c.h" +#include "../../events/SDL_touch_c.h" + +#define MAX_AXIS 16 + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 +static bool xinput2_initialized; + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +static bool xinput2_multitouch_supported; +#endif + +/* Opcode returned X11_XQueryExtension + * It will be used in event processing + * to know that the event came from + * this extension */ +static int xinput2_opcode; + +static void parse_valuators(const double *input_values, const unsigned char *mask, int mask_len, + double *output_values, int output_values_len) +{ + int i = 0, z = 0; + int top = mask_len * 8; + if (top > MAX_AXIS) { + top = MAX_AXIS; + } + + SDL_memset(output_values, 0, output_values_len * sizeof(double)); + for (; i < top && z < output_values_len; i++) { + if (XIMaskIsSet(mask, i)) { + const int value = (int)*input_values; + output_values[z] = value; + input_values++; + } + z++; + } +} + +static int query_xinput2_version(Display *display, int major, int minor) +{ + // We don't care if this fails, so long as it sets major/minor on it's way out the door. + X11_XIQueryVersion(display, &major, &minor); + return (major * 1000) + minor; +} + +static bool xinput2_version_atleast(const int version, const int wantmajor, const int wantminor) +{ + return version >= ((wantmajor * 1000) + wantminor); +} + +static SDL_WindowData *xinput2_get_sdlwindowdata(SDL_VideoData *videodata, Window window) +{ + int i; + for (i = 0; i < videodata->numwindows; i++) { + SDL_WindowData *d = videodata->windowlist[i]; + if (d->xwindow == window) { + return d; + } + } + return NULL; +} + +static SDL_Window *xinput2_get_sdlwindow(SDL_VideoData *videodata, Window window) +{ + const SDL_WindowData *windowdata = xinput2_get_sdlwindowdata(videodata, window); + return windowdata ? windowdata->window : NULL; +} + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH +static void xinput2_normalize_touch_coordinates(SDL_Window *window, double in_x, double in_y, float *out_x, float *out_y) +{ + if (window) { + if (window->w == 1) { + *out_x = 0.5f; + } else { + *out_x = (float)in_x / (window->w - 1); + } + if (window->h == 1) { + *out_y = 0.5f; + } else { + *out_y = (float)in_y / (window->h - 1); + } + } else { + // couldn't find the window... + *out_x = (float)in_x; + *out_y = (float)in_y; + } +} +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 + +bool X11_InitXinput2(SDL_VideoDevice *_this) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + SDL_VideoData *data = _this->internal; + + int version = 0; + XIEventMask eventmask; + unsigned char mask[4] = { 0, 0, 0, 0 }; + int event, err; + + /* XInput2 is required for relative mouse mode, so you probably want to leave this enabled */ + if (!SDL_GetHintBoolean("SDL_VIDEO_X11_XINPUT2", true)) { + return false; + } + + /* + * Initialize XInput 2 + * According to http://who-t.blogspot.com/2009/05/xi2-recipes-part-1.html its better + * to inform Xserver what version of Xinput we support.The server will store the version we support. + * "As XI2 progresses it becomes important that you use this call as the server may treat the client + * differently depending on the supported version". + * + * FIXME:event and err are not needed but if not passed X11_XQueryExtension returns SegmentationFault + */ + if (!SDL_X11_HAVE_XINPUT2 || + !X11_XQueryExtension(data->display, "XInputExtension", &xinput2_opcode, &event, &err)) { + return false; // X server does not have XInput at all + } + + // We need at least 2.2 for Multitouch, 2.0 otherwise. + version = query_xinput2_version(data->display, 2, 2); + if (!xinput2_version_atleast(version, 2, 0)) { + return false; // X server does not support the version we want at all. + } + + xinput2_initialized = true; + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH // Multitouch needs XInput 2.2 + xinput2_multitouch_supported = xinput2_version_atleast(version, 2, 2); +#endif + + // Enable raw motion events for this display + SDL_zero(eventmask); + SDL_zeroa(mask); + eventmask.deviceid = XIAllMasterDevices; + eventmask.mask_len = sizeof(mask); + eventmask.mask = mask; + + XISetMask(mask, XI_RawMotion); + XISetMask(mask, XI_RawButtonPress); + XISetMask(mask, XI_RawButtonRelease); + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + // Enable raw touch events if supported + if (X11_Xinput2IsMultitouchSupported()) { + XISetMask(mask, XI_RawTouchBegin); + XISetMask(mask, XI_RawTouchUpdate); + XISetMask(mask, XI_RawTouchEnd); + } +#endif + + X11_XISelectEvents(data->display, DefaultRootWindow(data->display), &eventmask, 1); + + SDL_zero(eventmask); + SDL_zeroa(mask); + eventmask.deviceid = XIAllDevices; + eventmask.mask_len = sizeof(mask); + eventmask.mask = mask; + + XISetMask(mask, XI_HierarchyChanged); + X11_XISelectEvents(data->display, DefaultRootWindow(data->display), &eventmask, 1); + + X11_Xinput2UpdateDevices(_this, true); + + return true; +#else + return false; +#endif +} + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 +// xi2 device went away? take it out of the list. +static void xinput2_remove_device_info(SDL_VideoData *videodata, const int device_id) +{ + SDL_XInput2DeviceInfo *prev = NULL; + SDL_XInput2DeviceInfo *devinfo; + + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { + if (devinfo->device_id == device_id) { + SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); + if (!prev) { + videodata->mouse_device_info = devinfo->next; + } else { + prev->next = devinfo->next; + } + SDL_free(devinfo); + return; + } + prev = devinfo; + } +} + +static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, const int device_id) +{ + // cache device info as we see new devices. + SDL_XInput2DeviceInfo *prev = NULL; + SDL_XInput2DeviceInfo *devinfo; + XIDeviceInfo *xidevinfo; + int axis = 0; + int i; + + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { + if (devinfo->device_id == device_id) { + SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); + if (prev) { // move this to the front of the list, assuming we'll get more from this one. + prev->next = devinfo->next; + devinfo->next = videodata->mouse_device_info; + videodata->mouse_device_info = devinfo; + } + return devinfo; + } + prev = devinfo; + } + + // don't know about this device yet, query and cache it. + devinfo = (SDL_XInput2DeviceInfo *)SDL_calloc(1, sizeof(SDL_XInput2DeviceInfo)); + if (!devinfo) { + return NULL; + } + + xidevinfo = X11_XIQueryDevice(videodata->display, device_id, &i); + if (!xidevinfo) { + SDL_free(devinfo); + return NULL; + } + + devinfo->device_id = device_id; + + /* !!! FIXME: this is sort of hacky because we only care about the first two axes we see, but any given + !!! FIXME: axis could be relative or absolute, and they might not even be the X and Y axes! + !!! FIXME: But we go on, for now. Maybe we need a more robust mouse API in SDL3... */ + for (i = 0; i < xidevinfo->num_classes; i++) { + const XIValuatorClassInfo *v = (const XIValuatorClassInfo *)xidevinfo->classes[i]; + if (v->type == XIValuatorClass) { + devinfo->relative[axis] = (v->mode == XIModeRelative); + devinfo->minval[axis] = v->min; + devinfo->maxval[axis] = v->max; + if (++axis >= 2) { + break; + } + } + } + + X11_XIFreeDeviceInfo(xidevinfo); + + devinfo->next = videodata->mouse_device_info; + videodata->mouse_device_info = devinfo; + + return devinfo; +} +#endif + +void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + SDL_VideoData *videodata = _this->internal; + + if (cookie->extension != xinput2_opcode) { + return; + } + + switch (cookie->evtype) { + case XI_HierarchyChanged: + { + const XIHierarchyEvent *hierev = (const XIHierarchyEvent *)cookie->data; + int i; + for (i = 0; i < hierev->num_info; i++) { + // pen stuff... + if ((hierev->info[i].flags & (XISlaveRemoved | XIDeviceDisabled)) != 0) { + X11_RemovePenByDeviceID(hierev->info[i].deviceid); // it's okay if this thing isn't actually a pen, it'll handle it. + } else if ((hierev->info[i].flags & (XISlaveAdded | XIDeviceEnabled)) != 0) { + X11_MaybeAddPenByDeviceID(_this, hierev->info[i].deviceid); // this will do more checks to make sure this is valid. + } + + // not pen stuff... + if (hierev->info[i].flags & XISlaveRemoved) { + xinput2_remove_device_info(videodata, hierev->info[i].deviceid); + } + } + videodata->xinput_hierarchy_changed = true; + } break; + + // !!! FIXME: the pen code used to rescan all devices here, but we can do this device-by-device with XI_HierarchyChanged. When do these events fire and why? + //case XI_PropertyEvent: + //case XI_DeviceChanged: + + case XI_RawMotion: + { + const XIRawEvent *rawev = (const XIRawEvent *)cookie->data; + const bool is_pen = X11_FindPenByDeviceID(rawev->sourceid) != NULL; + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_XInput2DeviceInfo *devinfo; + double coords[2]; + double processed_coords[2]; + int i; + Uint64 timestamp = X11_GetEventTimestamp(rawev->time); + + videodata->global_mouse_changed = true; + if (is_pen) { + break; // Pens check for XI_Motion instead + } + + devinfo = xinput2_get_device_info(videodata, rawev->deviceid); + if (!devinfo) { + break; // oh well. + } + + parse_valuators(rawev->raw_values, rawev->valuators.mask, + rawev->valuators.mask_len, coords, 2); + + for (i = 0; i < 2; i++) { + if (devinfo->relative[i]) { + processed_coords[i] = coords[i]; + } else { + processed_coords[i] = devinfo->prev_coords[i] - coords[i]; // convert absolute to relative + } + } + + // Relative mouse motion is delivered to the window with keyboard focus + if (mouse->relative_mode && SDL_GetKeyboardFocus()) { + SDL_SendMouseMotion(timestamp, mouse->focus, (SDL_MouseID)rawev->sourceid, true, (float)processed_coords[0], (float)processed_coords[1]); + } + + devinfo->prev_coords[0] = coords[0]; + devinfo->prev_coords[1] = coords[1]; + } break; + + case XI_KeyPress: + case XI_KeyRelease: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + SDL_WindowData *windowdata = X11_FindWindow(_this, xev->event); + XEvent xevent; + + if (xev->deviceid != xev->sourceid) { + // Discard events from "Master" devices to avoid duplicates. + break; + } + + if (cookie->evtype == XI_KeyPress) { + xevent.type = KeyPress; + } else { + xevent.type = KeyRelease; + } + xevent.xkey.serial = xev->serial; + xevent.xkey.send_event = xev->send_event; + xevent.xkey.display = xev->display; + xevent.xkey.window = xev->event; + xevent.xkey.root = xev->root; + xevent.xkey.subwindow = xev->child; + xevent.xkey.time = xev->time; + xevent.xkey.x = (int)xev->event_x; + xevent.xkey.y = (int)xev->event_y; + xevent.xkey.x_root = (int)xev->root_x; + xevent.xkey.y_root = (int)xev->root_y; + xevent.xkey.state = xev->mods.effective; + xevent.xkey.keycode = xev->detail; + xevent.xkey.same_screen = 1; + + X11_HandleKeyEvent(_this, windowdata, (SDL_KeyboardID)xev->sourceid, &xevent); + } break; + + case XI_RawButtonPress: + case XI_RawButtonRelease: +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + case XI_RawTouchBegin: + case XI_RawTouchUpdate: + case XI_RawTouchEnd: +#endif + { + videodata->global_mouse_changed = true; + } break; + + case XI_ButtonPress: + case XI_ButtonRelease: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + X11_PenHandle *pen = X11_FindPenByDeviceID(xev->deviceid); + const int button = xev->detail; + const bool down = (cookie->evtype == XI_ButtonPress); + + if (pen) { + // Only report button event; if there was also pen movement / pressure changes, we expect an XI_Motion event first anyway. + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + if (button == 1) { // button 1 is the pen tip + SDL_SendPenTouch(0, pen->pen, window, pen->is_eraser, down); + } else { + SDL_SendPenButton(0, pen->pen, window, button - 1, down); + } + } else { + // Otherwise assume a regular mouse + SDL_WindowData *windowdata = xinput2_get_sdlwindowdata(videodata, xev->event); + + if (xev->deviceid != xev->sourceid) { + // Discard events from "Master" devices to avoid duplicates. + break; + } + + if (down) { + X11_HandleButtonPress(_this, windowdata, (SDL_MouseID)xev->sourceid, button, + (float)xev->event_x, (float)xev->event_y, xev->time); + } else { + X11_HandleButtonRelease(_this, windowdata, (SDL_MouseID)xev->sourceid, button, xev->time); + } + } + } break; + + /* Register to receive XI_Motion (which deactivates MotionNotify), so that we can distinguish + real mouse motions from synthetic ones, for multitouch and pen support. */ + case XI_Motion: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + bool pointer_emulated = ((xev->flags & XIPointerEmulated) != 0); +#else + bool pointer_emulated = false; +#endif + + videodata->global_mouse_changed = true; + + X11_PenHandle *pen = X11_FindPenByDeviceID(xev->deviceid); + if (pen) { + if (xev->deviceid != xev->sourceid) { + // Discard events from "Master" devices to avoid duplicates. + break; + } + + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + SDL_SendPenMotion(0, pen->pen, window, (float) xev->event_x, (float) xev->event_y); + + float axes[SDL_PEN_AXIS_COUNT]; + X11_PenAxesFromValuators(pen, xev->valuators.values, xev->valuators.mask, xev->valuators.mask_len, axes); + + for (int i = 0; i < SDL_arraysize(axes); i++) { + if (pen->valuator_for_axis[i] != SDL_X11_PEN_AXIS_VALUATOR_MISSING) { + SDL_SendPenAxis(0, pen->pen, window, (SDL_PenAxis) i, axes[i]); + } + } + } else if (!pointer_emulated && xev->deviceid == videodata->xinput_master_pointer_device) { + // Use the master device for non-relative motion, as the slave devices can seemingly lag behind. + SDL_Mouse *mouse = SDL_GetMouse(); + if (!mouse->relative_mode) { + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + if (window) { + X11_ProcessHitTest(_this, window->internal, (float)xev->event_x, (float)xev->event_y, false); + SDL_SendMouseMotion(0, window, SDL_GLOBAL_MOUSE_ID, false, (float)xev->event_x, (float)xev->event_y); + } + } + } + } break; + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + case XI_TouchBegin: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + float x, y; + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); + SDL_SendTouch(0, xev->sourceid, xev->detail, window, SDL_EVENT_FINGER_DOWN, x, y, 1.0); + } break; + + case XI_TouchEnd: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + float x, y; + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); + SDL_SendTouch(0, xev->sourceid, xev->detail, window, SDL_EVENT_FINGER_UP, x, y, 1.0); + } break; + + case XI_TouchUpdate: + { + const XIDeviceEvent *xev = (const XIDeviceEvent *)cookie->data; + float x, y; + SDL_Window *window = xinput2_get_sdlwindow(videodata, xev->event); + xinput2_normalize_touch_coordinates(window, xev->event_x, xev->event_y, &x, &y); + SDL_SendTouchMotion(0, xev->sourceid, xev->detail, window, x, y, 1.0); + } break; +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + } +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 +} + +void X11_InitXinput2Multitouch(SDL_VideoDevice *_this) +{ +} + +void X11_Xinput2SelectTouch(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + SDL_VideoData *data = NULL; + XIEventMask eventmask; + unsigned char mask[4] = { 0, 0, 0, 0 }; + SDL_WindowData *window_data = NULL; + + if (!X11_Xinput2IsMultitouchSupported()) { + return; + } + + data = _this->internal; + window_data = window->internal; + + eventmask.deviceid = XIAllMasterDevices; + eventmask.mask_len = sizeof(mask); + eventmask.mask = mask; + + XISetMask(mask, XI_TouchBegin); + XISetMask(mask, XI_TouchUpdate); + XISetMask(mask, XI_TouchEnd); + XISetMask(mask, XI_Motion); + + X11_XISelectEvents(data->display, window_data->xwindow, &eventmask, 1); +#endif +} + +bool X11_Xinput2IsInitialized(void) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + return xinput2_initialized; +#else + return false; +#endif +} + +bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *window) +{ + SDL_WindowData *windowdata = window->internal; + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + const SDL_VideoData *data = _this->internal; + + if (X11_Xinput2IsInitialized()) { + XIEventMask eventmask; + unsigned char mask[4] = { 0, 0, 0, 0 }; + + eventmask.mask_len = sizeof(mask); + eventmask.mask = mask; + eventmask.deviceid = XIAllDevices; + +// This is not enabled by default because these events are only delivered to the window with mouse focus, not keyboard focus +#ifdef USE_XINPUT2_KEYBOARD + XISetMask(mask, XI_KeyPress); + XISetMask(mask, XI_KeyRelease); + windowdata->xinput2_keyboard_enabled = true; +#endif + + XISetMask(mask, XI_ButtonPress); + XISetMask(mask, XI_ButtonRelease); + XISetMask(mask, XI_Motion); + windowdata->xinput2_mouse_enabled = true; + + XISetMask(mask, XI_Enter); + XISetMask(mask, XI_Leave); + + // Hotplugging: + XISetMask(mask, XI_DeviceChanged); + XISetMask(mask, XI_HierarchyChanged); + XISetMask(mask, XI_PropertyEvent); // E.g., when swapping tablet pens + + if (X11_XISelectEvents(data->display, windowdata->xwindow, &eventmask, 1) != Success) { + SDL_LogWarn(SDL_LOG_CATEGORY_INPUT, "Could not enable XInput2 event handling"); + windowdata->xinput2_keyboard_enabled = false; + windowdata->xinput2_mouse_enabled = false; + } + } +#endif + + if (windowdata->xinput2_keyboard_enabled || windowdata->xinput2_mouse_enabled) { + return true; + } + return false; +} + +bool X11_Xinput2IsMultitouchSupported(void) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + return xinput2_initialized && xinput2_multitouch_supported; +#else + return true; +#endif +} + +void X11_Xinput2GrabTouch(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + + unsigned char mask[4] = { 0, 0, 0, 0 }; + XIGrabModifiers mods; + XIEventMask eventmask; + + if (!X11_Xinput2IsMultitouchSupported()) { + return; + } + + mods.modifiers = XIAnyModifier; + mods.status = 0; + + eventmask.deviceid = XIAllDevices; + eventmask.mask_len = sizeof(mask); + eventmask.mask = mask; + + XISetMask(eventmask.mask, XI_TouchBegin); + XISetMask(eventmask.mask, XI_TouchUpdate); + XISetMask(eventmask.mask, XI_TouchEnd); + XISetMask(eventmask.mask, XI_Motion); + + X11_XIGrabTouchBegin(display, XIAllDevices, data->xwindow, True, &eventmask, 1, &mods); +#endif +} + +void X11_Xinput2UngrabTouch(SDL_VideoDevice *_this, SDL_Window *window) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + + XIGrabModifiers mods; + + if (!X11_Xinput2IsMultitouchSupported()) { + return; + } + + mods.modifiers = XIAnyModifier; + mods.status = 0; + + X11_XIUngrabTouchBegin(display, XIAllDevices, data->xwindow, 1, &mods); +#endif +} + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + +static void AddDeviceID(Uint32 deviceID, Uint32 **list, int *count) +{ + int new_count = (*count + 1); + Uint32 *new_list = (Uint32 *)SDL_realloc(*list, new_count * sizeof(*new_list)); + if (!new_list) { + // Oh well, we'll drop this one + return; + } + new_list[new_count - 1] = deviceID; + + *count = new_count; + *list = new_list; +} + +static bool HasDeviceID(Uint32 deviceID, const Uint32 *list, int count) +{ + for (int i = 0; i < count; ++i) { + if (deviceID == list[i]) { + return true; + } + } + return false; +} + +static void AddDeviceID64(Uint64 deviceID, Uint64 **list, int *count) +{ + int new_count = (*count + 1); + Uint64 *new_list = (Uint64 *)SDL_realloc(*list, new_count * sizeof(*new_list)); + if (!new_list) { + // Oh well, we'll drop this one + return; + } + new_list[new_count - 1] = deviceID; + + *count = new_count; + *list = new_list; +} + +static bool HasDeviceID64(Uint64 deviceID, const Uint64 *list, int count) +{ + for (int i = 0; i < count; ++i) { + if (deviceID == list[i]) { + return true; + } + } + return false; +} + +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 + +void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, bool initial_check) +{ +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2 + SDL_VideoData *data = _this->internal; + XIDeviceInfo *info; + int ndevices; + int old_keyboard_count = 0; + SDL_KeyboardID *old_keyboards = NULL; + int new_keyboard_count = 0; + SDL_KeyboardID *new_keyboards = NULL; + int old_mouse_count = 0; + SDL_MouseID *old_mice = NULL; + int new_mouse_count = 0; + SDL_MouseID *new_mice = NULL; + int old_touch_count = 0; + Uint64 *old_touch_devices = NULL; + int new_touch_count = 0; + Uint64 *new_touch_devices = NULL; + bool send_event = !initial_check; + + SDL_assert(X11_Xinput2IsInitialized()); + + info = X11_XIQueryDevice(data->display, XIAllDevices, &ndevices); + + old_keyboards = SDL_GetKeyboards(&old_keyboard_count); + old_mice = SDL_GetMice(&old_mouse_count); + old_touch_devices = SDL_GetTouchDevices(&old_touch_count); + + for (int i = 0; i < ndevices; i++) { + XIDeviceInfo *dev = &info[i]; + + switch (dev->use) { + case XIMasterKeyboard: + case XISlaveKeyboard: + { + SDL_KeyboardID keyboardID = (SDL_KeyboardID)dev->deviceid; + AddDeviceID(keyboardID, &new_keyboards, &new_keyboard_count); + if (!HasDeviceID(keyboardID, old_keyboards, old_keyboard_count)) { + SDL_AddKeyboard(keyboardID, dev->name, send_event); + } + } + break; + case XIMasterPointer: + data->xinput_master_pointer_device = dev->deviceid; + SDL_FALLTHROUGH; + case XISlavePointer: + { + SDL_MouseID mouseID = (SDL_MouseID)dev->deviceid; + AddDeviceID(mouseID, &new_mice, &new_mouse_count); + if (!HasDeviceID(mouseID, old_mice, old_mouse_count)) { + SDL_AddMouse(mouseID, dev->name, send_event); + } + } + break; + default: + break; + } + +#ifdef SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + for (int j = 0; j < dev->num_classes; j++) { + Uint64 touchID; + SDL_TouchDeviceType touchType; + XIAnyClassInfo *class = dev->classes[j]; + XITouchClassInfo *t = (XITouchClassInfo *)class; + + // Only touch devices + if (class->type != XITouchClass) { + continue; + } + + touchID = (Uint64)t->sourceid; + AddDeviceID64(touchID, &new_touch_devices, &new_touch_count); + if (!HasDeviceID64(touchID, old_touch_devices, old_touch_count)) { + if (t->mode == XIDependentTouch) { + touchType = SDL_TOUCH_DEVICE_INDIRECT_RELATIVE; + } else { // XIDirectTouch + touchType = SDL_TOUCH_DEVICE_DIRECT; + } + SDL_AddTouch(touchID, touchType, dev->name); + } + } +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2_SUPPORTS_MULTITOUCH + } + + for (int i = old_keyboard_count; i--;) { + if (!HasDeviceID(old_keyboards[i], new_keyboards, new_keyboard_count)) { + SDL_RemoveKeyboard(old_keyboards[i], send_event); + } + } + + for (int i = old_mouse_count; i--;) { + if (!HasDeviceID(old_mice[i], new_mice, new_mouse_count)) { + SDL_RemoveMouse(old_mice[i], send_event); + } + } + + for (int i = old_touch_count; i--;) { + if (!HasDeviceID64(old_touch_devices[i], new_touch_devices, new_touch_count)) { + SDL_DelTouch(old_touch_devices[i]); + } + } + + SDL_free(old_keyboards); + SDL_free(new_keyboards); + SDL_free(old_mice); + SDL_free(new_mice); + SDL_free(old_touch_devices); + SDL_free(new_touch_devices); + + X11_XIFreeDeviceInfo(info); + +#endif // SDL_VIDEO_DRIVER_X11_XINPUT2 +} + +#endif // SDL_VIDEO_DRIVER_X11 diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.h new file mode 100644 index 0000000..c96c020 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xinput2.h @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_internal.h" + +#ifndef SDL_x11xinput2_h_ +#define SDL_x11xinput2_h_ + +#ifndef SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS +/* Define XGenericEventCookie as forward declaration when + *xinput2 is not available in order to compile */ +struct XGenericEventCookie; +typedef struct XGenericEventCookie XGenericEventCookie; +#endif + +extern bool X11_InitXinput2(SDL_VideoDevice *_this); +extern void X11_InitXinput2Multitouch(SDL_VideoDevice *_this); +extern void X11_HandleXinput2Event(SDL_VideoDevice *_this, XGenericEventCookie *cookie); +extern bool X11_Xinput2IsInitialized(void); +extern bool X11_Xinput2IsMultitouchSupported(void); +extern void X11_Xinput2SelectTouch(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_Xinput2GrabTouch(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_Xinput2UngrabTouch(SDL_VideoDevice *_this, SDL_Window *window); +extern bool X11_Xinput2SelectMouseAndKeyboard(SDL_VideoDevice *_this, SDL_Window *window); +extern void X11_Xinput2UpdateDevices(SDL_VideoDevice *_this, bool initial_check); + +#endif // SDL_x11xinput2_h_ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.c b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.c new file mode 100644 index 0000000..5310d67 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.c @@ -0,0 +1,148 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#if defined(SDL_VIDEO_DRIVER_X11) && defined(SDL_VIDEO_DRIVER_X11_XSYNC) + +#include "SDL_x11video.h" +#include "SDL_x11xsync.h" + +static int xsync_initialized = 0; + +static int query_xsync_version(Display *display, int major, int minor) +{ + /* We don't care if this fails, so long as it sets major/minor on it's way out the door. */ + X11_XSyncInitialize(display, &major, &minor); + return (major * 1000) + minor; +} + +static bool xsync_version_atleast(const int version, const int wantmajor, const int wantminor) +{ + return version >= ((wantmajor * 1000) + wantminor); +} + +void X11_InitXsync(SDL_VideoDevice *_this) +{ + SDL_VideoData *data = _this->internal; + + int version = 0; + int event, error; + int sync_opcode; + + if (!SDL_X11_HAVE_XSYNC || + !X11_XQueryExtension(data->display, "SYNC", &sync_opcode, &event, &error)) { + return; + } + + /* We need at least 5.0 for barriers. */ + version = query_xsync_version(data->display, 5, 0); + if (!xsync_version_atleast(version, 3, 0)) { + return; /* X server does not support the version we want at all. */ + } + + xsync_initialized = 1; +} + +int X11_XsyncIsInitialized(void) +{ + return xsync_initialized; +} + +int X11_InitResizeSync(SDL_Window *window) +{ + SDL_assert(window != NULL); + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + Atom counter_prop = data->videodata->atoms._NET_WM_SYNC_REQUEST_COUNTER; + XSyncCounter counter; + CARD32 counter_id; + + if (!X11_XsyncIsInitialized()){ + return SDL_Unsupported(); + } + + counter = X11_XSyncCreateCounter(display, (XSyncValue){0, 0}); + data->resize_counter = counter; + data->resize_id.lo = 0; + data->resize_id.hi = 0; + data->resize_in_progress = false; + + if (counter == None){ + return SDL_Unsupported(); + } + + counter_id = counter; + X11_XChangeProperty(display, data->xwindow, counter_prop, XA_CARDINAL, 32, + PropModeReplace, (unsigned char *)&counter_id, 1); + + return 0; +} + +void X11_TermResizeSync(SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + Atom counter_prop = data->videodata->atoms._NET_WM_SYNC_REQUEST_COUNTER; + XSyncCounter counter = data->resize_counter; + + X11_XDeleteProperty(display, data->xwindow, counter_prop); + if (counter != None) { + X11_XSyncDestroyCounter(display, counter); + } +} + +void X11_HandleSyncRequest(SDL_Window *window, XClientMessageEvent *event) +{ + SDL_WindowData *data = window->internal; + + data->resize_id.lo = event->data.l[2]; + data->resize_id.hi = event->data.l[3]; + data->resize_in_progress = false; +} + +void X11_HandleConfigure(SDL_Window *window, XConfigureEvent *event) +{ + SDL_WindowData *data = window->internal; + + if (data->resize_id.lo || data->resize_id.hi) { + data->resize_in_progress = true; + } +} + +void X11_HandlePresent(SDL_Window *window) +{ + SDL_WindowData *data = window->internal; + Display *display = data->videodata->display; + XSyncCounter counter = data->resize_counter; + + if ((counter == None) || (!data->resize_in_progress)) { + return; + } + + X11_XSyncSetCounter(display, counter, data->resize_id); + + data->resize_id.lo = 0; + data->resize_id.hi = 0; + data->resize_in_progress = false; +} + +#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_DRIVER_X11_XSYNC */ diff --git a/contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.h b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.h new file mode 100644 index 0000000..bc747c1 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/SDL_x11xsync.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2025 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_internal.h" + +#ifndef SDL_x11xsync_h_ +#define SDL_x11xsync_h_ + +#ifdef SDL_VIDEO_DRIVER_X11_XSYNC + +extern void X11_InitXsync(SDL_VideoDevice *_this); +extern int X11_XsyncIsInitialized(void); +int X11_InitResizeSync(SDL_Window *window); +void X11_TermResizeSync(SDL_Window *window); +void X11_HandleSyncRequest(SDL_Window *window, XClientMessageEvent *event); +void X11_HandleConfigure(SDL_Window *window, XConfigureEvent *event); +void X11_HandlePresent(SDL_Window *window); + +#endif /* SDL_VIDEO_DRIVER_X11_XSYNC */ + +#endif /* SDL_x11xsync_h_ */ diff --git a/contrib/SDL-3.2.8/src/video/x11/edid-parse.c b/contrib/SDL-3.2.8/src/video/x11/edid-parse.c new file mode 100644 index 0000000..eca187b --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/edid-parse.c @@ -0,0 +1,753 @@ +/* + * Copyright 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* Author: Soren Sandmann */ +#include "SDL_internal.h" + +#include "edid.h" +#include +#include +#include +#include + +#define TRUE 1 +#define FALSE 0 + +static int +get_bit (int in, int bit) +{ + return (in & (1 << bit)) >> bit; +} + +static int +get_bits (int in, int begin, int end) +{ + int mask = (1 << (end - begin + 1)) - 1; + + return (in >> begin) & mask; +} + +static int +decode_header (const uchar *edid) +{ + if (SDL_memcmp (edid, "\x00\xff\xff\xff\xff\xff\xff\x00", 8) == 0) + return TRUE; + return FALSE; +} + +static int +decode_vendor_and_product_identification (const uchar *edid, MonitorInfo *info) +{ + int is_model_year; + + /* Manufacturer Code */ + info->manufacturer_code[0] = get_bits (edid[0x08], 2, 6); + info->manufacturer_code[1] = get_bits (edid[0x08], 0, 1) << 3; + info->manufacturer_code[1] |= get_bits (edid[0x09], 5, 7); + info->manufacturer_code[2] = get_bits (edid[0x09], 0, 4); + info->manufacturer_code[3] = '\0'; + + info->manufacturer_code[0] += 'A' - 1; + info->manufacturer_code[1] += 'A' - 1; + info->manufacturer_code[2] += 'A' - 1; + + /* Product Code */ + info->product_code = edid[0x0b] << 8 | edid[0x0a]; + + /* Serial Number */ + info->serial_number = + edid[0x0c] | edid[0x0d] << 8 | edid[0x0e] << 16 | (Uint32)edid[0x0f] << 24; + + /* Week and Year */ + is_model_year = FALSE; + switch (edid[0x10]) + { + case 0x00: + info->production_week = -1; + break; + + case 0xff: + info->production_week = -1; + is_model_year = TRUE; + break; + + default: + info->production_week = edid[0x10]; + break; + } + + if (is_model_year) + { + info->production_year = -1; + info->model_year = 1990 + edid[0x11]; + } + else + { + info->production_year = 1990 + edid[0x11]; + info->model_year = -1; + } + + return TRUE; +} + +static int +decode_edid_version (const uchar *edid, MonitorInfo *info) +{ + info->major_version = edid[0x12]; + info->minor_version = edid[0x13]; + + return TRUE; +} + +static int +decode_display_parameters (const uchar *edid, MonitorInfo *info) +{ + /* Digital vs Analog */ + info->is_digital = get_bit (edid[0x14], 7); + + if (info->is_digital) + { + int bits; + + static const int bit_depth[8] = + { + -1, 6, 8, 10, 12, 14, 16, -1 + }; + + static const Interface interfaces[6] = + { + UNDEFINED, DVI, HDMI_A, HDMI_B, MDDI, DISPLAY_PORT + }; + + bits = get_bits (edid[0x14], 4, 6); + info->ad.digital.bits_per_primary = bit_depth[bits]; + + bits = get_bits (edid[0x14], 0, 3); + + if (bits <= 5) + info->ad.digital.interface = interfaces[bits]; + else + info->ad.digital.interface = UNDEFINED; + } + else + { + int bits = get_bits (edid[0x14], 5, 6); + + static const double levels[][3] = + { + { 0.7, 0.3, 1.0 }, + { 0.714, 0.286, 1.0 }, + { 1.0, 0.4, 1.4 }, + { 0.7, 0.0, 0.7 }, + }; + + info->ad.analog.video_signal_level = levels[bits][0]; + info->ad.analog.sync_signal_level = levels[bits][1]; + info->ad.analog.total_signal_level = levels[bits][2]; + + info->ad.analog.blank_to_black = get_bit (edid[0x14], 4); + + info->ad.analog.separate_hv_sync = get_bit (edid[0x14], 3); + info->ad.analog.composite_sync_on_h = get_bit (edid[0x14], 2); + info->ad.analog.composite_sync_on_green = get_bit (edid[0x14], 1); + + info->ad.analog.serration_on_vsync = get_bit (edid[0x14], 0); + } + + /* Screen Size / Aspect Ratio */ + if (edid[0x15] == 0 && edid[0x16] == 0) + { + info->width_mm = -1; + info->height_mm = -1; + info->aspect_ratio = -1.0; + } + else if (edid[0x16] == 0) + { + info->width_mm = -1; + info->height_mm = -1; + info->aspect_ratio = 100.0 / (edid[0x15] + 99); + } + else if (edid[0x15] == 0) + { + info->width_mm = -1; + info->height_mm = -1; + info->aspect_ratio = 100.0 / (edid[0x16] + 99); + info->aspect_ratio = 1/info->aspect_ratio; /* portrait */ + } + else + { + info->width_mm = 10 * edid[0x15]; + info->height_mm = 10 * edid[0x16]; + } + + /* Gamma */ + if (edid[0x17] == 0xFF) + info->gamma = -1.0; + else + info->gamma = (edid[0x17] + 100.0) / 100.0; + + /* Features */ + info->standby = get_bit (edid[0x18], 7); + info->suspend = get_bit (edid[0x18], 6); + info->active_off = get_bit (edid[0x18], 5); + + if (info->is_digital) + { + info->ad.digital.rgb444 = TRUE; + if (get_bit (edid[0x18], 3)) + info->ad.digital.ycrcb444 = 1; + if (get_bit (edid[0x18], 4)) + info->ad.digital.ycrcb422 = 1; + } + else + { + int bits = get_bits (edid[0x18], 3, 4); + ColorType color_type[4] = + { + MONOCHROME, RGB, OTHER_COLOR, UNDEFINED_COLOR + }; + + info->ad.analog.color_type = color_type[bits]; + } + + info->srgb_is_standard = get_bit (edid[0x18], 2); + + /* In 1.3 this is called "has preferred timing" */ + info->preferred_timing_includes_native = get_bit (edid[0x18], 1); + + /* FIXME: In 1.3 this indicates whether the monitor accepts GTF */ + info->continuous_frequency = get_bit (edid[0x18], 0); + return TRUE; +} + +static double +decode_fraction (int high, int low) +{ + double result = 0.0; + int i; + + high = (high << 2) | low; + + for (i = 0; i < 10; ++i) + result += get_bit (high, i) * SDL_pow (2, i - 10); + + return result; +} + +static int +decode_color_characteristics (const uchar *edid, MonitorInfo *info) +{ + info->red_x = decode_fraction (edid[0x1b], get_bits (edid[0x19], 6, 7)); + info->red_y = decode_fraction (edid[0x1c], get_bits (edid[0x19], 5, 4)); + info->green_x = decode_fraction (edid[0x1d], get_bits (edid[0x19], 2, 3)); + info->green_y = decode_fraction (edid[0x1e], get_bits (edid[0x19], 0, 1)); + info->blue_x = decode_fraction (edid[0x1f], get_bits (edid[0x1a], 6, 7)); + info->blue_y = decode_fraction (edid[0x20], get_bits (edid[0x1a], 4, 5)); + info->white_x = decode_fraction (edid[0x21], get_bits (edid[0x1a], 2, 3)); + info->white_y = decode_fraction (edid[0x22], get_bits (edid[0x1a], 0, 1)); + + return TRUE; +} + +static int +decode_established_timings (const uchar *edid, MonitorInfo *info) +{ + static const Timing established[][8] = + { + { + { 800, 600, 60 }, + { 800, 600, 56 }, + { 640, 480, 75 }, + { 640, 480, 72 }, + { 640, 480, 67 }, + { 640, 480, 60 }, + { 720, 400, 88 }, + { 720, 400, 70 } + }, + { + { 1280, 1024, 75 }, + { 1024, 768, 75 }, + { 1024, 768, 70 }, + { 1024, 768, 60 }, + { 1024, 768, 87 }, + { 832, 624, 75 }, + { 800, 600, 75 }, + { 800, 600, 72 } + }, + { + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 1152, 870, 75 } + }, + }; + + int i, j, idx; + + idx = 0; + for (i = 0; i < 3; ++i) + { + for (j = 0; j < 8; ++j) + { + int byte = edid[0x23 + i]; + + if (get_bit (byte, j) && established[i][j].frequency != 0) + info->established[idx++] = established[i][j]; + } + } + return TRUE; +} + +static int +decode_standard_timings (const uchar *edid, MonitorInfo *info) +{ + int i; + + for (i = 0; i < 8; i++) + { + int first = edid[0x26 + 2 * i]; + int second = edid[0x27 + 2 * i]; + + if (first != 0x01 && second != 0x01) + { + int w = 8 * (first + 31); + int h = 0; + + switch (get_bits (second, 6, 7)) + { + case 0x00: h = (w / 16) * 10; break; + case 0x01: h = (w / 4) * 3; break; + case 0x02: h = (w / 5) * 4; break; + case 0x03: h = (w / 16) * 9; break; + } + + info->standard[i].width = w; + info->standard[i].height = h; + info->standard[i].frequency = get_bits (second, 0, 5) + 60; + } + } + + return TRUE; +} + +static void +decode_lf_string (const uchar *s, int n_chars, char *result) +{ + int i; + for (i = 0; i < n_chars; ++i) + { + if (s[i] == 0x0a) + { + *result++ = '\0'; + break; + } + else if (s[i] == 0x00) + { + /* Convert embedded 0's to spaces */ + *result++ = ' '; + } + else + { + *result++ = s[i]; + } + } +} + +static void +decode_display_descriptor (const uchar *desc, + MonitorInfo *info) +{ + switch (desc[0x03]) + { + case 0xFC: + decode_lf_string (desc + 5, 13, info->dsc_product_name); + break; + case 0xFF: + decode_lf_string (desc + 5, 13, info->dsc_serial_number); + break; + case 0xFE: + decode_lf_string (desc + 5, 13, info->dsc_string); + break; + case 0xFD: + /* Range Limits */ + break; + case 0xFB: + /* Color Point */ + break; + case 0xFA: + /* Timing Identifications */ + break; + case 0xF9: + /* Color Management */ + break; + case 0xF8: + /* Timing Codes */ + break; + case 0xF7: + /* Established Timings */ + break; + case 0x10: + break; + } +} + +static void +decode_detailed_timing (const uchar *timing, + DetailedTiming *detailed) +{ + int bits; + StereoType stereo[] = + { + NO_STEREO, NO_STEREO, FIELD_RIGHT, FIELD_LEFT, + TWO_WAY_RIGHT_ON_EVEN, TWO_WAY_LEFT_ON_EVEN, + FOUR_WAY_INTERLEAVED, SIDE_BY_SIDE + }; + + detailed->pixel_clock = (timing[0x00] | timing[0x01] << 8) * 10000; + detailed->h_addr = timing[0x02] | ((timing[0x04] & 0xf0) << 4); + detailed->h_blank = timing[0x03] | ((timing[0x04] & 0x0f) << 8); + detailed->v_addr = timing[0x05] | ((timing[0x07] & 0xf0) << 4); + detailed->v_blank = timing[0x06] | ((timing[0x07] & 0x0f) << 8); + detailed->h_front_porch = timing[0x08] | get_bits (timing[0x0b], 6, 7) << 8; + detailed->h_sync = timing[0x09] | get_bits (timing[0x0b], 4, 5) << 8; + detailed->v_front_porch = + get_bits (timing[0x0a], 4, 7) | get_bits (timing[0x0b], 2, 3) << 4; + detailed->v_sync = + get_bits (timing[0x0a], 0, 3) | get_bits (timing[0x0b], 0, 1) << 4; + detailed->width_mm = timing[0x0c] | get_bits (timing[0x0e], 4, 7) << 8; + detailed->height_mm = timing[0x0d] | get_bits (timing[0x0e], 0, 3) << 8; + detailed->right_border = timing[0x0f]; + detailed->top_border = timing[0x10]; + + detailed->interlaced = get_bit (timing[0x11], 7); + + /* Stereo */ + bits = get_bits (timing[0x11], 5, 6) << 1 | get_bit (timing[0x11], 0); + detailed->stereo = stereo[bits]; + + /* Sync */ + bits = timing[0x11]; + + detailed->digital_sync = get_bit (bits, 4); + if (detailed->digital_sync) + { + detailed->ad.digital.composite = !get_bit (bits, 3); + + if (detailed->ad.digital.composite) + { + detailed->ad.digital.serrations = get_bit (bits, 2); + detailed->ad.digital.negative_vsync = FALSE; + } + else + { + detailed->ad.digital.serrations = FALSE; + detailed->ad.digital.negative_vsync = !get_bit (bits, 2); + } + + detailed->ad.digital.negative_hsync = !get_bit (bits, 0); + } + else + { + detailed->ad.analog.bipolar = get_bit (bits, 3); + detailed->ad.analog.serrations = get_bit (bits, 2); + detailed->ad.analog.sync_on_green = !get_bit (bits, 1); + } +} + +static int +decode_descriptors (const uchar *edid, MonitorInfo *info) +{ + int i; + int timing_idx; + + timing_idx = 0; + + for (i = 0; i < 4; ++i) + { + int index = 0x36 + i * 18; + + if (edid[index + 0] == 0x00 && edid[index + 1] == 0x00) + { + decode_display_descriptor (edid + index, info); + } + else + { + decode_detailed_timing ( + edid + index, &(info->detailed_timings[timing_idx++])); + } + } + + info->n_detailed_timings = timing_idx; + + return TRUE; +} + +static void +decode_check_sum (const uchar *edid, + MonitorInfo *info) +{ + int i; + uchar check = 0; + + for (i = 0; i < 128; ++i) + check += edid[i]; + + info->checksum = check; +} + +MonitorInfo * +decode_edid (const uchar *edid) +{ + MonitorInfo *info = SDL_calloc (1, sizeof (MonitorInfo)); + + decode_check_sum (edid, info); + + if (!decode_header (edid) || + !decode_vendor_and_product_identification (edid, info) || + !decode_edid_version (edid, info) || + !decode_display_parameters (edid, info) || + !decode_color_characteristics (edid, info) || + !decode_established_timings (edid, info) || + !decode_standard_timings (edid, info) || + !decode_descriptors (edid, info)) { + SDL_free(info); + return NULL; + } + + return info; +} + +static const char * +yesno (int v) +{ + return v? "yes" : "no"; +} + +void +dump_monitor_info (MonitorInfo *info) +{ + int i; + + printf ("Checksum: %d (%s)\n", + info->checksum, info->checksum? "incorrect" : "correct"); + printf ("Manufacturer Code: %s\n", info->manufacturer_code); + printf ("Product Code: 0x%x\n", info->product_code); + printf ("Serial Number: %u\n", info->serial_number); + + if (info->production_week != -1) + printf ("Production Week: %d\n", info->production_week); + else + printf ("Production Week: unspecified\n"); + + if (info->production_year != -1) + printf ("Production Year: %d\n", info->production_year); + else + printf ("Production Year: unspecified\n"); + + if (info->model_year != -1) + printf ("Model Year: %d\n", info->model_year); + else + printf ("Model Year: unspecified\n"); + + printf ("EDID revision: %d.%d\n", info->major_version, info->minor_version); + + printf ("Display is %s\n", info->is_digital? "digital" : "analog"); + if (info->is_digital) + { + const char *interface; + if (info->ad.digital.bits_per_primary != -1) + printf ("Bits Per Primary: %d\n", info->ad.digital.bits_per_primary); + else + printf ("Bits Per Primary: undefined\n"); + + switch (info->ad.digital.interface) + { + case DVI: interface = "DVI"; break; + case HDMI_A: interface = "HDMI-a"; break; + case HDMI_B: interface = "HDMI-b"; break; + case MDDI: interface = "MDDI"; break; + case DISPLAY_PORT: interface = "DisplayPort"; break; + case UNDEFINED: interface = "undefined"; break; + default: interface = "unknown"; break; + } + printf ("Interface: %s\n", interface); + + printf ("RGB 4:4:4: %s\n", yesno (info->ad.digital.rgb444)); + printf ("YCrCb 4:4:4: %s\n", yesno (info->ad.digital.ycrcb444)); + printf ("YCrCb 4:2:2: %s\n", yesno (info->ad.digital.ycrcb422)); + } + else + { + const char *s; + printf ("Video Signal Level: %f\n", info->ad.analog.video_signal_level); + printf ("Sync Signal Level: %f\n", info->ad.analog.sync_signal_level); + printf ("Total Signal Level: %f\n", info->ad.analog.total_signal_level); + + printf ("Blank to Black: %s\n", + yesno (info->ad.analog.blank_to_black)); + printf ("Separate HV Sync: %s\n", + yesno (info->ad.analog.separate_hv_sync)); + printf ("Composite Sync on H: %s\n", + yesno (info->ad.analog.composite_sync_on_h)); + printf ("Serration on VSync: %s\n", + yesno (info->ad.analog.serration_on_vsync)); + + switch (info->ad.analog.color_type) + { + case UNDEFINED_COLOR: s = "undefined"; break; + case MONOCHROME: s = "monochrome"; break; + case RGB: s = "rgb"; break; + case OTHER_COLOR: s = "other color"; break; + default: s = "unknown"; break; + } + + printf ("Color: %s\n", s); + } + + if (info->width_mm == -1) + printf ("Width: undefined\n"); + else + printf ("Width: %d mm\n", info->width_mm); + + if (info->height_mm == -1) + printf ("Height: undefined\n"); + else + printf ("Height: %d mm\n", info->height_mm); + + if (info->aspect_ratio > 0) + printf ("Aspect Ratio: %f\n", info->aspect_ratio); + else + printf ("Aspect Ratio: undefined\n"); + + if (info->gamma >= 0) + printf ("Gamma: %f\n", info->gamma); + else + printf ("Gamma: undefined\n"); + + printf ("Standby: %s\n", yesno (info->standby)); + printf ("Suspend: %s\n", yesno (info->suspend)); + printf ("Active Off: %s\n", yesno (info->active_off)); + + printf ("SRGB is Standard: %s\n", yesno (info->srgb_is_standard)); + printf ("Preferred Timing Includes Native: %s\n", + yesno (info->preferred_timing_includes_native)); + printf ("Continuous Frequency: %s\n", yesno (info->continuous_frequency)); + + printf ("Red X: %f\n", info->red_x); + printf ("Red Y: %f\n", info->red_y); + printf ("Green X: %f\n", info->green_x); + printf ("Green Y: %f\n", info->green_y); + printf ("Blue X: %f\n", info->blue_x); + printf ("Blue Y: %f\n", info->blue_y); + printf ("White X: %f\n", info->white_x); + printf ("White Y: %f\n", info->white_y); + + printf ("Established Timings:\n"); + + for (i = 0; i < 24; ++i) + { + Timing *timing = &(info->established[i]); + + if (timing->frequency == 0) + break; + + printf (" %d x %d @ %d Hz\n", + timing->width, timing->height, timing->frequency); + + } + + printf ("Standard Timings:\n"); + for (i = 0; i < 8; ++i) + { + Timing *timing = &(info->standard[i]); + + if (timing->frequency == 0) + break; + + printf (" %d x %d @ %d Hz\n", + timing->width, timing->height, timing->frequency); + } + + for (i = 0; i < info->n_detailed_timings; ++i) + { + DetailedTiming *timing = &(info->detailed_timings[i]); + const char *s; + + printf ("Timing%s: \n", + (i == 0 && info->preferred_timing_includes_native)? + " (Preferred)" : ""); + printf (" Pixel Clock: %d\n", timing->pixel_clock); + printf (" H Addressable: %d\n", timing->h_addr); + printf (" H Blank: %d\n", timing->h_blank); + printf (" H Front Porch: %d\n", timing->h_front_porch); + printf (" H Sync: %d\n", timing->h_sync); + printf (" V Addressable: %d\n", timing->v_addr); + printf (" V Blank: %d\n", timing->v_blank); + printf (" V Front Porch: %d\n", timing->v_front_porch); + printf (" V Sync: %d\n", timing->v_sync); + printf (" Width: %d mm\n", timing->width_mm); + printf (" Height: %d mm\n", timing->height_mm); + printf (" Right Border: %d\n", timing->right_border); + printf (" Top Border: %d\n", timing->top_border); + switch (timing->stereo) + { + default: + case NO_STEREO: s = "No Stereo"; break; + case FIELD_RIGHT: s = "Field Sequential, Right on Sync"; break; + case FIELD_LEFT: s = "Field Sequential, Left on Sync"; break; + case TWO_WAY_RIGHT_ON_EVEN: s = "Two-way, Right on Even"; break; + case TWO_WAY_LEFT_ON_EVEN: s = "Two-way, Left on Even"; break; + case FOUR_WAY_INTERLEAVED: s = "Four-way Interleaved"; break; + case SIDE_BY_SIDE: s = "Side-by-Side"; break; + } + printf (" Stereo: %s\n", s); + + if (timing->digital_sync) + { + printf (" Digital Sync:\n"); + printf (" composite: %s\n", yesno (timing->ad.digital.composite)); + printf (" serrations: %s\n", yesno (timing->ad.digital.serrations)); + printf (" negative vsync: %s\n", + yesno (timing->ad.digital.negative_vsync)); + printf (" negative hsync: %s\n", + yesno (timing->ad.digital.negative_hsync)); + } + else + { + printf (" Analog Sync:\n"); + printf (" bipolar: %s\n", yesno (timing->ad.analog.bipolar)); + printf (" serrations: %s\n", yesno (timing->ad.analog.serrations)); + printf (" sync on green: %s\n", yesno ( + timing->ad.analog.sync_on_green)); + } + } + + printf ("Detailed Product information:\n"); + printf (" Product Name: %s\n", info->dsc_product_name); + printf (" Serial Number: %s\n", info->dsc_serial_number); + printf (" Unspecified String: %s\n", info->dsc_string); +} + diff --git a/contrib/SDL-3.2.8/src/video/x11/edid.h b/contrib/SDL-3.2.8/src/video/x11/edid.h new file mode 100644 index 0000000..4581291 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/edid.h @@ -0,0 +1,191 @@ +/* + * Copyright 2007 Red Hat, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* Author: Soren Sandmann */ + +typedef unsigned char uchar; +typedef struct MonitorInfo MonitorInfo; +typedef struct Timing Timing; +typedef struct DetailedTiming DetailedTiming; + +typedef enum +{ + UNDEFINED, + DVI, + HDMI_A, + HDMI_B, + MDDI, + DISPLAY_PORT +} Interface; + +typedef enum +{ + UNDEFINED_COLOR, + MONOCHROME, + RGB, + OTHER_COLOR +} ColorType; + +typedef enum +{ + NO_STEREO, + FIELD_RIGHT, + FIELD_LEFT, + TWO_WAY_RIGHT_ON_EVEN, + TWO_WAY_LEFT_ON_EVEN, + FOUR_WAY_INTERLEAVED, + SIDE_BY_SIDE +} StereoType; + +struct Timing +{ + int width; + int height; + int frequency; +}; + +struct DetailedTiming +{ + int pixel_clock; + int h_addr; + int h_blank; + int h_sync; + int h_front_porch; + int v_addr; + int v_blank; + int v_sync; + int v_front_porch; + int width_mm; + int height_mm; + int right_border; + int top_border; + int interlaced; + StereoType stereo; + + int digital_sync; + union + { + struct + { + int bipolar; + int serrations; + int sync_on_green; + } analog; + + struct + { + int composite; + int serrations; + int negative_vsync; + int negative_hsync; + } digital; + } ad; +}; + +struct MonitorInfo +{ + int checksum; + char manufacturer_code[4]; + int product_code; + unsigned int serial_number; + + int production_week; // -1 if not specified + int production_year; // -1 if not specified + int model_year; // -1 if not specified + + int major_version; + int minor_version; + + int is_digital; + + union + { + struct + { + int bits_per_primary; + Interface interface; + int rgb444; + int ycrcb444; + int ycrcb422; + } digital; + + struct + { + double video_signal_level; + double sync_signal_level; + double total_signal_level; + + int blank_to_black; + + int separate_hv_sync; + int composite_sync_on_h; + int composite_sync_on_green; + int serration_on_vsync; + ColorType color_type; + } analog; + } ad; + + int width_mm; // -1 if not specified + int height_mm; // -1 if not specified + double aspect_ratio; // -1.0 if not specififed + + double gamma; // -1.0 if not specified + + int standby; + int suspend; + int active_off; + + int srgb_is_standard; + int preferred_timing_includes_native; + int continuous_frequency; + + double red_x; + double red_y; + double green_x; + double green_y; + double blue_x; + double blue_y; + double white_x; + double white_y; + + Timing established[24]; // Terminated by 0x0x0 + Timing standard[8]; + + int n_detailed_timings; + DetailedTiming detailed_timings[4]; /* If monitor has a preferred + * mode, it is the first one + * (whether it has, is + * determined by the + * preferred_timing_includes + * bit. + */ + + // Optional product description + char dsc_serial_number[14]; + char dsc_product_name[14]; + char dsc_string[14]; // Unspecified ASCII data +}; + +MonitorInfo *decode_edid(const uchar *data); +void dump_monitor_info(MonitorInfo *info); +char *make_display_name(const char *output_name, + const MonitorInfo *info); diff --git a/contrib/SDL-3.2.8/src/video/x11/xsettings-client.c b/contrib/SDL-3.2.8/src/video/x11/xsettings-client.c new file mode 100644 index 0000000..8fb1cd3 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/xsettings-client.c @@ -0,0 +1,859 @@ +/* + * Copyright © 2001, 2007 Red Hat, Inc. + * Copyright 2024 Igalia S.L. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Owen Taylor, Red Hat, Inc. + */ + +#include "SDL_internal.h" + +#ifdef SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" + +#include +#include +#include +#include + +#include "xsettings-client.h" + +struct _XSettingsClient +{ + Display *display; + int screen; + XSettingsNotifyFunc notify; + XSettingsWatchFunc watch; + void *cb_data; + + XSettingsGrabFunc grab; + XSettingsGrabFunc ungrab; + + Window manager_window; + Atom manager_atom; + Atom selection_atom; + Atom xsettings_atom; + + XSettingsList *settings; +}; + +static void +notify_changes (XSettingsClient *client, + XSettingsList *old_list) +{ + XSettingsList *old_iter = old_list; + XSettingsList *new_iter = client->settings; + + if (!client->notify) + return; + + while (old_iter || new_iter) + { + int cmp; + + if (old_iter && new_iter) + cmp = strcmp (old_iter->setting->name, new_iter->setting->name); + else if (old_iter) + cmp = -1; + else + cmp = 1; + + if (cmp < 0) + { + client->notify (old_iter->setting->name, + XSETTINGS_ACTION_DELETED, + NULL, + client->cb_data); + } + else if (cmp == 0) + { + if (!xsettings_setting_equal (old_iter->setting, + new_iter->setting)) + client->notify (old_iter->setting->name, + XSETTINGS_ACTION_CHANGED, + new_iter->setting, + client->cb_data); + } + else + { + client->notify (new_iter->setting->name, + XSETTINGS_ACTION_NEW, + new_iter->setting, + client->cb_data); + } + + if (old_iter) + old_iter = old_iter->next; + if (new_iter) + new_iter = new_iter->next; + } +} + +static int +ignore_errors (Display *display, XErrorEvent *event) +{ + return True; +} + +static char local_byte_order = '\0'; + +#define BYTES_LEFT(buffer) ((buffer)->data + (buffer)->len - (buffer)->pos) + +static XSettingsResult +fetch_card16 (XSettingsBuffer *buffer, + CARD16 *result) +{ + CARD16 x; + + if (BYTES_LEFT (buffer) < 2) + return XSETTINGS_ACCESS; + + x = *(CARD16 *)buffer->pos; + buffer->pos += 2; + + if (buffer->byte_order == local_byte_order) + *result = x; + else + *result = (x << 8) | (x >> 8); + + return XSETTINGS_SUCCESS; +} + +static XSettingsResult +fetch_ushort (XSettingsBuffer *buffer, + unsigned short *result) +{ + CARD16 x; + XSettingsResult r; + + r = fetch_card16 (buffer, &x); + if (r == XSETTINGS_SUCCESS) + *result = x; + + return r; +} + +static XSettingsResult +fetch_card32 (XSettingsBuffer *buffer, + CARD32 *result) +{ + CARD32 x; + + if (BYTES_LEFT (buffer) < 4) + return XSETTINGS_ACCESS; + + x = *(CARD32 *)buffer->pos; + buffer->pos += 4; + + if (buffer->byte_order == local_byte_order) + *result = x; + else + *result = (x << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | (x >> 24); + + return XSETTINGS_SUCCESS; +} + +static XSettingsResult +fetch_card8 (XSettingsBuffer *buffer, + CARD8 *result) +{ + if (BYTES_LEFT (buffer) < 1) + return XSETTINGS_ACCESS; + + *result = *(CARD8 *)buffer->pos; + buffer->pos += 1; + + return XSETTINGS_SUCCESS; +} + +#define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1))) + +static XSettingsList * +parse_settings (unsigned char *data, + size_t len) +{ + XSettingsBuffer buffer; + XSettingsResult result = XSETTINGS_SUCCESS; + XSettingsList *settings = NULL; + CARD32 serial; + CARD32 n_entries; + CARD32 i; + XSettingsSetting *setting = NULL; + char buffer_byte_order = '\0'; + + local_byte_order = xsettings_byte_order (); + + buffer.pos = buffer.data = data; + buffer.len = len; + buffer.byte_order = '\0'; + + result = fetch_card8 (&buffer, (unsigned char *) &buffer_byte_order); + if (buffer_byte_order != MSBFirst && + buffer_byte_order != LSBFirst) + { + fprintf (stderr, "Invalid byte order in XSETTINGS property\n"); + result = XSETTINGS_FAILED; + goto out; + } + + buffer.byte_order = buffer_byte_order; + buffer.pos += 3; + + result = fetch_card32 (&buffer, &serial); + if (result != XSETTINGS_SUCCESS) + goto out; + + result = fetch_card32 (&buffer, &n_entries); + if (result != XSETTINGS_SUCCESS) + goto out; + + for (i = 0; i < n_entries; i++) + { + CARD8 type; + CARD16 name_len; + CARD32 v_int; + size_t pad_len; + + result = fetch_card8 (&buffer, &type); + if (result != XSETTINGS_SUCCESS) + goto out; + + buffer.pos += 1; + + result = fetch_card16 (&buffer, &name_len); + if (result != XSETTINGS_SUCCESS) + goto out; + + pad_len = XSETTINGS_PAD(name_len, 4); + if (BYTES_LEFT (&buffer) < pad_len) + { + result = XSETTINGS_ACCESS; + goto out; + } + + setting = malloc (sizeof *setting); + if (!setting) + { + result = XSETTINGS_NO_MEM; + goto out; + } + setting->type = XSETTINGS_TYPE_INT; /* No allocated memory */ + + setting->name = malloc (name_len + 1); + if (!setting->name) + { + result = XSETTINGS_NO_MEM; + goto out; + } + + memcpy (setting->name, buffer.pos, name_len); + setting->name[name_len] = '\0'; + buffer.pos += pad_len; + + result = fetch_card32 (&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + setting->last_change_serial = v_int; + + switch (type) + { + case XSETTINGS_TYPE_INT: + result = fetch_card32 (&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + + setting->data.v_int = (INT32)v_int; + break; + case XSETTINGS_TYPE_STRING: + result = fetch_card32 (&buffer, &v_int); + if (result != XSETTINGS_SUCCESS) + goto out; + + pad_len = XSETTINGS_PAD (v_int, 4); + if (v_int + 1 == 0 || /* Guard against wrap-around */ + BYTES_LEFT (&buffer) < pad_len) + { + result = XSETTINGS_ACCESS; + goto out; + } + + setting->data.v_string = malloc (v_int + 1); + if (!setting->data.v_string) + { + result = XSETTINGS_NO_MEM; + goto out; + } + + memcpy (setting->data.v_string, buffer.pos, v_int); + setting->data.v_string[v_int] = '\0'; + buffer.pos += pad_len; + + break; + case XSETTINGS_TYPE_COLOR: + result = fetch_ushort (&buffer, &setting->data.v_color.red); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort (&buffer, &setting->data.v_color.green); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort (&buffer, &setting->data.v_color.blue); + if (result != XSETTINGS_SUCCESS) + goto out; + result = fetch_ushort (&buffer, &setting->data.v_color.alpha); + if (result != XSETTINGS_SUCCESS) + goto out; + + break; + default: + /* Quietly ignore unknown types */ + break; + } + + setting->type = type; + + result = xsettings_list_insert (&settings, setting); + if (result != XSETTINGS_SUCCESS) + goto out; + + setting = NULL; + } + + out: + + if (result != XSETTINGS_SUCCESS) + { + switch (result) + { + case XSETTINGS_NO_MEM: + fprintf(stderr, "Out of memory reading XSETTINGS property\n"); + break; + case XSETTINGS_ACCESS: + fprintf(stderr, "Invalid XSETTINGS property (read off end)\n"); + break; + case XSETTINGS_DUPLICATE_ENTRY: + fprintf (stderr, "Duplicate XSETTINGS entry for '%s'\n", setting->name); + SDL_FALLTHROUGH; + case XSETTINGS_FAILED: + SDL_FALLTHROUGH; + case XSETTINGS_SUCCESS: + SDL_FALLTHROUGH; + case XSETTINGS_NO_ENTRY: + break; + } + + if (setting) + xsettings_setting_free (setting); + + xsettings_list_free (settings); + settings = NULL; + + } + + return settings; +} + +static void +read_settings (XSettingsClient *client) +{ + Atom type; + int format; + unsigned long n_items; + unsigned long bytes_after; + unsigned char *data; + int result; + + int (*old_handler) (Display *, XErrorEvent *); + + XSettingsList *old_list = client->settings; + + client->settings = NULL; + + if (client->manager_window) + { + old_handler = X11_XSetErrorHandler (ignore_errors); + result = X11_XGetWindowProperty (client->display, client->manager_window, + client->xsettings_atom, 0, LONG_MAX, + False, client->xsettings_atom, + &type, &format, &n_items, &bytes_after, &data); + X11_XSetErrorHandler (old_handler); + + if (result == Success && type != None) + { + if (type != client->xsettings_atom) + { + fprintf (stderr, "Invalid type for XSETTINGS property"); + } + else if (format != 8) + { + fprintf (stderr, "Invalid format for XSETTINGS property %d", format); + } + else + client->settings = parse_settings (data, n_items); + + X11_XFree (data); + } + } + + notify_changes (client, old_list); + xsettings_list_free (old_list); +} + +static void +add_events (Display *display, + Window window, + long mask) +{ + XWindowAttributes attr; + + X11_XGetWindowAttributes (display, window, &attr); + X11_XSelectInput (display, window, attr.your_event_mask | mask); +} + +static void +check_manager_window (XSettingsClient *client) +{ + if (client->manager_window && client->watch) + client->watch (client->manager_window, False, 0, client->cb_data); + + if (client->grab) + client->grab (client->display); + else + X11_XGrabServer (client->display); + + client->manager_window = X11_XGetSelectionOwner (client->display, + client->selection_atom); + if (client->manager_window) + X11_XSelectInput (client->display, client->manager_window, + PropertyChangeMask | StructureNotifyMask); + + if (client->ungrab) + client->ungrab (client->display); + else + X11_XUngrabServer (client->display); + + X11_XFlush (client->display); + + if (client->manager_window && client->watch) + { + if (!client->watch (client->manager_window, True, + PropertyChangeMask | StructureNotifyMask, + client->cb_data)) + { + /* Inability to watch the window probably means that it was destroyed + * after we ungrabbed + */ + client->manager_window = None; + return; + } + } + + + read_settings (client); +} + +XSettingsClient * +xsettings_client_new (Display *display, + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data) +{ + return xsettings_client_new_with_grab_funcs (display, screen, notify, watch, cb_data, + NULL, NULL); +} + +XSettingsClient * +xsettings_client_new_with_grab_funcs (Display *display, + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data, + XSettingsGrabFunc grab, + XSettingsGrabFunc ungrab) +{ + XSettingsClient *client; + char buffer[256]; + char *atom_names[3]; + Atom atoms[3]; + + client = malloc (sizeof *client); + if (!client) + return NULL; + + client->display = display; + client->screen = screen; + client->notify = notify; + client->watch = watch; + client->cb_data = cb_data; + client->grab = grab; + client->ungrab = ungrab; + + client->manager_window = None; + client->settings = NULL; + + sprintf(buffer, "_XSETTINGS_S%d", screen); + atom_names[0] = buffer; + atom_names[1] = "_XSETTINGS_SETTINGS"; + atom_names[2] = "MANAGER"; + +#ifdef HAVE_XINTERNATOMS + XInternAtoms (display, atom_names, 3, False, atoms); +#else + atoms[0] = X11_XInternAtom (display, atom_names[0], False); + atoms[1] = X11_XInternAtom (display, atom_names[1], False); + atoms[2] = X11_XInternAtom (display, atom_names[2], False); +#endif + + client->selection_atom = atoms[0]; + client->xsettings_atom = atoms[1]; + client->manager_atom = atoms[2]; + + /* Select on StructureNotify so we get MANAGER events + */ + add_events (display, RootWindow (display, screen), StructureNotifyMask); + + if (client->watch) + client->watch (RootWindow (display, screen), True, StructureNotifyMask, + client->cb_data); + + check_manager_window (client); + + return client; +} + + +void +xsettings_client_set_grab_func (XSettingsClient *client, + XSettingsGrabFunc grab) +{ + client->grab = grab; +} + +void +xsettings_client_set_ungrab_func (XSettingsClient *client, + XSettingsGrabFunc ungrab) +{ + client->ungrab = ungrab; +} + +void +xsettings_client_destroy (XSettingsClient *client) +{ + if (client->watch) + client->watch (RootWindow (client->display, client->screen), + False, 0, client->cb_data); + if (client->manager_window && client->watch) + client->watch (client->manager_window, False, 0, client->cb_data); + + xsettings_list_free (client->settings); + free (client); +} + +XSettingsResult +xsettings_client_get_setting (XSettingsClient *client, + const char *name, + XSettingsSetting **setting) +{ + XSettingsSetting *search = xsettings_list_lookup (client->settings, name); + if (search) + { + *setting = xsettings_setting_copy (search); + return *setting ? XSETTINGS_SUCCESS : XSETTINGS_NO_MEM; + } + else + return XSETTINGS_NO_ENTRY; +} + +Bool +xsettings_client_process_event (XSettingsClient *client, + const XEvent *xev) +{ + /* The checks here will not unlikely cause us to reread + * the properties from the manager window a number of + * times when the manager changes from A->B. But manager changes + * are going to be pretty rare. + */ + if (xev->xany.window == RootWindow (client->display, client->screen)) + { + if (xev->xany.type == ClientMessage && + xev->xclient.message_type == client->manager_atom && + xev->xclient.data.l[1] == client->selection_atom) + { + check_manager_window (client); + return True; + } + } + else if (xev->xany.window == client->manager_window) + { + if (xev->xany.type == DestroyNotify) + { + check_manager_window (client); + return False; + } + else if (xev->xany.type == PropertyNotify) + { + read_settings (client); + return True; + } + } + + return False; +} + +XSettingsSetting * +xsettings_setting_copy (XSettingsSetting *setting) +{ + XSettingsSetting *result; + size_t str_len; + + result = malloc (sizeof *result); + if (!result) + return NULL; + + str_len = strlen (setting->name); + result->name = malloc (str_len + 1); + if (!result->name) + goto err; + + memcpy (result->name, setting->name, str_len + 1); + + result->type = setting->type; + + switch (setting->type) + { + case XSETTINGS_TYPE_INT: + result->data.v_int = setting->data.v_int; + break; + case XSETTINGS_TYPE_COLOR: + result->data.v_color = setting->data.v_color; + break; + case XSETTINGS_TYPE_STRING: + str_len = strlen (setting->data.v_string); + result->data.v_string = malloc (str_len + 1); + if (!result->data.v_string) + goto err; + + memcpy (result->data.v_string, setting->data.v_string, str_len + 1); + break; + } + + result->last_change_serial = setting->last_change_serial; + + return result; + + err: + if (result->name) + free (result->name); + free (result); + + return NULL; +} + +XSettingsList * +xsettings_list_copy (XSettingsList *list) +{ + XSettingsList *new = NULL; + XSettingsList *old_iter = list; + XSettingsList *new_iter = NULL; + + while (old_iter) + { + XSettingsList *new_node; + + new_node = malloc (sizeof *new_node); + if (!new_node) + goto error; + + new_node->setting = xsettings_setting_copy (old_iter->setting); + if (!new_node->setting) + { + free (new_node); + goto error; + } + + if (new_iter) + new_iter->next = new_node; + else + { + new = new_node; + new->next = NULL; + } + + + new_iter = new_node; + + old_iter = old_iter->next; + } + + return new; + + error: + xsettings_list_free (new); + return NULL; +} + +int +xsettings_setting_equal (XSettingsSetting *setting_a, + XSettingsSetting *setting_b) +{ + if (setting_a->type != setting_b->type) + return 0; + + if (strcmp (setting_a->name, setting_b->name) != 0) + return 0; + + switch (setting_a->type) + { + case XSETTINGS_TYPE_INT: + return setting_a->data.v_int == setting_b->data.v_int; + case XSETTINGS_TYPE_COLOR: + return (setting_a->data.v_color.red == setting_b->data.v_color.red && + setting_a->data.v_color.green == setting_b->data.v_color.green && + setting_a->data.v_color.blue == setting_b->data.v_color.blue && + setting_a->data.v_color.alpha == setting_b->data.v_color.alpha); + case XSETTINGS_TYPE_STRING: + return strcmp (setting_a->data.v_string, setting_b->data.v_string) == 0; + } + + return 0; +} + +void +xsettings_setting_free (XSettingsSetting *setting) +{ + if (setting->type == XSETTINGS_TYPE_STRING) + free (setting->data.v_string); + + if (setting->name) + free (setting->name); + + free (setting); +} + +void +xsettings_list_free (XSettingsList *list) +{ + while (list) + { + XSettingsList *next = list->next; + + xsettings_setting_free (list->setting); + free (list); + + list = next; + } +} + +XSettingsResult +xsettings_list_insert (XSettingsList **list, + XSettingsSetting *setting) +{ + XSettingsList *node; + XSettingsList *iter; + XSettingsList *last = NULL; + + node = malloc (sizeof *node); + if (!node) + return XSETTINGS_NO_MEM; + node->setting = setting; + + iter = *list; + while (iter) + { + int cmp = strcmp (setting->name, iter->setting->name); + + if (cmp < 0) + break; + else if (cmp == 0) + { + free (node); + return XSETTINGS_DUPLICATE_ENTRY; + } + + last = iter; + iter = iter->next; + } + + if (last) + last->next = node; + else + *list = node; + + node->next = iter; + + return XSETTINGS_SUCCESS; +} + +XSettingsResult +xsettings_list_delete (XSettingsList **list, + const char *name) +{ + XSettingsList *iter; + XSettingsList *last = NULL; + + iter = *list; + while (iter) + { + if (strcmp (name, iter->setting->name) == 0) + { + if (last) + last->next = iter->next; + else + *list = iter->next; + + xsettings_setting_free (iter->setting); + free (iter); + + return XSETTINGS_SUCCESS; + } + + last = iter; + iter = iter->next; + } + + return XSETTINGS_FAILED; +} + +XSettingsSetting * +xsettings_list_lookup (XSettingsList *list, + const char *name) +{ + XSettingsList *iter; + + iter = list; + while (iter) + { + if (strcmp (name, iter->setting->name) == 0) + return iter->setting; + + iter = iter->next; + } + + return NULL; +} + +char +xsettings_byte_order (void) +{ + CARD32 myint = 0x01020304; + return (*(char *)&myint == 1) ? MSBFirst : LSBFirst; +} + +#endif /* SDL_VIDEO_DRIVER_X11 */ diff --git a/contrib/SDL-3.2.8/src/video/x11/xsettings-client.h b/contrib/SDL-3.2.8/src/video/x11/xsettings-client.h new file mode 100644 index 0000000..863c6f9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/x11/xsettings-client.h @@ -0,0 +1,153 @@ +/* + * Copyright © 2001, 2007 Red Hat, Inc. + * Copyright 2024 Igalia S.L. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Red Hat not be used in advertising or + * publicity pertaining to distribution of the software without specific, + * written prior permission. Red Hat makes no representations about the + * suitability of this software for any purpose. It is provided "as is" + * without express or implied warranty. + * + * RED HAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL RED HAT + * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Author: Owen Taylor, Red Hat, Inc. + */ +#ifndef XSETTINGS_CLIENT_H +#define XSETTINGS_CLIENT_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +typedef struct _XSettingsBuffer XSettingsBuffer; +typedef struct _XSettingsColor XSettingsColor; +typedef struct _XSettingsList XSettingsList; +typedef struct _XSettingsSetting XSettingsSetting; + +/* Types of settings possible. Enum values correspond to + * protocol values. + */ +typedef enum +{ + XSETTINGS_TYPE_INT = 0, + XSETTINGS_TYPE_STRING = 1, + XSETTINGS_TYPE_COLOR = 2 +} XSettingsType; + +typedef enum +{ + XSETTINGS_SUCCESS, + XSETTINGS_NO_MEM, + XSETTINGS_ACCESS, + XSETTINGS_FAILED, + XSETTINGS_NO_ENTRY, + XSETTINGS_DUPLICATE_ENTRY +} XSettingsResult; + +struct _XSettingsBuffer +{ + char byte_order; + size_t len; + unsigned char *data; + unsigned char *pos; +}; + +struct _XSettingsColor +{ + unsigned short red, green, blue, alpha; +}; + +struct _XSettingsList +{ + XSettingsSetting *setting; + XSettingsList *next; +}; + +struct _XSettingsSetting +{ + char *name; + XSettingsType type; + + union { + int v_int; + char *v_string; + XSettingsColor v_color; + } data; + + unsigned long last_change_serial; +}; + +XSettingsSetting *xsettings_setting_copy (XSettingsSetting *setting); +void xsettings_setting_free (XSettingsSetting *setting); +int xsettings_setting_equal (XSettingsSetting *setting_a, + XSettingsSetting *setting_b); + +void xsettings_list_free (XSettingsList *list); +XSettingsList *xsettings_list_copy (XSettingsList *list); +XSettingsResult xsettings_list_insert (XSettingsList **list, + XSettingsSetting *setting); +XSettingsSetting *xsettings_list_lookup (XSettingsList *list, + const char *name); +XSettingsResult xsettings_list_delete (XSettingsList **list, + const char *name); + +char xsettings_byte_order (void); + +#define XSETTINGS_PAD(n,m) ((n + m - 1) & (~(m-1))) + +typedef struct _XSettingsClient XSettingsClient; + +typedef enum +{ + XSETTINGS_ACTION_NEW, + XSETTINGS_ACTION_CHANGED, + XSETTINGS_ACTION_DELETED +} XSettingsAction; + +typedef void (*XSettingsNotifyFunc) (const char *name, + XSettingsAction action, + XSettingsSetting *setting, + void *cb_data); +typedef Bool (*XSettingsWatchFunc) (Window window, + Bool is_start, + long mask, + void *cb_data); +typedef void (*XSettingsGrabFunc) (Display *display); + +XSettingsClient *xsettings_client_new (Display *display, + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data); +XSettingsClient *xsettings_client_new_with_grab_funcs (Display *display, + int screen, + XSettingsNotifyFunc notify, + XSettingsWatchFunc watch, + void *cb_data, + XSettingsGrabFunc grab, + XSettingsGrabFunc ungrab); +void xsettings_client_set_grab_func (XSettingsClient *client, + XSettingsGrabFunc grab); +void xsettings_client_set_ungrab_func (XSettingsClient *client, + XSettingsGrabFunc ungrab); +void xsettings_client_destroy (XSettingsClient *client); +Bool xsettings_client_process_event (XSettingsClient *client, + const XEvent *xev); +XSettingsResult xsettings_client_get_setting (XSettingsClient *client, + const char *name, + XSettingsSetting **setting); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* XSETTINGS_CLIENT_H */ diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/LICENSE b/contrib/SDL-3.2.8/src/video/yuv2rgb/LICENSE new file mode 100644 index 0000000..a76efd7 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2016, Adrien Descamps +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of yuv2rgb nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/README.md b/contrib/SDL-3.2.8/src/video/yuv2rgb/README.md new file mode 100644 index 0000000..21191e9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/README.md @@ -0,0 +1,63 @@ +From: https://github.com/descampsa/yuv2rgb +# yuv2rgb +C library for fast image conversion between yuv420p and rgb24. + +This is a simple library for optimized image conversion between YUV420p and rgb24. +It was done mainly as an exercise to learn to use sse intrinsics, so there may still be room for optimization. + +For each conversion, a standard c optimized function and two sse function (with aligned and unaligned memory) are implemented. +The sse version requires only SSE2, which is available on any reasonably recent CPU. +The library also supports the three different YUV (YCrCb to be correct) color spaces that exist (see comments in code), and others can be added simply. + +There is a simple test program, that convert a raw YUV file to rgb ppm format, and measure computation time. +Optionally, it also compares the result and computation time with the ffmpeg implementation (that uses MMX), and with the IPP functions. + +To compile, simply do : + + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release .. + make + +The test program only support raw YUV files for the YUV420 format, and ppm for the RGB24 format. +To generate a raw yuv file, you can use avconv: + + avconv -i example.jpg -c:v rawvideo -pix_fmt yuv420p example.yuv + +To generate the rgb file, you can use the ImageMagick convert program: + + convert example.jpg example.ppm + +Then, for YUV420 to RGB24 conversion, use the test program like that: + + ./test_yuv_rgb yuv2rgb image.yuv 4096 2160 image + +The second and third parameters are image width and height (that are needed because not available in the raw YUV file), and fourth parameter is the output filename template (several output files will be generated, named for example output_sse.ppm, output_av.ppm, etc.) + +Similarly, for RGB24 to YUV420 conversion: + + ./test_yuv_rgb yuv2rgb image.ppm image + +On my computer, the test program on a 4K image give the following for yuv2rgb: + + Time will be measured in each configuration for 100 iterations... + Processing time (std) : 2.630193 sec + Processing time (sse2_unaligned) : 0.704394 sec + Processing time (ffmpeg_unaligned) : 1.221432 sec + Processing time (ipp_unaligned) : 0.636274 sec + Processing time (sse2_aligned) : 0.606648 sec + Processing time (ffmpeg_aligned) : 1.227100 sec + Processing time (ipp_aligned) : 0.636951 sec + +And for rgb2yuv: + + Time will be measured in each configuration for 100 iterations... + Processing time (std) : 2.588675 sec + Processing time (sse2_unaligned) : 0.676625 sec + Processing time (ffmpeg_unaligned) : 3.385816 sec + Processing time (ipp_unaligned) : 0.593890 sec + Processing time (sse2_aligned) : 0.640630 sec + Processing time (ffmpeg_aligned) : 3.397952 sec + Processing time (ipp_aligned) : 0.579043 sec + +configuration : gcc 4.9.2, swscale 3.0.0, IPP 9.0.1, intel i7-5500U diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb.h b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb.h new file mode 100644 index 0000000..c359316 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb.h @@ -0,0 +1,33 @@ +#ifndef YUV_RGB_H_ +#define YUV_RGB_H_ + +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License + +// Provide optimized functions to convert images from 8bits yuv420 to rgb24 format + +// There are a few slightly different variations of the YCbCr color space with different parameters that +// change the conversion matrix. +// The three most common YCbCr color space, defined by BT.601, BT.709 and JPEG standard are implemented here. +// See the respective standards for details +// The matrix values used are derived from http://www.equasys.de/colorconversion.html + +// YUV420 is stored as three separate channels, with U and V (Cb and Cr) subsampled by a 2 factor +// For conversion from yuv to rgb, no interpolation is done, and the same UV value are used for 4 rgb pixels. This +// is suboptimal for image quality, but by far the fastest method. + +// For all methods, width and height should be even, if not, the last row/column of the result image won't be affected. +// For sse methods, if the width if not divisable by 32, the last (width%32) pixels of each line won't be affected. + +/*#include */ + +// yuv to rgb, standard c implementation +#include "yuv_rgb_std.h" + +// yuv to rgb, sse2 implementation +#include "yuv_rgb_sse.h" + +// yuv to rgb, lsx implementation +#include "yuv_rgb_lsx.h" + +#endif /* YUV_RGB_H_ */ diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_common.h b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_common.h new file mode 100644 index 0000000..a4ef8ea --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_common.h @@ -0,0 +1,15 @@ +#ifndef YUV_RGB_COMMON_H_ +#define YUV_RGB_COMMON_H_ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License + +typedef enum +{ + YCBCR_601_FULL, + YCBCR_601_LIMITED, + YCBCR_709_FULL, + YCBCR_709_LIMITED, + YCBCR_2020_NCL_FULL, +} YCbCrType; + +#endif /* YUV_RGB_COMMON_H_ */ diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_internal.h b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_internal.h new file mode 100644 index 0000000..d5939ed --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_internal.h @@ -0,0 +1,85 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License +#include "yuv_rgb.h" + +#define PRECISION 6 +#define PRECISION_FACTOR (1<[0-255]) +// for ITU-R BT.709-6 values are derived from equations in sections 3.2-3.4, assuming RGB is encoded using full range ([0-1]<->[0-255]) +// for ITU-R BT.2020 values are assuming RGB is encoded using full 10-bit range ([0-1]<->[0-1023]) +// all values are rounded to the fourth decimal + +static const YUV2RGBParam YUV2RGB[] = { + // ITU-T T.871 (JPEG) + {/*.y_shift=*/ 0, /*.y_factor=*/ V(1.0), /*.v_r_factor=*/ V(1.402), /*.u_g_factor=*/ -V(0.3441), /*.v_g_factor=*/ -V(0.7141), /*.u_b_factor=*/ V(1.772)}, + // ITU-R BT.601-7 + {/*.y_shift=*/ 16, /*.y_factor=*/ V(1.1644), /*.v_r_factor=*/ V(1.596), /*.u_g_factor=*/ -V(0.3918), /*.v_g_factor=*/ -V(0.813), /*.u_b_factor=*/ V(2.0172)}, + // ITU-R BT.709-6 full range + {/*.y_shift=*/ 0, /*.y_factor=*/ V(1.0), /*.v_r_factor=*/ V(1.581), /*.u_g_factor=*/ -V(0.1881), /*.v_g_factor=*/ -V(0.47), /*.u_b_factor=*/ V(1.8629)}, + // ITU-R BT.709-6 + {/*.y_shift=*/ 16, /*.y_factor=*/ V(1.1644), /*.v_r_factor=*/ V(1.7927), /*.u_g_factor=*/ -V(0.2132), /*.v_g_factor=*/ -V(0.5329), /*.u_b_factor=*/ V(2.1124)}, + // ITU-R BT.2020 10-bit full range + {/*.y_shift=*/ 0, /*.y_factor=*/ V(1.0), /*.v_r_factor=*/ V(1.4760), /*.u_g_factor=*/ -V(0.1647), /*.v_g_factor=*/ -V(0.5719), /*.u_b_factor=*/ V(1.8832) } +}; + +static const RGB2YUVParam RGB2YUV[] = { + // ITU-T T.871 (JPEG) + {/*.y_shift=*/ 0, /*.matrix=*/ {{V(0.299), V(0.587), V(0.114)}, {-V(0.1687), -V(0.3313), V(0.5)}, {V(0.5), -V(0.4187), -V(0.0813)}}}, + // ITU-R BT.601-7 + {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.2568), V(0.5041), V(0.0979)}, {-V(0.1482), -V(0.291), V(0.4392)}, {V(0.4392), -V(0.3678), -V(0.0714)}}}, + // ITU-R BT.709-6 full range + {/*.y_shift=*/ 0, /*.matrix=*/ {{V(0.2126), V(0.7152), V(0.0722)}, {-V(0.1141), -V(0.3839), V(0.498)}, {V(0.498), -V(0.4524), -V(0.0457)}}}, + // ITU-R BT.709-6 + {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.1826), V(0.6142), V(0.062)}, {-V(0.1006), -V(0.3386), V(0.4392)}, {V(0.4392), -V(0.3989), -V(0.0403)}}}, + // ITU-R BT.2020 10-bit full range + {/*.y_shift=*/ 0, /*.matrix=*/ {{V(0.2627), V(0.6780), V(0.0593)}, {-V(0.1395), -V(0.3600), V(0.4995)}, {V(0.4995), -V(0.4593), -V(0.0402)}}}, +}; + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +/* The various layouts of YUV data we support */ +#define YUV_FORMAT_420 1 +#define YUV_FORMAT_422 2 +#define YUV_FORMAT_NV12 3 + +/* The various formats of RGB pixel that we support */ +#define RGB_FORMAT_RGB565 1 +#define RGB_FORMAT_RGB24 2 +#define RGB_FORMAT_RGBA 3 +#define RGB_FORMAT_BGRA 4 +#define RGB_FORMAT_ARGB 5 +#define RGB_FORMAT_ABGR 6 +#define RGB_FORMAT_XBGR2101010 7 diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.c b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.c new file mode 100644 index 0000000..250ff37 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.c @@ -0,0 +1,43 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License +#include "SDL_internal.h" + +#ifdef SDL_HAVE_YUV +#include "yuv_rgb_lsx.h" +#include "yuv_rgb_internal.h" + +#ifdef SDL_LSX_INTRINSICS + +#define LSX_FUNCTION_NAME yuv420_rgb24_lsx +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_rgba_lsx +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_bgra_lsx +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_argb_lsx +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_lsx_func.h" + +#define LSX_FUNCTION_NAME yuv420_abgr_lsx +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_lsx_func.h" + +#endif // SDL_LSX_INTRINSICS + +#endif // SDL_HAVE_YUV diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.h b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.h new file mode 100644 index 0000000..1347a31 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx.h @@ -0,0 +1,36 @@ +#ifdef SDL_LSX_INTRINSICS + +#include "yuv_rgb_common.h" + +//yuv420 to bgra, lsx implementation +void yuv420_rgb24_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_lsx( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *v, const uint8_t *u, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +#endif //SDL_LSX_INTRINSICS diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx_func.h b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx_func.h new file mode 100644 index 0000000..89d582a --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_lsx_func.h @@ -0,0 +1,372 @@ +// Copyright 2016 Adrien Descamps +// // Distributed under BSD 3-Clause License + +#include + +#if YUV_FORMAT == YUV_FORMAT_420 + +#define READ_Y(y_ptr) \ + y = __lsx_vld(y_ptr, 0); \ + +#define READ_UV \ + u_temp = __lsx_vld(u_ptr, 0); \ + v_temp = __lsx_vld(v_ptr, 0); \ + +#else +#error READ_UV unimplemented +#endif + +#define PACK_RGBA_32(R1, R2, G1, G2, B1, B2, A1, A2, RGB1, RGB2, \ + RGB3, RGB4, RGB5, RGB6, RGB7, RGB8) \ +{ \ + __m128i ab_l, ab_h, gr_l, gr_h; \ + ab_l = __lsx_vilvl_b(B1, A1); \ + ab_h = __lsx_vilvh_b(B1, A1); \ + gr_l = __lsx_vilvl_b(R1, G1); \ + gr_h = __lsx_vilvh_b(R1, G1); \ + RGB1 = __lsx_vilvl_h(gr_l, ab_l); \ + RGB2 = __lsx_vilvh_h(gr_l, ab_l); \ + RGB3 = __lsx_vilvl_h(gr_h, ab_h); \ + RGB4 = __lsx_vilvh_h(gr_h, ab_h); \ + ab_l = __lsx_vilvl_b(B2, A2); \ + ab_h = __lsx_vilvh_b(B2, A2); \ + gr_l = __lsx_vilvl_b(R2, G2); \ + gr_h = __lsx_vilvh_b(R2, G2); \ + RGB5 = __lsx_vilvl_h(gr_l, ab_l); \ + RGB6 = __lsx_vilvh_h(gr_l, ab_l); \ + RGB7 = __lsx_vilvl_h(gr_h, ab_h); \ + RGB8 = __lsx_vilvh_h(gr_h, ab_h); \ +} + +#define PACK_RGB24_32_STEP(R, G, B, RGB1, RGB2, RGB3) \ + RGB1 = __lsx_vilvl_b(G, R); \ + RGB1 = __lsx_vshuf_b(B, RGB1, mask1); \ + RGB2 = __lsx_vshuf_b(B, G, mask2); \ + RGB2 = __lsx_vshuf_b(R, RGB2, mask3); \ + RGB3 = __lsx_vshuf_b(R, B, mask4); \ + RGB3 = __lsx_vshuf_b(G, RGB3, mask5); \ + +#define PACK_RGB24_32(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ + PACK_RGB24_32_STEP(R1, G1, B1, RGB1, RGB2, RGB3); \ + PACK_RGB24_32_STEP(R2, G2, B2, RGB4, RGB5, RGB6); \ + +#if RGB_FORMAT == RGB_FORMAT_RGB24 + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6; \ + __m128i rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12; \ + PACK_RGB24_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, \ + rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6) \ + PACK_RGB24_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, \ + rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12) \ + +#elif RGB_FORMAT == RGB_FORMAT_RGBA + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = __lsx_vldi(0xFF); \ + PACK_RGBA_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, a, a, \ + rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + PACK_RGBA_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, a, a, \ + rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#elif RGB_FORMAT == RGB_FORMAT_BGRA + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = __lsx_vldi(0xFF); \ + PACK_RGBA_32(b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, a, a, \ + rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + PACK_RGBA_32(b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, a, a, \ + rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#elif RGB_FORMAT == RGB_FORMAT_ARGB + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = __lsx_vldi(0xFF); \ + PACK_RGBA_32(a, a, r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, \ + rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + PACK_RGBA_32(a, a, r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, \ + rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#elif RGB_FORMAT == RGB_FORMAT_ABGR + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = __lsx_vldi(0xFF); \ + PACK_RGBA_32(a, a, b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, \ + rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + PACK_RGBA_32(a, a, b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, \ + rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#else +#error PACK_PIXEL unimplemented +#endif + +#define LSX_ST_UB2(in0, in1, pdst, stride) \ +{ \ + __lsx_vst(in0, pdst, 0); \ + __lsx_vst(in1, pdst + stride, 0); \ +} + +#if RGB_FORMAT == RGB_FORMAT_RGB24 \ + +#define SAVE_LINE1 \ + LSX_ST_UB2(rgb_1, rgb_2, rgb_ptr1, 16); \ + LSX_ST_UB2(rgb_3, rgb_4, rgb_ptr1 + 32, 16); \ + LSX_ST_UB2(rgb_5, rgb_6, rgb_ptr1 + 64, 16); \ + +#define SAVE_LINE2 \ + LSX_ST_UB2(rgb_7, rgb_8, rgb_ptr2, 16); \ + LSX_ST_UB2(rgb_9, rgb_10, rgb_ptr2 + 32, 16); \ + LSX_ST_UB2(rgb_11, rgb_12, rgb_ptr2 + 64, 16); \ + +#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT == RGB_FORMAT_BGRA || \ + RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT == RGB_FORMAT_ABGR \ + +#define SAVE_LINE1 \ + LSX_ST_UB2(rgb_1, rgb_2, rgb_ptr1, 16); \ + LSX_ST_UB2(rgb_3, rgb_4, rgb_ptr1 + 32, 16); \ + LSX_ST_UB2(rgb_5, rgb_6, rgb_ptr1 + 64, 16); \ + LSX_ST_UB2(rgb_7, rgb_8, rgb_ptr1 + 96, 16); \ + +#define SAVE_LINE2 \ + LSX_ST_UB2(rgb_9, rgb_10, rgb_ptr2, 16); \ + LSX_ST_UB2(rgb_11, rgb_12, rgb_ptr2 + 32, 16); \ + LSX_ST_UB2(rgb_13, rgb_14, rgb_ptr2 + 64, 16); \ + LSX_ST_UB2(rgb_15, rgb_16, rgb_ptr2 + 96, 16); \ + +#else +#error SAVE_LINE unimplemented +#endif + +// = u*vr g=u*ug+v*vg b=u*ub +#define UV2RGB_16(U, V, R1, G1, B1, R2, G2, B2) \ + r_temp = __lsx_vmul_h(V, v2r); \ + g_temp = __lsx_vmul_h(U, u2g); \ + g_temp = __lsx_vmadd_h(g_temp, V, v2g); \ + b_temp = __lsx_vmul_h(U, u2b); \ + R1 = __lsx_vilvl_h(r_temp, r_temp); \ + G1 = __lsx_vilvl_h(g_temp, g_temp); \ + B1 = __lsx_vilvl_h(b_temp, b_temp); \ + R2 = __lsx_vilvh_h(r_temp, r_temp); \ + G2 = __lsx_vilvh_h(g_temp, g_temp); \ + B2 = __lsx_vilvh_h(b_temp, b_temp); \ + +// Y=(Y-shift)*shift R=(Y+R)>>6,G=(Y+G)>>6,B=(B+Y)>>6 +#define ADD_Y2RGB_16(Y1, Y2, R1, G1, B1, R2, G2, B2) \ + Y1 = __lsx_vsub_h(Y1, shift); \ + Y2 = __lsx_vsub_h(Y2, shift); \ + Y1 = __lsx_vmul_h(Y1, yf); \ + Y2 = __lsx_vmul_h(Y2, yf); \ + R1 = __lsx_vadd_h(R1, Y1); \ + G1 = __lsx_vadd_h(G1, Y1); \ + B1 = __lsx_vadd_h(B1, Y1); \ + R2 = __lsx_vadd_h(R2, Y2); \ + G2 = __lsx_vadd_h(G2, Y2); \ + B2 = __lsx_vadd_h(B2, Y2); \ + R1 = __lsx_vsrai_h(R1, PRECISION); \ + G1 = __lsx_vsrai_h(G1, PRECISION); \ + B1 = __lsx_vsrai_h(B1, PRECISION); \ + R2 = __lsx_vsrai_h(R2, PRECISION); \ + G2 = __lsx_vsrai_h(G2, PRECISION); \ + B2 = __lsx_vsrai_h(B2, PRECISION); \ + +#define CLIP(in0, in1, in2, in3, in4, in5) \ +{ \ + in0 = __lsx_vmaxi_h(in0, 0); \ + in1 = __lsx_vmaxi_h(in1, 0); \ + in2 = __lsx_vmaxi_h(in2, 0); \ + in3 = __lsx_vmaxi_h(in3, 0); \ + in4 = __lsx_vmaxi_h(in4, 0); \ + in5 = __lsx_vmaxi_h(in5, 0); \ + in0 = __lsx_vsat_hu(in0, 7); \ + in1 = __lsx_vsat_hu(in1, 7); \ + in2 = __lsx_vsat_hu(in2, 7); \ + in3 = __lsx_vsat_hu(in3, 7); \ + in4 = __lsx_vsat_hu(in4, 7); \ + in5 = __lsx_vsat_hu(in5, 7); \ +} + +#define YUV2RGB_32 \ + __m128i y, u_temp, v_temp; \ + __m128i r_8_11, g_8_11, b_8_11, r_8_21, g_8_21, b_8_21; \ + __m128i r_8_12, g_8_12, b_8_12, r_8_22, g_8_22, b_8_22; \ + __m128i u, v, r_temp, g_temp, b_temp; \ + __m128i r_1, g_1, b_1, r_2, g_2, b_2; \ + __m128i y_1, y_2; \ + __m128i r_uv_1, g_uv_1, b_uv_1, r_uv_2, g_uv_2, b_uv_2; \ + \ + READ_UV \ + \ + /* process first 16 pixels of first line */ \ + u = __lsx_vilvl_b(zero, u_temp); \ + v = __lsx_vilvl_b(zero, v_temp); \ + u = __lsx_vsub_h(u, bias); \ + v = __lsx_vsub_h(v, bias); \ + UV2RGB_16(u, v, r_1, g_1, b_1, r_2, g_2, b_2); \ + r_uv_1 = r_1; g_uv_1 = g_1; b_uv_1 = b_1; \ + r_uv_2 = r_2; g_uv_2 = g_2; b_uv_2 = b_2; \ + READ_Y(y_ptr1) \ + y_1 = __lsx_vilvl_b(zero, y); \ + y_2 = __lsx_vilvh_b(zero, y); \ + ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \ + CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \ + r_8_11 = __lsx_vpickev_b(r_2, r_1); \ + g_8_11 = __lsx_vpickev_b(g_2, g_1); \ + b_8_11 = __lsx_vpickev_b(b_2, b_1); \ + \ + /* process first 16 pixels of second line */ \ + r_1 = r_uv_1; g_1 = g_uv_1; b_1 = b_uv_1; \ + r_2 = r_uv_2; g_2 = g_uv_2; b_2 = b_uv_2; \ + \ + READ_Y(y_ptr2) \ + y_1 = __lsx_vilvl_b(zero, y); \ + y_2 = __lsx_vilvh_b(zero, y); \ + ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \ + CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \ + r_8_21 = __lsx_vpickev_b(r_2, r_1); \ + g_8_21 = __lsx_vpickev_b(g_2, g_1); \ + b_8_21 = __lsx_vpickev_b(b_2, b_1); \ + \ + /* process last 16 pixels of first line */ \ + u = __lsx_vilvh_b(zero, u_temp); \ + v = __lsx_vilvh_b(zero, v_temp); \ + u = __lsx_vsub_h(u, bias); \ + v = __lsx_vsub_h(v, bias); \ + UV2RGB_16(u, v, r_1, g_1, b_1, r_2, g_2, b_2); \ + r_uv_1 = r_1; g_uv_1 = g_1; b_uv_1 = b_1; \ + r_uv_2 = r_2; g_uv_2 = g_2; b_uv_2 = b_2; \ + READ_Y(y_ptr1 + 16 * y_pixel_stride) \ + y_1 = __lsx_vilvl_b(zero, y); \ + y_2 = __lsx_vilvh_b(zero, y); \ + ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \ + CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \ + r_8_12 = __lsx_vpickev_b(r_2, r_1); \ + g_8_12 = __lsx_vpickev_b(g_2, g_1); \ + b_8_12 = __lsx_vpickev_b(b_2, b_1); \ + \ + /* process last 16 pixels of second line */ \ + r_1 = r_uv_1; g_1 = g_uv_1; b_1 = b_uv_1; \ + r_2 = r_uv_2; g_2 = g_uv_2; b_2 = b_uv_2; \ + \ + READ_Y(y_ptr2 + 16 * y_pixel_stride) \ + y_1 = __lsx_vilvl_b(zero, y); \ + y_2 = __lsx_vilvh_b(zero, y); \ + ADD_Y2RGB_16(y_1, y_2, r_1, g_1, b_1, r_2, g_2, b_2) \ + CLIP(r_1, g_1, b_1, r_2, g_2, b_2); \ + r_8_22 = __lsx_vpickev_b(r_2, r_1); \ + g_8_22 = __lsx_vpickev_b(g_2, g_1); \ + b_8_22 = __lsx_vpickev_b(b_2, b_1); \ + \ + +void LSX_FUNCTION_NAME(uint32_t width, uint32_t height, const uint8_t *Y, + const uint8_t *U, const uint8_t *V, uint32_t Y_stride, + uint32_t UV_stride, uint8_t *RGB, uint32_t RGB_stride, + YCbCrType yuv_type) +{ + const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]); +#if YUV_FORMAT == YUV_FORMAT_420 + const int y_pixel_stride = 1; + const int uv_pixel_stride = 1; + const int uv_x_sample_interval = 2; + const int uv_y_sample_interval = 2; +#endif + +#if RGB_FORMAT == RGB_FORMAT_RGB565 + const int rgb_pixel_stride = 2; +#elif RGB_FORMAT == RGB_FORMAT_RGB24 + const int rgb_pixel_stride = 3; + __m128i mask1 = {0x0504110302100100, 0x0A14090813070612}; + __m128i mask2 = {0x1808170716061505, 0x00000000000A1909}; + __m128i mask3 = {0x0504170302160100, 0x0A1A090819070618}; + __m128i mask4 = {0x1E0D1D0C1C0B1B0A, 0x00000000000F1F0E}; + __m128i mask5 = {0x05041C03021B0100, 0x0A1F09081E07061D}; +#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT_BGRA || \ + RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT_ABGR + const int rgb_pixel_stride = 4; +#else +#error Unknown RGB pixel size +#endif + + uint32_t xpos, ypos; + __m128i v2r = __lsx_vreplgr2vr_h(param->v_r_factor); + __m128i v2g = __lsx_vreplgr2vr_h(param->v_g_factor); + __m128i u2g = __lsx_vreplgr2vr_h(param->u_g_factor); + __m128i u2b = __lsx_vreplgr2vr_h(param->u_b_factor); + __m128i bias = __lsx_vreplgr2vr_h(128); + __m128i shift = __lsx_vreplgr2vr_h(param->y_shift); + __m128i yf = __lsx_vreplgr2vr_h(param->y_factor); + __m128i zero = __lsx_vldi(0); + + if (width >= 32) { + for (ypos = 0; ypos < (height - (uv_y_sample_interval - 1)); ypos += uv_y_sample_interval) { + const uint8_t *y_ptr1 = Y + ypos * Y_stride, + *y_ptr2 = Y + (ypos + 1) * Y_stride, + *u_ptr = U + (ypos/uv_y_sample_interval) * UV_stride, + *v_ptr = V + (ypos/uv_y_sample_interval) * UV_stride; + uint8_t *rgb_ptr1 = RGB + ypos * RGB_stride, + *rgb_ptr2 = RGB + (ypos + 1) * RGB_stride; + + for (xpos = 0; xpos < (width - 31); xpos += 32){ + YUV2RGB_32 + { + PACK_PIXEL + SAVE_LINE1 + if (uv_y_sample_interval > 1) + { + SAVE_LINE2 + } + } + y_ptr1 += 32 * y_pixel_stride; + y_ptr2 += 32 * y_pixel_stride; + u_ptr += 32 * uv_pixel_stride/uv_x_sample_interval; + v_ptr += 32 * uv_pixel_stride/uv_x_sample_interval; + rgb_ptr1 += 32 * rgb_pixel_stride; + rgb_ptr2 += 32 * rgb_pixel_stride; + } + } + if (uv_y_sample_interval == 2 && ypos == (height - 1)) { + const uint8_t *y_ptr = Y + ypos * Y_stride, + *u_ptr = U + (ypos/uv_y_sample_interval) * UV_stride, + *v_ptr = V + (ypos/uv_y_sample_interval) * UV_stride; + uint8_t *rgb_ptr = RGB + ypos * RGB_stride; + STD_FUNCTION_NAME(width, 1, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type); + } + } + { + int converted = (width & ~31); + if (converted != width) + { + const uint8_t *y_ptr = Y + converted * y_pixel_stride, + *u_ptr = U + converted * uv_pixel_stride / uv_x_sample_interval, + *v_ptr = V + converted * uv_pixel_stride / uv_x_sample_interval; + uint8_t *rgb_ptr = RGB + converted * rgb_pixel_stride; + + STD_FUNCTION_NAME(width-converted, height, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type); + } + } +} + +#undef LSX_FUNCTION_NAME +#undef STD_FUNCTION_NAME +#undef YUV_FORMAT +#undef RGB_FORMAT +#undef LSX_ALIGNED +#undef LSX_ST_UB2 +#undef UV2RGB_16 +#undef ADD_Y2RGB_16 +#undef PACK_RGB24_32_STEP +#undef PACK_RGB24_32 +#undef PACK_PIXEL +#undef PACK_RGBA_32 +#undef SAVE_LINE1 +#undef SAVE_LINE2 +#undef READ_Y +#undef READ_UV +#undef YUV2RGB_32 diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse.c b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse.c new file mode 100644 index 0000000..37fe7e4 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_sse.c @@ -0,0 +1,460 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License +#include "SDL_internal.h" + +#ifdef SDL_HAVE_YUV +#include "yuv_rgb_internal.h" + +#ifdef SDL_SSE2_INTRINSICS + +/* SDL doesn't use these atm and compiling them adds seconds onto the build. --ryan. +#define SSE_FUNCTION_NAME yuv420_rgb565_sse +#define STD_FUNCTION_NAME yuv420_rgb565_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgb24_sse +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgba_sse +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_bgra_sse +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_argb_sse +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_abgr_sse +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb565_sse +#define STD_FUNCTION_NAME yuv422_rgb565_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb24_sse +#define STD_FUNCTION_NAME yuv422_rgb24_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgba_sse +#define STD_FUNCTION_NAME yuv422_rgba_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGBA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_bgra_sse +#define STD_FUNCTION_NAME yuv422_bgra_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_BGRA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_argb_sse +#define STD_FUNCTION_NAME yuv422_argb_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ARGB +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_abgr_sse +#define STD_FUNCTION_NAME yuv422_abgr_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ABGR +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb565_sse +#define STD_FUNCTION_NAME yuvnv12_rgb565_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb24_sse +#define STD_FUNCTION_NAME yuvnv12_rgb24_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgba_sse +#define STD_FUNCTION_NAME yuvnv12_rgba_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGBA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_bgra_sse +#define STD_FUNCTION_NAME yuvnv12_bgra_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_BGRA +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_argb_sse +#define STD_FUNCTION_NAME yuvnv12_argb_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ARGB +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_abgr_sse +#define STD_FUNCTION_NAME yuvnv12_abgr_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ABGR +#define SSE_ALIGNED +#include "yuv_rgb_sse_func.h" +*/ + +#define SSE_FUNCTION_NAME yuv420_rgb565_sseu +#define STD_FUNCTION_NAME yuv420_rgb565_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgb24_sseu +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_rgba_sseu +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_bgra_sseu +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_argb_sseu +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv420_abgr_sseu +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb565_sseu +#define STD_FUNCTION_NAME yuv422_rgb565_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgb24_sseu +#define STD_FUNCTION_NAME yuv422_rgb24_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_rgba_sseu +#define STD_FUNCTION_NAME yuv422_rgba_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_bgra_sseu +#define STD_FUNCTION_NAME yuv422_bgra_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_argb_sseu +#define STD_FUNCTION_NAME yuv422_argb_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuv422_abgr_sseu +#define STD_FUNCTION_NAME yuv422_abgr_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb565_sseu +#define STD_FUNCTION_NAME yuvnv12_rgb565_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgb24_sseu +#define STD_FUNCTION_NAME yuvnv12_rgb24_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_rgba_sseu +#define STD_FUNCTION_NAME yuvnv12_rgba_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_bgra_sseu +#define STD_FUNCTION_NAME yuvnv12_bgra_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_argb_sseu +#define STD_FUNCTION_NAME yuvnv12_argb_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_sse_func.h" + +#define SSE_FUNCTION_NAME yuvnv12_abgr_sseu +#define STD_FUNCTION_NAME yuvnv12_abgr_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_sse_func.h" + + +/* SDL doesn't use these atm and compiling them adds seconds onto the build. --ryan. +#define UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +R1 = _mm_unpacklo_epi8(RGB1, RGB4); \ +R2 = _mm_unpackhi_epi8(RGB1, RGB4); \ +G1 = _mm_unpacklo_epi8(RGB2, RGB5); \ +G2 = _mm_unpackhi_epi8(RGB2, RGB5); \ +B1 = _mm_unpacklo_epi8(RGB3, RGB6); \ +B2 = _mm_unpackhi_epi8(RGB3, RGB6); + +#define UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +RGB1 = _mm_unpacklo_epi8(R1, G2); \ +RGB2 = _mm_unpackhi_epi8(R1, G2); \ +RGB3 = _mm_unpacklo_epi8(R2, B1); \ +RGB4 = _mm_unpackhi_epi8(R2, B1); \ +RGB5 = _mm_unpacklo_epi8(G1, B2); \ +RGB6 = _mm_unpackhi_epi8(G1, B2); \ + +#define UNPACK_RGB24_32(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ +UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \ + +#define RGB2YUV_16(R, G, B, Y, U, V) \ +Y = _mm_add_epi16(_mm_mullo_epi16(R, _mm_set1_epi16(param->matrix[0][0])), \ + _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[0][1]))); \ +Y = _mm_add_epi16(Y, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[0][2]))); \ +Y = _mm_add_epi16(Y, _mm_set1_epi16((param->y_shift)<matrix[1][0])), \ + _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[1][1]))); \ +U = _mm_add_epi16(U, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[1][2]))); \ +U = _mm_add_epi16(U, _mm_set1_epi16(128<matrix[2][0])), \ + _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[2][1]))); \ +V = _mm_add_epi16(V, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[2][2]))); \ +V = _mm_add_epi16(V, _mm_set1_epi16(128<v_r_factor)); \ + g_tmp = _mm_add_epi16( \ + _mm_mullo_epi16(U, _mm_set1_epi16(param->u_g_factor)), \ + _mm_mullo_epi16(V, _mm_set1_epi16(param->v_g_factor))); \ + b_tmp = _mm_mullo_epi16(U, _mm_set1_epi16(param->u_b_factor)); \ + R1 = _mm_unpacklo_epi16(r_tmp, r_tmp); \ + G1 = _mm_unpacklo_epi16(g_tmp, g_tmp); \ + B1 = _mm_unpacklo_epi16(b_tmp, b_tmp); \ + R2 = _mm_unpackhi_epi16(r_tmp, r_tmp); \ + G2 = _mm_unpackhi_epi16(g_tmp, g_tmp); \ + B2 = _mm_unpackhi_epi16(b_tmp, b_tmp); \ + +#define ADD_Y2RGB_16(Y1,Y2,R1,G1,B1,R2,G2,B2) \ + Y1 = _mm_mullo_epi16(_mm_sub_epi16(Y1, _mm_set1_epi16(param->y_shift)), _mm_set1_epi16(param->y_factor)); \ + Y2 = _mm_mullo_epi16(_mm_sub_epi16(Y2, _mm_set1_epi16(param->y_shift)), _mm_set1_epi16(param->y_factor)); \ + \ + R1 = _mm_srai_epi16(_mm_add_epi16(R1, Y1), PRECISION); \ + G1 = _mm_srai_epi16(_mm_add_epi16(G1, Y1), PRECISION); \ + B1 = _mm_srai_epi16(_mm_add_epi16(B1, Y1), PRECISION); \ + R2 = _mm_srai_epi16(_mm_add_epi16(R2, Y2), PRECISION); \ + G2 = _mm_srai_epi16(_mm_add_epi16(G2, Y2), PRECISION); \ + B2 = _mm_srai_epi16(_mm_add_epi16(B2, Y2), PRECISION); \ + +#define PACK_RGB565_32(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4) \ +{ \ + __m128i red_mask, tmp1, tmp2, tmp3, tmp4; \ +\ + red_mask = _mm_set1_epi16((unsigned short)0xF800); \ + RGB1 = _mm_and_si128(_mm_unpacklo_epi8(_mm_setzero_si128(), R1), red_mask); \ + RGB2 = _mm_and_si128(_mm_unpackhi_epi8(_mm_setzero_si128(), R1), red_mask); \ + RGB3 = _mm_and_si128(_mm_unpacklo_epi8(_mm_setzero_si128(), R2), red_mask); \ + RGB4 = _mm_and_si128(_mm_unpackhi_epi8(_mm_setzero_si128(), R2), red_mask); \ + tmp1 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpacklo_epi8(G1, _mm_setzero_si128()), 2), 5); \ + tmp2 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpackhi_epi8(G1, _mm_setzero_si128()), 2), 5); \ + tmp3 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpacklo_epi8(G2, _mm_setzero_si128()), 2), 5); \ + tmp4 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpackhi_epi8(G2, _mm_setzero_si128()), 2), 5); \ + RGB1 = _mm_or_si128(RGB1, tmp1); \ + RGB2 = _mm_or_si128(RGB2, tmp2); \ + RGB3 = _mm_or_si128(RGB3, tmp3); \ + RGB4 = _mm_or_si128(RGB4, tmp4); \ + tmp1 = _mm_srli_epi16(_mm_unpacklo_epi8(B1, _mm_setzero_si128()), 3); \ + tmp2 = _mm_srli_epi16(_mm_unpackhi_epi8(B1, _mm_setzero_si128()), 3); \ + tmp3 = _mm_srli_epi16(_mm_unpacklo_epi8(B2, _mm_setzero_si128()), 3); \ + tmp4 = _mm_srli_epi16(_mm_unpackhi_epi8(B2, _mm_setzero_si128()), 3); \ + RGB1 = _mm_or_si128(RGB1, tmp1); \ + RGB2 = _mm_or_si128(RGB2, tmp2); \ + RGB3 = _mm_or_si128(RGB3, tmp3); \ + RGB4 = _mm_or_si128(RGB4, tmp4); \ +} + +#define PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ +RGB1 = _mm_packus_epi16(_mm_and_si128(R1,_mm_set1_epi16(0xFF)), _mm_and_si128(R2,_mm_set1_epi16(0xFF))); \ +RGB2 = _mm_packus_epi16(_mm_and_si128(G1,_mm_set1_epi16(0xFF)), _mm_and_si128(G2,_mm_set1_epi16(0xFF))); \ +RGB3 = _mm_packus_epi16(_mm_and_si128(B1,_mm_set1_epi16(0xFF)), _mm_and_si128(B2,_mm_set1_epi16(0xFF))); \ +RGB4 = _mm_packus_epi16(_mm_srli_epi16(R1,8), _mm_srli_epi16(R2,8)); \ +RGB5 = _mm_packus_epi16(_mm_srli_epi16(G1,8), _mm_srli_epi16(G2,8)); \ +RGB6 = _mm_packus_epi16(_mm_srli_epi16(B1,8), _mm_srli_epi16(B2,8)); \ + +#define PACK_RGB24_32_STEP2(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ +R1 = _mm_packus_epi16(_mm_and_si128(RGB1,_mm_set1_epi16(0xFF)), _mm_and_si128(RGB2,_mm_set1_epi16(0xFF))); \ +R2 = _mm_packus_epi16(_mm_and_si128(RGB3,_mm_set1_epi16(0xFF)), _mm_and_si128(RGB4,_mm_set1_epi16(0xFF))); \ +G1 = _mm_packus_epi16(_mm_and_si128(RGB5,_mm_set1_epi16(0xFF)), _mm_and_si128(RGB6,_mm_set1_epi16(0xFF))); \ +G2 = _mm_packus_epi16(_mm_srli_epi16(RGB1,8), _mm_srli_epi16(RGB2,8)); \ +B1 = _mm_packus_epi16(_mm_srli_epi16(RGB3,8), _mm_srli_epi16(RGB4,8)); \ +B2 = _mm_packus_epi16(_mm_srli_epi16(RGB5,8), _mm_srli_epi16(RGB6,8)); \ + +#define PACK_RGB24_32(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ +PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ +PACK_RGB24_32_STEP2(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ +PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ +PACK_RGB24_32_STEP2(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ +PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \ + +#define PACK_RGBA_32(R1, R2, G1, G2, B1, B2, A1, A2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, RGB7, RGB8) \ +{ \ + __m128i lo_ab, hi_ab, lo_gr, hi_gr; \ +\ + lo_ab = _mm_unpacklo_epi8( A1, B1 ); \ + hi_ab = _mm_unpackhi_epi8( A1, B1 ); \ + lo_gr = _mm_unpacklo_epi8( G1, R1 ); \ + hi_gr = _mm_unpackhi_epi8( G1, R1 ); \ + RGB1 = _mm_unpacklo_epi16( lo_ab, lo_gr ); \ + RGB2 = _mm_unpackhi_epi16( lo_ab, lo_gr ); \ + RGB3 = _mm_unpacklo_epi16( hi_ab, hi_gr ); \ + RGB4 = _mm_unpackhi_epi16( hi_ab, hi_gr ); \ +\ + lo_ab = _mm_unpacklo_epi8( A2, B2 ); \ + hi_ab = _mm_unpackhi_epi8( A2, B2 ); \ + lo_gr = _mm_unpacklo_epi8( G2, R2 ); \ + hi_gr = _mm_unpackhi_epi8( G2, R2 ); \ + RGB5 = _mm_unpacklo_epi16( lo_ab, lo_gr ); \ + RGB6 = _mm_unpackhi_epi16( lo_ab, lo_gr ); \ + RGB7 = _mm_unpacklo_epi16( hi_ab, hi_gr ); \ + RGB8 = _mm_unpackhi_epi16( hi_ab, hi_gr ); \ +} + +#if RGB_FORMAT == RGB_FORMAT_RGB565 + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + \ + PACK_RGB565_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, rgb_1, rgb_2, rgb_3, rgb_4) \ + \ + PACK_RGB565_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, rgb_5, rgb_6, rgb_7, rgb_8) \ + +#elif RGB_FORMAT == RGB_FORMAT_RGB24 + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6; \ + __m128i rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12; \ + \ + PACK_RGB24_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6) \ + \ + PACK_RGB24_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12) \ + +#elif RGB_FORMAT == RGB_FORMAT_RGBA + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ + \ + PACK_RGBA_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, a, a, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + \ + PACK_RGBA_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, a, a, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#elif RGB_FORMAT == RGB_FORMAT_BGRA + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ + \ + PACK_RGBA_32(b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, a, a, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + \ + PACK_RGBA_32(b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, a, a, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#elif RGB_FORMAT == RGB_FORMAT_ARGB + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ + \ + PACK_RGBA_32(a, a, r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + \ + PACK_RGBA_32(a, a, r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#elif RGB_FORMAT == RGB_FORMAT_ABGR + +#define PACK_PIXEL \ + __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \ + __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \ + __m128i a = _mm_set1_epi8((unsigned char)0xFF); \ + \ + PACK_RGBA_32(a, a, b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \ + \ + PACK_RGBA_32(a, a, b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \ + +#else +#error PACK_PIXEL unimplemented +#endif + +#if RGB_FORMAT == RGB_FORMAT_RGB565 + +#define SAVE_LINE1 \ + SAVE_SI128((__m128i*)(rgb_ptr1), rgb_1); \ + SAVE_SI128((__m128i*)(rgb_ptr1+16), rgb_2); \ + SAVE_SI128((__m128i*)(rgb_ptr1+32), rgb_3); \ + SAVE_SI128((__m128i*)(rgb_ptr1+48), rgb_4); \ + +#define SAVE_LINE2 \ + SAVE_SI128((__m128i*)(rgb_ptr2), rgb_5); \ + SAVE_SI128((__m128i*)(rgb_ptr2+16), rgb_6); \ + SAVE_SI128((__m128i*)(rgb_ptr2+32), rgb_7); \ + SAVE_SI128((__m128i*)(rgb_ptr2+48), rgb_8); \ + +#elif RGB_FORMAT == RGB_FORMAT_RGB24 + +#define SAVE_LINE1 \ + SAVE_SI128((__m128i*)(rgb_ptr1), rgb_1); \ + SAVE_SI128((__m128i*)(rgb_ptr1+16), rgb_2); \ + SAVE_SI128((__m128i*)(rgb_ptr1+32), rgb_3); \ + SAVE_SI128((__m128i*)(rgb_ptr1+48), rgb_4); \ + SAVE_SI128((__m128i*)(rgb_ptr1+64), rgb_5); \ + SAVE_SI128((__m128i*)(rgb_ptr1+80), rgb_6); \ + +#define SAVE_LINE2 \ + SAVE_SI128((__m128i*)(rgb_ptr2), rgb_7); \ + SAVE_SI128((__m128i*)(rgb_ptr2+16), rgb_8); \ + SAVE_SI128((__m128i*)(rgb_ptr2+32), rgb_9); \ + SAVE_SI128((__m128i*)(rgb_ptr2+48), rgb_10); \ + SAVE_SI128((__m128i*)(rgb_ptr2+64), rgb_11); \ + SAVE_SI128((__m128i*)(rgb_ptr2+80), rgb_12); \ + +#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT == RGB_FORMAT_BGRA || \ + RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT == RGB_FORMAT_ABGR + +#define SAVE_LINE1 \ + SAVE_SI128((__m128i*)(rgb_ptr1), rgb_1); \ + SAVE_SI128((__m128i*)(rgb_ptr1+16), rgb_2); \ + SAVE_SI128((__m128i*)(rgb_ptr1+32), rgb_3); \ + SAVE_SI128((__m128i*)(rgb_ptr1+48), rgb_4); \ + SAVE_SI128((__m128i*)(rgb_ptr1+64), rgb_5); \ + SAVE_SI128((__m128i*)(rgb_ptr1+80), rgb_6); \ + SAVE_SI128((__m128i*)(rgb_ptr1+96), rgb_7); \ + SAVE_SI128((__m128i*)(rgb_ptr1+112), rgb_8); \ + +#define SAVE_LINE2 \ + SAVE_SI128((__m128i*)(rgb_ptr2), rgb_9); \ + SAVE_SI128((__m128i*)(rgb_ptr2+16), rgb_10); \ + SAVE_SI128((__m128i*)(rgb_ptr2+32), rgb_11); \ + SAVE_SI128((__m128i*)(rgb_ptr2+48), rgb_12); \ + SAVE_SI128((__m128i*)(rgb_ptr2+64), rgb_13); \ + SAVE_SI128((__m128i*)(rgb_ptr2+80), rgb_14); \ + SAVE_SI128((__m128i*)(rgb_ptr2+96), rgb_15); \ + SAVE_SI128((__m128i*)(rgb_ptr2+112), rgb_16); \ + +#else +#error SAVE_LINE unimplemented +#endif + +#if YUV_FORMAT == YUV_FORMAT_420 + +#define READ_Y(y_ptr) \ + y = LOAD_SI128((const __m128i*)(y_ptr)); \ + +#define READ_UV \ + u = LOAD_SI128((const __m128i*)(u_ptr)); \ + v = LOAD_SI128((const __m128i*)(v_ptr)); \ + +#elif YUV_FORMAT == YUV_FORMAT_422 + +#define READ_Y(y_ptr) \ +{ \ + __m128i y1, y2; \ + y1 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(y_ptr)), 8), 8); \ + y2 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(y_ptr+16)), 8), 8); \ + y = _mm_packus_epi16(y1, y2); \ +} + +#define READ_UV \ +{ \ + __m128i u1, u2, u3, u4, v1, v2, v3, v4; \ + u1 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr)), 24), 24); \ + u2 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr+16)), 24), 24); \ + u3 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr+32)), 24), 24); \ + u4 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr+48)), 24), 24); \ + u = _mm_packus_epi16(_mm_packs_epi32(u1, u2), _mm_packs_epi32(u3, u4)); \ + v1 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr)), 24), 24); \ + v2 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr+16)), 24), 24); \ + v3 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr+32)), 24), 24); \ + v4 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr+48)), 24), 24); \ + v = _mm_packus_epi16(_mm_packs_epi32(v1, v2), _mm_packs_epi32(v3, v4)); \ +} + +#elif YUV_FORMAT == YUV_FORMAT_NV12 + +#define READ_Y(y_ptr) \ + y = LOAD_SI128((const __m128i*)(y_ptr)); \ + +#define READ_UV \ +{ \ + __m128i u1, u2, v1, v2; \ + u1 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(u_ptr)), 8), 8); \ + u2 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(u_ptr+16)), 8), 8); \ + u = _mm_packus_epi16(u1, u2); \ + v1 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(v_ptr)), 8), 8); \ + v2 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(v_ptr+16)), 8), 8); \ + v = _mm_packus_epi16(v1, v2); \ +} + +#else +#error READ_UV unimplemented +#endif + +#define YUV2RGB_32 \ + __m128i r_tmp, g_tmp, b_tmp; \ + __m128i r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2; \ + __m128i r_uv_16_1, g_uv_16_1, b_uv_16_1, r_uv_16_2, g_uv_16_2, b_uv_16_2; \ + __m128i y_16_1, y_16_2; \ + __m128i y, u, v, u_16, v_16; \ + __m128i r_8_11, g_8_11, b_8_11, r_8_21, g_8_21, b_8_21; \ + __m128i r_8_12, g_8_12, b_8_12, r_8_22, g_8_22, b_8_22; \ + \ + READ_UV \ + \ + /* process first 16 pixels of first line */\ + u_16 = _mm_unpacklo_epi8(u, _mm_setzero_si128()); \ + v_16 = _mm_unpacklo_epi8(v, _mm_setzero_si128()); \ + u_16 = _mm_add_epi16(u_16, _mm_set1_epi16(-128)); \ + v_16 = _mm_add_epi16(v_16, _mm_set1_epi16(-128)); \ + \ + UV2RGB_16(u_16, v_16, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \ + r_uv_16_1=r_16_1; g_uv_16_1=g_16_1; b_uv_16_1=b_16_1; \ + r_uv_16_2=r_16_2; g_uv_16_2=g_16_2; b_uv_16_2=b_16_2; \ + \ + READ_Y(y_ptr1) \ + y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \ + y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \ + \ + ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \ + \ + r_8_11 = _mm_packus_epi16(r_16_1, r_16_2); \ + g_8_11 = _mm_packus_epi16(g_16_1, g_16_2); \ + b_8_11 = _mm_packus_epi16(b_16_1, b_16_2); \ + \ + /* process first 16 pixels of second line */\ + r_16_1=r_uv_16_1; g_16_1=g_uv_16_1; b_16_1=b_uv_16_1; \ + r_16_2=r_uv_16_2; g_16_2=g_uv_16_2; b_16_2=b_uv_16_2; \ + \ + READ_Y(y_ptr2) \ + y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \ + y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \ + \ + ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \ + \ + r_8_21 = _mm_packus_epi16(r_16_1, r_16_2); \ + g_8_21 = _mm_packus_epi16(g_16_1, g_16_2); \ + b_8_21 = _mm_packus_epi16(b_16_1, b_16_2); \ + \ + /* process last 16 pixels of first line */\ + u_16 = _mm_unpackhi_epi8(u, _mm_setzero_si128()); \ + v_16 = _mm_unpackhi_epi8(v, _mm_setzero_si128()); \ + u_16 = _mm_add_epi16(u_16, _mm_set1_epi16(-128)); \ + v_16 = _mm_add_epi16(v_16, _mm_set1_epi16(-128)); \ + \ + UV2RGB_16(u_16, v_16, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \ + r_uv_16_1=r_16_1; g_uv_16_1=g_16_1; b_uv_16_1=b_16_1; \ + r_uv_16_2=r_16_2; g_uv_16_2=g_16_2; b_uv_16_2=b_16_2; \ + \ + READ_Y(y_ptr1+16*y_pixel_stride) \ + y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \ + y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \ + \ + ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \ + \ + r_8_12 = _mm_packus_epi16(r_16_1, r_16_2); \ + g_8_12 = _mm_packus_epi16(g_16_1, g_16_2); \ + b_8_12 = _mm_packus_epi16(b_16_1, b_16_2); \ + \ + /* process last 16 pixels of second line */\ + r_16_1=r_uv_16_1; g_16_1=g_uv_16_1; b_16_1=b_uv_16_1; \ + r_16_2=r_uv_16_2; g_16_2=g_uv_16_2; b_16_2=b_uv_16_2; \ + \ + READ_Y(y_ptr2+16*y_pixel_stride) \ + y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \ + y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \ + \ + ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \ + \ + r_8_22 = _mm_packus_epi16(r_16_1, r_16_2); \ + g_8_22 = _mm_packus_epi16(g_16_1, g_16_2); \ + b_8_22 = _mm_packus_epi16(b_16_1, b_16_2); \ + \ + + +void SDL_TARGETING("sse2") SSE_FUNCTION_NAME(uint32_t width, uint32_t height, + const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, + uint8_t *RGB, uint32_t RGB_stride, + YCbCrType yuv_type) +{ + const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]); +#if YUV_FORMAT == YUV_FORMAT_420 + const int y_pixel_stride = 1; + const int uv_pixel_stride = 1; + const int uv_x_sample_interval = 2; + const int uv_y_sample_interval = 2; +#elif YUV_FORMAT == YUV_FORMAT_422 + const int y_pixel_stride = 2; + const int uv_pixel_stride = 4; + const int uv_x_sample_interval = 2; + const int uv_y_sample_interval = 1; +#elif YUV_FORMAT == YUV_FORMAT_NV12 + const int y_pixel_stride = 1; + const int uv_pixel_stride = 2; + const int uv_x_sample_interval = 2; + const int uv_y_sample_interval = 2; +#endif +#if RGB_FORMAT == RGB_FORMAT_RGB565 + const int rgb_pixel_stride = 2; +#elif RGB_FORMAT == RGB_FORMAT_RGB24 + const int rgb_pixel_stride = 3; +#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT == RGB_FORMAT_BGRA || \ + RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT == RGB_FORMAT_ABGR + const int rgb_pixel_stride = 4; +#else +#error Unknown RGB pixel size +#endif + +#if YUV_FORMAT == YUV_FORMAT_NV12 + /* For NV12 formats (where U/V are interleaved) + * SSE READ_UV does an invalid read access at the very last pixel. + * As a workaround. Make sure not to decode the last column using assembly but with STD fallback path. + * see https://github.com/libsdl-org/SDL/issues/4841 + */ + const int fix_read_nv12 = ((width & 31) == 0); +#else + const int fix_read_nv12 = 0; +#endif + +#if YUV_FORMAT == YUV_FORMAT_422 + /* Avoid invalid read on last line */ + const int fix_read_422 = 1; +#else + const int fix_read_422 = 0; +#endif + + + if (width >= 32) { + uint32_t xpos, ypos; + for(ypos=0; ypos<(height-(uv_y_sample_interval-1)) - fix_read_422; ypos+=uv_y_sample_interval) + { + const uint8_t *y_ptr1=Y+ypos*Y_stride, + *y_ptr2=Y+(ypos+1)*Y_stride, + *u_ptr=U+(ypos/uv_y_sample_interval)*UV_stride, + *v_ptr=V+(ypos/uv_y_sample_interval)*UV_stride; + + uint8_t *rgb_ptr1=RGB+ypos*RGB_stride, + *rgb_ptr2=RGB+(ypos+1)*RGB_stride; + + for(xpos=0; xpos<(width-31) - fix_read_nv12; xpos+=32) + { + YUV2RGB_32 + { + PACK_PIXEL + SAVE_LINE1 + if (uv_y_sample_interval > 1) + { + SAVE_LINE2 + } + } + + y_ptr1+=32*y_pixel_stride; + y_ptr2+=32*y_pixel_stride; + u_ptr+=32*uv_pixel_stride/uv_x_sample_interval; + v_ptr+=32*uv_pixel_stride/uv_x_sample_interval; + rgb_ptr1+=32*rgb_pixel_stride; + rgb_ptr2+=32*rgb_pixel_stride; + } + } + + if (fix_read_422) { + const uint8_t *y_ptr=Y+ypos*Y_stride, + *u_ptr=U+(ypos/uv_y_sample_interval)*UV_stride, + *v_ptr=V+(ypos/uv_y_sample_interval)*UV_stride; + uint8_t *rgb_ptr=RGB+ypos*RGB_stride; + STD_FUNCTION_NAME(width, 1, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type); + ypos += uv_y_sample_interval; + } + + /* Catch the last line, if needed */ + if (uv_y_sample_interval == 2 && ypos == (height-1)) + { + const uint8_t *y_ptr=Y+ypos*Y_stride, + *u_ptr=U+(ypos/uv_y_sample_interval)*UV_stride, + *v_ptr=V+(ypos/uv_y_sample_interval)*UV_stride; + + uint8_t *rgb_ptr=RGB+ypos*RGB_stride; + + STD_FUNCTION_NAME(width, 1, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type); + } + } + + /* Catch the right column, if needed */ + { + uint32_t converted = (width & ~31); + if (fix_read_nv12) { + converted -= 32; + } + if (converted != width) + { + const uint8_t *y_ptr=Y+converted*y_pixel_stride, + *u_ptr=U+converted*uv_pixel_stride/uv_x_sample_interval, + *v_ptr=V+converted*uv_pixel_stride/uv_x_sample_interval; + + uint8_t *rgb_ptr=RGB+converted*rgb_pixel_stride; + + STD_FUNCTION_NAME(width-converted, height, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type); + } + } +} + +#undef SSE_FUNCTION_NAME +#undef STD_FUNCTION_NAME +#undef YUV_FORMAT +#undef RGB_FORMAT +#undef SSE_ALIGNED +#undef LOAD_SI128 +#undef SAVE_SI128 +#undef UV2RGB_16 +#undef ADD_Y2RGB_16 +#undef PACK_RGB24_32_STEP1 +#undef PACK_RGB24_32_STEP2 +#undef PACK_RGB24_32 +#undef PACK_RGBA_32 +#undef PACK_PIXEL +#undef SAVE_LINE1 +#undef SAVE_LINE2 +#undef READ_Y +#undef READ_UV +#undef YUV2RGB_32 diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std.c b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std.c new file mode 100644 index 0000000..0fa900d --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std.c @@ -0,0 +1,200 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License +#include "SDL_internal.h" + +#ifdef SDL_HAVE_YUV + +#include "yuv_rgb_internal.h" + +// divide by PRECISION_FACTOR and clamp to [0:255] interval +// input must be in the [-128*PRECISION_FACTOR:384*PRECISION_FACTOR] range +static uint8_t clampU8(int32_t v) +{ + static const uint8_t lut[512] = + {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46, + 47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90, + 91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125, + 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158, + 159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191, + 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224, + 225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, + 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255 + }; + return lut[((v+128*PRECISION_FACTOR)>>PRECISION)&511]; +} + +static uint16_t clamp10(int32_t v) +{ + v >>= PRECISION; + if (v < 0) { + return 0; + } else if (v > 1023) { + return 1023; + } else { + return (uint16_t)v; + } +} + +#define YUV_BITS 8 + +#define STD_FUNCTION_NAME yuv420_rgb565_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_rgb24_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_rgba_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_bgra_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_argb_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv420_abgr_std +#define YUV_FORMAT YUV_FORMAT_420 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_rgb565_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_rgb24_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_rgba_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_bgra_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_argb_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuv422_abgr_std +#define YUV_FORMAT YUV_FORMAT_422 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_rgb565_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB565 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_rgb24_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGB24 +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_rgba_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_RGBA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_bgra_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_BGRA +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_argb_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ARGB +#include "yuv_rgb_std_func.h" + +#define STD_FUNCTION_NAME yuvnv12_abgr_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_ABGR +#include "yuv_rgb_std_func.h" + +#undef YUV_BITS +#define YUV_BITS 10 + +#define STD_FUNCTION_NAME yuvp010_xbgr2101010_std +#define YUV_FORMAT YUV_FORMAT_NV12 +#define RGB_FORMAT RGB_FORMAT_XBGR2101010 +#include "yuv_rgb_std_func.h" + +void rgb24_yuv420_std( + uint32_t width, uint32_t height, + const uint8_t *RGB, uint32_t RGB_stride, + uint8_t *Y, uint8_t *U, uint8_t *V, uint32_t Y_stride, uint32_t UV_stride, + YCbCrType yuv_type) +{ + const RGB2YUVParam *const param = &(RGB2YUV[yuv_type]); + + uint32_t x, y; + for(y=0; y<(height-1); y+=2) + { + const uint8_t *rgb_ptr1=RGB+y*RGB_stride, + *rgb_ptr2=RGB+(y+1)*RGB_stride; + + uint8_t *y_ptr1=Y+y*Y_stride, + *y_ptr2=Y+(y+1)*Y_stride, + *u_ptr=U+(y/2)*UV_stride, + *v_ptr=V+(y/2)*UV_stride; + + for(x=0; x<(width-1); x+=2) + { + // compute yuv for the four pixels, u and v values are summed + int32_t y_tmp, u_tmp, v_tmp; + + y_tmp = param->matrix[0][0]*rgb_ptr1[0] + param->matrix[0][1]*rgb_ptr1[1] + param->matrix[0][2]*rgb_ptr1[2]; + u_tmp = param->matrix[1][0]*rgb_ptr1[0] + param->matrix[1][1]*rgb_ptr1[1] + param->matrix[1][2]*rgb_ptr1[2]; + v_tmp = param->matrix[2][0]*rgb_ptr1[0] + param->matrix[2][1]*rgb_ptr1[1] + param->matrix[2][2]*rgb_ptr1[2]; + y_ptr1[0]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr1[3] + param->matrix[0][1]*rgb_ptr1[4] + param->matrix[0][2]*rgb_ptr1[5]; + u_tmp += param->matrix[1][0]*rgb_ptr1[3] + param->matrix[1][1]*rgb_ptr1[4] + param->matrix[1][2]*rgb_ptr1[5]; + v_tmp += param->matrix[2][0]*rgb_ptr1[3] + param->matrix[2][1]*rgb_ptr1[4] + param->matrix[2][2]*rgb_ptr1[5]; + y_ptr1[1]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr2[0] + param->matrix[0][1]*rgb_ptr2[1] + param->matrix[0][2]*rgb_ptr2[2]; + u_tmp += param->matrix[1][0]*rgb_ptr2[0] + param->matrix[1][1]*rgb_ptr2[1] + param->matrix[1][2]*rgb_ptr2[2]; + v_tmp += param->matrix[2][0]*rgb_ptr2[0] + param->matrix[2][1]*rgb_ptr2[1] + param->matrix[2][2]*rgb_ptr2[2]; + y_ptr2[0]=clampU8(y_tmp+((param->y_shift)<matrix[0][0]*rgb_ptr2[3] + param->matrix[0][1]*rgb_ptr2[4] + param->matrix[0][2]*rgb_ptr2[5]; + u_tmp += param->matrix[1][0]*rgb_ptr2[3] + param->matrix[1][1]*rgb_ptr2[4] + param->matrix[1][2]*rgb_ptr2[5]; + v_tmp += param->matrix[2][0]*rgb_ptr2[3] + param->matrix[2][1]*rgb_ptr2[4] + param->matrix[2][2]*rgb_ptr2[5]; + y_ptr2[1]=clampU8(y_tmp+((param->y_shift)<*/ + +#include "yuv_rgb_common.h" + +// yuv to rgb, standard c implementation +void yuv420_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv420_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuv422_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb565_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgb24_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_rgba_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_bgra_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_argb_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvnv12_abgr_std( + uint32_t width, uint32_t height, + const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +void yuvp010_xbgr2101010_std( + uint32_t width, uint32_t height, + const uint16_t *y, const uint16_t *u, const uint16_t *v, uint32_t y_stride, uint32_t uv_stride, + uint8_t *rgb, uint32_t rgb_stride, + YCbCrType yuv_type); + +// rgb to yuv, standard c implementation +void rgb24_yuv420_std( + uint32_t width, uint32_t height, + const uint8_t *rgb, uint32_t rgb_stride, + uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride, + YCbCrType yuv_type); diff --git a/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std_func.h b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std_func.h new file mode 100644 index 0000000..8091ea9 --- /dev/null +++ b/contrib/SDL-3.2.8/src/video/yuv2rgb/yuv_rgb_std_func.h @@ -0,0 +1,271 @@ +// Copyright 2016 Adrien Descamps +// Distributed under BSD 3-Clause License + +/* You need to define the following macros before including this file: + STD_FUNCTION_NAME + YUV_FORMAT + RGB_FORMAT +*/ + +#if RGB_FORMAT == RGB_FORMAT_RGB565 + +#define PACK_PIXEL(rgb_ptr) \ + *(Uint16 *)rgb_ptr = \ + ((((Uint16)clampU8(y_tmp+r_tmp)) << 8 ) & 0xF800) | \ + ((((Uint16)clampU8(y_tmp+g_tmp)) << 3) & 0x07E0) | \ + (((Uint16)clampU8(y_tmp+b_tmp)) >> 3); \ + rgb_ptr += 2; \ + +#elif RGB_FORMAT == RGB_FORMAT_RGB24 + +#define PACK_PIXEL(rgb_ptr) \ + rgb_ptr[0] = clampU8(y_tmp+r_tmp); \ + rgb_ptr[1] = clampU8(y_tmp+g_tmp); \ + rgb_ptr[2] = clampU8(y_tmp+b_tmp); \ + rgb_ptr += 3; \ + +#elif RGB_FORMAT == RGB_FORMAT_RGBA + +#define PACK_PIXEL(rgb_ptr) \ + *(Uint32 *)rgb_ptr = \ + (((Uint32)clampU8(y_tmp+r_tmp)) << 24) | \ + (((Uint32)clampU8(y_tmp+g_tmp)) << 16) | \ + (((Uint32)clampU8(y_tmp+b_tmp)) << 8) | \ + 0x000000FF; \ + rgb_ptr += 4; \ + +#elif RGB_FORMAT == RGB_FORMAT_BGRA + +#define PACK_PIXEL(rgb_ptr) \ + *(Uint32 *)rgb_ptr = \ + (((Uint32)clampU8(y_tmp+b_tmp)) << 24) | \ + (((Uint32)clampU8(y_tmp+g_tmp)) << 16) | \ + (((Uint32)clampU8(y_tmp+r_tmp)) << 8) | \ + 0x000000FF; \ + rgb_ptr += 4; \ + +#elif RGB_FORMAT == RGB_FORMAT_ARGB + +#define PACK_PIXEL(rgb_ptr) \ + *(Uint32 *)rgb_ptr = \ + 0xFF000000 | \ + (((Uint32)clampU8(y_tmp+r_tmp)) << 16) | \ + (((Uint32)clampU8(y_tmp+g_tmp)) << 8) | \ + (((Uint32)clampU8(y_tmp+b_tmp)) << 0); \ + rgb_ptr += 4; \ + +#elif RGB_FORMAT == RGB_FORMAT_ABGR + +#define PACK_PIXEL(rgb_ptr) \ + *(Uint32 *)rgb_ptr = \ + 0xFF000000 | \ + (((Uint32)clampU8(y_tmp+b_tmp)) << 16) | \ + (((Uint32)clampU8(y_tmp+g_tmp)) << 8) | \ + (((Uint32)clampU8(y_tmp+r_tmp)) << 0); \ + rgb_ptr += 4; \ + +#elif RGB_FORMAT == RGB_FORMAT_XBGR2101010 + +#define PACK_PIXEL(rgb_ptr) \ + *(Uint32 *)rgb_ptr = \ + 0xC0000000 | \ + (((Uint32)clamp10(y_tmp+b_tmp)) << 20) | \ + (((Uint32)clamp10(y_tmp+g_tmp)) << 10) | \ + (((Uint32)clamp10(y_tmp+r_tmp)) << 0); \ + rgb_ptr += 4; \ + +#else +#error PACK_PIXEL unimplemented +#endif + + +#ifdef _MSC_VER /* Visual Studio analyzer can't tell that we're building this with different constants */ +#pragma warning(push) +#pragma warning(disable : 6239) +#endif + +#undef YUV_TYPE +#if YUV_BITS > 8 +#define YUV_TYPE uint16_t +#else +#define YUV_TYPE uint8_t +#endif +#undef UV_OFFSET +#define UV_OFFSET (1 << ((YUV_BITS)-1)) + +#undef GET +#if YUV_BITS == 10 +#define GET(X) ((X) >> 6) +#else +#define GET(X) (X) +#endif + +void STD_FUNCTION_NAME( + uint32_t width, uint32_t height, + const YUV_TYPE *Y, const YUV_TYPE *U, const YUV_TYPE *V, uint32_t Y_stride, uint32_t UV_stride, + uint8_t *RGB, uint32_t RGB_stride, + YCbCrType yuv_type) +{ + const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]); +#if YUV_FORMAT == YUV_FORMAT_420 + #define y_pixel_stride 1 + #define uv_pixel_stride 1 + #define uv_x_sample_interval 2 + #define uv_y_sample_interval 2 +#elif YUV_FORMAT == YUV_FORMAT_422 + #define y_pixel_stride 2 + #define uv_pixel_stride 4 + #define uv_x_sample_interval 2 + #define uv_y_sample_interval 1 +#elif YUV_FORMAT == YUV_FORMAT_NV12 + #define y_pixel_stride 1 + #define uv_pixel_stride 2 + #define uv_x_sample_interval 2 + #define uv_y_sample_interval 2 +#endif + + Y_stride /= sizeof(YUV_TYPE); + UV_stride /= sizeof(YUV_TYPE); + + uint32_t x, y; + for(y=0; y<(height-(uv_y_sample_interval-1)); y+=uv_y_sample_interval) + { + const YUV_TYPE *y_ptr1=Y+y*Y_stride, + *u_ptr=U+(y/uv_y_sample_interval)*UV_stride, + *v_ptr=V+(y/uv_y_sample_interval)*UV_stride; + + #if uv_y_sample_interval > 1 + const YUV_TYPE *y_ptr2=Y+(y+1)*Y_stride; + #endif + + uint8_t *rgb_ptr1=RGB+y*RGB_stride; + + #if uv_y_sample_interval > 1 + uint8_t *rgb_ptr2=RGB+(y+1)*RGB_stride; + #endif + + for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval) + { + // Compute U and V contributions, common to the four pixels + + int32_t u_tmp = (GET(*u_ptr)-UV_OFFSET); + int32_t v_tmp = (GET(*v_ptr)-UV_OFFSET); + + int32_t r_tmp = (v_tmp*param->v_r_factor); + int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); + int32_t b_tmp = (u_tmp*param->u_b_factor); + + // Compute the Y contribution for each pixel + + int32_t y_tmp = (GET(y_ptr1[0]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr1); + + y_tmp = (GET(y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr1); + + #if uv_y_sample_interval > 1 + y_tmp = (GET(y_ptr2[0]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr2); + + y_tmp = (GET(y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr2); + #endif + + y_ptr1+=2*y_pixel_stride; + #if uv_y_sample_interval > 1 + y_ptr2+=2*y_pixel_stride; + #endif + u_ptr+=2*uv_pixel_stride/uv_x_sample_interval; + v_ptr+=2*uv_pixel_stride/uv_x_sample_interval; + } + + /* Catch the last pixel, if needed */ + if (uv_x_sample_interval == 2 && x == (width-1)) + { + // Compute U and V contributions, common to the four pixels + + int32_t u_tmp = (GET(*u_ptr)-UV_OFFSET); + int32_t v_tmp = (GET(*v_ptr)-UV_OFFSET); + + int32_t r_tmp = (v_tmp*param->v_r_factor); + int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); + int32_t b_tmp = (u_tmp*param->u_b_factor); + + // Compute the Y contribution for each pixel + + int32_t y_tmp = (GET(y_ptr1[0]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr1); + + #if uv_y_sample_interval > 1 + y_tmp = (GET(y_ptr2[0]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr2); + #endif + } + } + + /* Catch the last line, if needed */ + if (uv_y_sample_interval == 2 && y == (height-1)) + { + const YUV_TYPE *y_ptr1=Y+y*Y_stride, + *u_ptr=U+(y/uv_y_sample_interval)*UV_stride, + *v_ptr=V+(y/uv_y_sample_interval)*UV_stride; + + uint8_t *rgb_ptr1=RGB+y*RGB_stride; + + for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval) + { + // Compute U and V contributions, common to the four pixels + + int32_t u_tmp = (GET(*u_ptr)-UV_OFFSET); + int32_t v_tmp = (GET(*v_ptr)-UV_OFFSET); + + int32_t r_tmp = (v_tmp*param->v_r_factor); + int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); + int32_t b_tmp = (u_tmp*param->u_b_factor); + + // Compute the Y contribution for each pixel + + int32_t y_tmp = (GET(y_ptr1[0]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr1); + + y_tmp = (GET(y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr1); + + y_ptr1+=2*y_pixel_stride; + u_ptr+=2*uv_pixel_stride/uv_x_sample_interval; + v_ptr+=2*uv_pixel_stride/uv_x_sample_interval; + } + + /* Catch the last pixel, if needed */ + if (uv_x_sample_interval == 2 && x == (width-1)) + { + // Compute U and V contributions, common to the four pixels + + int32_t u_tmp = (GET(*u_ptr)-UV_OFFSET); + int32_t v_tmp = (GET(*v_ptr)-UV_OFFSET); + + int32_t r_tmp = (v_tmp*param->v_r_factor); + int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor); + int32_t b_tmp = (u_tmp*param->u_b_factor); + + // Compute the Y contribution for each pixel + + int32_t y_tmp = (GET(y_ptr1[0]-param->y_shift)*param->y_factor); + PACK_PIXEL(rgb_ptr1); + } + } + + #undef y_pixel_stride + #undef uv_pixel_stride + #undef uv_x_sample_interval + #undef uv_y_sample_interval +} + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + +#undef STD_FUNCTION_NAME +#undef YUV_FORMAT +#undef RGB_FORMAT +#undef PACK_PIXEL -- cgit v1.2.3